Code cleanup: use GPUDynamicType instead of int
authorNicholas Bishop <nicholasbishop@gmail.com>
Sat, 24 Jan 2015 14:50:03 +0000 (15:50 +0100)
committerNicholas Bishop <nicholasbishop@gmail.com>
Mon, 26 Jan 2015 15:36:07 +0000 (16:36 +0100)
Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D1026

source/blender/gpu/GPU_material.h
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_codegen.h

index a002c981a8f6049e2802d1f3452fc74e9192a6a0..a65a123c7687c5921dccc3c23ddfdbcdcadc5c2f 100644 (file)
@@ -123,13 +123,40 @@ typedef struct GPUNodeStack {
        short sockettype;
 } GPUNodeStack;
 
+typedef enum GPUDynamicType {
+       GPU_DYNAMIC_NONE = 0,
+       GPU_DYNAMIC_OBJECT_VIEWMAT = 1,
+       GPU_DYNAMIC_OBJECT_MAT = 2,
+       GPU_DYNAMIC_OBJECT_VIEWIMAT = 3,
+       GPU_DYNAMIC_OBJECT_IMAT = 4,
+       GPU_DYNAMIC_OBJECT_COLOR = 5,
+       GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE = 15,
+
+       GPU_DYNAMIC_LAMP_FIRST = 6,
+       GPU_DYNAMIC_LAMP_DYNVEC = 6,
+       GPU_DYNAMIC_LAMP_DYNCO = 7,
+       GPU_DYNAMIC_LAMP_DYNIMAT = 8,
+       GPU_DYNAMIC_LAMP_DYNPERSMAT = 9,
+       GPU_DYNAMIC_LAMP_DYNENERGY = 10,
+       GPU_DYNAMIC_LAMP_DYNCOL = 11,
+       GPU_DYNAMIC_LAMP_LAST = 11,
+       GPU_DYNAMIC_SAMPLER_2DBUFFER = 12,
+       GPU_DYNAMIC_SAMPLER_2DIMAGE = 13,
+       GPU_DYNAMIC_SAMPLER_2DSHADOW = 14,
+       GPU_DYNAMIC_LAMP_DISTANCE = 16,
+       GPU_DYNAMIC_LAMP_ATT1 = 17,
+       GPU_DYNAMIC_LAMP_ATT2 = 18,
+       GPU_DYNAMIC_LAMP_SPOTSIZE = 19,
+       GPU_DYNAMIC_LAMP_SPOTBLEND = 20,
+} GPUDynamicType;
+
 GPUNodeLink *GPU_attribute(CustomDataType type, const char *name);
 GPUNodeLink *GPU_uniform(float *num);
-GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data);
+GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *data);
 GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, bool is_data);
 GPUNodeLink *GPU_image_preview(struct PreviewImage *prv);
 GPUNodeLink *GPU_texture(int size, float *pixels);
-GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex, int dynamictype, void *data);
+GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex, GPUDynamicType dynamictype, void *data);
 GPUNodeLink *GPU_builtin(GPUBuiltin builtin);
 GPUNodeLink *GPU_opengl_builtin(GPUOpenGLBuiltin builtin);
 
@@ -183,33 +210,6 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr);
 
 /* Export GLSL shader */
 
-typedef enum GPUDynamicType {
-       GPU_DYNAMIC_NONE = 0,
-       GPU_DYNAMIC_OBJECT_VIEWMAT = 1,
-       GPU_DYNAMIC_OBJECT_MAT = 2,
-       GPU_DYNAMIC_OBJECT_VIEWIMAT = 3,
-       GPU_DYNAMIC_OBJECT_IMAT = 4,
-       GPU_DYNAMIC_OBJECT_COLOR = 5,
-       GPU_DYNAMIC_OBJECT_AUTOBUMPSCALE = 15,
-
-       GPU_DYNAMIC_LAMP_FIRST = 6,
-       GPU_DYNAMIC_LAMP_DYNVEC = 6,
-       GPU_DYNAMIC_LAMP_DYNCO = 7,
-       GPU_DYNAMIC_LAMP_DYNIMAT = 8,
-       GPU_DYNAMIC_LAMP_DYNPERSMAT = 9,
-       GPU_DYNAMIC_LAMP_DYNENERGY = 10,
-       GPU_DYNAMIC_LAMP_DYNCOL = 11,
-       GPU_DYNAMIC_LAMP_LAST = 11,
-       GPU_DYNAMIC_SAMPLER_2DBUFFER = 12,
-       GPU_DYNAMIC_SAMPLER_2DIMAGE = 13,
-       GPU_DYNAMIC_SAMPLER_2DSHADOW = 14,
-       GPU_DYNAMIC_LAMP_DISTANCE = 16,
-       GPU_DYNAMIC_LAMP_ATT1 = 17,
-       GPU_DYNAMIC_LAMP_ATT2 = 18,
-       GPU_DYNAMIC_LAMP_SPOTSIZE = 19,
-       GPU_DYNAMIC_LAMP_SPOTBLEND = 20,
-} GPUDynamicType;
-
 typedef enum GPUDataType {
        GPU_DATA_NONE = 0,
        GPU_DATA_1I = 1,        // 1 integer
index 0ada2602ae4e40f8cbfe56fedda137061354764b..9b49d232209a73a67a8528af45bb9cac88bece5f 100644 (file)
@@ -1178,7 +1178,7 @@ GPUNodeLink *GPU_uniform(float *num)
        return link;
 }
 
-GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data)
+GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *data)
 {
        GPUNodeLink *link = GPU_node_link_create();
 
@@ -1225,7 +1225,7 @@ GPUNodeLink *GPU_texture(int size, float *pixels)
        return link;
 }
 
-GPUNodeLink *GPU_dynamic_texture(GPUTexture *tex, int dynamictype, void *data)
+GPUNodeLink *GPU_dynamic_texture(GPUTexture *tex, GPUDynamicType dynamictype, void *data)
 {
        GPUNodeLink *link = GPU_node_link_create();
 
index 8b63af925a662f83e3e4c6a2092ccaffecb3a940..c76341afa00671f2a86e9037ecc0aee5df48b2c9 100644 (file)
@@ -94,7 +94,7 @@ struct GPUNodeLink {
        void *ptr1, *ptr2;
 
        bool dynamic;
-       int dynamictype;
+       GPUDynamicType dynamictype;
 
        GPUType type;
 
@@ -131,7 +131,7 @@ typedef struct GPUInput {
        int attribid;                   /* id for vertex attributes */
        bool bindtex;                   /* input is responsible for binding the texture? */
        bool definetex;                 /* input is responsible for defining the pixel? */
-       int textarget;                  /* GL_TEXTURE_* */
+       int textarget;                  /* GL texture target, e.g. GL_TEXTURE_2D */
        GPUType textype;                /* datatype */
 
        struct Image *ima;              /* image */
@@ -139,7 +139,7 @@ typedef struct GPUInput {
        struct PreviewImage *prv;       /* preview images & icons */
        bool image_isdata;              /* image does not contain color data */
        float *dynamicvec;              /* vector data in case it is dynamic */
-       int dynamictype;                /* origin of the dynamic uniform (GPUDynamicType) */
+       GPUDynamicType dynamictype;     /* origin of the dynamic uniform */
        void *dynamicdata;              /* data source of the dynamic uniform */
        struct GPUTexture *tex; /* input texture, only set at runtime */
        int shaderloc;                  /* id from opengl */