From 967fbbc49efa5607ff171ee5ec7daef5a990fc4f Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 1 Jun 2021 09:56:04 +0200 Subject: [PATCH] glgsg: Fix regression uploading buffer texture with null image Regression in c1babd1ad157b16f0a8d63b21d303e82c48489f4 - it caused an assertion to be thrown when uploading a buffer texture without a RAM image. --- .../glstuff/glGraphicsStateGuardian_src.cxx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 674962ff4f..04ffe9b94c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -12846,22 +12846,23 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { image = tex->get_uncompressed_ram_image(); } + bool is_buffer_texture = tex->get_texture_type() == Texture::TT_buffer_texture; + Texture::CompressionMode image_compression; if (image.is_null()) { image_compression = Texture::CM_off; } else { image_compression = tex->get_ram_image_compression(); - } - bool is_buffer_texture = tex->get_texture_type() == Texture::TT_buffer_texture; - if (is_buffer_texture || - !get_supports_compressed_texture_format(image_compression)) { - image = tex->get_uncompressed_ram_image(); - image_compression = Texture::CM_off; + if (is_buffer_texture || + !get_supports_compressed_texture_format(image_compression)) { + image = tex->get_uncompressed_ram_image(); + image_compression = Texture::CM_off; - // If this triggers, Panda cannot decompress the texture. Compile with - // libsquish support or precompress the texture. - nassertr(!image.is_null(), false); + // If this triggers, Panda cannot decompress the texture. Compile with + // libsquish support or precompress the texture. + nassertr(!image.is_null(), false); + } } int mipmap_bias = 0;