[Mesa-dev] [PATCH] st/mesa: honour sized internal formats in st_choose_format

Nicolai Hähnle nicolai at montle.net
Mon Mar 14 22:11:01 UTC 2016


On 14.03.2016 16:23, Marek Olšák wrote:
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Thanks.

> Do we need to fix GL_SRGB8_ALPHA8 as well?

Not sure about ARB_texture_view. For ARB_shader_image_load_store, the 
spec has a table with an exhaustive list of supported formats, and none 
of them are SRGB.

> Do we need to update st_extensions.c to check that all formats with
> the RGBA order are supported before enabling ARB_texture_view or
> ARB_shader_image_load_store?

The corresponding pipe caps aren't used for anything else, so I'd say we 
should just rely on the driver only enabling those caps when RGBA order 
is supported as required.

Cheers,
Nicolai

>
> Marek
>
> On Mon, Mar 14, 2016 at 9:42 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
>> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>>
>> The bitcasting which is possible with shader images (and texture views?)
>> requires that when the user specifies a sized internal format for a
>> texture, we really allocate that format. To this end:
>>
>> (1) find_exact_format should ignore sized internal formats and
>>
>> (2) some of the entries in the mapping table corresponding to sized
>>      internal formats are reordered to use an RGBA format instead of
>>      a BGRA one.
>>
>> This fixes arb_shader_image_load_store-bitcast in the (work in progress)
>> ARB_shader_image_load_store implementation for radeonsi.
>> ---
>>   src/mesa/state_tracker/st_format.c | 31 ++++++++-----------------------
>>   1 file changed, 8 insertions(+), 23 deletions(-)
>>
>> diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
>> index 5392c23..2fe0222 100644
>> --- a/src/mesa/state_tracker/st_format.c
>> +++ b/src/mesa/state_tracker/st_format.c
>> @@ -1109,17 +1109,17 @@ static const struct format_mapping format_map[] = {
>>      /* Basic RGB, RGBA formats */
>>      {
>>         { GL_RGB10, 0 },
>> -      { PIPE_FORMAT_B10G10R10X2_UNORM, PIPE_FORMAT_B10G10R10A2_UNORM,
>> -        PIPE_FORMAT_R10G10B10A2_UNORM, DEFAULT_RGB_FORMATS }
>> +      { PIPE_FORMAT_R10G10B10A2_UNORM, PIPE_FORMAT_B10G10R10X2_UNORM,
>> +        PIPE_FORMAT_B10G10R10A2_UNORM, DEFAULT_RGB_FORMATS }
>>      },
>>      {
>>         { GL_RGB10_A2, 0 },
>> -      { PIPE_FORMAT_B10G10R10A2_UNORM, PIPE_FORMAT_R10G10B10A2_UNORM,
>> +      { PIPE_FORMAT_R10G10B10A2_UNORM, PIPE_FORMAT_B10G10R10A2_UNORM,
>>           DEFAULT_RGBA_FORMATS }
>>      },
>>      {
>>         { 4, GL_RGBA, GL_RGBA8, 0 },
>> -      { DEFAULT_RGBA_FORMATS }
>> +      { PIPE_FORMAT_R8G8B8A8_UNORM, DEFAULT_RGBA_FORMATS }
>>      },
>>      {
>>         { GL_BGRA, 0 },
>> @@ -1127,7 +1127,7 @@ static const struct format_mapping format_map[] = {
>>      },
>>      {
>>         { 3, GL_RGB, GL_RGB8, 0 },
>> -      { DEFAULT_RGB_FORMATS }
>> +      { PIPE_FORMAT_R8G8B8X8_UNORM, DEFAULT_RGB_FORMATS }
>>      },
>>      {
>>         { GL_RGB12, GL_RGB16, 0 },
>> @@ -2022,20 +2022,10 @@ static const struct exact_format_mapping rgbx8888_tbl[] =
>>      { 0,           0,                              0                          }
>>   };
>>
>> -static const struct exact_format_mapping rgba1010102_tbl[] =
>> -{
>> -   { GL_BGRA,     GL_UNSIGNED_INT_2_10_10_10_REV, PIPE_FORMAT_B10G10R10A2_UNORM },
>> -   /* No Mesa formats for these Gallium formats:
>> -   { GL_RGBA,     GL_UNSIGNED_INT_2_10_10_10_REV, PIPE_FORMAT_R10G10B10A2_UNORM },
>> -   { GL_ABGR_EXT, GL_UNSIGNED_INT_10_10_10_2,     PIPE_FORMAT_R10G10B10A2_UNORM },
>> -   { GL_ABGR_EXT, GL_UNSIGNED_INT,                PIPE_FORMAT_R10G10B10A2_UNORM },
>> -   */
>> -   { 0,           0,                              0                             }
>> -};
>> -
>>   /**
>> - * If there is an exact pipe_format match for {internalFormat, format, type}
>> - * return that, otherwise return PIPE_FORMAT_NONE so we can do fuzzy matching.
>> + * For unsized/base internal formats, we may choose a convenient effective
>> + * internal format for {format, type}. If one exists, return that, otherwise
>> + * return PIPE_FORMAT_NONE.
>>    */
>>   static enum pipe_format
>>   find_exact_format(GLint internalFormat, GLenum format, GLenum type)
>> @@ -2049,17 +2039,12 @@ find_exact_format(GLint internalFormat, GLenum format, GLenum type)
>>      switch (internalFormat) {
>>      case 4:
>>      case GL_RGBA:
>> -   case GL_RGBA8:
>>         tbl = rgba8888_tbl;
>>         break;
>>      case 3:
>>      case GL_RGB:
>> -   case GL_RGB8:
>>         tbl = rgbx8888_tbl;
>>         break;
>> -   case GL_RGB10_A2:
>> -      tbl = rgba1010102_tbl;
>> -      break;
>>      default:
>>         return PIPE_FORMAT_NONE;
>>      }
>> --
>> 2.5.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list