DRW: Refactor to use object pointer for drawcall by default
authorClément Foucault <foucault.clem@gmail.com>
Wed, 29 May 2019 21:52:37 +0000 (23:52 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Thu, 30 May 2019 11:43:33 +0000 (13:43 +0200)
This cleans up a bit of duplicated code and some confusion about
what was culled and what wasn't.

Now everything is culled based on the given object pointer.

If the object pointer is NULL there is no culling performed.

25 files changed:
source/blender/draw/engines/basic/basic_engine.c
source/blender/draw/engines/eevee/eevee_depth_of_field.c
source/blender/draw/engines/eevee/eevee_effects.c
source/blender/draw/engines/eevee/eevee_lightprobes.c
source/blender/draw/engines/eevee/eevee_lights.c
source/blender/draw/engines/eevee/eevee_materials.c
source/blender/draw/engines/eevee/eevee_volumes.c
source/blender/draw/engines/external/external_engine.c
source/blender/draw/engines/gpencil/gpencil_draw_utils.c
source/blender/draw/engines/gpencil/gpencil_engine.c
source/blender/draw/engines/workbench/workbench_deferred.c
source/blender/draw/engines/workbench/workbench_forward.c
source/blender/draw/engines/workbench/workbench_volume.c
source/blender/draw/intern/DRW_render.h
source/blender/draw/intern/draw_hair.c
source/blender/draw/intern/draw_manager_data.c
source/blender/draw/modes/edit_curve_mode.c
source/blender/draw/modes/edit_lattice_mode.c
source/blender/draw/modes/edit_mesh_mode.c
source/blender/draw/modes/edit_text_mode.c
source/blender/draw/modes/object_mode.c
source/blender/draw/modes/overlay_mode.c
source/blender/draw/modes/paint_texture_mode.c
source/blender/draw/modes/paint_vertex_mode.c
source/blender/draw/modes/pose_mode.c

index a274eda..beff451 100644 (file)
@@ -154,7 +154,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
     if (is_flat_object_viewed_from_side) {
       /* Avoid losing flat objects when in ortho views (see T56549) */
       struct GPUBatch *geom = DRW_cache_object_all_edges_get(ob);
-      DRW_shgroup_call_object(stl->g_data->depth_shgrp, geom, ob);
+      DRW_shgroup_call(stl->g_data->depth_shgrp, geom, ob);
       return;
     }
   }
@@ -164,7 +164,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
     const bool do_cull = (draw_ctx->v3d &&
                           (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING));
     /* Depth Prepass */
-    DRW_shgroup_call_object(
+    DRW_shgroup_call(
         (do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob);
   }
 }
index 4675901..8c3e58e 100644 (file)
@@ -217,7 +217,7 @@ void EEVEE_depth_of_field_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_
     DRW_shgroup_uniform_texture_ref(grp, "cocBuffer", &effects->dof_coc);
     DRW_shgroup_uniform_vec4(grp, "bokehParams", effects->dof_bokeh, 2);
 
-    DRW_shgroup_call_procedural_triangles(grp, sprite_len, NULL);
+    DRW_shgroup_call_procedural_triangles(grp, NULL, sprite_len);
 
     DRW_PASS_CREATE(psl->dof_resolve, DRW_STATE_WRITE_COLOR);
 
index 8e670da..8f2fd63 100644 (file)
@@ -292,7 +292,7 @@ void EEVEE_effects_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
     DRW_shgroup_uniform_texture_ref(grp, "source", &e_data.color_src);
     DRW_shgroup_uniform_float(grp, "texelSize", &e_data.cube_texel_size, 1);
     DRW_shgroup_uniform_int_copy(grp, "Layer", 0);
-    DRW_shgroup_call_instances(grp, quad, NULL, 6);
+    DRW_shgroup_call_instances(grp, NULL, quad, 6);
   }
 
   {
index 6253a9d..bbad169 100644 (file)
@@ -398,7 +398,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
       DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
       DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
 
-      DRW_shgroup_call_procedural_triangles(grp, cube_len * 2, NULL);
+      DRW_shgroup_call_procedural_triangles(grp, NULL, cube_len * 2);
     }
 
     /* Grid Display */
@@ -424,7 +424,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
         DRW_shgroup_uniform_block(shgrp, "grid_block", sldata->grid_ubo);
         DRW_shgroup_uniform_block(shgrp, "common_block", sldata->common_ubo);
         int tri_count = egrid->resolution[0] * egrid->resolution[1] * egrid->resolution[2] * 2;
-        DRW_shgroup_call_procedural_triangles(shgrp, tri_count, NULL);
+        DRW_shgroup_call_procedural_triangles(shgrp, NULL, tri_count);
       }
     }
 
@@ -787,7 +787,7 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
 
     DRW_shgroup_uniform_texture_ref(grp, "source", &txl->planar_pool);
     DRW_shgroup_uniform_float(grp, "fireflyFactor", &sldata->common_data.ssr_firefly_fac, 1);
-    DRW_shgroup_call_procedural_triangles(grp, pinfo->num_planar, NULL);
+    DRW_shgroup_call_procedural_triangles(grp, NULL, pinfo->num_planar);
   }
 }
 
index e966fad..24d35e2 100644 (file)
@@ -453,7 +453,7 @@ void EEVEE_lights_cache_shcaster_add(EEVEE_ViewLayerData *UNUSED(sldata),
                                      struct GPUBatch *geom,
                                      Object *ob)
 {
-  DRW_shgroup_call_object(stl->g_data->shadow_shgrp, geom, ob);
+  DRW_shgroup_call(stl->g_data->shadow_shgrp, geom, ob);
 }
 
 void EEVEE_lights_cache_shcaster_material_add(EEVEE_ViewLayerData *sldata,
@@ -483,7 +483,7 @@ void EEVEE_lights_cache_shcaster_material_add(EEVEE_ViewLayerData *sldata,
     DRW_shgroup_uniform_float(grp, "alphaThreshold", alpha_threshold, 1);
   }
 
-  DRW_shgroup_call_object(grp, geom, ob);
+  DRW_shgroup_call(grp, geom, ob);
 }
 
 /* Make that object update shadow casting lights inside its influence bounding box. */
index cd75cce..3b78d87 100644 (file)
@@ -1126,10 +1126,10 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
 #define ADD_SHGROUP_CALL(shgrp, ob, geom, oedata) \
   do { \
     if (oedata) { \
-      DRW_shgroup_call_object_with_callback(shgrp, geom, ob, oedata); \
+      DRW_shgroup_call_with_callback(shgrp, geom, ob, oedata); \
     } \
     else { \
-      DRW_shgroup_call_object(shgrp, geom, ob); \
+      DRW_shgroup_call(shgrp, geom, ob); \
     } \
   } while (0)
 
index 47a02a2..e3afa91 100644 (file)
@@ -356,7 +356,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
       DRW_shgroup_uniform_texture(grp, "sampflame", e_data.dummy_flame);
       DRW_shgroup_uniform_vec2_copy(grp, "unftemperature", (float[2]){0.0f, 1.0f});
 
