mesa/swrast: fix GL_TEXTURE_2D_ARRAY texture fetches for latc/rgtc formats
authorBrian Paul <brianp@vmware.com>
Thu, 23 Aug 2012 03:22:00 +0000 (21:22 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 24 Aug 2012 12:18:41 +0000 (06:18 -0600)
Fix-up the texel fetch functions so that they handle 3D coords (as used for
array textures) and remove the "f_2d" part from their names.

Helps fix swrast crashes in piglit's copyteximage test.  More to come.

src/mesa/main/texcompress.c
src/mesa/main/texcompress_rgtc.c
src/mesa/main/texcompress_rgtc.h
src/mesa/swrast/s_texfetch.c

index 48c472eda633335a557b0646fc0886ce27bc4b6d..5e66937596363d6516c9fadf1dffe2da697ebf1b 100644 (file)
@@ -516,30 +516,30 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
 
    /* Red/RG formats */
    case MESA_FORMAT_RED_RGTC1:
-      fetch = _mesa_fetch_texel_2d_f_red_rgtc1;
+      fetch = _mesa_fetch_texel_red_rgtc1;
       break;
    case MESA_FORMAT_SIGNED_RED_RGTC1:
-      fetch = _mesa_fetch_texel_2d_f_signed_red_rgtc1;
+      fetch = _mesa_fetch_texel_signed_red_rgtc1;
       break;
    case MESA_FORMAT_RG_RGTC2:
-      fetch = _mesa_fetch_texel_2d_f_rg_rgtc2;
+      fetch = _mesa_fetch_texel_rg_rgtc2;
       break;
    case MESA_FORMAT_SIGNED_RG_RGTC2:
-      fetch = _mesa_fetch_texel_2d_f_signed_rg_rgtc2;
+      fetch = _mesa_fetch_texel_signed_rg_rgtc2;
       break;
 
    /* L/LA formats */
    case MESA_FORMAT_L_LATC1:
-      fetch = _mesa_fetch_texel_2d_f_l_latc1;
+      fetch = _mesa_fetch_texel_l_latc1;
       break;
    case MESA_FORMAT_SIGNED_L_LATC1:
-      fetch = _mesa_fetch_texel_2d_f_signed_l_latc1;
+      fetch = _mesa_fetch_texel_signed_l_latc1;
       break;
    case MESA_FORMAT_LA_LATC2:
-      fetch = _mesa_fetch_texel_2d_f_la_latc2;
+      fetch = _mesa_fetch_texel_la_latc2;
       break;
    case MESA_FORMAT_SIGNED_LA_LATC2:
-      fetch = _mesa_fetch_texel_2d_f_signed_la_latc2;
+      fetch = _mesa_fetch_texel_signed_la_latc2;
       break;
 
    /* ETC1 formats */
index f707a0994e94b4ff077bdec5ee96ce4e1443131d..84d8fc7fc19a26f434bc5f3ec5cd6c2fb71283be 100644 (file)
@@ -292,12 +292,14 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
 }
 
 void
-_mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_red_rgtc1(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel)
 {
    GLubyte red;
-   unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map,
-                      i, j, &red, 1);
+   GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
+   unsigned_fetch_texel_rgtc(texImage->RowStride,
+                             texImage->Map + sliceOffset,
+                             i, j, &red, 1);
    texel[RCOMP] = UBYTE_TO_FLOAT(red);
    texel[GCOMP] = 0.0;
    texel[BCOMP] = 0.0;
@@ -305,12 +307,14 @@ _mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage,
 }
 
 void
-_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texImage,
-                                       GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_signed_red_rgtc1(const struct swrast_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, GLfloat *texel)
 {
    GLbyte red;
-   signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map),
-                      i, j, &red, 1);
+   GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
+   signed_fetch_texel_rgtc(texImage->RowStride,
+                           (GLbyte *)(texImage->Map) + sliceOffset,
+                           i, j, &red, 1);
    texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
    texel[GCOMP] = 0.0;
    texel[BCOMP] = 0.0;
@@ -318,14 +322,17 @@ _mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texIm
 }
 
 void
