From c1babd1ad157b16f0a8d63b21d303e82c48489f4 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 29 Apr 2021 20:33:52 +0200 Subject: [PATCH] texture: Don't try to compress buffer textures by default Buffer textures don't support compression, so we shouldn't try to driver-compress them, and we should not try to compress the RAM image unless explicitly overridden. --- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 9 ++++++--- panda/src/gobj/texture.cxx | 13 +++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index e97755acc2..674962ff4f 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -9797,7 +9797,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const { bool is_3d = (texture_type == Texture::TT_3d_texture || texture_type == Texture::TT_2d_texture_array); - if (get_supports_compressed_texture_format(compression)) { + if (get_supports_compressed_texture_format(compression) && + texture_type != Texture::TT_buffer_texture) { switch (compression) { case Texture::CM_on: // The user asked for just generic compression. OpenGL supports @@ -12852,7 +12853,9 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { image_compression = tex->get_ram_image_compression(); } - if (!get_supports_compressed_texture_format(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; @@ -12870,7 +12873,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) { // If we'll use immutable texture storage, we have to pick a sized image // format. bool force_sized = (gl_immutable_texture_storage && _supports_tex_storage) || - (tex->get_texture_type() == Texture::TT_buffer_texture); + (is_buffer_texture); GLint internal_format = get_internal_image_format(tex, force_sized); GLint external_format = get_external_image_format(tex); diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 8d4756fee4..d6c30296d9 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -5866,7 +5866,12 @@ do_consider_auto_process_ram_image(CData *cdata, bool generate_mipmaps, if (allow_compression && !driver_compress_textures) { CompressionMode compression = cdata->_compression; if (compression == CM_default && compressed_textures) { - compression = CM_on; + if (cdata->_texture_type == Texture::TT_buffer_texture) { + compression = CM_off; + } + else { + compression = CM_on; + } } if (compression != CM_off && cdata->_ram_image_compression == CM_off) { GraphicsStateGuardianBase *gsg = GraphicsStateGuardianBase::get_default_gsg(); @@ -7249,7 +7254,11 @@ do_set_quality_level(CData *cdata, Texture::QualityLevel quality_level) { bool Texture:: do_has_compression(const CData *cdata) const { if (cdata->_compression == CM_default) { - return compressed_textures; + if (cdata->_texture_type != Texture::TT_buffer_texture) { + return compressed_textures; + } else { + return false; + } } else { return (cdata->_compression != CM_off); }