Mesa (master): intel: Handle arbitrary compressed formats in intel_compressed_num_bytes.

Eric Anholt anholt at kemper.freedesktop.org
Fri May 14 18:29:05 UTC 2010


Module: Mesa
Branch: master
Commit: 7554b83a21bd62b20df5a7327b69f08108ac9ab6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7554b83a21bd62b20df5a7327b69f08108ac9ab6

Author: Eric Anholt <eric at anholt.net>
Date:   Thu May 13 14:48:13 2010 -0700

intel: Handle arbitrary compressed formats in intel_compressed_num_bytes.

Note that we don't support arbitrary block size for compressed quite
yet -- block height of 4 is hard-coded all over the place.

Bug #27098 (srgb dxt1 producing a bytes per pixel of 0).

---

 src/mesa/drivers/dri/intel/intel_tex_format.c |   27 +++++++-----------------
 1 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c
index 7be5231..610a169 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_format.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_format.c
@@ -1,7 +1,7 @@
 #include "intel_context.h"
 #include "intel_tex.h"
 #include "main/enums.h"
-
+#include "main/formats.h"
 
 /**
  * Choose hardware texture format given the user's glTexImage parameters.
@@ -208,22 +208,11 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
 
 int intel_compressed_num_bytes(GLuint mesaFormat)
 {
-   int bytes = 0;
-   switch(mesaFormat) {
-     
-   case MESA_FORMAT_RGB_FXT1:
-   case MESA_FORMAT_RGBA_FXT1:
-   case MESA_FORMAT_RGB_DXT1:
-   case MESA_FORMAT_RGBA_DXT1:
-     bytes = 2;
-     break;
-     
-   case MESA_FORMAT_RGBA_DXT3:
-   case MESA_FORMAT_RGBA_DXT5:
-     bytes = 4;
-   default:
-     break;
-   }
-   
-   return bytes;
+   GLuint bw, bh;
+   GLuint block_size;
+
+   block_size = _mesa_get_format_bytes(mesaFormat);
+   _mesa_get_format_block_size(mesaFormat, &bw, &bh);
+
+   return block_size / bh;
 }




More information about the mesa-commit mailing list