diff options
-rw-r--r-- | src/mesa/main/format_pack.c | 186 | ||||
-rw-r--r-- | src/mesa/main/format_unpack.c | 297 | ||||
-rw-r--r-- | src/mesa/main/formats.c | 207 | ||||
-rw-r--r-- | src/mesa/main/formats.h | 16 | ||||
-rw-r--r-- | src/mesa/main/texstore.c | 210 | ||||
-rw-r--r-- | src/mesa/swrast/s_texfetch.c | 90 |
6 files changed, 959 insertions, 47 deletions
diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c index 330919f55d2..1a14b98b706 100644 --- a/src/mesa/main/format_pack.c +++ b/src/mesa/main/format_pack.c @@ -1669,6 +1669,160 @@ pack_float_R11_G11_B10_FLOAT(const GLfloat src[4], void *dst) } +/* + * MESA_FORMAT_XRGB4444_UNORM + */ + +static void +pack_ubyte_XRGB4444_UNORM(const GLubyte src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + *d = PACK_COLOR_4444(255, src[RCOMP], src[GCOMP], src[BCOMP]); +} + +static void +pack_float_XRGB4444_UNORM(const GLfloat src[4], void *dst) +{ + GLubyte v[4]; + _mesa_unclamped_float_rgba_to_ubyte(v, src); + pack_ubyte_XRGB4444_UNORM(v, dst); +} + + +/* + * MESA_FORMAT_XRGB1555_UNORM + */ + +static void +pack_ubyte_XRGB1555_UNORM(const GLubyte src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + *d = PACK_COLOR_1555(255, src[RCOMP], src[GCOMP], src[BCOMP]); +} + +static void +pack_float_XRGB1555_UNORM(const GLfloat src[4], void *dst) +{ + GLubyte v[4]; + _mesa_unclamped_float_rgba_to_ubyte(v, src); + pack_ubyte_XRGB1555_UNORM(v, dst); +} + + +/* + * MESA_FORMAT_XBGR8888_SNORM + */ + +static void +pack_float_XBGR8888_SNORM(const GLfloat src[4], void *dst) +{ + GLuint *d = (GLuint *) dst; + GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f)); + GLbyte g = FLOAT_TO_BYTE(CLAMP(src[GCOMP], -1.0f, 1.0f)); + GLbyte b = FLOAT_TO_BYTE(CLAMP(src[BCOMP], -1.0f, 1.0f)); + *d = PACK_COLOR_8888(127, b, g, r); +} + + +/* + * MESA_FORMAT_XBGR8888_SRGB + */ + +static void +pack_float_XBGR8888_SRGB(const GLfloat src[4], void *dst) +{ + GLuint *d = (GLuint *) dst; + GLubyte r = linear_float_to_srgb_ubyte(src[RCOMP]); + GLubyte g = linear_float_to_srgb_ubyte(src[GCOMP]); + GLubyte b = linear_float_to_srgb_ubyte(src[BCOMP]); + *d = PACK_COLOR_8888(127, b, g, r); +} + + +/* MESA_FORMAT_XRGB2101010_UNORM */ + +static void +pack_ubyte_XRGB2101010_UNORM(const GLubyte src[4], void *dst) +{ + GLuint *d = ((GLuint *) dst); + GLushort r = UBYTE_TO_USHORT(src[RCOMP]); + GLushort g = UBYTE_TO_USHORT(src[GCOMP]); + GLushort b = UBYTE_TO_USHORT(src[BCOMP]); + *d = PACK_COLOR_2101010_US(3, r, g, b); +} + +static void +pack_float_XRGB2101010_UNORM(const GLfloat src[4], void *dst) +{ + GLuint *d = ((GLuint *) dst); + GLushort r, g, b; + UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); + *d = PACK_COLOR_2101010_US(3, r, g, b); +} + + +/* MESA_FORMAT_XBGR16161616_UNORM */ + +static void +pack_ubyte_XBGR16161616_UNORM(const GLubyte src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + d[0] = UBYTE_TO_USHORT(src[RCOMP]); + d[1] = UBYTE_TO_USHORT(src[GCOMP]); + d[2] = UBYTE_TO_USHORT(src[BCOMP]); + d[3] = 65535; +} + +static void +pack_float_XBGR16161616_UNORM(const GLfloat src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + UNCLAMPED_FLOAT_TO_USHORT(d[0], src[RCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(d[1], src[GCOMP]); + UNCLAMPED_FLOAT_TO_USHORT(d[2], src[BCOMP]); + d[3] = 65535; +} + + +/* MESA_FORMAT_XBGR16161616_SNORM */ + +static void +pack_float_XBGR16161616_SNORM(const GLfloat src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + UNCLAMPED_FLOAT_TO_SHORT(d[0], src[RCOMP]); + UNCLAMPED_FLOAT_TO_SHORT(d[1], src[GCOMP]); + UNCLAMPED_FLOAT_TO_SHORT(d[2], src[BCOMP]); + d[3] = 32767; +} + + +/* MESA_FORMAT_XBGR16161616_FLOAT */ + +static void +pack_float_XBGR16161616_FLOAT(const GLfloat src[4], void *dst) +{ + GLushort *d = ((GLushort *) dst); + d[0] = _mesa_float_to_half(src[RCOMP]); + d[1] = _mesa_float_to_half(src[GCOMP]); + d[2] = _mesa_float_to_half(src[BCOMP]); + d[3] = _mesa_float_to_half(1.0); +} + +/* MESA_FORMAT_XBGR32323232_FLOAT */ + +static void +pack_float_XBGR32323232_FLOAT(const GLfloat src[4], void *dst) +{ + GLfloat *d = ((GLfloat *) dst); + d[0] = src[RCOMP]; + d[1] = src[GCOMP]; + d[2] = src[BCOMP]; + d[3] = 1.0; +} + /** * Return a function that can pack a GLubyte rgba[4] color. @@ -1807,6 +1961,22 @@ _mesa_get_pack_ubyte_rgba_function(gl_format format) table[MESA_FORMAT_RGB9_E5_FLOAT] = pack_ubyte_RGB9_E5_FLOAT; table[MESA_FORMAT_R11_G11_B10_FLOAT] = pack_ubyte_R11_G11_B10_FLOAT; + table[MESA_FORMAT_XRGB4444_UNORM] = pack_ubyte_XRGB4444_UNORM; + table[MESA_FORMAT_XRGB1555_UNORM] = pack_ubyte_XRGB1555_UNORM; + table[MESA_FORMAT_XBGR8888_SNORM] = NULL; + table[MESA_FORMAT_XBGR8888_SRGB] = NULL; + table[MESA_FORMAT_XBGR8888_UINT] = NULL; + table[MESA_FORMAT_XBGR8888_SINT] = NULL; + table[MESA_FORMAT_XRGB2101010_UNORM] = pack_ubyte_XRGB2101010_UNORM; + table[MESA_FORMAT_XBGR16161616_UNORM] = pack_ubyte_XBGR16161616_UNORM; + table[MESA_FORMAT_XBGR16161616_SNORM] = NULL; + table[MESA_FORMAT_XBGR16161616_FLOAT] = NULL; + table[MESA_FORMAT_XBGR16161616_UINT] = NULL; + table[MESA_FORMAT_XBGR16161616_SINT] = NULL; + table[MESA_FORMAT_XBGR32323232_FLOAT] = NULL; + table[MESA_FORMAT_XBGR32323232_UINT] = NULL; + table[MESA_FORMAT_XBGR32323232_SINT] = NULL; + initialized = GL_TRUE; } @@ -1949,6 +2119,22 @@ _mesa_get_pack_float_rgba_function(gl_format format) table[MESA_FORMAT_RGB9_E5_FLOAT] = pack_float_RGB9_E5_FLOAT; table[MESA_FORMAT_R11_G11_B10_FLOAT] = pack_float_R11_G11_B10_FLOAT; + table[MESA_FORMAT_XRGB4444_UNORM] = pack_float_XRGB4444_UNORM; + table[MESA_FORMAT_XRGB1555_UNORM] = pack_float_XRGB1555_UNORM; + table[MESA_FORMAT_XBGR8888_SNORM] = pack_float_XBGR8888_SNORM; + table[MESA_FORMAT_XBGR8888_SRGB] = pack_float_XBGR8888_SRGB; + table[MESA_FORMAT_XBGR8888_UINT] = NULL; + table[MESA_FORMAT_XBGR8888_SINT] = NULL; + table[MESA_FORMAT_XRGB2101010_UNORM] = pack_float_XRGB2101010_UNORM; + table[MESA_FORMAT_XBGR16161616_UNORM] = pack_float_XBGR16161616_UNORM; + table[MESA_FORMAT_XBGR16161616_SNORM] = pack_float_XBGR16161616_SNORM; + table[MESA_FORMAT_XBGR16161616_FLOAT] = pack_float_XBGR16161616_FLOAT; + table[MESA_FORMAT_XBGR16161616_UINT] = NULL; + table[MESA_FORMAT_XBGR16161616_SINT] = NULL; + table[MESA_FORMAT_XBGR32323232_FLOAT] = pack_float_XBGR32323232_FLOAT; + table[MESA_FORMAT_XBGR32323232_UINT] = NULL; + table[MESA_FORMAT_XBGR32323232_SINT] = NULL; + initialized = GL_TRUE; } diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c index cccb2b4cb19..0933b4e87ff 100644 --- a/src/mesa/main/format_unpack.c +++ b/src/mesa/main/format_unpack.c @@ -1524,6 +1524,201 @@ unpack_R11_G11_B10_FLOAT(const void *src, GLfloat dst[][4], GLuint n) } } +static void +unpack_XRGB4444_UNORM(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLushort *s = ((const GLushort *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = ((s[i] >> 8) & 0xf) * (1.0F / 15.0F); + dst[i][GCOMP] = ((s[i] >> 4) & 0xf) * (1.0F / 15.0F); + dst[i][BCOMP] = ((s[i] ) & 0xf) * (1.0F / 15.0F); + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XRGB1555_UNORM(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLushort *s = ((const GLushort *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = ((s[i] >> 10) & 0x1f) * (1.0F / 31.0F); + dst[i][GCOMP] = ((s[i] >> 5) & 0x1f) * (1.0F / 31.0F); + dst[i][BCOMP] = ((s[i] >> 0) & 0x1f) * (1.0F / 31.0F); + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR8888_SNORM(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] ) ); + dst[i][GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] >> 8) ); + dst[i][BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] >> 16) ); + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR8888_SRGB(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = _mesa_nonlinear_to_linear( (s[i] ) & 0xff ); + dst[i][GCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 8) & 0xff ); + dst[i][BCOMP] = _mesa_nonlinear_to_linear( (s[i] >> 16) & 0xff ); + dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] >> 24 ); /* linear! */ + } +} + +static void +unpack_XBGR8888_UINT(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLbyte *s = (const GLbyte *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = s[i*4+0]; + dst[i][GCOMP] = s[i*4+1]; + dst[i][BCOMP] = s[i*4+2]; + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR8888_SINT(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLbyte *s = (const GLbyte *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = s[i*4+0]; + dst[i][GCOMP] = s[i*4+1]; + dst[i][BCOMP] = s[i*4+2]; + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XRGB2101010_UNORM(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = ((const GLuint *) src); + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = ((s[i] >> 20) & 0x3ff) * (1.0F / 1023.0F); + dst[i][GCOMP] = ((s[i] >> 10) & 0x3ff) * (1.0F / 1023.0F); + dst[i][BCOMP] = ((s[i] >> 0) & 0x3ff) * (1.0F / 1023.0F); + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR16161616_UNORM(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLushort *s = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = USHORT_TO_FLOAT( s[i*4+0] ); + dst[i][GCOMP] = USHORT_TO_FLOAT( s[i*4+1] ); + dst[i][BCOMP] = USHORT_TO_FLOAT( s[i*4+2] ); + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR16161616_SNORM(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLshort *s = (const GLshort *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = SHORT_TO_FLOAT_TEX( s[i*4+0] ); + dst[i][GCOMP] = SHORT_TO_FLOAT_TEX( s[i*4+1] ); + dst[i][BCOMP] = SHORT_TO_FLOAT_TEX( s[i*4+2] ); + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR16161616_FLOAT(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLshort *s = (const GLshort *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = _mesa_half_to_float(s[i*4+0]); + dst[i][GCOMP] = _mesa_half_to_float(s[i*4+1]); + dst[i][BCOMP] = _mesa_half_to_float(s[i*4+2]); + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR16161616_UINT(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLushort *s = (const GLushort *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = (GLfloat) s[i*4+0]; + dst[i][GCOMP] = (GLfloat) s[i*4+1]; + dst[i][BCOMP] = (GLfloat) s[i*4+2]; + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR16161616_SINT(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLshort *s = (const GLshort *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = (GLfloat) s[i*4+0]; + dst[i][GCOMP] = (GLfloat) s[i*4+1]; + dst[i][BCOMP] = (GLfloat) s[i*4+2]; + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR32323232_FLOAT(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLfloat *s = (const GLfloat *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = s[i*4+0]; + dst[i][GCOMP] = s[i*4+1]; + dst[i][BCOMP] = s[i*4+2]; + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR32323232_UINT(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLuint *s = (const GLuint *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = (GLfloat) s[i*4+0]; + dst[i][GCOMP] = (GLfloat) s[i*4+1]; + dst[i][BCOMP] = (GLfloat) s[i*4+2]; + dst[i][ACOMP] = 1.0; + } +} + +static void +unpack_XBGR32323232_SINT(const void *src, GLfloat dst[][4], GLuint n) +{ + const GLint *s = (const GLint *) src; + GLuint i; + for (i = 0; i < n; i++) { + dst[i][RCOMP] = (GLfloat) s[i*4+0]; + dst[i][GCOMP] = (GLfloat) s[i*4+1]; + dst[i][BCOMP] = (GLfloat) s[i*4+2]; + dst[i][ACOMP] = 1.0; + } +} + /** * Return the unpacker function for the given format. @@ -1674,6 +1869,22 @@ get_unpack_rgba_function(gl_format format) table[MESA_FORMAT_Z32_FLOAT] = unpack_Z32_FLOAT; table[MESA_FORMAT_Z32_FLOAT_X24S8] = unpack_Z32_FLOAT_X24S8; + table[MESA_FORMAT_XRGB4444_UNORM] = unpack_XRGB4444_UNORM; + table[MESA_FORMAT_XRGB1555_UNORM] = unpack_XRGB1555_UNORM; + table[MESA_FORMAT_XBGR8888_SNORM] = unpack_XBGR8888_SNORM; + table[MESA_FORMAT_XBGR8888_SRGB] = unpack_XBGR8888_SRGB; + table[MESA_FORMAT_XBGR8888_UINT] = unpack_XBGR8888_UINT; + table[MESA_FORMAT_XBGR8888_SINT] = unpack_XBGR8888_SINT; + table[MESA_FORMAT_XRGB2101010_UNORM] = unpack_XRGB2101010_UNORM; + table[MESA_FORMAT_XBGR16161616_UNORM] = unpack_XBGR16161616_UNORM; + table[MESA_FORMAT_XBGR16161616_SNORM] = unpack_XBGR16161616_SNORM; + table[MESA_FORMAT_XBGR16161616_FLOAT] = unpack_XBGR16161616_FLOAT; + table[MESA_FORMAT_XBGR16161616_UINT] = unpack_XBGR16161616_UINT; + table[MESA_FORMAT_XBGR16161616_SINT] = unpack_XBGR16161616_SINT; + table[MESA_FORMAT_XBGR32323232_FLOAT] = unpack_XBGR32323232_FLOAT; + table[MESA_FORMAT_XBGR32323232_UINT] = unpack_XBGR32323232_UINT; + table[MESA_FORMAT_XBGR32323232_SINT] = unpack_XBGR32323232_SINT; + initialized = GL_TRUE; } @@ -2710,6 +2921,71 @@ unpack_int_rgba_ARGB2101010(const GLuint *src, GLuint dst[][4], GLuint n) } } +static void +unpack_int_rgba_XBGR8888_UINT(const GLubyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 4 + 0]; + dst[i][1] = src[i * 4 + 1]; + dst[i][2] = src[i * 4 + 2]; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_XBGR8888_SINT(const GLbyte *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 4 + 0]; + dst[i][1] = src[i * 4 + 1]; + dst[i][2] = src[i * 4 + 2]; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_XBGR16161616_UINT(const GLushort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 4 + 0]; + dst[i][1] = src[i * 4 + 1]; + dst[i][2] = src[i * 4 + 2]; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_XBGR16161616_SINT(const GLshort *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 4 + 0]; + dst[i][1] = src[i * 4 + 1]; + dst[i][2] = src[i * 4 + 2]; + dst[i][3] = 1; + } +} + +static void +unpack_int_rgba_XBGR32323232_UINT(const GLuint *src, GLuint dst[][4], GLuint n) +{ + unsigned int i; + + for (i = 0; i < n; i++) { + dst[i][0] = src[i * 4 + 0]; + dst[i][1] = src[i * 4 + 1]; + dst[i][2] = src[i * 4 + 2]; + dst[i][3] = 1; + } +} + void _mesa_unpack_uint_rgba_row(gl_format format, GLuint n, const void *src, GLuint dst[][4]) @@ -2889,6 +3165,27 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n, unpack_int_rgba_ARGB2101010(src, dst, n); break; + case MESA_FORMAT_XBGR8888_UINT: + unpack_int_rgba_XBGR8888_UINT(src, dst, n); + break; + + case MESA_FORMAT_XBGR8888_SINT: + unpack_int_rgba_XBGR8888_SINT(src, dst, n); + break; + + case MESA_FORMAT_XBGR16161616_UINT: + unpack_int_rgba_XBGR16161616_UINT(src, dst, n); + break; + + case MESA_FORMAT_XBGR16161616_SINT: + unpack_int_rgba_XBGR16161616_SINT(src, dst, n); + break; + + case MESA_FORMAT_XBGR32323232_UINT: + case MESA_FORMAT_XBGR32323232_SINT: + unpack_int_rgba_XBGR32323232_UINT(src, dst, n); + break; + default: _mesa_problem(NULL, "%s: bad format %s", __FUNCTION__, _mesa_get_format_name(format)); diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c index 1f400644436..176067d53b3 100644 --- a/src/mesa/main/formats.c +++ b/src/mesa/main/formats.c @@ -1629,6 +1629,141 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 0, 0, 0, 0, 0, 1, 1, 4 }, + { + MESA_FORMAT_XRGB4444_UNORM, + "MESA_FORMAT_XRGB4444_UNORM", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 4, 4, 4, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_XRGB1555_UNORM, + "MESA_FORMAT_XRGB1555_UNORM", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 5, 5, 5, 0, + 0, 0, 0, 0, 0, + 1, 1, 2 + }, + { + MESA_FORMAT_XBGR8888_SNORM, + "MESA_FORMAT_XBGR8888_SNORM", + GL_RGB, + GL_SIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_XBGR8888_SRGB, + "MESA_FORMAT_XBGR8888_SRGB", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_XBGR8888_UINT, + "MESA_FORMAT_XBGR8888_UINT", + GL_RGB, + GL_UNSIGNED_INT, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_XBGR8888_SINT, + "MESA_FORMAT_XBGR8888_SINT", + GL_RGB, + GL_INT, + 8, 8, 8, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_XRGB2101010_UNORM, + "MESA_FORMAT_XRGB2101010_UNORM", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 10, 10, 10, 0, + 0, 0, 0, 0, 0, + 1, 1, 4 + }, + { + MESA_FORMAT_XBGR16161616_UNORM, + "MESA_FORMAT_XBGR16161616_UNORM", + GL_RGB, + GL_UNSIGNED_NORMALIZED, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_XBGR16161616_SNORM, + "MESA_FORMAT_XBGR16161616_SNORM", + GL_RGB, + GL_SIGNED_NORMALIZED, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_XBGR16161616_FLOAT, + "MESA_FORMAT_XBGR16161616_FLOAT", + GL_RGB, + GL_FLOAT, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_XBGR16161616_UINT, + "MESA_FORMAT_XBGR16161616_UINT", + GL_RGB, + GL_UNSIGNED_INT, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_XBGR16161616_SINT, + "MESA_FORMAT_XBGR16161616_SINT", + GL_RGB, + GL_INT, + 16, 16, 16, 0, + 0, 0, 0, 0, 0, + 1, 1, 8 + }, + { + MESA_FORMAT_XBGR32323232_FLOAT, + "MESA_FORMAT_XBGR32323232_FLOAT", + GL_RGB, + GL_FLOAT, + 32, 32, 32, 0, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + { + MESA_FORMAT_XBGR32323232_UINT, + "MESA_FORMAT_XBGR32323232_UINT", + GL_RGB, + GL_UNSIGNED_INT, + 32, 32, 32, 0, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, + { + MESA_FORMAT_XBGR32323232_SINT, + "MESA_FORMAT_XBGR32323232_SINT", + GL_RGB, + GL_INT, + 32, 32, 32, 0, + 0, 0, 0, 0, 0, + 1, 1, 16 + }, }; @@ -1850,6 +1985,7 @@ _mesa_get_format_color_encoding(gl_format format) case MESA_FORMAT_SRGBA_DXT1: case MESA_FORMAT_SRGBA_DXT3: case MESA_FORMAT_SRGBA_DXT5: + case MESA_FORMAT_XBGR8888_SRGB: return GL_SRGB; default: return GL_LINEAR; @@ -1892,6 +2028,9 @@ _mesa_get_srgb_format_linear(gl_format format) case MESA_FORMAT_SRGBA_DXT5: format = MESA_FORMAT_RGBA_DXT5; break; + case MESA_FORMAT_XBGR8888_SRGB: + format = MESA_FORMAT_RGBX8888_REV; + break; default: break; } @@ -2199,12 +2338,14 @@ _mesa_format_to_type_and_comps(gl_format format, case MESA_FORMAT_ARGB4444: case MESA_FORMAT_ARGB4444_REV: + case MESA_FORMAT_XRGB4444_UNORM: *datatype = GL_UNSIGNED_SHORT_4_4_4_4; *comps = 4; return; case MESA_FORMAT_ARGB1555: case MESA_FORMAT_ARGB1555_REV: + case MESA_FORMAT_XRGB1555_UNORM: *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV; *comps = 4; return; @@ -2632,6 +2773,55 @@ _mesa_format_to_type_and_comps(gl_format format, *comps = 4; return; + case MESA_FORMAT_XBGR8888_SRGB: + case MESA_FORMAT_XBGR8888_UINT: + *datatype = GL_UNSIGNED_BYTE; + *comps = 4; + return; + + case MESA_FORMAT_XBGR8888_SNORM: + case MESA_FORMAT_XBGR8888_SINT: + *datatype = GL_BYTE; + *comps = 4; + return; + + case MESA_FORMAT_XRGB2101010_UNORM: + *datatype = GL_UNSIGNED_INT_2_10_10_10_REV; + *comps = 4; + return; + + case MESA_FORMAT_XBGR16161616_UNORM: + case MESA_FORMAT_XBGR16161616_UINT: + *datatype = GL_UNSIGNED_SHORT; + *comps = 4; + return; + + case MESA_FORMAT_XBGR16161616_SNORM: + case MESA_FORMAT_XBGR16161616_SINT: + *datatype = GL_SHORT; + *comps = 4; + return; + + case MESA_FORMAT_XBGR16161616_FLOAT: + *datatype = GL_HALF_FLOAT; + *comps = 4; + return; + + case MESA_FORMAT_XBGR32323232_FLOAT: + *datatype = GL_FLOAT; + *comps = 4; + return; + + case MESA_FORMAT_XBGR32323232_UINT: + *datatype = GL_UNSIGNED_INT; + *comps = 4; + return; + + case MESA_FORMAT_XBGR32323232_SINT: + *datatype = GL_INT; + *comps = 4; + return; + case MESA_FORMAT_COUNT: assert(0); return; @@ -3081,6 +3271,23 @@ _mesa_format_matches_format_and_type(gl_format gl_format, case MESA_FORMAT_Z32_FLOAT_X24S8: return GL_FALSE; + + case MESA_FORMAT_XRGB4444_UNORM: + case MESA_FORMAT_XRGB1555_UNORM: + case MESA_FORMAT_XBGR8888_SNORM: + case MESA_FORMAT_XBGR8888_SRGB: + case MESA_FORMAT_XBGR8888_UINT: + case MESA_FORMAT_XBGR8888_SINT: + case MESA_FORMAT_XRGB2101010_UNORM: + case MESA_FORMAT_XBGR16161616_UNORM: + case MESA_FORMAT_XBGR16161616_SNORM: + case MESA_FORMAT_XBGR16161616_FLOAT: + case MESA_FORMAT_XBGR16161616_UINT: + case MESA_FORMAT_XBGR16161616_SINT: + case MESA_FORMAT_XBGR32323232_FLOAT: + case MESA_FORMAT_XBGR32323232_UINT: + case MESA_FORMAT_XBGR32323232_SINT: + return GL_FALSE; } return GL_FALSE; diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h index be140a750a0..2961ffa9f24 100644 --- a/src/mesa/main/formats.h +++ b/src/mesa/main/formats.h @@ -288,6 +288,22 @@ typedef enum MESA_FORMAT_ARGB2101010_UINT, MESA_FORMAT_ABGR2101010_UINT, + MESA_FORMAT_XRGB4444_UNORM, + MESA_FORMAT_XRGB1555_UNORM, + MESA_FORMAT_XBGR8888_SNORM, + MESA_FORMAT_XBGR8888_SRGB, + MESA_FORMAT_XBGR8888_UINT, + MESA_FORMAT_XBGR8888_SINT, + MESA_FORMAT_XRGB2101010_UNORM, + MESA_FORMAT_XBGR16161616_UNORM, + MESA_FORMAT_XBGR16161616_SNORM, + MESA_FORMAT_XBGR16161616_FLOAT, + MESA_FORMAT_XBGR16161616_UINT, + MESA_FORMAT_XBGR16161616_SINT, + MESA_FORMAT_XBGR32323232_FLOAT, + MESA_FORMAT_XBGR32323232_UINT, + MESA_FORMAT_XBGR32323232_SINT, + MESA_FORMAT_COUNT } gl_format; diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index 471c41aa875..6e7ce237f6f 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -1688,9 +1688,8 @@ _mesa_texstore_argb1555(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_argb2101010(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_ARGB2101010); + ASSERT(dstFormat == MESA_FORMAT_ARGB2101010 || + dstFormat == MESA_FORMAT_XRGB2101010_UNORM); ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && @@ -1706,15 +1705,16 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) } else { /* general path */ + /* Hardcode GL_RGBA as the base format, which forces alpha to 1.0 + * if the internal format is RGB. */ const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, baseInternalFormat, - baseFormat, + GL_RGBA, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking, ctx->_ImageTransferState); const GLfloat *src = tempImage; - const GLushort aMask = (srcFormat == GL_RGB) ? 0xffff : 0; GLint img, row, col; if (!tempImage) return GL_FALSE; @@ -1727,7 +1727,6 @@ _mesa_texstore_argb2101010(TEXSTORE_PARAMS) GLushort a,r,g,b; UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]); - a = a | aMask; UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]); UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]); UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]); @@ -2043,9 +2042,8 @@ _mesa_texstore_unorm16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_16(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - - ASSERT(dstFormat == MESA_FORMAT_RGBA_16); + ASSERT(dstFormat == MESA_FORMAT_RGBA_16 || + dstFormat == MESA_FORMAT_XBGR16161616_UNORM); ASSERT(_mesa_get_format_bytes(dstFormat) == 8); if (!ctx->_ImageTransferState && @@ -2062,17 +2060,21 @@ _mesa_texstore_rgba_16(TEXSTORE_PARAMS) } else { /* general path */ + /* Hardcode GL_RGBA as the base format, which forces alpha to 1.0 + * if the internal format is RGB. */ const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims, baseInternalFormat, - baseFormat, + GL_RGBA, srcWidth, srcHeight, srcDepth, srcFormat, srcType, srcAddr, srcPacking, ctx->_ImageTransferState); const GLfloat *src = tempImage; GLint img, row, col; + if (!tempImage) return GL_FALSE; + for (img = 0; img < srcDepth; img++) { GLubyte *dstRow = dstSlices[img]; for (row = 0; row < srcHeight; row++) { @@ -2105,7 +2107,8 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGB_16 || - dstFormat == MESA_FORMAT_SIGNED_RGBA_16); + dstFormat == MESA_FORMAT_SIGNED_RGBA_16 || + dstFormat == MESA_FORMAT_XBGR16161616_SNORM); if (!ctx->_ImageTransferState && !srcPacking->SwapBytes && @@ -2154,7 +2157,22 @@ _mesa_texstore_signed_rgba_16(TEXSTORE_PARAMS) } dstRow += dstRowStride; src += 4 * srcWidth; - } else { + } + else if (dstFormat == MESA_FORMAT_XBGR16161616_SNORM) { + for (col = 0; col < srcWidth; col++) { + GLuint c; + + for (c = 0; c < 3; c++) { + GLshort p; + UNCLAMPED_FLOAT_TO_SHORT(p, src[col * 3 + c]); + dstRowS[col * comps + c] = p; + } + dstRowS[col * comps + 3] = 32767; + } + dstRow += dstRowStride; + src += 3 * srcWidth; + } + else { for (col = 0; col < srcWidth; col++) { GLuint c; for (c = 0; c < comps; c++) { @@ -2641,14 +2659,16 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS) } /** - * Store a texture in MESA_FORMAT_SIGNED_RGBX8888. + * Store a texture in MESA_FORMAT_SIGNED_RGBX8888 or + * MESA_FORMAT_XBGR8888_SNORM. */ static GLboolean _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) { const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888); + ASSERT(dstFormat == MESA_FORMAT_SIGNED_RGBX8888 || + dstFormat == MESA_FORMAT_XBGR8888_SNORM); ASSERT(_mesa_get_format_bytes(dstFormat) == 4); { @@ -2668,13 +2688,25 @@ _mesa_texstore_signed_rgbx8888(TEXSTORE_PARAMS) GLbyte *dstRow = (GLbyte *) dstSlices[img]; for (row = 0; row < srcHeight; row++) { GLbyte *dst = dstRow; - for (col = 0; col < srcWidth; col++) { - dst[3] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]); - dst[2] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]); - dst[1] = FLOAT_TO_BYTE_TEX(srcRow[BCOMP]); - dst[0] = 127; - srcRow += 3; - dst += 4; + if (dstFormat == MESA_FORMAT_SIGNED_RGBX8888) { + for (col = 0; col < srcWidth; col++) { + dst[3] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]); + dst[2] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]); + dst[1] = FLOAT_TO_BYTE_TEX(srcRow[BCOMP]); + dst[0] = 127; + srcRow += 3; + dst += 4; + } + } + else { + for (col = 0; col < srcWidth; col++) { + dst[0] = FLOAT_TO_BYTE_TEX(srcRow[RCOMP]); + dst[1] = FLOAT_TO_BYTE_TEX(srcRow[GCOMP]); + dst[2] = FLOAT_TO_BYTE_TEX(srcRow[BCOMP]); + dst[3] = 127; + srcRow += 3; + dst += 4; + } } dstRow += dstRowStride; } @@ -3004,8 +3036,14 @@ _mesa_texstore_s8(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); + GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + GLint components = _mesa_components_in_format(baseFormat); + + /* this forces alpha to 1 in _mesa_make_temp_float_image */ + if (dstFormat == MESA_FORMAT_XBGR32323232_FLOAT) { + baseFormat = GL_RGBA; + components = 4; + } ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT32 || dstFormat == MESA_FORMAT_RGB_FLOAT32 || @@ -3014,7 +3052,8 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32 || dstFormat == MESA_FORMAT_INTENSITY_FLOAT32 || dstFormat == MESA_FORMAT_R_FLOAT32 || - dstFormat == MESA_FORMAT_RG_FLOAT32); + dstFormat == MESA_FORMAT_RG_FLOAT32 || + dstFormat == MESA_FORMAT_XBGR32323232_FLOAT); ASSERT(baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB || baseInternalFormat == GL_ALPHA || @@ -3074,8 +3113,14 @@ _mesa_texstore_rgba_float32(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); + GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + GLint components = _mesa_components_in_format(baseFormat); + + /* this forces alpha to 1 in _mesa_make_temp_float_image */ + if (dstFormat == MESA_FORMAT_XBGR16161616_FLOAT) { + baseFormat = GL_RGBA; + components = 4; + } ASSERT(dstFormat == MESA_FORMAT_RGBA_FLOAT16 || dstFormat == MESA_FORMAT_RGB_FLOAT16 || @@ -3084,7 +3129,8 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16 || dstFormat == MESA_FORMAT_INTENSITY_FLOAT16 || dstFormat == MESA_FORMAT_R_FLOAT16 || - dstFormat == MESA_FORMAT_RG_FLOAT16); + dstFormat == MESA_FORMAT_RG_FLOAT16 || + dstFormat == MESA_FORMAT_XBGR16161616_FLOAT); ASSERT(baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB || baseInternalFormat == GL_ALPHA || @@ -3143,8 +3189,14 @@ _mesa_texstore_rgba_float16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); + GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + GLint components = _mesa_components_in_format(baseFormat); + + /* this forces alpha to 1 in make_temp_uint_image */ + if (dstFormat == MESA_FORMAT_XBGR8888_SINT) { + baseFormat = GL_RGBA; + components = 4; + } ASSERT(dstFormat == MESA_FORMAT_R_INT8 || dstFormat == MESA_FORMAT_RG_INT8 || @@ -3153,7 +3205,8 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_ALPHA_INT8 || dstFormat == MESA_FORMAT_INTENSITY_INT8 || dstFormat == MESA_FORMAT_LUMINANCE_INT8 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT8); + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT8 || + dstFormat == MESA_FORMAT_XBGR8888_SINT); ASSERT(baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB || baseInternalFormat == GL_RG || @@ -3220,8 +3273,14 @@ _mesa_texstore_rgba_int8(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); + GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + GLint components = _mesa_components_in_format(baseFormat); + + /* this forces alpha to 1 in make_temp_uint_image */ + if (dstFormat == MESA_FORMAT_XBGR16161616_SINT) { + baseFormat = GL_RGBA; + components = 4; + } ASSERT(dstFormat == MESA_FORMAT_R_INT16 || dstFormat == MESA_FORMAT_RG_INT16 || @@ -3230,7 +3289,8 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_ALPHA_INT16 || dstFormat == MESA_FORMAT_LUMINANCE_INT16 || dstFormat == MESA_FORMAT_INTENSITY_INT16 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT16); + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT16 || + dstFormat == MESA_FORMAT_XBGR16161616_SINT); ASSERT(baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB || baseInternalFormat == GL_RG || @@ -3297,8 +3357,14 @@ _mesa_texstore_rgba_int16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); + GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + GLint components = _mesa_components_in_format(baseFormat); + + /* this forces alpha to 1 in make_temp_uint_image */ + if (dstFormat == MESA_FORMAT_XBGR32323232_SINT) { + baseFormat = GL_RGBA; + components = 4; + } ASSERT(dstFormat == MESA_FORMAT_R_INT32 || dstFormat == MESA_FORMAT_RG_INT32 || @@ -3307,7 +3373,8 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_ALPHA_INT32 || dstFormat == MESA_FORMAT_INTENSITY_INT32 || dstFormat == MESA_FORMAT_LUMINANCE_INT32 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT32); + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_INT32 || + dstFormat == MESA_FORMAT_XBGR32323232_SINT); ASSERT(baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB || baseInternalFormat == GL_RG || @@ -3374,8 +3441,14 @@ _mesa_texstore_rgba_int32(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); + GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + GLint components = _mesa_components_in_format(baseFormat); + + /* this forces alpha to 1 in make_temp_uint_image */ + if (dstFormat == MESA_FORMAT_XBGR8888_UINT) { + baseFormat = GL_RGBA; + components = 4; + } ASSERT(dstFormat == MESA_FORMAT_R_UINT8 || dstFormat == MESA_FORMAT_RG_UINT8 || @@ -3384,7 +3457,8 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_ALPHA_UINT8 || dstFormat == MESA_FORMAT_INTENSITY_UINT8 || dstFormat == MESA_FORMAT_LUMINANCE_UINT8 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT8); + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT8 || + dstFormat == MESA_FORMAT_XBGR8888_UINT); ASSERT(baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB || baseInternalFormat == GL_RG || @@ -3448,8 +3522,14 @@ _mesa_texstore_rgba_uint8(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); + GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + GLint components = _mesa_components_in_format(baseFormat); + + /* this forces alpha to 1 in make_temp_uint_image */ + if (dstFormat == MESA_FORMAT_XBGR16161616_UINT) { + baseFormat = GL_RGBA; + components = 4; + } ASSERT(dstFormat == MESA_FORMAT_R_UINT16 || dstFormat == MESA_FORMAT_RG_UINT16 || @@ -3458,7 +3538,8 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_ALPHA_UINT16 || dstFormat == MESA_FORMAT_INTENSITY_UINT16 || dstFormat == MESA_FORMAT_LUMINANCE_UINT16 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT16); + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT16 || + dstFormat == MESA_FORMAT_XBGR16161616_UINT); ASSERT(baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB || baseInternalFormat == GL_RG || @@ -3522,8 +3603,14 @@ _mesa_texstore_rgba_uint16(TEXSTORE_PARAMS) static GLboolean _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) { - const GLenum baseFormat = _mesa_get_format_base_format(dstFormat); - const GLint components = _mesa_components_in_format(baseFormat); + GLenum baseFormat = _mesa_get_format_base_format(dstFormat); + GLint components = _mesa_components_in_format(baseFormat); + + /* this forces alpha to 1 in make_temp_uint_image */ + if (dstFormat == MESA_FORMAT_XBGR32323232_UINT) { + baseFormat = GL_RGBA; + components = 4; + } ASSERT(dstFormat == MESA_FORMAT_R_UINT32 || dstFormat == MESA_FORMAT_RG_UINT32 || @@ -3532,7 +3619,8 @@ _mesa_texstore_rgba_uint32(TEXSTORE_PARAMS) dstFormat == MESA_FORMAT_ALPHA_UINT32 || dstFormat == MESA_FORMAT_INTENSITY_UINT32 || dstFormat == MESA_FORMAT_LUMINANCE_UINT32 || - dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT32); + dstFormat == MESA_FORMAT_LUMINANCE_ALPHA_UINT32 || + dstFormat == MESA_FORMAT_XBGR32323232_UINT); ASSERT(baseInternalFormat == GL_RGBA || baseInternalFormat == GL_RGB || baseInternalFormat == GL_RG || @@ -3619,10 +3707,21 @@ _mesa_texstore_srgba8(TEXSTORE_PARAMS) gl_format newDstFormat; GLboolean k; - ASSERT(dstFormat == MESA_FORMAT_SRGBA8); + ASSERT(dstFormat == MESA_FORMAT_SRGBA8 || + dstFormat == MESA_FORMAT_XBGR8888_SRGB); /* reuse normal rgba texstore code */ - newDstFormat = MESA_FORMAT_RGBA8888; + if (dstFormat == MESA_FORMAT_SRGBA8) { + newDstFormat = MESA_FORMAT_RGBA8888; + } + else if (dstFormat == MESA_FORMAT_XBGR8888_SRGB) { + newDstFormat = MESA_FORMAT_RGBX8888_REV; + } + else { + ASSERT(0); + return GL_TRUE; + } + k = _mesa_texstore_rgba8888(ctx, dims, baseInternalFormat, newDstFormat, dstRowStride, dstSlices, @@ -4193,6 +4292,23 @@ _mesa_get_texstore_func(gl_format format) table[MESA_FORMAT_ARGB2101010_UINT] = _mesa_texstore_argb2101010_uint; table[MESA_FORMAT_ABGR2101010_UINT] = _mesa_texstore_abgr2101010_uint; + + table[MESA_FORMAT_XRGB4444_UNORM] = store_ubyte_texture; + table[MESA_FORMAT_XRGB1555_UNORM] = store_ubyte_texture; + table[MESA_FORMAT_XBGR8888_SNORM] = _mesa_texstore_signed_rgbx8888; + table[MESA_FORMAT_XBGR8888_SRGB] = _mesa_texstore_srgba8; + table[MESA_FORMAT_XBGR8888_UINT] = _mesa_texstore_rgba_uint8; + table[MESA_FORMAT_XBGR8888_SINT] = _mesa_texstore_rgba_int8; + table[MESA_FORMAT_XRGB2101010_UNORM] = _mesa_texstore_argb2101010; + table[MESA_FORMAT_XBGR16161616_UNORM] = _mesa_texstore_rgba_16; + table[MESA_FORMAT_XBGR16161616_SNORM] = _mesa_texstore_signed_rgba_16; + table[MESA_FORMAT_XBGR16161616_FLOAT] = _mesa_texstore_rgba_float16; + table[MESA_FORMAT_XBGR16161616_UINT] = _mesa_texstore_rgba_uint16; + table[MESA_FORMAT_XBGR16161616_SINT] = _mesa_texstore_rgba_int16; + table[MESA_FORMAT_XBGR32323232_FLOAT] = _mesa_texstore_rgba_float32; + table[MESA_FORMAT_XBGR32323232_UINT] = _mesa_texstore_rgba_uint32; + table[MESA_FORMAT_XBGR32323232_SINT] = _mesa_texstore_rgba_int32; + initialized = GL_TRUE; } diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c index a3c2091c48a..5e1a9f78324 100644 --- a/src/mesa/swrast/s_texfetch.c +++ b/src/mesa/swrast/s_texfetch.c @@ -1189,6 +1189,96 @@ texfetch_funcs[] = NULL, NULL }, + { + MESA_FORMAT_XRGB4444_UNORM, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XRGB1555_UNORM, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR8888_SNORM, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR8888_SRGB, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR8888_UINT, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR8888_SINT, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XRGB2101010_UNORM, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR16161616_UNORM, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR16161616_SNORM, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR16161616_FLOAT, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR16161616_UINT, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR16161616_SINT, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR32323232_FLOAT, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR32323232_UINT, + NULL, + NULL, + NULL + }, + { + MESA_FORMAT_XBGR32323232_SINT, + NULL, + NULL, + NULL + }, }; |