Skip to content

Commit f1f3f52

Browse files
committed
tr_image: add some GL format checks and asserts
1 parent 1482624 commit f1f3f52

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/engine/renderer/tr_image.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,29 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
11721172
}
11731173
}
11741174

1175+
// Make sure we prefer GL_R8 when ARB_texture_rg is available.
1176+
ASSERT( !( internalFormat == GL_RED && glConfig.textureRGAvailable ) );
1177+
// Make sure we only use GL_R8 when ARB_texture_rg is available.
1178+
ASSERT( !( internalFormat == GL_R8 && !glConfig.textureRGAvailable ) );
1179+
// Make sure we only use GL_RG8 when ARB_texture_rg is available.
1180+
ASSERT( !( internalFormat == GL_RG8 && !glConfig.textureRGAvailable ) );
1181+
// Make sure we only use GL_SR8_EXT when EXT_texture_sRGB_R8 is available.
1182+
ASSERT( !( internalFormat == GL_R8 && isSRGB && !glConfig.textureSrgbR8Available ) );
1183+
// Make sure we only use GL_SRG8_EXT when EXT_texture_sRGB_RG8 is available.
1184+
ASSERT( !( internalFormat == GL_RG8 && isSRGB && !glConfig.textureSrgbRG8Available ) );
1185+
1186+
// Make sure we prefer GL_RGB but don't enforce it. GL_RGB is used when we don't set a format.
1187+
if ( internalFormat == GL_RGBA )
1188+
{
1189+
Log::Warn( "An explicit format should be used instead of GL_RGB for image %s", name );
1190+
}
1191+
1192+
// Make sure we prefer GL_RGBA but don't enforce it. GL_RGBA is used when we don't set a format.
1193+
if ( internalFormat == GL_RGBA )
1194+
{
1195+
Log::Warn( "An explicit format should be used instead of GL_RGBA for image %s", name );
1196+
}
1197+
11751198
Log::Debug( "Uploading image %s (%d×%d, %d layers, %0#x type, %0#x format)", name, scaledWidth, scaledHeight, numLayers, image->type, internalFormat );
11761199

11771200
// 3D textures are uploaded in slices via glTexSubImage3D,

0 commit comments

Comments
 (0)