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;
}
radeon_mipmap_tree *mt;
GLuint texel_size;
radeon_mipmap_level *lvl;
- int rs;
if (!image || !image->mt)
return;
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
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;
}
}
/** 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
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;
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];
}
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];
}
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];
}
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];
}
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;
}
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];
}
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;
}
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];
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;
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];
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);
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);
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;
}
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);
}
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;
}
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] =
}
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);
}
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] =
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);
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] =
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]);
}
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]);
}
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]);
}
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]);
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]);
}
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]);
}
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]);
}
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]);
/** 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 */
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);
}
#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
/* 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];
}
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;
/**
* 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.
*/
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;
swImage->Buffer = NULL;
}
- free(swImage->ImageOffsets);
- swImage->ImageOffsets = NULL;
+ free(swImage->ImageSlices);
+ swImage->ImageSlices = NULL;
}
*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);