Cleanup: style, gpu module
authorCampbell Barton <ideasman42@gmail.com>
Sat, 9 Jan 2016 20:12:10 +0000 (07:12 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 9 Jan 2016 20:12:10 +0000 (07:12 +1100)
21 files changed:
source/blender/gpu/GPU_basic_shader.h
source/blender/gpu/GPU_compositing.h
source/blender/gpu/GPU_draw.h
source/blender/gpu/GPU_extensions.h
source/blender/gpu/GPU_framebuffer.h
source/blender/gpu/GPU_material.h
source/blender/gpu/GPU_select.h
source/blender/gpu/GPU_shader.h
source/blender/gpu/GPU_texture.h
source/blender/gpu/intern/gpu_basic_shader.c
source/blender/gpu/intern/gpu_buffers.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/gpu/intern/gpu_compositing.c
source/blender/gpu/intern/gpu_debug.c
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_extensions.c
source/blender/gpu/intern/gpu_framebuffer.c
source/blender/gpu/intern/gpu_material.c
source/blender/gpu/intern/gpu_select.c
source/blender/gpu/intern/gpu_shader.c
source/blender/gpu/intern/gpu_texture.c

index f964e056d44d792634359e7769e03ee9edadb34f..f376850a8f93da25e5c9e69064d37ae0fb296817 100644 (file)
@@ -41,15 +41,15 @@ extern "C" {
 /* Fixed Function Shader */
 
 typedef enum GPUBasicShaderOption {
-       GPU_SHADER_USE_COLOR =        (1<<0),   /* use glColor, for lighting it replaces diffuse */
-       GPU_SHADER_LIGHTING =         (1<<1),   /* use lighting */
-       GPU_SHADER_TWO_SIDED =        (1<<2),   /* flip normals towards viewer */
-       GPU_SHADER_TEXTURE_2D =       (1<<3),   /* use 2D texture to replace diffuse color */
+       GPU_SHADER_USE_COLOR =        (1 << 0),   /* use glColor, for lighting it replaces diffuse */
+       GPU_SHADER_LIGHTING =         (1 << 1),   /* use lighting */
+       GPU_SHADER_TWO_SIDED =        (1 << 2),   /* flip normals towards viewer */
+       GPU_SHADER_TEXTURE_2D =       (1 << 3),   /* use 2D texture to replace diffuse color */
 
-       GPU_SHADER_SOLID_LIGHTING =   (1<<4),   /* use faster lighting (set automatically) */
-       GPU_SHADER_STIPPLE =          (1<<5),   /* use stipple */
+       GPU_SHADER_SOLID_LIGHTING =   (1 << 4),   /* use faster lighting (set automatically) */
+       GPU_SHADER_STIPPLE =          (1 << 5),   /* use stipple */
        GPU_SHADER_OPTIONS_NUM = 6,
-       GPU_SHADER_OPTION_COMBINATIONS = (1<<GPU_SHADER_OPTIONS_NUM)
+       GPU_SHADER_OPTION_COMBINATIONS = (1 << GPU_SHADER_OPTIONS_NUM)
 } GPUBasicShaderOption;
 
 /* Keep these in sync with gpu_shader_basic_frag.glsl */
index 04e89da00a7bec0b7ff33f29f308b49a0f52aa80..892fe4f325538ad78e0d190f65c97ea3997a3405 100644 (file)
@@ -82,7 +82,9 @@ bool GPU_fx_compositor_initialize_passes(
         const struct GPUFXSettings *fx_settings);
 
 /* do compositing on the fx passes that have been initialized */
-bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, struct Scene *scene, struct GPUOffScreen *ofs);
+bool GPU_fx_do_composite_pass(
+        GPUFX *fx, float projmat[4][4], bool is_persp,
+        struct Scene *scene, struct GPUOffScreen *ofs);
 
 /* bind new depth buffer for XRay pass */
 void GPU_fx_compositor_setup_XRay_pass(GPUFX *fx, bool do_xray);
index 3e6c26f608cf06b639b105fe1dda008fdb1d9eba..afb1cbcf71d4df503fbc5c54b1a3f886352ffbce 100644 (file)
@@ -133,9 +133,12 @@ void GPU_paint_update_image(struct Image *ima, struct ImageUser *iuser, int x, i
 void GPU_update_images_framechange(void);
 int GPU_update_image_time(struct Image *ima, double time);
 int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, bool compare, bool mipmap, bool is_data);
-void GPU_create_gl_tex(unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth,
-                       bool mipmap, bool use_hight_bit_depth, struct Image *ima);
-void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, struct Image *ima, struct ImBuf *ibuf);
+void GPU_create_gl_tex(
+        unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth,
+        bool mipmap, bool use_hight_bit_depth, struct Image *ima);
+void GPU_create_gl_tex_compressed(
+        unsigned int *bind, unsigned int *pix, int x, int y, int mipmap,
+        struct Image *ima, struct ImBuf *ibuf);
 bool GPU_upload_dxt_texture(struct ImBuf *ibuf);
 void GPU_free_image(struct Image *ima);
 void GPU_free_images(void);
index fda12a43a5dbdc2281442c33549b31262bc6f27b..64167e94933fc197eeb5c9e557c94dcd64c8a4f7 100644 (file)
@@ -64,25 +64,25 @@ void GPU_code_generate_glsl_lib(void);
 /* GPU Types */
 
 typedef enum GPUDeviceType {
-       GPU_DEVICE_NVIDIA =     (1<<0),
-       GPU_DEVICE_ATI =        (1<<1),
-       GPU_DEVICE_INTEL =      (1<<2),
-       GPU_DEVICE_SOFTWARE =   (1<<3),
-       GPU_DEVICE_UNKNOWN =    (1<<4),
+       GPU_DEVICE_NVIDIA =     (1 << 0),
+       GPU_DEVICE_ATI =        (1 << 1),
+       GPU_DEVICE_INTEL =      (1 << 2),
+       GPU_DEVICE_SOFTWARE =   (1 << 3),
+       GPU_DEVICE_UNKNOWN =    (1 << 4),
        GPU_DEVICE_ANY =        (0xff)
 } GPUDeviceType;
 
 typedef enum GPUOSType {
-       GPU_OS_WIN =            (1<<8),
-       GPU_OS_MAC =            (1<<9),
-       GPU_OS_UNIX =           (1<<10),
+       GPU_OS_WIN =            (1 << 8),
+       GPU_OS_MAC =            (1 << 9),
+       GPU_OS_UNIX =           (1 << 10),
        GPU_OS_ANY =            (0xff00)
 } GPUOSType;
 
 typedef enum GPUDriverType {
-       GPU_DRIVER_OFFICIAL =   (1<<16),
-       GPU_DRIVER_OPENSOURCE = (1<<17),
-       GPU_DRIVER_SOFTWARE =   (1<<18),
+       GPU_DRIVER_OFFICIAL =   (1 << 16),
+       GPU_DRIVER_OPENSOURCE = (1 << 17),
+       GPU_DRIVER_SOFTWARE =   (1 << 18),
        GPU_DRIVER_ANY =        (0xff0000)
 } GPUDriverType;
 
index 973da5d9608bb9e2f7ed2566552221bb01ea8320..2719b8fa6a871e323762002da56989107ff41e80 100644 (file)
@@ -62,7 +62,9 @@ void GPU_framebuffer_bind_no_save(GPUFrameBuffer *fb, int slot);
 bool GPU_framebuffer_bound(GPUFrameBuffer *fb);
 
 void GPU_framebuffer_restore(void);
-void GPU_framebuffer_blur(GPUFrameBuffer *fb, struct GPUTexture *tex, GPUFrameBuffer *blurfb, struct GPUTexture *blurtex);
+void GPU_framebuffer_blur(
+        GPUFrameBuffer *fb, struct GPUTexture *tex,
+        GPUFrameBuffer *blurfb, struct GPUTexture *blurtex);
 
 /* GPU OffScreen
  * - wrapper around framebuffer and texture for simple offscreen drawing
index 25a4f33b526df5d039cb4e9e4c51cc04bde59f67..40b32862e9f92a45bc1e6b7052834885efbf9c6a 100644 (file)
@@ -214,8 +214,12 @@ void GPU_material_free(struct ListBase *gpumaterial);
 void GPU_materials_free(void);
 
 bool GPU_lamp_override_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma);
-void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4], float cameraborder[4], bool scenelock);
-void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[4][4], float obcol[4], float autobumpscale, GPUParticleInfo *pi);
+void GPU_material_bind(
+        GPUMaterial *material, int oblay, int viewlay, double time, int mipmap,
+        float viewmat[4][4], float viewinv[4][4], float cameraborder[4], bool scenelock);
+void GPU_material_bind_uniforms(
+        GPUMaterial *material, float obmat[4][4], float obcol[4],
+        float autobumpscale, GPUParticleInfo *pi);
 void GPU_material_unbind(GPUMaterial *material);
 bool GPU_material_bound(GPUMaterial *material);
 struct Scene *GPU_material_scene(GPUMaterial *material);
@@ -269,7 +273,8 @@ typedef struct GPUInputUniform {
        struct Image *image;      /* when type=GPU_DYNAMIC_SAMPLER_2DIMAGE */
        int texnumber;            /* when type=GPU_DYNAMIC_SAMPLER, texture number: 0.. */
        unsigned char *texpixels; /* for internally generated texture, pixel data in RGBA format */
-       int texsize;              /* size in pixel of the texture in texpixels buffer: for 2D textures, this is S and T size (square texture) */
+       int texsize;              /* size in pixel of the texture in texpixels buffer:
+                                  * for 2D textures, this is S and T size (square texture) */
 } GPUInputUniform;
 
 typedef struct GPUInputAttribute {
@@ -307,7 +312,9 @@ void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float ener
 void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2);
 void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend);
 int GPU_lamp_shadow_layer(GPULamp *lamp);
-GPUNodeLink *GPU_lamp_get_data(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **col, GPUNodeLink **lv, GPUNodeLink **dist, GPUNodeLink **shadow, GPUNodeLink **energy);
+GPUNodeLink *GPU_lamp_get_data(
+        GPUMaterial *mat, GPULamp *lamp,
+        GPUNodeLink **r_col, GPUNodeLink **r_lv, GPUNodeLink **r_dist, GPUNodeLink **r_shadow, GPUNodeLink **r_energy);
 
 /* World */
 void GPU_mist_update_enable(short enable);
@@ -334,4 +341,3 @@ void GPU_material_update_fvar_offset(GPUMaterial *gpu_material,
 #endif
 
 #endif /*__GPU_MATERIAL_H__*/
-
index 5dff711633644a9a2a3bfa1da8df21505feeb3c6..6a16b5b7456145d5d222d057cd82ed3e199b2e4d 100644 (file)
@@ -40,19 +40,9 @@ enum {
        GPU_SELECT_NEAREST_SECOND_PASS      = 3,
 };
 
-/* initialize and provide buffer for results */
 void GPU_select_begin(unsigned int *buffer, unsigned int bufsize, rctf *input, char mode, int oldhits);
-
-/* loads a new selection id and ends previous query, if any. In second pass of selection it also returns
- * if id has been hit on the first pass already. Thus we can skip drawing un-hit objects IMPORTANT: We rely on the order of object rendering on passes to be
- * the same for this to work */
 bool GPU_select_load_id(unsigned int id);
-
-/* cleanup and flush selection results to buffer. Return number of hits and hits in buffer.
- * if dopass is true, we will do a second pass with occlusion queries to get the closest hit */
 unsigned int GPU_select_end(void);
-
-/* has user activated? */
 bool GPU_select_query_check_active(void);
 
 #endif
index b80c425818dc3acca209e4eb23d5eca3f542bf29..6464fb7454a6d401926a9712f1e0b7c8ce783335 100644 (file)
@@ -56,20 +56,26 @@ void GPU_program_unbind(GPUProgram *);
  * - only for fragment shaders now
  * - must call texture bind before setting a texture as uniform! */
 
-GPUShader *GPU_shader_create(const char *vertexcode, const char *fragcode, const char *geocode, const char *libcode, const char *defines, int input, int output, int number);
 enum {
        GPU_SHADER_FLAGS_NONE = 0,
        GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV = (1 << 0),
 };
-GPUShader *GPU_shader_create_ex(const char *vertexcode,
-                                const char *fragcode,
-                                const char *geocode,
-                                const char *libcode,
-                                const char *defines,
-                                int input,
-                                int output,
-                                int number,
-                                const int flags);
+
+GPUShader *GPU_shader_create(
+        const char *vertexcode,
+        const char *fragcode,
+        const char *geocode,
+        const char *libcode,
+        const char *defines,
+        int input, int output, int number);
+GPUShader *GPU_shader_create_ex(
+        const char *vertexcode,
+        const char *fragcode,
+        const char *geocode,
+        const char *libcode,
+        const char *defines,
+        int input, int output, int number,
+        const int flags);
 void GPU_shader_free(GPUShader *shader);
 
 void GPU_shader_bind(GPUShader *shader);
index 5300061396cf9b6b6f56a69371b3d7e1c3ea2ce9..4166aaf293d332441aa298ede2c2e05fffb5ef21 100644 (file)
@@ -68,10 +68,11 @@ GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]);
 GPUTexture *GPU_texture_create_vsm_shadow_map(int size, char err_out[256]);
 GPUTexture *GPU_texture_create_2D_procedural(int w, int h, const float *pixels, bool repeat, char err_out[256]);
 GPUTexture *GPU_texture_create_1D_procedural(int w, const float *pixels, char err_out[256]);
-GPUTexture *GPU_texture_create_2D_multisample(int w, int h, const float *pixels, GPUHDRType hdr, int samples, char err_out[256]);
+GPUTexture *GPU_texture_create_2D_multisample(
+        int w, int h, const float *pixels, GPUHDRType hdr, int samples, char err_out[256]);
 GPUTexture *GPU_texture_create_depth_multisample(int w, int h, int samples, char err_out[256]);
-GPUTexture *GPU_texture_from_blender(struct Image *ima,
-       struct ImageUser *iuser, bool is_data, double time, int mipmap);
+GPUTexture *GPU_texture_from_blender(
+        struct Image *ima, struct ImageUser *iuser, bool is_data, double time, int mipmap);
 GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap);
 void GPU_invalid_tex_init(void);
 void GPU_invalid_tex_bind(int mode);
index 8a3658931928219fd789c23f5a39676f516c6f33..4a27965aee1bd077970911994f6a9891c0230335 100644 (file)
@@ -337,7 +337,7 @@ static GPUShader *gpu_basic_shader(int options)
 
        if (!shader && !GPU_MATERIAL_STATE.failed_shaders[options]) {
                /* create shader if it doesn't exist yet */
-               char defines[64*GPU_SHADER_OPTIONS_NUM] = "";
+               char defines[64 * GPU_SHADER_OPTIONS_NUM] = "";
 
                if (options & GPU_SHADER_USE_COLOR)
                        strcat(defines, "#define USE_COLOR\n");
@@ -415,7 +415,7 @@ void GPU_basic_shader_bind(int options)
                }
 
                if (options & GPU_SHADER_TEXTURE_2D) {
-                       GLint env_mode = (options & (GPU_SHADER_USE_COLOR|GPU_SHADER_LIGHTING)) ? GL_MODULATE : GL_REPLACE;
+                       GLint env_mode = (options & (GPU_SHADER_USE_COLOR | GPU_SHADER_LIGHTING)) ? GL_MODULATE : GL_REPLACE;
                        glEnable(GL_TEXTURE_2D);
                        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, env_mode);
                }
