summaryrefslogtreecommitdiffstats
path: root/src/mesa/program
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/mesa/program
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/mesa/program')
-rw-r--r--src/mesa/program/ir_to_mesa.cpp2
-rw-r--r--src/mesa/program/prog_parameter.c10
-rw-r--r--src/mesa/program/prog_parameter.h6
-rw-r--r--src/mesa/program/prog_statevars.c6
-rw-r--r--src/mesa/program/prog_statevars.h5
-rw-r--r--src/mesa/program/program_parse.y18
-rw-r--r--src/mesa/program/programopt.c8
7 files changed, 27 insertions, 28 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 660e2c1bd04..74089605029 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -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) {
diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
index 81609f5c5e1..6b6599d7453 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -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() */
diff --git a/src/mesa/program/prog_parameter.h b/src/mesa/program/prog_parameter.h
index f50e99c8abe..ce5d2cbaabc 100644
--- a/src/mesa/program/prog_parameter.h
+++ b/src/mesa/program/prog_parameter.h
@@ -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
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index 78f70053017..e7fa72ce10e 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -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];
diff --git a/src/mesa/program/prog_statevars.h b/src/mesa/program/prog_statevars.h
index 3fdb413c421..6d3cc94a029 100644
--- a/src/mesa/program/prog_statevars.h
+++ b/src/mesa/program/prog_statevars.h
@@ -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]);
diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y
index 1bc5f515494..8adbbf0ac5b 100644
--- a/src/mesa/program/program_parse.y
+++ b/src/mesa/program/program_parse.y
@@ -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));
diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c
index f560bce62e4..a9c0beb31bc 100644
--- a/src/mesa/program/programopt.c
+++ b/src/mesa/program/programopt.c
@@ -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;