radeonsi: make si_shader_io_get_unique_index stricter
authorMarek Olšák <marek.olsak@amd.com>
Sun, 13 Nov 2016 18:54:13 +0000 (19:54 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 21 Nov 2016 20:44:35 +0000 (21:44 +0100)
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_state_shaders.c

index a80d9c375b04ce394eebd9d151727dbc8b602d44..8b5645930841e82dfa1cc39d428a725a07b0a43a 100644 (file)
@@ -123,11 +123,9 @@ unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index)
        case TGSI_SEMANTIC_GENERIC:
                if (index <= 63-4)
                        return 4 + index;
-               else
-                       /* same explanation as in the default statement,
-                        * the only user hitting this is st/nine.
-                        */
-                       return 0;
+
+               assert(!"invalid generic index");
+               return 0;
 
        /* patch indices are completely separate and thus start from 0 */
        case TGSI_SEMANTIC_TESSOUTER:
@@ -138,11 +136,7 @@ unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index)
                return 2 + index;
 
        default:
-               /* Don't fail here. The result of this function is only used
-                * for LS, TCS, TES, and GS, where legacy GL semantics can't
-                * occur, but this function is called for all vertex shaders
-                * before it's known whether LS will be compiled or not.
-                */
+               assert(!"invalid semantic name");
                return 0;
        }
 }
index 1d116f6b00b49615ebfc293396c3b540cbd70916..d10084dfe4e7f57c8c972ea929e78bb999a113e5 100644 (file)
@@ -1425,9 +1425,18 @@ static void *si_create_shader_selector(struct pipe_context *ctx,
                                sel->patch_outputs_written |=
                                        1llu << si_shader_io_get_unique_index(name, index);
                                break;
-                       default:
+
+                       case TGSI_SEMANTIC_GENERIC:
+                               /* don't process indices the function can't handle */
+                               if (index >= 60)
+                                       break;
+                               /* fall through */
+                       case TGSI_SEMANTIC_POSITION:
+                       case TGSI_SEMANTIC_PSIZE:
+                       case TGSI_SEMANTIC_CLIPDIST:
                                sel->outputs_written |=
                                        1llu << si_shader_io_get_unique_index(name, index);
+                               break;
                        }
                }
                sel->esgs_itemsize = util_last_bit64(sel->outputs_written) * 16;