[virglrenderer-devel] [PATCH] renderer: swizzle sampler border color channel if we emulate alpha format

Elie Tournier tournier.elie at gmail.com
Tue Jul 17 10:36:09 UTC 2018


On Mon, Jul 16, 2018 at 11:56:45AM +0200, Erik Faye-Lund wrote:
> On 11. juli 2018 18:06, Elie Tournier wrote:
> > Fixes:
> > dEQP-GLES31.functional.texture.border_clamp.formats.alpha.nearest_size_pot
> > dEQP-GLES31.functional.texture.border_clamp.formats.alpha.nearest_size_npot
> > dEQP-GLES31.functional.texture.border_clamp.formats.alpha.linear_size_pot
> > dEQP-GLES31.functional.texture.border_clamp.formats.alpha.linear_size_npot
> > dEQP-GLES31.functional.texture.border_clamp.unused_channels.alpha
> > 
> > Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
> > ---
> >   src/vrend_renderer.c | 12 ++++++++++++
> >   1 file changed, 12 insertions(+)
> > 
> > diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> > index cc99087..f32e8fd 100644
> > --- a/src/vrend_renderer.c
> > +++ b/src/vrend_renderer.c
> > @@ -4173,7 +4173,19 @@ static void vrend_apply_sampler_state(struct vrend_context *ctx,
> >         return;
> >      }
> > +   /*
> > +    * If we emulate alpha format with red, we need to tell
> > +    * the sampler to use the red channel and not the alpha one
> > +    * by swizzling the GL_TEXTURE_BORDER_COLOR parameter.
> > +    */
> >      if (vrend_state.have_samplers) {
> > +      if (vrend_format_is_emulated_alpha(res->base.format)) {
> > +         union pipe_color_union border_color;
> > +         border_color = vstate->base.border_color;
> > +         border_color.ui[0] = border_color.ui[3];
> > +         border_color.ui[3] = 0;
> > +         glSamplerParameterIuiv(vstate->id, GL_TEXTURE_BORDER_COLOR, border_color.ui);
> > +      }
> >         glBindSampler(sampler_id, vstate->id);
> >         glSamplerParameteri(vstate->id, GL_TEXTURE_SRGB_DECODE_EXT,
> >                             srgb_decode);
> 
> I suspect that the glTexParameterIuiv-variant also needs a similar fix...
> something along these lines?

The code looks good to me. But we are suppose to hit this path when we call
vrend_apply_sampler_state without having a sampler. Not sure it's happen once.
I will run the non regression tests tonight.
> 
> ---8<---
> diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> index e5015a6..3202ba6 100644
> --- a/src/vrend_renderer.c
> +++ b/src/vrend_renderer.c
> @@ -4605,8 +4605,18 @@ static void vrend_apply_sampler_state(struct
> vrend_context *ctx,
>        }
>     }
> 
> -   if (memcmp(&tex->state.border_color, &state->border_color, 16) ||
> set_all)
> -      glTexParameterIuiv(target, GL_TEXTURE_BORDER_COLOR,
> state->border_color.ui);
> +   bool is_emulated_alpha =
> vrend_format_is_emulated_alpha(res->base.format);
> +   if (memcmp(&tex->state.border_color, &state->border_color, 16) ||
> set_all ||
> +       is_emulated_alpha) {
> +      if (is_emulated_alpha) {
> +         union pipe_color_union border_color;
> +         border_color = vstate->base.border_color;
> +         border_color.ui[0] = border_color.ui[3];
> +         border_color.ui[3] = 0;
> +         glTexParameterIuiv(target, GL_TEXTURE_BORDER_COLOR,
> border_color.ui);
> +      } else
> +         glTexParameterIuiv(target, GL_TEXTURE_BORDER_COLOR,
> state->border_color.ui);
> +   }
>     tex->state = *state;
>  }
> 
> ---8<---


More information about the virglrenderer-devel mailing list