[Mesa-dev] [PATCH 4/4] st/glsl_to_tgsi: use tgsi_get_gl_varying_semantic() for gs/tes outputs

Nicolai Hähnle nhaehnle at gmail.com
Tue Nov 14 16:29:08 UTC 2017


For the series:

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>


On 13.11.2017 02:56, Timothy Arceri wrote:
> ---
>   src/mesa/state_tracker/st_program.c | 96 ++-----------------------------------
>   1 file changed, 5 insertions(+), 91 deletions(-)
> 
> diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
> index 3bc15bccc0..6b3da028c5 100644
> --- a/src/mesa/state_tracker/st_program.c
> +++ b/src/mesa/state_tracker/st_program.c
> @@ -1343,111 +1343,25 @@ st_translate_program_common(struct st_context *st,
>      /*
>       * Determine number of outputs, the (default) output register
>       * mapping and the semantic information for each output.
>       */
>      for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
>         if (prog->info.outputs_written & BITFIELD64_BIT(attr)) {
>            GLuint slot = num_outputs++;
>   
>            outputMapping[attr] = slot;
>   
> -         switch (attr) {
> -         case VARYING_SLOT_POS:
> -            assert(slot == 0);
> -            output_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_COL0:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_COL1:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
> -            output_semantic_index[slot] = 1;
> -            break;
> -         case VARYING_SLOT_BFC0:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_BFC1:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_BCOLOR;
> -            output_semantic_index[slot] = 1;
> -            break;
> -         case VARYING_SLOT_FOGC:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_FOG;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_PSIZ:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_CLIP_VERTEX:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_CLIP_DIST0:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_CLIP_DIST1:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
> -            output_semantic_index[slot] = 1;
> -            break;
> -         case VARYING_SLOT_CULL_DIST0:
> -         case VARYING_SLOT_CULL_DIST1:
> -            /* these should have been lowered by GLSL */
> -            assert(0);
> -            break;
> -         case VARYING_SLOT_LAYER:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_LAYER;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_PRIMITIVE_ID:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_PRIMID;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_VIEWPORT:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_VIEWPORT_INDEX;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_TESS_LEVEL_OUTER:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_TESSOUTER;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_TESS_LEVEL_INNER:
> -            output_semantic_name[slot] = TGSI_SEMANTIC_TESSINNER;
> -            output_semantic_index[slot] = 0;
> -            break;
> -         case VARYING_SLOT_TEX0:
> -         case VARYING_SLOT_TEX1:
> -         case VARYING_SLOT_TEX2:
> -         case VARYING_SLOT_TEX3:
> -         case VARYING_SLOT_TEX4:
> -         case VARYING_SLOT_TEX5:
> -         case VARYING_SLOT_TEX6:
> -         case VARYING_SLOT_TEX7:
> -            if (st->needs_texcoord_semantic) {
> -               output_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD;
> -               output_semantic_index[slot] = attr - VARYING_SLOT_TEX0;
> -               break;
> -            }
> -            /* fall through */
> -         case VARYING_SLOT_VAR0:
> -         default:
> -            assert(slot < ARRAY_SIZE(output_semantic_name));
> -            assert(attr >= VARYING_SLOT_VAR0 ||
> -                   (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7));
> -            output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
> -            output_semantic_index[slot] =
> -               st_get_generic_varying_index(st, attr);
> -            break;
> -         }
> +         unsigned semantic_name, semantic_index;
> +         tgsi_get_gl_varying_semantic(attr, st->needs_texcoord_semantic,
> +                                      &semantic_name, &semantic_index);
> +         output_semantic_name[slot] = semantic_name;
> +         output_semantic_index[slot] = semantic_index;
>         }
>      }
>   
>      /* Also add patch outputs. */
>      for (attr = 0; attr < 32; attr++) {
>         if (prog->info.patch_outputs_written & (1u << attr)) {
>            GLuint slot = num_outputs++;
>            GLuint patch_attr = VARYING_SLOT_PATCH0 + attr;
>   
>            outputMapping[patch_attr] = slot;
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list