mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-17 12:18:01 -05:00
Garbage Collection: Redesign the algorithm to do a better use of memory.
This commit is contained in:
@ -484,6 +484,15 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager&
|
||||
rescale_read_fbos[i].Create();
|
||||
}
|
||||
}
|
||||
|
||||
device_access_memory = []() -> u64 {
|
||||
if (GLAD_GL_NVX_gpu_memory_info) {
|
||||
GLint cur_avail_mem_kb = 0;
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &cur_avail_mem_kb);
|
||||
return static_cast<u64>(cur_avail_mem_kb) * 1_KiB;
|
||||
}
|
||||
return 2_GiB; // Return minimum requirements
|
||||
}();
|
||||
}
|
||||
|
||||
TextureCacheRuntime::~TextureCacheRuntime() = default;
|
||||
@ -500,13 +509,13 @@ ImageBufferMap TextureCacheRuntime::DownloadStagingBuffer(size_t size) {
|
||||
return download_buffers.RequestMap(size, false);
|
||||
}
|
||||
|
||||
u64 TextureCacheRuntime::GetDeviceLocalMemory() const {
|
||||
u64 TextureCacheRuntime::GetDeviceMemoryUsage() const {
|
||||
if (GLAD_GL_NVX_gpu_memory_info) {
|
||||
GLint cur_avail_mem_kb = 0;
|
||||
glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &cur_avail_mem_kb);
|
||||
return static_cast<u64>(cur_avail_mem_kb) * 1_KiB;
|
||||
}
|
||||
return 2_GiB; // Return minimum requirements
|
||||
return 2_GiB;
|
||||
}
|
||||
|
||||
void TextureCacheRuntime::CopyImage(Image& dst_image, Image& src_image,
|
||||
@ -686,6 +695,7 @@ Image::Image(TextureCacheRuntime& runtime_, const VideoCommon::ImageInfo& info_,
|
||||
}
|
||||
if (IsConverted(runtime->device, info.format, info.type)) {
|
||||
flags |= ImageFlagBits::Converted;
|
||||
flags |= ImageFlagBits::GCProtected;
|
||||
gl_internal_format = IsPixelFormatSRGB(info.format) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
||||
gl_format = GL_RGBA;
|
||||
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
||||
|
@ -83,7 +83,15 @@ public:
|
||||
|
||||
ImageBufferMap DownloadStagingBuffer(size_t size);
|
||||
|
||||
u64 GetDeviceLocalMemory() const;
|
||||
u64 GetDeviceLocalMemory() const {
|
||||
return device_access_memory;
|
||||
}
|
||||
|
||||
u64 GetDeviceMemoryUsage() const;
|
||||
|
||||
bool CanReportMemoryUsage() const {
|
||||
return GLAD_GL_NVX_gpu_memory_info;
|
||||
}
|
||||
|
||||
bool ShouldReinterpret([[maybe_unused]] Image& dst, [[maybe_unused]] Image& src) {
|
||||
return true;
|
||||
@ -172,6 +180,7 @@ private:
|
||||
std::array<OGLFramebuffer, 4> rescale_draw_fbos;
|
||||
std::array<OGLFramebuffer, 4> rescale_read_fbos;
|
||||
const Settings::ResolutionScalingInfo& resolution;
|
||||
u64 device_access_memory;
|
||||
};
|
||||
|
||||
class Image : public VideoCommon::ImageBase {
|
||||
|
Reference in New Issue
Block a user