Cleanup: remove duplicated shaders that only added clipping checks
authorCampbell Barton <ideasman42@gmail.com>
Thu, 24 Jan 2019 21:01:07 +0000 (08:01 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 24 Jan 2019 21:01:07 +0000 (08:01 +1100)
Originally I wanted to avoid adding draw manager specific ifdef's all
over generic shaders however this isn't needed in so many places.

Also there are shaders that are only used by the draw manager so
duplicating them only to have the original unused doesn't make sense.

source/blender/draw/CMakeLists.txt
source/blender/draw/intern/draw_builtin_shader.c
source/blender/draw/modes/object_mode.c
source/blender/draw/modes/shaders/drw_shader_3D_smooth_color_vert.glsl [deleted file]
source/blender/draw/modes/shaders/drw_shader_3D_vert.glsl [deleted file]
source/blender/gpu/shaders/gpu_shader_3D_smooth_color_vert.glsl
source/blender/gpu/shaders/gpu_shader_3D_vert.glsl

index c25d5564b2136148021b04e4df6f7d52be05ac56..acad2a5d14bd3b1e5c57ffa6195ab1cf8f23b5e9 100644 (file)
@@ -325,8 +325,6 @@ data_to_c_simple(modes/shaders/particle_strand_frag.glsl SRC)
 data_to_c_simple(modes/shaders/particle_strand_vert.glsl SRC)
 data_to_c_simple(modes/shaders/sculpt_mask_vert.glsl SRC)
 data_to_c_simple(modes/shaders/volume_velocity_vert.glsl SRC)
-data_to_c_simple(modes/shaders/drw_shader_3D_vert.glsl SRC)
-data_to_c_simple(modes/shaders/drw_shader_3D_smooth_color_vert.glsl SRC)
 
 data_to_c_simple(engines/gpencil/shaders/gpencil_fill_vert.glsl SRC)
 data_to_c_simple(engines/gpencil/shaders/gpencil_fill_frag.glsl SRC)
index 6a70b91d67a98060303369d2040502847d690f7d..889dbaed3da3b178d613aab5168a7c9615c09e80 100644 (file)
 
 extern char datatoc_common_world_clip_lib_glsl[];
 
-extern char datatoc_drw_shader_3D_vert_glsl[];
-extern char datatoc_drw_shader_3D_smooth_color_vert_glsl[];
-
-extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
 extern char datatoc_gpu_shader_3D_smooth_color_frag_glsl[];
+extern char datatoc_gpu_shader_3D_smooth_color_vert_glsl[];
+extern char datatoc_gpu_shader_3D_vert_glsl[];
 extern char datatoc_gpu_shader_depth_only_frag_glsl[];
 extern char datatoc_gpu_shader_flat_color_frag_glsl[];
 extern char datatoc_gpu_shader_instance_camera_vert_glsl[];
+extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
 
 /* cache of built-in shaders (each is created on first use) */
 static struct {
@@ -68,7 +67,7 @@ static GPUShader *drw_shader_get_builtin_shader_clipped(eGPUBuiltinShader shader
                                break;
                        }
                        shader = DRW_shader_create_from_arrays({
-                               .vert = (const char *[]){world_clip_lib, datatoc_drw_shader_3D_vert_glsl, NULL},
+                               .vert = (const char *[]){world_clip_lib, datatoc_gpu_shader_3D_vert_glsl, NULL},
                                .frag = (const char *[]){datatoc_gpu_shader_uniform_color_frag_glsl, NULL},
                                .defs = (const char *[]){world_clip_def, NULL}});
                        break;
@@ -77,7 +76,7 @@ static GPUShader *drw_shader_get_builtin_shader_clipped(eGPUBuiltinShader shader
                                break;
                        }
                        shader = DRW_shader_create_from_arrays({
-                               .vert = (const char *[]){world_clip_lib, datatoc_drw_shader_3D_smooth_color_vert_glsl, NULL},
+                               .vert = (const char *[]){world_clip_lib, datatoc_gpu_shader_3D_smooth_color_vert_glsl, NULL},
                                .frag = (const char *[]){datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL},
                                .defs = (const char *[]){world_clip_def, NULL}});
                        break;
@@ -86,7 +85,7 @@ static GPUShader *drw_shader_get_builtin_shader_clipped(eGPUBuiltinShader shader
                                break;
                        }
                        shader = DRW_shader_create_from_arrays({
-                               .vert = (const char *[]){world_clip_lib, datatoc_drw_shader_3D_vert_glsl, NULL},
+                               .vert = (const char *[]){world_clip_lib, datatoc_gpu_shader_3D_vert_glsl, NULL},
                                .frag = (const char *[]){datatoc_gpu_shader_depth_only_frag_glsl, NULL},
                                .defs = (const char *[]){world_clip_def, NULL}});
                        break;
index 52a173e433f13c6231019c059b1245e54ffcafe0..837de9c9ca724ff5acce70f01ea45108db29e683 100644 (file)
@@ -105,7 +105,7 @@ extern char datatoc_gpu_shader_flat_color_frag_glsl[];
 extern char datatoc_gpu_shader_flat_id_frag_glsl[];
 extern char datatoc_common_fullscreen_vert_glsl[];
 extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
-extern char datatoc_drw_shader_3D_vert_glsl[];
+extern char datatoc_gpu_shader_3D_vert_glsl[];
 
 /* *********** LISTS *********** */
 typedef struct OBJECT_PassList {
@@ -419,7 +419,7 @@ static void OBJECT_engine_init(void *vedata)
        if (!sh_data->outline_resolve) {
                /* Outline */
                sh_data->outline_prepass = DRW_shader_create_from_arrays({
-                       .vert = (const char *[]){world_clip_lib_or_empty, datatoc_drw_shader_3D_vert_glsl, NULL},
+                       .vert = (const char *[]){world_clip_lib_or_empty, datatoc_gpu_shader_3D_vert_glsl, NULL},
                        .frag = (const char *[]){datatoc_object_outline_prepass_frag_glsl, NULL},
                        .defs = (const char *[]){world_clip_def_or_empty, NULL}});
                sh_data->outline_prepass_wire = DRW_shader_create_from_arrays({
@@ -495,7 +495,7 @@ static void OBJECT_engine_init(void *vedata)
 
                /* Loose Points */
                sh_data->loose_points = DRW_shader_create_from_arrays({
-                       .vert = (const char *[]){world_clip_lib_or_empty, datatoc_drw_shader_3D_vert_glsl, NULL},
+                       .vert = (const char *[]){world_clip_lib_or_empty, datatoc_gpu_shader_3D_vert_glsl, NULL},
                        .frag = (const char *[]){datatoc_object_loose_points_frag_glsl, NULL},
                        .defs = (const char *[]){world_clip_def_or_empty, NULL}});
        }
diff --git a/source/blender/draw/modes/shaders/drw_shader_3D_smooth_color_vert.glsl b/source/blender/draw/modes/shaders/drw_shader_3D_smooth_color_vert.glsl
deleted file mode 100644 (file)
index 05f9618..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Keep 'gpu_shader_3D_smooth_color_vert.glsl' compatible. */
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 ModelMatrix;
-
-in vec3 pos;
-in vec4 color;
-
-out vec4 finalColor;
-
-void main()
-{
-       gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
-       finalColor = color;
-#ifdef USE_WORLD_CLIP_PLANES
-       world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
-#endif
-}
diff --git a/source/blender/draw/modes/shaders/drw_shader_3D_vert.glsl b/source/blender/draw/modes/shaders/drw_shader_3D_vert.glsl
deleted file mode 100644 (file)
index f0d4775..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Keep 'gpu_shader_3D_vert.glsl' compatible. */
-uniform mat4 ModelViewProjectionMatrix;
-uniform mat4 ModelMatrix;
-
-in vec3 pos;
-
-void main()
-{
-       gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
-#ifdef USE_WORLD_CLIP_PLANES
-       world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
-#endif
-}
index a1feb2f75b73f529589d29f7c45f0b485e3c7522..955ce07780ca99f885a4058cb03d99776bcc4cf9 100644 (file)
@@ -1,6 +1,10 @@
 
 uniform mat4 ModelViewProjectionMatrix;
 
+#ifdef USE_WORLD_CLIP_PLANES
+uniform mat4 ModelMatrix;
+#endif
+
 in vec3 pos;
 in vec4 color;
 
@@ -10,4 +14,8 @@ void main()
 {
        gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
        finalColor = color;
+
+#ifdef USE_WORLD_CLIP_PLANES
+       world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
+#endif
 }
index 059473ebb7411631ba443542d5de8ddea292b7f5..9fc748b292bafe05e318332ca5236267459ebad5 100644 (file)
@@ -1,9 +1,17 @@
 
 uniform mat4 ModelViewProjectionMatrix;
 
+#ifdef USE_WORLD_CLIP_PLANES
+uniform mat4 ModelMatrix;
+#endif
+
 in vec3 pos;
 
 void main()
 {
        gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+
+#ifdef USE_WORLD_CLIP_PLANES
+       world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
+#endif
 }