-      DRW_shgroup_call_procedural_triangles(grp, common_data->vol_tex_size[2], NULL);
+      DRW_shgroup_call_procedural_triangles(grp, NULL, common_data->vol_tex_size[2]);
 
       effects->enabled_effects |= (EFFECT_VOLUMETRIC | EFFECT_POST_BUFFER);
     }
@@ -367,7 +367,7 @@ void EEVEE_volumes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
     grp = DRW_shgroup_create(e_data.volumetric_clear_sh, psl->volumetric_world_ps);
     DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
 
-    DRW_shgroup_call_procedural_triangles(grp, common_data->vol_tex_size[2], NULL);
+    DRW_shgroup_call_procedural_triangles(grp, NULL, common_data->vol_tex_size[2]);
   }
 }
 
@@ -462,7 +462,7 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
 
   /* TODO Reduce to number of slices intersecting. */
   /* TODO Preemptive culling. */
-  DRW_shgroup_call_procedural_triangles(grp, sldata->common_data.vol_tex_size[2], ob->obmat);
+  DRW_shgroup_call_procedural_triangles(grp, ob, sldata->common_data.vol_tex_size[2]);
 
   vedata->stl->effects->enabled_effects |= (EFFECT_VOLUMETRIC | EFFECT_POST_BUFFER);
 }
@@ -495,7 +495,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
     DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
     DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
 
-    DRW_shgroup_call_procedural_triangles(grp, common_data->vol_tex_size[2], NULL);
+    DRW_shgroup_call_procedural_triangles(grp, NULL, common_data->vol_tex_size[2]);
 
     DRW_PASS_CREATE(psl->volumetric_integration_ps, DRW_STATE_WRITE_COLOR);
     grp = DRW_shgroup_create(e_data.volumetric_integration_sh, psl->volumetric_integration_ps);
@@ -503,7 +503,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
     DRW_shgroup_uniform_texture_ref(grp, "volumeExtinction", &txl->volume_transmit);
     DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
 
-    DRW_shgroup_call_procedural_triangles(grp, common_data->vol_tex_size[2], NULL);
+    DRW_shgroup_call_procedural_triangles(grp, NULL, common_data->vol_tex_size[2]);
 
     DRW_PASS_CREATE(psl->volumetric_resolve_ps, DRW_STATE_WRITE_COLOR);
     grp = DRW_shgroup_create(e_data.volumetric_resolve_sh, psl->volumetric_resolve_ps);
@@ -513,7 +513,7 @@ void EEVEE_volumes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
     DRW_shgroup_uniform_texture_ref(grp, "inSceneDepth", &e_data.depth_src);
     DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
 
-    DRW_shgroup_call_procedural_triangles(grp, 1, NULL);
+    DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
   }
 }
 
index d8748b0..9512304 100644 (file)
@@ -188,7 +188,7 @@ static void external_cache_populate(void *vedata, Object *ob)
     struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
     if (geom) {
       /* Depth Prepass */
-      DRW_shgroup_call(stl->g_data->depth_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->depth_shgrp, geom, ob);
     }
   }
 }
index 964b797..cd35395 100644 (file)
@@ -1705,6 +1705,7 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
       break;
     }
 
+    float(*obmat)[4] = (!cache_ob->is_dup_ob) ? gpf->runtime.parent_obmat : cache_ob->obmat;
     switch (elm->type) {
       case eGpencilBatchGroupType_Stroke: {
         const int len = elm->vertex_idx - start_stroke;
@@ -1723,12 +1724,7 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
                                                   scale,
                                                   cache_ob->shading_type);
         if ((do_onion) || (elm->onion == false)) {
-          DRW_shgroup_call_range(shgrp,
-                                 cache->b_stroke.batch,
-                                 (!cache_ob->is_dup_ob) ? gpf->runtime.parent_obmat :
-                                                          cache_ob->obmat,
-                                 start_stroke,
-                                 len);
+          DRW_shgroup_call_range_obmat(shgrp, cache->b_stroke.batch, obmat, start_stroke, len);
         }
         stl->storage->shgroup_id++;
         start_stroke = elm->vertex_idx;
@@ -1752,12 +1748,7 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
                                                  cache_ob->shading_type);
 
         if ((do_onion) || (elm->onion == false)) {
-          DRW_shgroup_call_range(shgrp,
-                                 cache->b_point.batch,
-                                 (!cache_ob->is_dup_ob) ? gpf->runtime.parent_obmat :
-                                                          cache_ob->obmat,
-                                 start_point,
-                                 len);
+          DRW_shgroup_call_range_obmat(shgrp, cache->b_point.batch, obmat, start_point, len);
         }
         stl->storage->shgroup_id++;
         start_point = elm->vertex_idx;
@@ -1778,12 +1769,7 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
                                                 cache_ob->shading_type);
 
         if ((do_onion) || (elm->onion == false)) {
-          DRW_shgroup_call_range(shgrp,
-                                 cache->b_fill.batch,
-                                 (!cache_ob->is_dup_ob) ? gpf->runtime.parent_obmat :
-                                                          cache_ob->obmat,
-                                 start_fill,
-                                 len);
+          DRW_shgroup_call_range_obmat(shgrp, cache->b_fill.batch, obmat, start_fill, len);
         }
         stl->storage->shgroup_id++;
         start_fill = elm->vertex_idx;
@@ -1793,12 +1779,8 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
         if (stl->g_data->shgrps_edit_point) {
           const int len = elm->vertex_idx - start_edit;
           /* use always the same group */
-          DRW_shgroup_call_range(stl->g_data->shgrps_edit_point,
-                                 cache->b_edit.batch,
-                                 (!cache_ob->is_dup_ob) ? gpf->runtime.parent_obmat :
-                                                          cache_ob->obmat,
-                                 start_edit,
-                                 len);
+          DRW_shgroup_call_range_obmat(
+              stl->g_data->shgrps_edit_point, cache->b_edit.batch, obmat, start_edit, len);
 
           start_edit = elm->vertex_idx;
         }
@@ -1808,12 +1790,8 @@ static void DRW_gpencil_shgroups_create(GPENCIL_e_data *e_data,
         if (stl->g_data->shgrps_edit_line) {
           const int len = elm->vertex_idx - start_edlin;
           /* use always the same group */
-          DRW_shgroup_call_range(stl->g_data->shgrps_edit_line,
-                                 cache->b_edlin.batch,
-                                 (!cache_ob->is_dup_ob) ? gpf->runtime.parent_obmat :
-                                                          cache_ob->obmat,
-                                 start_edlin,
-                                 len);
+          DRW_shgroup_call_range_obmat(
+              stl->g_data->shgrps_edit_line, cache->b_edlin.batch, obmat, start_edlin, len);
 
           start_edlin = elm->vertex_idx;
         }
index f597797..f78f729 100644 (file)
@@ -680,7 +680,7 @@ void GPENCIL_cache_populate(void *vedata, Object *ob)
         copy_v3_v3(grid_matrix[3], ob->obmat[3]);
       }
 
-      DRW_shgroup_call(stl->g_data->shgrps_grid, e_data.batch_grid, grid_matrix);
+      DRW_shgroup_call_obmat(stl->g_data->shgrps_grid, e_data.batch_grid, grid_matrix);
     }
   }
 }
