diff options
author | Dave Airlie <[email protected]> | 2011-11-27 16:21:02 +0000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2011-11-28 09:40:53 +0000 |
commit | f449be660e70aac2aefd2ce84581e137de25520b (patch) | |
tree | a538a4e7992180705f01250424eead00452bdc33 /src/mesa/main/texstore.c | |
parent | 47e2e367170edec022481f1487cd980e00ef3203 (diff) |
mesa/format: add mesa MESA_FORMAT_ARGB2101010_UINT support.
This format is used in the ARB_texture_rgb10_a2ui spec.
It adds core mesa support, texformat + texstore support, format_unpack
and fbobject.c (all patches from list merged + fixed up).
also fixes some whitespace issues.
Parts were:
Reviewed-by: Eric Anholt <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r-- | src/mesa/main/texstore.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 6deeb642ede..892f07da8bd 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -4254,6 +4254,64 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS) } 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; @@ -4446,6 +4504,7 @@ _mesa_get_texstore_func(gl_format format) 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; } |