diff options
author | marha <marha@users.sourceforge.net> | 2013-02-07 10:17:56 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-02-07 10:17:56 +0100 |
commit | 956c20498738c242726b5a42ed28db8572a90bed (patch) | |
tree | bf663b89417d0d9d7b37575eb0260d5a10af0e12 /mesalib/src/mesa | |
parent | 76c527be60066b647468ad66f8e4d7dd18fa1769 (diff) | |
download | vcxsrv-956c20498738c242726b5a42ed28db8572a90bed.tar.gz vcxsrv-956c20498738c242726b5a42ed28db8572a90bed.tar.bz2 vcxsrv-956c20498738c242726b5a42ed28db8572a90bed.zip |
mesa fontconfig git update 7 Feb 2013
fontconfig commit 96220a5ed9d1d761b14a7ac516ac6786c132f280
mesa commit 9ba1e23647c09290c98cc7133fb73dd1df1da8ab
Diffstat (limited to 'mesalib/src/mesa')
20 files changed, 1199 insertions, 201 deletions
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c index 051fb40b9..1a14b98b7 100644 --- a/mesalib/src/mesa/main/format_pack.c +++ b/mesalib/src/mesa/main/format_pack.c @@ -934,10 +934,10 @@ pack_float_R16(const GLfloat src[4], void *dst) } -/* MESA_FORMAT_RG1616 */ +/* MESA_FORMAT_GR1616 */ static void -pack_ubyte_RG1616(const GLubyte src[4], void *dst) +pack_ubyte_GR1616(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r = UBYTE_TO_USHORT(src[RCOMP]); @@ -946,7 +946,7 @@ pack_ubyte_RG1616(const GLubyte src[4], void *dst) } static void -pack_float_RG1616(const GLfloat src[4], void *dst) +pack_float_GR1616(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r, g; @@ -956,10 +956,10 @@ pack_float_RG1616(const GLfloat src[4], void *dst) } -/* MESA_FORMAT_RG1616_REV */ +/* MESA_FORMAT_RG1616 */ static void -pack_ubyte_RG1616_REV(const GLubyte src[4], void *dst) +pack_ubyte_RG1616(const GLubyte src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r = UBYTE_TO_USHORT(src[RCOMP]); @@ -969,7 +969,7 @@ pack_ubyte_RG1616_REV(const GLubyte src[4], void *dst) static void -pack_float_RG1616_REV(const GLfloat src[4], void *dst) +pack_float_RG1616(const GLfloat src[4], void *dst) { GLuint *d = ((GLuint *) dst); GLushort r, g; @@ -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. @@ -1719,8 +1873,8 @@ _mesa_get_pack_ubyte_rgba_function(gl_format format) table[MESA_FORMAT_GR88] = pack_ubyte_GR88; table[MESA_FORMAT_RG88] = pack_ubyte_RG88; table[MESA_FORMAT_R16] = pack_ubyte_R16; + table[MESA_FORMAT_GR1616] = pack_ubyte_GR1616; table[MESA_FORMAT_RG1616] = pack_ubyte_RG1616; - table[MESA_FORMAT_RG1616_REV] = pack_ubyte_RG1616_REV; table[MESA_FORMAT_ARGB2101010] = pack_ubyte_ARGB2101010; table[MESA_FORMAT_ABGR2101010_UINT] = pack_ubyte_ABGR2101010_UINT; @@ -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; } @@ -1865,8 +2035,8 @@ _mesa_get_pack_float_rgba_function(gl_format format) table[MESA_FORMAT_GR88] = pack_float_GR88; table[MESA_FORMAT_RG88] = pack_float_RG88; table[MESA_FORMAT_R16] = pack_float_R16; + table[MESA_FORMAT_GR1616] = pack_float_GR1616; table[MESA_FORMAT_RG1616] = pack_float_RG1616; - table[MESA_FORMAT_RG1616_REV] = pack_float_RG1616_REV; table[MESA_FORMAT_ARGB2101010] = pack_float_ARGB2101010; table[MESA_FORMAT_ABGR2101010_UINT] = pack_float_ABGR2101010_UINT; @@ -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/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c index 92ce86908..0933b4e87 100644 --- a/mesalib/src/mesa/main/format_unpack.c +++ b/mesalib/src/mesa/main/format_unpack.c @@ -570,7 +570,7 @@ unpack_R16(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RG1616(const void *src, GLfloat dst[][4], GLuint n) +unpack_GR1616(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -583,7 +583,7 @@ unpack_RG1616(const void *src, GLfloat dst[][4], GLuint n) } static void -unpack_RG1616_REV(const void *src, GLfloat dst[][4], GLuint n) +unpack_RG1616(const void *src, GLfloat dst[][4], GLuint n) { const GLuint *s = ((const GLuint *) src); GLuint i; @@ -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. @@ -1572,8 +1767,8 @@ get_unpack_rgba_function(gl_format format) table[MESA_FORMAT_GR88] = unpack_GR88; table[MESA_FORMAT_RG88] = unpack_RG88; table[MESA_FORMAT_R16] = unpack_R16; + table[MESA_FORMAT_GR1616] = unpack_GR1616; table[MESA_FORMAT_RG1616] = unpack_RG1616; - table[MESA_FORMAT_RG1616_REV] = unpack_RG1616_REV; table[MESA_FORMAT_ARGB2101010] = unpack_ARGB2101010; table[MESA_FORMAT_ABGR2101010_UINT] = unpack_ABGR2101010_UINT; table[MESA_FORMAT_Z24_S8] = unpack_Z24_S8; @@ -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/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c index 1c9e63377..176067d53 100644 --- a/mesalib/src/mesa/main/formats.c +++ b/mesalib/src/mesa/main/formats.c @@ -404,8 +404,8 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 1, 1, 2 }, { - MESA_FORMAT_RG1616, - "MESA_FORMAT_RG1616", + MESA_FORMAT_GR1616, + "MESA_FORMAT_GR1616", GL_RG, GL_UNSIGNED_NORMALIZED, 16, 16, 0, 0, @@ -413,8 +413,8 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] = 1, 1, 4 }, { - MESA_FORMAT_RG1616_REV, - "MESA_FORMAT_RG1616_REV", + MESA_FORMAT_RG1616, + "MESA_FORMAT_RG1616", GL_RG, GL_UNSIGNED_NORMALIZED, 16, 16, 0, 0, @@ -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; } @@ -1953,7 +2092,7 @@ _mesa_get_uncompressed_format(gl_format format) return MESA_FORMAT_R16; case MESA_FORMAT_ETC2_RG11_EAC: case MESA_FORMAT_ETC2_SIGNED_RG11_EAC: - return MESA_FORMAT_RG1616; + return MESA_FORMAT_GR1616; default: #ifdef DEBUG assert(!_mesa_is_format_compressed(format)); @@ -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; @@ -2234,8 +2375,8 @@ _mesa_format_to_type_and_comps(gl_format format, case MESA_FORMAT_AL1616: case MESA_FORMAT_AL1616_REV: + case MESA_FORMAT_GR1616: case MESA_FORMAT_RG1616: - case MESA_FORMAT_RG1616_REV: *datatype = GL_UNSIGNED_SHORT; *comps = 2; 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; @@ -2839,10 +3029,10 @@ _mesa_format_matches_format_and_type(gl_format gl_format, case MESA_FORMAT_R16: return format == GL_RED && type == GL_UNSIGNED_SHORT && littleEndian && !swapBytes; - case MESA_FORMAT_RG1616: + case MESA_FORMAT_GR1616: return format == GL_RG && type == GL_UNSIGNED_SHORT && littleEndian && !swapBytes; - case MESA_FORMAT_RG1616_REV: + case MESA_FORMAT_RG1616: return GL_FALSE; case MESA_FORMAT_ARGB2101010: @@ -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/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h index 050fce96c..2961ffa9f 100644 --- a/mesalib/src/mesa/main/formats.h +++ b/mesalib/src/mesa/main/formats.h @@ -102,8 +102,8 @@ typedef enum MESA_FORMAT_GR88, /* GGGG GGGG RRRR RRRR */ MESA_FORMAT_RG88, /* RRRR RRRR GGGG GGGG */ MESA_FORMAT_R16, /* RRRR RRRR RRRR RRRR */ - MESA_FORMAT_RG1616, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ - MESA_FORMAT_RG1616_REV, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ + MESA_FORMAT_GR1616, /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */ + MESA_FORMAT_RG1616, /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */ MESA_FORMAT_ARGB2101010, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */ MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */ MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */ @@ -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/mesalib/src/mesa/main/renderbuffer.h b/mesalib/src/mesa/main/renderbuffer.h index 5495ae150..c450b33cb 100644 --- a/mesalib/src/mesa/main/renderbuffer.h +++ b/mesalib/src/mesa/main/renderbuffer.h @@ -29,6 +29,10 @@ #include "glheader.h" #include "mtypes.h" +#ifdef __cplusplus +extern "C" { +#endif + struct gl_context; struct gl_framebuffer; struct gl_renderbuffer; @@ -62,6 +66,8 @@ _mesa_reference_renderbuffer(struct gl_renderbuffer **ptr, _mesa_reference_renderbuffer_(ptr, rb); } - +#ifdef __cplusplus +} +#endif #endif /* RENDERBUFFER_H */ diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c index 75b1021d4..6f22a4f5f 100644 --- a/mesalib/src/mesa/main/texformat.c +++ b/mesalib/src/mesa/main/texformat.c @@ -812,7 +812,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, break; case GL_RG16: - RETURN_IF_SUPPORTED(MESA_FORMAT_RG1616); + RETURN_IF_SUPPORTED(MESA_FORMAT_GR1616); break; default: diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index ff3c92c5e..9283ece8a 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -3917,7 +3917,7 @@ get_texbuffer_format(const struct gl_context *ctx, GLenum internalFormat) case GL_RG8: return MESA_FORMAT_GR88; case GL_RG16: - return MESA_FORMAT_RG1616; + return MESA_FORMAT_GR1616; case GL_RG16F: return MESA_FORMAT_RG_FLOAT16; case GL_RG32F: diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index a5c7712e0..6e7ce237f 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/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]); @@ -1915,8 +1914,8 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS) ASSERT(dstFormat == MESA_FORMAT_AL1616 || dstFormat == MESA_FORMAT_AL1616_REV || - dstFormat == MESA_FORMAT_RG1616 || - dstFormat == MESA_FORMAT_RG1616_REV); + dstFormat == MESA_FORMAT_GR1616 || + dstFormat == MESA_FORMAT_RG1616); ASSERT(_mesa_get_format_bytes(dstFormat) == 4); if (!ctx->_ImageTransferState && @@ -1924,7 +1923,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS) ((dstFormat == MESA_FORMAT_AL1616 && baseInternalFormat == GL_LUMINANCE_ALPHA && srcFormat == GL_LUMINANCE_ALPHA) || - (dstFormat == MESA_FORMAT_RG1616 && + (dstFormat == MESA_FORMAT_GR1616 && baseInternalFormat == srcFormat)) && srcType == GL_UNSIGNED_SHORT && littleEndian) { @@ -1953,7 +1952,7 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS) for (row = 0; row < srcHeight; row++) { GLuint *dstUI = (GLuint *) dstRow; if (dstFormat == MESA_FORMAT_AL1616 || - dstFormat == MESA_FORMAT_RG1616) { + dstFormat == MESA_FORMAT_GR1616) { for (col = 0; col < srcWidth; col++) { GLushort l, a; @@ -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, @@ -4051,8 +4150,8 @@ _mesa_get_texstore_func(gl_format format) table[MESA_FORMAT_GR88] = _mesa_texstore_unorm88; table[MESA_FORMAT_RG88] = _mesa_texstore_unorm88; table[MESA_FORMAT_R16] = _mesa_texstore_unorm16; + table[MESA_FORMAT_GR1616] = _mesa_texstore_unorm1616; table[MESA_FORMAT_RG1616] = _mesa_texstore_unorm1616; - table[MESA_FORMAT_RG1616_REV] = _mesa_texstore_unorm1616; table[MESA_FORMAT_ARGB2101010] = _mesa_texstore_argb2101010; table[MESA_FORMAT_Z24_S8] = _mesa_texstore_z24_s8; table[MESA_FORMAT_S8_Z24] = _mesa_texstore_s8_z24; @@ -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/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 26d1923b5..ba4f17a3d 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -492,7 +492,7 @@ make_texture(struct st_context *st, /* Choose a pixel format for the temp texture which will hold the * image to draw. */ - pipeFormat = st_choose_format(pipe->screen, intFormat, format, type, + pipeFormat = st_choose_format(st, intFormat, format, type, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, FALSE); assert(pipeFormat != PIPE_FORMAT_NONE); @@ -1499,7 +1499,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, else { /* srcFormat can't be used as a texture format */ if (type == GL_DEPTH) { - texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT, + texFormat = st_choose_format(st, GL_DEPTH_COMPONENT, GL_NONE, GL_NONE, st->internal_target, sample_count, PIPE_BIND_DEPTH_STENCIL, FALSE); @@ -1507,7 +1507,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, } else { /* default color format */ - texFormat = st_choose_format(screen, GL_RGBA, + texFormat = st_choose_format(st, GL_RGBA, GL_NONE, GL_NONE, st->internal_target, sample_count, PIPE_BIND_SAMPLER_VIEW, FALSE); diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c index d042ebabf..72bc960b0 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c @@ -63,7 +63,7 @@ st_renderbuffer_alloc_sw_storage(struct gl_context * ctx, GLenum internalFormat, GLuint width, GLuint height) { - struct pipe_screen *screen = st_context(ctx)->pipe->screen; + struct st_context *st = st_context(ctx); struct st_renderbuffer *strb = st_renderbuffer(rb); enum pipe_format format; size_t size; @@ -80,7 +80,7 @@ st_renderbuffer_alloc_sw_storage(struct gl_context * ctx, format = PIPE_FORMAT_R16G16B16A16_SNORM; } else { - format = st_choose_renderbuffer_format(screen, internalFormat, 0); + format = st_choose_renderbuffer_format(st, internalFormat, 0); /* Not setting gl_renderbuffer::Format here will cause * FRAMEBUFFER_UNSUPPORTED and ValidateFramebuffer will not be called. @@ -153,7 +153,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, unsigned i; for (i = rb->NumSamples; i <= ctx->Const.MaxSamples; i++) { - format = st_choose_renderbuffer_format(screen, internalFormat, i); + format = st_choose_renderbuffer_format(st, internalFormat, i); if (format != PIPE_FORMAT_NONE) { rb->NumSamples = i; @@ -161,7 +161,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, } } } else { - format = st_choose_renderbuffer_format(screen, internalFormat, 0); + format = st_choose_renderbuffer_format(st, internalFormat, 0); } /* Not setting gl_renderbuffer::Format here will cause diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 80a440d18..ab5ff27b3 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -596,7 +596,7 @@ decompress_with_blit(struct gl_context * ctx, pipe_target = gl_target_to_pipe(gl_target); /* Find the best match for the format+type combo. */ - pipe_format = st_choose_format(pipe->screen, GL_RGBA8, format, type, + pipe_format = st_choose_format(st, GL_RGBA8, format, type, pipe_target, 0, bind, FALSE); if (pipe_format == PIPE_FORMAT_NONE) { /* unable to get an rgba format!?! */ diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index b416319e1..676fc069d 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -182,6 +182,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, st->has_stencil_export = screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT); + st->has_shader_model3 = screen->get_param(screen, PIPE_CAP_SM3); /* GL limits and extensions */ st_init_limits(st); diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h index 70ee671d0..726c64d04 100644 --- a/mesalib/src/mesa/state_tracker/st_context.h +++ b/mesalib/src/mesa/state_tracker/st_context.h @@ -84,6 +84,7 @@ struct st_context GLboolean clamp_vert_color_in_shader; boolean has_stencil_export; /**< can do shader stencil export? */ boolean has_time_elapsed; + boolean has_shader_model3; /* On old libGL's for linux we need to invalidate the drawables * on glViewpport calls, this is set via a option. diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 214588f1f..4d2d43d7e 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -597,6 +597,7 @@ void st_init_extensions(struct st_context *st) /* Extensions that either depend on GLSL 1.30 or are a subset thereof. */ ctx->Extensions.ARB_conservative_depth = GL_TRUE; ctx->Extensions.ARB_shader_bit_encoding = GL_TRUE; + ctx->Extensions.ARB_shading_language_packing = GL_TRUE; ctx->Extensions.OES_depth_texture_cube_map = GL_TRUE; } else { /* Optional integer support for GLSL 1.2. */ diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 2169bed89..5b6e74d50 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -184,7 +184,7 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) return PIPE_FORMAT_R16_UNORM; case MESA_FORMAT_GR88: return PIPE_FORMAT_R8G8_UNORM; - case MESA_FORMAT_RG1616: + case MESA_FORMAT_GR1616: return PIPE_FORMAT_R16G16_UNORM; case MESA_FORMAT_RGBA_16: return PIPE_FORMAT_R16G16B16A16_UNORM; @@ -357,6 +357,38 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) return PIPE_FORMAT_R11G11B10_FLOAT; case MESA_FORMAT_ARGB2101010_UINT: return PIPE_FORMAT_B10G10R10A2_UINT; + + case MESA_FORMAT_XRGB4444_UNORM: + return PIPE_FORMAT_B4G4R4X4_UNORM; + case MESA_FORMAT_XRGB1555_UNORM: + return PIPE_FORMAT_B5G5R5X1_UNORM; + case MESA_FORMAT_XBGR8888_SNORM: + return PIPE_FORMAT_R8G8B8X8_SNORM; + case MESA_FORMAT_XBGR8888_SRGB: + return PIPE_FORMAT_R8G8B8X8_SRGB; + case MESA_FORMAT_XBGR8888_UINT: + return PIPE_FORMAT_R8G8B8X8_UINT; + case MESA_FORMAT_XBGR8888_SINT: + return PIPE_FORMAT_R8G8B8X8_SINT; + case MESA_FORMAT_XRGB2101010_UNORM: + return PIPE_FORMAT_B10G10R10X2_UNORM; + case MESA_FORMAT_XBGR16161616_UNORM: + return PIPE_FORMAT_R16G16B16X16_UNORM; + case MESA_FORMAT_XBGR16161616_SNORM: + return PIPE_FORMAT_R16G16B16X16_SNORM; + case MESA_FORMAT_XBGR16161616_FLOAT: + return PIPE_FORMAT_R16G16B16X16_FLOAT; + case MESA_FORMAT_XBGR16161616_UINT: + return PIPE_FORMAT_R16G16B16X16_UINT; + case MESA_FORMAT_XBGR16161616_SINT: + return PIPE_FORMAT_R16G16B16X16_SINT; + case MESA_FORMAT_XBGR32323232_FLOAT: + return PIPE_FORMAT_R32G32B32X32_FLOAT; + case MESA_FORMAT_XBGR32323232_UINT: + return PIPE_FORMAT_R32G32B32X32_UINT; + case MESA_FORMAT_XBGR32323232_SINT: + return PIPE_FORMAT_R32G32B32X32_SINT; + default: assert(0); return PIPE_FORMAT_NONE; @@ -509,7 +541,7 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_R8G8_UNORM: return MESA_FORMAT_GR88; case PIPE_FORMAT_R16G16_UNORM: - return MESA_FORMAT_RG1616; + return MESA_FORMAT_GR1616; case PIPE_FORMAT_A8_UINT: return MESA_FORMAT_ALPHA_UINT8; @@ -679,6 +711,38 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_B10G10R10A2_UINT: return MESA_FORMAT_ARGB2101010_UINT; + + case PIPE_FORMAT_B4G4R4X4_UNORM: + return MESA_FORMAT_XRGB4444_UNORM; + case PIPE_FORMAT_B5G5R5X1_UNORM: + return MESA_FORMAT_XRGB1555_UNORM; + case PIPE_FORMAT_R8G8B8X8_SNORM: + return MESA_FORMAT_XBGR8888_SNORM; + case PIPE_FORMAT_R8G8B8X8_SRGB: + return MESA_FORMAT_XBGR8888_SRGB; + case PIPE_FORMAT_R8G8B8X8_UINT: + return MESA_FORMAT_XBGR8888_UINT; + case PIPE_FORMAT_R8G8B8X8_SINT: + return MESA_FORMAT_XBGR8888_SINT; + case PIPE_FORMAT_B10G10R10X2_UNORM: + return MESA_FORMAT_XRGB2101010_UNORM; + case PIPE_FORMAT_R16G16B16X16_UNORM: + return MESA_FORMAT_XBGR16161616_UNORM; + case PIPE_FORMAT_R16G16B16X16_SNORM: + return MESA_FORMAT_XBGR16161616_SNORM; + case PIPE_FORMAT_R16G16B16X16_FLOAT: + return MESA_FORMAT_XBGR16161616_FLOAT; + case PIPE_FORMAT_R16G16B16X16_UINT: + return MESA_FORMAT_XBGR16161616_UINT; + case PIPE_FORMAT_R16G16B16X16_SINT: + return MESA_FORMAT_XBGR16161616_SINT; + case PIPE_FORMAT_R32G32B32X32_FLOAT: + return MESA_FORMAT_XBGR32323232_FLOAT; + case PIPE_FORMAT_R32G32B32X32_UINT: + return MESA_FORMAT_XBGR32323232_UINT; + case PIPE_FORMAT_R32G32B32X32_SINT: + return MESA_FORMAT_XBGR32323232_SINT; + default: assert(0); return MESA_FORMAT_NONE; @@ -692,26 +756,24 @@ st_pipe_format_to_mesa_format(enum pipe_format format) struct format_mapping { GLenum glFormats[18]; /**< list of GLenum formats, 0-terminated */ - enum pipe_format pipeFormats[10]; /**< list of pipe formats, 0-terminated */ + enum pipe_format pipeFormats[13]; /**< list of pipe formats, 0-terminated */ }; #define DEFAULT_RGBA_FORMATS \ PIPE_FORMAT_B8G8R8A8_UNORM, \ + PIPE_FORMAT_R8G8B8A8_UNORM, \ PIPE_FORMAT_A8R8G8B8_UNORM, \ PIPE_FORMAT_A8B8G8R8_UNORM, \ - PIPE_FORMAT_B5G6R5_UNORM, \ 0 #define DEFAULT_RGB_FORMATS \ PIPE_FORMAT_B8G8R8X8_UNORM, \ + PIPE_FORMAT_R8G8B8X8_UNORM, \ PIPE_FORMAT_X8R8G8B8_UNORM, \ PIPE_FORMAT_X8B8G8R8_UNORM, \ - PIPE_FORMAT_B8G8R8A8_UNORM, \ - PIPE_FORMAT_A8R8G8B8_UNORM, \ - PIPE_FORMAT_A8B8G8R8_UNORM, \ PIPE_FORMAT_B5G6R5_UNORM, \ - 0 + DEFAULT_RGBA_FORMATS #define DEFAULT_SRGBA_FORMATS \ PIPE_FORMAT_B8G8R8A8_SRGB, \ @@ -744,7 +806,12 @@ struct format_mapping static const struct format_mapping format_map[] = { /* Basic RGB, RGBA formats */ { - { GL_RGB10, GL_RGB10_A2, 0 }, + { GL_RGB10, 0 }, + { PIPE_FORMAT_B10G10R10X2_UNORM, PIPE_FORMAT_B10G10R10A2_UNORM, + DEFAULT_RGB_FORMATS } + }, + { + { GL_RGB10_A2, 0 }, { PIPE_FORMAT_B10G10R10A2_UNORM, DEFAULT_RGBA_FORMATS } }, { @@ -760,7 +827,12 @@ static const struct format_mapping format_map[] = { { DEFAULT_RGB_FORMATS } }, { - { GL_RGB12, GL_RGB16, GL_RGBA12, GL_RGBA16, 0 }, + { GL_RGB12, GL_RGB16, 0 }, + { PIPE_FORMAT_R16G16B16X16_UNORM, PIPE_FORMAT_R16G16B16A16_UNORM, + DEFAULT_RGB_FORMATS } + }, + { + { GL_RGBA12, GL_RGBA16, 0 }, { PIPE_FORMAT_R16G16B16A16_UNORM, DEFAULT_RGBA_FORMATS } }, { @@ -774,16 +846,21 @@ static const struct format_mapping format_map[] = { { { GL_R3_G3_B2, 0 }, { PIPE_FORMAT_B2G3R3_UNORM, PIPE_FORMAT_B5G6R5_UNORM, - PIPE_FORMAT_B5G5R5A1_UNORM, DEFAULT_RGBA_FORMATS } + PIPE_FORMAT_B5G5R5A1_UNORM, DEFAULT_RGB_FORMATS } }, { - { GL_RGB5, GL_RGB4 }, - { PIPE_FORMAT_B5G6R5_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM, - DEFAULT_RGBA_FORMATS } + { GL_RGB4 }, + { PIPE_FORMAT_B4G4R4X4_UNORM, PIPE_FORMAT_B4G4R4A4_UNORM, + DEFAULT_RGB_FORMATS } + }, + { + { GL_RGB5 }, + { PIPE_FORMAT_B5G5R5X1_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM, + DEFAULT_RGB_FORMATS } }, { { GL_RGB565 }, - { PIPE_FORMAT_B5G6R5_UNORM, DEFAULT_RGBA_FORMATS } + { PIPE_FORMAT_B5G6R5_UNORM, DEFAULT_RGB_FORMATS } }, /* basic Alpha formats */ @@ -923,12 +1000,17 @@ static const struct format_mapping format_map[] = { /* sRGB formats */ { - { GL_SRGB_EXT, GL_SRGB8_EXT, GL_SRGB_ALPHA_EXT, GL_SRGB8_ALPHA8_EXT, 0 }, + { GL_SRGB_EXT, GL_SRGB8_EXT, 0 }, + { PIPE_FORMAT_R8G8B8X8_SRGB, DEFAULT_SRGBA_FORMATS } + }, + { + { GL_SRGB_ALPHA_EXT, GL_SRGB8_ALPHA8_EXT, 0 }, { DEFAULT_SRGBA_FORMATS } }, { { GL_COMPRESSED_SRGB_EXT, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, 0 }, - { PIPE_FORMAT_DXT1_SRGB, DEFAULT_SRGBA_FORMATS } + { PIPE_FORMAT_DXT1_SRGB, PIPE_FORMAT_R8G8B8X8_SRGB, + DEFAULT_SRGBA_FORMATS } }, { { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0 }, @@ -945,11 +1027,12 @@ static const struct format_mapping format_map[] = { }, { { GL_SLUMINANCE_ALPHA_EXT, GL_SLUMINANCE8_ALPHA8_EXT, - GL_COMPRESSED_SLUMINANCE_EXT, GL_COMPRESSED_SLUMINANCE_ALPHA_EXT, 0 }, + GL_COMPRESSED_SLUMINANCE_ALPHA_EXT, 0 }, { PIPE_FORMAT_L8A8_SRGB, DEFAULT_SRGBA_FORMATS } }, { - { GL_SLUMINANCE_EXT, GL_SLUMINANCE8_EXT, 0 }, + { GL_SLUMINANCE_EXT, GL_SLUMINANCE8_EXT, GL_COMPRESSED_SLUMINANCE_EXT, + 0 }, { PIPE_FORMAT_L8_SRGB, DEFAULT_SRGBA_FORMATS } }, @@ -960,7 +1043,8 @@ static const struct format_mapping format_map[] = { }, { { GL_RGB16F_ARB, 0 }, - { PIPE_FORMAT_R16G16B16_FLOAT, PIPE_FORMAT_R16G16B16A16_FLOAT, + { PIPE_FORMAT_R16G16B16_FLOAT, PIPE_FORMAT_R16G16B16X16_FLOAT, + PIPE_FORMAT_R16G16B16A16_FLOAT, PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT, 0 } }, { @@ -1005,8 +1089,8 @@ static const struct format_mapping format_map[] = { }, { { GL_RGB32F_ARB, 0 }, - { PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT, - PIPE_FORMAT_R16G16B16A16_FLOAT, 0 } + { PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32X32_FLOAT, + PIPE_FORMAT_R32G32B32A32_FLOAT, PIPE_FORMAT_R16G16B16A16_FLOAT, 0 } }, { { GL_LUMINANCE_ALPHA32F_ARB, 0 }, @@ -1106,10 +1190,7 @@ static const struct format_mapping format_map[] = { /* signed/unsigned integer formats. */ { - { GL_RED_INTEGER_EXT, - GL_GREEN_INTEGER_EXT, - GL_BLUE_INTEGER_EXT, - GL_RGBA_INTEGER_EXT, + { GL_RGBA_INTEGER_EXT, GL_BGRA_INTEGER_EXT, GL_RGBA8I_EXT, 0 }, { PIPE_FORMAT_R8G8B8A8_SINT, 0 } @@ -1117,8 +1198,9 @@ static const struct format_mapping format_map[] = { { { GL_RGB_INTEGER_EXT, GL_BGR_INTEGER_EXT, - GL_RGB8I_EXT, 0 }, - { PIPE_FORMAT_R8G8B8_SINT, + GL_RGB8I_EXT, + GL_BLUE_INTEGER_EXT, 0 }, + { PIPE_FORMAT_R8G8B8_SINT, PIPE_FORMAT_R8G8B8X8_SINT, PIPE_FORMAT_R8G8B8A8_SINT, 0 } }, { @@ -1222,7 +1304,7 @@ static const struct format_mapping format_map[] = { }, { { GL_RGB16I_EXT, 0 }, - { PIPE_FORMAT_R16G16B16_SINT, + { PIPE_FORMAT_R16G16B16_SINT, PIPE_FORMAT_R16G16B16X16_SINT, PIPE_FORMAT_R16G16B16A16_SINT, 0 }, }, { @@ -1231,7 +1313,7 @@ static const struct format_mapping format_map[] = { }, { { GL_RGB32I_EXT, 0 }, - { PIPE_FORMAT_R32G32B32_SINT, + { PIPE_FORMAT_R32G32B32_SINT, PIPE_FORMAT_R32G32B32X32_SINT, PIPE_FORMAT_R32G32B32A32_SINT, 0 }, }, { @@ -1244,12 +1326,12 @@ static const struct format_mapping format_map[] = { }, { { GL_RGB8UI_EXT, 0 }, - { PIPE_FORMAT_R8G8B8_UINT, + { PIPE_FORMAT_R8G8B8_UINT, PIPE_FORMAT_R8G8B8X8_UINT, PIPE_FORMAT_R8G8B8A8_UINT, 0 } }, { { GL_RGB16UI_EXT, 0 }, - { PIPE_FORMAT_R16G16B16_UINT, + { PIPE_FORMAT_R16G16B16_UINT, PIPE_FORMAT_R16G16B16X16_UINT, PIPE_FORMAT_R16G16B16A16_UINT, 0 } }, { @@ -1258,7 +1340,7 @@ static const struct format_mapping format_map[] = { }, { { GL_RGB32UI_EXT, 0}, - { PIPE_FORMAT_R32G32B32_UINT, + { PIPE_FORMAT_R32G32B32_UINT, PIPE_FORMAT_R32G32B32X32_UINT, PIPE_FORMAT_R32G32B32A32_UINT, 0 } }, { @@ -1266,7 +1348,7 @@ static const struct format_mapping format_map[] = { { PIPE_FORMAT_R32G32B32A32_UINT, 0 } }, { - { GL_R8I, 0}, + { GL_R8I, GL_RED_INTEGER_EXT, 0}, { PIPE_FORMAT_R8_SINT, 0}, }, { @@ -1290,7 +1372,7 @@ static const struct format_mapping format_map[] = { { PIPE_FORMAT_R32_UINT, 0}, }, { - { GL_RG8I, 0}, + { GL_RG8I, GL_GREEN_INTEGER_EXT, 0}, { PIPE_FORMAT_R8G8_SINT, 0}, }, { @@ -1338,11 +1420,20 @@ static const struct format_mapping format_map[] = { PIPE_FORMAT_R8G8_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 } }, { - { GL_RGB_SNORM, GL_RGB8_SNORM, GL_RGBA_SNORM, GL_RGBA8_SNORM, 0 }, + { GL_RGB_SNORM, GL_RGB8_SNORM, 0 }, + { PIPE_FORMAT_R8G8B8X8_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 } + }, + { + { GL_RGBA_SNORM, GL_RGBA8_SNORM, 0 }, { PIPE_FORMAT_R8G8B8A8_SNORM, 0 } }, { - { GL_RGB16_SNORM, GL_RGBA16_SNORM, 0 }, + { GL_RGB16_SNORM, 0 }, + { PIPE_FORMAT_R16G16B16X16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM, + PIPE_FORMAT_R8G8B8A8_SNORM, 0 } + }, + { + { GL_RGBA16_SNORM, 0 }, { PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 } }, { @@ -1449,14 +1540,12 @@ static const struct exact_format_mapping rgbx8888_tbl[] = { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_X8R8G8B8_UNORM }, { GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_B8G8R8X8_UNORM }, { GL_BGRA, GL_UNSIGNED_BYTE, PIPE_FORMAT_B8G8R8X8_UNORM }, - /* No Mesa formats for these Gallium formats: { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_X8B8G8R8_UNORM }, { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_X8B8G8R8_UNORM }, { GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, PIPE_FORMAT_R8G8B8X8_UNORM }, { GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, PIPE_FORMAT_R8G8B8X8_UNORM }, { GL_RGBA, GL_UNSIGNED_BYTE, PIPE_FORMAT_R8G8B8X8_UNORM }, { GL_ABGR_EXT, GL_UNSIGNED_BYTE, PIPE_FORMAT_X8B8G8R8_UNORM }, - */ { 0, 0, 0 } }; @@ -1527,17 +1616,17 @@ find_exact_format(GLint internalFormat, GLenum format, GLenum type) * when we're getting called from gl[Copy]TexImage(). */ enum pipe_format -st_choose_format(struct pipe_screen *screen, GLenum internalFormat, +st_choose_format(struct st_context *st, GLenum internalFormat, GLenum format, GLenum type, enum pipe_texture_target target, unsigned sample_count, unsigned bindings, boolean allow_dxt) { - GET_CURRENT_CONTEXT(ctx); /* XXX this should be a function parameter */ + struct pipe_screen *screen = st->pipe->screen; int i, j; enum pipe_format pf; /* can't render to compressed formats at this time */ - if (_mesa_is_compressed_format(ctx, internalFormat) + if (_mesa_is_compressed_format(st->ctx, internalFormat) && (bindings & ~PIPE_BIND_SAMPLER_VIEW)) { return PIPE_FORMAT_NONE; } @@ -1573,7 +1662,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, * Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces. */ enum pipe_format -st_choose_renderbuffer_format(struct pipe_screen *screen, +st_choose_renderbuffer_format(struct st_context *st, GLenum internalFormat, unsigned sample_count) { uint usage; @@ -1581,7 +1670,7 @@ st_choose_renderbuffer_format(struct pipe_screen *screen, usage = PIPE_BIND_DEPTH_STENCIL; else usage = PIPE_BIND_RENDER_TARGET; - return st_choose_format(screen, internalFormat, GL_NONE, GL_NONE, + return st_choose_format(st, internalFormat, GL_NONE, GL_NONE, PIPE_TEXTURE_2D, sample_count, usage, FALSE); } @@ -1599,7 +1688,7 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, internalFormat == GL_RGB || internalFormat == GL_RGBA || internalFormat == GL_RGB8 || internalFormat == GL_RGBA8 || internalFormat == GL_BGRA; - struct pipe_screen *screen = st_context(ctx)->pipe->screen; + struct st_context *st = st_context(ctx); enum pipe_format pFormat; unsigned bindings; @@ -1623,12 +1712,12 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, bindings |= PIPE_BIND_RENDER_TARGET; } - pFormat = st_choose_format(screen, internalFormat, format, type, + pFormat = st_choose_format(st, internalFormat, format, type, PIPE_TEXTURE_2D, 0, bindings, ctx->Mesa_DXTn); if (pFormat == PIPE_FORMAT_NONE) { /* try choosing format again, this time without render target bindings */ - pFormat = st_choose_format(screen, internalFormat, format, type, + pFormat = st_choose_format(st, internalFormat, format, type, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, ctx->Mesa_DXTn); } @@ -1649,7 +1738,7 @@ size_t st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat, int samples[16]) { - struct pipe_screen *screen = st_context(ctx)->pipe->screen; + struct st_context *st = st_context(ctx); enum pipe_format format; unsigned i, bind, num_sample_counts = 0; @@ -1660,7 +1749,7 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat, /* Set sample counts in descending order. */ for (i = 16; i > 1; i--) { - format = st_choose_format(screen, internalFormat, GL_NONE, GL_NONE, + format = st_choose_format(st, internalFormat, GL_NONE, GL_NONE, PIPE_TEXTURE_2D, i, bind, FALSE); if (format != PIPE_FORMAT_NONE) { diff --git a/mesalib/src/mesa/state_tracker/st_format.h b/mesalib/src/mesa/state_tracker/st_format.h index 50588d8d4..aee624d24 100644 --- a/mesalib/src/mesa/state_tracker/st_format.h +++ b/mesalib/src/mesa/state_tracker/st_format.h @@ -48,13 +48,13 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat); extern enum pipe_format -st_choose_format(struct pipe_screen *screen, GLenum internalFormat, +st_choose_format(struct st_context *st, GLenum internalFormat, GLenum format, GLenum type, enum pipe_texture_target target, unsigned sample_count, unsigned bindings, boolean allow_dxt); extern enum pipe_format -st_choose_renderbuffer_format(struct pipe_screen *screen, +st_choose_renderbuffer_format(struct st_context *st, GLenum internalFormat, unsigned sample_count); diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index b3da2016d..63b74285a 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1287,11 +1287,12 @@ glsl_to_tgsi_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operan bool glsl_to_tgsi_visitor::try_emit_sat(ir_expression *ir) { - /* Saturates were only introduced to vertex programs in - * NV_vertex_program3, so don't give them to drivers in the VP. + /* Emit saturates in the vertex shader only if SM 3.0 is supported. */ - if (this->prog->Target == GL_VERTEX_PROGRAM_ARB) + if (this->prog->Target == GL_VERTEX_PROGRAM_ARB && + !st_context(this->ctx)->has_shader_model3) { return false; + } ir_rvalue *sat_src = ir->as_rvalue_to_saturate(); if (!sat_src) @@ -2931,32 +2932,12 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir) void glsl_to_tgsi_visitor::visit(ir_if *ir) { - glsl_to_tgsi_instruction *cond_inst, *if_inst; - glsl_to_tgsi_instruction *prev_inst; - - prev_inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail(); + glsl_to_tgsi_instruction *if_inst; ir->condition->accept(this); assert(this->result.file != PROGRAM_UNDEFINED); - if (this->options->EmitCondCodes) { - cond_inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail(); - - /* See if we actually generated any instruction for generating - * the condition. If not, then cook up a move to a temp so we - * have something to set cond_update on. - */ - if (cond_inst == prev_inst) { - st_src_reg temp = get_temp(glsl_type::bool_type); - cond_inst = emit(ir->condition, TGSI_OPCODE_MOV, st_dst_reg(temp), result); - } - cond_inst->cond_update = GL_TRUE; - - if_inst = emit(ir->condition, TGSI_OPCODE_IF); - if_inst->dst.cond_mask = COND_NE; - } else { - if_inst = emit(ir->condition, TGSI_OPCODE_IF, undef_dst, this->result); - } + if_inst = emit(ir->condition, TGSI_OPCODE_IF, undef_dst, this->result); this->instructions.push_tail(if_inst); @@ -5175,21 +5156,52 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) const struct gl_shader_compiler_options *options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)]; - do { - unsigned what_to_lower = MOD_TO_FRACT | DIV_TO_MUL_RCP | - EXP_TO_EXP2 | LOG_TO_LOG2; - if (options->EmitNoPow) - what_to_lower |= POW_TO_EXP2; - if (!ctx->Const.NativeIntegers) - what_to_lower |= INT_DIV_TO_MUL_RCP; + /* If there are forms of indirect addressing that the driver + * cannot handle, perform the lowering pass. + */ + if (options->EmitNoIndirectInput || options->EmitNoIndirectOutput || + options->EmitNoIndirectTemp || options->EmitNoIndirectUniform) { + lower_variable_index_to_cond_assign(ir, + options->EmitNoIndirectInput, + options->EmitNoIndirectOutput, + options->EmitNoIndirectTemp, + options->EmitNoIndirectUniform); + } - progress = false; + if (ctx->Extensions.ARB_shading_language_packing) { + unsigned lower_inst = LOWER_PACK_SNORM_2x16 | + LOWER_UNPACK_SNORM_2x16 | + LOWER_PACK_UNORM_2x16 | + LOWER_UNPACK_UNORM_2x16 | + LOWER_PACK_SNORM_4x8 | + LOWER_UNPACK_SNORM_4x8 | + LOWER_UNPACK_UNORM_4x8 | + LOWER_PACK_UNORM_4x8 | + LOWER_PACK_HALF_2x16 | + LOWER_UNPACK_HALF_2x16; + + lower_packing_builtins(ir, lower_inst); + } - /* Lowering */ - do_mat_op_to_vec(ir); - lower_instructions(ir, what_to_lower); + do_mat_op_to_vec(ir); + lower_instructions(ir, + MOD_TO_FRACT | + DIV_TO_MUL_RCP | + EXP_TO_EXP2 | + LOG_TO_LOG2 | + (options->EmitNoPow ? POW_TO_EXP2 : 0) | + (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0)); + + lower_ubo_reference(prog->_LinkedShaders[i], ir); + do_vec_index_to_cond_assign(ir); + lower_quadop_vector(ir, false); + lower_noise(ir); + if (options->MaxIfDepth == 0) { + lower_discard(ir); + } - lower_ubo_reference(prog->_LinkedShaders[i], ir); + do { + progress = false; progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress; @@ -5197,31 +5209,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) options->MaxUnrollIterations) || progress; - progress = lower_quadop_vector(ir, false) || progress; - - if (options->MaxIfDepth == 0) - progress = lower_discard(ir) || progress; - progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress; - if (options->EmitNoNoise) - progress = lower_noise(ir) || progress; - - /* If there are forms of indirect addressing that the driver - * cannot handle, perform the lowering pass. - */ - if (options->EmitNoIndirectInput || options->EmitNoIndirectOutput - || options->EmitNoIndirectTemp || options->EmitNoIndirectUniform) - progress = - lower_variable_index_to_cond_assign(ir, - options->EmitNoIndirectInput, - options->EmitNoIndirectOutput, - options->EmitNoIndirectTemp, - options->EmitNoIndirectUniform) - || progress; - - progress = do_vec_index_to_cond_assign(ir) || progress; - } while (progress); validate_ir_tree(ir); diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index 584eaa981..ed3709848 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -391,13 +391,12 @@ struct pipe_resource * st_create_color_map_texture(struct gl_context *ctx) { struct st_context *st = st_context(ctx); - struct pipe_context *pipe = st->pipe; struct pipe_resource *pt; enum pipe_format format; const uint texSize = 256; /* simple, and usually perfect */ /* find an RGBA texture format */ - format = st_choose_format(pipe->screen, GL_RGBA, GL_NONE, GL_NONE, + format = st_choose_format(st, GL_RGBA, GL_NONE, GL_NONE, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, FALSE); diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c index 1f1964172..5e1a9f783 100644 --- a/mesalib/src/mesa/swrast/s_texfetch.c +++ b/mesalib/src/mesa/swrast/s_texfetch.c @@ -352,13 +352,13 @@ texfetch_funcs[] = fetch_texel_3d_f_r16 }, { - MESA_FORMAT_RG1616, + MESA_FORMAT_GR1616, fetch_texel_1d_f_rg1616, fetch_texel_2d_f_rg1616, fetch_texel_3d_f_rg1616 }, { - MESA_FORMAT_RG1616_REV, + MESA_FORMAT_RG1616, fetch_texel_1d_f_rg1616_rev, fetch_texel_2d_f_rg1616_rev, fetch_texel_3d_f_rg1616_rev @@ -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 + }, }; diff --git a/mesalib/src/mesa/swrast/s_texfetch_tmp.h b/mesalib/src/mesa/swrast/s_texfetch_tmp.h index b65d33f04..2de1f1a97 100644 --- a/mesalib/src/mesa/swrast/s_texfetch_tmp.h +++ b/mesalib/src/mesa/swrast/s_texfetch_tmp.h @@ -797,7 +797,7 @@ static void FETCH(f_al88_rev)( const struct swrast_texture_image *texImage, -/* MESA_FORMAT_RG1616 ********************************************************/ +/* MESA_FORMAT_GR1616 ********************************************************/ /* Fetch texel from 1D, 2D or 3D rg1616 texture, return 4 GLchans */ static void FETCH(f_rg1616)( const struct swrast_texture_image *texImage, @@ -813,7 +813,7 @@ static void FETCH(f_rg1616)( const struct swrast_texture_image *texImage, -/* MESA_FORMAT_RG1616_REV ****************************************************/ +/* MESA_FORMAT_RG1616 ****************************************************/ /* Fetch texel from 1D, 2D or 3D rg1616_rev texture, return 4 GLchans */ static void FETCH(f_rg1616_rev)( const struct swrast_texture_image *texImage, |