[Bf-blender-cvs] [577d3498b4d] master: Cleanup: DRW: Move WorldClipPlanes to builtin uniform

Clément Foucault noreply at git.blender.org
Mon May 27 12:58:25 CEST 2019


Commit: 577d3498b4d4d3b747e184550378bc7d77e72b60
Author: Clément Foucault
Date:   Sun May 26 20:36:24 2019 +0200
Branches: master
https://developer.blender.org/rB577d3498b4d4d3b747e184550378bc7d77e72b60

Cleanup: DRW: Move WorldClipPlanes to builtin uniform

===================================================================

M	source/blender/draw/engines/basic/basic_engine.c
M	source/blender/draw/engines/workbench/workbench_forward.c
M	source/blender/draw/engines/workbench/workbench_materials.c
M	source/blender/draw/intern/draw_common.c
M	source/blender/draw/intern/draw_common.h
M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/intern/draw_manager_data.c
M	source/blender/draw/modes/edit_curve_mode.c
M	source/blender/draw/modes/edit_lattice_mode.c
M	source/blender/draw/modes/edit_mesh_mode.c
M	source/blender/draw/modes/object_mode.c
M	source/blender/draw/modes/overlay_mode.c
M	source/blender/draw/modes/paint_texture_mode.c
M	source/blender/draw/modes/paint_vertex_mode.c
M	source/blender/gpu/GPU_shader_interface.h
M	source/blender/gpu/intern/gpu_shader_interface.c

===================================================================

diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c
index d6902dddc61..a274eda84fe 100644
--- a/source/blender/draw/engines/basic/basic_engine.c
+++ b/source/blender/draw/engines/basic/basic_engine.c
@@ -94,7 +94,6 @@ static void basic_cache_init(void *vedata)
 
   const DRWContextState *draw_ctx = DRW_context_state_get();
   BASIC_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg];
-  const RegionView3D *rv3d = draw_ctx->rv3d;
 
   if (!stl->g_data) {
     /* Alloc transient pointers */
@@ -106,7 +105,7 @@ static void basic_cache_init(void *vedata)
                                       DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL);
     stl->g_data->depth_shgrp = DRW_shgroup_create(sh_data->depth, psl->depth_pass);
     if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-      DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->depth_shgrp, rv3d);
+      DRW_shgroup_state_enable(stl->g_data->depth_shgrp, DRW_STATE_CLIP_PLANES);
     }
 
     psl->depth_pass_cull = DRW_pass_create("Depth Pass Cull",
@@ -114,7 +113,7 @@ static void basic_cache_init(void *vedata)
                                                DRW_STATE_CULL_BACK);
     stl->g_data->depth_shgrp_cull = DRW_shgroup_create(sh_data->depth, psl->depth_pass_cull);
     if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-      DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->depth_shgrp_cull, rv3d);
+      DRW_shgroup_state_enable(stl->g_data->depth_shgrp_cull, DRW_STATE_CLIP_PLANES);
     }
   }
 }
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index f12902b6801..5f15fb3f19e 100644
--- a/source/blender/draw/engines/workbench/workbench_forward.c
+++ b/source/blender/draw/engines/workbench/workbench_forward.c
@@ -212,7 +212,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_
     material->object_id = engine_object_data->object_id;
     DRW_shgroup_uniform_int(material->shgrp_object_outline, "object_id", &material->object_id, 1);
     if (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-      DRW_shgroup_world_clip_planes_from_rv3d(material->shgrp_object_outline, draw_ctx->rv3d);
+      DRW_shgroup_state_enable(material->shgrp_object_outline, DRW_STATE_CLIP_PLANES);
     }
     BLI_ghash_insert(wpd->material_transp_hash, POINTER_FROM_UINT(hash), material);
   }
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index a079d64a799..02fbbe0b042 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -316,7 +316,6 @@ void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd,
   }
 
   if (WORLD_CLIPPING_ENABLED(wpd)) {
-    DRW_shgroup_uniform_vec4(grp, "WorldClipPlanes", wpd->world_clip_planes[0], 6);
     DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
 }
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index 28b34bffe3e..bcca660f861 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -306,13 +306,6 @@ void DRW_globals_free(void)
   }
 }
 