index 3e442ce..516d4de 100644 (file)
@@ -993,7 +993,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
             material = get_or_create_material_data(
                 vedata, ob, mat, image, iuser, color_type, interp);
           }
-          DRW_shgroup_call_object(material->shgrp, geom_array[i], ob);
+          DRW_shgroup_call(material->shgrp, geom_array[i], ob);
         }
       }
     }
@@ -1030,7 +1030,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
         }
 
         if (geom) {
-          DRW_shgroup_call_object(material->shgrp, geom, ob);
+          DRW_shgroup_call(material->shgrp, geom, ob);
         }
       }
     }
@@ -1077,7 +1077,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
               material = get_or_create_material_data(
                   vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0);
             }
-            DRW_shgroup_call_object(material->shgrp, geoms[i], ob);
+            DRW_shgroup_call(material->shgrp, geoms[i], ob);
           }
         }
       }
@@ -1120,7 +1120,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
               }
               DRW_shgroup_uniform_vec3(grp, "lightDirection", engine_object_data->shadow_dir, 1);
               DRW_shgroup_uniform_float_copy(grp, "lightDistance", 1e5f);
-              DRW_shgroup_call(grp, geom_shadow, ob->obmat);
+              DRW_shgroup_call_no_cull(grp, geom_shadow, ob);
 #ifdef DEBUG_SHADOW_VOLUME
               DRW_debug_bbox(&engine_object_data->shadow_bbox, (float[4]){1.0f, 0.0f, 0.0f, 1.0f});
 #endif
@@ -1142,7 +1142,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
                 }
                 DRW_shgroup_uniform_vec3(grp, "lightDirection", engine_object_data->shadow_dir, 1);
                 DRW_shgroup_uniform_float_copy(grp, "lightDistance", extrude_distance);
-                DRW_shgroup_call(grp, DRW_cache_object_surface_get(ob), ob->obmat);
+                DRW_shgroup_call_no_cull(grp, DRW_cache_object_surface_get(ob), ob);
               }
 
               if (is_manifold) {
@@ -1154,7 +1154,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
               }
               DRW_shgroup_uniform_vec3(grp, "lightDirection", engine_object_data->shadow_dir, 1);
               DRW_shgroup_uniform_float_copy(grp, "lightDistance", extrude_distance);
-              DRW_shgroup_call(grp, geom_shadow, ob->obmat);
+              DRW_shgroup_call_no_cull(grp, geom_shadow, ob);
 #ifdef DEBUG_SHADOW_VOLUME
               DRW_debug_bbox(&engine_object_data->shadow_bbox, (float[4]){0.0f, 1.0f, 0.0f, 1.0f});
 #endif
index 6b19821..26c4b92 100644 (file)
@@ -582,8 +582,8 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
         int color_type = workbench_material_determine_color_type(wpd, image, ob, is_sculpt_mode);
         material = workbench_forward_get_or_create_material_data(
             vedata, ob, mat, image, iuser, color_type, interp, is_sculpt_mode);
-        DRW_shgroup_call_object(material->shgrp_object_outline, geom_array[i], ob);
-        DRW_shgroup_call_object(material->shgrp, geom_array[i], ob);
+        DRW_shgroup_call(material->shgrp_object_outline, geom_array[i], ob);
+        DRW_shgroup_call(material->shgrp, geom_array[i], ob);
       }
     }
     else if (ELEM(wpd->shading.color_type,
@@ -612,9 +612,9 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
           material = workbench_forward_get_or_create_material_data(
               vedata, ob, NULL, NULL, NULL, color_type, 0, is_sculpt_mode);
           /* TODO(fclem) make this call optional */
-          DRW_shgroup_call_object(material->shgrp_object_outline, geom, ob);
+          DRW_shgroup_call(material->shgrp_object_outline, geom, ob);
           if (!is_wire) {
-            DRW_shgroup_call_object(material->shgrp, geom, ob);
+            DRW_shgroup_call(material->shgrp, geom, ob);
           }
         }
       }
@@ -652,9 +652,9 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
             material = workbench_forward_get_or_create_material_data(
                 vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode);
             /* TODO(fclem) make this call optional */
-            DRW_shgroup_call_object(material->shgrp_object_outline, mat_geom[i], ob);
+            DRW_shgroup_call(material->shgrp_object_outline, mat_geom[i], ob);
             if (!is_wire) {
-              DRW_shgroup_call_object(material->shgrp, mat_geom[i], ob);
+              DRW_shgroup_call(material->shgrp, mat_geom[i], ob);
             }
           }
         }
index a2fdf35..575da1f 100644 (file)
@@ -211,10 +211,10 @@ void workbench_volume_cache_populate(WORKBENCH_Data *vedata,
   DRW_shgroup_uniform_float_copy(grp, "densityScale", 10.0f * sds->display_thickness);
 
   if (use_slice) {
-    DRW_shgroup_call_object(grp, DRW_cache_quad_get(), ob);
+    DRW_shgroup_call(grp, DRW_cache_quad_get(), ob);
   }
   else {
-    DRW_shgroup_call_object(grp, DRW_cache_cube_get(), ob);
+    DRW_shgroup_call(grp, DRW_cache_cube_get(), ob);
   }
 
   BLI_addtail(&wpd->smoke_domains, BLI_genericNodeN(smd));
index 4066352..4115038 100644 (file)
@@ -392,37 +392,51 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader,
 /* return final visibility */
 typedef bool(DRWCallVisibilityFn)(bool vis_in, void *user_data);
 
-void DRW_shgroup_call(DRWShadingGroup *sh, struct GPUBatch *geom, float (*obmat)[4]);
-void DRW_shgroup_call_range(
-    DRWShadingGroup *sh, struct GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_ct);
+void DRW_shgroup_call_ex(DRWShadingGroup *shgroup,
+                         Object *ob,
+                         float (*obmat)[4],
+                         struct GPUBatch *geom,
+                         uint v_sta,
+                         uint v_ct,
+                         bool bypass_culling,
+                         void *user_data);
 
-void DRW_shgroup_call_procedural_points(DRWShadingGroup *sh, uint point_ct, float (*obmat)[4]);
-void DRW_shgroup_call_procedural_lines(DRWShadingGroup *sh, uint line_ct, float (*obmat)[4]);
-void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *sh, uint tri_ct, float (*obmat)[4]);
+/* If ob is NULL, unit modelmatrix is assumed and culling is bypassed. */
+#define DRW_shgroup_call(shgrp, geom, ob) \
+  DRW_shgroup_call_ex(shgrp, ob, NULL, geom, 0, 0, false, NULL);
 
