diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_validate.c | 37 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texture.c | 13 | ||||
-rw-r--r-- | src/mesa/main/texcompress.c | 2 | ||||
-rw-r--r-- | src/mesa/main/texcompress.h | 3 | ||||
-rw-r--r-- | src/mesa/main/texcompress_etc.c | 51 | ||||
-rw-r--r-- | src/mesa/main/texcompress_fxt1.c | 8 | ||||
-rw-r--r-- | src/mesa/main/texcompress_rgtc.c | 70 | ||||
-rw-r--r-- | src/mesa/main/texcompress_s3tc.c | 56 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.h | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfetch.c | 5 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfetch_tmp.h | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_texrender.c | 14 | ||||
-rw-r--r-- | src/mesa/swrast/s_texture.c | 43 |
13 files changed, 123 insertions, 185 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c index c880bcee102..60687332191 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c @@ -163,34 +163,19 @@ intel_tex_map_image_for_swrast(struct intel_context *intel, for (int i = 0; i < mt->level[level].depth; i++) intel_miptree_slice_resolve_depth(intel, mt, level, i); - if (mt->target == GL_TEXTURE_3D || - mt->target == GL_TEXTURE_2D_ARRAY || - mt->target == GL_TEXTURE_1D_ARRAY) { - int i; - - /* ImageOffsets[] is only used for swrast's fetch_texel_3d, so we can't - * share code with the normal path. - */ - for (i = 0; i < mt->level[level].depth; i++) { - intel_miptree_get_image_offset(mt, level, i, &x, &y); - intel_image->base.ImageOffsets[i] = x + y * (mt->region->pitch / - mt->region->cpp); - } - - DBG("%s \n", __FUNCTION__); - - intel_image->base.Map = intel_miptree_map_raw(intel, mt); - } else { - assert(intel_image->base.Base.Depth == 1); - intel_miptree_get_image_offset(mt, level, face, &x, &y); - - DBG("%s: (%d,%d) -> (%d, %d)/%d\n", - __FUNCTION__, face, level, x, y, mt->region->pitch); - - intel_image->base.Map = intel_miptree_map_raw(intel, mt) + - x * mt->cpp + y * mt->region->pitch; + void *map = intel_miptree_map_raw(intel, mt); + + for (int i = 0; i < mt->level[level].depth; i++) { + intel_miptree_get_image_offset(mt, level, i, &x, &y); + intel_image->base.ImageSlices[i] = (map + + y * mt->region->pitch + + x * mt->cpp); + DBG("%s: (%d,%d,%d) -> (%d, %d)/%d\n", + __FUNCTION__, face, level, i, x, y, mt->region->pitch); } + intel_image->base.Map = intel_image->base.ImageSlices[0]; + assert(mt->region->pitch % mt->region->cpp == 0); intel_image->base.RowStride = mt->region->pitch / mt->region->cpp; } diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 23942cbb0a0..aa2f734c657 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -638,7 +638,6 @@ radeon_swrast_map_image(radeonContextPtr rmesa, radeon_mipmap_tree *mt; GLuint texel_size; radeon_mipmap_level *lvl; - int rs; if (!image || !image->mt) return; @@ -650,18 +649,16 @@ radeon_swrast_map_image(radeonContextPtr rmesa, lvl = &image->mt->levels[level]; - rs = lvl->rowstride / texel_size; - radeon_bo_map(mt->bo, 1); image->base.Map = mt->bo->ptr + lvl->faces[face].offset; - if (mt->target == GL_TEXTURE_3D) { - int i; - for (i = 0; i < mt->levels[level].depth; i++) - image->base.ImageOffsets[i] = rs * lvl->height * i; + for (int i = 0; i < mt->levels[level].depth; i++) { + image->base.ImageSlices[i] = + image->base.Map + (lvl->rowstride * lvl->height * i); } - image->base.RowStride = rs; + + image->base.RowStride = lvl->rowstride / texel_size; } static void diff --git a/src/mesa/main/texcompress.c b/src/mesa/main/texcompress.c index 94ea0311f7d..2391868a417 100644 --- a/src/mesa/main/texcompress.c +++ b/src/mesa/main/texcompress.c @@ -588,7 +588,7 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height, for (j = 0; j < height; j++) { for (i = 0; i < width; i++) { - fetch(src, NULL, stride, i, j, 0, dest); + fetch(src, stride, i, j, dest); dest += 4; } } diff --git a/src/mesa/main/texcompress.h b/src/mesa/main/texcompress.h index 03e537ba13b..c27fc26c90f 100644 --- a/src/mesa/main/texcompress.h +++ b/src/mesa/main/texcompress.h @@ -51,9 +51,8 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img, /** A function to fetch one texel from a compressed texture */ typedef void (*compressed_fetch_func)(const GLubyte *map, - const GLuint imageOffsets[], GLint rowStride, - GLint i, GLint j, GLint k, + GLint i, GLint j, GLfloat *texel); extern compressed_fetch_func diff --git a/src/mesa/main/texcompress_etc.c b/src/mesa/main/texcompress_etc.c index 442f844a5a7..a06d29f19aa 100644 --- a/src/mesa/main/texcompress_etc.c +++ b/src/mesa/main/texcompress_etc.c @@ -1222,8 +1222,8 @@ _mesa_unpack_etc2_format(uint8_t *dst_row, static void -fetch_etc1_rgb8(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, +fetch_etc1_rgb8(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc1_block block; @@ -1243,9 +1243,8 @@ fetch_etc1_rgb8(const GLubyte *map, const GLuint imageOffsets[], static void -fetch_etc2_rgb8(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_etc2_rgb8(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; uint8_t dst[3]; @@ -1265,9 +1264,8 @@ fetch_etc2_rgb8(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_etc2_srgb8(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_etc2_srgb8(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; uint8_t dst[3]; @@ -1287,9 +1285,8 @@ fetch_etc2_srgb8(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_etc2_rgba8_eac(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_etc2_rgba8_eac(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; uint8_t dst[4]; @@ -1307,9 +1304,8 @@ fetch_etc2_rgba8_eac(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_etc2_srgb8_alpha8_eac(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_etc2_srgb8_alpha8_eac(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; uint8_t dst[4]; @@ -1327,9 +1323,8 @@ fetch_etc2_srgb8_alpha8_eac(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_etc2_r11_eac(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_etc2_r11_eac(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; GLushort dst; @@ -1347,9 +1342,8 @@ fetch_etc2_r11_eac(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_etc2_rg11_eac(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_etc2_rg11_eac(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; GLushort dst[2]; @@ -1372,9 +1366,8 @@ fetch_etc2_rg11_eac(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_etc2_signed_r11_eac(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_etc2_signed_r11_eac(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; GLushort dst; @@ -1392,9 +1385,8 @@ fetch_etc2_signed_r11_eac(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_etc2_signed_rg11_eac(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_etc2_signed_rg11_eac(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; GLushort dst[2]; @@ -1418,8 +1410,7 @@ fetch_etc2_signed_rg11_eac(const GLubyte *map, const GLuint imageOffsets[], static void fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte *map, - const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { struct etc2_block block; @@ -1440,10 +1431,8 @@ fetch_etc2_rgb8_punchthrough_alpha1(const GLubyte *map, static void fetch_etc2_srgb8_punchthrough_alpha1(const GLubyte *map, - const GLuint imageOffsets[], GLint rowStride, - GLint i, GLint j, GLint k, - GLfloat *texel) + GLint i, GLint j, GLfloat *texel) { struct etc2_block block; uint8_t dst[4]; diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c index 92a10a351e4..93bd19a9a99 100644 --- a/src/mesa/main/texcompress_fxt1.c +++ b/src/mesa/main/texcompress_fxt1.c @@ -1616,8 +1616,8 @@ fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */ static void -fetch_rgb_fxt1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_rgb_fxt1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte rgba[4]; fxt1_decode_1(map, rowStride, i, j, rgba); @@ -1629,8 +1629,8 @@ fetch_rgb_fxt1(const GLubyte *map, const GLuint imageOffsets[], static void -fetch_rgba_fxt1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_rgba_fxt1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte rgba[4]; fxt1_decode_1(map, rowStride, i, j, rgba); diff --git a/src/mesa/main/texcompress_rgtc.c b/src/mesa/main/texcompress_rgtc.c index a7006614367..7afd8ffa7a6 100644 --- a/src/mesa/main/texcompress_rgtc.c +++ b/src/mesa/main/texcompress_rgtc.c @@ -318,12 +318,11 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS) static void -fetch_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_red_rgtc1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red; - GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0; - unsigned_fetch_texel_rgtc(rowStride, map + sliceOffset, i, j, &red, 1); + unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1); texel[RCOMP] = UBYTE_TO_FLOAT(red); texel[GCOMP] = 0.0; texel[BCOMP] = 0.0; @@ -331,12 +330,11 @@ fetch_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_l_latc1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_l_latc1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red; - GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0; - unsigned_fetch_texel_rgtc(rowStride, map + sliceOffset, i, j, &red, 1); + unsigned_fetch_texel_rgtc(rowStride, map, i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = texel[BCOMP] = UBYTE_TO_FLOAT(red); @@ -344,13 +342,11 @@ fetch_l_latc1(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_signed_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_signed_red_rgtc1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLbyte red; - GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0; - signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map + sliceOffset, + signed_fetch_texel_rgtc(rowStride, (const GLbyte *) map, i, j, &red, 1); texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); texel[GCOMP] = 0.0; @@ -359,13 +355,11 @@ fetch_signed_red_rgtc1(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_signed_l_latc1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_signed_l_latc1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLbyte red; - GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0; - signed_fetch_texel_rgtc(rowStride, (GLbyte *) map + sliceOffset, + signed_fetch_texel_rgtc(rowStride, (GLbyte *) map, i, j, &red, 1); texel[RCOMP] = texel[GCOMP] = @@ -374,17 +368,15 @@ fetch_signed_l_latc1(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_rg_rgtc2(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red, green; - GLuint sliceOffset = k ? imageOffsets[k] : 0; unsigned_fetch_texel_rgtc(rowStride, - map + sliceOffset, + map, i, j, &red, 2); unsigned_fetch_texel_rgtc(rowStride, - map + sliceOffset + 8, + map + 8, i, j, &green, 2); texel[RCOMP] = UBYTE_TO_FLOAT(red); texel[GCOMP] = UBYTE_TO_FLOAT(green); @@ -393,17 +385,15 @@ fetch_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_la_latc2(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_la_latc2(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLubyte red, green; - GLuint sliceOffset = k ? imageOffsets[k] : 0; unsigned_fetch_texel_rgtc(rowStride, - map + sliceOffset, + map, i, j, &red, 2); unsigned_fetch_texel_rgtc(rowStride, - map + sliceOffset + 8, + map + 8, i, j, &green, 2); texel[RCOMP] = texel[GCOMP] = @@ -413,17 +403,15 @@ fetch_la_latc2(const GLubyte *map, const GLuint imageOffsets[], static void -fetch_signed_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_signed_rg_rgtc2(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLbyte red, green; - GLuint sliceOffset = k ? imageOffsets[k] : 0; signed_fetch_texel_rgtc(rowStride, - (GLbyte *) map + sliceOffset, + (GLbyte *) map, i, j, &red, 2); signed_fetch_texel_rgtc(rowStride, - (GLbyte *) map + sliceOffset + 8, + (GLbyte *) map + 8, i, j, &green, 2); texel[RCOMP] = BYTE_TO_FLOAT_TEX(red); texel[GCOMP] = BYTE_TO_FLOAT_TEX(green); @@ -433,17 +421,15 @@ fetch_signed_rg_rgtc2(const GLubyte *map, const GLuint imageOffsets[], static void -fetch_signed_la_latc2(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, - GLfloat *texel) +fetch_signed_la_latc2(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { GLbyte red, green; - GLuint sliceOffset = k ? imageOffsets[k] : 0; signed_fetch_texel_rgtc(rowStride, - (GLbyte *) map + sliceOffset, + (GLbyte *) map, i, j, &red, 2); signed_fetch_texel_rgtc(rowStride, - (GLbyte *) map + sliceOffset + 8, + (GLbyte *) map + 8, i, j, &green, 2); texel[RCOMP] = texel[GCOMP] = diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c index 02f2c7c0ce9..41ea3361308 100644 --- a/src/mesa/main/texcompress_s3tc.c +++ b/src/mesa/main/texcompress_s3tc.c @@ -345,13 +345,12 @@ problem(const char *func) static void -fetch_rgb_dxt1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_rgb_dxt1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgb_dxt1) { - GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0; GLubyte tex[4]; - fetch_ext_rgb_dxt1(rowStride, map + sliceOffset, i, j, tex); + fetch_ext_rgb_dxt1(rowStride, map, i, j, tex); texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); @@ -363,13 +362,12 @@ fetch_rgb_dxt1(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_rgba_dxt1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_rgba_dxt1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgba_dxt1) { - GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0; GLubyte tex[4]; - fetch_ext_rgba_dxt1(rowStride, map + sliceOffset, i, j, tex); + fetch_ext_rgba_dxt1(rowStride, map, i, j, tex); texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); @@ -381,13 +379,12 @@ fetch_rgba_dxt1(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_rgba_dxt3(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_rgba_dxt3(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgba_dxt3) { - GLuint sliceOffset = k ? imageOffsets[k] : 0; GLubyte tex[4]; - fetch_ext_rgba_dxt3(rowStride, map + sliceOffset, i, j, tex); + fetch_ext_rgba_dxt3(rowStride, map, i, j, tex); texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); @@ -399,13 +396,12 @@ fetch_rgba_dxt3(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_rgba_dxt5(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_rgba_dxt5(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgba_dxt5) { - GLuint sliceOffset = k ? imageOffsets[k] : 0; GLubyte tex[4]; - fetch_ext_rgba_dxt5(rowStride, map + sliceOffset, i, j, tex); + fetch_ext_rgba_dxt5(rowStride, map, i, j, tex); texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); @@ -418,13 +414,12 @@ fetch_rgba_dxt5(const GLubyte *map, const GLuint imageOffsets[], static void -fetch_srgb_dxt1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_srgb_dxt1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgb_dxt1) { - GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0; GLubyte tex[4]; - fetch_ext_rgb_dxt1(rowStride, map + sliceOffset, i, j, tex); + fetch_ext_rgb_dxt1(rowStride, map, i, j, tex); texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]); texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]); texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]); @@ -436,13 +431,12 @@ fetch_srgb_dxt1(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_srgba_dxt1(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_srgba_dxt1(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgba_dxt1) { - GLuint sliceOffset = k ? imageOffsets[k] / 2 : 0; GLubyte tex[4]; - fetch_ext_rgba_dxt1(rowStride, map + sliceOffset, i, j, tex); + fetch_ext_rgba_dxt1(rowStride, map, i, j, tex); texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]); texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]); texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]); @@ -454,13 +448,12 @@ fetch_srgba_dxt1(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_srgba_dxt3(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_srgba_dxt3(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgba_dxt3) { - GLuint sliceOffset = k ? imageOffsets[k] : 0; GLubyte tex[4]; - fetch_ext_rgba_dxt3(rowStride, map + sliceOffset, i, j, tex); + fetch_ext_rgba_dxt3(rowStride, map, i, j, tex); texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]); texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]); texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]); @@ -472,13 +465,12 @@ fetch_srgba_dxt3(const GLubyte *map, const GLuint imageOffsets[], } static void -fetch_srgba_dxt5(const GLubyte *map, const GLuint imageOffsets[], - GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel) +fetch_srgba_dxt5(const GLubyte *map, + GLint rowStride, GLint i, GLint j, GLfloat *texel) { if (fetch_ext_rgba_dxt5) { - GLuint sliceOffset = k ? imageOffsets[k] : 0; GLubyte tex[4]; - fetch_ext_rgba_dxt5(rowStride, map + sliceOffset, i, j, tex); + fetch_ext_rgba_dxt5(rowStride, map, i, j, tex); texel[RCOMP] = _mesa_nonlinear_to_linear(tex[RCOMP]); texel[GCOMP] = _mesa_nonlinear_to_linear(tex[GCOMP]); texel[BCOMP] = _mesa_nonlinear_to_linear(tex[BCOMP]); diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index 5d9354d7cf1..7b3c740c1ca 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -140,7 +140,7 @@ struct swrast_texture_image /** These fields only valid when texture memory is mapped */ GLint RowStride; /**< Padded width in units of texels */ - GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to + void **ImageSlices; /**< if 3D texture: array [Depth] of offsets to each 2D slice in 'Data', in texels */ GLubyte *Map; /**< Pointer to mapped image memory */ diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index 7c76f18ceba..a9bc3fad0a2 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -98,10 +98,9 @@ static void fetch_compressed(const struct swrast_texture_image *swImage, GLint i, GLint j, GLint k, GLfloat *texel) { - swImage->FetchCompressedTexel(swImage->Map, - swImage->ImageOffsets, + swImage->FetchCompressedTexel(swImage->ImageSlices[k], swImage->RowStride, - i, j, k, texel); + i, j, texel); } diff --git a/src/mesa/swrast/s_texfetch_tmp.h b/src/mesa/swrast/s_texfetch_tmp.h index 7f09683630c..cf8f61fefdc 100644 --- a/src/mesa/swrast/s_texfetch_tmp.h +++ b/src/mesa/swrast/s_texfetch_tmp.h @@ -59,8 +59,8 @@ #elif DIM == 3 #define TEXEL_ADDR( type, image, i, j, k, size ) \ - ((type *)(image)->Map + ((image)->ImageOffsets[k] \ - + (image)->RowStride * (j) + (i)) * (size)) + ((type *)(image)->ImageSlices[k] + \ + ((image)->RowStride * (j) + (i)) * (size)) #define FETCH(x) fetch_texel_3d_##x diff --git a/src/mesa/swrast/s_texrender.c b/src/mesa/swrast/s_texrender.c index 7b25a7b7d81..92d4edcd835 100644 --- a/src/mesa/swrast/s_texrender.c +++ b/src/mesa/swrast/s_texrender.c @@ -88,18 +88,8 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) /* Want to store linear values, not sRGB */ rb->Format = _mesa_get_srgb_format_linear(format); - - /* Set the gl_renderbuffer::Buffer field so that mapping the buffer - * succeeds. - */ - if (att->Texture->Target == GL_TEXTURE_3D || - att->Texture->Target == GL_TEXTURE_2D_ARRAY_EXT) { - srb->Buffer = swImage->Buffer + - swImage->ImageOffsets[zOffset] * _mesa_get_format_bytes(format); - } - else { - srb->Buffer = swImage->Buffer; - } + + srb->Buffer = swImage->ImageSlices[zOffset]; } diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c index 4d3cd0f8ce1..b0990a8cc30 100644 --- a/src/mesa/swrast/s_texture.c +++ b/src/mesa/swrast/s_texture.c @@ -88,23 +88,26 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, struct gl_texture_image *texImage) { struct swrast_texture_image *swImg = swrast_texture_image(texImage); - GLuint bytes = _mesa_format_image_size(texImage->TexFormat, texImage->Width, - texImage->Height, texImage->Depth); + GLuint bytesPerSlice; + GLuint slices = texture_slices(texImage); GLuint i; if (!_swrast_init_texture_image(texImage)) return GL_FALSE; + bytesPerSlice = _mesa_format_image_size(texImage->TexFormat, texImage->Width, + _swrast_teximage_slice_height(texImage), 1); + assert(!swImg->Buffer); - swImg->Buffer = _mesa_align_malloc(bytes, 512); + swImg->Buffer = _mesa_align_malloc(bytesPerSlice * slices, 512); if (!swImg->Buffer) return GL_FALSE; - /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ + /* RowStride and ImageSlices[] describe how to address texels in 'Data' */ swImg->RowStride = texImage->Width; - for (i = 0; i < texture_slices(texImage); i++) { - swImg->ImageOffsets[i] = i * texImage->Width * texImage->Height; + for (i = 0; i < slices; i++) { + swImg->ImageSlices[i] = swImg->Buffer + bytesPerSlice * i; } return GL_TRUE; @@ -114,7 +117,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, /** * Code that overrides ctx->Driver.AllocTextureImageBuffer may use this to * initialize the fields of swrast_texture_image without allocating the image - * buffer or initializing RowStride or the contents of ImageOffsets. + * buffer or initializing RowStride or the contents of ImageSlices. * * Returns GL_TRUE on success, GL_FALSE on memory allocation failure. */ @@ -143,9 +146,9 @@ _swrast_init_texture_image(struct gl_texture_image *texImage) swImg->DepthScale = (GLfloat) texImage->Depth; } - assert(!swImg->ImageOffsets); - swImg->ImageOffsets = malloc(texture_slices(texImage) * sizeof(GLuint)); - if (!swImg->ImageOffsets) + assert(!swImg->ImageSlices); + swImg->ImageSlices = calloc(texture_slices(texImage), sizeof(void *)); + if (!swImg->ImageSlices) return GL_FALSE; return GL_TRUE; @@ -165,8 +168,8 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx, swImage->Buffer = NULL; } - free(swImage->ImageOffsets); - swImage->ImageOffsets = NULL; + free(swImage->ImageSlices); + swImage->ImageSlices = NULL; } @@ -227,17 +230,15 @@ _swrast_map_teximage(struct gl_context *ctx, *mapOut = NULL; return; } - - map = swImage->Buffer; + + /* This function can only be used with a swrast-allocated buffer, in which + * case ImageSlices is populated with pointers into Buffer. + */ + assert(swImage->Buffer); + assert(swImage->Buffer == swImage->ImageSlices[0]); assert(slice < texture_slices(texImage)); - if (slice != 0) { - GLuint sliceSize = _mesa_format_image_size(texImage->TexFormat, - texImage->Width, - _swrast_teximage_slice_height(texImage), - 1); - map += slice * sliceSize; - } + map = swImage->ImageSlices[slice]; /* apply x/y offset to map address */ map += stride * (y / bh) + texelSize * (x / bw); |