0, 0, width, 1,
rwMode,
&dstMap, &dstRowStride);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ 0, /* dstRowStride */
+ &dstMap,
+ width, 1, 1,
+ format, type, pixels, packing);
- success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- 0, /* dstRowStride */
- &dstMap,
- width, 1, 1,
- format, type, pixels, packing);
-
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ success = GL_FALSE;
+ }
if (!success)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
0, 0, width, 1,
rwMode,
&dstMap, &dstRowStride);
- assert(dstMap);
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, 1, 1,
- format, type, pixels, packing);
- ctx->Driver.UnmapTextureImage(ctx, texImage, y);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, 1, 1,
+ format, type, pixels, packing);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, y);
+ }
+ else {
+ success = GL_FALSE;
+ }
if (!success)
break;
0, 0, width, height,
rwMode,
&dstMap, &dstRowStride);
- assert(dstMap);
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, height, 1,
- format, type, pixels, packing);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, height, 1,
+ format, type, pixels, packing);
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ success = GL_FALSE;
+ }
}
if (!success)
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- GLboolean success;
+ GLboolean success = GL_TRUE;
GLint slice;
GLubyte **sliceMaps;
GLint dstRowStride;
height = 1;
}
- sliceMaps = (GLubyte **) malloc(depth * sizeof(GLubyte *));
+ sliceMaps = (GLubyte **) calloc(depth, sizeof(GLubyte *));
/* Map dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
0, 0, width, height,
rwMode,
&sliceMaps[slice], &dstRowStride);
+ if (!sliceMaps[slice]) {
+ success = GL_FALSE;
+ break;
+ }
}
- success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- sliceMaps,
- width, height, depth,
- format, type, pixels, packing);
+ if (success) {
+ success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ sliceMaps,
+ width, height, depth,
+ format, type, pixels, packing);
+ }
/* Unmap dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
- ctx->Driver.UnmapTextureImage(ctx, texImage, slice);
+ if (sliceMaps[slice]) {
+ ctx->Driver.UnmapTextureImage(ctx, texImage, slice);
+ }
}
if (!success)
rwMode,
&dstMap, &dstRowStride);
- success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, 1, 1,
- format, type, pixels, packing);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, 1, 1,
+ format, type, pixels, packing);
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ success = GL_FALSE;
+ }
if (!success)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
rwMode,
&dstMap, &dstRowStride);
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &dstMap,
- width, height, 1,
- format, type, pixels, packing);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, height, 1,
+ format, type, pixels, packing);
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ success = GL_FALSE;
+ }
if (!success)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- GLboolean success;
+ GLboolean success = GL_TRUE;
GLint slice;
GLubyte **sliceMaps;
GLint dstRowStride;
if (!pixels)
return;
- sliceMaps = (GLubyte **) malloc(depth * sizeof(GLubyte *));
+ sliceMaps = (GLubyte **) calloc(depth, sizeof(GLubyte *));
/* Map dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
xoffset, yoffset, width, height,
rwMode,
&sliceMaps[slice], &dstRowStride);
+ if (!sliceMaps[slice]) {
+ success = GL_FALSE;
+ break;
+ }
}
- success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- 0, 0, 0,
- dstRowStride,
- sliceMaps,
- width, height, depth,
- format, type, pixels, packing);
+ if (success) {
+ success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0,
+ dstRowStride,
+ sliceMaps,
+ width, height, depth,
+ format, type, pixels, packing);
+ }
/* Unmap dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
- ctx->Driver.UnmapTextureImage(ctx, texImage, zoffset + slice);
+ if (sliceMaps[slice]) {
+ ctx->Driver.UnmapTextureImage(ctx, texImage, zoffset + slice);
+ }
}
if (!success)
0, 0, width, height,
GL_MAP_WRITE_BIT,
&dstMap, &dstRowStride);
+ if (dstMap) {
+ /* copy the data */
+ memcpy(dstMap, data, imageSize);
- /* copy the data */
- memcpy(dstMap, data, imageSize);
-
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ }
_mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
}
GL_MAP_WRITE_BIT,
&dstMap, &dstRowStride);
- bytesPerRow = srcRowStride; /* bytes per row of blocks */
- rows = height / bh; /* rows in blocks */
+ if (dstMap) {
+ bytesPerRow = srcRowStride; /* bytes per row of blocks */
+ rows = height / bh; /* rows in blocks */
- /* copy rows of blocks */
- for (i = 0; i < rows; i++) {
- memcpy(dstMap, src, bytesPerRow);
- dstMap += dstRowStride;
- src += srcRowStride;
- }
+ /* copy rows of blocks */
+ for (i = 0; i < rows; i++) {
+ memcpy(dstMap, src, bytesPerRow);
+ dstMap += dstRowStride;
+ src += srcRowStride;
+ }
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");
+ }
_mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
}