From: Brian Paul Date: Thu, 24 Aug 2006 21:57:36 +0000 (+0000) Subject: Added _mesa_realloc_instructions() utility function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3b9b8de9b0bf2f1e69a450360a812090520b2b29;p=mesa.git Added _mesa_realloc_instructions() utility function. Fixed/updated comments for parameter list functions. --- diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 371500304f4..27eb5c2f432 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -419,7 +419,10 @@ _mesa_add_named_parameter(struct gl_program_parameter_list *paramList, /** - * Add a new unnamed constant to the parameter list. + * Add a new named constant to the parameter list. + * This will be used when the program contains something like this: + * PARAM myVals = { 0, 1, 2, 3 }; + * * \param paramList - the parameter list * \param values - four float values * \return index of the new parameter. @@ -434,6 +437,9 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList, /** * Add a new unnamed constant to the parameter list. + * This will be used when the program contains something like this: + * MOV r, { 0, 1, 2, 3 }; + * * \param paramList - the parameter list * \param values - four float values * \return index of the new parameter. @@ -448,9 +454,11 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, /** * Add a new state reference to the parameter list. + * This will be used when the program contains something like this: + * PARAM ambient = state.material.front.ambient; + * * \param paramList - the parameter list * \param state - an array of 6 state tokens - * * \return index of the new parameter. */ GLint @@ -1304,6 +1312,30 @@ _mesa_init_instruction(struct prog_instruction *inst) } +/** + * Reallocate memory storing an array of program instructions. + * This is used when we need to append additional instructions onto an + * program. + * \param oldInst pointer to first of old/src instructions + * \param numOldInst number of instructions at + * \param numNewInst desired size of new instruction array. + * \return pointer to start of new instruction array. + */ +struct prog_instruction * +_mesa_realloc_instructions(struct prog_instruction *oldInst, + GLuint numOldInst, GLuint numNewInst) +{ + struct prog_instruction *newInst; + + newInst = (struct prog_instruction *) + _mesa_realloc(oldInst, + numOldInst * sizeof(struct prog_instruction), + numNewInst * sizeof(struct prog_instruction)); + + return newInst; +} + + /** * Basic info about each instruction */ diff --git a/src/mesa/shader/program.h b/src/mesa/shader/program.h index 1d91e63af50..a8535cc2cf1 100644 --- a/src/mesa/shader/program.h +++ b/src/mesa/shader/program.h @@ -114,6 +114,10 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog); extern struct gl_program * _mesa_lookup_program(GLcontext *ctx, GLuint id); +extern struct prog_instruction * +_mesa_realloc_instructions(struct prog_instruction *oldInst, + GLuint numOldInst, GLuint numNewInst); + /** * Used for describing GL state referenced from inside ARB vertex and