[Mesa-dev] [PATCH 13/13] mesa: move STATE_LENGTH to shader_enums.h and use it everywhere

Marek Olšák maraeo at gmail.com
Fri Feb 9 01:18:48 UTC 2018


From: Marek Olšák <marek.olsak at amd.com>

---
 src/compiler/glsl/ir.h                  |  2 +-
 src/compiler/nir/nir.h                  | 10 +++++-----
 src/compiler/nir/nir_lower_drawpixels.c |  2 +-
 src/compiler/shader_enums.h             |  6 ++++++
 src/mesa/program/prog_statevars.h       |  6 ------
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index b849c93..6d3ef89 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -390,21 +390,21 @@ enum ir_depth_layout {
  */
 const char*
 depth_layout_string(ir_depth_layout layout);
 
 /**
  * Description of built-in state associated with a uniform
  *
  * \sa ir_variable::state_slots
  */
 struct ir_state_slot {
-   gl_state_index16 tokens[5];
+   gl_state_index16 tokens[STATE_LENGTH];
    int swizzle;
 };
 
 
 /**
  * Get the string value for an interpolation qualifier
  *
  * \return The string that would be used in a shader to specify \c
  * mode will be returned.
  *
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 216cc88..2acd951 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -82,21 +82,21 @@ struct nir_function;
 struct nir_shader;
 struct nir_instr;
 
 
 /**
  * Description of built-in state associated with a uniform
  *
  * \sa nir_variable::state_slots
  */
 typedef struct {
-   gl_state_index16 tokens[5];
+   gl_state_index16 tokens[STATE_LENGTH];
    int swizzle;
 } nir_state_slot;
 
 typedef enum {
    nir_var_shader_in       = (1 << 0),
    nir_var_shader_out      = (1 << 1),
    nir_var_global          = (1 << 2),
    nir_var_local           = (1 << 3),
    nir_var_uniform         = (1 << 4),
    nir_var_shader_storage  = (1 << 5),
@@ -2646,35 +2646,35 @@ bool nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables);
 bool nir_lower_clip_cull_distance_arrays(nir_shader *nir);
 
 void nir_lower_two_sided_color(nir_shader *shader);
 
 bool nir_lower_clamp_color_outputs(nir_shader *shader);
 
 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 {
-   gl_state_index16 state_tokens[5];
+   gl_state_index16 state_tokens[STATE_LENGTH];
    bool fs_coord_origin_upper_left :1;
    bool fs_coord_origin_lower_left :1;
    bool fs_coord_pixel_center_integer :1;
    bool fs_coord_pixel_center_half_integer :1;
 } nir_lower_wpos_ytransform_options;
 
 bool nir_lower_wpos_ytransform(nir_shader *shader,
                                const nir_lower_wpos_ytransform_options *options);
 bool nir_lower_wpos_center(nir_shader *shader, const bool for_sample_shading);
 
 typedef struct nir_lower_drawpixels_options {
-   gl_state_index16 texcoord_state_tokens[5];
-   gl_state_index16 scale_state_tokens[5];
-   gl_state_index16 bias_state_tokens[5];
+   gl_state_index16 texcoord_state_tokens[STATE_LENGTH];
+   gl_state_index16 scale_state_tokens[STATE_LENGTH];
+   gl_state_index16 bias_state_tokens[STATE_LENGTH];
    unsigned drawpix_sampler;
    unsigned pixelmap_sampler;
    bool pixel_maps :1;
    bool scale_and_bias :1;
 } nir_lower_drawpixels_options;
 
 void nir_lower_drawpixels(nir_shader *shader,
                           const nir_lower_drawpixels_options *options);
 
 typedef struct nir_lower_bitmap_options {
diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c
index 4d43f42..5cc358d 100644
--- a/src/compiler/nir/nir_lower_drawpixels.c
+++ b/src/compiler/nir/nir_lower_drawpixels.c
@@ -61,21 +61,21 @@ get_texcoord(lower_drawpixels_state *state)
          texcoord->data.location = VARYING_SLOT_TEX0;
       }
 
       state->texcoord = texcoord;
    }
    return nir_load_var(&state->b, state->texcoord);
 }
 
 static nir_variable *
 create_uniform(nir_shader *shader, const char *name,
-               const gl_state_index16 state_tokens[5])
+               const gl_state_index16 state_tokens[STATE_LENGTH])
 {
    nir_variable *var = nir_variable_create(shader,
                                            nir_var_uniform,
                                            glsl_vec4_type(),
                                            name);
    var->num_state_slots = 1;
    var->state_slots = ralloc_array(var, nir_state_slot, 1);
    memcpy(var->state_slots[0].tokens, state_tokens,
           sizeof(var->state_slots[0].tokens));
    return var;
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index d1e875b..ac83c65 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -41,20 +41,26 @@ typedef enum
 {
    MESA_SHADER_NONE = -1,
    MESA_SHADER_VERTEX = 0,
    MESA_SHADER_TESS_CTRL = 1,
    MESA_SHADER_TESS_EVAL = 2,
    MESA_SHADER_GEOMETRY = 3,
    MESA_SHADER_FRAGMENT = 4,
    MESA_SHADER_COMPUTE = 5,
 } gl_shader_stage;
 
+/**
+ * Number of STATE_* values we need to address any GL state.
+ * Used to dimension arrays.
+ */
+#define STATE_LENGTH 5
+
 typedef short gl_state_index16; /* see enum gl_state_index */
 
 const char *gl_shader_stage_name(gl_shader_stage stage);
 
 /**
  * Translate a gl_shader_stage to a short shader stage name for debug
  * printouts and error messages.
  */
 const char *_mesa_shader_stage_to_string(unsigned stage);
 
diff --git a/src/mesa/program/prog_statevars.h b/src/mesa/program/prog_statevars.h
index 6d3cc94..6cb3531 100644
--- a/src/mesa/program/prog_statevars.h
+++ b/src/mesa/program/prog_statevars.h
@@ -30,26 +30,20 @@
 
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
 struct gl_context;
 struct gl_program_parameter_list;
 
-/**
- * Number of STATE_* values we need to address any GL state.
- * Used to dimension arrays.
- */
-#define STATE_LENGTH 5
-
 
 /**
  * Used for describing GL state referenced from inside ARB vertex and
  * fragment programs.
  * A string such as "state.light[0].ambient" gets translated into a
  * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
  *
  * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should
  * always be the array index.
  */
-- 
2.7.4



More information about the mesa-dev mailing list