From a738b2a50bc6384d710315333098c105f498522e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 6 Oct 2023 19:24:02 +0300 Subject: [PATCH] ref: restore missing PARM_TEX_MEMORY RenderAPI parameter --- ref/gl/gl_context.c | 2 ++ ref/gl/gl_image.c | 19 ++++++++++++++++++- ref/gl/gl_local.h | 1 + ref/soft/r_context.c | 2 ++ ref/soft/r_image.c | 17 +++++++++++++++++ ref/soft/r_local.h | 2 ++ 6 files changed, 42 insertions(+), 1 deletion(-) diff --git a/ref/gl/gl_context.c b/ref/gl/gl_context.c index cd71ce43..5e35659c 100644 --- a/ref/gl/gl_context.c +++ b/ref/gl/gl_context.c @@ -212,6 +212,8 @@ static int GL_RefGetParm( int parm, int arg ) case PARM_TEX_FLAGS: glt = R_GetTexture( arg ); return glt->flags; + case PARM_TEX_MEMORY: + return GL_TexMemory(); case PARM_ACTIVE_TMU: return glState.activeTMU; case PARM_LIGHTSTYLEVALUE: diff --git a/ref/gl/gl_image.c b/ref/gl/gl_image.c index 737ba49f..ffe9411d 100644 --- a/ref/gl/gl_image.c +++ b/ref/gl/gl_image.c @@ -1607,7 +1607,7 @@ int GL_LoadTextureArray( const char **names, int flags ) len += ret; } - + COM_FileBase( names[i], basename, sizeof( basename )); ret = Q_snprintf( &name[len], sizeof( name ) - len, "%s[%i]", basename, numLayers ); @@ -1943,6 +1943,23 @@ void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor ) gEngfuncs.FS_FreeImage( pic ); } +/* +================ +GL_TexMemory + +return size of all uploaded textures +================ +*/ +int GL_TexMemory( void ) +{ + int i, total = 0; + + for( i = 0; i < gl_numTextures; i++ ) + total += gl_textures[i].size; + + return total; +} + /* ============================================================================== diff --git a/ref/gl/gl_local.h b/ref/gl/gl_local.h index f53f4561..bddfc307 100644 --- a/ref/gl/gl_local.h +++ b/ref/gl/gl_local.h @@ -366,6 +366,7 @@ void R_InitDlightTexture( void ); void R_TextureList_f( void ); void R_InitImages( void ); void R_ShutdownImages( void ); +int GL_TexMemory( void ); // // gl_rlight.c diff --git a/ref/soft/r_context.c b/ref/soft/r_context.c index 6ab73ae2..ece7fb64 100644 --- a/ref/soft/r_context.c +++ b/ref/soft/r_context.c @@ -147,6 +147,8 @@ static int GL_RefGetParm( int parm, int arg ) case PARM_TEX_FLAGS: glt = R_GetTexture( arg ); return glt->flags; + case PARM_TEX_MEMORY: + return R_TexMemory(); case PARM_ACTIVE_TMU: return 0; //glState.activeTMU; case PARM_LIGHTSTYLEVALUE: diff --git a/ref/soft/r_image.c b/ref/soft/r_image.c index b02437c9..933e8cf7 100644 --- a/ref/soft/r_image.c +++ b/ref/soft/r_image.c @@ -1199,6 +1199,23 @@ void GAME_EXPORT GL_ProcessTexture( int texnum, float gamma, int topColor, int b gEngfuncs.FS_FreeImage( pic ); } +/* +================ +R_TexMemory + +return size of all uploaded textures +================ +*/ +int R_TexMemory( void ) +{ + int i, total = 0; + + for( i = 0; i < r_numImages; i++ ) + total += r_images[i].size; + + return total; +} + /* ============================================================================== diff --git a/ref/soft/r_local.h b/ref/soft/r_local.h index 7a465db1..d4e132df 100644 --- a/ref/soft/r_local.h +++ b/ref/soft/r_local.h @@ -448,6 +448,8 @@ void R_InitDlightTexture( void ); void R_TextureList_f( void ); void R_InitImages( void ); void R_ShutdownImages( void ); +int R_TexMemory( void ); + #if 1 // // gl_rlight.c