-void DRW_shgroup_call_object_ex(DRWShadingGroup *shgroup,
-                                struct GPUBatch *geom,
-                                struct Object *ob,
-                                bool bypass_culling);
-#define DRW_shgroup_call_object(shgroup, geom, ob) \
-  DRW_shgroup_call_object_ex(shgroup, geom, ob, false)
-#define DRW_shgroup_call_object_no_cull(shgroup, geom, ob) \
-  DRW_shgroup_call_object_ex(shgroup, geom, ob, true)
+/* Same as DRW_shgroup_call but override the obmat. Not culled. */
+#define DRW_shgroup_call_obmat(shgrp, geom, obmat) \
+  DRW_shgroup_call_ex(shgrp, NULL, obmat, geom, 0, 0, false, NULL);
 
 /* TODO(fclem) remove this when we have DRWView */
 /* user_data is used by DRWCallVisibilityFn defined in DRWView. */
-void DRW_shgroup_call_object_with_callback(DRWShadingGroup *shgroup,
-                                           struct GPUBatch *geom,
-                                           struct Object *ob,
-                                           void *user_data);
+#define DRW_shgroup_call_with_callback(shgrp, geom, ob, user_data) \
+  DRW_shgroup_call_ex(shgrp, ob, NULL, geom, 0, 0, false, user_data);
+
+/* Same as DRW_shgroup_call but bypass culling even if ob is not NULL. */
+#define DRW_shgroup_call_no_cull(shgrp, geom, ob) \
+  DRW_shgroup_call_ex(shgrp, ob, NULL, geom, 0, 0, true, NULL);
+
+/* Only draw a certain range of geom. */
+#define DRW_shgroup_call_range(shgrp, geom, ob, v_sta, v_ct) \
+  DRW_shgroup_call_ex(shgrp, ob, NULL, geom, v_sta, v_ct, false, NULL);
+
+/* Same as DRW_shgroup_call_range but override the obmat. Special for gpencil. */
+#define DRW_shgroup_call_range_obmat(shgrp, geom, obmat, v_sta, v_ct) \
+  DRW_shgroup_call_ex(shgrp, NULL, obmat, geom, v_sta, v_ct, false, NULL);
+
+void DRW_shgroup_call_procedural_points(DRWShadingGroup *sh, Object *ob, uint point_ct);
+void DRW_shgroup_call_procedural_lines(DRWShadingGroup *sh, Object *ob, uint line_ct);
+void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *sh, Object *ob, uint tri_ct);
 
 void DRW_shgroup_call_instances(DRWShadingGroup *shgroup,
+                                Object *ob,
                                 struct GPUBatch *geom,
-                                float (*obmat)[4],
                                 uint count);
 void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup,
+                                             Object *ob,
                                              struct GPUBatch *geom,
-                                             float (*obmat)[4],
                                              struct GPUBatch *inst_attributes);
 
 void DRW_shgroup_call_sculpt(DRWShadingGroup *sh, Object *ob, bool wire, bool mask, bool vcol);
index 50819f6..20d5ae0 100644 (file)
@@ -195,8 +195,8 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
       shgrp, "hairCloseTip", (part->shape_flag & PART_SHAPE_CLOSE_TIP) != 0);
   /* TODO(fclem): Until we have a better way to cull the hair and render with orco, bypass culling
    * test. */
-  DRW_shgroup_call_object_no_cull(
-      shgrp, hair_cache->final[subdiv].proc_hairs[thickness_res - 1], object);
+  GPUBatch *geom = hair_cache->final[subdiv].proc_hairs[thickness_res - 1];
+  DRW_shgroup_call_no_cull(shgrp, geom, object);
 
   /* Transform Feedback subdiv. */
   if (need_ft_update) {
@@ -224,7 +224,7 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(Object *object,
     DRW_shgroup_uniform_texture(tf_shgrp, "hairStrandBuffer", hair_cache->strand_tex);
     DRW_shgroup_uniform_texture(tf_shgrp, "hairStrandSegBuffer", hair_cache->strand_seg_tex);
     DRW_shgroup_uniform_int(tf_shgrp, "hairStrandsRes", &hair_cache->final[subdiv].strands_res, 1);
-    DRW_shgroup_call_procedural_points(tf_shgrp, final_points_len, NULL);
+    DRW_shgroup_call_procedural_points(tf_shgrp, NULL, final_points_len);
   }
 
   return shgrp;
index 24f2670..5aec14a 100644 (file)
@@ -433,65 +433,70 @@ static DRWCallState *drw_call_state_create(DRWShadingGroup *shgroup, float (*obm
 
 static DRWCallState *drw_call_state_object(DRWShadingGroup *shgroup, float (*obmat)[4], Object *ob)
 {
-  if (DST.ob_state == NULL) {
-    DST.ob_state = drw_call_state_create(shgroup, obmat, ob);
+  if (ob == NULL) {
+    if (obmat == NULL) {
+      /* TODO return unitmat state. */
+      return drw_call_state_create(shgroup, obmat, ob);
+    }
+    else {
+      return drw_call_state_create(shgroup, obmat, ob);
+    }
   }
   else {
-    /* If the DRWCallState is reused, add necessary matrices. */
-    drw_call_state_update_matflag(DST.ob_state, shgroup, ob);
-  }
-
-  return DST.ob_state;
-}
-
-void DRW_shgroup_call(DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4])
-{
-  BLI_assert(geom != NULL);
-
-  DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
-  BLI_LINKS_APPEND(&shgroup->calls, call);
+    if (DST.ob_state == NULL) {
+      DST.ob_state = drw_call_state_create(shgroup, obmat, ob);
+    }
+    else {
+      /* If the DRWCallState is reused, add necessary matrices. */
+      drw_call_state_update_matflag(DST.ob_state, shgroup, ob);
+    }
 
-  call->state = drw_call_state_create(shgroup, obmat, NULL);
-  call->batch = geom;
-  call->vert_first = 0;
-  call->vert_count = 0; /* Auto from batch. */
-  call->inst_count = 0;
-#ifdef USE_GPU_SELECT
-  call->select_id = DST.select_id;
-  call->inst_selectid = NULL;
-#endif
+    return DST.ob_state;
+  }
 }
 
-void DRW_shgroup_call_range(
-    DRWShadingGroup *shgroup, GPUBatch *geom, float (*obmat)[4], uint v_sta, uint v_count)
+void DRW_shgroup_call_ex(DRWShadingGroup *shgroup,
+                         Object *ob,
+                         float (*obmat)[4],
+                         struct GPUBatch *geom,
+                         uint v_sta,
+                         uint v_ct,
+                         bool bypass_culling,
+                         void *user_data)
 {
   BLI_assert(geom != NULL);
-  BLI_assert(v_count);
 
   DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
   BLI_LINKS_APPEND(&shgroup->calls, call);
 
-  call->state = drw_call_state_create(shgroup, obmat, NULL);
+  call->state = drw_call_state_object(shgroup, ob ? ob->obmat : obmat, ob);
   call->batch = geom;
   call->vert_first = v_sta;
-  call->vert_count = v_count;
+  call->vert_count = v_ct; /* 0 means auto from batch. */
   call->inst_count = 0;
 #ifdef USE_GPU_SELECT
   call->select_id = DST.select_id;
   call->inst_selectid = NULL;
 #endif
+  if (call->state->culling) {
+    call->state->culling->user_data = user_data;
+    if (bypass_culling) {
+      /* NOTE this will disable culling for the whole object. */
+      call->state->culling->bsphere.radius = -1.0f;
+    }
+  }
 }
 
 static void drw_shgroup_call_procedural_add_ex(DRWShadingGroup *shgroup,
                                                GPUBatch *geom,
-                                               uint vert_count,
-                                               float (*obmat)[4])
+                                               Object *ob,
+                                               uint vert_count)
 {
 
   DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
   BLI_LINKS_APPEND(&shgroup->calls, call);
 
-  call->state = drw_call_state_object(shgroup, obmat, NULL);
+  call->state = drw_call_state_object(shgroup, ob ? ob->obmat : NULL, ob);
   call->batch = geom;
   call->vert_first = 0;
   call->vert_count = vert_count;
@@ -502,81 +507,27 @@ static void drw_shgroup_call_procedural_add_ex(DRWShadingGroup *shgroup,
 #endif
 }
 
-void DRW_shgroup_call_procedural_points(DRWShadingGroup *shgroup,
-                                        uint point_len,
-                                        float (*obmat)[4])
+void DRW_shgroup_call_procedural_points(DRWShadingGroup *shgroup, Object *ob, uint point_len)
 {
   struct GPUBatch *geom = drw_cache_procedural_points_get();
-  drw_shgroup_call_procedural_add_ex(shgroup, geom, point_len, obmat);
+  drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, point_len);
 }
 
-void DRW_shgroup_call_procedural_lines(DRWShadingGroup *shgroup,
-                                       uint line_count,
-                                       float (*obmat)[4])
+void DRW_shgroup_call_procedural_lines(DRWShadingGroup *shgroup, Object *ob, uint line_count)
 {
   struct GPUBatch *geom = drw_cache_procedural_lines_get();
-  drw_shgroup_call_procedural_add_ex(shgroup, geom, line_count * 2, obmat);
+  drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, line_count * 2);
 }
 