-void DRW_shgroup_world_clip_planes_from_rv3d(DRWShadingGroup *shgrp, const RegionView3D *rv3d)
-{
-  int world_clip_planes_len = (rv3d->viewlock & RV3D_BOXCLIP) ? 4 : 6;
-  DRW_shgroup_uniform_vec4(shgrp, "WorldClipPlanes", rv3d->clip[0], world_clip_planes_len);
-  DRW_shgroup_state_enable(shgrp, DRW_STATE_CLIP_PLANES);
-}
-
 struct DRWCallBuffer *buffer_dynlines_flat_color(DRWPass *pass, eGPUShaderConfig sh_cfg)
 {
   GPUShader *sh = GPU_shader_get_builtin_shader_with_config(GPU_SHADER_3D_FLAT_COLOR, sh_cfg);
@@ -325,7 +318,7 @@ struct DRWCallBuffer *buffer_dynlines_flat_color(DRWPass *pass, eGPUShaderConfig
 
   DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer(grp, g_formats.pos_color, GPU_PRIM_LINES);
 }
@@ -349,7 +342,7 @@ struct DRWCallBuffer *buffer_dynlines_dashed_uniform_color(DRWPass *pass,
   DRW_shgroup_uniform_float(grp, "dash_factor", &dash_factor, 1);
   DRW_shgroup_uniform_int_copy(grp, "colors_len", 0); /* "simple" mode */
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer(grp, g_formats.pos, GPU_PRIM_LINES);
 }
@@ -372,7 +365,7 @@ struct DRWCallBuffer *buffer_groundlines_uniform_color(DRWPass *pass,
   DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
   DRW_shgroup_uniform_vec4(grp, "color", color, 1);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer(grp, g_formats.pos, GPU_PRIM_POINTS);
 }
@@ -388,7 +381,7 @@ struct DRWCallBuffer *buffer_groundpoints_uniform_color(DRWPass *pass,
   DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
   DRW_shgroup_uniform_vec4(grp, "color", color, 1);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer(grp, g_formats.pos, GPU_PRIM_POINTS);
 }
@@ -412,7 +405,7 @@ struct DRWCallBuffer *buffer_instance_screenspace(DRWPass *pass,
   DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
   DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_screenspace, geom);
 }
@@ -467,7 +460,7 @@ struct DRWCallBuffer *buffer_instance_screen_aligned(DRWPass *pass,
   DRWShadingGroup *grp = DRW_shgroup_create(sh, pass);
   DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_screen_aligned, geom);
 }
@@ -488,7 +481,7 @@ struct DRWCallBuffer *buffer_instance_scaled(DRWPass *pass,
 
   DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_scaled, geom);
 }
@@ -510,7 +503,7 @@ struct DRWCallBuffer *buffer_instance(DRWPass *pass,
   DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass);
   DRW_shgroup_state_disable(grp, DRW_STATE_BLEND);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_sized, geom);
 }
@@ -551,7 +544,7 @@ struct DRWCallBuffer *buffer_instance_empty_axes(DRWPass *pass,
   DRWShadingGroup *grp = DRW_shgroup_create(sh_data->empty_axes_sh, pass);
   DRW_shgroup_uniform_vec3(grp, "screenVecs[0]", DRW_viewport_screenvecs_get(), 2);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_sized, geom);
 }
@@ -591,7 +584,7 @@ struct DRWCallBuffer *buffer_camera_instance(DRWPass *pass,
 
   DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_camera, geom);
 }
@@ -615,7 +608,7 @@ struct DRWCallBuffer *buffer_distance_lines_instance(DRWPass *pass,
   DRWShadingGroup *grp = DRW_shgroup_create(sh_inst, pass);
   DRW_shgroup_uniform_float(grp, "size", &point_size, 1);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_distance_lines, geom);
 }
@@ -640,7 +633,7 @@ struct DRWCallBuffer *buffer_spot_instance(DRWPass *pass,
   DRW_shgroup_uniform_bool(grp, "drawBack", &False, 1);
   DRW_shgroup_uniform_bool(grp, "drawSilhouette", &True, 1);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(grp, g_formats.instance_spot, geom);
 }
@@ -666,7 +659,7 @@ struct DRWCallBuffer *buffer_instance_bone_axes(DRWPass *pass, eGPUShaderConfig
   DRWShadingGroup *grp = DRW_shgroup_create(sh_data->bone_axes, pass);
   DRW_shgroup_uniform_vec3(grp, "screenVecs[0]", DRW_viewport_screenvecs_get(), 2);
   if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
-    DRW_shgroup_world_clip_planes_from_rv3d(grp, DRW_context_state_get()->rv3d);
+    DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
   }
   return DRW_shgroup_call_buffer_instance(
       grp, g_formats.instance_color, DRW_cache_bone_arrows_get());
@@ -696,7 +689,7 @@ struct DRWCallBuffer *buffer_instance_bone_envelope_outline(DRWPass *pass, eGPUS
   DRWShadingGroup *grp = DRW_shgroup_create(sh_data->bone_envelope_out

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list