Browse Source

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.
rdb 4 years ago
parent
commit
c1babd1ad1
2 changed files with 17 additions and 5 deletions
  1. 6 3
      panda/src/glstuff/glGraphicsStateGuardian_src.cxx
  2. 11 2
      panda/src/gobj/texture.cxx

+ 6 - 3
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 ||
   bool is_3d = (texture_type == Texture::TT_3d_texture ||
                 texture_type == Texture::TT_2d_texture_array);
                 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) {
     switch (compression) {
     case Texture::CM_on:
     case Texture::CM_on:
       // The user asked for just generic compression.  OpenGL supports
       // 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();
     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 = tex->get_uncompressed_ram_image();
     image_compression = Texture::CM_off;
     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
   // If we'll use immutable texture storage, we have to pick a sized image
   // format.
   // format.
   bool force_sized = (gl_immutable_texture_storage && _supports_tex_storage) ||
   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 internal_format = get_internal_image_format(tex, force_sized);
   GLint external_format = get_external_image_format(tex);
   GLint external_format = get_external_image_format(tex);

+ 11 - 2
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) {
   if (allow_compression && !driver_compress_textures) {
     CompressionMode compression = cdata->_compression;
     CompressionMode compression = cdata->_compression;
     if (compression == CM_default && compressed_textures) {
     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) {
     if (compression != CM_off && cdata->_ram_image_compression == CM_off) {
       GraphicsStateGuardianBase *gsg = GraphicsStateGuardianBase::get_default_gsg();
       GraphicsStateGuardianBase *gsg = GraphicsStateGuardianBase::get_default_gsg();
@@ -7249,7 +7254,11 @@ do_set_quality_level(CData *cdata, Texture::QualityLevel quality_level) {
 bool Texture::
 bool Texture::
 do_has_compression(const CData *cdata) const {
 do_has_compression(const CData *cdata) const {
   if (cdata->_compression == CM_default) {
   if (cdata->_compression == CM_default) {
-    return compressed_textures;
+    if (cdata->_texture_type != Texture::TT_buffer_texture) {
+      return compressed_textures;
+    } else {
+      return false;
+    }
   } else {
   } else {
     return (cdata->_compression != CM_off);
     return (cdata->_compression != CM_off);
   }
   }