@@ -476,7 +476,7 @@ void GPU_basic_shader_light_set(int light_num, GPULightData *light)
        if (light) {
                float position[4], diffuse[4], specular[4];
 
-               glEnable(GL_LIGHT0+light_num);
+               glEnable(GL_LIGHT0 + light_num);
 
                /* position */
                if (light->type == GPU_LIGHT_SUN) {
@@ -487,37 +487,37 @@ void GPU_basic_shader_light_set(int light_num, GPULightData *light)
                        copy_v3_v3(position, light->position);
                        position[3] = 1.0f;
                }
-               glLightfv(GL_LIGHT0+light_num, GL_POSITION, position);
+               glLightfv(GL_LIGHT0 + light_num, GL_POSITION, position);
 
                /* energy */
                copy_v3_v3(diffuse, light->diffuse);
                copy_v3_v3(specular, light->specular);
                diffuse[3] = 1.0f;
                specular[3] = 1.0f;
-               glLightfv(GL_LIGHT0+light_num, GL_DIFFUSE, diffuse);
-               glLightfv(GL_LIGHT0+light_num, GL_SPECULAR, specular);
+               glLightfv(GL_LIGHT0 + light_num, GL_DIFFUSE, diffuse);
+               glLightfv(GL_LIGHT0 + light_num, GL_SPECULAR, specular);
 
                /* attenuation */
                if (light->type == GPU_LIGHT_SUN) {
-                       glLightf(GL_LIGHT0+light_num, GL_CONSTANT_ATTENUATION, 1.0f);
-                       glLightf(GL_LIGHT0+light_num, GL_LINEAR_ATTENUATION, 0.0f);
-                       glLightf(GL_LIGHT0+light_num, GL_QUADRATIC_ATTENUATION, 0.0f);
+                       glLightf(GL_LIGHT0 + light_num, GL_CONSTANT_ATTENUATION, 1.0f);
+                       glLightf(GL_LIGHT0 + light_num, GL_LINEAR_ATTENUATION, 0.0f);
+                       glLightf(GL_LIGHT0 + light_num, GL_QUADRATIC_ATTENUATION, 0.0f);
                }
                else {
-                       glLightf(GL_LIGHT0+light_num, GL_CONSTANT_ATTENUATION, light->constant_attenuation);
-                       glLightf(GL_LIGHT0+light_num, GL_LINEAR_ATTENUATION, light->linear_attenuation);
-                       glLightf(GL_LIGHT0+light_num, GL_QUADRATIC_ATTENUATION, light->quadratic_attenuation);
+                       glLightf(GL_LIGHT0 + light_num, GL_CONSTANT_ATTENUATION, light->constant_attenuation);
+                       glLightf(GL_LIGHT0 + light_num, GL_LINEAR_ATTENUATION, light->linear_attenuation);
+                       glLightf(GL_LIGHT0 + light_num, GL_QUADRATIC_ATTENUATION, light->quadratic_attenuation);
                }
 
                /* spot */
-               glLightfv(GL_LIGHT0+light_num, GL_SPOT_DIRECTION, light->direction);
+               glLightfv(GL_LIGHT0 + light_num, GL_SPOT_DIRECTION, light->direction);
                if (light->type == GPU_LIGHT_SPOT) {
-                       glLightf(GL_LIGHT0+light_num, GL_SPOT_CUTOFF, light->spot_cutoff);
-                       glLightf(GL_LIGHT0+light_num, GL_SPOT_EXPONENT, light->spot_exponent);
+                       glLightf(GL_LIGHT0 + light_num, GL_SPOT_CUTOFF, light->spot_cutoff);
+                       glLightf(GL_LIGHT0 + light_num, GL_SPOT_EXPONENT, light->spot_exponent);
                }
                else {
-                       glLightf(GL_LIGHT0+light_num, GL_SPOT_CUTOFF, 180.0f);
-                       glLightf(GL_LIGHT0+light_num, GL_SPOT_EXPONENT, 0.0f);
+                       glLightf(GL_LIGHT0 + light_num, GL_SPOT_CUTOFF, 180.0f);
+                       glLightf(GL_LIGHT0 + light_num, GL_SPOT_EXPONENT, 0.0f);
                }
 
                GPU_MATERIAL_STATE.lights_enabled |= light_bit;
@@ -529,18 +529,18 @@ void GPU_basic_shader_light_set(int light_num, GPULightData *light)
                        /* glsl shader needs these zero to skip them */
                        const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 
-                       glLightfv(GL_LIGHT0+light_num, GL_POSITION, zero);
-                       glLightfv(GL_LIGHT0+light_num, GL_DIFFUSE, zero);
-                       glLightfv(GL_LIGHT0+light_num, GL_SPECULAR, zero);
+                       glLightfv(GL_LIGHT0 + light_num, GL_POSITION, zero);
+                       glLightfv(GL_LIGHT0 + light_num, GL_DIFFUSE, zero);
+                       glLightfv(GL_LIGHT0 + light_num, GL_SPECULAR, zero);
                }
 
-               glDisable(GL_LIGHT0+light_num);
+               glDisable(GL_LIGHT0 + light_num);
        }
 }
 
 void GPU_basic_shader_light_set_viewer(bool local)
 {
-       glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (local)? GL_TRUE: GL_FALSE);
+       glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, (local) ? GL_TRUE: GL_FALSE);
 }
 
 void GPU_basic_shader_stipple(GPUBasicShaderStipple stipple_id)
@@ -549,46 +549,46 @@ void GPU_basic_shader_stipple(GPUBasicShaderStipple stipple_id)
                glUniform1i(GPU_shader_get_uniform(gpu_basic_shader(GPU_MATERIAL_STATE.bound_options), "stipple_id"), stipple_id);
        }
        else {
-               switch(stipple_id) {
-               case GPU_SHADER_STIPPLE_HALFTONE:
-                       glPolygonStipple(stipple_halftone);
-                       return;
-               case GPU_SHADER_STIPPLE_QUARTTONE:
-                       glPolygonStipple(stipple_quarttone);
-                       return;
-               case GPU_SHADER_STIPPLE_CHECKER_8PX:
-                       glPolygonStipple(stipple_checker_8px);
-                       return;
-               case GPU_SHADER_STIPPLE_HEXAGON:
-                       glPolygonStipple(stipple_hexagon);
-                       return;
-               case GPU_SHADER_STIPPLE_DIAG_STRIPES_SWAP:
-                       glPolygonStipple(stipple_diag_stripes_neg);
-                       return;
-               case GPU_SHADER_STIPPLE_DIAG_STRIPES:
-                       glPolygonStipple(stipple_diag_stripes_pos);
-                       return;
-               case GPU_SHADER_STIPPLE_S3D_INTERLACE_ROW:
-                       glPolygonStipple(stipple_interlace_row);
-                       return;
-               case GPU_SHADER_STIPPLE_S3D_INTERLACE_ROW_SWAP:
-                       glPolygonStipple(stipple_interlace_row_swap);
-                       return;
-               case GPU_SHADER_STIPPLE_S3D_INTERLACE_COLUMN:
-                       glPolygonStipple(stipple_interlace_column);
-                       return;
-               case GPU_SHADER_STIPPLE_S3D_INTERLACE_COLUMN_SWAP:
-                       glPolygonStipple(stipple_interlace_column_swap);
-                       return;
-               case GPU_SHADER_STIPPLE_S3D_INTERLACE_CHECKER:
-                       glPolygonStipple(stipple_interlace_checker);
-                       return;
-               case GPU_SHADER_STIPPLE_S3D_INTERLACE_CHECKER_SWAP:
-                       glPolygonStipple(stipple_interlace_checker_swap);
-                       return;
-               default:
-                       glPolygonStipple(stipple_hexagon);
-                       return;
+               switch (stipple_id) {
+                       case GPU_SHADER_STIPPLE_HALFTONE:
+                               glPolygonStipple(stipple_halftone);
+                               return;
+                       case GPU_SHADER_STIPPLE_QUARTTONE:
+                               glPolygonStipple(stipple_quarttone);
+                               return;
+                       case GPU_SHADER_STIPPLE_CHECKER_8PX:
+                               glPolygonStipple(stipple_checker_8px);
+                               return;
+                       case GPU_SHADER_STIPPLE_HEXAGON:
+                               glPolygonStipple(stipple_hexagon);
+                               return;
+                       case GPU_SHADER_STIPPLE_DIAG_STRIPES_SWAP:
+                               glPolygonStipple(stipple_diag_stripes_neg);
+                               return;
+                       case GPU_SHADER_STIPPLE_DIAG_STRIPES:
+                               glPolygonStipple(stipple_diag_stripes_pos);
+                               return;
+                       case GPU_SHADER_STIPPLE_S3D_INTERLACE_ROW:
+                               glPolygonStipple(stipple_interlace_row);
+                               return;
+                       case GPU_SHADER_STIPPLE_S3D_INTERLACE_ROW_SWAP:
+                               glPolygonStipple(stipple_interlace_row_swap);
+                               return;
+                       case GPU_SHADER_STIPPLE_S3D_INTERLACE_COLUMN:
+                               glPolygonStipple(stipple_interlace_column);
+                               return;
+                       case GPU_SHADER_STIPPLE_S3D_INTERLACE_COLUMN_SWAP:
+                               glPolygonStipple(stipple_interlace_column_swap);
+                               return;
+                       case GPU_SHADER_STIPPLE_S3D_INTERLACE_CHECKER:
+                               glPolygonStipple(stipple_interlace_checker);
+                               return;
+                       case GPU_SHADER_STIPPLE_S3D_INTERLACE_CHECKER_SWAP:
+                               glPolygonStipple(stipple_interlace_checker_swap);
+                               return;
+                       default:
+                               glPolygonStipple(stipple_hexagon);
+                               return;
                }
        }
 }
index a2a604f0d401ed0639a3320ce0f620f26c57acd4..45a2632a6fa8140fb4b751a8a2114f486d0bf2f8 100644 (file)
@@ -579,23 +579,24 @@ static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBuffer
 /* get the amount of space to allocate for a buffer of a particular type */
 static size_t gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type)
 {
+       const int components = gpu_buffer_type_settings[type].num_components;
        switch (type) {
                case GPU_BUFFER_VERTEX:
-                       return sizeof(float) * gpu_buffer_type_settings[type].num_components * (dm->drawObject->tot_loop_verts + dm->drawObject->tot_loose_point);
+                       return sizeof(float) * components * (dm->drawObject->tot_loop_verts + dm->drawObject->tot_loose_point);
                case GPU_BUFFER_NORMAL:
-                       return sizeof(short) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_loop_verts;
+                       return sizeof(short) * components * dm->drawObject->tot_loop_verts;
                case GPU_BUFFER_COLOR:
-                       return sizeof(char) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_loop_verts;
+                       return sizeof(char) * components * dm->drawObject->tot_loop_verts;
                case GPU_BUFFER_UV:
-                       return sizeof(float) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_loop_verts;
+                       return sizeof(float) * components * dm->drawObject->tot_loop_verts;
                case GPU_BUFFER_UV_TEXPAINT:
-                       return sizeof(float) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_loop_verts;
+                       return sizeof(float) * components * dm->drawObject->tot_loop_verts;
                case GPU_BUFFER_EDGE:
-                       return sizeof(int) * gpu_buffer_type_settings[type].num_components * dm->drawObject->totedge;
+                       return sizeof(int) * components * dm->drawObject->totedge;
                case GPU_BUFFER_UVEDGE:
-                       return sizeof(int) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_loop_verts;
+                       return sizeof(int) * components * dm->drawObject->tot_loop_verts;
                case GPU_BUFFER_TRIANGLES:
-                       return sizeof(int) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_triangle_point;
+                       return sizeof(int) * components * dm->drawObject->tot_triangle_point;
                default:
                        return -1;
        }
@@ -1780,8 +1781,8 @@ void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
 
                        buffers->tot_tri = tottri;
                        buffers->index_type = (use_short ?
-                                                                  GL_UNSIGNED_SHORT :
-                                                                  GL_UNSIGNED_INT);
+                                              GL_UNSIGNED_SHORT :
+                                              GL_UNSIGNED_INT);
                }
                else {
                        /* Memory map failed */
index 1db44c5b3a97fa3949eb38e97826729b729e52e1..857b339c3a3a5f79b97f60ee76e0f9d1ecfdc09f 100644 (file)
@@ -177,10 +177,12 @@ static void gpu_parse_functions_string(GHash *hash, char *code)
                                }
                        }
 
-                       if (!type && gpu_str_prefix(code, "sampler2DShadow"))
-                               type= GPU_SHADOW2D;
-                       if (!type && gpu_str_prefix(code, "sampler2D"))
-                               type= GPU_TEX2D;
+                       if (!type && gpu_str_prefix(code, "sampler2DShadow")) {
+                               type = GPU_SHADOW2D;
+                       }
+                       if (!type && gpu_str_prefix(code, "sampler2D")) {
+                               type = GPU_TEX2D;
+                       }
 
                        if (type) {
                                /* add parameter */
@@ -497,10 +499,11 @@ static int codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes)
                for (input = node->inputs.first; input; input = input->next) {
                        if ((input->source == GPU_SOURCE_TEX) || (input->source == GPU_SOURCE_TEX_PIXEL)) {
                                /* create exactly one sampler for each texture */
-                               if (codegen_input_has_texture(input) && input->bindtex)
+                               if (codegen_input_has_texture(input) && input->bindtex) {
                                        BLI_dynstr_appendf(ds, "uniform %s samp%d;\n",
-                                               (input->textype == GPU_TEX2D) ? "sampler2D" : "sampler2DShadow",
-                                               input->texid);
+                                                          (input->textype == GPU_TEX2D) ? "sampler2D" : "sampler2DShadow",
+                                                          input->texid);
+                               }
                        }
                        else if (input->source == GPU_SOURCE_BUILTIN) {
                                /* only define each builtin uniform/varying once */
@@ -570,15 +573,16 @@ static void codegen_declare_tmps(DynStr *ds, ListBase *nodes)
                                if (codegen_input_has_texture(input) && input->definetex) {
                                        BLI_dynstr_appendf(ds, "\tvec4 tex%d = texture2D(", input->texid);
                                        BLI_dynstr_appendf(ds, "samp%d, gl_TexCoord[%d].st);\n",
-                                               input->texid, input->texid);
+                                                          input->texid, input->texid);
                                }
                        }
                }
 
                /* declare temporary variables for node output storage */
-               for (output = node->outputs.first; output; output = output->next)
+               for (output = node->outputs.first; output; output = output->next) {
                        BLI_dynstr_appendf(ds, "\t%s tmp%d;\n",
-                               GPU_DATATYPE_STR[output->type], output->id);
+                                          GPU_DATATYPE_STR[output->type], output->id);
+               }
        }
 
        BLI_dynstr_append(ds, "\n");
@@ -770,8 +774,12 @@ static char *code_generate_vertex(ListBase *nodes, const GPUMatType type)
 #ifdef WITH_OPENSUBDIV
                                        BLI_dynstr_appendf(ds, "#ifndef USE_OPENSUBDIV\n");
 #endif
-                                       BLI_dynstr_appendf(ds, "\tvar%d.xyz = normalize(gl_NormalMatrix * att%d.xyz);\n", input->attribid, input->attribid);
-                                       BLI_dynstr_appendf(ds, "\tvar%d.w = att%d.w;\n", input->attribid, input->attribid);
+                                       BLI_dynstr_appendf(
+                                               ds, "\tvar%d.xyz = normalize(gl_NormalMatrix * att%d.xyz);\n",
+                                               input->attribid, input->attribid);
+                                       BLI_dynstr_appendf(
+                                               ds, "\tvar%d.w = att%d.w;\n",
+                                               input->attribid, input->attribid);
 #ifdef WITH_OPENSUBDIV
                                        BLI_dynstr_appendf(ds, "#endif\n");
 #endif
