summaryrefslogtreecommitdiff
path: root/indra/llrender/llimagegl.cpp
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-08-21 10:47:31 -0400
committerGitHub <noreply@github.com>2024-08-21 09:47:31 -0500
commitdb84bf9567c27e266ccc6b1b6aed089c6022fe91 (patch)
treebcf9edf9968e4087621a9e55ea02743671b45c12 /indra/llrender/llimagegl.cpp
parenta0da63db57b4799cf67df4618afe70760840a719 (diff)
Improve accuracy of texture memory tracking (#2371)
* Fix alloc_tex_image to account for more missing texture memory Change alloc_tex_image calls to pass internal format to properly account for used image type * Fix scaleDown passing primary format in place of internal format to glTexImage2D * Make texture debug view and texture bias calculation consistent and remove double accounting for render target textures
Diffstat (limited to 'indra/llrender/llimagegl.cpp')
-rw-r--r--indra/llrender/llimagegl.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp
index 058afa0cf2..0746e21079 100644
--- a/indra/llrender/llimagegl.cpp
+++ b/indra/llrender/llimagegl.cpp
@@ -67,11 +67,12 @@ static U64 sTextureBytes = 0;
// track a texture alloc on the currently bound texture.
// asserts that no currently tracked alloc exists
-void LLImageGLMemory::alloc_tex_image(U32 width, U32 height, U32 pixformat)
+void LLImageGLMemory::alloc_tex_image(U32 width, U32 height, U32 intformat, U32 count)
{
U32 texUnit = gGL.getCurrentTexUnitIndex();
U32 texName = gGL.getTexUnit(texUnit)->getCurrTexture();
- U64 size = LLImageGL::dataFormatBytes(pixformat, width, height);
+ U64 size = LLImageGL::dataFormatBytes(intformat, width, height);
+ size *= count;
llassert(size >= 0);
@@ -291,9 +292,13 @@ S32 LLImageGL::dataFormatBits(S32 dataformat)
case GL_SRGB: return 24;
case GL_RGB8: return 24;
case GL_RGBA: return 32;
+ case GL_RGBA8: return 32;
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;
+ case GL_DEPTH_COMPONENT24: return 24;
+ case GL_R16F: return 16;
+ case GL_RG16F: return 32;
case GL_RGB16F: return 48;
case GL_RGBA16F: return 64;
default:
@@ -1384,7 +1389,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, intformat, 1);
}
stop_glerror();
@@ -2370,11 +2375,11 @@ bool LLImageGL::scaleDown(S32 desired_discard)
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, temp_texname, true);
{
LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("scaleDown - glTexImage2D");
- glTexImage2D(mTarget, 0, mFormatPrimary, desired_width, desired_height, 0, mFormatPrimary, mFormatType, NULL);
+ glTexImage2D(mTarget, 0, mFormatInternal, desired_width, desired_height, 0, mFormatPrimary, mFormatType, NULL);
}
// account for new texture getting created
- alloc_tex_image(desired_width, desired_height, mFormatPrimary);
+ alloc_tex_image(desired_width, desired_height, mFormatInternal, 1);
// Use render-to-texture to scale down the texture
{
@@ -2428,10 +2433,10 @@ bool LLImageGL::scaleDown(S32 desired_discard)
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, sScratchPBO);
- glTexImage2D(mTarget, 0, mFormatPrimary, desired_width, desired_height, 0, mFormatPrimary, mFormatType, nullptr);
+ glTexImage2D(mTarget, 0, mFormatInternal, desired_width, desired_height, 0, mFormatPrimary, mFormatType, nullptr);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
- alloc_tex_image(desired_width, desired_height, mFormatPrimary);
+ alloc_tex_image(desired_width, desired_height, mFormatInternal, 1);
if (mHasMipMaps)
{