[Mesa-dev] [PATCH] st/mesa: replace _mesa_sysval_to_semantic table with function

Brian Paul brianp at vmware.com
Mon Apr 11 22:33:04 UTC 2016


On 04/11/2016 04:30 PM, Brian Paul wrote:
> Instead of using an array indexed by SYSTEM_VALUE_x, just use a
> switch statement.  This fixes a regression caused by inserting new
> SYSTEM_VALUE_ enums but not updating the mapping to TGSI semantics.
> ---
>   src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 132 ++++++++++++++---------------
>   src/mesa/state_tracker/st_glsl_to_tgsi.h   |   3 +-
>   src/mesa/state_tracker/st_mesa_to_tgsi.c   |   2 +-
>   3 files changed, 69 insertions(+), 68 deletions(-)
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index b9ab7ae..e6df51f 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -5192,43 +5192,72 @@ struct st_translate {
>   };
>
>   /** Map Mesa's SYSTEM_VALUE_x to TGSI_SEMANTIC_x */
> -const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
> -   /* Vertex shader
> -    */
> -   TGSI_SEMANTIC_VERTEXID,
> -   TGSI_SEMANTIC_INSTANCEID,
> -   TGSI_SEMANTIC_VERTEXID_NOBASE,
> -   TGSI_SEMANTIC_BASEVERTEX,
> -   TGSI_SEMANTIC_BASEINSTANCE,
> -   TGSI_SEMANTIC_DRAWID,
> -
> -   /* Geometry shader
> -    */
> -   TGSI_SEMANTIC_INVOCATIONID,
> -
> -   /* Fragment shader
> -    */
> -   TGSI_SEMANTIC_POSITION,
> -   TGSI_SEMANTIC_FACE,
> -   TGSI_SEMANTIC_SAMPLEID,
> -   TGSI_SEMANTIC_SAMPLEPOS,
> -   TGSI_SEMANTIC_SAMPLEMASK,
> -   TGSI_SEMANTIC_HELPER_INVOCATION,
> -
> -   /* Tessellation shaders
> -    */
> -   TGSI_SEMANTIC_TESSCOORD,
> -   TGSI_SEMANTIC_VERTICESIN,
> -   TGSI_SEMANTIC_PRIMID,
> -   TGSI_SEMANTIC_TESSOUTER,
> -   TGSI_SEMANTIC_TESSINNER,
> +unsigned
> +_mesa_sysval_to_semantic(unsigned sysval)
> +{
> +   switch (sysval) {
> +   /* Vertex shader */
> +   case SYSTEM_VALUE_VERTEX_ID:
> +      return TGSI_SEMANTIC_VERTEXID;
> +   case SYSTEM_VALUE_INSTANCE_ID:
> +      return TGSI_SEMANTIC_INSTANCEID;
> +   case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE:
> +      return TGSI_SEMANTIC_VERTEXID_NOBASE;
> +   case SYSTEM_VALUE_BASE_VERTEX:
> +      return TGSI_SEMANTIC_BASEVERTEX;
> +   case SYSTEM_VALUE_BASE_INSTANCE:
> +      return TGSI_SEMANTIC_BASEINSTANCE;
> +   case SYSTEM_VALUE_DRAW_ID:
> +      return TGSI_SEMANTIC_DRAWID;
> +
> +   /* Geometry shader */
> +   case SYSTEM_VALUE_INVOCATION_ID:
> +      return TGSI_SEMANTIC_INVOCATIONID;
> +
> +   /* Fragment shader */
> +   case SYSTEM_VALUE_FRAG_COORD:
> +      return TGSI_SEMANTIC_POSITION;
> +   case SYSTEM_VALUE_FRONT_FACE:
> +      return TGSI_SEMANTIC_FACE;
> +   case SYSTEM_VALUE_SAMPLE_ID:
> +      return TGSI_SEMANTIC_SAMPLEID;
> +   case SYSTEM_VALUE_SAMPLE_POS:
> +      return TGSI_SEMANTIC_SAMPLEPOS;
> +   case SYSTEM_VALUE_SAMPLE_MASK_IN:
> +      return TGSI_SEMANTIC_SAMPLEMASK;
> +   case SYSTEM_VALUE_HELPER_INVOCATION:
> +      return TGSI_SEMANTIC_HELPER_INVOCATION;
> +
> +   /* Tessellation shader */
> +   case SYSTEM_VALUE_TESS_COORD:
> +      return TGSI_SEMANTIC_TESSCOORD;
> +   case SYSTEM_VALUE_VERTICES_IN:
> +      return TGSI_SEMANTIC_VERTICESIN;
> +   case SYSTEM_VALUE_PRIMITIVE_ID:
> +      return TGSI_SEMANTIC_PRIMID;
> +   case SYSTEM_VALUE_TESS_LEVEL_OUTER:
> +      return TGSI_SEMANTIC_TESSOUTER;
> +   case SYSTEM_VALUE_TESS_LEVEL_INNER:
> +      return TGSI_SEMANTIC_TESSINNER;
> +
> +   /* Compute shader */
> +   case SYSTEM_VALUE_GLOBAL_INVOCATION_ID:
> +   case SYSTEM_VALUE_WORK_GROUP_ID:
> +      return TGSI_SEMANTIC_THREAD_ID;
> +   case SYSTEM_VALUE_NUM_WORK_GROUPS:
> +      return TGSI_SEMANTIC_BLOCK_ID;
> +   case SYSTEM_VALUE_VERTEX_CNT:
> +      return TGSI_SEMANTIC_GRID_SIZE;

Disregard this.  I see I have a few mistakes.

-Brian




More information about the mesa-dev mailing list