Only swrast and the drivers that fall back to swrast need these fields now.
This removes the last of the fields related to software rendering from
gl_texture_image.
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);
dst_x, dst_y,
width, height,
src,
- intelImage->base.Base.RowStride,
+ intelImage->base.RowStride,
0, 0);
intel_region_unmap(intel, dst_mt->region);
}
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);
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
*/
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);
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);
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);
}
}
if (intel_image->mt == NULL)
return;
- image->RowStride = region->pitch;
+ intel_image->base.RowStride = region->pitch;
}
void
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
{
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;
}
}
{
struct nouveau_teximage *nti = CALLOC_STRUCT(nouveau_teximage);
- return &nti->base;
+ return &nti->base.Base;
}
static void
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 {
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;
}
}
}
nouveau_bo_unmap(s->bo);
}
- ti->Data = NULL;
+ nti->base.Data = NULL;
}
*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;
}
}
nouveau_bo_unmap(s->bo);
}
- ti->Data = NULL;
+ nti->base.Data = NULL;
}
static gl_format
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,
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);
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,
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);
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. */
/* 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))
#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;
_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)
_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--;
_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;
_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;
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.
*/
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);
_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;
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);
}
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;
}
}
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);
}
__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);
"%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);
}
}
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)
radeon_bo_unmap(t->bo);
- img->base.Base.Data = NULL;
+ img->base.Data = NULL;
}
/**
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);
}
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;
"%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.
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",
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);
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;
}
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,
}
}
- if (dims == 3) {
- free(dstImageOffsets);
- }
-
radeon_teximage_unmap(image);
}
t->validated = GL_FALSE;
- /* Mesa core only clears texImage->Data but not image->mt */
radeonFreeTextureImageBuffer(ctx, texImage);
if (!t->bo) {
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);
}
}
}
}
+ 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(
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)
#include "main/texstate.h"
#include "swrast_priv.h"
+#include "swrast/s_context.h"
/**
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;
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);
_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);
GLuint Level; /**< Which mipmap level am I? */
/** Cube map face: index into gl_texture_object::Image[] array */
GLuint Face;
-
- GLuint RowStride; /**< Padded width in units of texels */
- GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to
- each 2D slice in 'Data', in texels */
- GLvoid *Data; /**< Image data, accessed via FetchTexel() */
};
/* setup dummy texture image info */
memset(&texImage, 0, sizeof(texImage));
- texImage.Base.Data = (void *) src;
- texImage.Base.RowStride = srcRowStride;
+ texImage.Data = (void *) src;
+ texImage.RowStride = srcRowStride;
switch (format) {
/* DXT formats */
/* just sample as GLubyte and convert to float here */
GLubyte rgba[4];
(void) k;
- fxt1_decode_1(texImage->Base.Data, texImage->Base.RowStride, i, j, rgba);
+ fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba);
texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
/* just sample as GLubyte and convert to float here */
GLubyte rgba[4];
(void) k;
- fxt1_decode_1(texImage->Base.Data, texImage->Base.RowStride, i, j, rgba);
+ fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba);
texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
GLint i, GLint j, GLint k, GLfloat *texel)
{
GLubyte red;
- unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data),
+ unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data,
i, j, &red, 1);
texel[RCOMP] = UBYTE_TO_FLOAT(red);
texel[GCOMP] = 0.0;
GLint i, GLint j, GLint k, GLfloat *texel)
{
GLbyte red;
- signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data),
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
i, j, &red, 1);
texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
texel[GCOMP] = 0.0;
GLint i, GLint j, GLint k, GLfloat *texel)
{
GLubyte red, green;
- unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data),
+ unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data,
i, j, &red, 2);
- unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data) + 8,
+ unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data + 8,
i, j, &green, 2);
texel[RCOMP] = UBYTE_TO_FLOAT(red);
texel[GCOMP] = UBYTE_TO_FLOAT(green);
GLint i, GLint j, GLint k, GLfloat *texel)
{
GLbyte red, green;
- signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data),
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
i, j, &red, 2);
- signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data) + 8,
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data) + 8,
i, j, &green, 2);
texel[RCOMP] = BYTE_TO_FLOAT_TEX(red);
texel[GCOMP] = BYTE_TO_FLOAT_TEX(green);
GLint i, GLint j, GLint k, GLfloat *texel)
{
GLubyte red;
- unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data),
+ unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data,
i, j, &red, 1);
texel[RCOMP] =
texel[GCOMP] =
GLint i, GLint j, GLint k, GLfloat *texel)
{
GLbyte red;
- signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data),
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
i, j, &red, 1);
texel[RCOMP] =
texel[GCOMP] =
GLint i, GLint j, GLint k, GLfloat *texel)
{
GLubyte red, green;
- unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data),
+ unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data,
i, j, &red, 2);
- unsigned_fetch_texel_rgtc(texImage->Base.RowStride, (GLubyte *)(texImage->Base.Data) + 8,
+ unsigned_fetch_texel_rgtc(texImage->RowStride, texImage->Data + 8,
i, j, &green, 2);
texel[RCOMP] =
texel[GCOMP] =
GLint i, GLint j, GLint k, GLfloat *texel)
{
GLbyte red, green;
- signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data),
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
i, j, &red, 2);
- signed_fetch_texel_rgtc(texImage->Base.RowStride, (GLbyte *)(texImage->Base.Data) + 8,
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data) + 8,
i, j, &green, 2);
texel[RCOMP] =
texel[GCOMP] =
{
(void) k;
if (fetch_ext_rgb_dxt1) {
- fetch_ext_rgb_dxt1(texImage->Base.RowStride,
- (GLubyte *)(texImage)->Base.Data, i, j, texel);
+ fetch_ext_rgb_dxt1(texImage->RowStride,
+ texImage->Data, i, j, texel);
}
else
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1");
{
(void) k;
if (fetch_ext_rgba_dxt1) {
- fetch_ext_rgba_dxt1(texImage->Base.RowStride,
- (GLubyte *)(texImage)->Base.Data, i, j, texel);
+ fetch_ext_rgba_dxt1(texImage->RowStride,
+ texImage->Data, i, j, texel);
}
else
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n");
{
(void) k;
if (fetch_ext_rgba_dxt3) {
- fetch_ext_rgba_dxt3(texImage->Base.RowStride,
- (GLubyte *)(texImage)->Base.Data,
- i, j, texel);
+ fetch_ext_rgba_dxt3(texImage->RowStride,
+ texImage->Data, i, j, texel);
}
else
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n");
{
(void) k;
if (fetch_ext_rgba_dxt5) {
- fetch_ext_rgba_dxt5(texImage->Base.RowStride,
- (GLubyte *)(texImage)->Base.Data,
- i, j, texel);
+ fetch_ext_rgba_dxt5(texImage->RowStride,
+ texImage->Data, i, j, texel);
}
else
_mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n");
{
(void) ctx;
+#if 0
if (texImage->Data) {
/* free the old texture data */
_mesa_free_texmemory(texImage->Data);
}
texImage->Data = NULL;
+#endif
}
ASSERT(ctx->Driver.FreeTextureImageBuffer);
ctx->Driver.FreeTextureImageBuffer( ctx, texImage );
+#if 0
ASSERT(texImage->Data == NULL);
if (texImage->ImageOffsets)
free(texImage->ImageOffsets);
free(texImage);
+#endif
}
img->Width = 0;
img->Height = 0;
img->Depth = 0;
+#if 0
img->RowStride = 0;
if (img->ImageOffsets) {
free(img->ImageOffsets);
img->ImageOffsets = NULL;
}
+#endif
img->Width2 = 0;
img->Height2 = 0;
img->Depth2 = 0;
img->WidthLog2 = 0;
img->HeightLog2 = 0;
img->DepthLog2 = 0;
- img->Data = NULL;
img->TexFormat = MESA_FORMAT_NONE;
}
GLint border, GLenum internalFormat,
gl_format format)
{
- GLint i;
-
ASSERT(img);
ASSERT(width >= 0);
ASSERT(height >= 0);
img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
+#if 0
/* RowStride and ImageOffsets[] describe how to address texels in 'Data' */
img->RowStride = width;
/* Allocate the ImageOffsets array and initialize to typical values.
for (i = 0; i < depth; i++) {
img->ImageOffsets[i] = i * width * height;
}
+#endif
img->TexFormat = format;
}
ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
- ASSERT(texImage->Data == NULL);
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, format,
type);
} else {
ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
- ASSERT(texImage->Data == NULL);
ctx->Driver.EGLImageTargetTexture2D(ctx, target,
texObj, texImage, image);
gl_format texFormat;
ctx->Driver.FreeTextureImageBuffer(ctx, texImage);
- ASSERT(texImage->Data == NULL);
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
internalFormat, GL_NONE,
ASSERT(texImage->Width > 0);
ASSERT(texImage->Height > 0);
ASSERT(texImage->Depth == 1);
- ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */
/* allocate storage for texture data */
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
/** used for mipmap LOD computation */
GLfloat WidthScale, HeightScale, DepthScale;
-#if 0
- GLubyte *Data; /**< The actual texture data in malloc'd memory */
-
- GLint TexelSize; /**< bytes per texel block */
-#endif
+ /** 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
+ each 2D slice in 'Data', in texels */
+ GLubyte *Data; /**< Image data, accessed via FetchTexel() */
FetchTexelFunc FetchTexel;
StoreTexelFunc Store;
-
-#if 0
- /** These fields only valid when texture memory is mapped */
- GLubyte **SliceMaps; /**< points to OneMap or a malloc'd array */
- GLint RowStride; /**< bytes per row of blocks */
-#endif
};
#if DIM == 1
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((void) (j), (void) (k), ((type *)(image)->Base.Data + (i) * (size)))
+ ((void) (j), (void) (k), ((type *)(image)->Data + (i) * (size)))
#define FETCH(x) fetch_texel_1d_##x
#define TEXEL_ADDR( type, image, i, j, k, size ) \
((void) (k), \
- ((type *)(image)->Base.Data + ((image)->Base.RowStride * (j) + (i)) * (size)))
+ ((type *)(image)->Data + ((image)->RowStride * (j) + (i)) * (size)))
#define FETCH(x) fetch_texel_2d_##x
#elif DIM == 3
#define TEXEL_ADDR( type, image, i, j, k, size ) \
- ((type *)(image)->Base.Data + ((image)->Base.ImageOffsets[k] \
- + (image)->Base.RowStride * (j) + (i)) * (size))
+ ((type *)(image)->Data + ((image)->ImageOffsets[k] \
+ + (image)->RowStride * (j) + (i)) * (size))
#define FETCH(x) fetch_texel_3d_##x
GLint i = IFLOOR(texcoords[k][0] * width) & colMask;
GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;
GLint pos = (j << shift) | i;
- GLubyte *texel = ((GLubyte *) img->Data) + 3*pos;
+ GLubyte *texel = swImg->Data + 3 * pos;
rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]);
rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]);
rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]);
const GLint col = IFLOOR(texcoords[i][0] * width) & colMask;
const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask;
const GLint pos = (row << shift) | col;
- const GLuint texel = *((GLuint *) img->Data + pos);
+ const GLuint texel = *((GLuint *) swImg->Data + pos);
rgba[i][RCOMP] = UBYTE_TO_FLOAT( (texel >> 24) );
rgba[i][GCOMP] = UBYTE_TO_FLOAT( (texel >> 16) & 0xff );
rgba[i][BCOMP] = UBYTE_TO_FLOAT( (texel >> 8) & 0xff );
const GLboolean repeatNoBorderPOT = (tObj->Sampler.WrapS == GL_REPEAT)
&& (tObj->Sampler.WrapT == GL_REPEAT)
- && (tImg->Border == 0 && (tImg->Width == tImg->RowStride))
+ && (tImg->Border == 0 && (tImg->Width == swImg->RowStride))
&& swImg->_IsPowerOfTwo;
ASSERT(lambda != NULL);
trb->Base.DataType = CHAN_TYPE;
trb->Base._BaseFormat = GL_RGBA;
}
- trb->Base.Data = trb->TexImage->Base.Data;
+ trb->Base.Data = trb->TexImage->Data;
}
{
struct swrast_texture_image *swImg = swrast_texture_image(texImage);
GLuint bytes = _mesa_format_image_size(format, width, height, depth);
+ GLuint i;
/* This _should_ be true (revisit if these ever fail) */
assert(texImage->Width == width);
assert(texImage->Height == height);
assert(texImage->Depth == depth);
- assert(!texImage->Data);
- texImage->Data = _mesa_align_malloc(bytes, 512);
+ assert(!swImg->Data);
+ swImg->Data = _mesa_align_malloc(bytes, 512);
+ if (!swImg->Data)
+ return GL_FALSE;
+
+ /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */
+ swImg->RowStride = width;
+
+ /* Allocate the ImageOffsets array and initialize to typical values.
+ * We allocate the array for 1D/2D textures too in order to avoid special-
+ * case code in the texstore routines.
+ */
+ swImg->ImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint));
+ if (!swImg->ImageOffsets)
+ return GL_FALSE;
+
+ for (i = 0; i < depth; i++) {
+ swImg->ImageOffsets[i] = i * width * height;
+ }
if ((width == 1 || _mesa_is_pow_two(texImage->Width2)) &&
(height == 1 || _mesa_is_pow_two(texImage->Height2)) &&
swImg->DepthScale = (GLfloat) texImage->Depth;
}
- return texImage->Data != NULL;
+ return GL_TRUE;
}
_swrast_free_texture_image_buffer(struct gl_context *ctx,
struct gl_texture_image *texImage)
{
- if (texImage->Data) {
- _mesa_align_free(texImage->Data);
+ struct swrast_texture_image *swImage = swrast_texture_image(texImage);
+ if (swImage->Data) {
+ _mesa_align_free(swImage->Data);
+ swImage->Data = NULL;
}
- texImage->Data = NULL;
+ if (swImage->ImageOffsets) {
+ free(swImage->ImageOffsets);
+ swImage->ImageOffsets = NULL;
+ }
}
GLubyte **mapOut,
GLint *rowStrideOut)
{
+ struct swrast_texture_image *swImage = swrast_texture_image(texImage);
GLubyte *map;
GLint stride, texelSize;
GLuint bw, bh;
stride = _mesa_format_row_stride(texImage->TexFormat, texImage->Width);
_mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
- assert(texImage->Data);
+ assert(swImage->Data);
- map = texImage->Data;
+ map = swImage->Data;
if (texImage->TexObject->Target == GL_TEXTURE_3D ||
texImage->TexObject->Target == GL_TEXTURE_2D_ARRAY) {
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
obj->Image[0][obj->BaseLevel]; \
+ const struct swrast_texture_image *swImg = \
+ swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
const GLint twidth_log2 = texImg->WidthLog2; \
- const GLubyte *texture = (const GLubyte *) texImg->Data; \
+ const GLubyte *texture = (const GLubyte *) swImg->Data; \
const GLint smask = texImg->Width - 1; \
const GLint tmask = texImg->Height - 1; \
ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
obj->Image[0][obj->BaseLevel]; \
+ const struct swrast_texture_image *swImg = \
+ swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
const GLint twidth_log2 = texImg->WidthLog2; \
- const GLubyte *texture = (const GLubyte *) texImg->Data; \
+ const GLubyte *texture = (const GLubyte *) swImg->Data; \
const GLint smask = texImg->Width - 1; \
const GLint tmask = texImg->Height - 1; \
ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
obj->Image[0][obj->BaseLevel]; \
+ const struct swrast_texture_image *swImg = \
+ swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
- info.texture = (const GLchan *) texImg->Data; \
+ info.texture = (const GLchan *) swImg->Data; \
info.twidth_log2 = texImg->WidthLog2; \
info.smask = texImg->Width - 1; \
info.tmask = texImg->Height - 1; \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
obj->Image[0][obj->BaseLevel]; \
- info.texture = (const GLchan *) texImg->Data; \
+ const struct swrast_texture_image *swImg = \
+ swrast_texture_image_const(texImg); \
+ info.texture = (const GLchan *) swImg->Data; \
info.twidth_log2 = texImg->WidthLog2; \
info.smask = texImg->Width - 1; \
info.tmask = texImg->Height - 1; \
&& texObj2D->_Swizzle == SWIZZLE_NOOP
&& swImg->_IsPowerOfTwo
&& texImg->Border == 0
- && texImg->Width == texImg->RowStride
+ && texImg->Width == swImg->RowStride
&& (format == MESA_FORMAT_RGB888 || format == MESA_FORMAT_RGBA8888)
&& minFilter == magFilter
&& ctx->Light.Model.ColorControl == GL_SINGLE_COLOR