Skip to content

Commit 9ef2aa9

Browse files
committed
tr_image: add some GL format checks and asserts
1 parent ee1be9d commit 9ef2aa9

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
@@ -1167,6 +1167,29 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
11671167
}
11681168
}
11691169

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

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

0 commit comments

Comments
 (0)