mesa,glsl,nir: reduce gl_state_index size to 2 bytes
authorMarek Olšák <marek.olsak@amd.com>
Thu, 16 Nov 2017 03:29:35 +0000 (04:29 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 13 Feb 2018 00:00:45 +0000 (01:00 +0100)
Let's use the new gl_state_index16 type everywhere and remove
the typecasts.

This helps reduce the size of gl_program_parameter.

Reviewed-by: Brian Paul <brianp@vmware.com>
27 files changed:
src/compiler/glsl/ir.h
src/compiler/glsl/serialize.cpp
src/compiler/glsl/standalone_scaffolding.cpp
src/compiler/glsl/standalone_scaffolding.h
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_drawpixels.c
src/compiler/shader_enums.h
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/drivers/dri/i965/brw_nir_uniforms.cpp
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/r200/r200_vertprog.c
src/mesa/main/ffvertex_prog.c
src/mesa/main/tests/program_state_string.cpp
src/mesa/main/uniforms.h
src/mesa/program/ir_to_mesa.cpp
src/mesa/program/prog_parameter.c
src/mesa/program/prog_parameter.h
src/mesa/program/prog_statevars.c
src/mesa/program/prog_statevars.h
src/mesa/program/program_parse.y
src/mesa/program/programopt.c
src/mesa/state_tracker/st_atifs_to_tgsi.c
src/mesa/state_tracker/st_glsl_to_nir.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp
src/mesa/state_tracker/st_mesa_to_tgsi.c
src/mesa/state_tracker/st_nir_lower_builtin.c
src/mesa/state_tracker/st_program.c

index d5a255eb8b405a4f2fefd597015b15276b89faf1..b849c938722c5e3b3fd86cda5328834c177b2f33 100644 (file)
@@ -397,7 +397,7 @@ depth_layout_string(ir_depth_layout layout);
  * \sa ir_variable::state_slots
  */
 struct ir_state_slot {
-   int tokens[5];
+   gl_state_index16 tokens[5];
    int swizzle;
 };
 
index 63ce41d87bdc2ba6f91060ea8973f92d191c00d9..9d2033bddfa8e6a159e1d1276e9ed48906a58e9c 100644 (file)
@@ -975,7 +975,7 @@ static void
 read_shader_parameters(struct blob_reader *metadata,
                        struct gl_program_parameter_list *params)
 {
-   gl_state_index state_indexes[STATE_LENGTH];
+   gl_state_index16 state_indexes[STATE_LENGTH];
    uint32_t i = 0;
    uint32_t num_parameters = blob_read_uint32(metadata);
 
index 34065a9fe10671864eb7c0d946839c8ea89a13f9..caaddc028f7624371ee1b1dbe7bbd636c49266ff 100644 (file)
@@ -100,13 +100,13 @@ _mesa_new_shader(GLuint name, gl_shader_stage stage)
 }
 
 GLbitfield
-_mesa_program_state_flags(UNUSED const gl_state_index state[STATE_LENGTH])
+_mesa_program_state_flags(UNUSED const gl_state_index16 state[STATE_LENGTH])
 {
    return 0;
 }
 
 char *
-_mesa_program_state_string(UNUSED const gl_state_index state[STATE_LENGTH])
+_mesa_program_state_string(UNUSED const gl_state_index16 state[STATE_LENGTH])
 {
    return NULL;
 }
index 7532d0836f728db24486c5e13f15ca9648c4681e..c8d90597ca0a1a6f115ffc7b8ffdad8ead9be1ef 100644 (file)
@@ -69,11 +69,11 @@ _mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id,
                    const char *msg);
 
 extern "C" GLbitfield
-_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]);
+_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);
 
 
 extern "C" char *
-_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
+_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
 
 static inline gl_shader_stage
 _mesa_shader_enum_to_shader_stage(GLenum v)
index 5ea8c9926b92374406abbe2980ea1a04ac707853..216cc8837fdc93b8ed58637b4a942860d60efae4 100644 (file)
@@ -89,7 +89,7 @@ struct nir_instr;
  * \sa nir_variable::state_slots
  */
 typedef struct {
-   int tokens[5];
+   gl_state_index16 tokens[5];
    int swizzle;
 } nir_state_slot;
 
