Mesa (master): mesa/swrast: fix GL_TEXTURE_2D_ARRAY texture fetches for dxt formats

Brian Paul brianp at kemper.freedesktop.org
Fri Aug 24 12:20:56 UTC 2012


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

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Aug 22 21:23:53 2012 -0600

mesa/swrast: fix GL_TEXTURE_2D_ARRAY texture fetches for dxt formats

As with the previous commit.

This fixes the last crash in the piglit copyteximage test but there's
still some failures.

---

 src/mesa/main/texcompress.c      |    8 ++--
 src/mesa/main/texcompress_s3tc.c |   60 ++++++++++++++++++++-----------------
 src/mesa/main/texcompress_s3tc.h |   32 ++++++++++----------
 src/mesa/swrast/s_texfetch.c     |   48 +++++++++++++++---------------
 4 files changed, 76 insertions(+), 72 deletions(-)

diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c
index 5e66937..846d4bb 100644
--- a/src/mesa/main/texcompress.c
+++ b/src/mesa/main/texcompress.c
@@ -494,16 +494,16 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
    switch (format) {
    /* DXT formats */
    case MESA_FORMAT_RGB_DXT1:
-      fetch = _mesa_fetch_texel_2d_f_rgb_dxt1;
+      fetch = _mesa_fetch_texel_rgb_dxt1;
       break;
    case MESA_FORMAT_RGBA_DXT1:
-      fetch = _mesa_fetch_texel_2d_f_rgba_dxt1;
+      fetch = _mesa_fetch_texel_rgba_dxt1;
       break;
    case MESA_FORMAT_RGBA_DXT3:
-      fetch = _mesa_fetch_texel_2d_f_rgba_dxt3;
+      fetch = _mesa_fetch_texel_rgba_dxt3;
       break;
    case MESA_FORMAT_RGBA_DXT5:
-      fetch = _mesa_fetch_texel_2d_f_rgba_dxt5;
+      fetch = _mesa_fetch_texel_rgba_dxt5;
       break;
 
    /* FXT1 formats */
diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
index e30890c..230242c 100644
--- a/src/mesa/main/texcompress_s3tc.c
+++ b/src/mesa/main/texcompress_s3tc.c
@@ -368,13 +368,14 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
 
 
 static void
-fetch_texel_2d_rgb_dxt1( const struct swrast_texture_image *texImage,
-                         GLint i, GLint j, GLint k, GLubyte *texel )
+fetch_texel_2d_rgb_dxt1(const struct swrast_texture_image *texImage,
+                        GLint i, GLint j, GLint k, GLubyte *texel)
 {
    (void) k;
    if (fetch_ext_rgb_dxt1) {
+      GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
       fetch_ext_rgb_dxt1(texImage->RowStride,
-                         texImage->Map, i, j, texel);
+                         texImage->Map + sliceOffset, i, j, texel);
    }
    else
       _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1");
@@ -382,8 +383,8 @@ fetch_texel_2d_rgb_dxt1( const struct swrast_texture_image *texImage,
 
 
 void
-_mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_rgb_dxt1(const struct swrast_texture_image *texImage,
+                           GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLubyte and convert to float here */
    GLubyte rgba[4];
@@ -396,13 +397,14 @@ _mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage,
 
 
 static void
-fetch_texel_2d_rgba_dxt1( const struct swrast_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLubyte *texel )
+fetch_texel_2d_rgba_dxt1(const struct swrast_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLubyte *texel)
 {
    (void) k;
    if (fetch_ext_rgba_dxt1) {
+      GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
       fetch_ext_rgba_dxt1(texImage->RowStride,
-                          texImage->Map, i, j, texel);
+                          texImage->Map + sliceOffset, i, j, texel);
    }
    else
       _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n");
@@ -410,8 +412,8 @@ fetch_texel_2d_rgba_dxt1( const struct swrast_texture_image *texImage,
 
 
 void
-_mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_rgba_dxt1(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLubyte and convert to float here */
    GLubyte rgba[4];
@@ -424,13 +426,14 @@ _mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage,
 
 
 static void
-fetch_texel_2d_rgba_dxt3( const struct swrast_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLubyte *texel )
+fetch_texel_2d_rgba_dxt3(const struct swrast_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLubyte *texel)
 {
    (void) k;
    if (fetch_ext_rgba_dxt3) {
+      GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
       fetch_ext_rgba_dxt3(texImage->RowStride,
-                          texImage->Map, i, j, texel);
+                          texImage->Map + sliceOffset, i, j, texel);
    }
    else
       _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n");
@@ -438,8 +441,8 @@ fetch_texel_2d_rgba_dxt3( const struct swrast_texture_image *texImage,
 
 
 void
-_mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_rgba_dxt3(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLubyte and convert to float here */
    GLubyte rgba[4];
@@ -452,13 +455,14 @@ _mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage,
 
 
 static void
-fetch_texel_2d_rgba_dxt5( const struct swrast_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLubyte *texel )
+fetch_texel_2d_rgba_dxt5(const struct swrast_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLubyte *texel)
 {
    (void) k;
    if (fetch_ext_rgba_dxt5) {
+      GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
       fetch_ext_rgba_dxt5(texImage->RowStride,
-                          texImage->Map, i, j, texel);
+                          texImage->Map + sliceOffset, i, j, texel);
    }
    else
       _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n");
@@ -466,8 +470,8 @@ fetch_texel_2d_rgba_dxt5( const struct swrast_texture_image *texImage,
 
 
 void
-_mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_rgba_dxt5(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLubyte and convert to float here */
    GLubyte rgba[4];
@@ -480,8 +484,8 @@ _mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage,
 
 #if FEATURE_EXT_texture_sRGB
 void
-_mesa_fetch_texel_2d_f_srgb_dxt1( const struct swrast_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, GLfloat *texel )
+_mesa_fetch_texel_srgb_dxt1(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLubyte and convert to float here */
    GLubyte rgba[4];
@@ -493,8 +497,8 @@ _mesa_fetch_texel_2d_f_srgb_dxt1( const struct swrast_texture_image *texImage,
 }
 
 void
-_mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_srgba_dxt1(const struct swrast_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLubyte and convert to float here */
    GLubyte rgba[4];
@@ -506,8 +510,8 @@ _mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage,
 }
 
 void
-_mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_srgba_dxt3(const struct swrast_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLubyte and convert to float here */
    GLubyte rgba[4];
@@ -519,8 +523,8 @@ _mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage,
 }
 
 void
-_mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_srgba_dxt5(const struct swrast_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel)
 {
    /* just sample as GLubyte and convert to float here */
    GLubyte rgba[4];
diff --git a/src/mesa/main/texcompress_s3tc.h b/src/mesa/main/texcompress_s3tc.h
index 23793d1..2c06e50 100644
--- a/src/mesa/main/texcompress_s3tc.h
+++ b/src/mesa/main/texcompress_s3tc.h
@@ -48,36 +48,36 @@ extern GLboolean
 _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS);
 
 extern void
-_mesa_fetch_texel_2d_f_rgb_dxt1(const struct swrast_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_rgb_dxt1(const struct swrast_texture_image *texImage,
+                           GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_rgba_dxt1(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_rgba_dxt1(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_rgba_dxt3(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_rgba_dxt3(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_rgba_dxt5(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_rgba_dxt5(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_srgb_dxt1(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_srgb_dxt1(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_srgba_dxt1(const struct swrast_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_srgba_dxt1(const struct swrast_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_srgba_dxt3(const struct swrast_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_srgba_dxt3(const struct swrast_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_srgba_dxt5(const struct swrast_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_srgba_dxt5(const struct swrast_texture_image *texImage,
+                             GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
 _mesa_init_texture_s3tc(struct gl_context *ctx);
diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
index cd3a2b1..741dd87 100644
--- a/src/mesa/swrast/s_texfetch.c
+++ b/src/mesa/swrast/s_texfetch.c
@@ -426,27 +426,27 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
    },
    {
       MESA_FORMAT_SRGB_DXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_srgb_dxt1,
-      NULL
+      _mesa_fetch_texel_srgb_dxt1,
+      _mesa_fetch_texel_srgb_dxt1,
+      _mesa_fetch_texel_srgb_dxt1
    },
    {
       MESA_FORMAT_SRGBA_DXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_srgba_dxt1,
-      NULL
+      _mesa_fetch_texel_srgba_dxt1,
+      _mesa_fetch_texel_srgba_dxt1,
+      _mesa_fetch_texel_srgba_dxt1
    },
    {
       MESA_FORMAT_SRGBA_DXT3,
-      NULL,
-      _mesa_fetch_texel_2d_f_srgba_dxt3,
-      NULL
+      _mesa_fetch_texel_srgba_dxt3,
+      _mesa_fetch_texel_srgba_dxt3,
+      _mesa_fetch_texel_srgba_dxt3
    },
    {
       MESA_FORMAT_SRGBA_DXT5,
-      NULL,
-      _mesa_fetch_texel_2d_f_srgba_dxt5,
-      NULL
+      _mesa_fetch_texel_srgba_dxt5,
+      _mesa_fetch_texel_srgba_dxt5,
+      _mesa_fetch_texel_srgba_dxt5
    },
 
    {
@@ -463,27 +463,27 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
    },
    {
       MESA_FORMAT_RGB_DXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgb_dxt1,
-      NULL
+      _mesa_fetch_texel_rgb_dxt1,
+      _mesa_fetch_texel_rgb_dxt1,
+      _mesa_fetch_texel_rgb_dxt1
    },
    {
       MESA_FORMAT_RGBA_DXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgba_dxt1,
-      NULL
+      _mesa_fetch_texel_rgba_dxt1,
+      _mesa_fetch_texel_rgba_dxt1,
+      _mesa_fetch_texel_rgba_dxt1
    },
    {
       MESA_FORMAT_RGBA_DXT3,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgba_dxt3,
-      NULL
+      _mesa_fetch_texel_rgba_dxt3,
+      _mesa_fetch_texel_rgba_dxt3,
+      _mesa_fetch_texel_rgba_dxt3
    },
    {
       MESA_FORMAT_RGBA_DXT5,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgba_dxt5,
-      NULL
+      _mesa_fetch_texel_rgba_dxt5,
+      _mesa_fetch_texel_rgba_dxt5,
+      _mesa_fetch_texel_rgba_dxt5
    },
    {
       MESA_FORMAT_RGBA_FLOAT32,




More information about the mesa-commit mailing list