diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2006-05-20 16:19:48 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2006-05-20 16:19:48 +0000 |
commit | b0b6d1abe5c7e629baebd4bf3d3ee3b17ba6ff08 (patch) | |
tree | ebac2d5b8cf7d29a38beb6bc7854b5f67a8b9524 /src/mesa/drivers/dri/savage | |
parent | 226d0187b530482684f3a0dddd0934bd015eb986 (diff) |
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.
Diffstat (limited to 'src/mesa/drivers/dri/savage')
-rw-r--r-- | src/mesa/drivers/dri/savage/savagetex.c | 148 |
1 files changed, 53 insertions, 95 deletions
diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c index b2802904bd..f0fe0c5259 100644 --- a/src/mesa/drivers/dri/savage/savagetex.c +++ b/src/mesa/drivers/dri/savage/savagetex.c @@ -525,80 +525,11 @@ 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. */ -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); -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); - -static struct gl_texture_format _savage_texformat_a1114444 = { - MESA_FORMAT_ARGB4444, /* MesaFormat */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 4, /* RedBits */ - 4, /* GreenBits */ - 4, /* BlueBits */ - 4, /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* StencilBits */ - 2, /* TexelBytes */ - _savage_texstore_a1114444, /* StoreTexImageFunc */ - NULL, NULL, NULL, NULL, NULL, NULL /* FetchTexel* filled in by - * savageDDInitTextureFuncs */ -}; -static struct gl_texture_format _savage_texformat_a1118888 = { - MESA_FORMAT_ARGB8888, /* MesaFormat */ - GL_RGBA, /* BaseFormat */ - GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ - 8, /* RedBits */ - 8, /* GreenBits */ - 8, /* BlueBits */ - 8, /* AlphaBits */ - 0, /* LuminanceBits */ - 0, /* IntensityBits */ - 0, /* IndexBits */ - 0, /* DepthBits */ - 0, /* StencilBits */ - 4, /* TexelBytes */ - _savage_texstore_a1118888, /* StoreTexImageFunc */ - NULL, NULL, NULL, NULL, NULL, NULL /* FetchTexel* filled in by - * savageDDInitTextureFuncs */ -}; - + * 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) { - /* general path */ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, baseInternalFormat, @@ -606,10 +537,6 @@ _savage_texstore_a1114444 (GLcontext *ctx, GLuint dims, 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); @@ -619,7 +546,10 @@ _savage_texstore_a1114444 (GLcontext *ctx, GLuint dims, 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 *dstUI = (GLushort *) dstRow; for (col = 0; col < srcWidth; col++) { @@ -629,25 +559,16 @@ _savage_texstore_a1114444 (GLcontext *ctx, GLuint dims, } 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) +_savage_texstore_a1118888(TEXSTORE_PARAMS) { - /* general path */ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, baseInternalFormat, baseInternalFormat, @@ -655,10 +576,6 @@ _savage_texstore_a1118888 (GLcontext *ctx, GLuint dims, 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); @@ -668,7 +585,10 @@ _savage_texstore_a1118888 (GLcontext *ctx, GLuint dims, 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; for (col = 0; col < srcWidth; col++) { @@ -678,13 +598,51 @@ _savage_texstore_a1118888 (GLcontext *ctx, GLuint dims, } dstRow += dstRowStride; } - dstImage += dstImageStride; } _mesa_free((void *) tempImage); return GL_TRUE; } + +static struct gl_texture_format _savage_texformat_a1114444 = { + MESA_FORMAT_ARGB4444, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 4, /* RedBits */ + 4, /* GreenBits */ + 4, /* BlueBits */ + 4, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* StencilBits */ + 2, /* TexelBytes */ + _savage_texstore_a1114444, /* StoreTexImageFunc */ + NULL, NULL, NULL, NULL, NULL, NULL /* FetchTexel* filled in by + * savageDDInitTextureFuncs */ +}; +static struct gl_texture_format _savage_texformat_a1118888 = { + MESA_FORMAT_ARGB8888, /* MesaFormat */ + GL_RGBA, /* BaseFormat */ + GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ + 8, /* RedBits */ + 8, /* GreenBits */ + 8, /* BlueBits */ + 8, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ + 0, /* DepthBits */ + 0, /* StencilBits */ + 4, /* TexelBytes */ + _savage_texstore_a1118888, /* StoreTexImageFunc */ + NULL, NULL, NULL, NULL, NULL, NULL /* FetchTexel* filled in by + * savageDDInitTextureFuncs */ +}; + + /* Called by the _mesa_store_teximage[123]d() functions. */ static const struct gl_texture_format * savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat, |