summaryrefslogtreecommitdiff
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c502
1 files changed, 242 insertions, 260 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 4868b806ea..28f6a191fd 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -611,7 +611,8 @@ _mesa_swizzle_ubyte_image(GLcontext *ctx,
GLvoid *dstAddr,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
- GLint dstRowStride, GLint dstImageStride,
+ GLint dstRowStride,
+ const GLuint *dstImageOffsets,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
const GLvoid *srcAddr,
@@ -632,11 +633,6 @@ _mesa_swizzle_ubyte_image(GLcontext *ctx,
srcWidth, srcHeight, srcFormat,
GL_UNSIGNED_BYTE, 0, 0, 0);
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstComponents;
-
(void) ctx;
compute_component_mapping(srcFormat, GL_RGBA, srcmap);
@@ -645,23 +641,28 @@ _mesa_swizzle_ubyte_image(GLcontext *ctx,
map[i] = srcmap[dstmap[i]];
if (srcRowStride == srcWidth * srcComponents &&
- (srcImageStride == srcWidth * srcHeight * srcComponents ||
- srcDepth == 1)) {
+ dimensions < 3) {
+ /* 1 and 2D images only */
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstComponents;
swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map,
- srcWidth * srcHeight * srcDepth);
+ srcWidth * srcHeight);
}
else {
GLint img, row;
for (img = 0; img < srcDepth; img++) {
const GLubyte *srcRow = srcImage;
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstComponents
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstComponents;
for (row = 0; row < srcHeight; row++) {
swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth);
dstRow += dstRowStride;
srcRow += srcRowStride;
}
srcImage += srcImageStride;
- dstImage += dstImageStride;
}
}
}
@@ -678,7 +679,8 @@ memcpy_texture(GLcontext *ctx,
const struct gl_texture_format *dstFormat,
GLvoid *dstAddr,
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
- GLint dstRowStride, GLint dstImageStride,
+ GLint dstRowStride,
+ const GLuint *dstImageOffsets,
GLint srcWidth, GLint srcHeight, GLint srcDepth,
GLenum srcFormat, GLenum srcType,
const GLvoid *srcAddr,
@@ -691,6 +693,9 @@ memcpy_texture(GLcontext *ctx,
const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions,
srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes;
+
+#if 0
+ /* XXX update/re-enable for dstImageOffsets array */
const GLint bytesPerImage = srcHeight * bytesPerRow;
const GLint bytesPerTexture = srcDepth * bytesPerImage;
GLubyte *dstImage = (GLubyte *) dstAddr
@@ -706,7 +711,8 @@ memcpy_texture(GLcontext *ctx,
/* one big memcpy */
ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture);
}
- else {
+ else
+ {
GLint img, row;
for (img = 0; img < srcDepth; img++) {
const GLubyte *srcRow = srcImage;
@@ -720,6 +726,22 @@ memcpy_texture(GLcontext *ctx,
dstImage += dstImageStride;
}
}
+#endif
+
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ const GLubyte *srcRow = srcImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (row = 0; row < srcHeight; row++) {
+ ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ srcImage += srcImageStride;
+ }
}
@@ -733,30 +755,9 @@ memcpy_texture(GLcontext *ctx,
* _mesa_texformat_luminance_alpha
* _mesa_texformat_intensity
*
- * \param dims either 1 or 2 or 3
- * \param baseInternalFormat user-specified base internal format
- * \param dstFormat destination Mesa texture format
- * \param dstAddr destination image address
- * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
- * \param dstRowStride destination image row stride, in bytes
- * \param dstImageStride destination image layer stride, in bytes
- * \param srcWidth/Height/Depth source image size, in pixels
- * \param srcFormat incoming image format
- * \param srcType incoming image data type
- * \param srcAddr source image address
- * \param srcPacking source image packing parameters
*/
GLboolean
-_mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
- GLenum baseInternalFormat,
- const struct gl_texture_format *dstFormat,
- GLvoid *dstAddr,
- GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
- GLint dstRowStride, GLint dstImageStride,
- GLint srcWidth, GLint srcHeight, GLint srcDepth,
- GLenum srcFormat, GLenum srcType,
- const GLvoid *srcAddr,
- const struct gl_pixelstore_attrib *srcPacking)
+_mesa_texstore_rgba(TEXSTORE_PARAMS)
{
const GLint components = _mesa_components_in_format(baseInternalFormat);
@@ -781,7 +782,8 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -791,12 +793,14 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
srcFormat == GL_RGBA &&
srcType == CHAN_TYPE) {
/* extract RGB from RGBA */
- int img, row, col;
- GLchan *dstImage = (GLchan *) ((GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes);
+ GLint img, row, col;
for (img = 0; img < srcDepth; img++) {
+ GLchan *dstImage = (GLchan *)
+ ((GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes);
+
const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
srcWidth, srcFormat, srcType);
GLchan *srcRow = (GLchan *) _mesa_image_address(dims, srcPacking,
@@ -811,7 +815,6 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
dstRow += dstRowStride / sizeof(GLchan);
srcRow = (GLchan *) ((GLubyte *) srcRow + srcRowStride);
}
- dstImage += dstImageStride / sizeof(GLchan);
}
}
else {
@@ -824,23 +827,21 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
srcPacking);
const GLchan *src = tempImage;
GLint bytesPerRow;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
bytesPerRow = srcWidth * components * sizeof(GLchan);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
_mesa_memcpy(dstRow, src, bytesPerRow);
dstRow += dstRowStride;
src += srcWidth * components;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
@@ -853,7 +854,7 @@ _mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
* Store a 32-bit integer depth component texture image.
*/
GLboolean
-_mesa_texstore_z32(STORE_PARAMS)
+_mesa_texstore_z32(TEXSTORE_PARAMS)
{
const GLfloat depthScale = (GLfloat) 0xffffffff;
(void) dims;
@@ -868,19 +869,19 @@ _mesa_texstore_z32(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
else {
/* general path */
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -889,18 +890,18 @@ _mesa_texstore_z32(STORE_PARAMS)
depthScale, srcType, src, srcPacking);
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
}
return GL_TRUE;
}
+#define STRIDE_3D 0
/**
* Store a 16-bit integer depth component texture image.
*/
GLboolean
-_mesa_texstore_z16(STORE_PARAMS)
+_mesa_texstore_z16(TEXSTORE_PARAMS)
{
const GLfloat depthScale = 65535.0f;
(void) dims;
@@ -915,19 +916,19 @@ _mesa_texstore_z16(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
else {
/* general path */
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -937,7 +938,6 @@ _mesa_texstore_z16(STORE_PARAMS)
srcType, src, srcPacking);
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
}
return GL_TRUE;
@@ -948,7 +948,7 @@ _mesa_texstore_z16(STORE_PARAMS)
* Store an rgb565 or rgb565_rev texture image.
*/
GLboolean
-_mesa_texstore_rgb565(STORE_PARAMS)
+_mesa_texstore_rgb565(TEXSTORE_PARAMS)
{
ASSERT(dstFormat == &_mesa_texformat_rgb565 ||
dstFormat == &_mesa_texformat_rgb565_rev);
@@ -963,7 +963,8 @@ _mesa_texstore_rgb565(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -980,7 +981,6 @@ _mesa_texstore_rgb565(STORE_PARAMS)
_mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,
srcFormat, srcType, 0, 0, 0);
GLubyte *dst = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
+ dstYoffset * dstRowStride
+ dstXoffset * dstFormat->TexelBytes;
GLint row, col;
@@ -1013,16 +1013,15 @@ _mesa_texstore_rgb565(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
/* check for byteswapped format */
@@ -1044,7 +1043,6 @@ _mesa_texstore_rgb565(STORE_PARAMS)
}
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1053,7 +1051,7 @@ _mesa_texstore_rgb565(STORE_PARAMS)
GLboolean
-_mesa_texstore_rgba8888(STORE_PARAMS)
+_mesa_texstore_rgba8888(TEXSTORE_PARAMS)
{
const GLuint ui = 1;
const GLubyte littleEndian = *((const GLubyte *) &ui);
@@ -1072,11 +1070,13 @@ _mesa_texstore_rgba8888(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
#if 0
+ /* broken? */
else if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
srcType == GL_UNSIGNED_BYTE &&
@@ -1118,16 +1118,15 @@ _mesa_texstore_rgba8888(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == &_mesa_texformat_rgba8888) {
@@ -1150,7 +1149,6 @@ _mesa_texstore_rgba8888(STORE_PARAMS)
}
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1159,7 +1157,7 @@ _mesa_texstore_rgba8888(STORE_PARAMS)
GLboolean
-_mesa_texstore_argb8888(STORE_PARAMS)
+_mesa_texstore_argb8888(TEXSTORE_PARAMS)
{
const GLuint ui = 1;
const GLubyte littleEndian = *((const GLubyte *) &ui);
@@ -1178,7 +1176,8 @@ _mesa_texstore_argb8888(STORE_PARAMS)
/* simple memcpy path (little endian) */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1192,7 +1191,8 @@ _mesa_texstore_argb8888(STORE_PARAMS)
/* simple memcpy path (big endian) */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1203,16 +1203,15 @@ _mesa_texstore_argb8888(STORE_PARAMS)
srcType == GL_UNSIGNED_BYTE) {
int img, row, col;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _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 = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col * 4 + 0] = srcRow[col * 3 + BCOMP];
@@ -1223,7 +1222,6 @@ _mesa_texstore_argb8888(STORE_PARAMS)
dstRow += dstRowStride;
srcRow += srcRowStride;
}
- dstImage += dstImageStride;
}
}
else if (!ctx->_ImageTransferState &&
@@ -1231,13 +1229,7 @@ _mesa_texstore_argb8888(STORE_PARAMS)
dstFormat == &_mesa_texformat_argb8888 &&
srcFormat == GL_RGBA &&
(srcType == GL_UNSIGNED_BYTE && littleEndian)) {
-
- int img, row, col;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
-
+ GLint img, row, col;
/* For some reason, streaming copies to write-combined regions
* are extremely sensitive to the characteristics of how the
* source data is retrieved. By reordering the source reads to
@@ -1249,7 +1241,11 @@ _mesa_texstore_argb8888(STORE_PARAMS)
srcWidth, srcFormat, srcType);
GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
*(GLuint *)(dstRow + col * 4) = (srcRow[col * 4 + RCOMP] << 16 |
@@ -1260,7 +1256,6 @@ _mesa_texstore_argb8888(STORE_PARAMS)
dstRow += dstRowStride;
srcRow += srcRowStride;
}
- dstImage += dstImageStride;
}
}
else if (!ctx->_ImageTransferState &&
@@ -1269,17 +1264,16 @@ _mesa_texstore_argb8888(STORE_PARAMS)
srcFormat == GL_RGBA &&
srcType == GL_UNSIGNED_BYTE) {
- int img, row, col;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _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 = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col * 4 + 0] = srcRow[col * 4 + BCOMP];
@@ -1290,7 +1284,6 @@ _mesa_texstore_argb8888(STORE_PARAMS)
dstRow += dstRowStride;
srcRow += srcRowStride;
}
- dstImage += dstImageStride;
}
}
else if (!ctx->_ImageTransferState &&
@@ -1319,7 +1312,8 @@ _mesa_texstore_argb8888(STORE_PARAMS)
srcFormat,
dstmap, 4,
dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcAddr,
srcPacking);
}
@@ -1332,16 +1326,15 @@ _mesa_texstore_argb8888(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
if (dstFormat == &_mesa_texformat_argb8888) {
@@ -1364,7 +1357,6 @@ _mesa_texstore_argb8888(STORE_PARAMS)
}
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1373,7 +1365,7 @@ _mesa_texstore_argb8888(STORE_PARAMS)
GLboolean
-_mesa_texstore_rgb888(STORE_PARAMS)
+_mesa_texstore_rgb888(TEXSTORE_PARAMS)
{
const GLuint ui = 1;
const GLubyte littleEndian = *((const GLubyte *) &ui);
@@ -1390,7 +1382,8 @@ _mesa_texstore_rgb888(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1399,17 +1392,16 @@ _mesa_texstore_rgb888(STORE_PARAMS)
srcFormat == GL_RGBA &&
srcType == GL_UNSIGNED_BYTE) {
/* extract RGB from RGBA */
- int img, row, col;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _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 = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP];
@@ -1419,7 +1411,6 @@ _mesa_texstore_rgb888(STORE_PARAMS)
dstRow += dstRowStride;
srcRow += srcRowStride;
}
- dstImage += dstImageStride;
}
}
else {
@@ -1431,16 +1422,15 @@ _mesa_texstore_rgb888(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = (const GLchan *) tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
#if 0
if (littleEndian) {
@@ -1469,7 +1459,6 @@ _mesa_texstore_rgb888(STORE_PARAMS)
#endif
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1478,7 +1467,7 @@ _mesa_texstore_rgb888(STORE_PARAMS)
GLboolean
-_mesa_texstore_bgr888(STORE_PARAMS)
+_mesa_texstore_bgr888(TEXSTORE_PARAMS)
{
const GLuint ui = 1;
const GLubyte littleEndian = *((const GLubyte *) &ui);
@@ -1495,7 +1484,8 @@ _mesa_texstore_bgr888(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1505,16 +1495,15 @@ _mesa_texstore_bgr888(STORE_PARAMS)
srcType == GL_UNSIGNED_BYTE) {
/* extract BGR from RGBA */
int img, row, col;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
for (img = 0; img < srcDepth; img++) {
const GLint srcRowStride = _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 = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];
@@ -1524,7 +1513,6 @@ _mesa_texstore_bgr888(STORE_PARAMS)
dstRow += dstRowStride;
srcRow += srcRowStride;
}
- dstImage += dstImageStride;
}
}
else {
@@ -1536,16 +1524,15 @@ _mesa_texstore_bgr888(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = (const GLchan *) tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
@@ -1555,7 +1542,6 @@ _mesa_texstore_bgr888(STORE_PARAMS)
}
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1564,7 +1550,7 @@ _mesa_texstore_bgr888(STORE_PARAMS)
GLboolean
-_mesa_texstore_argb4444(STORE_PARAMS)
+_mesa_texstore_argb4444(TEXSTORE_PARAMS)
{
ASSERT(dstFormat == &_mesa_texformat_argb4444 ||
dstFormat == &_mesa_texformat_argb4444_rev);
@@ -1579,7 +1565,8 @@ _mesa_texstore_argb4444(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1592,16 +1579,15 @@ _mesa_texstore_argb4444(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == &_mesa_texformat_argb4444) {
@@ -1624,7 +1610,6 @@ _mesa_texstore_argb4444(STORE_PARAMS)
}
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1634,7 +1619,7 @@ _mesa_texstore_argb4444(STORE_PARAMS)
GLboolean
-_mesa_texstore_argb1555(STORE_PARAMS)
+_mesa_texstore_argb1555(TEXSTORE_PARAMS)
{
ASSERT(dstFormat == &_mesa_texformat_argb1555 ||
dstFormat == &_mesa_texformat_argb1555_rev);
@@ -1649,7 +1634,8 @@ _mesa_texstore_argb1555(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1662,16 +1648,15 @@ _mesa_texstore_argb1555(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src =tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == &_mesa_texformat_argb1555) {
@@ -1694,7 +1679,6 @@ _mesa_texstore_argb1555(STORE_PARAMS)
}
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1703,7 +1687,7 @@ _mesa_texstore_argb1555(STORE_PARAMS)
GLboolean
-_mesa_texstore_al88(STORE_PARAMS)
+_mesa_texstore_al88(TEXSTORE_PARAMS)
{
const GLuint ui = 1;
const GLubyte littleEndian = *((const GLubyte *) &ui);
@@ -1722,7 +1706,8 @@ _mesa_texstore_al88(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1735,16 +1720,15 @@ _mesa_texstore_al88(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
GLushort *dstUS = (GLushort *) dstRow;
if (dstFormat == &_mesa_texformat_al88) {
@@ -1765,7 +1749,6 @@ _mesa_texstore_al88(STORE_PARAMS)
}
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1774,7 +1757,7 @@ _mesa_texstore_al88(STORE_PARAMS)
GLboolean
-_mesa_texstore_rgb332(STORE_PARAMS)
+_mesa_texstore_rgb332(TEXSTORE_PARAMS)
{
ASSERT(dstFormat == &_mesa_texformat_rgb332);
ASSERT(dstFormat->TexelBytes == 1);
@@ -1786,7 +1769,8 @@ _mesa_texstore_rgb332(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1799,16 +1783,15 @@ _mesa_texstore_rgb332(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]),
@@ -1818,7 +1801,6 @@ _mesa_texstore_rgb332(STORE_PARAMS)
}
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1830,7 +1812,7 @@ _mesa_texstore_rgb332(STORE_PARAMS)
* Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
*/
GLboolean
-_mesa_texstore_a8(STORE_PARAMS)
+_mesa_texstore_a8(TEXSTORE_PARAMS)
{
ASSERT(dstFormat == &_mesa_texformat_a8 ||
dstFormat == &_mesa_texformat_l8 ||
@@ -1844,7 +1826,8 @@ _mesa_texstore_a8(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -1857,16 +1840,15 @@ _mesa_texstore_a8(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLchan *src = tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row, col;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
for (col = 0; col < srcWidth; col++) {
dstRow[col] = CHAN_TO_UBYTE(src[col]);
@@ -1874,7 +1856,6 @@ _mesa_texstore_a8(STORE_PARAMS)
dstRow += dstRowStride;
src += srcWidth;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
}
@@ -1884,7 +1865,7 @@ _mesa_texstore_a8(STORE_PARAMS)
GLboolean
-_mesa_texstore_ci8(STORE_PARAMS)
+_mesa_texstore_ci8(TEXSTORE_PARAMS)
{
(void) dims; (void) baseInternalFormat;
ASSERT(dstFormat == &_mesa_texformat_ci8);
@@ -1898,19 +1879,19 @@ _mesa_texstore_ci8(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
else {
/* general path */
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
const GLvoid *src = _mesa_image_address(dims, srcPacking,
srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
@@ -1919,7 +1900,6 @@ _mesa_texstore_ci8(STORE_PARAMS)
ctx->_ImageTransferState);
dstRow += dstRowStride;
}
- dstImage += dstImageStride;
}
}
return GL_TRUE;
@@ -1930,7 +1910,7 @@ _mesa_texstore_ci8(STORE_PARAMS)
* Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_rev.
*/
GLboolean
-_mesa_texstore_ycbcr(STORE_PARAMS)
+_mesa_texstore_ycbcr(TEXSTORE_PARAMS)
{
const GLuint ui = 1;
const GLubyte littleEndian = *((const GLubyte *) &ui);
@@ -1948,7 +1928,8 @@ _mesa_texstore_ycbcr(STORE_PARAMS)
/* always just memcpy since no pixel transfer ops apply */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
@@ -1958,18 +1939,16 @@ _mesa_texstore_ycbcr(STORE_PARAMS)
(srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^
(dstFormat == &_mesa_texformat_ycbcr_rev) ^
!littleEndian) {
- GLubyte *pImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLubyte *pRow = pImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
- _mesa_swap2((GLushort *) pRow, srcWidth);
- pRow += dstRowStride;
+ _mesa_swap2((GLushort *) dstRow, srcWidth);
+ dstRow += dstRowStride;
}
- pImage += dstImageStride;
}
}
return GL_TRUE;
@@ -1981,7 +1960,7 @@ _mesa_texstore_ycbcr(STORE_PARAMS)
* Store a combined depth/stencil texture image.
*/
GLboolean
-_mesa_texstore_z24_s8(STORE_PARAMS)
+_mesa_texstore_z24_s8(TEXSTORE_PARAMS)
{
ASSERT(dstFormat == &_mesa_texformat_z24_s8);
ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT);
@@ -1992,7 +1971,8 @@ _mesa_texstore_z24_s8(STORE_PARAMS)
/* simple path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -2001,11 +1981,13 @@ _mesa_texstore_z24_s8(STORE_PARAMS)
const GLint srcRowStride
= _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
/ sizeof(GLuint);
- GLuint *dstImage = (GLuint *) dstAddr;
GLint img, row;
for (img = 0; img < srcDepth; img++) {
- GLuint *dst = dstImage;
+ GLuint *dstRow = (GLuint *) dstAddr
+ + dstImageOffsets[dstZoffset + img]
+ + dstYoffset * dstRowStride / sizeof(GLuint)
+ + dstXoffset;
const GLuint *src
= (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
srcWidth, srcHeight,
@@ -2017,7 +1999,7 @@ _mesa_texstore_z24_s8(STORE_PARAMS)
/* the 24 depth bits will be in the high position: */
_mesa_unpack_depth_span(ctx, srcWidth,
GL_UNSIGNED_INT, /* dst type */
- dst, /* dst addr */
+ dstRow, /* dst addr */
(GLfloat) 0xffffff, /* depthScale */
srcType, src, srcPacking);
/* get the 8-bit stencil values */
@@ -2028,16 +2010,13 @@ _mesa_texstore_z24_s8(STORE_PARAMS)
ctx->_ImageTransferState);
/* merge stencil values into depth values */
for (i = 0; i < srcWidth; i++)
- dst[i] |= stencil[i];
+ dstRow[i] |= stencil[i];
src += srcRowStride;
- dst += dstRowStride / sizeof(GLuint);
+ dstRow += dstRowStride / sizeof(GLuint);
}
- dstImage += dstImageStride / sizeof(GLuint);
}
}
-
-
return GL_TRUE;
}
@@ -2053,7 +2032,7 @@ _mesa_texstore_z24_s8(STORE_PARAMS)
* _mesa_texformat_intensity_float32
*/
GLboolean
-_mesa_texstore_rgba_float32(STORE_PARAMS)
+_mesa_texstore_rgba_float32(TEXSTORE_PARAMS)
{
const GLint components = _mesa_components_in_format(dstFormat->BaseFormat);
@@ -2078,7 +2057,8 @@ _mesa_texstore_rgba_float32(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -2090,25 +2070,23 @@ _mesa_texstore_rgba_float32(STORE_PARAMS)
srcWidth, srcHeight, srcDepth,
srcFormat, srcType, srcAddr,
srcPacking);
- const GLfloat *src = tempImage;
+ const GLfloat *srcRow = tempImage;
GLint bytesPerRow;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
bytesPerRow = srcWidth * components * sizeof(GLfloat);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dst = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
- _mesa_memcpy(dst, src, bytesPerRow);
- dst += dstRowStride;
- src += srcWidth * components;
+ _mesa_memcpy(dstRow, srcRow, bytesPerRow);
+ dstRow += dstRowStride;
+ srcRow += srcWidth * components;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
@@ -2121,7 +2099,7 @@ _mesa_texstore_rgba_float32(STORE_PARAMS)
* As above, but store 16-bit floats.
*/
GLboolean
-_mesa_texstore_rgba_float16(STORE_PARAMS)
+_mesa_texstore_rgba_float16(TEXSTORE_PARAMS)
{
const GLint components = _mesa_components_in_format(dstFormat->BaseFormat);
@@ -2146,7 +2124,8 @@ _mesa_texstore_rgba_float16(STORE_PARAMS)
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
@@ -2159,16 +2138,15 @@ _mesa_texstore_rgba_float16(STORE_PARAMS)
srcFormat, srcType, srcAddr,
srcPacking);
const GLfloat *src = tempImage;
- GLubyte *dstImage = (GLubyte *) dstAddr
- + dstZoffset * dstImageStride
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
GLint img, row;
if (!tempImage)
return GL_FALSE;
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
for (img = 0; img < srcDepth; img++) {
- GLubyte *dstRow = dstImage;
+ GLubyte *dstRow = (GLubyte *) dstAddr
+ + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
for (row = 0; row < srcHeight; row++) {
GLhalfARB *dstTexel = (GLhalfARB *) dstRow;
GLint i;
@@ -2178,7 +2156,6 @@ _mesa_texstore_rgba_float16(STORE_PARAMS)
dstRow += dstRowStride;
src += srcWidth * components;
}
- dstImage += dstImageStride;
}
_mesa_free((void *) tempImage);
@@ -2454,14 +2431,15 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
return;
}
else {
- const GLint dstRowStride = 0, dstImageStride = 0;
+ const GLint dstRowStride = 0;
GLboolean success;
ASSERT(texImage->TexFormat->StoreImage);
success = texImage->TexFormat->StoreImage(ctx, 1, texImage->_BaseFormat,
texImage->TexFormat,
texImage->Data,
0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride, dstImageStride,
+ dstRowStride,
+ texImage->ImageOffsets,
width, 1, 1,
format, type, pixels, packing);
if (!success) {
@@ -2483,16 +2461,12 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
/**
* This is the software fallback for Driver.TexImage2D()
* and Driver.CopyTexImage2D().
- * We store the image in heap memory. We know nothing about on-board
- * VRAM here. But since most DRI drivers rely on keeping a copy of all
- * textures in main memory, this routine will typically be used by
- * hardware drivers too.
*
- * Reasons why a driver might override this function:
- * - Special memory allocation needs (VRAM, AGP, etc)
- * - Unusual row/image strides or padding
- * - Special housekeeping
- * - Using VRAM-based Pixel Buffer Objects
+ * This function is oriented toward storing images in main memory, rather
+ * than VRAM. Device driver's can easily plug in their own replacement.
+ *
+ * Note: width and height may be pre-convolved dimensions, but
+ * texImage->Width and texImage->Height will be post-convolved dimensions.
*/
void
_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
@@ -2536,21 +2510,22 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
return;
}
else {
- GLint dstRowStride, dstImageStride = 0;
+ GLint dstRowStride;
GLboolean success;
if (texImage->IsCompressed) {
dstRowStride
= _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
}
else {
- dstRowStride = postConvWidth * texImage->TexFormat->TexelBytes;
+ dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
}
ASSERT(texImage->TexFormat->StoreImage);
success = texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
texImage->TexFormat,
texImage->Data,
0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride, dstImageStride,
+ dstRowStride,
+ texImage->ImageOffsets,
width, height, 1,
format, type, pixels, packing);
if (!success) {
@@ -2611,23 +2586,22 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
return;
}
else {
- GLint dstRowStride, dstImageStride;
+ GLint dstRowStride;
GLboolean success;
if (texImage->IsCompressed) {
dstRowStride
= _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
- dstImageStride = 0;
}
else {
- dstRowStride = width * texImage->TexFormat->TexelBytes;
- dstImageStride = dstRowStride * height;
+ dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
}
ASSERT(texImage->TexFormat->StoreImage);
success = texImage->TexFormat->StoreImage(ctx, 3, texImage->_BaseFormat,
texImage->TexFormat,
texImage->Data,
0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride, dstImageStride,
+ dstRowStride,
+ texImage->ImageOffsets,
width, height, depth,
format, type, pixels, packing);
if (!success) {
@@ -2660,20 +2634,22 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
+ /* get pointer to src pixels (may be in a pbo which we'll map here) */
pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
pixels, packing, "glTexSubImage1D");
if (!pixels)
return;
{
- const GLint dstRowStride = 0, dstImageStride = 0;
+ const GLint dstRowStride = 0;
GLboolean success;
ASSERT(texImage->TexFormat->StoreImage);
success = texImage->TexFormat->StoreImage(ctx, 1, texImage->_BaseFormat,
texImage->TexFormat,
texImage->Data,
xoffset, 0, 0, /* offsets */
- dstRowStride, dstImageStride,
+ dstRowStride,
+ texImage->ImageOffsets,
width, 1, 1,
format, type, pixels, packing);
if (!success) {
@@ -2706,27 +2682,29 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
+ /* 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)
return;
{
- GLint dstRowStride = 0, dstImageStride = 0;
+ GLint dstRowStride = 0;
GLboolean success;
if (texImage->IsCompressed) {
dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat,
texImage->Width);
}
else {
- dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
+ dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
}
ASSERT(texImage->TexFormat->StoreImage);
success = texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
texImage->TexFormat,
texImage->Data,
xoffset, yoffset, 0,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ texImage->ImageOffsets,
width, height, 1,
format, type, pixels, packing);
if (!success) {
@@ -2758,6 +2736,7 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
+ /* 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,
type, pixels, packing,
"glTexSubImage3D");
@@ -2765,23 +2744,22 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
return;
{
- GLint dstRowStride, dstImageStride;
+ GLint dstRowStride;
GLboolean success;
if (texImage->IsCompressed) {
dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat,
texImage->Width);
- dstImageStride = 0; /* XXX fix */
}
else {
- dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
- dstImageStride = dstRowStride * texImage->Height;
+ dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
}
ASSERT(texImage->TexFormat->StoreImage);
success = texImage->TexFormat->StoreImage(ctx, 3, texImage->_BaseFormat,
texImage->TexFormat,
texImage->Data,
xoffset, yoffset, zoffset,
- dstRowStride, dstImageStride,
+ dstRowStride,
+ texImage->ImageOffsets,
width, height, depth,
format, type, pixels, packing);
if (!success) {
@@ -2823,7 +2801,7 @@ _mesa_store_compressed_teximage1d(GLcontext *ctx, GLenum target, GLint level,
-/*
+/**
* Fallback for Driver.CompressedTexImage2D()
*/
void
@@ -2952,6 +2930,7 @@ _mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
ASSERT((xoffset & 3) == 0);
ASSERT((yoffset & 3) == 0);
+ /* get pointer to src pixels (may be in a pbo which we'll map here) */
data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
&ctx->Unpack,
"glCompressedTexSubImage2D");
@@ -3495,6 +3474,9 @@ make_1d_mipmap(const struct gl_texture_format *format, GLint border,
}
+/**
+ * XXX need to use the tex image's row stride!
+ */
static void
make_2d_mipmap(const struct gl_texture_format *format, GLint border,
GLint srcWidth, GLint srcHeight, const GLubyte *srcPtr,