Skip to content

Commit 2b5d7aa

Browse files
committed
tr_image: add some GL format checks and asserts
1 parent 3ad1a2d commit 2b5d7aa

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
@@ -1178,6 +1178,29 @@ void R_UploadImage( const char *name, const byte **dataArray, int numLayers, int
11781178
}
11791179
}
11801180

1181+
// Make sure we prefer GL_R8 when ARB_texture_rg is available.
1182+
ASSERT( !( internalFormat == GL_RED && glConfig.textureRGAvailable ) );
1183+
// Make sure we only use GL_R8 when ARB_texture_rg is available.
1184+
ASSERT( !( internalFormat == GL_R8 && !glConfig.textureRGAvailable ) );
1185+
// Make sure we only use GL_RG8 when ARB_texture_rg is available.
1186+
ASSERT( !( internalFormat == GL_RG8 && !glConfig.textureRGAvailable ) );
1187+
// Make sure we only use GL_SR8_EXT when EXT_texture_sRGB_R8 is available.
1188+
ASSERT( !( internalFormat == GL_R8 && isSRGB && !glConfig.textureSrgbR8Available ) );
1189+
// Make sure we only use GL_SRG8_EXT when EXT_texture_sRGB_RG8 is available.
1190+
ASSERT( !( internalFormat == GL_RG8 && isSRGB && !glConfig.textureSrgbRG8Available ) );
1191+
1192+
// Make sure we prefer GL_RGB but don't enforce it. GL_RGB 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_RGB for image %s", name );
1196+
}
1197+
1198+
// Make sure we prefer GL_RGBA but don't enforce it. GL_RGBA is used when we don't set a format.
1199+
if ( internalFormat == GL_RGBA )
1200+
{
1201+
Log::Warn( "An explicit format should be used instead of GL_RGBA for image %s", name );
1202+
}
1203+
11811204
Log::Debug( "Uploading image %s (%d×%d, %d layers, %0#x type, %0#x format)", name, scaledWidth, scaledHeight, numLayers, image->type, internalFormat );
11821205

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

0 commit comments

Comments
 (0)