-void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup,
-                                           uint tria_count,
-                                           float (*obmat)[4])
+void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, Object *ob, uint tria_count)
 {
   struct GPUBatch *geom = drw_cache_procedural_triangles_get();
-  drw_shgroup_call_procedural_add_ex(shgroup, geom, tria_count * 3, obmat);
-}
-
-/* These calls can be culled and are optimized for redraw */
-void DRW_shgroup_call_object_ex(DRWShadingGroup *shgroup,
-                                GPUBatch *geom,
-                                Object *ob,
-                                bool bypass_culling)
-{
-  BLI_assert(geom != NULL);
-
-  DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
-  BLI_LINKS_APPEND(&shgroup->calls, call);
-
-  call->state = drw_call_state_object(shgroup, ob->obmat, ob);
-  call->batch = geom;
-  call->vert_first = 0;
-  call->vert_count = 0; /* Auto from batch. */
-  call->inst_count = 0;
-#ifdef USE_GPU_SELECT
-  call->select_id = DST.select_id;
-  call->inst_selectid = NULL;
-#endif
-  if (bypass_culling) {
-    /* NOTE this will disable culling for the whole object. */
-    call->state->culling->bsphere.radius = -1.0f;
-  }
-}
-
-void DRW_shgroup_call_object_with_callback(DRWShadingGroup *shgroup,
-                                           GPUBatch *geom,
-                                           Object *ob,
-                                           void *user_data)
-{
-  BLI_assert(geom != NULL);
-
-  DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
-  BLI_LINKS_APPEND(&shgroup->calls, call);
-
-  call->state = drw_call_state_object(shgroup, ob->obmat, ob);
-  call->state->culling->user_data = user_data;
-  call->batch = geom;
-  call->vert_first = 0;
-  call->vert_count = 0; /* Auto from batch. */
-  call->inst_count = 0;
-#ifdef USE_GPU_SELECT
-  call->select_id = DST.select_id;
-  call->inst_selectid = NULL;
-#endif
+  drw_shgroup_call_procedural_add_ex(shgroup, geom, ob, tria_count * 3);
 }
 
 void DRW_shgroup_call_instances(DRWShadingGroup *shgroup,
-                                GPUBatch *geom,
-                                float (*obmat)[4],
+                                Object *ob,
+                                struct GPUBatch *geom,
                                 uint count)
 {
   BLI_assert(geom != NULL);
@@ -584,7 +535,7 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup,
   DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
   BLI_LINKS_APPEND(&shgroup->calls, call);
 
-  call->state = drw_call_state_create(shgroup, obmat, NULL);
+  call->state = drw_call_state_object(shgroup, ob ? ob->obmat : NULL, ob);
   call->batch = geom;
   call->vert_first = 0;
   call->vert_count = 0; /* Auto from batch. */
@@ -596,8 +547,8 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup,
 }
 
 void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup,
+                                             Object *ob,
                                              struct GPUBatch *geom,
-                                             float (*obmat)[4],
                                              struct GPUBatch *inst_attributes)
 {
   BLI_assert(geom != NULL);
@@ -608,7 +559,7 @@ void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup,
   DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
   BLI_LINKS_APPEND(&shgroup->calls, call);
 
-  call->state = drw_call_state_create(shgroup, obmat, NULL);
+  call->state = drw_call_state_object(shgroup, ob ? ob->obmat : NULL, ob);
   call->batch = DRW_temp_batch_instance_request(DST.idatalist, buf_inst, geom);
   call->vert_first = 0;
   call->vert_count = 0; /* Auto from batch. */
@@ -669,9 +620,9 @@ static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers
     shgrp = DRW_shgroup_create_sub(shgrp);
     DRW_shgroup_uniform_vec3(shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->node_nr++), 1);
 #endif
-    /* DRW_shgroup_call_object_ex reuses matrices calculations for all the drawcalls of this
+    /* DRW_shgroup_call_no_cull reuses matrices calculations for all the drawcalls of this
      * object. */
-    DRW_shgroup_call_object_ex(shgrp, geom, scd->ob, true);
+    DRW_shgroup_call_no_cull(shgrp, geom, scd->ob);
   }
 }
 