@@ -1032,7 +1040,7 @@ void GPU_pass_update_uniforms(GPUPass *pass)
                if (!(input->ima || input->tex || input->prv)) {
                        if (input->dynamictype == GPU_DYNAMIC_MAT_HARD) {
                                // The hardness is actually a short pointer, so we convert it here
-                               float val = (float)(*(short*)input->dynamicvec);
+                               float val = (float)(*(short *)input->dynamicvec);
                                GPU_shader_uniform_vector(shader, input->shaderloc, 1, 1, &val);
                        }
                        else {
@@ -1205,7 +1213,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const GPUType
                input->type = type;
                input->source = GPU_SOURCE_VEC_UNIFORM;
 
-               memcpy(input->vec, link->ptr1, type*sizeof(float));
+               memcpy(input->vec, link->ptr1, type * sizeof(float));
                if (link->dynamic) {
                        input->dynamicvec = link->ptr1;
                        input->dynamictype = link->dynamictype;
@@ -1431,7 +1439,7 @@ GPUNodeLink *GPU_builtin(GPUBuiltin builtin)
 {
        GPUNodeLink *link = GPU_node_link_create();
 
-       link->builtin= builtin;
+       link->builtin = builtin;
 
        return link;
 }
@@ -1462,13 +1470,13 @@ bool GPU_link(GPUMaterial *mat, const char *name, ...)
        node = GPU_node_begin(name);
 
        va_start(params, name);
-       for (i = 0; i<function->totparam; i++) {
+       for (i = 0; i < function->totparam; i++) {
                if (function->paramqual[i] != FUNCTION_QUAL_IN) {
-                       linkptr = va_arg(params, GPUNodeLink**);
+                       linkptr = va_arg(params, GPUNodeLink **);
                        gpu_node_output(node, function->paramtype[i], linkptr);
                }
                else {
-                       link = va_arg(params, GPUNodeLink*);
+                       link = va_arg(params, GPUNodeLink *);
                        gpu_node_input_link(node, link, function->paramtype[i]);
                }
        }
@@ -1512,10 +1520,10 @@ bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNod
        }
 
        va_start(params, out);
-       for (i = 0; i<function->totparam; i++) {
+       for (i = 0; i < function->totparam; i++) {
                if (function->paramqual[i] != FUNCTION_QUAL_IN) {
                        if (totout == 0) {
-                               linkptr = va_arg(params, GPUNodeLink**);
+                               linkptr = va_arg(params, GPUNodeLink **);
                                gpu_node_output(node, function->paramtype[i], linkptr);
                        }
                        else
@@ -1523,7 +1531,7 @@ bool GPU_stack_link(GPUMaterial *mat, const char *name, GPUNodeStack *in, GPUNod
                }
                else {
                        if (totin == 0) {
-                               link = va_arg(params, GPUNodeLink*);
+                               link = va_arg(params, GPUNodeLink *);
                                if (link->socket)
                                        gpu_node_input_socket(node, link->socket);
                                else
@@ -1600,9 +1608,10 @@ static void gpu_nodes_prune(ListBase *nodes, GPUNodeLink *outlink)
        }
 }
 
-GPUPass *GPU_generate_pass(ListBase *nodes, GPUNodeLink *outlink,
-                                                  GPUVertexAttribs *attribs, int *builtins,
-                                                  const GPUMatType type, const char *UNUSED(name), const bool use_opensubdiv)
+GPUPass *GPU_generate_pass(
+        ListBase *nodes, GPUNodeLink *outlink,
+        GPUVertexAttribs *attribs, int *builtins,
+        const GPUMatType type, const char *UNUSED(name), const bool use_opensubdiv)
 {
        GPUShader *shader;
        GPUPass *pass;
index 05968bf1e4c04555604592886bd1bbc1810e1a0f..04802d804e6dc6bd4daa3027acd44fcb69903192 100644 (file)
@@ -38,7 +38,6 @@
 #include "BLI_linklist.h"
 
 #include "BLI_rand.h"
-#include "BLI_listbase.h"
 
 #include "DNA_vec_types.h"
 #include "DNA_view3d_types.h"
@@ -79,7 +78,8 @@ struct GPUFX {
        /* texture used for jittering for various effects */
        GPUTexture *jitter_buffer;
 
-       /* all those buffers below have to coexist. Fortunately they are all quarter sized (1/16th of memory) of original framebuffer */
+       /* all those buffers below have to coexist.
+        * Fortunately they are all quarter sized (1/16th of memory) of original framebuffer */
        int dof_downsampled_w;
        int dof_downsampled_h;
 
@@ -282,7 +282,7 @@ void GPU_fx_compositor_destroy(GPUFX *fx)
 
 static GPUTexture * create_jitter_texture(void)
 {
-       float jitter [64 * 64][2];
+       float jitter[64 * 64][2];
        int i;
 
        for (i = 0; i < 64 * 64; i++) {
@@ -396,7 +396,7 @@ bool GPU_fx_compositor_initialize_passes(
        /* create textures for dof effect */
        if (fx_flag & GPU_FX_FLAG_DOF) {
                bool dof_high_quality = (fx_settings->dof->high_quality != 0) &&
-                                                               GPU_geometry_shader_support() && GPU_instanced_drawing_support();
+                                       GPU_geometry_shader_support() && GPU_instanced_drawing_support();
 
                /* cleanup buffers if quality setting has changed (no need to keep more buffers around than necessary ) */
                if (dof_high_quality != fx->dof_high_quality)
@@ -407,7 +407,8 @@ bool GPU_fx_compositor_initialize_passes(
                        fx->dof_downsampled_h = h / 2;
 
                        if (!fx->dof_half_downsampled_near || !fx->dof_nearfar_coc || !fx->dof_near_blur ||
-                           !fx->dof_far_blur || !fx->dof_half_downsampled_far) {
+                           !fx->dof_far_blur || !fx->dof_half_downsampled_far)
+                       {
 
                                if (!(fx->dof_half_downsampled_near = GPU_texture_create_2D(
                                      fx->dof_downsampled_w, fx->dof_downsampled_h, NULL, GPU_HDR_NONE, err_out)))
@@ -525,7 +526,7 @@ bool GPU_fx_compositor_initialize_passes(
                glPushAttrib(GL_SCISSOR_BIT);
                glEnable(GL_SCISSOR_TEST);
                glScissor(scissor_rect->xmin - rect->xmin, scissor_rect->ymin - rect->ymin,
-                                 w_sc, h_sc);
+                         w_sc, h_sc);
                fx->restore_stencil = true;
        }
        else {
@@ -565,7 +566,9 @@ void GPU_fx_compositor_setup_XRay_pass(GPUFX *fx, bool do_xray)
        char err_out[256];
 
        if (do_xray) {
-               if (!fx->depth_buffer_xray && !(fx->depth_buffer_xray = GPU_texture_create_depth(fx->gbuffer_dim[0], fx->gbuffer_dim[1], err_out))) {
+               if (!fx->depth_buffer_xray &&
+                   !(fx->depth_buffer_xray = GPU_texture_create_depth(fx->gbuffer_dim[0], fx->gbuffer_dim[1], err_out)))
+               {
                        printf("%.256s\n", err_out);
                        cleanup_fx_gl_data(fx, true);
                        return;
@@ -644,7 +647,9 @@ void GPU_fx_compositor_XRay_resolve(GPUFX *fx)
 }
 
 
-bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, struct Scene *scene, struct GPUOffScreen *ofs)
+bool GPU_fx_do_composite_pass(
+        GPUFX *fx, float projmat[4][4], bool is_persp,
+        struct Scene *scene, struct GPUOffScreen *ofs)
 {
        GPUTexture *src, *target;
        int numslots = 0;
@@ -801,7 +806,8 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
                /* we want radius here for the aperture number  */
                float aperture = 0.5f * scale_camera * fx_dof->focal_length / fx_dof->fstop;
 
-               dof_params[0] = aperture * fabsf(scale_camera * fx_dof->focal_length / ((fx_dof->focus_distance / scale) - scale_camera * fx_dof->focal_length));
+               dof_params[0] = aperture * fabsf(scale_camera * fx_dof->focal_length /
+                                                ((fx_dof->focus_distance / scale) - scale_camera * fx_dof->focal_length));
                dof_params[1] = fx_dof->focus_distance / scale;
                dof_params[2] = fx->gbuffer_dim[0] / (scale_camera * fx_dof->sensor);
                dof_params[3] = fx_dof->num_blades;
@@ -1018,9 +1024,12 @@ bool GPU_fx_do_composite_pass(GPUFX *fx, float projmat[4][4], bool is_persp, str
                else {
                        GPUShader *dof_shader_pass1, *dof_shader_pass2, *dof_shader_pass3, *dof_shader_pass4, *dof_shader_pass5;
 
-                       /* DOF effect has many passes but most of them are performed on a texture whose dimensions are 4 times less than the original
-                        * (16 times lower than original screen resolution). Technique used is not very exact but should be fast enough and is based
-                        * on "Practical Post-Process Depth of Field" see http://http.developer.nvidia.com/GPUGems3/gpugems3_ch28.html */
+                       /* DOF effect has many passes but most of them are performed
+                        * on a texture whose dimensions are 4 times less than the original
+                        * (16 times lower than original screen resolution).
+                        * Technique used is not very exact but should be fast enough and is based
+                        * on "Practical Post-Process Depth of Field"
+                        * see http://http.developer.nvidia.com/GPUGems3/gpugems3_ch28.html */
                        dof_shader_pass1 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_ONE, is_persp);
                        dof_shader_pass2 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_TWO, is_persp);
                        dof_shader_pass3 = GPU_shader_get_builtin_fx_shader(GPU_SHADER_FX_DEPTH_OF_FIELD_PASS_THREE, is_persp);
index ce1ddafa3e4944fca71e24a463ddd71fefb5c05f..da2082677a37fab579bbfe8f17d1e7bc7b94245e 100644 (file)
@@ -276,7 +276,9 @@ void GPU_string_marker(size_t length, const char *buf)
 #ifndef WITH_GLEW_ES
 #ifndef GLEW_ES_ONLY
        if (GLEW_VERSION_4_3) {
-               glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, GL_DEBUG_SEVERITY_NOTIFICATION, length, buf);
+               glDebugMessageInsert(
+                       GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
+                       GL_DEBUG_SEVERITY_NOTIFICATION, length, buf);
 
                return;
        }
@@ -285,20 +287,26 @@ void GPU_string_marker(size_t length, const char *buf)
 
        if (GLEW_KHR_debug) {
 #ifndef GLEW_ES_ONLY
-               glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, GL_DEBUG_SEVERITY_NOTIFICATION, length, buf);
+               glDebugMessageInsert(
+                       GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
+                       GL_DEBUG_SEVERITY_NOTIFICATION, length, buf);
 #endif
                return;
        }
 
 #ifndef GLEW_ES_ONLY
        if (GLEW_ARB_debug_output) {
-               glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0, GL_DEBUG_SEVERITY_LOW_ARB, length, buf);
+               glDebugMessageInsertARB(
+                       GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0,
+                       GL_DEBUG_SEVERITY_LOW_ARB, length, buf);
 
                return;
        }
 
        if (GLEW_AMD_debug_output) {
-               glDebugMessageInsertAMD(GL_DEBUG_CATEGORY_APPLICATION_AMD, GL_DEBUG_SEVERITY_LOW_AMD, 0, length, buf);
+               glDebugMessageInsertAMD(
+                       GL_DEBUG_CATEGORY_APPLICATION_AMD, GL_DEBUG_SEVERITY_LOW_AMD, 0,
+                       length, buf);
 
                return;
        }
index 70ec035d9437c679cba4924d80517e7be5c737cf..95c019be4096da28934e8fd71df6a590bd704f98 100644 (file)
@@ -88,7 +88,6 @@
 #include "smoke_API.h"
 
 #ifdef WITH_OPENSUBDIV
-#  include "DNA_mesh_types.h"
 #  include "BKE_editmesh.h"
 
 #  include "gpu_codegen.h"
@@ -227,7 +226,7 @@ static bool is_power_of_2_resolution(int w, int h)
 
 static bool is_over_resolution_limit(int w, int h)
 {
-       int reslimit = (U.glreslimit != 0)?
+       int reslimit = (U.glreslimit != 0) ?
                min_ii(U.glreslimit, GPU_max_texture_size()) :
                GPU_max_texture_size();
 
@@ -236,7 +235,7 @@ static bool is_over_resolution_limit(int w, int h)
 
 static int smaller_power_of_2_limit(int num)
 {
-       int reslimit = (U.glreslimit != 0)?
+       int reslimit = (U.glreslimit != 0) ?
                min_ii(U.glreslimit, GPU_max_texture_size()) :
                GPU_max_texture_size();
        /* take texture clamping into account */
@@ -390,10 +389,11 @@ static void gpu_make_repbind(Image *ima)
                ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
        }
 
-       ima->totbind = ima->xrep*ima->yrep;
+       ima->totbind = ima->xrep * ima->yrep;
 
-       if (ima->totbind>1)
+       if (ima->totbind > 1) {
                ima->repbind = MEM_callocN(sizeof(int) * ima->totbind, "repbind");
+       }
 
        BKE_image_release_ibuf(ima, ibuf, NULL);
 }
@@ -508,7 +508,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, bool compare, boo
 
        /* initialize tile mode and number of repeats */
        GTS.ima = ima;
-       GTS.tilemode = (ima && (ima->tpageflag & (IMA_TILES|IMA_TWINANIM)));
+       GTS.tilemode = (ima && (ima->tpageflag & (IMA_TILES | IMA_TWINANIM)));
        GTS.tileXRep = 0;
        GTS.tileYRep = 0;
 
@@ -615,13 +615,15 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, bool compare, boo
                                        IMB_buffer_float_unpremultiply(srgb_frect, ibuf->x, ibuf->y);
                                        /* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */
                                        IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y);
-                                       frect = srgb_frect + texwinsy*ibuf->x + texwinsx;
+                                       frect = srgb_frect + texwinsy * ibuf->x + texwinsx;
+                               }
+                               else {
+                                       frect = ibuf->rect_float + texwinsy * ibuf->x + texwinsx;
                                }
-                               else
-                                       frect = ibuf->rect_float + texwinsy*ibuf->x + texwinsx;
                        }
-                       else
-                               rect = ibuf->rect + texwinsy*ibuf->x + texwinsx;
+                       else {
+                               rect = ibuf->rect + texwinsy * ibuf->x + texwinsx;
+                       }
                }
        }
        else {
@@ -635,9 +637,10 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, bool compare, boo
                        if (use_high_bit_depth) {
                                if (do_color_management) {
                                        frect = srgb_frect = MEM_mallocN(ibuf->x * ibuf->y * sizeof(*srgb_frect) * 4, "floar_buf_col_cor");
-                                       IMB_buffer_float_from_float(srgb_frect, ibuf->rect_float,
-                                                       ibuf->channels, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, true,
-                                                       ibuf->x, ibuf->y, ibuf->x, ibuf->x);
+                                       IMB_buffer_float_from_float(
+                                               srgb_frect, ibuf->rect_float,
+                                               ibuf->channels, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, true,
+                                               ibuf->x, ibuf->y, ibuf->x, ibuf->x);
                                        IMB_buffer_float_unpremultiply(srgb_frect, ibuf->x, ibuf->y);
                                        /* clamp buffer colors to 1.0 to avoid artifacts due to glu for hdr images */
                                        IMB_buffer_float_clamp(srgb_frect, ibuf->x, ibuf->y);
@@ -664,7 +667,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, bool compare, boo
        /* for tiles, copy only part of image into buffer */
        if (GTS.tilemode) {
                if (use_high_bit_depth) {
-                       ftilerect = MEM_mallocN(rectw*recth*sizeof(*ftilerect), "tilerect");
+                       ftilerect = MEM_mallocN(rectw * recth * sizeof(*ftilerect), "tilerect");
 
                        for (int y = 0; y < recth; y++) {
                                const float *frectrow = &frect[y * ibuf->x];
@@ -676,7 +679,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, bool compare, boo
                        frect = ftilerect;
                }
                else {
-                       tilerect = MEM_mallocN(rectw*recth*sizeof(*tilerect), "tilerect");
+                       tilerect = MEM_mallocN(rectw * recth * sizeof(*tilerect), "tilerect");
 
                        for (int y = 0; y < recth; y++) {
                                const unsigned *rectrow = &rect[y * ibuf->x];
@@ -730,7 +733,8 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *rect, float *frect, int
         * GPUs (OpenGL version >= 2.0) since they support non-power-of-two-textures 
         * Then don't bother scaling for hardware that supports NPOT textures! */
        if ((!GPU_full_non_power_of_two_support() && !is_power_of_2_resolution(rectw, recth)) ||
-               is_over_resolution_limit(rectw, recth)) {
+           is_over_resolution_limit(rectw, recth))
+       {
                rectw = smaller_power_of_2_limit(rectw);
                recth = smaller_power_of_2_limit(recth);
                
@@ -783,12 +787,15 @@ void GPU_create_gl_tex(unsigned int *bind, unsigned int *rect, float *frect, int
                                ImBuf *mip = ibuf->mipmap[i - 1];
                                if (use_high_bit_depth) {
                                        if (GLEW_ARB_texture_float)
-                                               glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16F_ARB, mip->x, mip->y, 0, GL_RGBA, GL_FLOAT, mip->rect_float);
+                                               glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16F_ARB, mip->x, mip->y,
+                                                            0, GL_RGBA, GL_FLOAT, mip->rect_float);
                                        else
-                                               glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16, mip->x, mip->y, 0, GL_RGBA, GL_FLOAT, mip->rect_float);
+                                               glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA16, mip->x, mip->y,
+                                                            0, GL_RGBA, GL_FLOAT, mip->rect_float);
                                }
                                else {
-                                       glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA8, mip->x, mip->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
+                                       glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA8, mip->x, mip->y,
+                                                    0, GL_RGBA, GL_UNSIGNED_BYTE, mip->rect);
                                }
                        }
                }
@@ -848,13 +855,13 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf)
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
 
        blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16;
-       for (i = 0; i < ibuf->dds_data.nummipmaps && (width||height); ++i) {
+       for (i = 0; i < ibuf->dds_data.nummipmaps && (width || height); ++i) {
                if (width == 0)
                        width = 1;
                if (height == 0)
                        height = 1;
 
-               size = ((width+3)/4)*((height+3)/4)*blocksize;
+               size = ((width + 3) / 4) * ((height + 3) / 4) * blocksize;
 
                glCompressedTexImage2D(GL_TEXTURE_2D, i, format, width, height,
                        0, size, ibuf->dds_data.data + offset);
@@ -874,7 +881,9 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf)
 #endif
 }
 
-void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, Image *ima, ImBuf *ibuf)
+void GPU_create_gl_tex_compressed(
+        unsigned int *bind, unsigned int *pix, int x, int y, int mipmap,
+        Image *ima, ImBuf *ibuf)
 {
 #ifndef WITH_DDS
        (void)ibuf;
@@ -1063,7 +1072,7 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
        ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
        
        if (ima->repbind || (GPU_get_mipmap() && !GTS.gpu_mipmap) || !ima->bindcode || !ibuf ||
-               (w == 0) || (h == 0))
+           (w == 0) || (h == 0))
        {
                /* these cases require full reload still */
                GPU_free_image(ima);
@@ -1314,7 +1323,7 @@ void GPU_free_image(Image *ima)
                ima->repbind = NULL;
        }
 
-       ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE|IMA_GLBIND_IS_DATA);
+       ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE | IMA_GLBIND_IS_DATA);
 }
 
 void GPU_free_images(void)
@@ -1419,8 +1428,9 @@ static struct GPUMaterialState {
 } GMS = {NULL};
 
 /* fixed function material, alpha handed by caller */
-static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob, const int new_shading_nodes, 
-                                  const bool dimdown)
+static void gpu_material_to_fixed(
+        GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob,
+        const int new_shading_nodes, const bool dimdown)
 {
        if (bmat->mode & MA_SHLESS) {
                copy_v3_v3(smat->diff, &bmat->r);
@@ -1489,7 +1499,9 @@ void GPU_end_dupli_object(void)
        GMS.dob = NULL;
 }
 
-void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, Object *ob, bool glsl, bool *do_alpha_after)
+void GPU_begin_object_materials(
+        View3D *v3d, RegionView3D *rv3d, Scene *scene, Object *ob,
+        bool glsl, bool *do_alpha_after)
 {
        Material *ma;
        GPUMaterial *gpumat;
@@ -1546,13 +1558,13 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
 
        GMS.two_sided_lighting = false;
        if (ob && ob->type == OB_MESH)
-               GMS.two_sided_lighting = (((Mesh*)ob->data)->flag & ME_TWOSIDED) != 0;
+               GMS.two_sided_lighting = (((Mesh *)ob->data)->flag & ME_TWOSIDED) != 0;
 
        GMS.gob = ob;
        GMS.gscene = scene;
        GMS.is_opensubdiv = use_opensubdiv;
        GMS.totmat = use_matcap ? 1 : ob->totcol + 1;  /* materials start from 1, default material is 0 */
-       GMS.glay = (v3d->localvd)? v3d->localvd->lay: v3d->lay; /* keep lamps visible in local view */
+       GMS.glay = (v3d->localvd) ? v3d->localvd->lay : v3d->lay; /* keep lamps visible in local view */
        GMS.gscenelock = (v3d->scenelock != 0);
        GMS.gviewmat = rv3d->viewmat;
        GMS.gviewinv = rv3d->viewinv;
@@ -1614,7 +1626,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
                        if (ma == NULL) ma = &defmaterial;
 
                        /* create glsl material if requested */
-                       gpumat = glsl? GPU_material_from_blender(GMS.gscene, ma, GMS.is_opensubdiv): NULL;
+                       gpumat = glsl ? GPU_material_from_blender(GMS.gscene, ma, GMS.is_opensubdiv) : NULL;
 
                        if (gpumat) {
                                /* do glsl only if creating it succeed, else fallback */
@@ -1627,7 +1639,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
 
                                if (GMS.use_alpha_pass && ((ma->mode & MA_TRANSP) || (new_shading_nodes && ma->alpha != 1.0f))) {
                                        GMS.matbuf[a].alpha = ma->alpha;
-                                       alphablend = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA;
+                                       alphablend = (ma->alpha == 1.0f) ? GPU_BLEND_SOLID: GPU_BLEND_ALPHA;
                                }
                                else {
                                        GMS.matbuf[a].alpha = 1.0f;
@@ -1746,7 +1758,9 @@ int GPU_object_material_bind(int nr, void *attribs)
                        if (GMS.dob)
                                GPU_get_particle_info(&partile_info);
 
-                       GPU_material_bind(gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT), GMS.gviewmat, GMS.gviewinv, GMS.gviewcamtexcofac, GMS.gscenelock);
+                       GPU_material_bind(
+                               gpumat, GMS.gob->lay, GMS.glay, 1.0, !(GMS.gob->mode & OB_MODE_TEXTURE_PAINT),
+                               GMS.gviewmat, GMS.gviewinv, GMS.gviewcamtexcofac, GMS.gscenelock);
 
                        auto_bump_scale = GMS.gob->derivedFinal != NULL ? GMS.gob->derivedFinal->auto_bump_scale : 1.0f;
                        GPU_material_bind_uniforms(gpumat, GMS.gob->obmat, GMS.gob->col, auto_bump_scale, &partile_info);
@@ -1755,7 +1769,7 @@ int GPU_object_material_bind(int nr, void *attribs)
                        /* for glsl use alpha blend mode, unless it's set to solid and
                         * we are already drawing in an alpha pass */
                        if (mat->game.alpha_blend != GPU_BLEND_SOLID)
-                               alphablend= mat->game.alpha_blend;
+                               alphablend = mat->game.alpha_blend;
 
                        if (GMS.is_alpha_pass) glDepthMask(1);
 
index 45bde9d73914c1c3b03da026288b396e567f88c1..dc39699e36face5b58545083933a0c56b74642ac 100644 (file)
@@ -147,7 +147,7 @@ void gpu_extensions_init(void)
        GG.colordepth = r + g + b; /* assumes same depth for RGB */
 
        if (GLEW_VERSION_3_2 || GLEW_ARB_texture_multisample) {
-               glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES , &GG.samples_color_texture_max);
+               glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &GG.samples_color_texture_max);
        }
 
        const char *vendor = (const char *)glGetString(GL_VENDOR);
@@ -163,9 +163,10 @@ void gpu_extensions_init(void)
                GG.driver = GPU_DRIVER_OFFICIAL;
        }
        else if (strstr(vendor, "Intel") ||
-               /* src/mesa/drivers/dri/intel/intel_context.c */
-               strstr(renderer, "Mesa DRI Intel") ||
-               strstr(renderer, "Mesa DRI Mobile Intel")) {
+                /* src/mesa/drivers/dri/intel/intel_context.c */
+                strstr(renderer, "Mesa DRI Intel") ||
+                strstr(renderer, "Mesa DRI Mobile Intel"))
+       {
                GG.device = GPU_DEVICE_INTEL;
                GG.driver = GPU_DRIVER_OFFICIAL;
        }
@@ -212,13 +213,13 @@ void gpu_extensions_init(void)
                GG.dfdyfactors[0] = 1.0;
                GG.dfdyfactors[1] = -1.0;
        }
-       else if (GG.device == GPU_DEVICE_INTEL && GG.os == GPU_OS_WIN  &&
-               (strstr(version, "4.0.0 - Build 10.18.10.3308") ||
-                strstr(version, "4.0.0 - Build 9.18.10.3186") ||
-                strstr(version, "4.0.0 - Build 9.18.10.3165") ||
-                strstr(version, "3.1.0 - Build 9.17.10.3347") ||
-                strstr(version, "3.1.0 - Build 9.17.10.4101") ||
-                strstr(version, "3.3.0 - Build 8.15.10.2618")))
+       else if ((GG.device == GPU_DEVICE_INTEL) && (GG.os == GPU_OS_WIN) &&
+                (strstr(version, "4.0.0 - Build 10.18.10.3308") ||
+                 strstr(version, "4.0.0 - Build 9.18.10.3186") ||
+                 strstr(version, "4.0.0 - Build 9.18.10.3165") ||
+                 strstr(version, "3.1.0 - Build 9.17.10.3347") ||
+                 strstr(version, "3.1.0 - Build 9.17.10.4101") ||
+                 strstr(version, "3.3.0 - Build 8.15.10.2618")))
        {
                GG.dfdyfactors[0] = -1.0;
                GG.dfdyfactors[1] = 1.0;
index 4ef7611a3f3e008e7ffcd185eeb71ab83c3becf0..c15e49a8ed124b5bf8b4360aeadff6eeee10bcf4 100644 (file)
@@ -44,7 +44,8 @@ static struct GPUFrameBufferGlobal {
        GLuint currentfb;
 } GG = {0};
 
-/* Number of maximum output slots. We support 4 outputs for now (usually we wouldn't need more to preserve fill rate) */
+/* Number of maximum output slots.
+ * We support 4 outputs for now (usually we wouldn't need more to preserve fill rate) */
 #define GPU_FB_MAX_SLOTS 4
 
 struct GPUFrameBuffer {
@@ -102,8 +103,11 @@ GPUFrameBuffer *GPU_framebuffer_create(void)
 {
        GPUFrameBuffer *fb;
 
-       if (!(GLEW_VERSION_3_0 || GLEW_ARB_framebuffer_object || (GLEW_EXT_framebuffer_object && GLEW_EXT_framebuffer_blit)))
+       if (!(GLEW_VERSION_3_0 || GLEW_ARB_framebuffer_object ||
+             (GLEW_EXT_framebuffer_object && GLEW_EXT_framebuffer_blit)))
+       {
                return NULL;
+       }
        
        fb = MEM_callocN(sizeof(GPUFrameBuffer), "GPUFrameBuffer");
        glGenFramebuffersEXT(1, &fb->object);
@@ -368,7 +372,9 @@ void GPU_framebuffer_restore(void)
        }
 }
 
-void GPU_framebuffer_blur(GPUFrameBuffer *fb, GPUTexture *tex, GPUFrameBuffer *blurfb, GPUTexture *blurtex)
+void GPU_framebuffer_blur(
+        GPUFrameBuffer *fb, GPUTexture *tex,
+        GPUFrameBuffer *blurfb, GPUTexture *blurtex)
 {
        const float scaleh[2] = {1.0f / GPU_texture_width(blurtex), 0.0f};
        const float scalev[2] = {0.0f, 1.0f / GPU_texture_height(tex)};
index 485b04841fed6a13bb0714d8affa401add3e5f23..2c5054c0d622ca3f7c34f3b99c7fa2f48881566a 100644 (file)
@@ -170,7 +170,9 @@ struct GPULamp {
 };
 
 /* Forward declaration so shade_light_textures() can use this, while still keeping the code somewhat organized */
-static void texture_rgb_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg, int blendtype, GPUNodeLink **in);
+static void texture_rgb_blend(
+        GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg,
+        int blendtype, GPUNodeLink **in);
 
 /* Functions */
 
@@ -301,7 +303,9 @@ bool GPU_lamp_override_visible(GPULamp *lamp, SceneRenderLayer *srl, Material *m
                return true;
 }
 
-void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4], float camerafactors[4], bool scenelock)
+void GPU_material_bind(
+        GPUMaterial *material, int oblay, int viewlay, double time, int mipmap,
+        float viewmat[4][4], float viewinv[4][4], float camerafactors[4], bool scenelock)
 {
        if (material->pass) {
                GPUShader *shader = GPU_pass_shader(material->pass);
@@ -315,8 +319,9 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim
                        for (LinkData *nlink = material->lamps.first; nlink; nlink = nlink->next) {
                                GPULamp *lamp = nlink->data;
                                
-                               if (!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay))
-                                       && GPU_lamp_override_visible(lamp, srl, material->ma)) {
+                               if (!lamp->hide && (lamp->lay & viewlay) && (!(lamp->mode & LA_LAYER) || (lamp->lay & oblay)) &&
+                                   GPU_lamp_override_visible(lamp, srl, material->ma))
+                               {
                                        lamp->dynenergy = lamp->energy;
                                        copy_v3_v3(lamp->dyncol, lamp->col);
                                }
@@ -342,8 +347,10 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim
                                }
                                
                                if (material->dynproperty & DYN_LAMP_PERSMAT) {
-                                       if (!GPU_lamp_has_shadow_buffer(lamp)) /* The lamp matrices are already updated if we're using shadow buffers */
+                                       /* The lamp matrices are already updated if we're using shadow buffers */
+                                       if (!GPU_lamp_has_shadow_buffer(lamp)) {
                                                GPU_lamp_update_buffer_mats(lamp);
+                                       }
                                        mul_m4_m4m4(lamp->dynpersmat, lamp->persmat, viewinv);
                                }
                        }
@@ -354,19 +361,19 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim
 
                /* handle per material built-ins */
                if (material->builtins & GPU_VIEW_MATRIX) {
-                       GPU_shader_uniform_vector(shader, material->viewmatloc, 16, 1, (float*)viewmat);
+                       GPU_shader_uniform_vector(shader, material->viewmatloc, 16, 1, (float *)viewmat);
                }
                if (material->builtins & GPU_INVERSE_VIEW_MATRIX) {
-                       GPU_shader_uniform_vector(shader, material->invviewmatloc, 16, 1, (float*)viewinv);
+                       GPU_shader_uniform_vector(shader, material->invviewmatloc, 16, 1, (float *)viewinv);
                }
                if (material->builtins & GPU_CAMERA_TEXCO_FACTORS) {
                        if (camerafactors) {
-                               GPU_shader_uniform_vector(shader, material->cameratexcofacloc, 4, 1, (float*)camerafactors);
+                               GPU_shader_uniform_vector(shader, material->cameratexcofacloc, 4, 1, (float *)camerafactors);
                        }
                        else {
                                /* use default, no scaling no offset */
                                float borders[4] = {1.0f, 1.0f, 0.0f, 0.0f};
-                               GPU_shader_uniform_vector(shader, material->cameratexcofacloc, 4, 1, (float*)borders);
+                               GPU_shader_uniform_vector(shader, material->cameratexcofacloc, 4, 1, (float *)borders);
                        }
                }
 
@@ -376,7 +383,9 @@ void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double tim
        }
 }
 
