aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker/st_cb_texture.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker/st_cb_texture.c')
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 76bf78bbf..169e235ac 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -162,9 +162,9 @@ st_FreeTextureImageBuffer(struct gl_context * ctx, struct gl_texture_image *texI
pipe_resource_reference(&stImage->pt, NULL);
}
- if (texImage->Data) {
- _mesa_align_free(texImage->Data);
- texImage->Data = NULL;
+ if (stImage->TexData) {
+ _mesa_align_free(stImage->TexData);
+ stImage->TexData = NULL;
}
}
@@ -482,7 +482,7 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
assert(width > 0);
assert(height > 0);
assert(depth > 0);
- assert(!texImage->Data);
+ assert(!stImage->TexData);
assert(!stImage->pt); /* xxx this might be wrong */
/* Look if the parent texture object has space for this image */
@@ -604,6 +604,7 @@ st_TexImage(struct gl_context * ctx,
GLuint dstRowStride = 0;
struct gl_pixelstore_attrib unpackNB;
enum pipe_transfer_usage transfer_usage = 0;
+ GLubyte *dstMap;
DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
_mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
@@ -650,10 +651,10 @@ st_TexImage(struct gl_context * ctx,
*/
if (stImage->pt) {
pipe_resource_reference(&stImage->pt, NULL);
- assert(!texImage->Data);
+ assert(!stImage->TexData);
}
- else if (texImage->Data) {
- _mesa_align_free(texImage->Data);
+ else if (stImage->TexData) {
+ _mesa_align_free(stImage->TexData);
}
/*
@@ -744,8 +745,8 @@ st_TexImage(struct gl_context * ctx,
else
transfer_usage = PIPE_TRANSFER_WRITE;
- texImage->Data = st_texture_image_map(st, stImage, 0,
- transfer_usage, 0, 0, width, height);
+ dstMap = st_texture_image_map(st, stImage, 0,
+ transfer_usage, 0, 0, width, height);
if(stImage->transfer)
dstRowStride = stImage->transfer->stride;
}
@@ -755,10 +756,11 @@ st_TexImage(struct gl_context * ctx,
width, height, depth);
dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
- texImage->Data = _mesa_align_malloc(imageSize, 16);
+ stImage->TexData = _mesa_align_malloc(imageSize, 16);
+ dstMap = stImage->TexData;
}
- if (!texImage->Data) {
+ if (!dstMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
return;
}
@@ -771,16 +773,16 @@ st_TexImage(struct gl_context * ctx,
DBG("Upload image %dx%dx%d row_len %x pitch %x\n",
width, height, depth, width, dstRowStride);
- /* Copy user texture image into the texture buffer.
+ /* Copy user texture image into the mapped texture buffer.
*/
if (compressed_src) {
const GLuint srcRowStride =
_mesa_format_row_stride(texImage->TexFormat, width);
if (dstRowStride == srcRowStride) {
- memcpy(texImage->Data, pixels, imageSize);
+ memcpy(dstMap, pixels, imageSize);
}
else {
- char *dst = texImage->Data;
+ GLubyte *dst = dstMap;
const char *src = pixels;
GLuint i, bw, bh, lines;
_mesa_get_format_block_size(texImage->TexFormat, &bw, &bh);
@@ -803,10 +805,9 @@ st_TexImage(struct gl_context * ctx,
if (!_mesa_texstore(ctx, dims,
texImage->_BaseFormat,
texImage->TexFormat,
- texImage->Data,
0, 0, 0, /* dstX/Y/Zoffset */
dstRowStride,
- texImage->ImageOffsets,
+ (GLubyte **) &dstMap, /* dstSlice */
width, height, 1,
format, type, src, unpack)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
@@ -816,9 +817,9 @@ st_TexImage(struct gl_context * ctx,
/* unmap this slice */
st_texture_image_unmap(st, stImage);
/* map next slice of 3D texture */
- texImage->Data = st_texture_image_map(st, stImage, i + 1,
- transfer_usage, 0, 0,
- width, height);
+ dstMap = st_texture_image_map(st, stImage, i + 1,
+ transfer_usage, 0, 0,
+ width, height);
src += srcImageStride;
}
}
@@ -827,9 +828,8 @@ st_TexImage(struct gl_context * ctx,
done:
_mesa_unmap_teximage_pbo(ctx, unpack);
- if (stImage->pt && texImage->Data) {
+ if (stImage->pt && stImage->transfer) {
st_texture_image_unmap(st, stImage);
- texImage->Data = NULL;
}
}
@@ -1018,7 +1018,7 @@ st_GetTexImage(struct gl_context * ctx,
if (stImage->pt && util_format_is_s3tc(stImage->pt->format)) {
/* Need to decompress the texture.
* We'll do this by rendering a textured quad (which is hopefully
- * faster than using the fallback code in texcompress.c.
+ * faster than using the fallback code in texcompress.c).
* Note that we only expect RGBA formats (no Z/depth formats).
*/
decompress_with_blit(ctx, format, type, pixels, texImage);
@@ -1047,6 +1047,7 @@ st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
const GLubyte *src;
/* init to silence warning only: */
enum pipe_transfer_usage transfer_usage = PIPE_TRANSFER_WRITE;
+ GLubyte *dstMap;
DBG("%s target %s level %d offset %d,%d %dx%d\n", __FUNCTION__,
_mesa_lookup_enum_by_nr(target),
@@ -1074,13 +1075,13 @@ st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
else
transfer_usage = PIPE_TRANSFER_WRITE;
- texImage->Data = st_texture_image_map(st, stImage, zoffset,
- transfer_usage,
- xoffset, yoffset,
- width, height);
+ dstMap = st_texture_image_map(st, stImage, zoffset,
+ transfer_usage,
+ xoffset, yoffset,
+ width, height);
}
- if (!texImage->Data) {
+ if (!dstMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
goto done;
}
@@ -1091,10 +1092,9 @@ st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
for (i = 0; i < depth; i++) {
if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
texImage->TexFormat,
- texImage->Data,
0, 0, 0,
dstRowStride,
- texImage->ImageOffsets,
+ (GLubyte **) &dstMap,
width, height, 1,
format, type, src, packing)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
@@ -1104,11 +1104,11 @@ st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
/* unmap this slice */
st_texture_image_unmap(st, stImage);
/* map next slice of 3D texture */
- texImage->Data = st_texture_image_map(st, stImage,
- zoffset + i + 1,
- transfer_usage,
- xoffset, yoffset,
- width, height);
+ dstMap = st_texture_image_map(st, stImage,
+ zoffset + i + 1,
+ transfer_usage,
+ xoffset, yoffset,
+ width, height);
src += srcImageStride;
}
}
@@ -1116,9 +1116,8 @@ st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
done:
_mesa_unmap_teximage_pbo(ctx, packing);
- if (stImage->pt && texImage->Data) {
+ if (stImage->pt && stImage->transfer) {
st_texture_image_unmap(st, stImage);
- texImage->Data = NULL;
}
}
@@ -1194,14 +1193,15 @@ st_CompressedTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
int dstBlockStride;
int y;
enum pipe_format pformat;
+ GLubyte *dstMap;
if (stImage->pt) {
pformat = stImage->pt->format;
- texImage->Data = st_texture_image_map(st, stImage, 0,
- PIPE_TRANSFER_WRITE,
- xoffset, yoffset,
- width, height);
+ dstMap = st_texture_image_map(st, stImage, 0,
+ PIPE_TRANSFER_WRITE,
+ xoffset, yoffset,
+ width, height);
srcBlockStride = util_format_get_stride(pformat, width);
dstBlockStride = stImage->transfer->stride;
@@ -1212,7 +1212,7 @@ st_CompressedTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
return;
}
- if (!texImage->Data) {
+ if (!dstMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage");
return;
}
@@ -1223,13 +1223,12 @@ st_CompressedTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
for (y = 0; y < height; y += util_format_get_blockheight(pformat)) {
/* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */
const char *src = (const char*)data + srcBlockStride * util_format_get_nblocksy(pformat, y);
- char *dst = (char*)texImage->Data + dstBlockStride * util_format_get_nblocksy(pformat, y);
+ char *dst = (char *) dstMap + dstBlockStride * util_format_get_nblocksy(pformat, y);
memcpy(dst, src, util_format_get_stride(pformat, width));
}
- if (stImage->pt) {
+ if (stImage->pt && stImage->transfer) {
st_texture_image_unmap(st, stImage);
- texImage->Data = NULL;
}
}
@@ -1356,10 +1355,9 @@ fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level,
_mesa_texstore(ctx, dims,
texImage->_BaseFormat,
texImage->TexFormat,
- texDest,
0, 0, 0,
dstRowStride,
- texImage->ImageOffsets,
+ (GLubyte **) &texDest,
width, height, 1,
GL_RGBA, GL_FLOAT, tempSrc, /* src */
&unpack);
@@ -1686,19 +1684,21 @@ copy_image_data_to_texture(struct st_context *st,
pipe_resource_reference(&stImage->pt, NULL);
}
- else if (stImage->base.Data) {
+ else if (stImage->TexData) {
+ /* Copy from malloc'd memory */
+ /* XXX this should be re-examined/tested with a compressed format */
+ GLuint blockSize = util_format_get_blocksize(stObj->pt->format);
+ GLuint srcRowStride = stImage->base.Width * blockSize;
+ GLuint srcSliceStride = stImage->base.Height * srcRowStride;
st_texture_image_data(st,
stObj->pt,
stImage->base.Face,
dstLevel,
- stImage->base.Data,
- stImage->base.RowStride *
- util_format_get_blocksize(stObj->pt->format),
- stImage->base.RowStride *
- stImage->base.Height *
- util_format_get_blocksize(stObj->pt->format));
- _mesa_align_free(stImage->base.Data);
- stImage->base.Data = NULL;
+ stImage->TexData,
+ srcRowStride,
+ srcSliceStride);
+ _mesa_align_free(stImage->TexData);
+ stImage->TexData = NULL;
}
pipe_resource_reference(&stImage->pt, stObj->pt);