@@ -769,7 +720,7 @@ DRWCallBuffer *DRW_shgroup_call_buffer(DRWShadingGroup *shgroup,
   DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
   BLI_LINKS_APPEND(&shgroup->calls, call);
 
-  call->state = drw_call_state_create(shgroup, NULL, NULL);
+  call->state = drw_call_state_object(shgroup, NULL, NULL);
   GPUVertBuf *buf = DRW_temp_buffer_request(DST.idatalist, format, &call->vert_count);
   call->batch = DRW_temp_batch_request(DST.idatalist, buf, prim_type);
   call->vert_first = 0;
@@ -799,7 +750,7 @@ DRWCallBuffer *DRW_shgroup_call_buffer_instance(DRWShadingGroup *shgroup,
   DRWCall *call = BLI_memblock_alloc(DST.vmempool->calls);
   BLI_LINKS_APPEND(&shgroup->calls, call);
 
-  call->state = drw_call_state_create(shgroup, NULL, NULL);
+  call->state = drw_call_state_object(shgroup, NULL, NULL);
   GPUVertBuf *buf = DRW_temp_buffer_request(DST.idatalist, format, &call->inst_count);
   call->batch = DRW_temp_batch_instance_request(DST.idatalist, buf, geom);
   call->vert_first = 0;
index 212768d..068af2e 100644 (file)
@@ -269,30 +269,30 @@ static void EDIT_CURVE_cache_populate(void *vedata, Object *ob)
       }
 
       geom = DRW_cache_curve_edge_wire_get(ob);
-      DRW_shgroup_call(wire_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(wire_shgrp, geom, ob);
 
       if ((cu->flag & CU_3D) && (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_NORMALS) != 0) {
         geom = DRW_cache_curve_edge_normal_get(ob);
-        DRW_shgroup_call_instances(wire_normals_shgrp, geom, ob->obmat, 2);
+        DRW_shgroup_call_instances(wire_normals_shgrp, ob, geom, 2);
       }
 
       geom = DRW_cache_curve_edge_overlay_get(ob);
       if (geom) {
-        DRW_shgroup_call(stl->g_data->overlay_edge_shgrp, geom, ob->obmat);
+        DRW_shgroup_call(stl->g_data->overlay_edge_shgrp, geom, ob);
       }
 
       geom = DRW_cache_curve_vert_overlay_get(ob, stl->g_data->show_handles);
-      DRW_shgroup_call(stl->g_data->overlay_vert_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->overlay_vert_shgrp, geom, ob);
     }
   }
 
   if (ob->type == OB_SURF) {
     if (BKE_object_is_in_editmode(ob)) {
       struct GPUBatch *geom = DRW_cache_curve_edge_overlay_get(ob);
-      DRW_shgroup_call(stl->g_data->overlay_edge_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->overlay_edge_shgrp, geom, ob);
 
       geom = DRW_cache_curve_vert_overlay_get(ob, false);
-      DRW_shgroup_call(stl->g_data->overlay_vert_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->overlay_vert_shgrp, geom, ob);
     }
   }
 }
index 56c3d48..0440405 100644 (file)
@@ -211,10 +211,10 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob)
       struct GPUBatch *geom;
 
       geom = DRW_cache_lattice_wire_get(ob, true);
-      DRW_shgroup_call(stl->g_data->wire_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->wire_shgrp, geom, ob);
 
       geom = DRW_cache_lattice_vert_overlay_get(ob);
-      DRW_shgroup_call(stl->g_data->vert_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->vert_shgrp, geom, ob);
     }
   }
 }
index 7b8dc01..bb11ff3 100644 (file)
@@ -663,17 +663,17 @@ static void edit_mesh_add_ob_to_pass(Scene *scene,
 
   geom_tris = DRW_mesh_batch_cache_get_edit_triangles(ob->data);
   geom_edges = DRW_mesh_batch_cache_get_edit_edges(ob->data);
-  DRW_shgroup_call(edge_shgrp, geom_edges, ob->obmat);
-  DRW_shgroup_call(face_shgrp, geom_tris, ob->obmat);
+  DRW_shgroup_call(edge_shgrp, geom_edges, ob);
+  DRW_shgroup_call(face_shgrp, geom_tris, ob);
 
   if ((tsettings->selectmode & SCE_SELECT_VERTEX) != 0) {
     geom_verts = DRW_mesh_batch_cache_get_edit_vertices(ob->data);
-    DRW_shgroup_call(vert_shgrp, geom_verts, ob->obmat);
+    DRW_shgroup_call(vert_shgrp, geom_verts, ob);
   }
 
   if (facedot_shgrp && (tsettings->selectmode & SCE_SELECT_FACE) != 0) {
     geom_fcenter = DRW_mesh_batch_cache_get_edit_facedots(ob->data);
-    DRW_shgroup_call(facedot_shgrp, geom_fcenter, ob->obmat);
+    DRW_shgroup_call(facedot_shgrp, geom_fcenter, ob);
   }
 }
 
@@ -698,7 +698,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
 
       if (do_show_weight) {
         geom = DRW_cache_mesh_surface_weights_get(ob);
-        DRW_shgroup_call(g_data->fweights_shgrp, geom, ob->obmat);
+        DRW_shgroup_call(g_data->fweights_shgrp, geom, ob);
       }
 
       if (do_show_mesh_analysis && !XRAY_ACTIVE(v3d)) {
@@ -709,7 +709,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
         if (is_original) {
           geom = DRW_cache_mesh_surface_mesh_analysis_get(ob);
           if (geom) {
-            DRW_shgroup_call(g_data->mesh_analysis_shgrp, geom, ob->obmat);
+            DRW_shgroup_call(g_data->mesh_analysis_shgrp, geom, ob);
           }
         }
       }
@@ -719,20 +719,20 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
         DRW_shgroup_call(do_in_front ? g_data->depth_shgrp_hidden_wire_in_front :
                                        g_data->depth_shgrp_hidden_wire,
                          geom,
-                         ob->obmat);
+                         ob);
       }
 
       if (vnormals_do) {
         geom = DRW_mesh_batch_cache_get_edit_vertices(ob->data);
-        DRW_shgroup_call(g_data->vnormals_shgrp, geom, ob->obmat);
+        DRW_shgroup_call(g_data->vnormals_shgrp, geom, ob);
       }
       if (lnormals_do) {
         geom = DRW_mesh_batch_cache_get_edit_lnors(ob->data);
-        DRW_shgroup_call(g_data->lnormals_shgrp, geom, ob->obmat);
+        DRW_shgroup_call(g_data->lnormals_shgrp, geom, ob);
       }
       if (fnormals_do) {
         geom = DRW_mesh_batch_cache_get_edit_facedots(ob->data);
-        DRW_shgroup_call(g_data->fnormals_shgrp, geom, ob->obmat);
+        DRW_shgroup_call(g_data->fnormals_shgrp, geom, ob);
       }
 
       if (g_data->do_zbufclip) {
index b7215d5..d1d17f2 100644 (file)
@@ -240,7 +240,7 @@ static void edit_text_cache_populate_select(void *vedata, Object *ob)
     v2_quad_corners_to_mat4(box, final_mat);
     mul_m4_m4m4(final_mat, ob->obmat, final_mat);
 
-    DRW_shgroup_call(stl->g_data->overlay_select_shgrp, geom, final_mat);
+    DRW_shgroup_call_obmat(stl->g_data->overlay_select_shgrp, geom, final_mat);
   }
 }
 
@@ -256,7 +256,7 @@ static void edit_text_cache_populate_cursor(void *vedata, Object *ob)
   mul_m4_m4m4(mat, ob->obmat, mat);
 
   struct GPUBatch *geom = DRW_cache_quad_get();
-  DRW_shgroup_call(stl->g_data->overlay_cursor_shgrp, geom, mat);
+  DRW_shgroup_call_obmat(stl->g_data->overlay_cursor_shgrp, geom, mat);
 }
 
 static void edit_text_cache_populate_boxes(void *vedata, Object *ob)