@@ -2653,7 +2653,7 @@ void nir_lower_passthrough_edgeflags(nir_shader *shader);
 void nir_lower_tes_patch_vertices(nir_shader *tes, unsigned patch_vertices);
 
 typedef struct nir_lower_wpos_ytransform_options {
-   int state_tokens[5];
+   gl_state_index16 state_tokens[5];
    bool fs_coord_origin_upper_left :1;
    bool fs_coord_origin_lower_left :1;
    bool fs_coord_pixel_center_integer :1;
@@ -2665,9 +2665,9 @@ bool nir_lower_wpos_ytransform(nir_shader *shader,
 bool nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading);
 
 typedef struct nir_lower_drawpixels_options {
-   int texcoord_state_tokens[5];
-   int scale_state_tokens[5];
-   int bias_state_tokens[5];
+   gl_state_index16 texcoord_state_tokens[5];
+   gl_state_index16 scale_state_tokens[5];
+   gl_state_index16 bias_state_tokens[5];
    unsigned drawpix_sampler;
    unsigned pixelmap_sampler;
    bool pixel_maps :1;
index acec9443431be774195661f0175d41394d5d3ef8..4d43f423a49e4281a0d3d47a932372c5c383514b 100644 (file)
@@ -67,7 +67,8 @@ get_texcoord(lower_drawpixels_state *state)
 }
 
 static nir_variable *
-create_uniform(nir_shader *shader, const char *name, const int state_tokens[5])
+create_uniform(nir_shader *shader, const char *name,
+               const gl_state_index16 state_tokens[5])
 {
    nir_variable *var = nir_variable_create(shader,
                                            nir_var_uniform,
index fb78ad384cbc790da1123b951445919d22bc6721..d1e875bd189f02f8613a7fd80d2fe75d272e174d 100644 (file)
@@ -48,6 +48,8 @@ typedef enum
    MESA_SHADER_COMPUTE = 5,
 } gl_shader_stage;
 
+typedef short gl_state_index16; /* see enum gl_state_index */
+
 const char *gl_shader_stage_name(gl_shader_stage stage);
 
 /**
index fc35c006dcd1495638d10d07c10b86913c005c48..f0598f591ab1240fb0586b41367ba4a171ee2505 100644 (file)
@@ -319,8 +319,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
             assert(var->state_slots != NULL);
 
             for (unsigned int i = 0; i < var->num_state_slots; i++) {
-               _mesa_add_state_reference(prog->Parameters,
-                                         (gl_state_index *)slots[i].tokens);
+               _mesa_add_state_reference(prog->Parameters, slots[i].tokens);
             }
          }
       }
index 05f61674c3c158d3c609a3b3054a950b7d98aeac..9c4fb22a90513feb97c53ca29318308c60cd4b6d 100644 (file)
@@ -40,7 +40,7 @@ brw_nir_setup_glsl_builtin_uniform(nir_variable *var,
        * get the same index back here.
        */
       int index = _mesa_add_state_reference(prog->Parameters,
-                                           (gl_state_index *)slots[i].tokens);
+                                           slots[i].tokens);
 
       /* Add each of the unique swizzles of the element as a parameter.
        * This'll end up matching the expected layout of the
index 7fae22c620710d03213b7be9859ee1d13866d7bd..9aaffc37bd10766e921155a12b5bc913894ee85c 100644 (file)
@@ -127,7 +127,7 @@ brw_create_nir(struct brw_context *brw,
       NIR_PASS(progress, nir, nir_lower_wpos_ytransform, &wpos_options);
       if (progress) {
          _mesa_add_state_reference(prog->Parameters,
-                                   (gl_state_index *) wpos_options.state_tokens);
+                                   wpos_options.state_tokens);
       }
    }
 
index c3606b50ff06e045ffb246bc6c3b334cd5a8ea55..8599e478815b9ed8b2d63f56a35a15f2fd7d34ff 100644 (file)
@@ -456,7 +456,7 @@ static GLboolean r200_translate_vertex_program(struct gl_context *ctx, struct r2
    if ((mesa_vp->info.outputs_written & (1 << VARYING_SLOT_FOGC)) &&
        !vp->fogpidx) {
       struct gl_program_parameter_list *paramList;
-      gl_state_index tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
+      gl_state_index16 tokens[STATE_LENGTH] = { STATE_FOG_PARAMS, 0, 0, 0, 0 };
       paramList = mesa_vp->Parameters;
       vp->fogpidx = _mesa_add_state_reference(paramList, tokens);
    }
index 976b6f46b9f3aeb56385cb8621d39042d48376c7..c7b639456cdfa596a75ce24a54f7e182160e6566 100644 (file)
@@ -413,7 +413,7 @@ static struct ureg register_param5(struct tnl_program *p,
                                   GLint s3,
                                    GLint s4)
 {
-   gl_state_index tokens[STATE_LENGTH];
+   gl_state_index16 tokens[STATE_LENGTH];
    GLint idx;
    tokens[0] = s0;
    tokens[1] = s1;
index 64c43960f146dd0821e75af32684cb4566025d24..38805f92c77b25dc96f5d5c15c070c4d635bc5da 100644 (file)
@@ -30,7 +30,7 @@
 
 TEST(program_state_string, depth_range)
 {
-   const gl_state_index state[STATE_LENGTH] = {
+   const gl_state_index16 state[STATE_LENGTH] = {
       STATE_DEPTH_RANGE
    };
 
index 9236db97805b1d5eec84607424d1aecd8d097cbe..819cf90ba41eb0c4483d66281bf282d7b884df69 100644 (file)
@@ -505,7 +505,7 @@ _mesa_flush_vertices_for_uniforms(struct gl_context *ctx,
 
 struct gl_builtin_uniform_element {
    const char *field;
-   int tokens[STATE_LENGTH];
+   gl_state_index16 tokens[STATE_LENGTH];
    int swizzle;
 };
 
index 660e2c1bd040226381918ce7e7d37ca956f2b777..74089605029ebae4fa03a6d7f017f660e8a216f5 100644 (file)
@@ -663,7 +663,7 @@ ir_to_mesa_visitor::visit(ir_variable *ir)
 
       for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
         int index = _mesa_add_state_reference(this->prog->Parameters,
-                                              (gl_state_index *)slots[i].tokens);
+                                              slots[i].tokens);
 
         if (storage->file == PROGRAM_STATE_VAR) {
            if (storage->index == -1) {
index 81609f5c5e1069660fb54da919051d002f349d4d..6b6599d745379c079ac59f1218869bbc6e5b2b30 100644 (file)
@@ -232,7 +232,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
                     gl_register_file type, const char *name,
                     GLuint size, GLenum datatype,
                     const gl_constant_value *values,
-                    const gl_state_index state[STATE_LENGTH])
+                    const gl_state_index16 state[STATE_LENGTH])
 {
    assert(0 < size && size <=4);
    const GLuint oldNum = paramList->NumParameters;
@@ -352,7 +352,7 @@ _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
  */
 GLint
 _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
-                          const gl_state_index stateTokens[STATE_LENGTH])
+                          const gl_state_index16 stateTokens[STATE_LENGTH])
 {
    const GLuint size = 4; /* XXX fix */
    char *name;
@@ -361,15 +361,15 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
    /* Check if the state reference is already in the list */
    for (index = 0; index < (GLint) paramList->NumParameters; index++) {
       if (!memcmp(paramList->Parameters[index].StateIndexes,
-                  stateTokens, STATE_LENGTH * sizeof(gl_state_index))) {
+                  stateTokens,
+                  sizeof(paramList->Parameters[index].StateIndexes))) {
          return index;
       }
    }
 
    name = _mesa_program_state_string(stateTokens);
    index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
