From 613e1ad5d517d9964bd9cf94daa931dda33113fe Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 5 Nov 2005 02:15:21 +0000 Subject: [PATCH] Replace parameter_type enum in program.[ch], use register_file enums instead. --- src/mesa/main/mtypes.h | 25 ++++++++++++++----------- src/mesa/shader/nvfragparse.c | 4 ++-- src/mesa/shader/program.c | 12 ++++++------ src/mesa/shader/program.h | 21 ++++++--------------- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index cc44acf3cf9..3271cb0772f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1723,20 +1723,23 @@ struct atifs_machine /** - * Names of the various vertex/fragment register files + * Names of the various vertex/fragment program register files, etc. + * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c) + * All values should fit in a 4-bit field. */ enum register_file { - PROGRAM_TEMPORARY, - PROGRAM_INPUT, - PROGRAM_OUTPUT, - PROGRAM_LOCAL_PARAM, - PROGRAM_ENV_PARAM, - PROGRAM_NAMED_PARAM, - PROGRAM_STATE_VAR, - PROGRAM_WRITE_ONLY, - PROGRAM_ADDRESS, - PROGRAM_UNDEFINED /* invalid value */ + PROGRAM_TEMPORARY = 0, + PROGRAM_LOCAL_PARAM = 1, + PROGRAM_ENV_PARAM = 2, + PROGRAM_STATE_VAR = 3, + PROGRAM_INPUT = 4, + PROGRAM_OUTPUT = 5, + PROGRAM_NAMED_PARAM = 6, + PROGRAM_CONSTANT = 7, + PROGRAM_WRITE_ONLY = 8, + PROGRAM_ADDRESS = 9, + PROGRAM_UNDEFINED = 15 /* invalid value */ }; diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index 2e1113267a6..41344ec8694 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -1582,7 +1582,7 @@ PrintSrcReg(const struct fragment_program *program, _mesa_printf("-"); } if (src->File == PROGRAM_NAMED_PARAM) { - if (program->Parameters->Parameters[src->Index].Type == CONSTANT) { + if (program->Parameters->Parameters[src->Index].Type == PROGRAM_CONSTANT) { _mesa_printf("{%g, %g, %g, %g}", program->Parameters->ParameterValues[src->Index][0], program->Parameters->ParameterValues[src->Index][1], @@ -1591,7 +1591,7 @@ PrintSrcReg(const struct fragment_program *program, } else { ASSERT(program->Parameters->Parameters[src->Index].Type - == NAMED_PARAMETER); + == PROGRAM_NAMED_PARAM); _mesa_printf("%s", program->Parameters->Parameters[src->Index].Name); } } diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 7b9185a6a81..b4ac8f51d45 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -388,7 +388,7 @@ _mesa_free_parameters(struct program_parameter_list *paramList) static GLint add_parameter(struct program_parameter_list *paramList, const char *name, const GLfloat values[4], - enum parameter_type type) + enum register_file type) { const GLuint n = paramList->NumParameters; @@ -443,7 +443,7 @@ GLint _mesa_add_named_parameter(struct program_parameter_list *paramList, const char *name, const GLfloat values[4]) { - return add_parameter(paramList, name, values, NAMED_PARAMETER); + return add_parameter(paramList, name, values, PROGRAM_NAMED_PARAM); } @@ -457,7 +457,7 @@ GLint _mesa_add_named_constant(struct program_parameter_list *paramList, const char *name, const GLfloat values[4]) { - return add_parameter(paramList, name, values, CONSTANT); + return add_parameter(paramList, name, values, PROGRAM_CONSTANT); } @@ -471,7 +471,7 @@ GLint _mesa_add_unnamed_constant(struct program_parameter_list *paramList, const GLfloat values[4]) { - return add_parameter(paramList, NULL, values, CONSTANT); + return add_parameter(paramList, NULL, values, PROGRAM_CONSTANT); } @@ -491,7 +491,7 @@ _mesa_add_state_reference(struct program_parameter_list *paramList, */ GLint index; - index = add_parameter(paramList, NULL, NULL, STATE); + index = add_parameter(paramList, NULL, NULL, PROGRAM_STATE_VAR); if (index >= 0) { GLuint i; for (i = 0; i < 6; i++) @@ -953,7 +953,7 @@ _mesa_load_state_parameters(GLcontext *ctx, return; for (i = 0; i < paramList->NumParameters; i++) { - if (paramList->Parameters[i].Type == STATE) { + if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) { _mesa_fetch_state(ctx, paramList->Parameters[i].StateIndexes, paramList->ParameterValues[i]); diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index 776062f7d08..2d8ff4ab14d 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -190,35 +190,26 @@ enum state_index { -/* +/** * Named program parameters * Used for NV_fragment_program "DEFINE"d constants and "DECLARE"d parameters, * and ARB_fragment_program global state references. For the later, Name * might be "state.light[0].diffuse", for example. */ - -enum parameter_type -{ - NAMED_PARAMETER, - CONSTANT, - STATE -}; - - struct program_parameter { const char *Name; /* Null-terminated */ - enum parameter_type Type; + enum register_file Type; /** PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */ enum state_index StateIndexes[6]; /* Global state reference */ }; struct program_parameter_list { - GLuint Size; - GLuint NumParameters; - struct program_parameter *Parameters; - GLfloat (*ParameterValues)[4]; + GLuint Size; /** allocated size of Parameters, ParameterValues */ + GLuint NumParameters; /** number of parameters in arrays */ + struct program_parameter *Parameters; /** Array [Size] */ + GLfloat (*ParameterValues)[4]; /** Array [Size] */ }; -- 2.30.2