diff options
author | Brian Paul <[email protected]> | 2004-05-13 15:26:51 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2004-05-13 15:26:51 +0000 |
commit | defb035b6cf03c555318d9dd48864242ed036f39 (patch) | |
tree | 9c76a7ccf918d9dfc53905cefd46ac4be5154d79 /src/mesa | |
parent | 46bc595969e23ea1a61b684076f8b0608ff4d714 (diff) |
Another pass at implementing byte-swapped texture formats.
More code re-use this time.
Most formats now tested/debugged with new packedpixels.c test.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/texformat.c | 113 | ||||
-rw-r--r-- | src/mesa/main/texformat.h | 24 | ||||
-rw-r--r-- | src/mesa/main/texformat_tmp.h | 367 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 455 | ||||
-rw-r--r-- | src/mesa/main/texstore.h | 10 |
5 files changed, 319 insertions, 650 deletions
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c index 01aec5a5bb6..c4f7a23e812 100644 --- a/src/mesa/main/texformat.c +++ b/src/mesa/main/texformat.c @@ -555,8 +555,8 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = { fetch_texel_3d_f_rgba8888, /* FetchTexel3Df */ }; -const struct gl_texture_format _mesa_texformat_abgr8888 = { - MESA_FORMAT_ABGR8888, /* MesaFormat */ +const struct gl_texture_format _mesa_texformat_rgba8888_rev = { + MESA_FORMAT_RGBA8888_REV, /* MesaFormat */ GL_RGBA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 8, /* RedBits */ @@ -568,13 +568,13 @@ const struct gl_texture_format _mesa_texformat_abgr8888 = { 0, /* IndexBits */ 0, /* DepthBits */ 4, /* TexelBytes */ - _mesa_texstore_abgr8888, /* StoreTexImageFunc */ - fetch_texel_1d_abgr8888, /* FetchTexel1D */ - fetch_texel_2d_abgr8888, /* FetchTexel2D */ - fetch_texel_3d_abgr8888, /* FetchTexel3D */ - fetch_texel_1d_f_abgr8888, /* FetchTexel1Df */ - fetch_texel_2d_f_abgr8888, /* FetchTexel2Df */ - fetch_texel_3d_f_abgr8888, /* FetchTexel3Df */ + _mesa_texstore_rgba8888, /* StoreTexImageFunc */ + fetch_texel_1d_rgba8888_rev, /* FetchTexel1D */ + fetch_texel_2d_rgba8888_rev, /* FetchTexel2D */ + fetch_texel_3d_rgba8888_rev, /* FetchTexel3D */ + fetch_texel_1d_f_rgba8888_rev, /* FetchTexel1Df */ + fetch_texel_2d_f_rgba8888_rev, /* FetchTexel2Df */ + fetch_texel_3d_f_rgba8888_rev, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_argb8888 = { @@ -599,8 +599,8 @@ const struct gl_texture_format _mesa_texformat_argb8888 = { fetch_texel_3d_f_argb8888, /* FetchTexel3Df */ }; -const struct gl_texture_format _mesa_texformat_bgra8888 = { - MESA_FORMAT_BGRA8888, /* MesaFormat */ +const struct gl_texture_format _mesa_texformat_argb8888_rev = { + MESA_FORMAT_ARGB8888_REV, /* MesaFormat */ GL_RGBA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 8, /* RedBits */ @@ -612,13 +612,13 @@ const struct gl_texture_format _mesa_texformat_bgra8888 = { 0, /* IndexBits */ 0, /* DepthBits */ 4, /* TexelBytes */ - _mesa_texstore_bgra8888, /* StoreTexImageFunc */ - fetch_texel_1d_bgra8888, /* FetchTexel1D */ - fetch_texel_2d_bgra8888, /* FetchTexel2D */ - fetch_texel_3d_bgra8888, /* FetchTexel3D */ - fetch_texel_1d_f_bgra8888, /* FetchTexel1Df */ - fetch_texel_2d_f_bgra8888, /* FetchTexel2Df */ - fetch_texel_3d_f_bgra8888, /* FetchTexel3Df */ + _mesa_texstore_argb8888, /* StoreTexImageFunc */ + fetch_texel_1d_argb8888_rev, /* FetchTexel1D */ + fetch_texel_2d_argb8888_rev, /* FetchTexel2D */ + fetch_texel_3d_argb8888_rev, /* FetchTexel3D */ + fetch_texel_1d_f_argb8888_rev, /* FetchTexel1Df */ + fetch_texel_2d_f_argb8888_rev, /* FetchTexel2Df */ + fetch_texel_3d_f_argb8888_rev, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgb888 = { @@ -687,8 +687,8 @@ const struct gl_texture_format _mesa_texformat_rgb565 = { fetch_texel_3d_f_rgb565, /* FetchTexel3Df */ }; -const struct gl_texture_format _mesa_texformat_bgr565 = { - MESA_FORMAT_BGR565, /* MesaFormat */ +const struct gl_texture_format _mesa_texformat_rgb565_rev = { + MESA_FORMAT_RGB565_REV, /* MesaFormat */ GL_RGB, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 5, /* RedBits */ @@ -700,13 +700,13 @@ const struct gl_texture_format _mesa_texformat_bgr565 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - _mesa_texstore_bgr565, /* StoreTexImageFunc */ - fetch_texel_1d_bgr565, /* FetchTexel1D */ - fetch_texel_2d_bgr565, /* FetchTexel2D */ - fetch_texel_3d_bgr565, /* FetchTexel3D */ - fetch_texel_1d_f_bgr565, /* FetchTexel1Df */ - fetch_texel_2d_f_bgr565, /* FetchTexel2Df */ - fetch_texel_3d_f_bgr565, /* FetchTexel3Df */ + _mesa_texstore_rgb565, /* StoreTexImageFunc */ + fetch_texel_1d_rgb565_rev, /* FetchTexel1D */ + fetch_texel_2d_rgb565_rev, /* FetchTexel2D */ + fetch_texel_3d_rgb565_rev, /* FetchTexel3D */ + fetch_texel_1d_f_rgb565_rev, /* FetchTexel1Df */ + fetch_texel_2d_f_rgb565_rev, /* FetchTexel2Df */ + fetch_texel_3d_f_rgb565_rev, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_argb4444 = { @@ -731,8 +731,8 @@ const struct gl_texture_format _mesa_texformat_argb4444 = { fetch_texel_3d_f_argb4444, /* FetchTexel3Df */ }; -const struct gl_texture_format _mesa_texformat_bgra4444 = { - MESA_FORMAT_BGRA4444, /* MesaFormat */ +const struct gl_texture_format _mesa_texformat_argb4444_rev = { + MESA_FORMAT_ARGB4444_REV, /* MesaFormat */ GL_RGBA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 4, /* RedBits */ @@ -744,13 +744,13 @@ const struct gl_texture_format _mesa_texformat_bgra4444 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - _mesa_texstore_bgra4444, /* StoreTexImageFunc */ - fetch_texel_1d_bgra4444, /* FetchTexel1D */ - fetch_texel_2d_bgra4444, /* FetchTexel2D */ - fetch_texel_3d_bgra4444, /* FetchTexel3D */ - fetch_texel_1d_f_bgra4444, /* FetchTexel1Df */ - fetch_texel_2d_f_bgra4444, /* FetchTexel2Df */ - fetch_texel_3d_f_bgra4444, /* FetchTexel3Df */ + _mesa_texstore_argb4444, /* StoreTexImageFunc */ + fetch_texel_1d_argb4444_rev, /* FetchTexel1D */ + fetch_texel_2d_argb4444_rev, /* FetchTexel2D */ + fetch_texel_3d_argb4444_rev, /* FetchTexel3D */ + fetch_texel_1d_f_argb4444_rev, /* FetchTexel1Df */ + fetch_texel_2d_f_argb4444_rev, /* FetchTexel2Df */ + fetch_texel_3d_f_argb4444_rev, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_argb1555 = { @@ -775,8 +775,8 @@ const struct gl_texture_format _mesa_texformat_argb1555 = { fetch_texel_3d_f_argb1555, /* FetchTexel3Df */ }; -const struct gl_texture_format _mesa_texformat_bgra5551 = { - MESA_FORMAT_BGRA5551, /* MesaFormat */ +const struct gl_texture_format _mesa_texformat_argb1555_rev = { + MESA_FORMAT_ARGB1555_REV, /* MesaFormat */ GL_RGBA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 5, /* RedBits */ @@ -788,13 +788,13 @@ const struct gl_texture_format _mesa_texformat_bgra5551 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - _mesa_texstore_bgra5551, /* StoreTexImageFunc */ - fetch_texel_1d_bgra5551, /* FetchTexel1D */ - fetch_texel_2d_bgra5551, /* FetchTexel2D */ - fetch_texel_3d_bgra5551, /* FetchTexel3D */ - fetch_texel_1d_f_bgra5551, /* FetchTexel1Df */ - fetch_texel_2d_f_bgra5551, /* FetchTexel2Df */ - fetch_texel_3d_f_bgra5551, /* FetchTexel3Df */ + _mesa_texstore_argb1555, /* StoreTexImageFunc */ + fetch_texel_1d_argb1555_rev, /* FetchTexel1D */ + fetch_texel_2d_argb1555_rev, /* FetchTexel2D */ + fetch_texel_3d_argb1555_rev, /* FetchTexel3D */ + fetch_texel_1d_f_argb1555_rev, /* FetchTexel1Df */ + fetch_texel_2d_f_argb1555_rev, /* FetchTexel2Df */ + fetch_texel_3d_f_argb1555_rev, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_al88 = { @@ -819,8 +819,8 @@ const struct gl_texture_format _mesa_texformat_al88 = { fetch_texel_3d_f_al88, /* FetchTexel3Df */ }; -const struct gl_texture_format _mesa_texformat_la88 = { - MESA_FORMAT_LA88, /* MesaFormat */ +const struct gl_texture_format _mesa_texformat_al88_rev = { + MESA_FORMAT_AL88_REV, /* MesaFormat */ GL_LUMINANCE_ALPHA, /* BaseFormat */ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */ 0, /* RedBits */ @@ -832,13 +832,13 @@ const struct gl_texture_format _mesa_texformat_la88 = { 0, /* IndexBits */ 0, /* DepthBits */ 2, /* TexelBytes */ - _mesa_texstore_la88, /* StoreTexImageFunc */ - fetch_texel_1d_la88, /* FetchTexel1D */ - fetch_texel_2d_la88, /* FetchTexel2D */ - fetch_texel_3d_la88, /* FetchTexel3D */ - fetch_texel_1d_f_la88, /* FetchTexel1Df */ - fetch_texel_2d_f_la88, /* FetchTexel2Df */ - fetch_texel_3d_f_la88, /* FetchTexel3Df */ + _mesa_texstore_al88, /* StoreTexImageFunc */ + fetch_texel_1d_al88_rev, /* FetchTexel1D */ + fetch_texel_2d_al88_rev, /* FetchTexel2D */ + fetch_texel_3d_al88_rev, /* FetchTexel3D */ + fetch_texel_1d_f_al88_rev, /* FetchTexel1Df */ + fetch_texel_2d_f_al88_rev, /* FetchTexel2Df */ + fetch_texel_3d_f_al88_rev, /* FetchTexel3Df */ }; const struct gl_texture_format _mesa_texformat_rgb332 = { @@ -1062,20 +1062,23 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat, case GL_RGB5_A1: return &_mesa_texformat_argb1555; case GL_RGBA2: + return &_mesa_texformat_argb4444_rev; /* just to test another format*/ case GL_RGBA4: return &_mesa_texformat_argb4444; /* RGB formats */ case 3: case GL_RGB: - case GL_RGB8: case GL_RGB10: case GL_RGB12: case GL_RGB16: return &_mesa_texformat_rgb; + case GL_RGB8: + return &_mesa_texformat_rgb888; case GL_R3_G3_B2: return &_mesa_texformat_rgb332; case GL_RGB4: + return &_mesa_texformat_rgb565_rev; /* just to test another format */ case GL_RGB5: return &_mesa_texformat_rgb565; diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h index 8cfd4e8265e..35522d62189 100644 --- a/src/mesa/main/texformat.h +++ b/src/mesa/main/texformat.h @@ -63,19 +63,19 @@ enum _format { /* msb <------ TEXEL BITS -----------> lsb */ /* ---- ---- ---- ---- ---- ---- ---- ---- */ MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */ - MESA_FORMAT_ABGR8888, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ + MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */ MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */ - MESA_FORMAT_BGRA8888, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ + MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */ MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */ MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */ MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */ - MESA_FORMAT_BGR565, /* BBBB BGGG GGGR RRRR */ + MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */ MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */ - MESA_FORMAT_BGRA4444, /* AAAA RRRR GGGG BBBB */ + MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */ MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */ - MESA_FORMAT_BGRA5551, /* BBBB BGGG GGRR RRRA */ + MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */ MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */ - MESA_FORMAT_LA88, /* LLLL LLLL AAAA AAAA */ + MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */ MESA_FORMAT_RGB332, /* RRRG GGBB */ MESA_FORMAT_A8, /* AAAA AAAA */ MESA_FORMAT_L8, /* LLLL LLLL */ @@ -179,19 +179,19 @@ extern const struct gl_texture_format _mesa_texformat_intensity_float16; /** \name Assorted hardware-friendly formats */ /*@{*/ extern const struct gl_texture_format _mesa_texformat_rgba8888; -extern const struct gl_texture_format _mesa_texformat_abgr8888; +extern const struct gl_texture_format _mesa_texformat_rgba8888_rev; extern const struct gl_texture_format _mesa_texformat_argb8888; -extern const struct gl_texture_format _mesa_texformat_bgra8888; +extern const struct gl_texture_format _mesa_texformat_argb8888_rev; extern const struct gl_texture_format _mesa_texformat_rgb888; extern const struct gl_texture_format _mesa_texformat_bgr888; extern const struct gl_texture_format _mesa_texformat_rgb565; -extern const struct gl_texture_format _mesa_texformat_bgr565; +extern const struct gl_texture_format _mesa_texformat_rgb565_rev; extern const struct gl_texture_format _mesa_texformat_argb4444; -extern const struct gl_texture_format _mesa_texformat_bgra4444; +extern const struct gl_texture_format _mesa_texformat_argb4444_rev; extern const struct gl_texture_format _mesa_texformat_argb1555; -extern const struct gl_texture_format _mesa_texformat_bgra5551; +extern const struct gl_texture_format _mesa_texformat_argb1555_rev; extern const struct gl_texture_format _mesa_texformat_al88; -extern const struct gl_texture_format _mesa_texformat_la88; +extern const struct gl_texture_format _mesa_texformat_al88_rev; extern const struct gl_texture_format _mesa_texformat_rgb332; extern const struct gl_texture_format _mesa_texformat_a8; extern const struct gl_texture_format _mesa_texformat_l8; diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index 972dab6eae1..0ccdead291b 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -49,6 +49,8 @@ ((GLubyte *)(t)->Data + (i) * (sz)) #define USHORT_SRC( t, i, j, k ) \ ((GLushort *)(t)->Data + (i)) +#define UINT_SRC( t, i, j, k ) \ + ((GLuint *)(t)->Data + (i)) #define FLOAT_SRC( t, i, j, k, sz ) \ ((GLfloat *)(t)->Data + (i) * (sz)) #define HALF_SRC( t, i, j, k, sz ) \ @@ -64,6 +66,8 @@ ((GLubyte *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)) #define USHORT_SRC( t, i, j, k ) \ ((GLushort *)(t)->Data + ((t)->RowStride * (j) + (i))) +#define UINT_SRC( t, i, j, k ) \ + ((GLuint *)(t)->Data + ((t)->RowStride * (j) + (i))) #define FLOAT_SRC( t, i, j, k, sz ) \ ((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)) #define HALF_SRC( t, i, j, k, sz ) \ @@ -82,6 +86,9 @@ #define USHORT_SRC( t, i, j, k ) \ ((GLushort *)(t)->Data + (((t)->Height * (k) + (j)) * \ (t)->RowStride + (i))) +#define UINT_SRC( t, i, j, k ) \ + ((GLuint *)(t)->Data + (((t)->Height * (k) + (j)) * \ + (t)->RowStride + (i))) #define FLOAT_SRC( t, i, j, k, sz ) \ ((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \ (t)->RowStride + (i)) * (sz)) @@ -96,7 +103,7 @@ #endif -/* Fetch color texel from 1D, 2D or 3D RGBA texture, returning 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLchans */ static void FETCH(rgba)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -104,7 +111,7 @@ static void FETCH(rgba)( const struct gl_texture_image *texImage, COPY_CHAN4( texel, src ); } -/* Fetch color texel from 1D, 2D or 3D RGBA texture, returning 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLfloats */ static void FETCH(f_rgba)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -116,7 +123,7 @@ static void FETCH(f_rgba)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D RGB texture, returning 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLchans */ static void FETCH(rgb)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -127,7 +134,7 @@ static void FETCH(rgb)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D RGB texture, returning 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLfloats */ static void FETCH(f_rgb)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -138,7 +145,7 @@ static void FETCH(f_rgb)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAXF; } -/* Fetch color texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */ static void FETCH(alpha)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -149,7 +156,7 @@ static void FETCH(alpha)( const struct gl_texture_image *texImage, texel[ACOMP] = src[0]; } -/* Fetch color texel from 1D, 2D or 3D ALPHA texture, returning 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D ALPHA texture, returning 4 GLfloats */ static void FETCH(f_alpha)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -160,7 +167,7 @@ static void FETCH(f_alpha)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_TO_FLOAT(src[0]); } -/* Fetch color texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */ static void FETCH(luminance)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -171,7 +178,7 @@ static void FETCH(luminance)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */ static void FETCH(f_luminance)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -182,7 +189,7 @@ static void FETCH(f_luminance)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAXF; } -/* Fetch color texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */ static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -193,7 +200,7 @@ static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage, texel[ACOMP] = src[1]; } -/* Fetch color texel from 1D, 2D or 3D L_A texture, returning 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D L_A texture, returning 4 GLfloats */ static void FETCH(f_luminance_alpha)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -205,7 +212,7 @@ static void FETCH(f_luminance_alpha)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */ static void FETCH(intensity)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -216,7 +223,7 @@ static void FETCH(intensity)( const struct gl_texture_image *texImage, texel[ACOMP] = src[0]; } -/* Fetch color texel from 1D, 2D or 3D INT. texture, returning 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D INT. texture, returning 4 GLfloats */ static void FETCH(f_intensity)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -252,7 +259,7 @@ static void FETCH(f_depth_component16)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, * returning 4 GLchans. */ static void FETCH(rgba_f32)( const struct gl_texture_image *texImage, @@ -265,7 +272,7 @@ static void FETCH(rgba_f32)( const struct gl_texture_image *texImage, UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[3]); } -/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, * returning 4 GLfloats. */ static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage, @@ -278,7 +285,7 @@ static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage, texel[ACOMP] = src[3]; } -/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture, * returning 4 GLchans. */ static void FETCH(rgba_f16)( const struct gl_texture_image *texImage, @@ -291,7 +298,7 @@ static void FETCH(rgba_f16)( const struct gl_texture_image *texImage, UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[3])); } -/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture, * returning 4 GLfloats. */ static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage, @@ -304,7 +311,7 @@ static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage, texel[ACOMP] = _mesa_half_to_float(src[3]); } -/* Fetch color texel from 1D, 2D or 3D RGB_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture, * returning 4 GLchans. */ static void FETCH(rgb_f32)( const struct gl_texture_image *texImage, @@ -317,7 +324,7 @@ static void FETCH(rgb_f32)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D RGB_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture, * returning 4 GLfloats. */ static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage, @@ -330,7 +337,7 @@ static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAXF; } -/* Fetch color texel from 1D, 2D or 3D RGBA_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture, * returning 4 GLchans. */ static void FETCH(rgb_f16)( const struct gl_texture_image *texImage, @@ -343,7 +350,7 @@ static void FETCH(rgb_f16)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D RGB_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture, * returning 4 GLfloats. */ static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage, @@ -356,7 +363,7 @@ static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAXF; } -/* Fetch color texel from 1D, 2D or 3D ALPHA_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture, * returning 4 GLchans. */ static void FETCH(alpha_f32)( const struct gl_texture_image *texImage, @@ -369,7 +376,7 @@ static void FETCH(alpha_f32)( const struct gl_texture_image *texImage, UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[0]); } -/* Fetch color texel from 1D, 2D or 3D ALPHA_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture, * returning 4 GLfloats. */ static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage, @@ -382,7 +389,7 @@ static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage, texel[ACOMP] = src[0]; } -/* Fetch color texel from 1D, 2D or 3D ALPHA_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture, * returning 4 GLchans. */ static void FETCH(alpha_f16)( const struct gl_texture_image *texImage, @@ -395,7 +402,7 @@ static void FETCH(alpha_f16)( const struct gl_texture_image *texImage, UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[0])); } -/* Fetch color texel from 1D, 2D or 3D ALPHA_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture, * returning 4 GLfloats. */ static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage, @@ -408,7 +415,7 @@ static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage, texel[ACOMP] = _mesa_half_to_float(src[0]); } -/* Fetch color texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture, * returning 4 GLchans. */ static void FETCH(luminance_f32)( const struct gl_texture_image *texImage, @@ -421,7 +428,7 @@ static void FETCH(luminance_f32)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture, * returning 4 GLfloats. */ static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage, @@ -434,7 +441,7 @@ static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAXF; } -/* Fetch color texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture, * returning 4 GLchans. */ static void FETCH(luminance_f16)( const struct gl_texture_image *texImage, @@ -447,7 +454,7 @@ static void FETCH(luminance_f16)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture, * returning 4 GLfloats. */ static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage, @@ -460,7 +467,7 @@ static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAXF; } -/* Fetch color texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture, * returning 4 GLchans. */ static void FETCH(luminance_alpha_f32)( const struct gl_texture_image *texImage, @@ -473,7 +480,7 @@ static void FETCH(luminance_alpha_f32)( const struct gl_texture_image *texImage, UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[1]); } -/* Fetch color texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture, * returning 4 GLfloats. */ static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage, @@ -486,7 +493,7 @@ static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImag texel[ACOMP] = src[1]; } -/* Fetch color texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture, * returning 4 GLfloats. */ static void FETCH(luminance_alpha_f16)( const struct gl_texture_image *texImage, @@ -499,7 +506,7 @@ static void FETCH(luminance_alpha_f16)( const struct gl_texture_image *texImage, UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[1])); } -/* Fetch color texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture, * returning 4 GLfloats. */ static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage, @@ -512,7 +519,7 @@ static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImag texel[ACOMP] = _mesa_half_to_float(src[1]); } -/* Fetch color texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture, * returning 4 GLchans. */ static void FETCH(intensity_f32)( const struct gl_texture_image *texImage, @@ -525,7 +532,7 @@ static void FETCH(intensity_f32)( const struct gl_texture_image *texImage, texel[ACOMP] = texel[RCOMP]; } -/* Fetch color texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture, +/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture, * returning 4 GLfloats. */ static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage, @@ -538,7 +545,7 @@ static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage, texel[ACOMP] = src[0]; } -/* Fetch color texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture, * returning 4 GLchans. */ static void FETCH(intensity_f16)( const struct gl_texture_image *texImage, @@ -551,7 +558,7 @@ static void FETCH(intensity_f16)( const struct gl_texture_image *texImage, texel[ACOMP] = texel[RCOMP]; } -/* Fetch color texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture, +/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture, * returning 4 GLfloats. */ static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage, @@ -570,99 +577,100 @@ static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage, * Begin Hardware formats */ -/* Fetch color texel from 1D, 2D or 3D rgba8888 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLchans */ static void FETCH(rgba8888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - texel[RCOMP] = UBYTE_TO_CHAN( src[3] ); - texel[GCOMP] = UBYTE_TO_CHAN( src[2] ); - texel[BCOMP] = UBYTE_TO_CHAN( src[1] ); - texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); + const GLuint s = *UINT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_CHAN( (s >> 24) ); + texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff ); + texel[BCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff ); + texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff ); } -/* Fetch color texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */ static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - texel[RCOMP] = UBYTE_TO_FLOAT( src[3] ); - texel[GCOMP] = UBYTE_TO_FLOAT( src[2] ); - texel[BCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); + const GLuint s = *UINT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); } -/* Fetch color texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */ -static void FETCH(abgr8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) +/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */ +static void FETCH(rgba8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - texel[RCOMP] = UBYTE_TO_CHAN( src[0] ); - texel[GCOMP] = UBYTE_TO_CHAN( src[1] ); - texel[BCOMP] = UBYTE_TO_CHAN( src[2] ); - texel[ACOMP] = UBYTE_TO_CHAN( src[3] ); + const GLuint s = *UINT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_CHAN( (s ) & 0xff ); + texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff ); + texel[BCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff ); + texel[ACOMP] = UBYTE_TO_CHAN( (s >> 24) ); } -/* Fetch color texel from 1D, 2D or 3D abgr8888 texture, return 4 GLfloats */ -static void FETCH(f_abgr8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLfloats */ +static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - texel[RCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[BCOMP] = UBYTE_TO_FLOAT( src[2] ); - texel[ACOMP] = UBYTE_TO_FLOAT( src[3] ); + const GLuint s = *UINT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); } -/* Fetch color texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */ static void FETCH(argb8888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - texel[RCOMP] = UBYTE_TO_CHAN( src[2] ); - texel[GCOMP] = UBYTE_TO_CHAN( src[1] ); - texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); - texel[ACOMP] = UBYTE_TO_CHAN( src[3] ); + const GLuint s = *UINT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff ); + texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff ); + texel[BCOMP] = UBYTE_TO_CHAN( (s ) & 0xff ); + texel[ACOMP] = UBYTE_TO_CHAN( (s >> 24) ); } -/* Fetch color texel from 1D, 2D or 3D argb8888 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLfloats */ static void FETCH(f_argb8888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - texel[RCOMP] = UBYTE_TO_FLOAT( src[2] ); - texel[GCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[ACOMP] = UBYTE_TO_FLOAT( src[3] ); + const GLuint s = *UINT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); } -/* Fetch color texel from 1D, 2D or 3D bgra8888 texture, return 4 GLchans */ -static void FETCH(bgra8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) +/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLchans */ +static void FETCH(argb8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - texel[RCOMP] = UBYTE_TO_CHAN( src[1] ); - texel[GCOMP] = UBYTE_TO_CHAN( src[2] ); - texel[BCOMP] = UBYTE_TO_CHAN( src[3] ); - texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); + const GLuint s = *UINT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff ); + texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff ); + texel[BCOMP] = UBYTE_TO_CHAN( (s >> 24) ); + texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff ); } -/* Fetch color texel from 1D, 2D or 3D bgra8888 texture, return 4 GLfloats */ -static void FETCH(f_bgra8888)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) + +/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */ +static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 ); - texel[RCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[GCOMP] = UBYTE_TO_FLOAT( src[2] ); - texel[BCOMP] = UBYTE_TO_FLOAT( src[3] ); - texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); + const GLuint s = *UINT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff ); + texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff ); + texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) ); + texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); } -/* Fetch color texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */ static void FETCH(rgb888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -673,7 +681,7 @@ static void FETCH(rgb888)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D rgb888 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLfloats */ static void FETCH(f_rgb888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -685,7 +693,7 @@ static void FETCH(f_rgb888)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */ static void FETCH(bgr888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -696,7 +704,7 @@ static void FETCH(bgr888)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D bgr888 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLfloats */ static void FETCH(f_bgr888)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -708,7 +716,7 @@ static void FETCH(f_bgr888)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */ static void FETCH(rgb565)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -720,7 +728,7 @@ static void FETCH(rgb565)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLfloats */ static void FETCH(f_rgb565)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -733,32 +741,32 @@ static void FETCH(f_rgb565)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D bgr565 texture, return 4 GLchans */ -static void FETCH(bgr565)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) +/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */ +static void FETCH(rgb565_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); - const GLushort s = *src; - texel[RCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); + const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */ + texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); - texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D bgr565 texture, return 4 GLfloats */ -static void FETCH(f_bgr565)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLfloats */ +static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); - const GLushort s = *src; - texel[RCOMP] = ((s << 3) & 0xf8) * (1.0F / 248.0F); + const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */ + texel[RCOMP] = ((s >> 8) & 0xf8) * (1.0F / 248.0F); texel[GCOMP] = ((s >> 3) & 0xfc) * (1.0F / 252.0F); - texel[BCOMP] = ((s >> 8) & 0xf8) * (1.0F / 248.0F); + texel[BCOMP] = ((s << 3) & 0xf8) * (1.0F / 248.0F); texel[ACOMP] = CHAN_MAXF; } -/* Fetch color texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */ static void FETCH(argb4444)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -770,7 +778,7 @@ static void FETCH(argb4444)( const struct gl_texture_image *texImage, texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); } -/* Fetch color texel from 1D, 2D or 3D argb4444 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D argb4444 texture, return 4 GLfloats */ static void FETCH(f_argb4444)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -783,32 +791,30 @@ static void FETCH(f_argb4444)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D bgra444 texture, return 4 GLchans */ -static void FETCH(bgra4444)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) +/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */ +static void FETCH(argb4444_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) { - const GLushort *src = USHORT_SRC( texImage, i, j, k ); - const GLushort s = *src; - texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); - texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); - texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); - texel[ACOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); + const GLushort s = *USHORT_SRC( texImage, i, j, k ); + texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); + texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); } -/* Fetch color texel from 1D, 2D or 3D bgra4444 texture, return 4 GLfloats */ -static void FETCH(f_bgra4444)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLfloats */ +static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLushort *src = USHORT_SRC( texImage, i, j, k ); - const GLushort s = *src; - texel[RCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); - texel[GCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F); - texel[BCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); - texel[ACOMP] = ((s ) & 0xf) * (1.0F / 15.0F); + const GLushort s = *USHORT_SRC( texImage, i, j, k ); + texel[RCOMP] = ((s ) & 0xf) * (1.0F / 15.0F); + texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F); + texel[BCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F); + texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F); } -/* Fetch color texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */ static void FETCH(argb1555)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -820,7 +826,7 @@ static void FETCH(argb1555)( const struct gl_texture_image *texImage, texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); } -/* Fetch color texel from 1D, 2D or 3D argb1555 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLfloats */ static void FETCH(f_argb1555)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -833,78 +839,78 @@ static void FETCH(f_argb1555)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D bgra5551 texture, return 4 GLchans */ -static void FETCH(bgra5551)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) +/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */ +static void FETCH(argb1555_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); - const GLushort s = *src; - texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 1) & 0x1f) * 255 / 0x1f ); - texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 6) & 0x1f) * 255 / 0x1f ); - texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 11) & 0x1f) * 255 / 0x1f ); - texel[ACOMP] = UBYTE_TO_CHAN( ((s ) & 0x01) * 255 ); + const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */ + texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); + texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); + texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); + texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 ); } -/* Fetch color texel from 1D, 2D or 3D bgra5551 texture, return 4 GLfloats */ -static void FETCH(f_bgra5551)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLfloats */ +static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { const GLushort *src = USHORT_SRC( texImage, i, j, k ); - const GLushort s = *src; - texel[RCOMP] = ((s >> 1) & 0x1f) * (1.0F / 31.0F); - texel[GCOMP] = ((s >> 6) & 0x1f) * (1.0F / 31.0F); - texel[BCOMP] = ((s >> 11) & 0x1f) * (1.0F / 31.0F); - texel[ACOMP] = ((s ) & 0x01); + const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */ + texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F); + texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F); + texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F); + texel[ACOMP] = ((s >> 15) & 0x01); } -/* Fetch color texel from 1D, 2D or 3D al88 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */ static void FETCH(al88)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); + const GLushort s = *USHORT_SRC( texImage, i, j, k ); texel[RCOMP] = texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_CHAN( src[0] ); - texel[ACOMP] = UBYTE_TO_CHAN( src[1] ); + texel[BCOMP] = UBYTE_TO_CHAN( s & 0xff ); + texel[ACOMP] = UBYTE_TO_CHAN( s >> 8 ); } -/* Fetch color texel from 1D, 2D or 3D al88 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLfloats */ static void FETCH(f_al88)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); + const GLushort s = *USHORT_SRC( texImage, i, j, k ); texel[RCOMP] = texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( src[0] ); - texel[ACOMP] = UBYTE_TO_FLOAT( src[1] ); + texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff ); + texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 ); } -/* Fetch color texel from 1D, 2D or 3D la88 texture, return 4 GLchans */ -static void FETCH(la88)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLchan *texel ) +/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */ +static void FETCH(al88_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLchan *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); + const GLushort s = *USHORT_SRC( texImage, i, j, k ); texel[RCOMP] = texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_CHAN( src[1] ); - texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); + texel[BCOMP] = UBYTE_TO_CHAN( s >> 8 ); + texel[ACOMP] = UBYTE_TO_CHAN( s & 0xff ); } -/* Fetch color texel from 1D, 2D or 3D la88 texture, return 4 GLfloats */ -static void FETCH(f_la88)( const struct gl_texture_image *texImage, - GLint i, GLint j, GLint k, GLfloat *texel ) +/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLfloats */ +static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage, + GLint i, GLint j, GLint k, GLfloat *texel ) { - const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 ); + const GLushort s = *USHORT_SRC( texImage, i, j, k ); texel[RCOMP] = texel[GCOMP] = - texel[BCOMP] = UBYTE_TO_FLOAT( src[1] ); - texel[ACOMP] = UBYTE_TO_FLOAT( src[0] ); + texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 ); + texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); } -/* Fetch color texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */ static void FETCH(rgb332)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -916,7 +922,7 @@ static void FETCH(rgb332)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D rgb332 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLfloats */ static void FETCH(f_rgb332)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -929,7 +935,7 @@ static void FETCH(f_rgb332)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */ static void FETCH(a8)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -940,7 +946,7 @@ static void FETCH(a8)( const struct gl_texture_image *texImage, texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); } -/* Fetch color texel from 1D, 2D or 3D a8 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLfloats */ static void FETCH(f_a8)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -952,7 +958,7 @@ static void FETCH(f_a8)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */ static void FETCH(l8)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -963,7 +969,7 @@ static void FETCH(l8)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D l8 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLfloats */ static void FETCH(f_l8)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -975,7 +981,7 @@ static void FETCH(f_l8)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */ static void FETCH(i8)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLchan *texel ) { @@ -986,7 +992,7 @@ static void FETCH(i8)( const struct gl_texture_image *texImage, texel[ACOMP] = UBYTE_TO_CHAN( src[0] ); } -/* Fetch color texel from 1D, 2D or 3D i8 texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLfloats */ static void FETCH(f_i8)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) { @@ -1081,7 +1087,7 @@ static void FETCH(f_ci8)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D ycbcr texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLchans */ /* We convert YCbCr to RGB here */ /* XXX this may break if GLchan != GLubyte */ static void FETCH(ycbcr)( const struct gl_texture_image *texImage, @@ -1112,7 +1118,7 @@ static void FETCH(ycbcr)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats */ /* We convert YCbCr to RGB here */ static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) @@ -1148,7 +1154,7 @@ static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage, } -/* Fetch color texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLchans */ +/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLchans */ /* We convert YCbCr to RGB here */ /* XXX this may break if GLchan != GLubyte */ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, @@ -1179,7 +1185,7 @@ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage, texel[ACOMP] = CHAN_MAX; } -/* Fetch color texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats */ +/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats */ /* We convert YCbCr to RGB here */ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage, GLint i, GLint j, GLint k, GLfloat *texel ) @@ -1219,6 +1225,7 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage, #undef CHAN_SRC #undef UBYTE_SRC #undef USHORT_SRC +#undef UINT_SRC #undef FLOAT_SRC #undef HALF_SRC #undef FETCH diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 4e603c45f6d..57b669ac38f 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -762,16 +762,18 @@ _mesa_texstore_depth_component16(STORE_PARAMS) /** - * Store an rgb565 texture image. + * Store an rgb565 or rgb565_rev texture image. */ GLboolean _mesa_texstore_rgb565(STORE_PARAMS) { - ASSERT(dstFormat == &_mesa_texformat_rgb565); + ASSERT(dstFormat == &_mesa_texformat_rgb565 || + dstFormat == &_mesa_texformat_rgb565_rev); ASSERT(dstFormat->TexelBytes == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && + dstFormat == &_mesa_texformat_rgb565 && baseInternalFormat == GL_RGB && srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5) { @@ -805,6 +807,10 @@ _mesa_texstore_rgb565(STORE_PARAMS) dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] ); srcUB += 3; } + /* check for byteswapped format */ + if (dstFormat == &_mesa_texformat_rgb565_rev) { + _mesa_swap2(dstUS, srcWidth); + } dst += dstRowStride; src += srcRowStride; } @@ -836,90 +842,9 @@ _mesa_texstore_rgb565(STORE_PARAMS) CHAN_TO_UBYTE(src[BCOMP]) ); src += 3; } - dstRow += dstRowStride; - } - dstImage += dstImageStride; - } - _mesa_free((void *) tempImage); - } - return GL_TRUE; -} - - -/** - * Store an bgr565 texture image. - */ -GLboolean -_mesa_texstore_bgr565(STORE_PARAMS) -{ - ASSERT(dstFormat == &_mesa_texformat_bgr565); - ASSERT(dstFormat->TexelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_RGB && - srcType == GL_UNSIGNED_SHORT_5_6_5_REV) { - /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageStride, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGB && - srcFormat == GL_BGR && - srcType == GL_UNSIGNED_BYTE && - dims == 2) { - /* do optimized tex store */ - const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, - srcFormat, srcType); - const GLubyte *src = (const GLubyte *) - _mesa_image_address(srcPacking, srcAddr, srcWidth, srcHeight, - srcFormat, srcType, 0, 0, 0); - GLubyte *dst = (GLubyte *) dstAddr - + dstZoffset * dstImageStride - + dstYoffset * dstRowStride - + dstXoffset * dstFormat->TexelBytes; - GLint row, col; - for (row = 0; row < srcHeight; row++) { - const GLubyte *srcUB = (const GLubyte *) src; - GLushort *dstUS = (GLushort *) dst; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565( srcUB[2], srcUB[1], srcUB[0] ); - srcUB += 3; - } - dst += dstRowStride; - src += srcRowStride; - } - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - dstFormat->BaseFormat, - 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; - 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 *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[RCOMP]) ); - src += 3; + /* check for byteswapped format */ + if (dstFormat == &_mesa_texformat_rgb565_rev) { + _mesa_swap2(dstUS, srcWidth); } dstRow += dstRowStride; } @@ -934,18 +859,16 @@ _mesa_texstore_bgr565(STORE_PARAMS) GLboolean _mesa_texstore_rgba8888(STORE_PARAMS) { - const GLuint ui = 1; - const GLubyte littleEndian = *((const GLubyte *) &ui); - - ASSERT(dstFormat == &_mesa_texformat_rgba8888); + ASSERT(dstFormat == &_mesa_texformat_rgba8888 || + dstFormat == &_mesa_texformat_rgba8888_rev); ASSERT(dstFormat->TexelBytes == 4); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && + dstFormat == &_mesa_texformat_rgba8888 && baseInternalFormat == GL_RGBA && - srcFormat == GL_RGBA && - ((srcType == GL_UNSIGNED_INT_8_8_8_8_REV && littleEndian) || - (srcType == GL_UNSIGNED_INT_8_8_8_8 && !littleEndian))) { + ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) || + (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV))) { /* simple memcpy path */ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, @@ -980,64 +903,9 @@ _mesa_texstore_rgba8888(STORE_PARAMS) CHAN_TO_UBYTE(src[ACOMP]) ); src += 4; } - dstRow += dstRowStride; - } - dstImage += dstImageStride; - } - _mesa_free((void *) tempImage); - } - return GL_TRUE; -} - - -GLboolean -_mesa_texstore_abgr8888(STORE_PARAMS) -{ - const GLuint ui = 1; - const GLubyte littleEndian = *((const GLubyte *) &ui); - - ASSERT(dstFormat == &_mesa_texformat_abgr8888); - ASSERT(dstFormat->TexelBytes == 4); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - srcFormat == GL_ABGR_EXT && - ((srcType == GL_UNSIGNED_INT_8_8_8_8_REV && littleEndian) || - (srcType == GL_UNSIGNED_INT_8_8_8_8 && !littleEndian))) { - /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageStride, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - dstFormat->BaseFormat, - 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; - 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[ACOMP]), - CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[RCOMP]) ); - src += 4; + /* check for byteswapped format */ + if (dstFormat == &_mesa_texformat_rgba8888_rev) { + _mesa_swap4(dstUI, srcWidth); } dstRow += dstRowStride; } @@ -1055,77 +923,31 @@ _mesa_texstore_argb8888(STORE_PARAMS) const GLuint ui = 1; const GLubyte littleEndian = *((const GLubyte *) &ui); - ASSERT(dstFormat == &_mesa_texformat_argb8888); + ASSERT(dstFormat == &_mesa_texformat_argb8888 || + dstFormat == &_mesa_texformat_argb8888_rev); ASSERT(dstFormat->TexelBytes == 4); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && + dstFormat == &_mesa_texformat_argb8888 && baseInternalFormat == GL_RGBA && srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && littleEndian) || - (srcType == GL_UNSIGNED_INT_8_8_8_8_REV && littleEndian) || - (srcType == GL_UNSIGNED_INT_8_8_8_8 && !littleEndian))) { - /* simple memcpy path */ + srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) { + /* simple memcpy path (little endian) */ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking); } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - dstFormat->BaseFormat, - 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; - 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[ACOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]) ); - src += 4; - } - dstRow += dstRowStride; - } - dstImage += dstImageStride; - } - _mesa_free((void *) tempImage); - } - return GL_TRUE; -} - - -GLboolean -_mesa_texstore_bgra8888(STORE_PARAMS) -{ - const GLuint ui = 1; - const GLubyte littleEndian = *((const GLubyte *) &ui); - - ASSERT(dstFormat == &_mesa_texformat_bgra8888); - ASSERT(dstFormat->TexelBytes == 4); - - if (!ctx->_ImageTransferState && + else if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && + dstFormat == &_mesa_texformat_argb8888_rev && baseInternalFormat == GL_RGBA && srcFormat == GL_BGRA && ((srcType == GL_UNSIGNED_BYTE && !littleEndian) || - (srcType == GL_UNSIGNED_INT_8_8_8_8_REV && !littleEndian) || - (srcType == GL_UNSIGNED_INT_8_8_8_8 && littleEndian))) { - /* simple memcpy path */ + srcType == GL_UNSIGNED_INT_8_8_8_8)) { + /* simple memcpy path (big endian) */ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, srcWidth, srcHeight, srcDepth, srcFormat, srcType, @@ -1153,12 +975,15 @@ _mesa_texstore_bgra8888(STORE_PARAMS) 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[BCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), + dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]), CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); + CHAN_TO_UBYTE(src[GCOMP]), + CHAN_TO_UBYTE(src[BCOMP]) ); src += 4; } + if (dstFormat == &_mesa_texformat_argb8888_rev) { + _mesa_swap4(dstUI, srcWidth); + } dstRow += dstRowStride; } dstImage += dstImageStride; @@ -1361,18 +1186,16 @@ _mesa_texstore_bgr888(STORE_PARAMS) GLboolean _mesa_texstore_argb4444(STORE_PARAMS) { - const GLuint ui = 1; - const GLubyte littleEndian = *((const GLubyte *) &ui); - - ASSERT(dstFormat == &_mesa_texformat_argb4444); + ASSERT(dstFormat == &_mesa_texformat_argb4444 || + dstFormat == &_mesa_texformat_argb4444_rev); ASSERT(dstFormat->TexelBytes == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && + dstFormat == &_mesa_texformat_argb4444 && baseInternalFormat == GL_RGBA && srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV && littleEndian) || - (srcType == GL_UNSIGNED_SHORT_4_4_4_4 && !littleEndian))) { + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) { /* simple memcpy path */ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, @@ -1407,64 +1230,8 @@ _mesa_texstore_argb4444(STORE_PARAMS) CHAN_TO_UBYTE(src[BCOMP]) ); src += 4; } - dstRow += dstRowStride; - } - dstImage += dstImageStride; - } - _mesa_free((void *) tempImage); - } - return GL_TRUE; -} - - -GLboolean -_mesa_texstore_bgra4444(STORE_PARAMS) -{ - const GLuint ui = 1; - const GLubyte littleEndian = *((const GLubyte *) &ui); - - ASSERT(dstFormat == &_mesa_texformat_bgra4444); - ASSERT(dstFormat->TexelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV && !littleEndian) || - (srcType == GL_UNSIGNED_SHORT_4_4_4_4 && littleEndian))) { - /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageStride, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - dstFormat->BaseFormat, - 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; - 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 *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 4; + if (dstFormat == &_mesa_texformat_argb4444_rev) { + _mesa_swap2(dstUS, srcWidth); } dstRow += dstRowStride; } @@ -1476,21 +1243,20 @@ _mesa_texstore_bgra4444(STORE_PARAMS) } + GLboolean _mesa_texstore_argb1555(STORE_PARAMS) { - const GLuint ui = 1; - const GLubyte littleEndian = *((const GLubyte *) &ui); - - ASSERT(dstFormat == &_mesa_texformat_argb1555); + ASSERT(dstFormat == &_mesa_texformat_argb1555 || + dstFormat == &_mesa_texformat_argb1555_rev); ASSERT(dstFormat->TexelBytes == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && + dstFormat == &_mesa_texformat_argb1555 && baseInternalFormat == GL_RGBA && srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV && littleEndian) || - (srcType == GL_UNSIGNED_SHORT_5_5_5_1 && !littleEndian))) { + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) { /* simple memcpy path */ memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, dstRowStride, dstImageStride, @@ -1525,63 +1291,8 @@ _mesa_texstore_argb1555(STORE_PARAMS) CHAN_TO_UBYTE(src[BCOMP]) ); src += 4; } - dstRow += dstRowStride; - } - dstImage += dstImageStride; - } - _mesa_free((void *) tempImage); - } - return GL_TRUE; -} - -GLboolean -_mesa_texstore_bgra5551(STORE_PARAMS) -{ - const GLuint ui = 1; - const GLubyte littleEndian = *((const GLubyte *) &ui); - - ASSERT(dstFormat == &_mesa_texformat_bgra5551); - ASSERT(dstFormat->TexelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_RGBA && - srcFormat == GL_BGRA && - ((srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV && !littleEndian) || - (srcType == GL_UNSIGNED_SHORT_5_5_5_1 && littleEndian))) { - /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageStride, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - dstFormat->BaseFormat, - 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; - 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 *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_5551( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[GCOMP]), - CHAN_TO_UBYTE(src[BCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 4; + if (dstFormat == &_mesa_texformat_argb1555_rev) { + _mesa_swap2(dstUS, srcWidth); } dstRow += dstRowStride; } @@ -1599,11 +1310,13 @@ _mesa_texstore_al88(STORE_PARAMS) const GLuint ui = 1; const GLubyte littleEndian = *((const GLubyte *) &ui); - ASSERT(dstFormat == &_mesa_texformat_al88); + ASSERT(dstFormat == &_mesa_texformat_al88 || + dstFormat == &_mesa_texformat_al88_rev); ASSERT(dstFormat->TexelBytes == 2); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && + dstFormat == &_mesa_texformat_al88 && baseInternalFormat == GL_LUMINANCE_ALPHA && srcFormat == GL_LUMINANCE_ALPHA && srcType == GL_UNSIGNED_BYTE && @@ -1640,62 +1353,8 @@ _mesa_texstore_al88(STORE_PARAMS) CHAN_TO_UBYTE(src[RCOMP]) ); src += 2; } - dstRow += dstRowStride; - } - dstImage += dstImageStride; - } - _mesa_free((void *) tempImage); - } - return GL_TRUE; -} - - -GLboolean -_mesa_texstore_la88(STORE_PARAMS) -{ - const GLuint ui = 1; - const GLubyte littleEndian = *((const GLubyte *) &ui); - - ASSERT(dstFormat == &_mesa_texformat_la88); - ASSERT(dstFormat->TexelBytes == 2); - - if (!ctx->_ImageTransferState && - !srcPacking->SwapBytes && - baseInternalFormat == GL_LUMINANCE_ALPHA && - srcFormat == GL_LUMINANCE_ALPHA && - srcType == GL_UNSIGNED_BYTE && - !littleEndian) { - /* simple memcpy path */ - memcpy_texture(dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset, - dstRowStride, dstImageStride, - srcWidth, srcHeight, srcDepth, srcFormat, srcType, - srcAddr, srcPacking); - } - else { - /* general path */ - const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims, - baseInternalFormat, - dstFormat->BaseFormat, - 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; - 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 *dstUS = (GLushort *) dstRow; - for (col = 0; col < srcWidth; col++) { - dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[RCOMP]), - CHAN_TO_UBYTE(src[ACOMP]) ); - src += 2; + if (dstFormat == &_mesa_texformat_al88_rev) { + _mesa_swap2(dstUS, srcWidth); } dstRow += dstRowStride; } @@ -2767,9 +2426,9 @@ do_row(const struct gl_texture_format *format, GLint srcWidth, return; /* Begin hardware formats */ case MESA_FORMAT_RGBA8888: - case MESA_FORMAT_ABGR8888: + case MESA_FORMAT_RGBA8888_REV: case MESA_FORMAT_ARGB8888: - case MESA_FORMAT_BGRA8888: + case MESA_FORMAT_ARGB8888_REV: { GLuint i, j, k; const GLubyte (*rowA)[4] = (const GLubyte (*)[4]) srcRowA; @@ -2807,7 +2466,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth, } return; case MESA_FORMAT_RGB565: - case MESA_FORMAT_BGR565: + case MESA_FORMAT_RGB565_REV: { GLuint i, j, k; const GLushort *rowA = (const GLushort *) srcRowA; @@ -2835,7 +2494,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth, } return; case MESA_FORMAT_ARGB4444: - case MESA_FORMAT_BGRA4444: + case MESA_FORMAT_ARGB4444_REV: { GLuint i, j, k; const GLushort *rowA = (const GLushort *) srcRowA; @@ -2868,6 +2527,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth, } return; case MESA_FORMAT_ARGB1555: + case MESA_FORMAT_ARGB1555_REV: /* XXX broken? */ { GLuint i, j, k; const GLushort *rowA = (const GLushort *) srcRowA; @@ -2900,6 +2560,7 @@ do_row(const struct gl_texture_format *format, GLint srcWidth, } return; case MESA_FORMAT_AL88: + case MESA_FORMAT_AL88_REV: { GLuint i, j, k; const GLubyte (*rowA)[2] = (const GLubyte (*)[2]) srcRowA; diff --git a/src/mesa/main/texstore.h b/src/mesa/main/texstore.h index ae79afbc513..85caa774fe5 100644 --- a/src/mesa/main/texstore.h +++ b/src/mesa/main/texstore.h @@ -56,19 +56,17 @@ extern GLboolean _mesa_texstore_color_index(STORE_PARAMS); extern GLboolean _mesa_texstore_depth_component16(STORE_PARAMS); extern GLboolean _mesa_texstore_depth_component_float32(STORE_PARAMS); extern GLboolean _mesa_texstore_rgba8888(STORE_PARAMS); -extern GLboolean _mesa_texstore_abgr8888(STORE_PARAMS); extern GLboolean _mesa_texstore_argb8888(STORE_PARAMS); -extern GLboolean _mesa_texstore_bgra8888(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_bgr565(STORE_PARAMS); +extern GLboolean _mesa_texstore_rgb565_rev(STORE_PARAMS); extern GLboolean _mesa_texstore_argb4444(STORE_PARAMS); -extern GLboolean _mesa_texstore_bgra4444(STORE_PARAMS); +extern GLboolean _mesa_texstore_argb4444_rev(STORE_PARAMS); extern GLboolean _mesa_texstore_argb1555(STORE_PARAMS); -extern GLboolean _mesa_texstore_bgra5551(STORE_PARAMS); +extern GLboolean _mesa_texstore_argb1555_rev(STORE_PARAMS); extern GLboolean _mesa_texstore_al88(STORE_PARAMS); -extern GLboolean _mesa_texstore_la88(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); |