-void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[4][4], float obcol[4], float autobumpscale, GPUParticleInfo* pi)
+void GPU_material_bind_uniforms(
+        GPUMaterial *material, float obmat[4][4], float obcol[4],
+        float autobumpscale, GPUParticleInfo *pi)
 {
        if (material->pass) {
                GPUShader *shader = GPU_pass_shader(material->pass);
@@ -384,11 +393,11 @@ void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[4][4], float
 
                /* handle per object builtins */
                if (material->builtins & GPU_OBJECT_MATRIX) {
-                       GPU_shader_uniform_vector(shader, material->obmatloc, 16, 1, (float*)obmat);
+                       GPU_shader_uniform_vector(shader, material->obmatloc, 16, 1, (float *)obmat);
                }
                if (material->builtins & GPU_INVERSE_OBJECT_MATRIX) {
                        invert_m4_m4(invmat, obmat);
-                       GPU_shader_uniform_vector(shader, material->invobmatloc, 16, 1, (float*)invmat);
+                       GPU_shader_uniform_vector(shader, material->invobmatloc, 16, 1, (float *)invmat);
                }
                if (material->builtins & GPU_OBCOLOR) {
                        copy_v4_v4(col, obcol);
@@ -489,12 +498,15 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode
        /* from get_lamp_visibility */
        if (lamp->type == LA_SUN || lamp->type == LA_HEMI) {
                mat->dynproperty |= DYN_LAMP_VEC;
-               GPU_link(mat, "lamp_visibility_sun_hemi", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), lv, dist, &visifac);
+               GPU_link(mat, "lamp_visibility_sun_hemi",
+                        GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), lv, dist, &visifac);
                return visifac;
        }
        else {
                mat->dynproperty |= DYN_LAMP_CO;
-               GPU_link(mat, "lamp_visibility_other", GPU_builtin(GPU_VIEW_POSITION), GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob), lv, dist, &visifac);
+               GPU_link(mat, "lamp_visibility_other",
+                        GPU_builtin(GPU_VIEW_POSITION),
+                        GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob), lv, dist, &visifac);
 
                if (lamp->type == LA_AREA)
                        return visifac;
