From 4e42170aae844e6eade2fd893b23f3c2285c5ff3 Mon Sep 17 00:00:00 2001 From: Rye Mutt <rye@alchemyviewer.org> Date: Sun, 1 Oct 2023 00:27:01 -0400 Subject: [PATCH] Add cubemap array textures to video memory tracking --- indra/llrender/llcubemaparray.cpp | 5 +++++ indra/llrender/llimagegl.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp index 7d3a92237b4..0d8aae6e300 100644 --- a/indra/llrender/llcubemaparray.cpp +++ b/indra/llrender/llcubemaparray.cpp @@ -42,6 +42,9 @@ //#pragma optimize("", off) +// tex mem tracking +extern void alloc_tex_image(U32 width, U32 height, U32 pixformat, U32 count); + // MUST match order of OpenGL face-layers GLenum LLCubeMapArray::sTargets[6] = { @@ -139,6 +142,8 @@ void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count, BOOL us ++mip; } + alloc_tex_image(resolution, resolution, format, count * 6); + mImage->setAddressMode(LLTexUnit::TAM_CLAMP); if (use_mips) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index fa54d4de26b..c7cbe9b62c0 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -63,11 +63,12 @@ static U64 sTextureBytes = 0; // track a texture alloc on the currently bound texture. // asserts that no currently tracked alloc exists -static void alloc_tex_image(U32 width, U32 height, U32 pixformat) +void alloc_tex_image(U32 width, U32 height, U32 pixformat, U32 count) { U32 texUnit = gGL.getCurrentTexUnitIndex(); U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture(); U64 size = LLImageGL::dataFormatBytes(pixformat, width, height); + size *= count; llassert(size >= 0); @@ -285,7 +286,10 @@ S32 LLImageGL::dataFormatBits(S32 dataformat) case GL_RGB: return 24; case GL_SRGB: return 24; case GL_RGB8: return 24; + case GL_RGB16F: return 48; case GL_RGBA: return 32; + case GL_RGBA8: return 32; + case GL_RGBA16F: return 64; case GL_SRGB_ALPHA: return 32; case GL_BGRA: return 32; // Used for QuickTime media textures on the Mac case GL_DEPTH_COMPONENT: return 24; @@ -1532,7 +1536,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt sub_image_lines(target, miplevel, 0, 0, width, height, pixformat, pixtype, src, width); } } - alloc_tex_image(width, height, pixformat); + alloc_tex_image(width, height, pixformat, 1); } stop_glerror(); } -- GitLab