diff options
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex.c | 36 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_image.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_validate.c | 21 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_texture.c | 24 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_texture.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_texstate.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_texstate.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r600/evergreen_tex.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r600/r600_texstate.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texstate.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texture.c | 103 | ||||
-rw-r--r-- | src/mesa/drivers/dri/swrast/swrast.c | 5 |
14 files changed, 116 insertions, 107 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index bf6a0f6b71e..c5ef38b7596 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -417,8 +417,8 @@ intel_miptree_copy_teximage(struct intel_context *intel, dst_mt, dst_x, dst_y, dst_mt->region->pitch * dst_mt->region->cpp, width, height); - src = intelImage->base.Base.Data; - src += (intelImage->base.Base.RowStride * + src = intelImage->base.Data; + src += (intelImage->base.RowStride * intelImage->base.Base.Height * dst_mt->region->cpp * slice); @@ -429,7 +429,7 @@ intel_miptree_copy_teximage(struct intel_context *intel, dst_x, dst_y, width, height, src, - intelImage->base.Base.RowStride, + intelImage->base.RowStride, 0, 0); intel_region_unmap(intel, dst_mt->region); @@ -437,8 +437,8 @@ intel_miptree_copy_teximage(struct intel_context *intel, } if (!src_mt) { - _mesa_free_texmemory(intelImage->base.Base.Data); - intelImage->base.Base.Data = NULL; + _mesa_free_texmemory(intelImage->base.Data); + intelImage->base.Data = NULL; } intel_miptree_reference(&intelImage->mt, dst_mt); diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c index 054ae421585..c11753b3deb 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.c +++ b/src/mesa/drivers/dri/intel/intel_tex.c @@ -59,6 +59,7 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx, struct intel_texture_image *intel_image = intel_texture_image(image); struct gl_texture_object *texobj = image->TexObject; struct intel_texture_object *intel_texobj = intel_texture_object(texobj); + GLuint slices; /* Because the driver uses AllocTextureImageBuffer() internally, it may end * up mismatched with FreeTextureImageBuffer(), but that is safe to call @@ -66,6 +67,26 @@ intel_alloc_texture_image_buffer(struct gl_context *ctx, */ ctx->Driver.FreeTextureImageBuffer(ctx, image); + if (intel->must_use_separate_stencil + && image->TexFormat == MESA_FORMAT_S8_Z24) { + intel_tex_image_s8z24_create_renderbuffers(intel, intel_image); + } + + /* Allocate the swrast_texture_image::ImageOffsets array now */ + switch (texobj->Target) { + case GL_TEXTURE_3D: + case GL_TEXTURE_2D_ARRAY: + slices = image->Depth; + break; + case GL_TEXTURE_1D_ARRAY: + slices = image->Height; + break; + default: + slices = 1; + } + assert(!intel_image->base.ImageOffsets); + intel_image->base.ImageOffsets = malloc(slices * sizeof(GLuint)); + if (intel_texobj->mt && intel_miptree_match_image(intel_texobj->mt, image)) { intel_miptree_reference(&intel_image->mt, intel_texobj->mt); @@ -113,9 +134,14 @@ intel_free_texture_image_buffer(struct gl_context * ctx, intel_miptree_release(&intelImage->mt); - if (texImage->Data) { - _mesa_free_texmemory(texImage->Data); - texImage->Data = NULL; + if (intelImage->base.Data) { + _mesa_free_texmemory(intelImage->base.Data); + intelImage->base.Data = NULL; + } + + if (intelImage->base.ImageOffsets) { + free(intelImage->base.ImageOffsets); + intelImage->base.ImageOffsets = NULL; } _mesa_reference_renderbuffer(&intelImage->depth_rb, NULL); @@ -188,11 +214,11 @@ intel_map_texture_image(struct gl_context *ctx, assert(map); *stride = _mesa_format_row_stride(tex_image->TexFormat, width); - *map = tex_image->Data + (slice * height + y) * *stride + x * texelSize; + *map = intel_image->base.Data + (slice * height + y) * *stride + x * texelSize; DBG("%s: %d,%d %dx%d from data %p = %p/%d\n", __FUNCTION__, x, y, w, h, - tex_image->Data, *map, *stride); + intel_image->base.Data, *map, *stride); } } diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c index 4710bf6049b..cf54a1391c1 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_image.c +++ b/src/mesa/drivers/dri/intel/intel_tex_image.c @@ -454,7 +454,7 @@ intel_set_texture_image_region(struct gl_context *ctx, if (intel_image->mt == NULL) return; - image->RowStride = region->pitch; + intel_image->base.RowStride = region->pitch; } void diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c index 40124009437..6639de9c2af 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_validate.c +++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c @@ -147,40 +147,29 @@ intel_tex_map_image_for_swrast(struct intel_context *intel, mt->target == GL_TEXTURE_1D_ARRAY) { int i; - if (mt->target == GL_TEXTURE_2D_ARRAY || - mt->target == GL_TEXTURE_1D_ARRAY) { - /* Mesa only allocates one entry for these, but we really do have an - * offset per depth. - */ - free(intel_image->base.Base.ImageOffsets); - intel_image->base.Base.ImageOffsets = malloc(mt->level[level].depth * - sizeof(GLuint)); - } - /* 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, face, i, &x, &y); - intel_image->base.Base.ImageOffsets[i] = x + y * mt->region->pitch; + intel_image->base.ImageOffsets[i] = x + y * mt->region->pitch; } DBG("%s \n", __FUNCTION__); - intel_image->base.Base.Data = intel_region_map(intel, mt->region, mode); + intel_image->base.Data = intel_region_map(intel, mt->region, mode); } else { assert(mt->level[level].depth == 1); intel_miptree_get_image_offset(mt, level, face, 0, &x, &y); - intel_image->base.Base.ImageOffsets[0] = 0; DBG("%s: (%d,%d) -> (%d, %d)/%d\n", __FUNCTION__, face, level, x, y, mt->region->pitch * mt->cpp); - intel_image->base.Base.Data = intel_region_map(intel, mt->region, mode) + + intel_image->base.Data = intel_region_map(intel, mt->region, mode) + (x + y * mt->region->pitch) * mt->cpp; } - intel_image->base.Base.RowStride = mt->region->pitch; + intel_image->base.RowStride = mt->region->pitch; } static void @@ -189,7 +178,7 @@ intel_tex_unmap_image_for_swrast(struct intel_context *intel, { if (intel_image && intel_image->mt) { intel_region_unmap(intel, intel_image->mt->region); - intel_image->base.Base.Data = NULL; + intel_image->base.Data = NULL; } } diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index 2212d895ae4..08ec03ee6c3 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -68,7 +68,7 @@ nouveau_teximage_new(struct gl_context *ctx) { struct nouveau_teximage *nti = CALLOC_STRUCT(nouveau_teximage); - return &nti->base; + return &nti->base.Base; } static void @@ -103,7 +103,7 @@ nouveau_teximage_map(struct gl_context *ctx, struct gl_texture_image *ti, nti->transfer.x = x; nti->transfer.y = y; - ti->Data = nouveau_get_scratch(ctx, st->pitch * h, + nti->base.Data = nouveau_get_scratch(ctx, st->pitch * h, &st->bo, &st->offset); } else { @@ -119,7 +119,7 @@ nouveau_teximage_map(struct gl_context *ctx, struct gl_texture_image *ti, assert(!ret); } - ti->Data = s->bo->map + y * s->pitch + x * s->cpp; + nti->base.Data = s->bo->map + y * s->pitch + x * s->cpp; } } } @@ -141,7 +141,7 @@ nouveau_teximage_unmap(struct gl_context *ctx, struct gl_texture_image *ti) nouveau_bo_unmap(s->bo); } - ti->Data = NULL; + nti->base.Data = NULL; } @@ -197,7 +197,7 @@ nouveau_map_texture_image(struct gl_context *ctx, *stride = s->pitch; } } else { - *map = ti->Data + y * s->pitch + x * s->cpp; + *map = nti->base.Data + y * s->pitch + x * s->cpp; *stride = s->pitch; } } @@ -220,7 +220,7 @@ nouveau_unmap_texture_image(struct gl_context *ctx, struct gl_texture_image *ti, nouveau_bo_unmap(s->bo); } - ti->Data = NULL; + nti->base.Data = NULL; } static gl_format @@ -461,12 +461,13 @@ nouveau_teximage(struct gl_context *ctx, GLint dims, GLenum target, GLint level, struct gl_texture_image *ti) { struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface; + struct nouveau_teximage *nti = to_nouveau_teximage(ti); int ret; /* Allocate a new bo for the image. */ nouveau_surface_alloc(ctx, s, LINEAR, get_teximage_placement(ti), ti->TexFormat, width, height); - ti->RowStride = s->pitch / s->cpp; + nti->base.RowStride = s->pitch / s->cpp; pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, format, type, pixels, packing, @@ -479,7 +480,7 @@ nouveau_teximage(struct gl_context *ctx, GLint dims, GLenum target, GLint level, ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, ti->TexFormat, 0, 0, 0, s->pitch, - (GLubyte **) &ti->Data, + &nti->base.Data, width, height, depth, format, type, pixels, packing); assert(ret); @@ -555,6 +556,7 @@ nouveau_texsubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint lev struct gl_texture_image *ti) { struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface; + struct nouveau_teximage *nti = to_nouveau_teximage(ti); int ret; pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, depth, @@ -566,7 +568,7 @@ nouveau_texsubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint lev ret = _mesa_texstore(ctx, 3, ti->_BaseFormat, ti->TexFormat, 0, 0, 0, s->pitch, - (GLubyte **) &ti->Data, + &nti->base.Data, width, height, depth, format, type, pixels, packing); assert(ret); @@ -654,10 +656,12 @@ nouveau_set_texbuffer(__DRIcontext *dri_ctx, fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer; struct gl_texture_object *t = _mesa_get_current_tex_object(ctx, target); struct gl_texture_image *ti; + struct nouveau_teximage *nti; struct nouveau_surface *s; _mesa_lock_texture(ctx, t); ti = _mesa_get_tex_image(ctx, t, target, 0); + nti = to_nouveau_teximage(ti); s = &to_nouveau_teximage(ti)->surface; /* Update the texture surface with the given drawable. */ @@ -669,7 +673,7 @@ nouveau_set_texbuffer(__DRIcontext *dri_ctx, /* Update the image fields. */ _mesa_init_teximage_fields(ctx, target, ti, s->width, s->height, 1, 0, s->cpp, s->format); - ti->RowStride = s->pitch / s->cpp; + nti->base.RowStride = s->pitch / s->cpp; /* Try to validate it. */ if (!validate_teximage(ctx, t, 0, 0, 0, 0, s->width, s->height, 1)) diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.h b/src/mesa/drivers/dri/nouveau/nouveau_texture.h index 56e61c7337b..562429f146b 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.h @@ -27,8 +27,10 @@ #ifndef __NOUVEAU_TEXTURE_H__ #define __NOUVEAU_TEXTURE_H__ +#include "swrast/s_context.h" + struct nouveau_teximage { - struct gl_texture_image base; + struct swrast_texture_image base; struct nouveau_surface surface; struct { struct nouveau_surface surface; diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c index cb3f245c854..0261840a1d1 100644 --- a/src/mesa/drivers/dri/r200/r200_texstate.c +++ b/src/mesa/drivers/dri/r200/r200_texstate.c @@ -846,7 +846,7 @@ void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format _mesa_init_teximage_fields(radeon->glCtx, target, texImage, rb->base.Width, rb->base.Height, 1, 0, rb->cpp, texFormat); - texImage->RowStride = rb->pitch / rb->cpp; + rImage->base.RowStride = rb->pitch / rb->cpp; t->pp_txsize = ((rb->base.Width - 1) << RADEON_TEX_USIZE_SHIFT) diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c index e73e79b9c3a..26ab0e5bf80 100644 --- a/src/mesa/drivers/dri/r300/r300_texstate.c +++ b/src/mesa/drivers/dri/r300/r300_texstate.c @@ -498,7 +498,7 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format _mesa_init_teximage_fields(radeon->glCtx, target, texImage, rb->base.Width, rb->base.Height, 1, 0, rb->cpp, texFormat); - texImage->RowStride = rb->pitch / rb->cpp; + rImage->base.RowStride = rb->pitch / rb->cpp; pitch_val--; diff --git a/src/mesa/drivers/dri/r600/evergreen_tex.c b/src/mesa/drivers/dri/r600/evergreen_tex.c index b2b67b00f12..c94a717c0ae 100644 --- a/src/mesa/drivers/dri/r600/evergreen_tex.c +++ b/src/mesa/drivers/dri/r600/evergreen_tex.c @@ -1404,7 +1404,7 @@ void evergreenSetTexBuffer(__DRIcontext *pDRICtx, GLint target, GLint glx_textur _mesa_init_teximage_fields(radeon->glCtx, target, texImage, rb->base.Width, rb->base.Height, 1, 0, rb->cpp, texFormat); - texImage->RowStride = rb->pitch / rb->cpp; + rImage->base.RowStride = rb->pitch / rb->cpp; pitch_val = (pitch_val + R700_TEXEL_PITCH_ALIGNMENT_MASK) & ~R700_TEXEL_PITCH_ALIGNMENT_MASK; diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c index b3fe544019a..e0c5011c63c 100644 --- a/src/mesa/drivers/dri/r600/r600_texstate.c +++ b/src/mesa/drivers/dri/r600/r600_texstate.c @@ -1257,7 +1257,7 @@ void r600SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo _mesa_init_teximage_fields(radeon->glCtx, target, texImage, rb->base.Width, rb->base.Height, 1, 0, rb->cpp, texFormat); - texImage->RowStride = rb->pitch / rb->cpp; + rImage->base.RowStride = rb->pitch / rb->cpp; pitch_val = (pitch_val + R700_TEXEL_PITCH_ALIGNMENT_MASK) & ~R700_TEXEL_PITCH_ALIGNMENT_MASK; diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index f1febd36ef0..8daeb5e8dd2 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -480,7 +480,7 @@ static void migrate_image_to_miptree(radeon_mipmap_tree *mt, radeon_bo_unmap(image->mt->bo); radeon_miptree_unreference(&image->mt); - } else if (image->base.Base.Data) { + } else if (image->base.Data) { /* This condition should be removed, it's here to workaround * a segfault when mapping textures during software fallbacks. */ @@ -496,11 +496,11 @@ static void migrate_image_to_miptree(radeon_mipmap_tree *mt, rows = (rows + blockHeight - 1) / blockHeight; } - copy_rows(dest, dstlvl->rowstride, image->base.Base.Data, srcrowstride, + copy_rows(dest, dstlvl->rowstride, image->base.Data, srcrowstride, rows, srcrowstride); - _mesa_free_texmemory(image->base.Base.Data); - image->base.Base.Data = 0; + _mesa_free_texmemory(image->base.Data); + image->base.Data = 0; } radeon_bo_unmap(mt->bo); diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c index 5c5cd8b176f..b67767893d9 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c @@ -720,7 +720,7 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form _mesa_init_teximage_fields(radeon->glCtx, target, texImage, rb->base.Width, rb->base.Height, 1, 0, rb->cpp, texFormat); - texImage->RowStride = rb->pitch / rb->cpp; + rImage->base.RowStride = rb->pitch / rb->cpp; t->pp_txpitch &= (1 << 13) -1; pitch_val = rb->pitch; diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 24e40e9853b..2d17d30bb50 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -104,7 +104,7 @@ void radeonFreeTextureImageBuffer(struct gl_context *ctx, struct gl_texture_imag if (image->mt) { radeon_miptree_unreference(&image->mt); - assert(!image->base.Base.Data); + assert(!image->base.Data); } else { _mesa_free_texture_image_data(ctx, timage); } @@ -112,9 +112,14 @@ void radeonFreeTextureImageBuffer(struct gl_context *ctx, struct gl_texture_imag radeon_bo_unref(image->bo); image->bo = NULL; } - if (timage->Data) { - _mesa_free_texmemory(timage->Data); - timage->Data = NULL; + if (image->base.Data) { + _mesa_free_texmemory(image->base.Data); + image->base.Data = NULL; + } + + if (image->base.ImageOffsets) { + free(image->base.ImageOffsets); + image->base.ImageOffsets = NULL; } } @@ -132,8 +137,8 @@ static void teximage_set_map_data(radeon_texture_image *image) lvl = &image->mt->levels[image->mtlevel]; - image->base.Base.Data = image->mt->bo->ptr + lvl->faces[image->mtface].offset; - image->base.Base.RowStride = lvl->rowstride / _mesa_get_format_bytes(image->base.Base.TexFormat); + image->base.Data = image->mt->bo->ptr + lvl->faces[image->mtface].offset; + image->base.RowStride = lvl->rowstride / _mesa_get_format_bytes(image->base.Base.TexFormat); } @@ -147,7 +152,7 @@ void radeon_teximage_map(radeon_texture_image *image, GLboolean write_enable) __func__, image, write_enable ? "true": "false"); if (image->mt) { - assert(!image->base.Base.Data); + assert(!image->base.Data); radeon_bo_map(image->mt->bo, write_enable); teximage_set_map_data(image); @@ -161,9 +166,9 @@ void radeon_teximage_unmap(radeon_texture_image *image) "%s(img %p)\n", __func__, image); if (image->mt) { - assert(image->base.Base.Data); + assert(image->base.Data); - image->base.Base.Data = 0; + image->base.Data = 0; radeon_bo_unmap(image->mt->bo); } } @@ -174,7 +179,7 @@ static void map_override(struct gl_context *ctx, radeonTexObj *t) radeon_bo_map(t->bo, GL_FALSE); - img->base.Base.Data = t->bo->ptr; + img->base.Data = t->bo->ptr; } static void unmap_override(struct gl_context *ctx, radeonTexObj *t) @@ -183,7 +188,7 @@ static void unmap_override(struct gl_context *ctx, radeonTexObj *t) radeon_bo_unmap(t->bo); - img->base.Base.Data = NULL; + img->base.Data = NULL; } /** @@ -243,8 +248,11 @@ void radeonUnmapTexture(struct gl_context *ctx, struct gl_texture_object *texObj return; for(face = 0; face < t->mt->faces; ++face) { - for(level = t->minLod; level <= t->maxLod; ++level) - texObj->Image[face][level]->Data = 0; + for(level = t->minLod; level <= t->maxLod; ++level) { + radeon_texture_image *image = + get_radeon_texture_image(texObj->Image[face][level]); + image->base.Data = NULL; + } } radeon_bo_unmap(t->mt->bo); } @@ -306,7 +314,7 @@ radeon_map_texture_image(struct gl_context *ctx, assert(map); *stride = _mesa_format_row_stride(texImage->TexFormat, width); - *map = texImage->Data + (slice * height) * *stride; + *map = image->base.Data + (slice * height) * *stride; } *map += y * *stride + x * texel_size; @@ -690,26 +698,6 @@ static void teximage_assign_miptree(radeonContextPtr rmesa, "%s Failed to allocate miptree.\n", __func__); } -static GLuint * allocate_image_offsets(struct gl_context *ctx, - unsigned alignedWidth, - unsigned height, - unsigned depth) -{ - int i; - GLuint *offsets; - - offsets = malloc(depth * sizeof(GLuint)) ; - if (!offsets) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTex[Sub]Image"); - return NULL; - } - - for (i = 0; i < depth; ++i) { - offsets[i] = alignedWidth * height * i; - } - - return offsets; -} /** * Update a subregion of the given texture image. @@ -728,9 +716,11 @@ static void radeon_store_teximage(struct gl_context* ctx, int dims, radeonContextPtr rmesa = RADEON_CONTEXT(ctx); radeonTexObj *t = radeon_tex_obj(texObj); radeon_texture_image* image = get_radeon_texture_image(texImage); + GLuint texel_size = _mesa_get_format_bytes(texImage->TexFormat); GLuint dstRowStride; - GLuint *dstImageOffsets; + GLuint alignedWidth; + GLint i; radeon_print(RADEON_TEXTURE, RADEON_TRACE, "%s(%p, tex %p, image %p) compressed %d\n", @@ -747,16 +737,13 @@ static void radeon_store_teximage(struct gl_context* ctx, int dims, assert(dstRowStride); - if (dims == 3) { - unsigned alignedWidth = dstRowStride/_mesa_get_format_bytes(texImage->TexFormat); - dstImageOffsets = allocate_image_offsets(ctx, alignedWidth, texImage->Height, texImage->Depth); - if (!dstImageOffsets) { - radeon_warning("%s Failed to allocate dstImaeOffset.\n", __func__); - return; - } - } else { - dstImageOffsets = texImage->ImageOffsets; + /* fill in the ImageOffsets array */ + alignedWidth = dstRowStride / texel_size; + for (i = 0; i < texImage->Depth; ++i) { + image->base.ImageOffsets[i] = alignedWidth * texImage->Height * i; } + /* and fill in RowStride (in texels) */ + image->base.RowStride = alignedWidth; radeon_teximage_map(image, GL_TRUE); @@ -770,13 +757,13 @@ static void radeon_store_teximage(struct gl_context* ctx, int dims, dstRowStride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width); img_start = _mesa_compressed_image_address(xoffset, yoffset, 0, texImage->TexFormat, - texImage->Width, texImage->Data); + texImage->Width, image->base.Data); } else { uint32_t offset; - offset = dstRowStride / _mesa_get_format_bytes(texImage->TexFormat) * yoffset / block_height + xoffset / block_width; - offset *= _mesa_get_format_bytes(texImage->TexFormat); - img_start = texImage->Data + offset; + offset = dstRowStride / texel_size * yoffset / block_height + xoffset / block_width; + offset *= texel_size; + img_start = image->base.Data + offset; } srcRowStride = _mesa_format_row_stride(texImage->TexFormat, width); bytesPerRow = srcRowStride; @@ -786,12 +773,11 @@ static void radeon_store_teximage(struct gl_context* ctx, int dims, } else { GLubyte *slices[512]; - GLuint texelBytes = _mesa_get_format_bytes(texImage->TexFormat); GLuint i; assert(depth <= 512); for (i = 0; i < depth; i++) { - slices[i] = (GLubyte *) texImage->Data - + dstImageOffsets[i] * texelBytes; + slices[i] = (GLubyte *) image->base.Data + + image->base.ImageOffsets[i] * texel_size; } if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat, texImage->TexFormat, @@ -804,10 +790,6 @@ static void radeon_store_teximage(struct gl_context* ctx, int dims, } } - if (dims == 3) { - free(dstImageOffsets); - } - radeon_teximage_unmap(image); } @@ -837,7 +819,6 @@ static void radeon_teximage( t->validated = GL_FALSE; - /* Mesa core only clears texImage->Data but not image->mt */ radeonFreeTextureImageBuffer(ctx, texImage); if (!t->bo) { @@ -847,11 +828,11 @@ static void radeon_teximage( texImage->Width, texImage->Height, texImage->Depth); - texImage->Data = _mesa_alloc_texmemory(size); + image->base.Data = _mesa_alloc_texmemory(size); radeon_print(RADEON_TEXTURE, RADEON_VERBOSE, "%s %dd: texObj %p, texImage %p, " " no miptree assigned, using local memory %p\n", - __func__, dims, texObj, texImage, texImage->Data); + __func__, dims, texObj, texImage, image->base.Data); } } @@ -867,6 +848,10 @@ static void radeon_teximage( } } + image->base.ImageOffsets = + (GLuint *) malloc(texImage->Depth * sizeof(GLuint)); + + /* Upload texture image; note that the spec allows pixels to be NULL */ if (compressed) { pixels = _mesa_validate_pbo_compressed_teximage( @@ -1090,7 +1075,7 @@ void radeon_image_target_texture_2d(struct gl_context *ctx, GLenum target, texImage->Depth = 1; texImage->_BaseFormat = GL_RGBA; texImage->TexFormat = image->format; - texImage->RowStride = image->pitch; + radeonImage->base.RowStride = image->pitch; texImage->InternalFormat = image->internal_format; if(t->mt) diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index d2c74b91dd1..75d25253eb4 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -52,6 +52,7 @@ #include "main/texstate.h" #include "swrast_priv.h" +#include "swrast/s_context.h" /** @@ -67,6 +68,7 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, struct gl_texture_unit *texUnit; struct gl_texture_object *texObj; struct gl_texture_image *texImage; + struct swrast_texture_image *swImage; uint32_t internalFormat; gl_format texFormat; @@ -77,6 +79,7 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, texUnit = _mesa_get_current_tex_unit(&dri_ctx->Base); texObj = _mesa_select_tex_object(&dri_ctx->Base, texUnit, target); texImage = _mesa_get_tex_image(&dri_ctx->Base, texObj, target, 0); + swImage = swrast_texture_image(texImage); _mesa_lock_texture(&dri_ctx->Base, texObj); @@ -90,7 +93,7 @@ static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage, w, h, 1, 0, internalFormat, texFormat); - sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)texImage->Data, + sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)swImage->Data, dPriv->loaderPrivate); _mesa_unlock_texture(&dri_ctx->Base, texObj); |