@@ -503,13 +515,18 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode
                        case LA_FALLOFF_CONSTANT:
                                break;
                        case LA_FALLOFF_INVLINEAR:
-                               GPU_link(mat, "lamp_falloff_invlinear", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac);
+                               GPU_link(mat, "lamp_falloff_invlinear",
+                                        GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac);
                                break;
                        case LA_FALLOFF_INVSQUARE:
-                               GPU_link(mat, "lamp_falloff_invsquare", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac);
+                               GPU_link(mat, "lamp_falloff_invsquare",
+                                        GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac);
                                break;
                        case LA_FALLOFF_SLIDERS:
-                               GPU_link(mat, "lamp_falloff_sliders", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), GPU_dynamic_uniform(&lamp->att1, GPU_DYNAMIC_LAMP_ATT1, lamp->ob), GPU_dynamic_uniform(&lamp->att2, GPU_DYNAMIC_LAMP_ATT2, lamp->ob), *dist, &visifac);
+                               GPU_link(mat, "lamp_falloff_sliders",
+                                        GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob),
+                                        GPU_dynamic_uniform(&lamp->att1, GPU_DYNAMIC_LAMP_ATT1, lamp->ob),
+                                        GPU_dynamic_uniform(&lamp->att2, GPU_DYNAMIC_LAMP_ATT2, lamp->ob), *dist, &visifac);
                                break;
                        case LA_FALLOFF_CURVE:
                        {
@@ -518,31 +535,41 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode
 
                                curvemapping_initialize(lamp->curfalloff);
                                curvemapping_table_RGBA(lamp->curfalloff, &array, &size);
-                               GPU_link(mat, "lamp_falloff_curve", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), GPU_texture(size, array), *dist, &visifac);
+                               GPU_link(mat, "lamp_falloff_curve",
+                                        GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob),
+                                        GPU_texture(size, array), *dist, &visifac);
 
                                break;
                        }
                }
 
                if (lamp->mode & LA_SPHERE)
-                       GPU_link(mat, "lamp_visibility_sphere", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, visifac, &visifac);
+                       GPU_link(mat, "lamp_visibility_sphere",
+                                GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob),
+                                *dist, visifac, &visifac);
 
                if (lamp->type == LA_SPOT) {
                        GPUNodeLink *inpr;
 
                        if (lamp->mode & LA_SQUARE) {
                                mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_IMAT;
-                               GPU_link(mat, "lamp_visibility_spot_square", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), GPU_dynamic_uniform((float*)lamp->dynimat, GPU_DYNAMIC_LAMP_DYNIMAT, lamp->ob),
+                               GPU_link(mat, "lamp_visibility_spot_square",
+                                        GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob),
+                                        GPU_dynamic_uniform((float *)lamp->dynimat, GPU_DYNAMIC_LAMP_DYNIMAT, lamp->ob),
                                GPU_dynamic_uniform((float *)lamp->spotvec, GPU_DYNAMIC_LAMP_SPOTSCALE, lamp->ob), *lv, &inpr);
                        }
                        else {
                                mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_IMAT;
-                               GPU_link(mat, "lamp_visibility_spot_circle", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob),
+                               GPU_link(mat, "lamp_visibility_spot_circle",
+                                        GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob),
                                GPU_dynamic_uniform((float *)lamp->dynimat, GPU_DYNAMIC_LAMP_DYNIMAT, lamp->ob),
                                GPU_dynamic_uniform((float *)lamp->spotvec, GPU_DYNAMIC_LAMP_SPOTSCALE, lamp->ob), *lv, &inpr);
                        }
                        
-                       GPU_link(mat, "lamp_visibility_spot", GPU_dynamic_uniform(&lamp->spotsi, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob), GPU_dynamic_uniform(&lamp->spotbl, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob), inpr, visifac, &visifac);
+                       GPU_link(mat, "lamp_visibility_spot",
+                                GPU_dynamic_uniform(&lamp->spotsi, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob),
+                                GPU_dynamic_uniform(&lamp->spotbl, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob),
+                                inpr, visifac, &visifac);
                }
 
                GPU_link(mat, "lamp_visibility_clamp", visifac, &visifac);
@@ -585,17 +612,21 @@ static void area_lamp_vectors(LampRen *lar)
 }
 #endif
 
-static void ramp_blend(GPUMaterial *mat, GPUNodeLink *fac, GPUNodeLink *col1, GPUNodeLink *col2, int type, GPUNodeLink **outcol)
+static void ramp_blend(
+        GPUMaterial *mat, GPUNodeLink *fac, GPUNodeLink *col1, GPUNodeLink *col2, int type,
+        GPUNodeLink **r_col)
 {
        static const char *names[] = {"mix_blend", "mix_add", "mix_mult", "mix_sub",
                "mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light",
                "mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat",
                "mix_val", "mix_color", "mix_soft", "mix_linear"};
 
-       GPU_link(mat, names[type], fac, col1, col2, outcol);
+       GPU_link(mat, names[type], fac, col1, col2, r_col);
 }
 
-static void do_colorband_blend(GPUMaterial *mat, ColorBand *coba, GPUNodeLink *fac, float rampfac, int type, GPUNodeLink *incol, GPUNodeLink **outcol)
+static void do_colorband_blend(
+        GPUMaterial *mat, ColorBand *coba, GPUNodeLink *fac, float rampfac, int type,
+        GPUNodeLink *incol, GPUNodeLink **r_col)
 {
        GPUNodeLink *tmp, *alpha, *col;
        float *array;
@@ -610,7 +641,7 @@ static void do_colorband_blend(GPUMaterial *mat, ColorBand *coba, GPUNodeLink *f
        GPU_link(mat, "math_multiply", alpha, GPU_uniform(&rampfac), &fac);
 
        /* blending method */
-       ramp_blend(mat, fac, incol, col, type, outcol);
+       ramp_blend(mat, fac, incol, col, type, r_col);
 }
 
 static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff)
@@ -620,7 +651,7 @@ static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff)
 
        if (!(mat->scene->gm.flag & GAME_GLSL_NO_RAMPS)) {
                if (ma->ramp_col) {
-                       if (ma->rampin_col==MA_RAMP_IN_RESULT) {
+                       if (ma->rampin_col == MA_RAMP_IN_RESULT) {
                                GPUNodeLink *fac;
                                GPU_link(mat, "ramp_rgbtobw", *diff, &fac);
                                
@@ -631,7 +662,9 @@ static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff)
        }
 }
 
-static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *rgb, GPUNodeLink **diff)
+static void add_to_diffuse(
+        GPUMaterial *mat, Material *ma, GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *rgb,
+        GPUNodeLink **r_diff)
 {
        GPUNodeLink *fac, *tmp, *addcol;
        
@@ -639,7 +672,7 @@ static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, G
            ma->ramp_col && (ma->mode & MA_RAMP_COL))
        {
                /* MA_RAMP_IN_RESULT is exceptional */
-               if (ma->rampin_col==MA_RAMP_IN_RESULT) {
+               if (ma->rampin_col == MA_RAMP_IN_RESULT) {
                        addcol = shi->rgb;
                }
                else {
@@ -649,7 +682,7 @@ static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, G
                                        GPU_link(mat, "ramp_rgbtobw", rgb, &fac);
                                        break;
                                case MA_RAMP_IN_SHADER:
-                                       fac= is;
+                                       fac = is;
                                        break;
                                case MA_RAMP_IN_NOR:
                                        GPU_link(mat, "vec_math_dot", shi->view, shi->vn, &tmp, &fac);
@@ -667,7 +700,7 @@ static void add_to_diffuse(GPUMaterial *mat, Material *ma, GPUShadeInput *shi, G
                addcol = shi->rgb;
 
        /* output to */
-       GPU_link(mat, "shade_madd", *diff, rgb, addcol, diff);
+       GPU_link(mat, "shade_madd", *r_diff, rgb, addcol, r_diff);
 }
 
 static void ramp_spec_result(GPUShadeInput *shi, GPUNodeLink **spec)
@@ -737,10 +770,10 @@ static void shade_light_textures(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **
                        GPUNodeLink *tex_rgb;
 
                        GPU_link(mat, "shade_light_texture",
-                               GPU_builtin(GPU_VIEW_POSITION),
-                               GPU_image(mtex->tex->ima, &mtex->tex->iuser, false),
-                               GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
-                               &tex_rgb);
+                                GPU_builtin(GPU_VIEW_POSITION),
+                                GPU_image(mtex->tex->ima, &mtex->tex->iuser, false),
+                                GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
+                                &tex_rgb);
                        texture_rgb_blend(mat, tex_rgb, *rgb, GPU_uniform(&one), GPU_uniform(&mtex->colfac), mtex->blendtype, rgb);
                }
        }
@@ -779,22 +812,31 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
                if (lamp->type == LA_AREA) {
                        float area[4][4] = {{0.0f}}, areasize = 0.0f;
 
-                       mat->dynproperty |= DYN_LAMP_VEC|DYN_LAMP_CO;
-                       GPU_link(mat, "shade_inp_area", GPU_builtin(GPU_VIEW_POSITION), GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob), GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), vn, GPU_uniform((float*)area),
-                               GPU_uniform(&areasize), GPU_uniform(&lamp->k), &inp);
+                       mat->dynproperty |= DYN_LAMP_VEC | DYN_LAMP_CO;
+                       GPU_link(mat, "shade_inp_area",
+                                GPU_builtin(GPU_VIEW_POSITION),
+                                GPU_dynamic_uniform(lamp->dynco, GPU_DYNAMIC_LAMP_DYNCO, lamp->ob),
+                                GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), vn,
+                                GPU_uniform((float *)area),
+                                GPU_uniform(&areasize),
+                                GPU_uniform(&lamp->k), &inp);
                }
 
                is = inp; /* Lambert */
 
                if (!(mat->scene->gm.flag & GAME_GLSL_NO_SHADERS)) {
                        if (ma->diff_shader == MA_DIFF_ORENNAYAR)
-                               GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view, GPU_uniform(&ma->roughness), &is);
+                               GPU_link(mat, "shade_diffuse_oren_nayer", inp, vn, lv, view,
+                                        GPU_uniform(&ma->roughness), &is);
                        else if (ma->diff_shader == MA_DIFF_TOON)
-                               GPU_link(mat, "shade_diffuse_toon", vn, lv, view, GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
+                               GPU_link(mat, "shade_diffuse_toon", vn, lv, view,
+                                        GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
                        else if (ma->diff_shader == MA_DIFF_MINNAERT)
-                               GPU_link(mat, "shade_diffuse_minnaert", inp, vn, view, GPU_uniform(&ma->darkness), &is);
+                               GPU_link(mat, "shade_diffuse_minnaert", inp, vn, view,
+                                        GPU_uniform(&ma->darkness), &is);
                        else if (ma->diff_shader == MA_DIFF_FRESNEL)
-                               GPU_link(mat, "shade_diffuse_fresnel", vn, lv, view, GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
+                               GPU_link(mat, "shade_diffuse_fresnel", vn, lv, view,
+                                        GPU_uniform(&ma->param[0]), GPU_uniform(&ma->param[1]), &is);
                }
        }
 
@@ -807,7 +849,8 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
        
        GPU_link(mat, "set_rgb", GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob), &lcol);
        shade_light_textures(mat, lamp, &lcol);
-       GPU_link(mat, "shade_mul_value_v3", GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob), lcol, &lcol);  
+       GPU_link(mat, "shade_mul_value_v3",
+                GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob), lcol, &lcol);
 
 #if 0
        if (ma->mode & MA_TANGENT_VN)
