From 4f593b57100af950a19da6e07201e53d4d33cdd7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 10 Jun 2024 17:33:28 +0200 Subject: [PATCH 1/8] Fix: Incorrect layout in vertex color shader node --- source/blender/nodes/shader/nodes/node_shader_vertex_color.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc index 2b4e0a1d130..29a978c6246 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc @@ -33,6 +33,7 @@ static void node_shader_buts_vertex_color(uiLayout *layout, bContext *C, Pointer DEG_get_evaluated_rna_pointer(depsgraph, &obptr, &eval_obptr); PointerRNA dataptr = RNA_pointer_get(&eval_obptr, "data"); uiItemPointerR(layout, ptr, "layer_name", &dataptr, "color_attributes", "", ICON_GROUP_VCOL); + return; } } From 27f467e02843514e2530de4f444b9f7d96e31b3d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 10 Jun 2024 18:11:41 +0200 Subject: [PATCH 2/8] Draw: Avoid hang when depsgraph update happens during draw This should not happen and any failure here should be considered a bug. But for end users better not to hang Blender, and to have a better diagnostic for developers in bug reports. Ref #82483 Pull Request: https://projects.blender.org/blender/blender/pulls/123023 --- source/blender/blenlib/BLI_threads.h | 1 + source/blender/blenlib/intern/threads.cc | 26 +++++++++++++++++++- source/blender/draw/intern/draw_manager_c.cc | 19 +++++++++++--- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/source/blender/blenlib/BLI_threads.h b/source/blender/blenlib/BLI_threads.h index 568b0360cc4..f9ef0a5be20 100644 --- a/source/blender/blenlib/BLI_threads.h +++ b/source/blender/blenlib/BLI_threads.h @@ -144,6 +144,7 @@ typedef struct TicketMutex TicketMutex; TicketMutex *BLI_ticket_mutex_alloc(void); void BLI_ticket_mutex_free(TicketMutex *ticket); void BLI_ticket_mutex_lock(TicketMutex *ticket); +bool BLI_ticket_mutex_lock_check_recursive(TicketMutex *ticket); void BLI_ticket_mutex_unlock(TicketMutex *ticket); /* Condition */ diff --git a/source/blender/blenlib/intern/threads.cc b/source/blender/blenlib/intern/threads.cc index 71277b1c786..42f106aeee8 100644 --- a/source/blender/blenlib/intern/threads.cc +++ b/source/blender/blenlib/intern/threads.cc @@ -504,6 +504,8 @@ struct TicketMutex { pthread_cond_t cond; pthread_mutex_t mutex; uint queue_head, queue_tail; + pthread_t owner; + bool has_owner; }; TicketMutex *BLI_ticket_mutex_alloc() @@ -524,24 +526,46 @@ void BLI_ticket_mutex_free(TicketMutex *ticket) MEM_freeN(ticket); } -void BLI_ticket_mutex_lock(TicketMutex *ticket) +static bool ticket_mutex_lock(TicketMutex *ticket, const bool check_recursive) { uint queue_me; pthread_mutex_lock(&ticket->mutex); + + /* Check for recursive locks, for debugging only. */ + if (check_recursive && ticket->has_owner && pthread_equal(pthread_self(), ticket->owner)) { + pthread_mutex_unlock(&ticket->mutex); + return false; + } + queue_me = ticket->queue_tail++; while (queue_me != ticket->queue_head) { pthread_cond_wait(&ticket->cond, &ticket->mutex); } + ticket->owner = pthread_self(); + ticket->has_owner = true; + pthread_mutex_unlock(&ticket->mutex); + return true; +} + +void BLI_ticket_mutex_lock(TicketMutex *ticket) +{ + ticket_mutex_lock(ticket, false); +} + +bool BLI_ticket_mutex_lock_check_recursive(TicketMutex *ticket) +{ + return ticket_mutex_lock(ticket, true); } void BLI_ticket_mutex_unlock(TicketMutex *ticket) { pthread_mutex_lock(&ticket->mutex); ticket->queue_head++; + ticket->has_owner = false; pthread_cond_broadcast(&ticket->cond); pthread_mutex_unlock(&ticket->mutex); } diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index 9a27203ab9d..458f651cc46 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -8,6 +8,8 @@ #include +#include "CLG_log.h" + #include "BLI_alloca.h" #include "BLI_listbase.h" #include "BLI_memblock.h" @@ -103,6 +105,8 @@ #include "DRW_select_buffer.hh" +static CLG_LogRef LOG = {"draw.manager"}; + /** Render State: No persistent data between draw calls. */ DRWManager DST = {nullptr}; @@ -1327,10 +1331,17 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx) const bool gpencil_engine_needed = drw_gpencil_engine_needed(depsgraph, v3d); - /* XXX Really nasty locking. But else this could - * be executed by the material previews thread - * while rendering a viewport. */ - BLI_ticket_mutex_lock(DST.system_gpu_context_mutex); + /* XXX Really nasty locking. But else this could be executed by the + * material previews thread while rendering a viewport. + * + * Check for recursive lock which can deadlock. This should not + * happen, but in case there is a bug where depsgraph update is called + * during drawing we try not to hang Blender. */ + if (!BLI_ticket_mutex_lock_check_recursive(DST.system_gpu_context_mutex)) { + CLOG_ERROR(&LOG, "GPU context already bound"); + BLI_assert_unreachable(); + return; + } /* Reset before using it. */ drw_state_prepare_clean_for_draw(&DST); From 35ccb08590b59d545f3e950200f94799791403ae Mon Sep 17 00:00:00 2001 From: Iliya Katueshenock Date: Mon, 10 Jun 2024 21:26:47 +0200 Subject: [PATCH 3/8] Fix: Geometry Nodes: handle sheared matrices in mixing more gracefully This fix of the assertion related with using `Combine Matrix` and `Sample UV` nodes in some simple cases. Pull Request: https://projects.blender.org/blender/blender/pulls/122958 --- source/blender/blenkernel/intern/attribute_math.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/attribute_math.cc b/source/blender/blenkernel/intern/attribute_math.cc index a9509101059..a62a723e7a3 100644 --- a/source/blender/blenkernel/intern/attribute_math.cc +++ b/source/blender/blenkernel/intern/attribute_math.cc @@ -3,6 +3,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ #include "BLI_array_utils.hh" +#include "BLI_math_euler.hh" #include "BLI_math_matrix.hh" #include "BLI_math_quaternion.hh" @@ -47,7 +48,10 @@ float4x4 mix3(const float3 &weights, const float4x4 &v0, const float4x4 &v1, con { const float3 location = mix3(weights, v0.location(), v1.location(), v2.location()); const math::Quaternion rotation = mix3( - weights, math::to_quaternion(v0), math::to_quaternion(v1), math::to_quaternion(v2)); + weights, + math::normalized_to_quaternion_safe(math::normalize(float3x3(v0))), + math::normalized_to_quaternion_safe(math::normalize(float3x3(v1))), + math::normalized_to_quaternion_safe(math::normalize(float3x3(v2)))); const float3 scale = mix3(weights, math::to_scale(v0), math::to_scale(v1), math::to_scale(v2)); return math::from_loc_rot_scale(location, rotation, scale); } From d5ac372715db3a49fc30e0119043dc679d6536cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Mon, 10 Jun 2024 21:26:30 +0200 Subject: [PATCH 4/8] Fix: EEVEE-Next: Lightprobe display size unit The unit was still a distance but it was changed to a factor. --- source/blender/makesrna/intern/rna_lightprobe.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_lightprobe.cc b/source/blender/makesrna/intern/rna_lightprobe.cc index db868027a8d..eaedf953d1f 100644 --- a/source/blender/makesrna/intern/rna_lightprobe.cc +++ b/source/blender/makesrna/intern/rna_lightprobe.cc @@ -172,7 +172,7 @@ static void rna_def_lightprobe(BlenderRNA *brna) RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, nullptr); - prop = RNA_def_property(srna, "data_display_size", PROP_FLOAT, PROP_DISTANCE); + prop = RNA_def_property(srna, "data_display_size", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, nullptr, "data_display_size"); RNA_def_property_range(prop, 0.0f, FLT_MAX); RNA_def_property_ui_range(prop, 0.01f, 1.0f, 1, 3); From e6ca5f00d552108cab1d6ed5e012439935c4b044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Mon, 10 Jun 2024 21:54:58 +0200 Subject: [PATCH 5/8] EEVEE-Next: Rename lightprobe volume single sided to backface cull This also modifies the RNA access path for consistency. This was a long standing change that was oversighted. --- scripts/startup/bl_ui/properties_material.py | 4 +--- .../blender/makesrna/intern/rna_material.cc | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/scripts/startup/bl_ui/properties_material.py b/scripts/startup/bl_ui/properties_material.py index 923ece92b5b..69011c7c4bf 100644 --- a/scripts/startup/bl_ui/properties_material.py +++ b/scripts/startup/bl_ui/properties_material.py @@ -319,6 +319,7 @@ class EEVEE_NEXT_MATERIAL_PT_settings_surface(MaterialButtonsPanel, Panel): col = layout.column(heading="Backface Culling") col.prop(mat, "use_backface_culling", text="Camera") col.prop(mat, "use_backface_culling_shadow", text="Shadow") + col.prop(mat, "use_backface_culling_lightprobe_volume", text="Light Probe Volume") col = layout.column(align=True) col.prop(mat, "displacement_method", text="Displacement") @@ -343,9 +344,6 @@ class EEVEE_NEXT_MATERIAL_PT_settings_surface(MaterialButtonsPanel, Panel): if mat.surface_render_method == 'DITHERED': col.prop(mat, "use_thickness_from_shadow", text="From Shadow") - col = layout.column(heading="Light Probe Volume") - col.prop(mat, "lightprobe_volume_single_sided", text="Single Sided") - class EEVEE_NEXT_MATERIAL_PT_settings_volume(MaterialButtonsPanel, Panel): bl_label = "Volume" diff --git a/source/blender/makesrna/intern/rna_material.cc b/source/blender/makesrna/intern/rna_material.cc index c00fc27a5ee..cbf39b52ce0 100644 --- a/source/blender/makesrna/intern/rna_material.cc +++ b/source/blender/makesrna/intern/rna_material.cc @@ -996,6 +996,16 @@ void RNA_def_material(BlenderRNA *brna) prop, "Shadow Backface Culling", "Use back face culling when casting shadows"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); + prop = RNA_def_property(srna, "use_backface_culling_lightprobe_volume", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna( + prop, nullptr, "blend_flag", MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED); + RNA_def_property_ui_text( + prop, + "Light Probe Volume Backface Culling", + "Consider material single sided for light probe volume capture. " + "Additionally helps rejecting probes inside the object to avoid light leaks"); + RNA_def_property_update(prop, 0, "rna_Material_draw_update"); + prop = RNA_def_property(srna, "use_transparent_shadow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_TRANSPARENT_SHADOW); RNA_def_property_ui_text( @@ -1005,16 +1015,6 @@ void RNA_def_material(BlenderRNA *brna) "disabling will render faster but not give accurate shadows"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "lightprobe_volume_single_sided", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna( - prop, nullptr, "blend_flag", MA_BL_LIGHTPROBE_VOLUME_DOUBLE_SIDED); - RNA_def_property_ui_text( - prop, - "Light Probe Volume Single Sided", - "Consider material single sided for light probe volume capture. " - "Additionally helps rejecting probes inside the object to avoid light leaks"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - prop = RNA_def_property(srna, "use_raytrace_refraction", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_SS_REFRACTION); RNA_def_property_ui_text( From 3db4367374013c026b2a0c68ffbb0cc43b3ca8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Mon, 10 Jun 2024 22:02:07 +0200 Subject: [PATCH 6/8] EEVEE-Next: Disable shadows in legacy files Having the sun extracted is mandatory to keep the same look and avoid too much light leaking compared to EEVEE-Legacy. But adding shadows might create performance overhead and change the result in a very different way. So we disable shadows in older file. --- source/blender/blenloader/intern/versioning_400.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 84531f47751..26eed75d472 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -3920,7 +3920,10 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) world->sun_threshold = default_world->sun_threshold; world->sun_angle = default_world->sun_angle; world->sun_shadow_maximum_resolution = default_world->sun_shadow_maximum_resolution; - world->flag |= WO_USE_SUN_SHADOW; + /* Having the sun extracted is mandatory to keep the same look and avoid too much light + * leaking compared to EEVEE-Legacy. But adding shadows might create performance overhead and + * change the result in a very different way. So we disable shadows in older file. */ + world->flag &= ~WO_USE_SUN_SHADOW; } } From 8a3979b0340b7895a435ab1a554088215bfe03b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Mon, 10 Jun 2024 22:28:27 +0200 Subject: [PATCH 7/8] EEVEE-Next: Display warning for world volume manual versioning This adds a hint to what is the correct procedure. --- .../blender/blenloader/intern/versioning_400.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 26eed75d472..77df824c135 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -3843,6 +3843,14 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) } if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 31)) { + bool only_uses_eevee_legacy_or_workbench = true; + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + if (!(STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE) || + STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH))) + { + only_uses_eevee_legacy_or_workbench = false; + } + } /* Mark old EEVEE world volumes for showing conversion operator. */ LISTBASE_FOREACH (World *, world, &bmain->worlds) { if (world->nodetree) { @@ -3854,6 +3862,14 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) LISTBASE_FOREACH (bNodeLink *, node_link, &world->nodetree->links) { if (node_link->tonode == output_node && node_link->tosock == volume_input_socket) { world->flag |= WO_USE_EEVEE_FINITE_VOLUME; + /* Only display a warning message if we are sure this can be used by EEVEE. */ + if (only_uses_eevee_legacy_or_workbench) { + BLO_reportf_wrap(fd->reports, + RPT_WARNING, + RPT_("%s contains a volume shader that might need to be " + "converted to object (see world volume panel)\n"), + world->id.name + 2); + } } } } From 739abf30311e53a5b28f6e9bb18faedb5fb51dfe Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Mon, 10 Jun 2024 23:38:35 +0200 Subject: [PATCH 8/8] Fix: UI: make statistics for Objects display 0 instead of (null) Display "0" instead of "(null)" for object stats count when there are no objects. Pull Request: https://projects.blender.org/blender/blender/pulls/123036 --- source/blender/editors/space_info/info_stats.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index c59f7b3b464..a717aecf502 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -828,7 +828,7 @@ void ED_info_draw_stats( } else if (!(object_mode & OB_MODE_SCULPT)) { /* No objects in scene. */ - stats_row(col1, labels[OBJ], col2, 0, nullptr, y, height); + stats_row(col1, labels[OBJ], col2, stats_fmt.totobj, nullptr, y, height); return; }