-_mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_rg_rgtc2(const struct swrast_texture_image *texImage,
+                           GLint i, GLint j, GLint k, GLfloat *texel)
 {
    GLubyte red, green;
-   unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map,
-                    i, j, &red, 2);
-   unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map + 8,
-                    i, j, &green, 2);
+   GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
+   unsigned_fetch_texel_rgtc(texImage->RowStride,
+                             texImage->Map + sliceOffset,
+                             i, j, &red, 2);
+   unsigned_fetch_texel_rgtc(texImage->RowStride,
+                             texImage->Map + sliceOffset + 8,
+                             i, j, &green, 2);
    texel[RCOMP] = UBYTE_TO_FLOAT(red);
    texel[GCOMP] = UBYTE_TO_FLOAT(green);
    texel[BCOMP] = 0.0;
@@ -333,14 +340,17 @@ _mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage,
 }
 
 void
-_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texImage,
-                                      GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_signed_rg_rgtc2(const struct swrast_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel)
 {
    GLbyte red, green;
-   signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map),
-                    i, j, &red, 2);
-   signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map) + 8,
-                    i, j, &green, 2);
+   GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
+   signed_fetch_texel_rgtc(texImage->RowStride,
+                           (GLbyte *)(texImage->Map) + sliceOffset,
+                           i, j, &red, 2);
+   signed_fetch_texel_rgtc(texImage->RowStride,
+                           (GLbyte *)(texImage->Map) + sliceOffset + 8,
+                           i, j, &green, 2);
    texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
    texel[GCOMP] = BYTE_TO_FLOAT_TEX(green);
    texel[BCOMP] = 0.0;
@@ -348,12 +358,14 @@ _mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texIma
 }
 
 void
-_mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_l_latc1(const struct swrast_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLfloat *texel)
 {
    GLubyte red;
-   unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map,
-                       i, j, &red, 1);
+   GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
+   unsigned_fetch_texel_rgtc(texImage->RowStride,
+                             texImage->Map + sliceOffset,
+                             i, j, &red, 1);
    texel[RCOMP] =
    texel[GCOMP] =
    texel[BCOMP] = UBYTE_TO_FLOAT(red);
@@ -361,12 +373,14 @@ _mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage,
 }
 
 void
-_mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImage,
-                                        GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_signed_l_latc1(const struct swrast_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel)
 {
    GLbyte red;
-   signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map),
-                       i, j, &red, 1);
+   GLint sliceOffset = k ? texImage->ImageOffsets[k] / 2 : 0;
+   signed_fetch_texel_rgtc(texImage->RowStride,
+                           (GLbyte *)(texImage->Map) + sliceOffset,
+                           i, j, &red, 1);
    texel[RCOMP] =
    texel[GCOMP] =
    texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
@@ -374,14 +388,17 @@ _mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImag
 }
 
 void
-_mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_la_latc2(const struct swrast_texture_image *texImage,
+                           GLint i, GLint j, GLint k, GLfloat *texel)
 {
    GLubyte red, green;
-   unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map,
-                     i, j, &red, 2);
-   unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Map + 8,
-                     i, j, &green, 2);
+   GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
+   unsigned_fetch_texel_rgtc(texImage->RowStride,
+                             texImage->Map + sliceOffset,
+                             i, j, &red, 2);
+   unsigned_fetch_texel_rgtc(texImage->RowStride,
+                             texImage->Map + sliceOffset + 8,
+                             i, j, &green, 2);
    texel[RCOMP] =
    texel[GCOMP] =
    texel[BCOMP] = UBYTE_TO_FLOAT(red);
@@ -389,14 +406,17 @@ _mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage,
 }
 
 void
-_mesa_fetch_texel_2d_f_signed_la_latc2(const struct swrast_texture_image *texImage,
-                                       GLint i, GLint j, GLint k, GLfloat *texel)
+_mesa_fetch_texel_signed_la_latc2(const struct swrast_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel)
 {
    GLbyte red, green;
-   signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map),
-                     i, j, &red, 2);
-   signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Map) + 8,
-                     i, j, &green, 2);
+   GLint sliceOffset = k ? texImage->ImageOffsets[k] : 0;
+   signed_fetch_texel_rgtc(texImage->RowStride,
+                           (GLbyte *)(texImage->Map) + sliceOffset,
+                           i, j, &red, 2);
+   signed_fetch_texel_rgtc(texImage->RowStride,
+                           (GLbyte *)(texImage->Map) + sliceOffset + 8,
+                           i, j, &green, 2);
    texel[RCOMP] =
    texel[GCOMP] =
    texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
index 6be6ad9be411567d86d55293710fa2fefb4a1234..91fda882d4bc06f96e4619911b23e4ee8dd79dea 100644 (file)
@@ -43,35 +43,35 @@ extern GLboolean
 _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS);
 
 extern void