@@ -333,7 +333,7 @@ static void EDIT_TEXT_cache_populate(void *vedata, Object *ob)
       if ((cu->flag & CU_FAST) || !has_surface) {
         geom = DRW_cache_text_edge_wire_get(ob);
         if (geom) {
-          DRW_shgroup_call(stl->g_data->wire_shgrp, geom, ob->obmat);
+          DRW_shgroup_call(stl->g_data->wire_shgrp, geom, ob);
         }
       }
       else {
index ed75742..9f52685 100644 (file)
@@ -1019,7 +1019,7 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
     if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
       DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
     }
-    DRW_shgroup_call(grp, DRW_cache_image_plane_wire_get(), ob->obmat);
+    DRW_shgroup_call_no_cull(grp, DRW_cache_image_plane_wire_get(), ob);
   }
 
   if (!BKE_object_empty_image_data_is_visible_in_view3d(ob, rv3d)) {
@@ -1039,7 +1039,7 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
     if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
       DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
     }
-    DRW_shgroup_call(grp, DRW_cache_image_plane_get(), ob->obmat);
+    DRW_shgroup_call_no_cull(grp, DRW_cache_image_plane_get(), ob);
   }
 }
 
@@ -1186,8 +1186,6 @@ static void OBJECT_cache_init(void *vedata)
 
     struct GPUBatch *geom = DRW_cache_grid_get();
     float grid_line_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f;
-    static float mat[4][4];
-    unit_m4(mat);
 
     /* Create 3 quads to render ordered transparency Z axis */
     DRWShadingGroup *grp = DRW_shgroup_create(sh_data->grid, psl->grid);
@@ -1199,21 +1197,21 @@ static void OBJECT_cache_init(void *vedata)
     DRW_shgroup_uniform_float(grp, "gridOneOverLogSubdiv", &e_data.grid_settings[4], 1);
     DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
     DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
-    DRW_shgroup_call(grp, geom, mat);
+    DRW_shgroup_call(grp, geom, NULL);
 
     grp = DRW_shgroup_create(sh_data->grid, psl->grid);
     DRW_shgroup_uniform_int(grp, "gridFlag", &e_data.grid_flag, 1);
     DRW_shgroup_uniform_vec3(grp, "planeAxes", e_data.grid_axes, 1);
     DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
     DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
-    DRW_shgroup_call(grp, geom, mat);
+    DRW_shgroup_call(grp, geom, NULL);
 
     grp = DRW_shgroup_create(sh_data->grid, psl->grid);
     DRW_shgroup_uniform_int(grp, "gridFlag", &e_data.zpos_flag, 1);
     DRW_shgroup_uniform_vec3(grp, "planeAxes", e_data.zplane_axes, 1);
     DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
     DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
-    DRW_shgroup_call(grp, geom, mat);
+    DRW_shgroup_call(grp, geom, NULL);
   }
 
   for (int i = 0; i < 2; ++i) {
@@ -2071,7 +2069,7 @@ static void camera_view3d_reconstruction(OBJECT_ShadingGroupList *sgl,
         GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
         DRWShadingGroup *shading_group = DRW_shgroup_create(shader, sgl->non_meshes);
         DRW_shgroup_uniform_vec4(shading_group, "color", camera_path_color, 1);
-        DRW_shgroup_call(shading_group, geom, camera_mat);
+        DRW_shgroup_call_obmat(shading_group, geom, camera_mat);
       }
     }
   }
@@ -2459,7 +2457,7 @@ static void DRW_shgroup_volume_extra(OBJECT_ShadingGroupList *sgl,
   DRW_shgroup_uniform_float_copy(grp, "displaySize", sds->vector_scale);
   DRW_shgroup_uniform_float_copy(grp, "slicePosition", sds->slice_depth);
   DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis);
-  DRW_shgroup_call_procedural_lines(grp, line_count, ob->obmat);
+  DRW_shgroup_call_procedural_lines(grp, ob, line_count);
 
   BLI_addtail(&e_data.smoke_domains, BLI_genericNodeN(smd));
 }
@@ -2561,7 +2559,7 @@ static void DRW_shgroup_lightprobe(OBJECT_Shaders *sh_data,
       DRW_shgroup_uniform_vec3(grp, "increment_y", prb_data->increment_y, 1);
       DRW_shgroup_uniform_vec3(grp, "increment_z", prb_data->increment_z, 1);
       DRW_shgroup_uniform_ivec3(grp, "grid_resolution", &prb->grid_resolution_x, 1);
-      DRW_shgroup_call_procedural_points(grp, cell_count, NULL);
+      DRW_shgroup_call_procedural_points(grp, NULL, cell_count);
       if (sh_cfg == GPU_SHADER_CFG_CLIPPED) {
         DRW_shgroup_state_enable(grp, DRW_STATE_CLIP_PLANES);
       }
@@ -2990,9 +2988,6 @@ static void OBJECT_cache_populate_particles(OBJECT_Shaders *sh_data,
     ParticleSettings *part = psys->part;
     int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
 
-    static float mat[4][4];
-    unit_m4(mat);
-
     if (draw_as != PART_DRAW_PATH) {
       struct GPUBatch *geom = DRW_cache_particles_get_dots(ob, psys);
       DRWShadingGroup *shgrp = NULL;
@@ -3010,7 +3005,7 @@ static void OBJECT_cache_populate_particles(OBJECT_Shaders *sh_data,
           DRW_shgroup_uniform_float(shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
           DRW_shgroup_uniform_float(shgrp, "size", &part->draw_size, 1);
           DRW_shgroup_uniform_texture(shgrp, "ramp", G_draw.ramp);
-          DRW_shgroup_call(shgrp, geom, mat);
+          DRW_shgroup_call(shgrp, geom, NULL);
           break;
         case PART_DRAW_CROSS:
           shgrp = DRW_shgroup_create(sh_data->part_prim, psl->particle);
@@ -3019,7 +3014,7 @@ static void OBJECT_cache_populate_particles(OBJECT_Shaders *sh_data,
           DRW_shgroup_uniform_float(shgrp, "draw_size", &part->draw_size, 1);
           DRW_shgroup_uniform_bool_copy(shgrp, "screen_space", false);
           shape = DRW_cache_particles_get_prim(PART_DRAW_CROSS);
-          DRW_shgroup_call_instances_with_attribs(shgrp, shape, NULL, geom);
+          DRW_shgroup_call_instances_with_attribs(shgrp, NULL, shape, geom);
           break;
         case PART_DRAW_CIRC:
           shape = DRW_cache_particles_get_prim(PART_DRAW_CIRC);
@@ -3028,14 +3023,14 @@ static void OBJECT_cache_populate_particles(OBJECT_Shaders *sh_data,
           DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
           DRW_shgroup_uniform_float(shgrp, "draw_size", &part->draw_size, 1);
           DRW_shgroup_uniform_bool_copy(shgrp, "screen_space", true);
-          DRW_shgroup_call_instances_with_attribs(shgrp, shape, NULL, geom);
+          DRW_shgroup_call_instances_with_attribs(shgrp, NULL, shape, geom);
           break;
         case PART_DRAW_AXIS:
           shape = DRW_cache_particles_get_prim(PART_DRAW_AXIS);
           shgrp = DRW_shgroup_create(sh_data->part_axis, psl->particle);
           DRW_shgroup_uniform_float(shgrp, "draw_size", &part->draw_size, 1);
           DRW_shgroup_uniform_bool_copy(shgrp, "screen_space", false);
-          DRW_shgroup_call_instances_with_attribs(shgrp, shape, NULL, geom);
+          DRW_shgroup_call_instances_with_attribs(shgrp, NULL, shape, geom);
           break;
         default:
           break;
@@ -3191,7 +3186,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
       }
 
       if (shgroup && geom) {
-        DRW_shgroup_call_object(shgroup, geom, ob);
+        DRW_shgroup_call(shgroup, geom, ob);
       }
 
       if (init_duplidata) {
@@ -3203,7 +3198,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
 
   if (dupli_data && !init_duplidata) {
     if (dupli_data->extra_shgrp && dupli_data->extra_geom) {
-      DRW_shgroup_call_object(dupli_data->extra_shgrp, dupli_data->extra_geom, ob);
+      DRW_shgroup_call(dupli_data->extra_shgrp, dupli_data->extra_geom, ob);
     }
   }
   else {
@@ -3222,7 +3217,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
               theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
             }
             shgroup = shgroup_theme_id_to_point(sgl, theme_id, ob->base_flag);
-            DRW_shgroup_call_object(shgroup, geom, ob);
+            DRW_shgroup_call(shgroup, geom, ob);
           }
         }
         else {
@@ -3240,7 +3235,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
                 theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
               }
               shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
-              DRW_shgroup_call_object(shgroup, geom, ob);
+              DRW_shgroup_call(shgroup, geom, ob);
             }
           }
         }
@@ -3258,7 +3253,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
           theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
         }
         shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
-        DRW_shgroup_call_object(shgroup, geom, ob);
+        DRW_shgroup_call(shgroup, geom, ob);
         break;
       }
       case OB_LATTICE: {
@@ -3272,7 +3267,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
           }
 
           shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
