[Mesa-dev] [PATCH 04/16] i965/hsw: Adjust uploading default color for stencil surfaces

Kenneth Graunke kenneth at whitecape.org
Thu Aug 25 00:54:23 UTC 2016


On Wednesday, August 24, 2016 5:49:53 PM PDT Ian Romanick wrote:
> On 08/24/2016 05:46 PM, Matt Turner wrote:
> > On Wed, Aug 24, 2016 at 4:54 PM, Jordan Justen
> > <jordan.l.justen at intel.com> wrote:
> >> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> >> ---
> >>  src/mesa/drivers/dri/i965/brw_sampler_state.c | 8 ++++++--
> >>  1 file changed, 6 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/src/mesa/drivers/dri/i965/brw_sampler_state.c b/src/mesa/drivers/dri/i965/brw_sampler_state.c
> >> index 9f56c81..8ad34b8 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_sampler_state.c
> >> +++ b/src/mesa/drivers/dri/i965/brw_sampler_state.c
> >> @@ -281,7 +281,10 @@ upload_default_color(struct brw_context *brw,
> >>        memset(sdc, 0, 20 * 4);
> >>        sdc = &sdc[16];
> >>
> >> -      int bits_per_channel = _mesa_get_format_bits(format, GL_RED_BITS);
> >> +      int bits_per_channel =
> >> +         _mesa_get_format_bits(format,
> >> +                               format == MESA_FORMAT_S_UINT8 ?
> >> +                               GL_STENCIL_BITS : GL_RED_BITS);
> >>
> >>        /* From the Haswell PRM, "Command Reference: Structures", Page 36:
> >>         * "If any color channel is missing from the surface format,
> >> @@ -290,8 +293,9 @@ upload_default_color(struct brw_context *brw,
> >>         *  be programmed as 1."
> >>         */
> >>        unsigned c[4] = { 0, 0, 0, 1 };
> >> +      bool is_color = _mesa_is_format_color_format(format);
> >>        for (int i = 0; i < 4; i++) {
> >> -         if (_mesa_format_has_color_component(format, i))
> >> +         if (is_color ? _mesa_format_has_color_component(format, i) : i == 0)
> > 
> > This line kinda makes my head hurt. Not sure what to suggest.
> 
> Yeah... I wasn't sure that (is_color &&
> _mesa_format_has_color_component(format, i)) || (!is_color && i == 0)
> was actually better.

How about

static bool
has_component(mesa_format format, int i)
{
   if (_mesa_is_format_color_format(format)
      return _mesa_format_has_color_component(format, i);

   /* depth and stencil have only one component */
   return i == 0;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160824/17f7abad/attachment.sig>


More information about the mesa-dev mailing list