-_mesa_fetch_texel_2d_f_red_rgtc1(const struct swrast_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_red_rgtc1(const struct swrast_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct swrast_texture_image *texImage,
-                                       GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_signed_red_rgtc1(const struct swrast_texture_image *texImage,
+                                   GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_rg_rgtc2(const struct swrast_texture_image *texImage,
-                                GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_rg_rgtc2(const struct swrast_texture_image *texImage,
+                           GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct swrast_texture_image *texImage,
-                                      GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_signed_rg_rgtc2(const struct swrast_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_l_latc1(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_l_latc1(const struct swrast_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_signed_l_latc1(const struct swrast_texture_image *texImage,
-                                        GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_signed_l_latc1(const struct swrast_texture_image *texImage,
+                                 GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_la_latc2(const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_la_latc2(const struct swrast_texture_image *texImage,
+                           GLint i, GLint j, GLint k, GLfloat *texel);
 
 extern void
-_mesa_fetch_texel_2d_f_signed_la_latc2(const struct swrast_texture_image *texImage,
-                                       GLint i, GLint j, GLint k, GLfloat *texel);
+_mesa_fetch_texel_signed_la_latc2(const struct swrast_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, GLfloat *texel);
 
 #endif
index db7c887b6737d0d7a583682d1e3be9a7c7f23080..cd3a2b151f3572b4b24ad2ebac26f56ae1fde2f9 100644 (file)
@@ -976,51 +976,51 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
    },
    {
       MESA_FORMAT_RED_RGTC1,
-      NULL,
-      _mesa_fetch_texel_2d_f_red_rgtc1,
-      NULL
+      _mesa_fetch_texel_red_rgtc1,
+      _mesa_fetch_texel_red_rgtc1,
+      _mesa_fetch_texel_red_rgtc1
    },
    {
       MESA_FORMAT_SIGNED_RED_RGTC1,
-      NULL,
-      _mesa_fetch_texel_2d_f_signed_red_rgtc1,
-      NULL
+      _mesa_fetch_texel_signed_red_rgtc1,
+      _mesa_fetch_texel_signed_red_rgtc1,
+      _mesa_fetch_texel_signed_red_rgtc1
    },
    {
       MESA_FORMAT_RG_RGTC2,
-      NULL,
-      _mesa_fetch_texel_2d_f_rg_rgtc2,
-      NULL
+      _mesa_fetch_texel_rg_rgtc2,
+      _mesa_fetch_texel_rg_rgtc2,
+      _mesa_fetch_texel_rg_rgtc2
    },
    {
       MESA_FORMAT_SIGNED_RG_RGTC2,
-      NULL,
-      _mesa_fetch_texel_2d_f_signed_rg_rgtc2,
-      NULL
+      _mesa_fetch_texel_signed_rg_rgtc2,
+      _mesa_fetch_texel_signed_rg_rgtc2,
+      _mesa_fetch_texel_signed_rg_rgtc2
    },
    {
       MESA_FORMAT_L_LATC1,
-      NULL,
-      _mesa_fetch_texel_2d_f_l_latc1,
-      NULL
+      _mesa_fetch_texel_l_latc1,
+      _mesa_fetch_texel_l_latc1,
+      _mesa_fetch_texel_l_latc1
    },
    {
       MESA_FORMAT_SIGNED_L_LATC1,
-      NULL,
-      _mesa_fetch_texel_2d_f_signed_l_latc1,
-      NULL
+      _mesa_fetch_texel_signed_l_latc1,
+      _mesa_fetch_texel_signed_l_latc1,
+      _mesa_fetch_texel_signed_l_latc1
    },
    {
       MESA_FORMAT_LA_LATC2,
-      NULL,
-      _mesa_fetch_texel_2d_f_la_latc2,
-      NULL
+      _mesa_fetch_texel_la_latc2,
+      _mesa_fetch_texel_la_latc2,
+      _mesa_fetch_texel_la_latc2
    },
    {
       MESA_FORMAT_SIGNED_LA_LATC2,
-      NULL,
-      _mesa_fetch_texel_2d_f_signed_la_latc2,
-      NULL
+      _mesa_fetch_texel_signed_la_latc2,
+      _mesa_fetch_texel_signed_la_latc2,
+      _mesa_fetch_texel_signed_la_latc2
    },
    {
       MESA_FORMAT_ETC1_RGB8,