[Mesa-dev] [PATCH] etnaviv: Fix point sprite issue on HALTI0

Lucas Stach l.stach at pengutronix.de
Wed Nov 15 18:47:54 UTC 2017


Hi Wladimir,

Am Mittwoch, den 15.11.2017, 18:03 +0100 schrieb Wladimir J. van der Laan:
> A recent commit (see below) fixed flat shading but at the same time
> broke the use of point sprites with multiple varyings. This resulted in
> particle systems rendering wrongly.
> 
> The reason for this is that it set VARYING_COMPONENT_USE_POINTCOORD_[XY]
> for all non-color varyings, causing them to be replaced with the point
> coordinate when rendering points.
> 
> VARYING_COMPONENT_USE_POINTCOORD_[XY] is a misnomer, it should be
> TEXCOORD. Its semantics are: texture coordinates will get replaced with
> the point coordinate when rendering GL_POINTS, for other primitives
> their interpolation is independent of the shading model.
> 
> So use VARYING_COMPONENT_USE_POINTCOORD_[XY] only for texture coordinates.
> This causes them to be interpolated correctly while flat shading, while
> generic varyings are left as-is when rendering point sprites.

Sorry for noticing before, but this breaks glmark2 texture. I didn't
yet dig into the issue but it's definitely caused by this commit.

To reproduce, simply run
glmark2-es2-drm -b texture:texture-filter=mipmap

Regards,
Lucas

> Fixes: cedab87e762aa38997a07bc8a2eb624aed584afd "etnaviv: fix varying interpolation"
> > Signed-off-by: Wladimir J. van der Laan <laanwj at gmail.com>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_compiler.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> index 3180646..6569979 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
> @@ -2561,7 +2561,11 @@ etna_link_shader(struct etna_shader_link_info *info,
>        const struct etna_shader_inout *fsio = &fs->infile.reg[idx];
>        const struct etna_shader_inout *vsio = etna_shader_vs_lookup(vs, fsio);
>        struct etna_varying *varying;
> -      bool interpolate_always = fsio->semantic.Name != TGSI_SEMANTIC_COLOR;
> +      /* Texture coordinates will get replaced with the point coordinate when
> +       * rendering GL_POINTS, for other primitives their interpolation is
> +       * independent of the shading model. */
> +      bool is_texcoord = fsio->semantic.Name == TGSI_SEMANTIC_TEXCOORD ||
> +                         fsio->semantic.Name == TGSI_SEMANTIC_PCOORD;
>  
>        assert(fsio->reg > 0 && fsio->reg <= ARRAY_SIZE(info->varyings));
>  
> @@ -2571,13 +2575,14 @@ etna_link_shader(struct etna_shader_link_info *info,
>        varying = &info->varyings[fsio->reg - 1];
>        varying->num_components = fsio->num_components;
>  
> -      if (!interpolate_always) /* colors affected by flat shading */
> +      /* PA_ATTRIBUTES appears to be unused on HALTI0 and up */
> +      if (!is_texcoord) /* colors affected by flat shading */
>           varying->pa_attributes = 0x200;
>        else /* texture coord or other bypasses flat shading */
>           varying->pa_attributes = 0x2f1;
>  
> -      varying->use[0] = interpolate_always ? VARYING_COMPONENT_USE_POINTCOORD_X : VARYING_COMPONENT_USE_USED;
> -      varying->use[1] = interpolate_always ? VARYING_COMPONENT_USE_POINTCOORD_Y : VARYING_COMPONENT_USE_USED;
> +      varying->use[0] = is_texcoord ? VARYING_COMPONENT_USE_POINTCOORD_X : VARYING_COMPONENT_USE_USED;
> +      varying->use[1] = is_texcoord ? VARYING_COMPONENT_USE_POINTCOORD_Y : VARYING_COMPONENT_USE_USED;
>        varying->use[2] = VARYING_COMPONENT_USE_USED;
>        varying->use[3] = VARYING_COMPONENT_USE_USED;
>  


More information about the mesa-dev mailing list