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);
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;
}
dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
texImage->Data = _mesa_align_malloc(imageSize, 16);
+ dstMap = texImage->Data;
}
- if (!texImage->Data) {
+ if (!dstMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
return;
}
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);
texImage->TexFormat,
0, 0, 0, /* dstX/Y/Zoffset */
dstRowStride,
- (GLubyte **) &texImage->Data, /* dstSlice */
+ (GLubyte **) &dstMap, /* dstSlice */
width, height, 1,
format, type, src, unpack)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
/* 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;
}
}
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;
}
}
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),
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;
}
texImage->TexFormat,
0, 0, 0,
dstRowStride,
- (GLubyte **) &texImage->Data,
+ (GLubyte **) &dstMap,
width, height, 1,
format, type, src, packing)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
/* 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;
}
}
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;
}
}
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;
return;
}
- if (!texImage->Data) {
+ if (!dstMap) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage");
return;
}
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;
}
}