summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-11-16 04:29:35 +0100
committerMarek Olšák <[email protected]>2018-02-13 01:00:45 +0100
commite149a0253c12d103805230bc7bc0a36887c3b8df (patch)
tree2eedb0e74a1d0f71c76634ac165f925feecfa1b3 /src/compiler
parenta7882013d3e788a76cce638704c02b7bea0e67a1 (diff)
mesa,glsl,nir: reduce gl_state_index size to 2 bytes
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 <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/ir.h2
-rw-r--r--src/compiler/glsl/serialize.cpp2
-rw-r--r--src/compiler/glsl/standalone_scaffolding.cpp4
-rw-r--r--src/compiler/glsl/standalone_scaffolding.h4
-rw-r--r--src/compiler/nir/nir.h10
-rw-r--r--src/compiler/nir/nir_lower_drawpixels.c3
-rw-r--r--src/compiler/shader_enums.h2
7 files changed, 15 insertions, 12 deletions
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index d5a255eb8b4..b849c938722 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -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;
};
diff --git a/src/compiler/glsl/serialize.cpp b/src/compiler/glsl/serialize.cpp
index 63ce41d87bd..9d2033bddfa 100644
--- a/src/compiler/glsl/serialize.cpp
+++ b/src/compiler/glsl/serialize.cpp
@@ -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);
diff --git a/src/compiler/glsl/standalone_scaffolding.cpp b/src/compiler/glsl/standalone_scaffolding.cpp
index 34065a9fe10..caaddc028f7 100644
--- a/src/compiler/glsl/standalone_scaffolding.cpp
+++ b/src/compiler/glsl/standalone_scaffolding.cpp
@@ -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;
}
diff --git a/src/compiler/glsl/standalone_scaffolding.h b/src/compiler/glsl/standalone_scaffolding.h
index 7532d0836f7..c8d90597ca0 100644
--- a/src/compiler/glsl/standalone_scaffolding.h
+++ b/src/compiler/glsl/standalone_scaffolding.h
@@ -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)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 5ea8c9926b9..216cc8837fd 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -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;
diff --git a/src/compiler/nir/nir_lower_drawpixels.c b/src/compiler/nir/nir_lower_drawpixels.c
index acec9443431..4d43f423a49 100644
--- a/src/compiler/nir/nir_lower_drawpixels.c
+++ b/src/compiler/nir/nir_lower_drawpixels.c
@@ -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,
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index fb78ad384cb..d1e875bd189 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -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);
/**