-                               size, GL_NONE,
-                               NULL, (gl_state_index *) stateTokens);
+                               size, GL_NONE, NULL, stateTokens);
    paramList->StateFlags |= _mesa_program_state_flags(stateTokens);
 
    /* free name string here since we duplicated it in add_parameter() */
index f50e99c8abef027ea53d0b76326e04c8c3853575..ce5d2cbaabc277bbcb10ed0c09577f220b3aa92f 100644 (file)
@@ -72,7 +72,7 @@ struct gl_program_parameter
    /**
     * A sequence of STATE_* tokens and integers to identify GL state.
     */
-   gl_state_index StateIndexes[STATE_LENGTH];
+   gl_state_index16 StateIndexes[STATE_LENGTH];
 };
 
 
@@ -108,7 +108,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
                     gl_register_file type, const char *name,
                     GLuint size, GLenum datatype,
                     const gl_constant_value *values,
-                    const gl_state_index state[STATE_LENGTH]);
+                    const gl_state_index16 state[STATE_LENGTH]);
 
 extern GLint
 _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList,
@@ -126,7 +126,7 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
 
 extern GLint
 _mesa_add_state_reference(struct gl_program_parameter_list *paramList,
-                          const gl_state_index stateTokens[STATE_LENGTH]);
+                          const gl_state_index16 stateTokens[]);
 
 
 static inline GLint