@@ -823,17 +866,17 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
                        
                        if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
                                GPU_link(mat, "test_shadowbuf_vsm",
-                                       GPU_builtin(GPU_VIEW_POSITION),
-                                       GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
-                                       GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
-                                       GPU_uniform(&lamp->bias), GPU_uniform(&lamp->la->bleedbias), inp, &shadfac);
+                                        GPU_builtin(GPU_VIEW_POSITION),
+                                        GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
+                                        GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
+                                        GPU_uniform(&lamp->bias), GPU_uniform(&lamp->la->bleedbias), inp, &shadfac);
                        }
                        else {
                                GPU_link(mat, "test_shadowbuf",
-                                       GPU_builtin(GPU_VIEW_POSITION),
-                                       GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
-                                       GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
-                                       GPU_uniform(&lamp->bias), inp, &shadfac);
+                                        GPU_builtin(GPU_VIEW_POSITION),
+                                        GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
+                                        GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
+                                        GPU_uniform(&lamp->bias), inp, &shadfac);
                        }
                        
                        if (lamp->mode & LA_ONLYSHADOW) {
@@ -844,12 +887,13 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
                                
                                if (!(lamp->mode & LA_NO_DIFF)) {
                                        GPU_link(mat, "shade_only_shadow_diffuse", shadrgb, shi->rgb,
-                                               shr->diff, &shr->diff);
+                                                shr->diff, &shr->diff);
                                }
 
-                               if (!(lamp->mode & LA_NO_SPEC))
+                               if (!(lamp->mode & LA_NO_SPEC)) {
                                        GPU_link(mat, "shade_only_shadow_specular", shadrgb, shi->specrgb,
-                                               shr->spec, &shr->spec);
+                                                shr->spec, &shr->spec);
+                               }
                                
                                add_user_list(&mat->lamps, lamp);
                                add_user_list(&lamp->materials, shi->gpumat->ma);
@@ -888,16 +932,24 @@ static void shade_one_light(GPUShadeInput *shi, GPUShadeResult *shr, GPULamp *la
                        GPU_link(mat, "shade_add_clamped", shr->spec, outcol, &shr->spec);
                }
                else {
-                       if (ma->spec_shader == MA_SPEC_PHONG)
+                       if (ma->spec_shader == MA_SPEC_PHONG) {
                                GPU_link(mat, "shade_phong_spec", vn, lv, view, shi->har, &specfac);
-                       else if (ma->spec_shader == MA_SPEC_COOKTORR)
+                       }
+                       else if (ma->spec_shader == MA_SPEC_COOKTORR) {
                                GPU_link(mat, "shade_cooktorr_spec", vn, lv, view, shi->har, &specfac);
-                       else if (ma->spec_shader == MA_SPEC_BLINN)
-                               GPU_link(mat, "shade_blinn_spec", vn, lv, view, GPU_uniform(&ma->refrac), shi->har, &specfac);
-                       else if (ma->spec_shader == MA_SPEC_WARDISO)
-                               GPU_link(mat, "shade_wardiso_spec", vn, lv, view, GPU_uniform(&ma->rms), &specfac);
-                       else
-                               GPU_link(mat, "shade_toon_spec", vn, lv, view, GPU_uniform(&ma->param[2]), GPU_uniform(&ma->param[3]), &specfac);
+                       }
+                       else if (ma->spec_shader == MA_SPEC_BLINN) {
+                               GPU_link(mat, "shade_blinn_spec", vn, lv, view,
+                                        GPU_uniform(&ma->refrac), shi->har, &specfac);
+                       }
+                       else if (ma->spec_shader == MA_SPEC_WARDISO) {
+                               GPU_link(mat, "shade_wardiso_spec", vn, lv, view,
+                                        GPU_uniform(&ma->rms), &specfac);
+                       }
+                       else {
+                               GPU_link(mat, "shade_toon_spec", vn, lv, view,
+                                        GPU_uniform(&ma->param[2]), GPU_uniform(&ma->param[3]), &specfac);
+                       }
 
                        if (lamp->type == LA_AREA)
                                GPU_link(mat, "shade_spec_area_inp", specfac, inp, &specfac);
@@ -963,96 +1015,100 @@ static void material_lights(GPUShadeInput *shi, GPUShadeResult *shr)
        GPU_link(shi->gpumat, "shade_clamp_positive", shr->diff, &shr->diff);
 }
 
-static void texture_rgb_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg, int blendtype, GPUNodeLink **in)
+static void texture_rgb_blend(
+        GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg,
+        int blendtype, GPUNodeLink **in)
 {
        switch (blendtype) {
-       case MTEX_BLEND:
-               GPU_link(mat, "mtex_rgb_blend", out, tex, fact, facg, in);
-               break;
-       case MTEX_MUL:
-               GPU_link(mat, "mtex_rgb_mul", out, tex, fact, facg, in);
-               break;
-       case MTEX_SCREEN:
-               GPU_link(mat, "mtex_rgb_screen", out, tex, fact, facg, in);
-               break;
-       case MTEX_OVERLAY:
-               GPU_link(mat, "mtex_rgb_overlay", out, tex, fact, facg, in);
-               break;
-       case MTEX_SUB:
-               GPU_link(mat, "mtex_rgb_sub", out, tex, fact, facg, in);
-               break;
-       case MTEX_ADD:
-               GPU_link(mat, "mtex_rgb_add", out, tex, fact, facg, in);
-               break;
-       case MTEX_DIV:
-               GPU_link(mat, "mtex_rgb_div", out, tex, fact, facg, in);
-               break;
-       case MTEX_DIFF:
-               GPU_link(mat, "mtex_rgb_diff", out, tex, fact, facg, in);
-               break;
-       case MTEX_DARK:
-               GPU_link(mat, "mtex_rgb_dark", out, tex, fact, facg, in);
-               break;
-       case MTEX_LIGHT:
-               GPU_link(mat, "mtex_rgb_light", out, tex, fact, facg, in);
-               break;
-       case MTEX_BLEND_HUE:
-               GPU_link(mat, "mtex_rgb_hue", out, tex, fact, facg, in);
-               break;
-       case MTEX_BLEND_SAT:
-               GPU_link(mat, "mtex_rgb_sat", out, tex, fact, facg, in);
-               break;
-       case MTEX_BLEND_VAL:
-               GPU_link(mat, "mtex_rgb_val", out, tex, fact, facg, in);
-               break;
-       case MTEX_BLEND_COLOR:
-               GPU_link(mat, "mtex_rgb_color", out, tex, fact, facg, in);
-               break;
-       case MTEX_SOFT_LIGHT:
-               GPU_link(mat, "mtex_rgb_soft", out, tex, fact, facg, in);
-               break;
-       case MTEX_LIN_LIGHT:
-               GPU_link(mat, "mtex_rgb_linear", out, tex, fact, facg, in);
-               break;
-       default:
-               GPU_link(mat, "set_rgb_zero", &in);
-               break;
+               case MTEX_BLEND:
+                       GPU_link(mat, "mtex_rgb_blend", out, tex, fact, facg, in);
+                       break;
+               case MTEX_MUL:
+                       GPU_link(mat, "mtex_rgb_mul", out, tex, fact, facg, in);
+                       break;
+               case MTEX_SCREEN:
+                       GPU_link(mat, "mtex_rgb_screen", out, tex, fact, facg, in);
+                       break;
+               case MTEX_OVERLAY:
+                       GPU_link(mat, "mtex_rgb_overlay", out, tex, fact, facg, in);
+                       break;
+               case MTEX_SUB:
+                       GPU_link(mat, "mtex_rgb_sub", out, tex, fact, facg, in);
+                       break;
+               case MTEX_ADD:
+                       GPU_link(mat, "mtex_rgb_add", out, tex, fact, facg, in);
+                       break;
+               case MTEX_DIV:
+                       GPU_link(mat, "mtex_rgb_div", out, tex, fact, facg, in);
+                       break;
+               case MTEX_DIFF:
+                       GPU_link(mat, "mtex_rgb_diff", out, tex, fact, facg, in);
+                       break;
+               case MTEX_DARK:
+                       GPU_link(mat, "mtex_rgb_dark", out, tex, fact, facg, in);
+                       break;
+               case MTEX_LIGHT:
+                       GPU_link(mat, "mtex_rgb_light", out, tex, fact, facg, in);
+                       break;
+               case MTEX_BLEND_HUE:
+                       GPU_link(mat, "mtex_rgb_hue", out, tex, fact, facg, in);
+                       break;
+               case MTEX_BLEND_SAT:
+                       GPU_link(mat, "mtex_rgb_sat", out, tex, fact, facg, in);
+                       break;
+               case MTEX_BLEND_VAL:
+                       GPU_link(mat, "mtex_rgb_val", out, tex, fact, facg, in);
+                       break;
+               case MTEX_BLEND_COLOR:
+                       GPU_link(mat, "mtex_rgb_color", out, tex, fact, facg, in);
+                       break;
+               case MTEX_SOFT_LIGHT:
+                       GPU_link(mat, "mtex_rgb_soft", out, tex, fact, facg, in);
+                       break;
+               case MTEX_LIN_LIGHT:
+                       GPU_link(mat, "mtex_rgb_linear", out, tex, fact, facg, in);
+                       break;
+               default:
+                       GPU_link(mat, "set_rgb_zero", &in);
+                       break;
        }
 }
 
-static void texture_value_blend(GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg, int blendtype, GPUNodeLink **in)
+static void texture_value_blend(
+        GPUMaterial *mat, GPUNodeLink *tex, GPUNodeLink *out, GPUNodeLink *fact, GPUNodeLink *facg,
+        int blendtype, GPUNodeLink **in)
 {
        switch (blendtype) {
-       case MTEX_BLEND:
-               GPU_link(mat, "mtex_value_blend", out, tex, fact, facg, in);
-               break;
-       case MTEX_MUL:
-               GPU_link(mat, "mtex_value_mul", out, tex, fact, facg, in);
-               break;
-       case MTEX_SCREEN:
-               GPU_link(mat, "mtex_value_screen", out, tex, fact, facg, in);
-               break;
-       case MTEX_SUB:
-               GPU_link(mat, "mtex_value_sub", out, tex, fact, facg, in);
-               break;
-       case MTEX_ADD:
-               GPU_link(mat, "mtex_value_add", out, tex, fact, facg, in);
-               break;
-       case MTEX_DIV:
-               GPU_link(mat, "mtex_value_div", out, tex, fact, facg, in);
-               break;
-       case MTEX_DIFF:
-               GPU_link(mat, "mtex_value_diff", out, tex, fact, facg, in);
-               break;
-       case MTEX_DARK:
-               GPU_link(mat, "mtex_value_dark", out, tex, fact, facg, in);
-               break;
-       case MTEX_LIGHT:
-               GPU_link(mat, "mtex_value_light", out, tex, fact, facg, in);
-               break;
-       default:
-               GPU_link(mat, "set_value_zero", &in);
-               break;
+               case MTEX_BLEND:
+                       GPU_link(mat, "mtex_value_blend", out, tex, fact, facg, in);
+                       break;
+               case MTEX_MUL:
+                       GPU_link(mat, "mtex_value_mul", out, tex, fact, facg, in);
+                       break;
+               case MTEX_SCREEN:
+                       GPU_link(mat, "mtex_value_screen", out, tex, fact, facg, in);
+                       break;
+               case MTEX_SUB:
+                       GPU_link(mat, "mtex_value_sub", out, tex, fact, facg, in);
+                       break;
+               case MTEX_ADD:
+                       GPU_link(mat, "mtex_value_add", out, tex, fact, facg, in);
+                       break;
+               case MTEX_DIV:
+                       GPU_link(mat, "mtex_value_div", out, tex, fact, facg, in);
+                       break;
+               case MTEX_DIFF:
+                       GPU_link(mat, "mtex_value_diff", out, tex, fact, facg, in);
+                       break;
+               case MTEX_DARK:
+                       GPU_link(mat, "mtex_value_dark", out, tex, fact, facg, in);
+                       break;
+               case MTEX_LIGHT:
+                       GPU_link(mat, "mtex_value_light", out, tex, fact, facg, in);
+                       break;
+               default:
+                       GPU_link(mat, "set_value_zero", &in);
+                       break;
        }
 }
 
@@ -1174,9 +1230,9 @@ static void do_material_tex(GPUShadeInput *shi)
                        }
 
                        /* mapping */
-                       if (mtex->mapto & (MAP_COL+MAP_COLSPEC)) {
+                       if (mtex->mapto & (MAP_COL + MAP_COLSPEC)) {
                                /* stencil maps on the texture control slider, not texture intensity value */
-                               if ((rgbnor & TEX_RGB)==0) {
+                               if ((rgbnor & TEX_RGB) == 0) {
                                        GPU_link(mat, "set_rgb", GPU_uniform(&mtex->r), &tcol);
                                }
                                else {
@@ -1228,12 +1284,15 @@ static void do_material_tex(GPUShadeInput *shi)
                                                        if (iFirstTimeNMap != 0) {
                                                                // use unnormalized normal (this is how we bake it - closer to gamedev)
                                                                GPUNodeLink *vNegNorm;
-                                                               GPU_link(mat, "vec_math_negate", GPU_builtin(GPU_VIEW_NORMAL), &vNegNorm);
-                                                               GPU_link(mat, "mtex_nspace_tangent", GPU_attribute(CD_TANGENT, ""), vNegNorm, tnor, &newnor);
+                                                               GPU_link(mat, "vec_math_negate",
+                                                                        GPU_builtin(GPU_VIEW_NORMAL), &vNegNorm);
+                                                               GPU_link(mat, "mtex_nspace_tangent",
+                                                                        GPU_attribute(CD_TANGENT, ""), vNegNorm, tnor, &newnor);
                                                                iFirstTimeNMap = 0;
                                                        }
                                                        else { /* otherwise use accumulated perturbations */
-                                                               GPU_link(mat, "mtex_nspace_tangent", GPU_attribute(CD_TANGENT, ""), shi->vn, tnor, &newnor);
+                                                               GPU_link(mat, "mtex_nspace_tangent",
+                                                                        GPU_attribute(CD_TANGENT, ""), shi->vn, tnor, &newnor);
                                                        }
                                                }
                                                else if (mtex->normapspace == MTEX_NSPACE_OBJECT) {
@@ -1264,7 +1323,9 @@ static void do_material_tex(GPUShadeInput *shi)
                                                }
                                                
                                        }
-                                       else if ((mtex->texflag & (MTEX_3TAP_BUMP | MTEX_5TAP_BUMP | MTEX_BICUBIC_BUMP)) || found_deriv_map) {
+                                       else if (found_deriv_map ||
+                                                (mtex->texflag & (MTEX_3TAP_BUMP | MTEX_5TAP_BUMP | MTEX_BICUBIC_BUMP)))
+                                       {
                                                /* ntap bumpmap image */
                                                int iBumpSpace;
                                                float ima_x, ima_y;
@@ -1333,7 +1394,10 @@ static void do_material_tex(GPUShadeInput *shi)
                                                        if (mtex->texflag & MTEX_BUMP_OBJECTSPACE)
                                                                GPU_link(mat, "mtex_bump_init_objspace",
                                                                         surf_pos, vNorg,
-                                                                        GPU_builtin(GPU_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_OBJECT_MATRIX),  GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
+                                                                        GPU_builtin(GPU_VIEW_MATRIX),
+                                                                        GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
+                                                                        GPU_builtin(GPU_OBJECT_MATRIX),
+                                                                        GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
                                                                         fPrevMagnitude, vNacc,
                                                                         &fPrevMagnitude, &vNacc,
                                                                         &vR1, &vR2, &fDet);
@@ -1358,7 +1422,8 @@ static void do_material_tex(GPUShadeInput *shi)
                                                
                                                if (found_deriv_map) {
                                                        GPU_link(mat, "mtex_bump_deriv",
-                                                                texco, GPU_image(tex->ima, &tex->iuser, true), GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac,
+                                                                texco, GPU_image(tex->ima, &tex->iuser, true),
+                                                                GPU_uniform(&ima_x), GPU_uniform(&ima_y), tnorfac,
                                                                 &dBs, &dBt);
                                                }
                                                else if (mtex->texflag & MTEX_3TAP_BUMP)
@@ -1388,7 +1453,8 @@ static void do_material_tex(GPUShadeInput *shi)
                                                        GPU_link(mat, "mtex_bump_apply_texspace",
                                                                 fDet, dBs, dBt, vR1, vR2,
                                                                 GPU_image(tex->ima, &tex->iuser, true), texco,
-                                                                GPU_uniform(&imag_tspace_dimension_x), GPU_uniform(&imag_tspace_dimension_y), vNacc,
+                                                                GPU_uniform(&imag_tspace_dimension_x),
+                                                                GPU_uniform(&imag_tspace_dimension_y), vNacc,
                                                                 &vNacc, &shi->vn);
                                                }
                                                else
@@ -1416,7 +1482,9 @@ static void do_material_tex(GPUShadeInput *shi)
                                        if (mtex->difffac == 1.0f) difffac = stencil;
                                        else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->difffac), stencil, &difffac);
 
-                                       texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->refl, tin, difffac, mtex->blendtype, &shi->refl);
+                                       texture_value_blend(
+                                               mat, GPU_uniform(&mtex->def_var), shi->refl, tin, difffac,
+                                               mtex->blendtype, &shi->refl);
                                        GPU_link(mat, "mtex_value_clamp_positive", shi->refl, &shi->refl);
                                }
                                if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_SPEC) {
@@ -1425,7 +1493,9 @@ static void do_material_tex(GPUShadeInput *shi)
                                        if (mtex->specfac == 1.0f) specfac = stencil;
                                        else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->specfac), stencil, &specfac);
 
