summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2012-01-19 09:41:30 -0700
committerJakob Bornecrantz <jakob@vmware.com>2012-06-27 20:00:43 +0200
commitcbeacf1b486ad8c918f6f6013bb09cea861450b7 (patch)
treeb6a6decba98ab81a3fd64fcb588fdc86ee677f6d
parentb0ef00cd4c9f22c781e6af03260173b06a4c75ec (diff)
st/mesa: add fallback pipe formats for (compressed) R, RG formats
If we don't find an exact PIPE_FORMAT_x for a GL_(COMPRESSED)_RED/RG format, try uncompressed formats. We were already doing this for the RGB(A) formats. Fixes piglit arb_texture_compression-internal-format-query test. NOTE: This is a candidate for the stable branches. Reviewed-by: José Fonseca <jfonseca@vmware.com> (cherry picked from commit 75f37ddba7e5a297390299be0dab8377ea40f5c8)
-rw-r--r--src/mesa/state_tracker/st_format.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index c6e31753580..2fdbcd773ea 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -739,6 +739,15 @@ struct format_mapping
PIPE_FORMAT_S8_UINT_Z24_UNORM, \
0
+#define DEFAULT_SNORM8_RGBA_FORMATS \
+ PIPE_FORMAT_R8G8B8A8_SNORM, \
+ 0
+
+#define DEFAULT_UNORM16_RGBA_FORMATS \
+ PIPE_FORMAT_R16G16B16A16_UNORM, \
+ DEFAULT_RGBA_FORMATS
+
+
/**
* This table maps OpenGL texture format enums to Gallium pipe_format enums.
* Multiple GL enums might map to multiple pipe_formats.
@@ -1045,54 +1054,55 @@ static const struct format_mapping format_map[] = {
/* R, RG formats */
{
{ GL_RED, GL_R8, 0 },
- { PIPE_FORMAT_R8_UNORM, 0 }
+ { PIPE_FORMAT_R8_UNORM, PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_RG, GL_RG8, 0 },
- { PIPE_FORMAT_R8G8_UNORM, 0 }
+ { PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_R16, 0 },
- { PIPE_FORMAT_R16_UNORM, 0 }
+ { PIPE_FORMAT_R16_UNORM, PIPE_FORMAT_R16G16_UNORM,
+ DEFAULT_UNORM16_RGBA_FORMATS }
},
{
{ GL_RG16, 0 },
- { PIPE_FORMAT_R16G16_UNORM, 0 }
+ { PIPE_FORMAT_R16G16_UNORM, DEFAULT_UNORM16_RGBA_FORMATS }
},
/* compressed R, RG formats */
{
{ GL_COMPRESSED_RED, GL_COMPRESSED_RED_RGTC1, 0 },
- { PIPE_FORMAT_RGTC1_UNORM, PIPE_FORMAT_R8_UNORM, 0 }
+ { PIPE_FORMAT_RGTC1_UNORM, PIPE_FORMAT_R8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_SIGNED_RED_RGTC1, 0 },
- { PIPE_FORMAT_RGTC1_SNORM, 0 }
+ { PIPE_FORMAT_RGTC1_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_RG, GL_COMPRESSED_RG_RGTC2, 0 },
- { PIPE_FORMAT_RGTC2_UNORM, PIPE_FORMAT_R8G8_UNORM, 0 }
+ { PIPE_FORMAT_RGTC2_UNORM, PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_SIGNED_RG_RGTC2, 0 },
- { PIPE_FORMAT_RGTC2_SNORM, 0 }
+ { PIPE_FORMAT_RGTC2_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_LUMINANCE, GL_COMPRESSED_LUMINANCE_LATC1_EXT, 0 },
- { PIPE_FORMAT_LATC1_UNORM, PIPE_FORMAT_L8_UNORM, 0 }
+ { PIPE_FORMAT_LATC1_UNORM, PIPE_FORMAT_L8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT, 0 },
- { PIPE_FORMAT_LATC1_SNORM, 0 }
+ { PIPE_FORMAT_LATC1_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_LUMINANCE_ALPHA, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT,
GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, 0 },
- { PIPE_FORMAT_LATC2_UNORM, PIPE_FORMAT_L8A8_UNORM, 0 }
+ { PIPE_FORMAT_LATC2_UNORM, PIPE_FORMAT_L8A8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT, 0 },
- { PIPE_FORMAT_LATC2_SNORM, 0 }
+ { PIPE_FORMAT_LATC2_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
},
/* ETC1 */