index 78f7005301765e154c284d063921b273da53b97b..e7fa72ce10e007a4525058ed1c7353d74951957e 100644 (file)
@@ -54,7 +54,7 @@
  * The program parser will produce the state[] values.
  */
 static void
-_mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
+_mesa_fetch_state(struct gl_context *ctx, const gl_state_index16 state[],
                   gl_constant_value *val)
 {
    GLfloat *value = &val->f;
@@ -628,7 +628,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
  * some GL state has changed.
  */
 GLbitfield
-_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
+_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH])
 {
    switch (state[0]) {
    case STATE_MATERIAL:
@@ -948,7 +948,7 @@ append_index(char *dst, GLint index)
  * Use free() to deallocate the string.
  */
 char *
-_mesa_program_state_string(const gl_state_index state[STATE_LENGTH])
+_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH])
 {
    char str[1000] = "";
    char tmp[30];
index 3fdb413c42104a16c1b2b53b1aacd9f372cbffa9..6d3cc94a0291ccf446970ac4953a80f227f692b8 100644 (file)
@@ -138,18 +138,17 @@ typedef enum gl_state_index_ {
 } gl_state_index;
 
 
-
 extern void
 _mesa_load_state_parameters(struct gl_context *ctx,
                             struct gl_program_parameter_list *paramList);
 
 
 extern GLbitfield
-_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]);
+_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);
 
 
 extern char *
-_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
+_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
 
 
 
