Code cleanup: retype various fields/parameters from int to GPUType

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1026
This commit is contained in:
Nicholas Bishop 2015-01-24 13:58:19 +01:00
parent a59e590e7f
commit d1f88c05aa
3 changed files with 39 additions and 19 deletions

@ -127,7 +127,8 @@ static char *gpu_str_skip_token(char *str, char *token, int max)
static void gpu_parse_functions_string(GHash *hash, char *code) static void gpu_parse_functions_string(GHash *hash, char *code)
{ {
GPUFunction *function; GPUFunction *function;
int i, type, qual; GPUType type;
int i, qual;
while ((code = strstr(code, "void "))) { while ((code = strstr(code, "void "))) {
function = MEM_callocN(sizeof(GPUFunction), "GPUFunction"); function = MEM_callocN(sizeof(GPUFunction), "GPUFunction");
@ -147,7 +148,7 @@ static void gpu_parse_functions_string(GHash *hash, char *code)
code = gpu_str_skip_token(code, NULL, 0); code = gpu_str_skip_token(code, NULL, 0);
/* test for type */ /* test for type */
type= 0; type= GPU_NONE;
for (i=1; i<=16; i++) { for (i=1; i<=16; i++) {
if (GPU_DATATYPE_STR[i] && gpu_str_prefix(code, GPU_DATATYPE_STR[i])) { if (GPU_DATATYPE_STR[i] && gpu_str_prefix(code, GPU_DATATYPE_STR[i])) {
type= i; type= i;
@ -321,7 +322,7 @@ static void codegen_convert_datatype(DynStr *ds, int from, int to, const char *t
} }
} }
static void codegen_print_datatype(DynStr *ds, int type, float *data) static void codegen_print_datatype(DynStr *ds, const GPUType type, float *data)
{ {
int i; int i;
@ -639,7 +640,7 @@ static char *code_generate_fragment(ListBase *nodes, GPUOutput *output, const ch
return code; return code;
} }
static char *code_generate_vertex(ListBase *nodes, int type) static char *code_generate_vertex(ListBase *nodes, const GPUMatType type)
{ {
DynStr *ds = BLI_dynstr_new(); DynStr *ds = BLI_dynstr_new();
GPUNode *node; GPUNode *node;
@ -900,7 +901,7 @@ static void GPU_node_end(GPUNode *UNUSED(node))
/* empty */ /* empty */
} }
static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType type)
{ {
GPUInput *input; GPUInput *input;
GPUNode *outnode; GPUNode *outnode;
@ -1027,7 +1028,7 @@ static void gpu_node_input_socket(GPUNode *node, GPUNodeStack *sock)
} }
} }
static void GPU_node_output(GPUNode *node, int type, const char *UNUSED(name), GPUNodeLink **link) static void GPU_node_output(GPUNode *node, const GPUType type, const char *UNUSED(name), GPUNodeLink **link)
{ {
GPUOutput *output = MEM_callocN(sizeof(GPUOutput), "GPUOutput"); GPUOutput *output = MEM_callocN(sizeof(GPUOutput), "GPUOutput");
@ -1400,7 +1401,9 @@ static void gpu_nodes_prune(ListBase *nodes, GPUNodeLink *outlink)
} }
} }
GPUPass *GPU_generate_pass(ListBase *nodes, GPUNodeLink *outlink, GPUVertexAttribs *attribs, int *builtins, int type, const char *name) GPUPass *GPU_generate_pass(ListBase *nodes, GPUNodeLink *outlink,
GPUVertexAttribs *attribs, int *builtins,
const GPUMatType type, const char *name)
{ {
GPUShader *shader; GPUShader *shader;
GPUPass *pass; GPUPass *pass;

@ -55,7 +55,7 @@ struct PreviewImage;
typedef struct GPUFunction { typedef struct GPUFunction {
char name[MAX_FUNCTION_NAME]; char name[MAX_FUNCTION_NAME];
int paramtype[MAX_PARAMETER]; GPUType paramtype[MAX_PARAMETER];
int paramqual[MAX_PARAMETER]; int paramqual[MAX_PARAMETER];
int totparam; int totparam;
} GPUFunction; } GPUFunction;
@ -104,7 +104,7 @@ struct GPUNodeLink {
int dynamic; int dynamic;
int dynamictype; int dynamictype;
int type; GPUType type;
/* Refcount */ /* Refcount */
int users; int users;
@ -121,7 +121,7 @@ typedef struct GPUOutput {
struct GPUOutput *next, *prev; struct GPUOutput *next, *prev;
GPUNode *node; GPUNode *node;
int type; /* data type = length of vector/matrix */ GPUType type; /* data type = length of vector/matrix */
GPUNodeLink *link; /* output link */ GPUNodeLink *link; /* output link */
int id; /* unique id as created by code generator */ int id; /* unique id as created by code generator */
} GPUOutput; } GPUOutput;
@ -131,7 +131,7 @@ typedef struct GPUInput {
GPUNode *node; GPUNode *node;
int type; /* datatype */ GPUType type; /* datatype */
int source; /* data source */ int source; /* data source */
int id; /* unique id as created by code generator */ int id; /* unique id as created by code generator */
@ -140,7 +140,7 @@ typedef struct GPUInput {
int bindtex; /* input is responsible for binding the texture? */ int bindtex; /* input is responsible for binding the texture? */
int definetex; /* input is responsible for defining the pixel? */ int definetex; /* input is responsible for defining the pixel? */
int textarget; /* GL_TEXTURE_* */ int textarget; /* GL_TEXTURE_* */
int textype; /* datatype */ GPUType textype; /* datatype */
struct Image *ima; /* image */ struct Image *ima; /* image */
struct ImageUser *iuser;/* image user */ struct ImageUser *iuser;/* image user */
@ -178,7 +178,8 @@ struct GPUPass {
typedef struct GPUPass GPUPass; typedef struct GPUPass GPUPass;
GPUPass *GPU_generate_pass(ListBase *nodes, struct GPUNodeLink *outlink, GPUPass *GPU_generate_pass(ListBase *nodes, struct GPUNodeLink *outlink,
struct GPUVertexAttribs *attribs, int *builtin, int type, const char *name); struct GPUVertexAttribs *attribs, int *builtin,
const GPUMatType type, const char *name);
struct GPUShader *GPU_pass_shader(GPUPass *pass); struct GPUShader *GPU_pass_shader(GPUPass *pass);

@ -2208,30 +2208,46 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
glBindTexture(GL_TEXTURE_2D, lastbindcode); glBindTexture(GL_TEXTURE_2D, lastbindcode);
} }
break; break;
case GPU_NONE:
case GPU_FLOAT:
case GPU_VEC2:
case GPU_VEC3:
case GPU_VEC4:
case GPU_MAT3:
case GPU_MAT4:
case GPU_ATTRIB:
break;
} }
} }
else { else {
uniform->type = input->dynamictype; uniform->type = input->dynamictype;
BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname)); BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
switch (input->type) { switch (input->type) {
case 1: case GPU_FLOAT:
uniform->datatype = GPU_DATA_1F; uniform->datatype = GPU_DATA_1F;
break; break;
case 2: case GPU_VEC2:
uniform->datatype = GPU_DATA_2F; uniform->datatype = GPU_DATA_2F;
break; break;
case 3: case GPU_VEC3:
uniform->datatype = GPU_DATA_3F; uniform->datatype = GPU_DATA_3F;
break; break;
case 4: case GPU_VEC4:
uniform->datatype = GPU_DATA_4F; uniform->datatype = GPU_DATA_4F;
break; break;
case 9: case GPU_MAT3:
uniform->datatype = GPU_DATA_9F; uniform->datatype = GPU_DATA_9F;
break; break;
case 16: case GPU_MAT4:
uniform->datatype = GPU_DATA_16F; uniform->datatype = GPU_DATA_16F;
break; break;
case GPU_NONE:
case GPU_TEX2D:
case GPU_SHADOW2D:
case GPU_ATTRIB:
break;
} }
if (uniform->type >= GPU_DYNAMIC_LAMP_FIRST && uniform->type <= GPU_DYNAMIC_LAMP_LAST) if (uniform->type >= GPU_DYNAMIC_LAMP_FIRST && uniform->type <= GPU_DYNAMIC_LAMP_LAST)