Depsgraph: avoid checking for evaluated object in draw code

This increases playback performance from 2.9fps to 3.2fps in the test file from #126391.

The check is unnecessary in draw code, because we know that the depsgraph
finished evaluation before. These checks were introduced to handle dependency
cycles during depsgraph evaluation.

At some point it may be nice to look into making these checks cheaper to avoid having
to use the unchecked version for performance reasons.
This commit is contained in:
Jacques Lucke
2024-08-17 00:41:31 +02:00
parent f21a25489f
commit 5358d1b09a
2 changed files with 5 additions and 5 deletions

View File

@@ -973,7 +973,7 @@ static void drw_shgroup_bone_custom_solid(const ArmatureDrawContext *ctx,
* by #data_eval. This is bad since it gives preference to an object's evaluated mesh over any
* other data type, but supporting all evaluated geometry components would require a much
* larger refactor of this area. */
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom);
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf_unchecked(custom);
if (mesh != nullptr) {
drw_shgroup_bone_custom_solid_mesh(
ctx, *mesh, bone_mat, bone_color, hint_color, outline_color, wire_width, *custom);
@@ -993,7 +993,7 @@ static void drw_shgroup_bone_custom_wire(const ArmatureDrawContext *ctx,
Object *custom)
{
/* See comments in #drw_shgroup_bone_custom_solid. */
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom);
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf_unchecked(custom);
if (mesh != nullptr) {
drw_shgroup_bone_custom_mesh_wire(ctx, *mesh, bone_mat, color, wire_width, *custom);
return;

View File

@@ -931,7 +931,7 @@ blender::gpu::Batch *DRW_cache_object_surface_get(Object *ob)
blender::gpu::VertBuf *DRW_cache_object_pos_vertbuf_get(Object *ob)
{
using namespace blender::draw;
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(ob);
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf_unchecked(ob);
short type = (mesh != nullptr) ? short(OB_MESH) : ob->type;
switch (type) {
@@ -948,7 +948,7 @@ int DRW_cache_object_material_count_get(const Object *ob)
using namespace blender::draw;
short type = ob->type;
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(ob);
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf_unchecked(ob);
if (mesh != nullptr && type != OB_POINTCLOUD) {
/* Some object types can have one data type in ob->data, but will be rendered as mesh.
* For point clouds this never happens. Ideally this check would happen at another level
@@ -3438,7 +3438,7 @@ void drw_batch_cache_generate_requested_evaluated_mesh_or_curve(Object *ob)
DRW_object_use_hide_faces(ob)) ||
((mode == CTX_MODE_EDIT_MESH) && DRW_object_is_in_edit_mode(ob))));
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(ob);
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf_unchecked(ob);
/* Try getting the mesh first and if that fails, try getting the curve data.
* If the curves are surfaces or have certain modifiers applied to them, the will have mesh data
* of the final result.