[Mesa-dev] [PATCH 04/22] gallium: add util_format_stencil helper function

Marek Olšák maraeo at gmail.com
Tue Jul 10 07:00:54 PDT 2012


On Tue, Jul 10, 2012 at 8:29 AM, Jose Fonseca <jfonseca at vmware.com> wrote:
> "util_format_stencil" seems a too generic. Some sort of qualifier would be more future proof, e.g., util_format_stencil_only.

Alright, consider it done. (without re-sending the patches)

Marek

>
> ----- Original Message -----
>> used for stencil sampler views.
>> ---
>>  src/gallium/auxiliary/util/u_format.h     |   29
>>  +++++++++++++++++++++++++++++
>>  src/mesa/state_tracker/st_cb_drawpixels.c |   23
>>  ++---------------------
>>  2 files changed, 31 insertions(+), 21 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/util/u_format.h
>> b/src/gallium/auxiliary/util/u_format.h
>> index e35e164..7995b57 100644
>> --- a/src/gallium/auxiliary/util/u_format.h
>> +++ b/src/gallium/auxiliary/util/u_format.h
>> @@ -882,6 +882,35 @@ util_format_linear(enum pipe_format format)
>>  }
>>
>>  /**
>> + * Given a depth-stencil format, return the corresponding
>> stencil-only format.
>> + * For stencil-only formats, return the format unchanged.
>> + */
>> +static INLINE enum pipe_format
>> +util_format_stencil(enum pipe_format format)
>> +{
>> +   switch (format) {
>> +   /* mask out the depth component */
>> +   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
>> +      return PIPE_FORMAT_X24S8_UINT;
>> +   case PIPE_FORMAT_S8_UINT_Z24_UNORM:
>> +      return PIPE_FORMAT_S8X24_UINT;
>> +   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
>> +      return PIPE_FORMAT_X32_S8X24_UINT;
>> +
>> +   /* stencil only formats */
>> +   case PIPE_FORMAT_X24S8_UINT:
>> +   case PIPE_FORMAT_S8X24_UINT:
>> +   case PIPE_FORMAT_X32_S8X24_UINT:
>> +   case PIPE_FORMAT_S8_UINT:
>> +      return format;
>> +
>> +   default:
>> +      assert(0);
>> +      return PIPE_FORMAT_NONE;
>> +   }
>> +}
>> +
>> +/**
>>   * Return the number of components stored.
>>   * Formats with block size != 1x1 will always have 1 component (the
>>   block).
>>   */
>> diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c
>> b/src/mesa/state_tracker/st_cb_drawpixels.c
>> index 2bcbada..727273b 100644
>> --- a/src/mesa/state_tracker/st_cb_drawpixels.c
>> +++ b/src/mesa/state_tracker/st_cb_drawpixels.c
>> @@ -1165,27 +1165,8 @@ st_DrawPixels(struct gl_context *ctx, GLint x,
>> GLint y,
>>               * The stencil is written using the shader stencil
>>               export
>>               * functionality. */
>>              if (write_stencil) {
>> -               enum pipe_format stencil_format = PIPE_FORMAT_NONE;
>> -
>> -               switch (pt->format) {
>> -               case PIPE_FORMAT_Z24_UNORM_S8_UINT:
>> -               case PIPE_FORMAT_X24S8_UINT:
>> -                  stencil_format = PIPE_FORMAT_X24S8_UINT;
>> -                  break;
>> -               case PIPE_FORMAT_S8_UINT_Z24_UNORM:
>> -               case PIPE_FORMAT_S8X24_UINT:
>> -                  stencil_format = PIPE_FORMAT_S8X24_UINT;
>> -                  break;
>> -               case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
>> -               case PIPE_FORMAT_X32_S8X24_UINT:
>> -                  stencil_format = PIPE_FORMAT_X32_S8X24_UINT;
>> -                  break;
>> -               case PIPE_FORMAT_S8_UINT:
>> -                  stencil_format = PIPE_FORMAT_S8_UINT;
>> -                  break;
>> -               default:
>> -                  assert(0);
>> -               }
>> +               enum pipe_format stencil_format =
>> +                     util_format_stencil(pt->format);
>>
>>                 sv[1] =
>>                 st_create_texture_sampler_view_format(st->pipe, pt,
>>                                                               stencil_format);
>> --
>> 1.7.9.5
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>


More information about the mesa-dev mailing list