In gl_texture_image, replace ImageStride with an ImageOffsets array.
Some hardware lays out 3D mipmaps in a manner that can't be expressed with a simple image stride. The ImageOffsets array is allocated and initialized to typical defaults in the _mesa_init_teximage_fields() function. If needed, a driver will then have to replace these offsets. TexStore and TexelFetch routines updated to use offsets array.
This commit is contained in:
@@ -525,29 +525,85 @@ savageAllocTexObj( struct gl_texture_object *texObj )
|
||||
* because we can't tell the hardware to ignore the color components
|
||||
* and only use the alpha component. So we define our own texture
|
||||
* formats that promote to ARGB8888 or ARGB4444 and set the color
|
||||
* components to white. This way we get the correct result. */
|
||||
* components to white. This way we get the correct result.
|
||||
*/
|
||||
static GLboolean
|
||||
_savage_texstore_a1114444 (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);
|
||||
_savage_texstore_a1114444(TEXSTORE_PARAMS)
|
||||
{
|
||||
const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
baseInternalFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
const GLchan *src = tempImage;
|
||||
GLint img, row, col;
|
||||
|
||||
ASSERT(dstFormat == &_savage_texformat_a1114444);
|
||||
ASSERT(baseInternalFormat == GL_ALPHA);
|
||||
|
||||
if (!tempImage)
|
||||
return GL_FALSE;
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
for (img = 0; img < srcDepth; img++) {
|
||||
GLubyte *dstRow = (GLubyte *) dstAddr
|
||||
+ dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
|
||||
+ dstYoffset * dstRowStride
|
||||
+ dstXoffset * dstFormat->TexelBytes;
|
||||
for (row = 0; row < srcHeight; row++) {
|
||||
GLushort *dstUI = (GLushort *) dstRow;
|
||||
for (col = 0; col < srcWidth; col++) {
|
||||
dstUI[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[0]),
|
||||
255, 255, 255 );
|
||||
src += 1;
|
||||
}
|
||||
dstRow += dstRowStride;
|
||||
}
|
||||
}
|
||||
_mesa_free((void *) tempImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static GLboolean
|
||||
_savage_texstore_a1118888 (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);
|
||||
_savage_texstore_a1118888(TEXSTORE_PARAMS)
|
||||
{
|
||||
const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
baseInternalFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
const GLchan *src = tempImage;
|
||||
GLint img, row, col;
|
||||
|
||||
ASSERT(dstFormat == &_savage_texformat_a1118888);
|
||||
ASSERT(baseInternalFormat == GL_ALPHA);
|
||||
|
||||
if (!tempImage)
|
||||
return GL_FALSE;
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
for (img = 0; img < srcDepth; img++) {
|
||||
GLubyte *dstRow = (GLubyte *) dstAddr
|
||||
+ dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
|
||||
+ dstYoffset * dstRowStride
|
||||
+ dstXoffset * dstFormat->TexelBytes;
|
||||
for (row = 0; row < srcHeight; row++) {
|
||||
GLuint *dstUI = (GLuint *) dstRow;
|
||||
for (col = 0; col < srcWidth; col++) {
|
||||
dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[0]),
|
||||
255, 255, 255 );
|
||||
src += 1;
|
||||
}
|
||||
dstRow += dstRowStride;
|
||||
}
|
||||
}
|
||||
_mesa_free((void *) tempImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static struct gl_texture_format _savage_texformat_a1114444 = {
|
||||
MESA_FORMAT_ARGB4444, /* MesaFormat */
|
||||
@@ -586,104 +642,6 @@ static struct gl_texture_format _savage_texformat_a1118888 = {
|
||||
* savageDDInitTextureFuncs */
|
||||
};
|
||||
|
||||
static GLboolean
|
||||
_savage_texstore_a1114444 (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)
|
||||
{
|
||||
/* general path */
|
||||
const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
baseInternalFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
const GLchan *src = tempImage;
|
||||
GLubyte *dstImage = (GLubyte *) dstAddr
|
||||
+ dstZoffset * dstImageStride
|
||||
+ dstYoffset * dstRowStride
|
||||
+ dstXoffset * dstFormat->TexelBytes;
|
||||
GLint img, row, col;
|
||||
|
||||
ASSERT(dstFormat == &_savage_texformat_a1114444);
|
||||
ASSERT(baseInternalFormat == GL_ALPHA);
|
||||
|
||||
if (!tempImage)
|
||||
return GL_FALSE;
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
for (img = 0; img < srcDepth; img++) {
|
||||
GLubyte *dstRow = dstImage;
|
||||
for (row = 0; row < srcHeight; row++) {
|
||||
GLushort *dstUI = (GLushort *) dstRow;
|
||||
for (col = 0; col < srcWidth; col++) {
|
||||
dstUI[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[0]),
|
||||
255, 255, 255 );
|
||||
src += 1;
|
||||
}
|
||||
dstRow += dstRowStride;
|
||||
}
|
||||
dstImage += dstImageStride;
|
||||
}
|
||||
_mesa_free((void *) tempImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
static GLboolean
|
||||
_savage_texstore_a1118888 (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)
|
||||
{
|
||||
/* general path */
|
||||
const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
|
||||
baseInternalFormat,
|
||||
baseInternalFormat,
|
||||
srcWidth, srcHeight, srcDepth,
|
||||
srcFormat, srcType, srcAddr,
|
||||
srcPacking);
|
||||
const GLchan *src = tempImage;
|
||||
GLubyte *dstImage = (GLubyte *) dstAddr
|
||||
+ dstZoffset * dstImageStride
|
||||
+ dstYoffset * dstRowStride
|
||||
+ dstXoffset * dstFormat->TexelBytes;
|
||||
GLint img, row, col;
|
||||
|
||||
ASSERT(dstFormat == &_savage_texformat_a1118888);
|
||||
ASSERT(baseInternalFormat == GL_ALPHA);
|
||||
|
||||
if (!tempImage)
|
||||
return GL_FALSE;
|
||||
_mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
|
||||
for (img = 0; img < srcDepth; img++) {
|
||||
GLubyte *dstRow = dstImage;
|
||||
for (row = 0; row < srcHeight; row++) {
|
||||
GLuint *dstUI = (GLuint *) dstRow;
|
||||
for (col = 0; col < srcWidth; col++) {
|
||||
dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[0]),
|
||||
255, 255, 255 );
|
||||
src += 1;
|
||||
}
|
||||
dstRow += dstRowStride;
|
||||
}
|
||||
dstImage += dstImageStride;
|
||||
}
|
||||
_mesa_free((void *) tempImage);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* Called by the _mesa_store_teximage[123]d() functions. */
|
||||
static const struct gl_texture_format *
|
||||
|
@@ -52,7 +52,7 @@
|
||||
|
||||
|
||||
/* no borders! can't halve 1x1! (stride > width * comp) not allowed */
|
||||
void
|
||||
static void
|
||||
_mesa_halve2x2_teximage2d ( GLcontext *ctx,
|
||||
struct gl_texture_image *texImage,
|
||||
GLuint bytesPerPixel,
|
||||
@@ -65,6 +65,7 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
|
||||
GLint srcRowStride = srcWidth * bytesPerPixel;
|
||||
GLubyte *src = (GLubyte *)srcImage;
|
||||
GLubyte *dst = dstImage;
|
||||
GLuint dstImageOffsets = 0;
|
||||
|
||||
GLuint bpt = 0;
|
||||
GLubyte *_s = NULL;
|
||||
@@ -96,7 +97,7 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
|
||||
&_mesa_texformat_rgba8888_rev, src,
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
srcRowStride, /* dstRowStride */
|
||||
0, /* dstImageStride */
|
||||
&dstImageOffsets,
|
||||
srcWidth, srcHeight, 1,
|
||||
texImage->_BaseFormat, _t, srcImage, &ctx->DefaultPacking);
|
||||
}
|
||||
@@ -143,7 +144,7 @@ _mesa_halve2x2_teximage2d ( GLcontext *ctx,
|
||||
texImage->TexFormat, dstImage,
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
dstWidth * bpt,
|
||||
0, /* dstImageStride */
|
||||
&dstImageOffsets,
|
||||
dstWidth, dstHeight, 1,
|
||||
GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
|
||||
FREE(dst);
|
||||
@@ -1177,6 +1178,7 @@ adjust2DRatio (GLcontext *ctx,
|
||||
const GLint newWidth = width * mml->wScale;
|
||||
const GLint newHeight = height * mml->hScale;
|
||||
GLvoid *tempImage;
|
||||
GLuint dstImageOffsets = 0;
|
||||
|
||||
if (!texImage->IsCompressed) {
|
||||
GLubyte *destAddr;
|
||||
@@ -1189,7 +1191,7 @@ adjust2DRatio (GLcontext *ctx,
|
||||
texImage->TexFormat, tempImage,
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
width * texelBytes, /* dstRowStride */
|
||||
0, /* dstImageStride */
|
||||
&dstImageOffsets,
|
||||
width, height, 1,
|
||||
format, type, pixels, packing);
|
||||
|
||||
@@ -1221,7 +1223,7 @@ adjust2DRatio (GLcontext *ctx,
|
||||
&_mesa_texformat_rgba8888_rev, rawImage,
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
width * rawBytes, /* dstRowStride */
|
||||
0, /* dstImageStride */
|
||||
&dstImageOffsets,
|
||||
width, height, 1,
|
||||
format, type, pixels, packing);
|
||||
_mesa_rescale_teximage2d(rawBytes,
|
||||
@@ -1234,7 +1236,7 @@ adjust2DRatio (GLcontext *ctx,
|
||||
texImage->TexFormat, texImage->Data,
|
||||
xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
|
||||
dstRowStride,
|
||||
0, /* dstImageStride */
|
||||
&dstImageOffsets,
|
||||
newWidth, newHeight, 1,
|
||||
GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
|
||||
FREE(rawImage);
|
||||
@@ -1391,12 +1393,12 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||
/* no rescaling needed */
|
||||
/* unpack image, apply transfer ops and store in texImage->Data */
|
||||
texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
|
||||
texImage->TexFormat, texImage->Data,
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
dstRowStride,
|
||||
0, /* dstImageStride */
|
||||
width, height, 1,
|
||||
format, type, pixels, packing);
|
||||
texImage->TexFormat, texImage->Data,
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
dstRowStride,
|
||||
texImage->ImageOffsets,
|
||||
width, height, 1,
|
||||
format, type, pixels, packing);
|
||||
}
|
||||
|
||||
/* GL_SGIS_generate_mipmap */
|
||||
@@ -1501,12 +1503,12 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||
else {
|
||||
/* no rescaling needed */
|
||||
texImage->TexFormat->StoreImage(ctx, 2, texImage->_BaseFormat,
|
||||
texImage->TexFormat, texImage->Data,
|
||||
xoffset, yoffset, 0,
|
||||
dstRowStride,
|
||||
0, /* dstImageStride */
|
||||
width, height, 1,
|
||||
format, type, pixels, packing);
|
||||
texImage->TexFormat, texImage->Data,
|
||||
xoffset, yoffset, 0,
|
||||
dstRowStride,
|
||||
texImage->ImageOffsets,
|
||||
width, height, 1,
|
||||
format, type, pixels, packing);
|
||||
}
|
||||
|
||||
/* GL_SGIS_generate_mipmap */
|
||||
|
@@ -787,7 +787,7 @@ static void viaTexImage(GLcontext *ctx,
|
||||
return;
|
||||
}
|
||||
else {
|
||||
GLint dstRowStride, dstImageStride = 0;
|
||||
GLint dstRowStride;
|
||||
GLboolean success;
|
||||
if (texImage->IsCompressed) {
|
||||
dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
|
||||
@@ -801,7 +801,8 @@ static void viaTexImage(GLcontext *ctx,
|
||||
texImage->TexFormat,
|
||||
texImage->Data,
|
||||
0, 0, 0, /* dstX/Y/Zoffset */
|
||||
dstRowStride, dstImageStride,
|
||||
dstRowStride,
|
||||
texImage->ImageOffsets,
|
||||
width, height, 1,
|
||||
format, type, pixels, packing);
|
||||
if (!success) {
|
||||
|
@@ -1216,22 +1216,40 @@ typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
|
||||
GLint col, GLint row, GLint img,
|
||||
const void *texel);
|
||||
|
||||
/**
|
||||
* TexImage store function. This is called by the glTex[Sub]Image
|
||||
* functions and is responsible for converting the user-specified texture
|
||||
* image into a specific (hardware) image format.
|
||||
*/
|
||||
typedef GLboolean (*StoreTexImageFunc)(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);
|
||||
|
||||
/**
|
||||
* This macro defines the (many) parameters to the texstore functions.
|
||||
* \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 dstImageOffsets offset of each 2D slice within 3D texture, in texels
|
||||
* \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
|
||||
*/
|
||||
#define TEXSTORE_PARAMS \
|
||||
GLcontext *ctx, GLuint dims, \
|
||||
GLenum baseInternalFormat, \
|
||||
const struct gl_texture_format *dstFormat, \
|
||||
GLvoid *dstAddr, \
|
||||
GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
|
||||
GLint dstRowStride, const GLuint *dstImageOffsets, \
|
||||
GLint srcWidth, GLint srcHeight, GLint srcDepth, \
|
||||
GLenum srcFormat, GLenum srcType, \
|
||||
const GLvoid *srcAddr, \
|
||||
const struct gl_pixelstore_attrib *srcPacking
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Texture image storage function.
|
||||
*/
|
||||
typedef GLboolean (*StoreTexImageFunc)(TEXSTORE_PARAMS);
|
||||
|
||||
|
||||
/**
|
||||
@@ -1277,6 +1295,8 @@ struct gl_texture_format
|
||||
};
|
||||
|
||||
|
||||
#define MAX_3D_TEXTURE_SIZE (1 << (MAX_3D_TEXTURE_LEVELS - 1))
|
||||
|
||||
/**
|
||||
* Texture image state. Describes the dimensions of a texture image,
|
||||
* the texel format and pointers to Texel Fetch functions.
|
||||
@@ -1294,8 +1314,6 @@ struct gl_texture_image
|
||||
GLuint Width; /**< = 2^WidthLog2 + 2*Border */
|
||||
GLuint Height; /**< = 2^HeightLog2 + 2*Border */
|
||||
GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
|
||||
GLuint RowStride; /**< == Width unless IsClientData and padded */
|
||||
GLuint ImageStride; /**< Stride between images, in texels */
|
||||
GLuint Width2; /**< = Width - 2*Border */
|
||||
GLuint Height2; /**< = Height - 2*Border */
|
||||
GLuint Depth2; /**< = Depth - 2*Border */
|
||||
@@ -1306,7 +1324,6 @@ struct gl_texture_image
|
||||
GLfloat WidthScale; /**< used for mipmap LOD computation */
|
||||
GLfloat HeightScale; /**< used for mipmap LOD computation */
|
||||
GLfloat DepthScale; /**< used for mipmap LOD computation */
|
||||
GLvoid *Data; /**< Image data, accessed via FetchTexel() */
|
||||
GLboolean IsClientData; /**< Data owned by client? */
|
||||
GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */
|
||||
|
||||
@@ -1320,6 +1337,11 @@ struct gl_texture_image
|
||||
GLboolean IsCompressed; /**< GL_ARB_texture_compression */
|
||||
GLuint CompressedSize; /**< GL_ARB_texture_compression */
|
||||
|
||||
GLuint RowStride; /**< == Width unless IsClientData and padded */
|
||||
GLuint *ImageOffsets; /**< if 3D texture: array [Depth] of offsets to
|
||||
each 2D slice in 'Data', in texels */
|
||||
GLvoid *Data; /**< Image data, accessed via FetchTexel() */
|
||||
|
||||
/**
|
||||
* \name For device driver:
|
||||
*/
|
||||
|
@@ -64,7 +64,7 @@ _mesa_init_texture_fxt1( GLcontext *ctx )
|
||||
* Called via TexFormat->StoreImage to store an RGB_FXT1 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgb_fxt1(STORE_PARAMS)
|
||||
texstore_rgb_fxt1(TEXSTORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
@@ -76,7 +76,8 @@ texstore_rgb_fxt1(STORE_PARAMS)
|
||||
ASSERT(dstXoffset % 8 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset == 0);
|
||||
(void) dstZoffset; (void) dstImageStride;
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGB ||
|
||||
srcType != CHAN_TYPE ||
|
||||
@@ -120,7 +121,7 @@ texstore_rgb_fxt1(STORE_PARAMS)
|
||||
* Called via TexFormat->StoreImage to store an RGBA_FXT1 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgba_fxt1(STORE_PARAMS)
|
||||
texstore_rgba_fxt1(TEXSTORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
@@ -132,7 +133,8 @@ texstore_rgba_fxt1(STORE_PARAMS)
|
||||
ASSERT(dstXoffset % 8 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset == 0);
|
||||
(void) dstZoffset; (void) dstImageStride;
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != CHAN_TYPE ||
|
||||
|
@@ -88,7 +88,7 @@ _mesa_init_texture_s3tc( GLcontext *ctx )
|
||||
dxtlibhandle = dlopen (DXTN_EXT, RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!dxtlibhandle) {
|
||||
_mesa_warning(ctx, "couldn't open " DXTN_EXT ", software DXTn "
|
||||
"compression/decompression unavailable\n");
|
||||
"compression/decompression unavailable");
|
||||
}
|
||||
else {
|
||||
/* the fetch functions are not per context! Might be problematic... */
|
||||
@@ -109,7 +109,7 @@ _mesa_init_texture_s3tc( GLcontext *ctx )
|
||||
if (ext_tx_compress_dxtn == NULL) {
|
||||
_mesa_warning(ctx, "couldn't reference all symbols in "
|
||||
DXTN_EXT ", software DXTn compression/decompression "
|
||||
"unavailable\n");
|
||||
"unavailable");
|
||||
fetch_ext_rgb_dxt1 = NULL;
|
||||
fetch_ext_rgba_dxt1 = NULL;
|
||||
fetch_ext_rgba_dxt3 = NULL;
|
||||
@@ -122,7 +122,7 @@ _mesa_init_texture_s3tc( GLcontext *ctx )
|
||||
}
|
||||
if (dxtlibhandle) {
|
||||
ctx->Mesa_DXTn = GL_TRUE;
|
||||
_mesa_warning(ctx, "software DXTn compression/decompression available\n");
|
||||
_mesa_warning(ctx, "software DXTn compression/decompression available");
|
||||
}
|
||||
#else
|
||||
(void) ctx;
|
||||
@@ -133,7 +133,7 @@ _mesa_init_texture_s3tc( GLcontext *ctx )
|
||||
* Called via TexFormat->StoreImage to store an RGB_DXT1 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgb_dxt1(STORE_PARAMS)
|
||||
texstore_rgb_dxt1(TEXSTORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
@@ -145,7 +145,8 @@ texstore_rgb_dxt1(STORE_PARAMS)
|
||||
ASSERT(dstXoffset % 4 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset; (void) dstImageStride;
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGB ||
|
||||
srcType != CHAN_TYPE ||
|
||||
@@ -195,7 +196,7 @@ texstore_rgb_dxt1(STORE_PARAMS)
|
||||
* Called via TexFormat->StoreImage to store an RGBA_DXT1 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgba_dxt1(STORE_PARAMS)
|
||||
texstore_rgba_dxt1(TEXSTORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
@@ -207,7 +208,8 @@ texstore_rgba_dxt1(STORE_PARAMS)
|
||||
ASSERT(dstXoffset % 4 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset; (void) dstImageStride;
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != CHAN_TYPE ||
|
||||
@@ -256,7 +258,7 @@ texstore_rgba_dxt1(STORE_PARAMS)
|
||||
* Called via TexFormat->StoreImage to store an RGBA_DXT3 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgba_dxt3(STORE_PARAMS)
|
||||
texstore_rgba_dxt3(TEXSTORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
@@ -268,7 +270,8 @@ texstore_rgba_dxt3(STORE_PARAMS)
|
||||
ASSERT(dstXoffset % 4 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset; (void) dstImageStride;
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != CHAN_TYPE ||
|
||||
@@ -316,7 +319,7 @@ texstore_rgba_dxt3(STORE_PARAMS)
|
||||
* Called via TexFormat->StoreImage to store an RGBA_DXT5 texture.
|
||||
*/
|
||||
static GLboolean
|
||||
texstore_rgba_dxt5(STORE_PARAMS)
|
||||
texstore_rgba_dxt5(TEXSTORE_PARAMS)
|
||||
{
|
||||
const GLchan *pixels;
|
||||
GLint srcRowStride;
|
||||
@@ -328,7 +331,8 @@ texstore_rgba_dxt5(STORE_PARAMS)
|
||||
ASSERT(dstXoffset % 4 == 0);
|
||||
ASSERT(dstYoffset % 4 == 0);
|
||||
ASSERT(dstZoffset % 4 == 0);
|
||||
(void) dstZoffset; (void) dstImageStride;
|
||||
(void) dstZoffset;
|
||||
(void) dstImageOffsets;
|
||||
|
||||
if (srcFormat != GL_RGBA ||
|
||||
srcType != CHAN_TYPE ||
|
||||
|
@@ -59,8 +59,8 @@
|
||||
#elif DIM == 3
|
||||
|
||||
#define TEXEL_ADDR( type, image, i, j, k, size ) \
|
||||
((type *)(image)->Data + (((image)->Height * (k) + (j)) * \
|
||||
(image)->RowStride + (i)) * (size))
|
||||
((type *)(image)->Data + ((image)->ImageOffsets[k] \
|
||||
+ (image)->RowStride * (j) + (i)) * (size))
|
||||
|
||||
#define FETCH(x) fetch_texel_3d_##x
|
||||
|
||||
|
@@ -662,7 +662,9 @@ _mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *texImage )
|
||||
ctx->Driver.FreeTexImageData( ctx, texImage );
|
||||
}
|
||||
ASSERT(texImage->Data == NULL);
|
||||
FREE( texImage );
|
||||
if (texImage->ImageOffsets)
|
||||
_mesa_free(texImage->ImageOffsets);
|
||||
_mesa_free(texImage);
|
||||
}
|
||||
|
||||
|
||||
@@ -1050,7 +1052,10 @@ clear_teximage_fields(struct gl_texture_image *img)
|
||||
img->Height = 0;
|
||||
img->Depth = 0;
|
||||
img->RowStride = 0;
|
||||
img->ImageStride = 0;
|
||||
if (img->ImageOffsets) {
|
||||
_mesa_free(img->ImageOffsets);
|
||||
img->ImageOffsets = NULL;
|
||||
}
|
||||
img->Width2 = 0;
|
||||
img->Height2 = 0;
|
||||
img->Depth2 = 0;
|
||||
@@ -1070,7 +1075,7 @@ clear_teximage_fields(struct gl_texture_image *img)
|
||||
* Initialize basic fields of the gl_texture_image struct.
|
||||
*
|
||||
* \param ctx GL context.
|
||||
* \param target texture target.
|
||||
* \param target texture target (GL_TEXTURE_1D, GL_TEXTURE_RECTANGLE, etc).
|
||||
* \param img texture image structure to be initialized.
|
||||
* \param width image width.
|
||||
* \param height image height.
|
||||
@@ -1087,7 +1092,13 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLint border, GLenum internalFormat)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
ASSERT(img);
|
||||
ASSERT(width > 0);
|
||||
ASSERT(height > 0);
|
||||
ASSERT(depth > 0);
|
||||
|
||||
img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
|
||||
ASSERT(img->_BaseFormat > 0);
|
||||
img->InternalFormat = internalFormat;
|
||||
@@ -1095,8 +1106,6 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
|
||||
img->Width = width;
|
||||
img->Height = height;
|
||||
img->Depth = depth;
|
||||
img->RowStride = width;
|
||||
img->ImageStride = width * height;
|
||||
img->Width2 = width - 2 * border; /* == 1 << img->WidthLog2; */
|
||||
img->Height2 = height - 2 * border; /* == 1 << img->HeightLog2; */
|
||||
img->Depth2 = depth - 2 * border; /* == 1 << img->DepthLog2; */
|
||||
@@ -1120,6 +1129,17 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
|
||||
else
|
||||
img->_IsPowerOfTwo = GL_FALSE;
|
||||
|
||||
/* RowStride and ImageOffsets[] describe how to address texels in 'Data' */
|
||||
img->RowStride = width;
|
||||
/* Allocate the ImageOffsets array and initialize to typical values.
|
||||
* We allocate the array for 1D/2D textures too in order to avoid special-
|
||||
* case code in the texstore routines.
|
||||
*/
|
||||
img->ImageOffsets = (GLuint *) _mesa_malloc(depth * sizeof(GLuint));
|
||||
for (i = 0; i < depth; i++) {
|
||||
img->ImageOffsets[i] = i * width * height;
|
||||
}
|
||||
|
||||
/* Compute Width/Height/DepthScale for mipmap lod computation */
|
||||
if (target == GL_TEXTURE_RECTANGLE_NV) {
|
||||
/* scale = 1.0 since texture coords directly map to texels */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -37,49 +37,36 @@
|
||||
|
||||
#include "mtypes.h"
|
||||
|
||||
/* Macro just to save some typing */
|
||||
#define STORE_PARAMS \
|
||||
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
|
||||
|
||||
|
||||
extern GLboolean _mesa_texstore_rgba(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_color_index(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba8888(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb8888(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb888(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_bgr888(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb565(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb565_rev(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb4444(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb4444_rev(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb1555(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb1555_rev(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_al88(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_al88_rev(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb332(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_a8(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_ci8(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_ycbcr(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_z24_s8(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_z16(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_z32(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_float32(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_float16(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb_fxt1(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_fxt1(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb_dxt1(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt1(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt3(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt5(STORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_color_index(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba8888(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb8888(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb888(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_bgr888(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb565(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb565_rev(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb4444(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb4444_rev(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb1555(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_argb1555_rev(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_al88(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_al88_rev(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb332(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_a8(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_ci8(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_ycbcr(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_z24_s8(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_z16(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_z32(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_float32(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_float16(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS);
|
||||
extern GLboolean _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS);
|
||||
|
||||
|
||||
extern GLchan *
|
||||
|
Reference in New Issue
Block a user