Skip to content

Commit

Permalink
renderer: add more debug log about image creation
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Oct 3, 2024
1 parent 7e8c832 commit 0407cd8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/engine/renderer/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6777,7 +6777,8 @@ void R_BuildCubeMaps()
}

// build the cubemap
cubeProbe->cubemap = R_AllocImage( Str::Format( "_autoCube%d", i ).c_str(), false );
std::string name = Str::Format( "_autoCube%d", i );
cubeProbe->cubemap = R_AllocImage( name.c_str(), false );

if ( !cubeProbe->cubemap )
{
Expand All @@ -6795,7 +6796,7 @@ void R_BuildCubeMaps()

imageParams_t imageParams = {};

R_UploadImage( ( const byte ** ) tr.cubeTemp, 6, 1, cubeProbe->cubemap, imageParams );
R_UploadImage( name.c_str(), ( const byte ** ) tr.cubeTemp, 6, 1, cubeProbe->cubemap, imageParams );
}

r_gpuOcclusionCulling.Set( gpuOcclusionCulling );
Expand Down
14 changes: 10 additions & 4 deletions src/engine/renderer/tr_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ level 1 has only numLayers/2 layers. There are still numLayers pointers in
the dataArray for every mip level, the unneeded elements at the end aren't used.
===============
*/
void R_UploadImage( const byte **dataArray, int numLayers, int numMips, image_t *image, const imageParams_t &imageParams )
void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int numMips, image_t *image, const imageParams_t &imageParams )
{
const byte *data;
byte *scaledBuffer = nullptr;
Expand Down Expand Up @@ -1022,6 +1022,8 @@ void R_UploadImage( const byte **dataArray, int numLayers, int numMips, image_t
}
}

Log::Debug( "Uploading image %s (%d×%d, %d layers, %0#x type, %0#x format)", name, scaledWidth, scaledHeight, numLayers, image->type, internalFormat );

// 3D textures are uploaded in slices via glTexSubImage3D,
// so the storage has to be allocated before the loop
if( image->type == GL_TEXTURE_3D ) {
Expand Down Expand Up @@ -1348,6 +1350,8 @@ R_AllocImage
*/
image_t *R_AllocImage( const char *name, bool linkIntoHashTable )
{
Log::Debug( "Allocating image %s", name );

image_t *image;
unsigned hash;

Expand Down Expand Up @@ -1405,6 +1409,8 @@ R_CreateImage
*/
image_t *R_CreateImage( const char *name, const byte **pic, int width, int height, int numMips, const imageParams_t &imageParams )
{
Log::Debug( "Creating image %s (%d×%d, %d mips)", name, width, height, numMips );

image_t *image;

image = R_AllocImage( name, true );
Expand All @@ -1424,7 +1430,7 @@ image_t *R_CreateImage( const char *name, const byte **pic, int width, int heigh
image->filterType = imageParams.filterType;
image->wrapType = imageParams.wrapType;

R_UploadImage( pic, 1, numMips, image, imageParams );
R_UploadImage( name, pic, 1, numMips, image, imageParams );

if( r_exportTextures->integer ) {
R_ExportTexture( image );
Expand Down Expand Up @@ -1505,7 +1511,7 @@ image_t *R_CreateCubeImage( const char *name, const byte *pic[ 6 ], int width, i
image->filterType = imageParams.filterType;
image->wrapType = imageParams.wrapType;

R_UploadImage( pic, 6, 1, image, imageParams );
R_UploadImage( name, pic, 6, 1, image, imageParams );

if( r_exportTextures->integer ) {
R_ExportTexture( image );
Expand Down Expand Up @@ -1552,7 +1558,7 @@ image_t *R_Create3DImage( const char *name, const byte *pic, int width, int heig
image->filterType = imageParams.filterType;
image->wrapType = imageParams.wrapType;

R_UploadImage( pics, numLayers, 1, image, imageParams );
R_UploadImage( name, pics, numLayers, 1, image, imageParams );

if( pics ) {
ri.Hunk_FreeTempMemory( pics );
Expand Down
2 changes: 1 addition & 1 deletion src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ inline bool checkGLErrors()
qhandle_t RE_GenerateTexture( const byte *pic, int width, int height );

image_t *R_AllocImage( const char *name, bool linkIntoHashTable );
void R_UploadImage( const byte **dataArray, int numLayers, int numMips, image_t *image, const imageParams_t &imageParams );
void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int numMips, image_t *image, const imageParams_t &imageParams );

void RE_GetTextureSize( int textureID, int *width, int *height );

Expand Down

0 comments on commit 0407cd8

Please sign in to comment.