-          DRW_shgroup_call_object(shgroup, geom, ob);
+          DRW_shgroup_call(shgroup, geom, ob);
         }
         break;
       }
@@ -3286,7 +3281,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
             theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
           }
           shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
-          DRW_shgroup_call_object(shgroup, geom, ob);
+          DRW_shgroup_call(shgroup, geom, ob);
         }
         break;
       }
@@ -3364,7 +3359,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
               theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
             }
             shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag);
-            DRW_shgroup_call_object(shgroup, geom, ob);
+            DRW_shgroup_call(shgroup, geom, ob);
           }
         }
         break;
index c74129d..667f2c9 100644 (file)
@@ -354,7 +354,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
   if (DRW_object_is_renderable(ob) && pd->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION) {
     struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
     if (geom) {
-      DRW_shgroup_call_object(pd->face_orientation_shgrp, geom, ob);
+      DRW_shgroup_call(pd->face_orientation_shgrp, geom, ob);
     }
   }
 
@@ -369,7 +369,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
       }
       else {
         if ((*dupli_data)->shgrp && (*dupli_data)->geom) {
-          DRW_shgroup_call_object((*dupli_data)->shgrp, (*dupli_data)->geom, ob);
+          DRW_shgroup_call((*dupli_data)->shgrp, (*dupli_data)->geom, ob);
         }
         return;
       }
@@ -424,7 +424,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
           DRW_shgroup_call_sculpt(shgrp, ob, true, false, false);
         }
         else {
-          DRW_shgroup_call_object(shgrp, geom, ob);
+          DRW_shgroup_call(shgrp, geom, ob);
         }
       }
 
index 1c60a62..90e4a2e 100644 (file)
@@ -359,23 +359,23 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
           for (int i = 0; i < mat_nr; i++) {
             const int index = use_material_slots ? i : 0;
             if ((i < me->totcol) && stl->g_data->shgroup_image_array[index]) {
-              DRW_shgroup_call(stl->g_data->shgroup_image_array[index], geom_array[i], ob->obmat);
+              DRW_shgroup_call(stl->g_data->shgroup_image_array[index], geom_array[i], ob);
             }
             else {
-              DRW_shgroup_call(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat);
+              DRW_shgroup_call(stl->g_data->shgroup_fallback, geom_array[i], ob);
             }
           }
         }
         else {
           if (stl->g_data->shgroup_image_array[0]) {
             struct GPUBatch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
-            DRW_shgroup_call(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
+            DRW_shgroup_call(stl->g_data->shgroup_image_array[0], geom, ob);
           }
         }
       }
       else {
         struct GPUBatch *geom = DRW_cache_mesh_surface_get(ob);
-        DRW_shgroup_call(stl->g_data->shgroup_fallback, geom, ob->obmat);
+        DRW_shgroup_call(stl->g_data->shgroup_fallback, geom, ob);
       }
     }
 
@@ -383,10 +383,10 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
     if (use_face_sel) {
       struct GPUBatch *geom;
       geom = DRW_cache_mesh_surface_edges_get(ob);
-      DRW_shgroup_call(stl->g_data->lwire_select_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->lwire_select_shgrp, geom, ob);
 
       geom = DRW_cache_mesh_surface_get(ob);
-      DRW_shgroup_call(stl->g_data->face_select_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->face_select_shgrp, geom, ob);
     }
   }
 }
index fe7f367..374cb10 100644 (file)
@@ -312,24 +312,24 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
       }
     }
     if (geom != NULL) {
-      DRW_shgroup_call(stl->g_data->by_mode[draw_mode].color_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->by_mode[draw_mode].color_shgrp, geom, ob);
     }
 
     if (use_face_sel || use_wire) {
       DRWShadingGroup *shgrp = use_face_sel ? stl->g_data->by_mode[draw_mode].lwire_select_shgrp :
                                               stl->g_data->by_mode[draw_mode].lwire_shgrp;
       geom = DRW_cache_mesh_surface_edges_get(ob);
-      DRW_shgroup_call(shgrp, geom, ob->obmat);
+      DRW_shgroup_call(shgrp, geom, ob);
     }
 
     if (use_face_sel) {
       geom = DRW_cache_mesh_surface_get(ob);
-      DRW_shgroup_call(stl->g_data->face_select_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->face_select_shgrp, geom, ob);
     }
 
     if (use_vert_sel) {
       geom = DRW_cache_mesh_all_verts_get(ob);
-      DRW_shgroup_call(stl->g_data->vert_select_shgrp, geom, ob->obmat);
+      DRW_shgroup_call(stl->g_data->vert_select_shgrp, geom, ob);
     }
   }
 }
index 2723f2d..8cdf28f 100644 (file)
@@ -226,10 +226,10 @@ static void POSE_cache_populate(void *vedata, Object *ob)
     struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
     if (geom) {
       if (POSE_is_driven_by_active_armature(ob)) {
-        DRW_shgroup_call_object(ppd->bone_selection_shgrp, geom, ob);
+        DRW_shgroup_call(ppd->bone_selection_shgrp, geom, ob);
       }
       else {
-        DRW_shgroup_call_object(ppd->bone_selection_invert_shgrp, geom, ob);
+        DRW_shgroup_call(ppd->bone_selection_invert_shgrp, geom, ob);
       }
     }
   }