-                                       texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->spec, tin, specfac, mtex->blendtype, &shi->spec);
+                                       texture_value_blend(
+                                               mat, GPU_uniform(&mtex->def_var), shi->spec, tin, specfac,
+                                               mtex->blendtype, &shi->spec);
                                        GPU_link(mat, "mtex_value_clamp_positive", shi->spec, &shi->spec);
                                }
                                if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_EMIT) {
@@ -1434,7 +1504,9 @@ static void do_material_tex(GPUShadeInput *shi)
                                        if (mtex->emitfac == 1.0f) emitfac = stencil;
                                        else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->emitfac), stencil, &emitfac);
 
-                                       texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->emit, tin, emitfac, mtex->blendtype, &shi->emit);
+                                       texture_value_blend(
+                                               mat, GPU_uniform(&mtex->def_var), shi->emit, tin, emitfac,
+                                               mtex->blendtype, &shi->emit);
                                        GPU_link(mat, "mtex_value_clamp_positive", shi->emit, &shi->emit);
                                }
                                if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_HAR) {
@@ -1444,7 +1516,9 @@ static void do_material_tex(GPUShadeInput *shi)
                                        else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->hardfac), stencil, &hardfac);
 
                                        GPU_link(mat, "mtex_har_divide", shi->har, &shi->har);
-                                       texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->har, tin, hardfac, mtex->blendtype, &shi->har);
+                                       texture_value_blend(
+                                               mat, GPU_uniform(&mtex->def_var), shi->har, tin, hardfac,
+                                               mtex->blendtype, &shi->har);
                                        GPU_link(mat, "mtex_har_multiply_clamp", shi->har, &shi->har);
                                }
                                if (mtex->mapto & MAP_ALPHA) {
@@ -1453,7 +1527,9 @@ static void do_material_tex(GPUShadeInput *shi)
                                        if (mtex->alphafac == 1.0f) alphafac = stencil;
                                        else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->alphafac), stencil, &alphafac);
 
-                                       texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, alphafac, mtex->blendtype, &shi->alpha);
+                                       texture_value_blend(
+                                               mat, GPU_uniform(&mtex->def_var), shi->alpha, tin, alphafac,
+                                               mtex->blendtype, &shi->alpha);
                                        GPU_link(mat, "mtex_value_clamp", shi->alpha, &shi->alpha);
                                }
                                if (!(mat->scene->gm.flag & GAME_GLSL_NO_EXTRA_TEX) && mtex->mapto & MAP_AMB) {
@@ -1462,7 +1538,9 @@ static void do_material_tex(GPUShadeInput *shi)
                                        if (mtex->ambfac == 1.0f) ambfac = stencil;
                                        else GPU_link(mat, "math_multiply", GPU_uniform(&mtex->ambfac), stencil, &ambfac);
 
-                                       texture_value_blend(mat, GPU_uniform(&mtex->def_var), shi->amb, tin, ambfac, mtex->blendtype, &shi->amb);
+                                       texture_value_blend(
+                                               mat, GPU_uniform(&mtex->def_var), shi->amb, tin, ambfac,
+                                               mtex->blendtype, &shi->amb);
                                        GPU_link(mat, "mtex_value_clamp", shi->amb, &shi->amb);
                                }
                        }
@@ -1491,7 +1569,7 @@ void GPU_shadeinput_set(GPUMaterial *mat, Material *ma, GPUShadeInput *shi)
        GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->ref, GPU_DYNAMIC_MAT_REF, NULL), &shi->refl);
        GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->spec, GPU_DYNAMIC_MAT_SPEC, NULL), &shi->spec);
        GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->emit, GPU_DYNAMIC_MAT_EMIT, NULL), &shi->emit);
-       GPU_link(mat, "set_value", GPU_dynamic_uniform((float*)&ma->har, GPU_DYNAMIC_MAT_HARD, NULL), &shi->har);
+       GPU_link(mat, "set_value", GPU_dynamic_uniform((float *)&ma->har, GPU_DYNAMIC_MAT_HARD, NULL), &shi->har);
        GPU_link(mat, "set_value", GPU_dynamic_uniform(&ma->amb, GPU_DYNAMIC_MAT_AMB, NULL), &shi->amb);
        GPU_link(mat, "set_value", GPU_uniform(&ma->spectra), &shi->spectra);
        GPU_link(mat, "shade_view", GPU_builtin(GPU_VIEW_POSITION), &shi->view);
@@ -1550,7 +1628,7 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
        }
        else {
                if (GPU_link_changed(shi->emit) || ma->emit != 0.0f) {
-                       if ((ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) == MA_VERTEXCOL) {
+                       if ((ma->mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == MA_VERTEXCOL) {
                                GPU_link(mat, "shade_add", shi->emit, shi->vcol, &emit);
                                GPU_link(mat, "shade_mul", emit, shi->rgb, &shr->diff);
                        }
@@ -1591,10 +1669,11 @@ void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr)
                        }
                }
 
-               if (ma->mode & MA_TRANSP && (ma->mode & (MA_ZTRANSP|MA_RAYTRANSP))) {
-                       if (GPU_link_changed(shi->spectra) || ma->spectra != 0.0f)
+               if (ma->mode & MA_TRANSP && (ma->mode & (MA_ZTRANSP | MA_RAYTRANSP))) {
+                       if (GPU_link_changed(shi->spectra) || ma->spectra != 0.0f) {
                                GPU_link(mat, "alpha_spec_correction", shr->spec, shi->spectra,
-                                       shi->alpha, &shr->alpha);
+                                        shi->alpha, &shr->alpha);
+                       }
                }
 
                if (ma->mode & MA_RAMP_COL) ramp_diffuse_result(shi, &shr->combined);
@@ -1651,7 +1730,8 @@ static GPUNodeLink *gpu_material_diffuse_bsdf(GPUMaterial *mat, Material *ma)
        static float roughness = 0.0f;
        GPUNodeLink *outlink;
 
-       GPU_link(mat, "node_bsdf_diffuse", GPU_uniform(&ma->r), GPU_uniform(&roughness), GPU_builtin(GPU_VIEW_NORMAL), &outlink);
+       GPU_link(mat, "node_bsdf_diffuse",
+                GPU_uniform(&ma->r), GPU_uniform(&roughness), GPU_builtin(GPU_VIEW_NORMAL), &outlink);
 
        return outlink;
 }
@@ -1664,7 +1744,8 @@ static GPUNodeLink *gpu_material_preview_matcap(GPUMaterial *mat, Material *ma)
         * matcap normal holds the normal remapped to the 0.0 - 1.0 range. To take advantage of flat shading, we abuse
         * the built in secondary color of opengl. Color is just the regular color, which should include mask value too.
         * This also needs flat shading so we use the primary opengl color built-in */
-       GPU_link(mat, "material_preview_matcap", GPU_uniform(&ma->r), GPU_image_preview(ma->preview), GPU_opengl_builtin(GPU_MATCAP_NORMAL), GPU_opengl_builtin(GPU_COLOR), &outlink);
+       GPU_link(mat, "material_preview_matcap", GPU_uniform(&ma->r), GPU_image_preview(ma->preview),
+                GPU_opengl_builtin(GPU_MATCAP_NORMAL), GPU_opengl_builtin(GPU_COLOR), &outlink);
        
        return outlink;
 }
