From eaa043c3ff640be92472b1533bebf4cd5563e52d Mon Sep 17 00:00:00 2001 From: niki Date: Tue, 20 Sep 2022 12:36:56 +0200 Subject: [PATCH] vulkan: report approximate used texture memory --- src/modules/graphics/vulkan/Texture.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/modules/graphics/vulkan/Texture.cpp b/src/modules/graphics/vulkan/Texture.cpp index 1d28b62a0..74e21829a 100644 --- a/src/modules/graphics/vulkan/Texture.cpp +++ b/src/modules/graphics/vulkan/Texture.cpp @@ -187,6 +187,20 @@ bool Texture::loadVolatile() } } + int64 memsize = 0; + + for (int mip = 0; mip < getMipmapCount(); mip++) + { + int w = getPixelWidth(mip); + int h = getPixelHeight(mip); + int slices = getDepth(mip) * layerCount; + memsize += getPixelFormatSliceSize(format, w, h) * slices; + } + + memsize *= static_cast(msaaSamples); + + setGraphicsMemorySize(memsize); + return true; } @@ -210,6 +224,8 @@ void Texture::unloadVolatile() }); textureImage = VK_NULL_HANDLE; + + setGraphicsMemorySize(0); } Texture::~Texture()