From: Brian Paul Date: Thu, 19 Jan 2012 16:41:30 +0000 (-0700) Subject: st/mesa: add fallback pipe formats for (compressed) R, RG formats X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75f37ddba7e5a297390299be0dab8377ea40f5c8;p=mesa.git 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 --- diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 5f9ae91298f..620910ddb88 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -839,6 +839,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. @@ -1145,54 +1154,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 */