@@ -1677,7 +1758,7 @@ GPUMaterial *GPU_material_matcap(Scene *scene, Material *ma, bool use_opensubdiv
        LinkData *link;
        
        for (link = ma->gpumaterial.first; link; link = link->next) {
-               GPUMaterial *current_material = (GPUMaterial*)link->data;
+               GPUMaterial *current_material = (GPUMaterial *)link->data;
                if (current_material->scene == scene &&
                    current_material->is_opensubdiv == use_opensubdiv)
                {
@@ -1719,7 +1800,7 @@ GPUMaterial *GPU_material_world(struct Scene *scene, struct World *wo)
        GPUMaterial *mat;
 
        for (link = wo->gpumaterial.first; link; link = link->next)
-               if (((GPUMaterial*)link->data)->scene == scene)
+               if (((GPUMaterial *)link->data)->scene == scene)
                        return link->data;
 
        /* allocate material */
@@ -1759,7 +1840,7 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma, bool use_open
        LinkData *link;
 
        for (link = ma->gpumaterial.first; link; link = link->next) {
-               GPUMaterial *current_material = (GPUMaterial*)link->data;
+               GPUMaterial *current_material = (GPUMaterial *)link->data;
                if (current_material->scene == scene &&
                    current_material->is_opensubdiv == use_opensubdiv)
                {
@@ -1986,7 +2067,7 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
        LinkData *link;
 
        for (link = ob->gpulamp.first; link; link = link->next) {
-               lamp = (GPULamp*)link->data;
+               lamp = (GPULamp *)link->data;
 
                if (lamp->par == par && lamp->scene == scene)
                        return link->data;
@@ -2001,7 +2082,9 @@ GPULamp *GPU_lamp_from_blender(Scene *scene, Object *ob, Object *par)
        la = ob->data;
        gpu_lamp_from_blender(scene, ob, par, la, lamp);
 
-       if ((la->type == LA_SPOT && (la->mode & (LA_SHAD_BUF | LA_SHAD_RAY))) || (la->type == LA_SUN && (la->mode & LA_SHAD_RAY))) {
+       if ((la->type == LA_SPOT && (la->mode & (LA_SHAD_BUF | LA_SHAD_RAY))) ||
+           (la->type == LA_SUN && (la->mode & LA_SHAD_RAY)))
+       {
                /* opengl */
                lamp->fb = GPU_framebuffer_create();
                if (!lamp->fb) {
@@ -2194,47 +2277,49 @@ int GPU_lamp_shadow_buffer_type(GPULamp *lamp)
 
 int GPU_lamp_shadow_layer(GPULamp *lamp)
 {
-       if (lamp->fb && lamp->tex && (lamp->mode & (LA_LAYER|LA_LAYER_SHADOW)))
+       if (lamp->fb && lamp->tex && (lamp->mode & (LA_LAYER | LA_LAYER_SHADOW)))
                return lamp->lay;
        else
                return -1;
 }
 
-GPUNodeLink *GPU_lamp_get_data(GPUMaterial *mat, GPULamp *lamp, GPUNodeLink **col, GPUNodeLink **lv, GPUNodeLink **dist, GPUNodeLink **shadow, GPUNodeLink **energy)
+GPUNodeLink *GPU_lamp_get_data(
+        GPUMaterial *mat, GPULamp *lamp,
+        GPUNodeLink **r_col, GPUNodeLink **r_lv, GPUNodeLink **r_dist, GPUNodeLink **r_shadow, GPUNodeLink **r_energy)
 {
        GPUNodeLink *visifac;
 
-       *col = GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob);
-       *energy = GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob);
-       visifac = lamp_get_visibility(mat, lamp, lv, dist);
+       *r_col = GPU_dynamic_uniform(lamp->dyncol, GPU_DYNAMIC_LAMP_DYNCOL, lamp->ob);
+       *r_energy = GPU_dynamic_uniform(&lamp->dynenergy, GPU_DYNAMIC_LAMP_DYNENERGY, lamp->ob);
+       visifac = lamp_get_visibility(mat, lamp, r_lv, r_dist);
 
-       shade_light_textures(mat, lamp, col);
+       shade_light_textures(mat, lamp, r_col);
 
        if (GPU_lamp_has_shadow_buffer(lamp)) {
                GPUNodeLink *vn, *inp;
 
                GPU_link(mat, "shade_norm", GPU_builtin(GPU_VIEW_NORMAL), &vn);
-               GPU_link(mat, "shade_inp", vn, *lv, &inp);
+               GPU_link(mat, "shade_inp", vn, *r_lv, &inp);
                mat->dynproperty |= DYN_LAMP_PERSMAT;
 
                if (lamp->la->shadowmap_type == LA_SHADMAP_VARIANCE) {
                        GPU_link(mat, "shadows_only_vsm",
                                 GPU_builtin(GPU_VIEW_POSITION),
                                 GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
-                                GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
+                                GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
                                 GPU_uniform(&lamp->bias), GPU_uniform(&lamp->la->bleedbias),
-                                GPU_uniform(lamp->shadow_color), inp, shadow);
+                                GPU_uniform(lamp->shadow_color), inp, r_shadow);
                }
                else {
                        GPU_link(mat, "shadows_only",
                                 GPU_builtin(GPU_VIEW_POSITION),
                                 GPU_dynamic_texture(lamp->tex, GPU_DYNAMIC_SAMPLER_2DSHADOW, lamp->ob),
-                                GPU_dynamic_uniform((float*)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
-                                GPU_uniform(&lamp->bias), GPU_uniform(lamp->shadow_color), inp, shadow);
+                                GPU_dynamic_uniform((float *)lamp->dynpersmat, GPU_DYNAMIC_LAMP_DYNPERSMAT, lamp->ob),
+                                GPU_uniform(&lamp->bias), GPU_uniform(lamp->shadow_color), inp, r_shadow);
                }
        }
        else {
-               GPU_link(mat, "set_rgb_one", shadow);
+               GPU_link(mat, "set_rgb_one", r_shadow);
        }
 
        /* ensure shadow buffer and lamp textures will be updated */
@@ -2268,7 +2353,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
 
        /* TODO(sergey): How to determine whether we need OSD or not here? */
        GPUMaterial *mat = GPU_material_from_blender(scene, ma, false);
-       GPUPass *pass = (mat)? mat->pass: NULL;
+       GPUPass *pass = (mat) ? mat->pass : NULL;
 
        if (pass && pass->fragmentcode && pass->vertexcode) {
                shader = MEM_callocN(sizeof(GPUShaderExport), "GPUShaderExport");
@@ -2291,60 +2376,60 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
                                BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
 
                                switch (input->textype) {
-                               case GPU_SHADOW2D:
-                                       uniform->type = GPU_DYNAMIC_SAMPLER_2DSHADOW;
-                                       uniform->lamp = input->dynamicdata;
-                                       break;
-                               case GPU_TEX2D:
-                                       if (GPU_texture_opengl_bindcode(input->tex)) {
-                                               uniform->type = GPU_DYNAMIC_SAMPLER_2DBUFFER;
-                                               glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(input->tex));
-                                               uniform->texsize = GPU_texture_width(input->tex) * GPU_texture_height(input->tex);
-                                               uniform->texpixels = MEM_mallocN(uniform->texsize*4, "RGBApixels");
-                                               glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, uniform->texpixels); 
-                                               glBindTexture(GL_TEXTURE_2D, 0);
-                                       }
-                                       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;
+                                       case GPU_SHADOW2D:
+                                               uniform->type = GPU_DYNAMIC_SAMPLER_2DSHADOW;
+                                               uniform->lamp = input->dynamicdata;
+                                               break;
+                                       case GPU_TEX2D:
+                                               if (GPU_texture_opengl_bindcode(input->tex)) {
+                                                       uniform->type = GPU_DYNAMIC_SAMPLER_2DBUFFER;
+                                                       glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(input->tex));
+                                                       uniform->texsize = GPU_texture_width(input->tex) * GPU_texture_height(input->tex);
+                                                       uniform->texpixels = MEM_mallocN(uniform->texsize * 4, "RGBApixels");
+                                                       glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, uniform->texpixels);
+                                                       glBindTexture(GL_TEXTURE_2D, 0);
+                                               }
+                                               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 {
                                uniform->type = input->dynamictype;
                                BLI_strncpy(uniform->varname, input->shadername, sizeof(uniform->varname));
                                switch (input->type) {
-                               case GPU_FLOAT:
-                                       uniform->datatype = GPU_DATA_1F;
-                                       break;
-                               case GPU_VEC2:
-                                       uniform->datatype = GPU_DATA_2F;
-                                       break;
-                               case GPU_VEC3:
-                                       uniform->datatype = GPU_DATA_3F;
-                                       break;
-                               case GPU_VEC4:
-                                       uniform->datatype = GPU_DATA_4F;
-                                       break;
-                               case GPU_MAT3:
-                                       uniform->datatype = GPU_DATA_9F;
-                                       break;
-                               case GPU_MAT4:
-                                       uniform->datatype = GPU_DATA_16F;
-                                       break;
-
-                               case GPU_NONE:
-                               case GPU_TEX2D:
-                               case GPU_SHADOW2D:
-                               case GPU_ATTRIB:
-                                       break;
+                                       case GPU_FLOAT:
+                                               uniform->datatype = GPU_DATA_1F;
+                                               break;
+                                       case GPU_VEC2:
+                                               uniform->datatype = GPU_DATA_2F;
+                                               break;
+                                       case GPU_VEC3:
+                                               uniform->datatype = GPU_DATA_3F;
+                                               break;
+                                       case GPU_VEC4:
+                                               uniform->datatype = GPU_DATA_4F;
+                                               break;
+                                       case GPU_MAT3:
+                                               uniform->datatype = GPU_DATA_9F;
+                                               break;
+                                       case GPU_MAT4:
+                                               uniform->datatype = GPU_DATA_16F;
+                                               break;
+
+                                       case GPU_NONE:
+                                       case GPU_TEX2D:
+                                       case GPU_SHADOW2D:
+                                       case GPU_ATTRIB:
+                                               break;
                                }
 
                                if (GPU_DYNAMIC_GROUP_FROM_TYPE(uniform->type) == GPU_DYNAMIC_GROUP_LAMP)
@@ -2386,20 +2471,20 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma)
                        BLI_snprintf(attribute->varname, sizeof(attribute->varname), "att%d", mat->attribs.layer[i].attribid);
 
                        switch (attribute->type) {
-                       case CD_TANGENT:
-                               attribute->datatype = GPU_DATA_4F;
-                               break;
-                       case CD_MTFACE:
-                               attribute->datatype = GPU_DATA_2F;
-                               attribute->name = mat->attribs.layer[i].name;
-                               break;
-                       case CD_MCOL:
-                               attribute->datatype = GPU_DATA_4UB;
-                               attribute->name = mat->attribs.layer[i].name;
-                               break;
-                       case CD_ORCO:
-                               attribute->datatype = GPU_DATA_3F;
-                               break;
+                               case CD_TANGENT:
+                                       attribute->datatype = GPU_DATA_4F;
+                                       break;
+                               case CD_MTFACE:
+                                       attribute->datatype = GPU_DATA_2F;
+                                       attribute->name = mat->attribs.layer[i].name;
+                                       break;
+                               case CD_MCOL:
+                                       attribute->datatype = GPU_DATA_4UB;
+                                       attribute->name = mat->attribs.layer[i].name;
+                                       break;
+                               case CD_ORCO:
+                                       attribute->datatype = GPU_DATA_3F;
+                                       break;
                        }
 
                        if (attribute->datatype != GPU_DATA_NONE)
index 44847dd5a480043097eff38653cfe009974664cb..d7b197756f940f3d3a710c1137892a12c76818c4 100644 (file)
@@ -69,6 +69,9 @@ typedef struct GPUQueryState {
 
 static GPUQueryState g_query_state = {0};
 
+/**
+ * initialize and provide buffer for results
+ */
 void GPU_select_begin(unsigned int *buffer, unsigned int bufsize, rctf *input, char mode, int oldhits)
 {
        g_query_state.select_is_active = true;
@@ -133,6 +136,13 @@ void GPU_select_begin(unsigned int *buffer, unsigned int bufsize, rctf *input, c
        }
 }
 
+/**
+ * loads a new selection id and ends previous query, if any. In second pass of selection it also returns
+ * if id has been hit on the first pass already.
+ * Thus we can skip drawing un-hit objects.
+ *
+ * \warning We rely on the order of object rendering on passes to be the same for this to work.
+ */
 bool GPU_select_load_id(unsigned int id)
 {
        /* if no selection mode active, ignore */
@@ -173,6 +183,11 @@ bool GPU_select_load_id(unsigned int id)
        return true;
 }
 
+/**
+ * Cleanup and flush selection results to buffer.
+ * Return number of hits and hits in buffer.
+ * if \a dopass is true, we will do a second pass with occlusion queries to get the closest hit.
+ */
 unsigned int GPU_select_end(void)
 {
        unsigned int hits = 0;
@@ -233,8 +248,12 @@ unsigned int GPU_select_end(void)
        return hits;
 }
 
+/**
+ * has user activated?
+ */
 bool GPU_select_query_check_active(void)
 {
        return ((U.gpu_select_method == USER_SELECT_USE_OCCLUSION_QUERY) ||
-               ((U.gpu_select_method == USER_SELECT_AUTO) && GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)));
+               ((U.gpu_select_method == USER_SELECT_AUTO) &&
+                GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)));
 }
index 83413dfdcb18ae08d59fe044b1b1a34f60b4c7ac..be1cc1c004f4718716ccaa93dcd3248d45001504 100644 (file)
@@ -633,12 +633,17 @@ GPUShader *GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
        switch (shader) {
                case GPU_SHADER_VSM_STORE:
                        if (!GG.shaders.vsm_store)
-                               GG.shaders.vsm_store = GPU_shader_create(datatoc_gpu_shader_vsm_store_vert_glsl, datatoc_gpu_shader_vsm_store_frag_glsl, NULL, NULL, NULL, 0, 0, 0);
+                               GG.shaders.vsm_store = GPU_shader_create(
+                                       datatoc_gpu_shader_vsm_store_vert_glsl, datatoc_gpu_shader_vsm_store_frag_glsl,
+                                       NULL, NULL, NULL, 0, 0, 0);
                        retval = GG.shaders.vsm_store;
                        break;
                case GPU_SHADER_SEP_GAUSSIAN_BLUR:
                        if (!GG.shaders.sep_gaussian_blur)
-                               GG.shaders.sep_gaussian_blur = GPU_shader_create(datatoc_gpu_shader_sep_gaussian_blur_vert_glsl, datatoc_gpu_shader_sep_gaussian_blur_frag_glsl, NULL, NULL, NULL, 0, 0, 0);
+                               GG.shaders.sep_gaussian_blur = GPU_shader_create(
+                                       datatoc_gpu_shader_sep_gaussian_blur_vert_glsl,
+                                       datatoc_gpu_shader_sep_gaussian_blur_frag_glsl,
+                                       NULL, NULL, NULL, 0, 0, 0);
                        retval = GG.shaders.sep_gaussian_blur;
                        break;
        }
@@ -655,13 +660,17 @@ GPUProgram *GPU_shader_get_builtin_program(GPUBuiltinProgram program)
 
        switch (program) {
                case GPU_PROGRAM_SMOKE:
-                       if (!GG.shaders.smoke)
-                               GG.shaders.smoke = GPU_program_shader_create(GPU_PROGRAM_TYPE_FRAGMENT, datatoc_gpu_program_smoke_frag_glsl);
+                       if (!GG.shaders.smoke) {
+                               GG.shaders.smoke = GPU_program_shader_create(
+                                       GPU_PROGRAM_TYPE_FRAGMENT, datatoc_gpu_program_smoke_frag_glsl);
+                       }
                        retval = GG.shaders.smoke;
                        break;
                case GPU_PROGRAM_SMOKE_COLORED:
-                       if (!GG.shaders.smoke_colored)
-                               GG.shaders.smoke_colored = GPU_program_shader_create(GPU_PROGRAM_TYPE_FRAGMENT, datatoc_gpu_program_smoke_color_frag_glsl);
+                       if (!GG.shaders.smoke_colored) {
+                               GG.shaders.smoke_colored = GPU_program_shader_create(
+                                       GPU_PROGRAM_TYPE_FRAGMENT, datatoc_gpu_program_smoke_color_frag_glsl);
+                       }
                        retval = GG.shaders.smoke_colored;
                        break;
        }
@@ -730,7 +739,7 @@ GPUShader *GPU_shader_get_builtin_fx_shader(int effects, bool persp)
                        case GPU_SHADER_FX_DEPTH_OF_FIELD_HQ_PASS_TWO:
                                strcat(defines, "#define SECOND_PASS\n");
                                shader = GPU_shader_create(datatoc_gpu_shader_fx_dof_hq_vert_glsl, datatoc_gpu_shader_fx_dof_hq_frag_glsl, datatoc_gpu_shader_fx_dof_hq_geo_glsl, datatoc_gpu_shader_fx_lib_glsl,
-                                                                                  defines, GL_POINTS, GL_TRIANGLE_STRIP, 4);
+                                                          defines, GL_POINTS, GL_TRIANGLE_STRIP, 4);
                                GG.shaders.fx_shaders[offset] = shader;
                                break;
 
@@ -741,6 +750,7 @@ GPUShader *GPU_shader_get_builtin_fx_shader(int effects, bool persp)
 
                        case GPU_SHADER_FX_DEPTH_RESOLVE:
                                GG.shaders.fx_shaders[offset] = GPU_shader_create(datatoc_gpu_shader_fx_vert_glsl, datatoc_gpu_shader_fx_depth_resolve_glsl, NULL, NULL, defines, 0, 0, 0);
+                               break;
                }
        }
 
index be39bee69e22f4056d5939337478e8e3c701b386..f410edb60b0790b770c116ea1153966e93812ce5 100644 (file)
@@ -181,7 +181,7 @@ static GPUTexture *GPU_texture_create_nD(
 
                if (fpixels && hdr_type == GPU_HDR_NONE) {
                        type = GL_UNSIGNED_BYTE;
-                       pixels = GPU_texture_convert_pixels(w*h, fpixels);
+                       pixels = GPU_texture_convert_pixels(w * h, fpixels);
                }
        }
 
@@ -192,9 +192,9 @@ static GPUTexture *GPU_texture_create_nD(
                        glTexSubImage1D(tex->target, 0, 0, w, format, type,
                                pixels ? pixels : fpixels);
 
-                       if (tex->w > w)
-                               GPU_glTexSubImageEmpty(tex->target, format, w, 0,
-                                       tex->w-w, 1);
+                       if (tex->w > w) {
+                               GPU_glTexSubImageEmpty(tex->target, format, w, 0, tex->w - w, 1);
+                       }
                }
        }
        else {
@@ -211,9 +211,9 @@ static GPUTexture *GPU_texture_create_nD(
                                format, type, pixels ? pixels : fpixels);
 
                        if (tex->w > w)
-                               GPU_glTexSubImageEmpty(tex->target, format, w, 0, tex->w-w, tex->h);
+                               GPU_glTexSubImageEmpty(tex->target, format, w, 0, tex->w - w, tex->h);
                        if (tex->h > h)
-                               GPU_glTexSubImageEmpty(tex->target, format, 0, h, w, tex->h-h);
+                               GPU_glTexSubImageEmpty(tex->target, format, 0, h, w, tex->h - h);
                }
        }
 
@@ -315,14 +315,15 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, const f
        if (rescale && fpixels) {
                /* FIXME: should these be floating point? */
                const unsigned int xf = w / tex->w, yf = h / tex->h, zf = depth / tex->depth;
-               float *tex3d = MEM_mallocN(channels * sizeof(float)*tex->w*tex->h*tex->depth, "tex3d");
+               float *tex3d = MEM_mallocN(channels * sizeof(float) * tex->w * tex->h * tex->depth, "tex3d");
 
                GPU_print_error_debug("You need to scale a 3D texture, feel the pain!");
 
                for (unsigned k = 0; k < tex->depth; k++) {
                        for (unsigned j = 0; j < tex->h; j++) {
                                for (unsigned i = 0; i < tex->w; i++) {
-                                       /* obviously doing nearest filtering here, it's going to be slow in any case, let's not make it worse */
+                                       /* obviously doing nearest filtering here,
+                                        * it's going to be slow in any case, let's not make it worse */
                                        float xb = i * xf;
                                        float yb = j * yf;
                                        float zb = k * zf;
@@ -387,7 +388,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, bool is_data,
        tex->target_base = GL_TEXTURE_2D;
        tex->fromblender = 1;
 
-       ima->gputexture= tex;
+       ima->gputexture = tex;
 
        if (!glIsTexture(tex->bindcode)) {
                GPU_ASSERT_NO_GL_ERRORS("Blender Texture Not Loaded");
@@ -475,7 +476,8 @@ GPUTexture *GPU_texture_create_2D(int w, int h, const float *fpixels, GPUHDRType
        
        return tex;
 }
-GPUTexture *GPU_texture_create_2D_multisample(int w, int h, const float *fpixels, GPUHDRType hdr, int samples, char err_out[256])
+GPUTexture *GPU_texture_create_2D_multisample(
+        int w, int h, const float *fpixels, GPUHDRType hdr, int samples, char err_out[256])
 {
        GPUTexture *tex = GPU_texture_create_nD(w, h, 2, fpixels, 0, hdr, 4, samples, err_out);