index 1bc5f5154943fc51c549724c826b0c879fb12ed0..8adbbf0ac5b4a1c04a2380268ecac7848ba48dfa 100644 (file)
@@ -45,13 +45,13 @@ static struct asm_symbol *declare_variable(struct asm_parser_state *state,
     char *name, enum asm_type t, struct YYLTYPE *locp);
 
 static int add_state_reference(struct gl_program_parameter_list *param_list,
-    const gl_state_index tokens[STATE_LENGTH]);
+    const gl_state_index16 tokens[STATE_LENGTH]);
 
 static int initialize_symbol_from_state(struct gl_program *prog,
-    struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]);
+    struct asm_symbol *param_var, const gl_state_index16 tokens[STATE_LENGTH]);
 
 static int initialize_symbol_from_param(struct gl_program *prog,
-    struct asm_symbol *param_var, const gl_state_index tokens[STATE_LENGTH]);
+    struct asm_symbol *param_var, const gl_state_index16 tokens[STATE_LENGTH]);
 
 static int initialize_symbol_from_const(struct gl_program *prog,
     struct asm_symbol *param_var, const struct asm_vector *vec,
@@ -136,7 +136,7 @@ static struct asm_instruction *asm_instruction_copy_ctor(
    unsigned attrib;
    int integer;
    float real;
-   gl_state_index state[STATE_LENGTH];
+   gl_state_index16 state[STATE_LENGTH];
    int negate;
    struct asm_vector vector;
    enum prog_opcode opcode;
@@ -2299,7 +2299,7 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
 
 
 int add_state_reference(struct gl_program_parameter_list *param_list,
-                       const gl_state_index tokens[STATE_LENGTH])
+                       const gl_state_index16 tokens[STATE_LENGTH])
 {
    const GLuint size = 4; /* XXX fix */
    char *name;
@@ -2320,10 +2320,10 @@ int add_state_reference(struct gl_program_parameter_list *param_list,
 int
 initialize_symbol_from_state(struct gl_program *prog,
                             struct asm_symbol *param_var, 
-                            const gl_state_index tokens[STATE_LENGTH])
+                            const gl_state_index16 tokens[STATE_LENGTH])
 {
    int idx = -1;
-   gl_state_index state_tokens[STATE_LENGTH];
+   gl_state_index16 state_tokens[STATE_LENGTH];
 
 
    memcpy(state_tokens, tokens, sizeof(state_tokens));
@@ -2372,10 +2372,10 @@ initialize_symbol_from_state(struct gl_program *prog,
 int
 initialize_symbol_from_param(struct gl_program *prog,
                             struct asm_symbol *param_var, 
-                            const gl_state_index tokens[STATE_LENGTH])
+                            const gl_state_index16 tokens[STATE_LENGTH])
 {
    int idx = -1;
-   gl_state_index state_tokens[STATE_LENGTH];
+   gl_state_index16 state_tokens[STATE_LENGTH];
 
 
    memcpy(state_tokens, tokens, sizeof(state_tokens));
index f560bce62e4060e3223bf6ae10669fb781c7cca1..a9c0beb31bc28cad05a97e97f392f394e960f20b 100644 (file)
@@ -57,7 +57,7 @@ insert_mvp_dp4_code(struct gl_context *ctx, struct gl_program *vprog)
     * Setup state references for the modelview/projection matrix.
     * XXX we should check if these state vars are already declared.
     */
-   static const gl_state_index mvpState[4][STATE_LENGTH] = {
+   static const gl_state_index16 mvpState[4][STATE_LENGTH] = {
       { STATE_MVP_MATRIX, 0, 0, 0, 0 },  /* state.matrix.mvp.row[0] */
       { STATE_MVP_MATRIX, 0, 1, 1, 0 },  /* state.matrix.mvp.row[1] */
       { STATE_MVP_MATRIX, 0, 2, 2, 0 },  /* state.matrix.mvp.row[2] */
@@ -125,7 +125,7 @@ insert_mvp_mad_code(struct gl_context *ctx, struct gl_program *vprog)
     * Setup state references for the modelview/projection matrix.
     * XXX we should check if these state vars are already declared.
     */
-   static const gl_state_index mvpState[4][STATE_LENGTH] = {
+   static const gl_state_index16 mvpState[4][STATE_LENGTH] = {
       { STATE_MVP_MATRIX, 0, 0, 0, STATE_MATRIX_TRANSPOSE },
       { STATE_MVP_MATRIX, 0, 1, 1, STATE_MATRIX_TRANSPOSE },
       { STATE_MVP_MATRIX, 0, 2, 2, STATE_MATRIX_TRANSPOSE },
@@ -247,9 +247,9 @@ void
 _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
                       GLenum fog_mode, GLboolean saturate)
 {
-   static const gl_state_index fogPStateOpt[STATE_LENGTH]
+   static const gl_state_index16 fogPStateOpt[STATE_LENGTH]
       = { STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0 };
-   static const gl_state_index fogColorState[STATE_LENGTH]
+   static const gl_state_index16 fogColorState[STATE_LENGTH]
       = { STATE_FOG_COLOR, 0, 0, 0, 0};
    struct prog_instruction *newInst, *inst;
    const GLuint origLen = fprog->arb.NumInstructions;
index 8affbdc8d1de8122cc0173440728324951a2ecc0..76236cf96563861971cd51ff78a1bbf2a121ffa4 100644 (file)
@@ -544,9 +544,9 @@ st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog)
 
    unsigned pass, i, r, optype, arg;
 
-   static const gl_state_index fog_params_state[STATE_LENGTH] =
+   static const gl_state_index16 fog_params_state[STATE_LENGTH] =
       {STATE_INTERNAL, STATE_FOG_PARAMS_OPTIMIZED, 0, 0, 0};
-   static const gl_state_index fog_color[STATE_LENGTH] =
+   static const gl_state_index16 fog_color[STATE_LENGTH] =
       {STATE_FOG_COLOR, 0, 0, 0, 0};
 
    prog->info.inputs_read = 0;
index 3f48a278359da349df383765f113a6eda6dec38b..765c827d93fd632df39f5bae4cca69b066e8c9a3 100644 (file)
@@ -247,7 +247,7 @@ st_nir_assign_uniform_locations(struct gl_program *prog,
          else
             loc = imageidx++;
       } else if (strncmp(uniform->name, "gl_", 3) == 0) {
-         const gl_state_index *const stateTokens = (gl_state_index *)uniform->state_slots[0].tokens;
+         const gl_state_index16 *const stateTokens = uniform->state_slots[0].tokens;
          /* This state reference has already been setup by ir_to_mesa, but we'll
           * get the same index back here.
           */
@@ -365,7 +365,7 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
 
          for (unsigned int i = 0; i < var->num_state_slots; i++) {
             _mesa_add_state_reference(prog->Parameters,
-                                      (gl_state_index *)slots[i].tokens);
+                                      slots[i].tokens);
          }
       }
    }
@@ -598,7 +598,7 @@ st_link_nir(struct gl_context *ctx,
 
       /* fragment shaders may need : */
       if (nir->info.stage == MESA_SHADER_FRAGMENT) {
-         static const gl_state_index wposTransformState[STATE_LENGTH] = {
+         static const gl_state_index16 wposTransformState[STATE_LENGTH] = {
             STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
          };
          nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
index ffe0ca0ad70b7fbf75eb55f825c8c786237e2299..7fef93949e8808f5914b297d003ce4e6fc2def90 100644 (file)
@@ -1135,7 +1135,6 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
 
       for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) {
          int index = _mesa_add_state_reference(this->prog->Parameters,
-                                               (gl_state_index *)
                                                slots[i].tokens);
 
          if (storage->file == PROGRAM_STATE_VAR) {
@@ -1497,7 +1496,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
        * is a FBO or the window system buffer, respectively.
        * It is then multiplied with the source operand of DDY.
        */
-      static const gl_state_index transform_y_state[STATE_LENGTH]
+      static const gl_state_index16 transform_y_state[STATE_LENGTH]
          = { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM };
 
       unsigned transform_y_index =
@@ -2115,7 +2114,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
       break;
    case ir_binop_interpolate_at_offset: {
       /* The y coordinate needs to be flipped for the default fb */
-      static const gl_state_index transform_y_state[STATE_LENGTH]
+      static const gl_state_index16 transform_y_state[STATE_LENGTH]
          = { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM };
 
       unsigned transform_y_index =
@@ -6866,7 +6865,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
    if (shader->Stage == MESA_SHADER_FRAGMENT &&
        (prog->info.inputs_read & VARYING_BIT_POS ||
         prog->info.system_values_read & (1 << SYSTEM_VALUE_FRAG_COORD))) {
-      static const gl_state_index wposTransformState[STATE_LENGTH] = {
+      static const gl_state_index16 wposTransformState[STATE_LENGTH] = {
          STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
       };
 
index 75825c3cf627eab2804466ec9d25d27517442cd0..c76180a5799c269607a51f714d8843b585e8d25b 100644 (file)
@@ -622,7 +622,7 @@ emit_wpos_adjustment(struct gl_context *ctx,
     * Need to replace instances of INPUT[WPOS] with temp T
     * where T = INPUT[WPOS] by y is inverted.
     */
-   static const gl_state_index wposTransformState[STATE_LENGTH]
+   static const gl_state_index16 wposTransformState[STATE_LENGTH]
       = { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM, 0, 0, 0 };
 
    /* XXX: note we are modifying the incoming shader here!  Need to
index 19a8ac031395de032ac087d2fdb23a8f0d6597f7..fca0bef6653b2db5677668294d92eb44122244d5 100644 (file)
@@ -100,7 +100,7 @@ get_variable(lower_builtin_state *state, nir_deref_var *deref,
              const struct gl_builtin_uniform_element *element)
 {
    nir_shader *shader = state->shader;
-   int tokens[STATE_LENGTH];
+   gl_state_index16 tokens[STATE_LENGTH];
 
    memcpy(tokens, element->tokens, sizeof(tokens));
 
@@ -126,7 +126,7 @@ get_variable(lower_builtin_state *state, nir_deref_var *deref,
       }
    }
 
-   char *name = _mesa_program_state_string((gl_state_index *)tokens);
+   char *name = _mesa_program_state_string(tokens);
 
    nir_foreach_variable(var, &shader->uniforms) {
       if (strcmp(var->name, name) == 0) {
index d9b7155a91214da4c58ac7acfaa442b9112ed7da..03f5ce4753b43c13ac97474ca56d1afd67833d2a 100644 (file)
@@ -1013,11 +1013,11 @@ st_create_fp_variant(struct st_context *st,
    struct st_fp_variant *variant = CALLOC_STRUCT(st_fp_variant);
    struct pipe_shader_state tgsi = {0};
    struct gl_program_parameter_list *params = stfp->Base.Parameters;
-   static const gl_state_index texcoord_state[STATE_LENGTH] =
+   static const gl_state_index16 texcoord_state[STATE_LENGTH] =
       { STATE_INTERNAL, STATE_CURRENT_ATTRIB, VERT_ATTRIB_TEX0 };
-   static const gl_state_index scale_state[STATE_LENGTH] =
+   static const gl_state_index16 scale_state[STATE_LENGTH] =
       { STATE_INTERNAL, STATE_PT_SCALE };
-   static const gl_state_index bias_state[STATE_LENGTH] =
+   static const gl_state_index16 bias_state[STATE_LENGTH] =
       { STATE_INTERNAL, STATE_PT_BIAS };
 
    if (!variant)