#include "texcompress_fxt1.h"
#include "texcompress_rgtc.h"
#include "texcompress_s3tc.h"
+#include "texcompress_etc.h"
#include "teximage.h"
#include "texstore.h"
#include "enums.h"
const GLubyte *rgba2dst,
GLuint dstComponents,
- GLvoid *dstAddr,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride,
- const GLuint *dstImageOffsets,
+ GLubyte **dstSlices,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
const GLvoid *srcAddr,
srcRowStride == srcWidth * srcComponents &&
dimensions < 3) {
/* 1 and 2D images only */
- GLubyte *dstImage = (GLubyte *) dstAddr
+ GLubyte *dstImage = dstSlices[0]
+ dstYoffset * dstRowStride
+ dstXoffset * dstComponents;
swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map,
GLint img, row;
for (img = 0; img < srcDepth; img++) {
const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * dstComponents
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * dstComponents;
for (row = 0; row < srcHeight; row++) {
memcpy_texture(struct gl_context *ctx,
GLuint dimensions,
gl_format dstFormat,
- GLvoid *dstAddr,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
GLint dstRowStride,
- const GLuint *dstImageOffsets,
+ GLubyte **dstSlices,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
GLenum srcFormat, GLenum srcType,
const GLvoid *srcAddr,
const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLint bytesPerRow = srcWidth * texelBytes;
-#if 0
- /* XXX update/re-enable for dstImageOffsets array */
- const GLint bytesPerImage = srcHeight * bytesPerRow;
- const GLint bytesPerTexture = srcDepth * bytesPerImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
-
if (dstRowStride == srcRowStride &&
- dstRowStride == bytesPerRow &&
- ((dstImageStride == srcImageStride &&
- dstImageStride == bytesPerImage) ||
- (srcDepth == 1))) {
- /* one big memcpy */
- ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture);
+ dstRowStride == bytesPerRow) {
+ /* memcpy image by image */
+ GLint img;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstImage = dstSlices[dstZoffset + img]
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+ memcpy(dstImage, srcImage, bytesPerRow * srcHeight);
+ srcImage += srcImageStride;
+ }
}
- else
- {
+ else {
+ /* memcpy row by row */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
- ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);
+ memcpy(dstRow, srcRow, bytesPerRow);
dstRow += dstRowStride;
srcRow += srcRowStride;
}
srcImage += srcImageStride;
- dstImage += dstImageStride;
- }
- }
-#endif
-
- GLint img, row;
- for (img = 0; img < srcDepth; img++) {
- const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * texelBytes;
- for (row = 0; row < srcHeight; row++) {
- ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);
- dstRow += dstRowStride;
- srcRow += srcRowStride;
}
- srcImage += srcImageStride;
}
}
{
const GLuint depthScale = 0xffffffff;
const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
- const GLenum dstType = _mesa_get_format_datatype(dstFormat);
+ GLenum dstType;
(void) dims;
ASSERT(dstFormat == MESA_FORMAT_Z32 ||
dstFormat == MESA_FORMAT_Z32_FLOAT);
ASSERT(texelBytes == sizeof(GLuint));
+ if (dstFormat == MESA_FORMAT_Z32)
+ dstType = GL_UNSIGNED_INT;
+ else
+ dstType = GL_FLOAT;
+
if (ctx->Pixel.DepthScale == 1.0f &&
ctx->Pixel.DepthBias == 0.0f &&
!srcPacking->SwapBytes &&
srcType == dstType) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
/* general path */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
/* general path */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
/* general path */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
/* general path */
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_UNSIGNED_SHORT_5_6_5) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
const GLubyte *src = (const GLubyte *)
_mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,
srcFormat, srcType, 0, 0, 0);
- GLubyte *dst = (GLubyte *) dstAddr
+ GLubyte *dst = dstSlices[0]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
GLint row, col;
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGBA8888 ||
- dstFormat == MESA_FORMAT_RGBA8888_REV);
+ dstFormat == MESA_FORMAT_RGBA8888_REV ||
+ dstFormat == MESA_FORMAT_RGBX8888 ||
+ dstFormat == MESA_FORMAT_RGBX8888_REV);
ASSERT(texelBytes == 4);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGBA8888 &&
+ (dstFormat == MESA_FORMAT_RGBA8888 ||
+ dstFormat == MESA_FORMAT_RGBX8888) &&
baseInternalFormat == GL_RGBA &&
((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
(srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
else if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGBA8888_REV &&
+ (dstFormat == MESA_FORMAT_RGBA8888_REV ||
+ dstFormat == MESA_FORMAT_RGBX8888_REV) &&
baseInternalFormat == GL_RGBA &&
((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
(srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_BYTE && !littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
/* dstmap - how to swizzle from RGBA to dst format:
*/
- if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) ||
- (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) {
+ if ((littleEndian && (dstFormat == MESA_FORMAT_RGBA8888 ||
+ dstFormat == MESA_FORMAT_RGBX8888)) ||
+ (!littleEndian && (dstFormat == MESA_FORMAT_RGBA8888_REV ||
+ dstFormat == MESA_FORMAT_RGBX8888_REV))) {
dstmap[3] = 0;
dstmap[2] = 1;
dstmap[1] = 2;
srcType,
baseInternalFormat,
dstmap, 4,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_RGBA8888) {
+ if (dstFormat == MESA_FORMAT_RGBA8888 ||
+ dstFormat == MESA_FORMAT_RGBX8888) {
for (col = 0; col < srcWidth; col++) {
dstUI[col] = PACK_COLOR_8888( src[RCOMP],
src[GCOMP],
srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
/* simple memcpy path (little endian) */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
srcType == GL_UNSIGNED_INT_8_8_8_8)) {
/* simple memcpy path (big endian) */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
_mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
_mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType,
baseInternalFormat,
dstmap, 4,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstXoffset, dstYoffset, dstZoffset,
dstRowStride,
- dstImageOffsets,
+ dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
_mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType,
baseInternalFormat,
dstmap, 3,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
_mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType,
baseInternalFormat,
dstmap, 3,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_UNSIGNED_SHORT_5_5_5_1) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
baseInternalFormat == GL_RGBA) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
if (baseInternalFormat == GL_RGBA) {
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
ASSERT(dstFormat == MESA_FORMAT_AL88 ||
dstFormat == MESA_FORMAT_AL88_REV ||
- dstFormat == MESA_FORMAT_RG88 ||
- dstFormat == MESA_FORMAT_RG88_REV);
+ dstFormat == MESA_FORMAT_GR88 ||
+ dstFormat == MESA_FORMAT_RG88);
ASSERT(texelBytes == 2);
if (!ctx->_ImageTransferState &&
((dstFormat == MESA_FORMAT_AL88 &&
baseInternalFormat == GL_LUMINANCE_ALPHA &&
srcFormat == GL_LUMINANCE_ALPHA) ||
- (dstFormat == MESA_FORMAT_RG88 &&
+ (dstFormat == MESA_FORMAT_GR88 &&
baseInternalFormat == srcFormat)) &&
srcType == GL_UNSIGNED_BYTE &&
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
}
}
else {
- if ((littleEndian && dstFormat == MESA_FORMAT_RG88) ||
- (!littleEndian && dstFormat == MESA_FORMAT_RG88_REV)) {
+ if ((littleEndian && dstFormat == MESA_FORMAT_GR88) ||
+ (!littleEndian && dstFormat == MESA_FORMAT_RG88)) {
dstmap[0] = 0;
dstmap[1] = 1;
}
srcType,
baseInternalFormat,
dstmap, 2,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == MESA_FORMAT_AL88 ||
- dstFormat == MESA_FORMAT_RG88) {
+ dstFormat == MESA_FORMAT_GR88) {
for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
+ /* src[0] is luminance (or R), src[1] is alpha (or G) */
dstUS[col] = PACK_COLOR_88( src[1],
src[0] );
src += 2;
}
else {
for (col = 0; col < srcWidth; col++) {
- /* src[0] is luminance, src[1] is alpha */
+ /* src[0] is luminance (or R), src[1] is alpha (or G) */
dstUS[col] = PACK_COLOR_88_REV( src[1],
src[0] );
src += 2;
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
* 3 or 4 components/pixel here.
*/
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
srcType,
baseInternalFormat,
dstmap, 1,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
/* always just memcpy since no pixel transfer ops apply */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
!littleEndian) {
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
GL_UNSIGNED_BYTE, /* hack */
GL_LUMINANCE_ALPHA, /* hack */
dstmap, 2,
- dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
}
}
src = tempImage;
- dst = (GLbyte *) dstAddr
+ dst = (GLbyte *) dstSlices[0]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
littleEndian) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
(srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
(srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLbyte *dstRow = (GLbyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLbyte *dstRow = (GLbyte *) dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
!srcPacking->SwapBytes) {
/* simple path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
srcFormat == GL_STENCIL_INDEX) {
/* In case we only upload depth we need to preserve the stencil */
for (img = 0; img < srcDepth; img++) {
- GLuint *dstRow = (GLuint *) dstAddr
- + dstImageOffsets[dstZoffset + img]
- + dstYoffset * dstRowStride / sizeof(GLuint)
- + dstXoffset;
+ GLuint *dstRow = (GLuint *) (dstSlices[dstZoffset + img]
+ + dstYoffset * dstRowStride
+ + dstXoffset * 4);
const GLubyte *src
= (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
srcType == GL_UNSIGNED_INT_24_8_EXT);
for (img = 0; img < srcDepth; img++) {
- GLuint *dstRow = (GLuint *) dstAddr
- + dstImageOffsets[dstZoffset + img]
- + dstYoffset * dstRowStride / sizeof(GLuint)
- + dstXoffset;
+ GLuint *dstRow = (GLuint *) (dstSlices[dstZoffset + img]
+ + dstYoffset * dstRowStride
+ + dstXoffset * 4);
const GLubyte *src
= (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img]
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride / sizeof(GLuint)
+ dstXoffset;
const GLubyte *src
srcType == GL_FLOAT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
return GL_FALSE;
bytesPerRow = srcWidth * components * sizeof(GLfloat);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
srcType == GL_HALF_FLOAT_ARB) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT8);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
srcType == GL_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT16);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
srcType == GL_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT32);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
srcType == GL_INT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT8);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
srcType == GL_UNSIGNED_BYTE) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT16);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
srcType == GL_UNSIGNED_SHORT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT32);
ASSERT(baseInternalFormat == GL_RGBA ||
baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_RG ||
+ baseInternalFormat == GL_RED ||
baseInternalFormat == GL_ALPHA ||
baseInternalFormat == GL_LUMINANCE ||
baseInternalFormat == GL_LUMINANCE_ALPHA ||
srcType == GL_UNSIGNED_INT) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * texelBytes
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
newDstFormat = MESA_FORMAT_RGB888;
k = _mesa_texstore_rgb888(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
+ newDstFormat,
dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
srcAddr, srcPacking);
/* reuse normal rgba texstore code */
newDstFormat = MESA_FORMAT_RGBA8888;
k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
+ newDstFormat,
dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
srcAddr, srcPacking);
newDstFormat = MESA_FORMAT_ARGB8888;
k = _mesa_texstore_argb8888(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
+ newDstFormat,
dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
srcAddr, srcPacking);
/* _mesa_textore_a8 handles luminance8 too */
k = _mesa_texstore_unorm8(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
- dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
- srcWidth, srcHeight, srcDepth,
- srcFormat, srcType,
- srcAddr, srcPacking);
+ newDstFormat,
+ dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType,
+ srcAddr, srcPacking);
return k;
}
newDstFormat = MESA_FORMAT_AL88;
k = _mesa_texstore_unorm88(ctx, dims, baseInternalFormat,
- newDstFormat, dstAddr,
+ newDstFormat,
dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType,
srcAddr, srcPacking);
srcType == GL_UNSIGNED_INT_5_9_9_9_REV) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * 4
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * 4;
for (row = 0; row < srcHeight; row++) {
srcType == GL_UNSIGNED_INT_10F_11F_11F_REV) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
if (!tempImage)
return GL_FALSE;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * 4
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ dstYoffset * dstRowStride
+ dstXoffset * 4;
for (row = 0; row < srcHeight; row++) {
!srcPacking->SwapBytes) {
/* simple path */
memcpy_texture(ctx, dims,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride,
- dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
/* In case we only upload depth we need to preserve the stencil */
for (img = 0; img < srcDepth; img++) {
- uint64_t *dstRow = (uint64_t *) dstAddr
- + dstImageOffsets[dstZoffset + img]
- + dstYoffset * dstRowStride / sizeof(uint64_t)
- + dstXoffset;
+ uint64_t *dstRow = (uint64_t *) (dstSlices[dstZoffset + img]
+ + dstYoffset * dstRowStride
+ + dstXoffset * 8);
const uint64_t *src
= (const uint64_t *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
return GL_TRUE;
}
+static GLboolean
+_mesa_texstore_argb2101010_uint(TEXSTORE_PARAMS)
+{
+ const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_ARGB2101010_UINT);
+ ASSERT(texelBytes == 4);
+
+ if (!srcPacking->SwapBytes &&
+ dstFormat == MESA_FORMAT_ARGB2101010_UINT &&
+ srcFormat == GL_BGRA_INTEGER_EXT &&
+ srcType == GL_UNSIGNED_INT_2_10_10_10_REV &&
+ baseInternalFormat == GL_RGBA) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLuint *tempImage = make_temp_uint_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight,
+ srcDepth, srcFormat,
+ srcType, srcAddr,
+ srcPacking);
+ const GLuint *src = tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstSlices[dstZoffset + img]
+ + dstYoffset * dstRowStride
+ + dstXoffset * texelBytes;
+
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ GLushort a,r,g,b;
+ r = src[RCOMP];
+ g = src[GCOMP];
+ b = src[BCOMP];
+ a = src[ACOMP];
+ dstUI[col] = (a << 30) | (r << 20) | (g << 10) | (b);
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
static GLboolean
_mesa_texstore_null(TEXSTORE_PARAMS)
{
(void) ctx; (void) dims;
(void) baseInternalFormat;
(void) dstFormat;
- (void) dstAddr;
(void) dstXoffset; (void) dstYoffset; (void) dstZoffset;
- (void) dstRowStride; (void) dstImageOffsets;
+ (void) dstRowStride; (void) dstSlices,
(void) srcWidth; (void) srcHeight; (void) srcDepth;
(void) srcFormat; (void) srcType;
(void) srcAddr;
table[MESA_FORMAT_RGBA8888_REV] = _mesa_texstore_rgba8888;
table[MESA_FORMAT_ARGB8888] = _mesa_texstore_argb8888;
table[MESA_FORMAT_ARGB8888_REV] = _mesa_texstore_argb8888;
+ table[MESA_FORMAT_RGBX8888] = _mesa_texstore_rgba8888;
+ table[MESA_FORMAT_RGBX8888_REV] = _mesa_texstore_rgba8888;
table[MESA_FORMAT_XRGB8888] = _mesa_texstore_argb8888;
table[MESA_FORMAT_XRGB8888_REV] = _mesa_texstore_argb8888;
table[MESA_FORMAT_RGB888] = _mesa_texstore_rgb888;
table[MESA_FORMAT_YCBCR] = _mesa_texstore_ycbcr;
table[MESA_FORMAT_YCBCR_REV] = _mesa_texstore_ycbcr;
table[MESA_FORMAT_R8] = _mesa_texstore_unorm8;
+ table[MESA_FORMAT_GR88] = _mesa_texstore_unorm88;
table[MESA_FORMAT_RG88] = _mesa_texstore_unorm88;
- table[MESA_FORMAT_RG88_REV] = _mesa_texstore_unorm88;
table[MESA_FORMAT_R16] = _mesa_texstore_unorm16;
table[MESA_FORMAT_RG1616] = _mesa_texstore_unorm1616;
table[MESA_FORMAT_RG1616_REV] = _mesa_texstore_unorm1616;
table[MESA_FORMAT_SIGNED_L_LATC1] = _mesa_texstore_signed_red_rgtc1;
table[MESA_FORMAT_LA_LATC2] = _mesa_texstore_rg_rgtc2;
table[MESA_FORMAT_SIGNED_LA_LATC2] = _mesa_texstore_signed_rg_rgtc2;
+ table[MESA_FORMAT_ETC1_RGB8] = _mesa_texstore_etc1_rgb8;
table[MESA_FORMAT_SIGNED_A8] = _mesa_texstore_snorm8;
table[MESA_FORMAT_SIGNED_L8] = _mesa_texstore_snorm8;
table[MESA_FORMAT_SIGNED_AL88] = _mesa_texstore_snorm88;
table[MESA_FORMAT_RGB_UINT32] = _mesa_texstore_rgba_uint32;
table[MESA_FORMAT_RGBA_UINT32] = _mesa_texstore_rgba_uint32;
+ table[MESA_FORMAT_ARGB2101010_UINT] = _mesa_texstore_argb2101010_uint;
initialized = GL_TRUE;
}
storeImage = _mesa_get_texstore_func(dstFormat);
success = storeImage(ctx, dims, baseInternalFormat,
- dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageOffsets,
+ dstFormat, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr, srcPacking);
return success;
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- const GLuint zeroImageOffset = 0;
GLubyte *dstMap;
GLint dstRowStride;
GLboolean success;
(void) border;
+ if (width == 0)
+ return;
+
/* allocate storage for texture data */
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
width, 1, 1)) {
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,
- dstMap,
- 0, 0, 0, /* dstX/Y/Zoffset */
- 0, /* dstRowStride */
- &zeroImageOffset,
- 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");
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- const GLuint zeroImageOffset = 0;
GLubyte *dstMap;
GLint dstRowStride;
GLboolean success;
(void) border;
+ if (width == 0 || height == 0)
+ return;
+
/* allocate storage for texture data */
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
width, height, 1)) {
0, 0, width, 1,
rwMode,
&dstMap, &dstRowStride);
- assert(dstMap);
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- dstMap,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &zeroImageOffset,
- 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,
- dstMap,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &zeroImageOffset,
- 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;
- GLuint *dstImageOffsets;
GLint dstRowStride;
- GLuint texelSize = _mesa_get_format_bytes(texImage->TexFormat);
(void) border;
+ if (width == 0 || height == 0 || depth == 0)
+ return;
+
/* allocate storage for texture data */
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage, texImage->TexFormat,
width, height, depth)) {
height = 1;
}
- sliceMaps = (GLubyte **) malloc(depth * sizeof(GLubyte *));
- dstImageOffsets = (GLuint *) malloc(depth * sizeof(GLuint));
+ 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);
- }
- /* Compute image slice offsets */
- for (slice = 0; slice < depth; slice++) {
- dstImageOffsets[slice] = (sliceMaps[slice] - sliceMaps[0]) / texelSize;
+ if (!sliceMaps[slice]) {
+ success = GL_FALSE;
+ break;
+ }
}
- success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- sliceMaps[0],
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- dstImageOffsets,
- 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)
_mesa_unmap_teximage_pbo(ctx, packing);
free(sliceMaps);
- free(dstImageOffsets);
}
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- const GLuint zeroImageOffset = 0;
GLubyte *dstMap;
GLint dstRowStride;
GLboolean success;
if (!pixels)
return;
- /* Map dest texture buffer (write to whole region) */
+ /* Map dest texture buffer */
ctx->Driver.MapTextureImage(ctx, texImage, 0,
xoffset, 0, width, 1,
rwMode,
&dstMap, &dstRowStride);
- success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
- texImage->TexFormat,
- dstMap,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &zeroImageOffset,
- 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");
struct gl_texture_image *texImage)
{
const GLbitfield rwMode = get_read_write_mode(format, texImage->TexFormat);
- const GLuint zeroImageOffset = 0;
- GLubyte *dstMap;
- GLint dstRowStride;
- GLboolean success;
+ GLboolean success = GL_FALSE;
+ GLuint slice, numSlices, sliceOffset, srcImageStride;
+ const GLubyte *src;
/* get pointer to src pixels (may be in a pbo which we'll map here) */
- pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
- pixels, packing, "glTexSubImage2D");
- if (!pixels)
+ src = (const GLubyte *)
+ _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
+ pixels, packing, "glTexSubImage2D");
+ if (!src)
return;
- /* Map dest texture buffer (write to whole region) */
- ctx->Driver.MapTextureImage(ctx, texImage, 0,
- xoffset, yoffset, width, height,
- rwMode,
- &dstMap, &dstRowStride);
+ if (target == GL_TEXTURE_1D_ARRAY) {
+ /* map each slice of the 1D array separately */
+ numSlices = height;
+ sliceOffset = yoffset;
+ height = 1;
+ yoffset = 0;
+ srcImageStride = _mesa_image_row_stride(packing, width, format, type);
+ }
+ else {
+ /* regular 2D image */
+ numSlices = 1;
+ sliceOffset = 0;
+ srcImageStride = 0;
+ }
+
+ for (slice = 0; slice < numSlices; slice++) {
+ GLubyte *dstMap;
+ GLint dstRowStride;
+
+ ctx->Driver.MapTextureImage(ctx, texImage,
+ slice + sliceOffset,
+ xoffset, yoffset, width, height,
+ rwMode, &dstMap, &dstRowStride);
+ if (dstMap) {
+ success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ &dstMap,
+ width, height, 1, /* w, h, d */
+ format, type, src, packing);
+
+ ctx->Driver.UnmapTextureImage(ctx, texImage, slice + sliceOffset);
+ }
- success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
- texImage->TexFormat,
- dstMap,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- &zeroImageOffset,
- width, height, 1,
- format, type, pixels, packing);
+ src += srcImageStride;
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
+ if (!success)
+ break;
+ }
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;
- GLuint *dstImageOffsets;
GLint dstRowStride;
- GLuint texelSize = _mesa_get_format_bytes(texImage->TexFormat);
/* get pointer to src pixels (may be in a pbo which we'll map here) */
pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
if (!pixels)
return;
- sliceMaps = (GLubyte **) malloc((zoffset + depth) * sizeof(GLubyte *));
- dstImageOffsets = (GLuint *) malloc((zoffset + depth) * sizeof(GLuint));
+ sliceMaps = (GLubyte **) calloc(depth, sizeof(GLubyte *));
/* Map dest texture buffer slices */
for (slice = 0; slice < depth; slice++) {
ctx->Driver.MapTextureImage(ctx, texImage, zoffset + slice,
xoffset, yoffset, width, height,
rwMode,
- &sliceMaps[zoffset + slice], &dstRowStride);
+ &sliceMaps[slice], &dstRowStride);
+ if (!sliceMaps[slice]) {
+ success = GL_FALSE;
+ break;
+ }
}
- /* Compute image slice offsets */
- for (slice = 0; slice < depth; slice++) {
- dstImageOffsets[slice] =
- (sliceMaps[zoffset + slice] - sliceMaps[zoffset]) / texelSize;
+ if (success) {
+ success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+ texImage->TexFormat,
+ 0, 0, 0,
+ dstRowStride,
+ sliceMaps,
+ width, height, depth,
+ format, type, pixels, packing);
}
- success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
- texImage->TexFormat,
- sliceMaps[zoffset],
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- dstImageOffsets,
- 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)
_mesa_unmap_teximage_pbo(ctx, packing);
free(sliceMaps);
- free(dstImageOffsets);
}
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- GLubyte *dstMap;
- GLint dstRowStride;
-
- /* This is pretty simple, basically just do a memcpy without worrying
- * about the usual image unpacking or image transfer operations.
+ /* This is pretty simple, because unlike the general texstore path we don't
+ * have to worry about the usual image unpacking or image transfer
+ * operations.
*/
ASSERT(texObj);
ASSERT(texImage);
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,
return;
}
- data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
- &ctx->Unpack,
- "glCompressedTexImage2D");
- if (!data)
- return;
-
-
- /* Map dest texture buffer (write to whole region) */
- ctx->Driver.MapTextureImage(ctx, texImage, 0,
- 0, 0, width, height,
- GL_MAP_WRITE_BIT,
- &dstMap, &dstRowStride);
-
- /* copy the data */
- memcpy(dstMap, data, imageSize);
-
- ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
-
- _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
+ _mesa_store_compressed_texsubimage2d(ctx, target, level,
+ 0, 0,
+ width, height,
+ texImage->TexFormat,
+ imageSize, data,
+ texObj, texImage);
}
_mesa_get_format_block_size(texFormat, &bw, &bh);
/* these should have been caught sooner */
- ASSERT((width % bw) == 0 || width == 2 || width == 1);
- ASSERT((height % bh) == 0 || height == 2 || height == 1);
+ ASSERT((width % bw) == 0 || width < bw);
+ ASSERT((height % bh) == 0 || height < bh);
ASSERT((xoffset % bw) == 0);
ASSERT((yoffset % bh) == 0);
srcRowStride = _mesa_format_row_stride(texFormat, width);
src = (const GLubyte *) data;
- /* Map dest texture buffer (write to whole region) */
+ /* Map dest texture buffer */
ctx->Driver.MapTextureImage(ctx, texImage, 0,
xoffset, yoffset, width, height,
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 - 1) / 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);
}