From fb539baa89cf8c505e7e7be96939553af059a468 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 Feb 2025 16:49:42 +1100 Subject: [PATCH 01/28] Cleanup: quiet compiler warnings WITH_INPUT_NDOF=OFF --- .../blender/editors/space_view3d/view3d_navigate_view_ndof.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc b/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc index cb0ae3b1eea..cbd7315480a 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc +++ b/source/blender/editors/space_view3d/view3d_navigate_view_ndof.cc @@ -26,8 +26,10 @@ using blender::Bounds; using blender::float3; +#ifdef WITH_INPUT_NDOF static bool ndof_orbit_center_is_valid(const RegionView3D *rv3d, const float3 ¢er); static bool ndof_orbit_center_is_auto(const View3D *v3d, const RegionView3D *rv3d); +#endif /* -------------------------------------------------------------------- */ /** \name NDOF Utility Functions From b768b0d91d6b3f3b49414b0dc2e4e4789f4501a7 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Thu, 6 Feb 2025 08:04:33 +0100 Subject: [PATCH 02/28] glTF: Bump version to 4.5.0 after 4.4 branch creation --- scripts/addons_core/io_scene_gltf2/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/addons_core/io_scene_gltf2/__init__.py b/scripts/addons_core/io_scene_gltf2/__init__.py index d8b3526aefb..edd05663f6a 100755 --- a/scripts/addons_core/io_scene_gltf2/__init__.py +++ b/scripts/addons_core/io_scene_gltf2/__init__.py @@ -5,7 +5,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (4, 4, 42), + "version": (4, 5, 0), 'blender': (4, 4, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', From 0a066c11ea20fafef6c80ad71e4e4bda63666cf8 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Thu, 6 Feb 2025 09:47:31 +0200 Subject: [PATCH 03/28] Fix #134151: Crash when appending Bloom node Blender crashes when appending a Bloom node. This is because the scene is needed to infer the render size while versioning, and the scene doesn't exist while appending, so we need to fallback to a default render size in those cases. --- source/blender/blenloader/intern/versioning_400.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 47b20c5dbb8..080d7424bc3 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -1133,8 +1133,15 @@ static void do_version_glare_node_bloom_strength(const Scene *scene, /* See the get_quality_factor method in the glare code. */ const int quality_factor = 1 << storage->quality; + /* Find the render size to guess the Strength value. The node tree might not belong to a scene, + * so we just assume an arbitrary HDTV 1080p render size. */ blender::int2 render_size; - BKE_render_resolution(&scene->r, true, &render_size.x, &render_size.y); + if (scene) { + BKE_render_resolution(&scene->r, true, &render_size.x, &render_size.y); + } + else { + render_size = blender::int2(1920, 1080); + } const blender::int2 highlights_size = render_size / quality_factor; From 8390fdbd66e4c05e4511ebd3d1192b2f97254669 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 6 Feb 2025 10:36:28 +0100 Subject: [PATCH 04/28] Fix #134155: Crash when searching in properties editor. Mistake in recent RNA refactor (45f231141d), not sure why I ended up returning empty PointerRNA with non-null type when calling `RNA_id_create_pointer` with a null ID... In general, PointerRNA with no data ==> no type either, we are trying to get rid of the very few exceptions in our codebase relying on a different behavior! --- source/blender/makesrna/intern/rna_access.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.cc b/source/blender/makesrna/intern/rna_access.cc index 3be4a1ef927..84dc687b72b 100644 --- a/source/blender/makesrna/intern/rna_access.cc +++ b/source/blender/makesrna/intern/rna_access.cc @@ -173,14 +173,13 @@ PointerRNA RNA_main_pointer_create(Main *main) PointerRNA RNA_id_pointer_create(ID *id) { - PointerRNA ptr{id, &RNA_ID, id}; - if (id) { - ptr.type = ID_code_to_RNA_type(GS(id->name)); + PointerRNA ptr{id, ID_code_to_RNA_type(GS(id->name)), id}; rna_pointer_refine(ptr); + return ptr; } - return ptr; + return PointerRNA_NULL; } PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data) From ca65379d70454ca79ddaf12434c5af91692b428b Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 6 Feb 2025 10:51:04 +0100 Subject: [PATCH 05/28] Fix: Indicate that creating a pose asset opens a pop up As indicated by pablovazquez , operators that open a pop up should end with `...`. I decided to change the operator name instead of doing it in python with `text=` This seemed more reasonable to me because it can't be forgotten when adding this operator somewhere else, but I am not sure if this is the right way to do it. Pull Request: https://projects.blender.org/blender/blender/pulls/134062 --- source/blender/editors/animation/anim_asset_ops.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/animation/anim_asset_ops.cc b/source/blender/editors/animation/anim_asset_ops.cc index 9310077b3eb..52415060c91 100644 --- a/source/blender/editors/animation/anim_asset_ops.cc +++ b/source/blender/editors/animation/anim_asset_ops.cc @@ -399,8 +399,8 @@ static void visit_library_prop_catalogs_catalog_for_search_fn( void POSELIB_OT_create_pose_asset(wmOperatorType *ot) { - ot->name = "Create Pose Asset"; - ot->description = "Create a new asset from the selection in the scene"; + ot->name = "Create Pose Asset..."; + ot->description = "Create a new asset from the selected bones in the scene"; ot->idname = "POSELIB_OT_create_pose_asset"; ot->exec = pose_asset_create_exec; From 734af8206cf55e263f84f2a265333deaee22ad04 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 6 Feb 2025 11:07:04 +0100 Subject: [PATCH 06/28] Fix #134162: Crash when opening a file with a compositor image node. Yet another remaining case of non-trivial data created with C-style allocation. While 4.4 and previous did not exhibit the crash, the invalid code responsible for this crash is present here as well, and it would be dangerous not to fix it. --- .../interface/templates/interface_templates_intern.hh | 2 +- source/blender/editors/space_image/image_buttons.cc | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/interface/templates/interface_templates_intern.hh b/source/blender/editors/interface/templates/interface_templates_intern.hh index 2200c9c5111..254ed085f48 100644 --- a/source/blender/editors/interface/templates/interface_templates_intern.hh +++ b/source/blender/editors/interface/templates/interface_templates_intern.hh @@ -27,7 +27,7 @@ struct bContext; #define TEMPLATE_SEARCH_TEXTBUT_HEIGHT UI_UNIT_Y struct RNAUpdateCb { - PointerRNA ptr; + PointerRNA ptr = {}; PropertyRNA *prop; }; diff --git a/source/blender/editors/space_image/image_buttons.cc b/source/blender/editors/space_image/image_buttons.cc index 2a24f38e627..e8999b38ac4 100644 --- a/source/blender/editors/space_image/image_buttons.cc +++ b/source/blender/editors/space_image/image_buttons.cc @@ -697,7 +697,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, } struct RNAUpdateCb { - PointerRNA ptr; + PointerRNA ptr = {}; PropertyRNA *prop; ImageUser *iuser; }; @@ -789,11 +789,16 @@ void uiTemplateImage(uiLayout *layout, } /* Set custom callback for property updates. */ - RNAUpdateCb *cb = static_cast(MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb")); + RNAUpdateCb *cb = MEM_new(__func__); cb->ptr = *ptr; cb->prop = prop; cb->iuser = iuser; - UI_block_funcN_set(block, rna_update_cb, cb, nullptr); + UI_block_funcN_set(block, + rna_update_cb, + cb, + nullptr, + but_func_argN_free, + but_func_argN_copy); /* Disable editing if image was modified, to avoid losing changes. */ const bool is_dirty = BKE_image_is_dirty(ima); From 3a85ccde38e34d6cfb6517dd6c013544e842daf1 Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 6 Feb 2025 11:14:23 +0100 Subject: [PATCH 07/28] Fix #133969: Crazyspace broken with bezier curves and armature modifier The issue was that the topology of the drawing changes when the bezier curves get resampled to poly curves in the armature modifier. This means that the crazyspace code fails to find deformed positions with the same length as the original positions. The fix does multiple things: * First, we make sure that we create an `GeometryComponentEditData` in weight paint mode. * When the armature modifier runs, we remember the current positions in this component. * Then, we store the curve offsets and weights _before_ converting the bezier curves. * Finally we deform the positions stored in the edit hint component (which have the same length as the original positions). Since the resampling just adds new points, there might be a way to avoid running the armature deformation a second time on the edit hints, but I'll leave that for another day as a performance improvement. In any case, this is only done when we actually need the deformation (e.g. in weight paint mode when we paint the weights). Pull Request: https://projects.blender.org/blender/blender/pulls/134030 --- .../blenkernel/intern/grease_pencil.cc | 11 ++++-- .../intern/MOD_grease_pencil_armature.cc | 34 ++++++++++++++++++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index f5d9de344a7..52b53eec517 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -2201,9 +2201,14 @@ void BKE_grease_pencil_data_update(Depsgraph *depsgraph, Scene *scene, Object *o if (layer_attributes.contains("tint_color") || layer_attributes.contains("radius_offset")) { grease_pencil_do_layer_adjustments(*geometry_set.get_grease_pencil_for_write()); } - /* Only add the edit hint component in edit mode or sculpt mode for now so users can properly - * select deformed drawings. */ - if (ELEM(object->mode, OB_MODE_EDIT, OB_MODE_SCULPT_GREASE_PENCIL)) { + /* Only add the edit hint component in modes where users can potentially interact with deformed + * drawings. */ + if (ELEM(object->mode, + OB_MODE_EDIT, + OB_MODE_SCULPT_GREASE_PENCIL, + OB_MODE_VERTEX_GREASE_PENCIL, + OB_MODE_WEIGHT_GREASE_PENCIL)) + { GeometryComponentEditData &edit_component = geometry_set.get_component_for_write(); edit_component.grease_pencil_edit_hints_ = std::make_unique( diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_armature.cc b/source/blender/modifiers/intern/MOD_grease_pencil_armature.cc index acc9723c2ee..56ff0d171c4 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_armature.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_armature.cc @@ -116,7 +116,21 @@ static void modify_curves(ModifierData &md, bke::GreasePencilDrawingEditHints *edit_hints) { auto &amd = reinterpret_cast(md); - modifier::greasepencil::ensure_no_bezier_curves(drawing); + + const bool has_bezier_curves = drawing.strokes().has_curve_with_type( + CurveType::CURVE_TYPE_BEZIER); + + Array orig_offsets; + Array orig_dverts; + OffsetIndices orig_points_by_curve; + if (has_bezier_curves) { + if (edit_hints) { + orig_dverts = drawing.strokes().deform_verts(); + orig_offsets = drawing.strokes().offsets(); + orig_points_by_curve = OffsetIndices(orig_offsets.as_span()); + } + modifier::greasepencil::ensure_no_bezier_curves(drawing); + } bke::CurvesGeometry &curves = drawing.strokes_for_write(); /* The influence flag is where the "invert" flag is stored, @@ -144,12 +158,16 @@ static void modify_curves(ModifierData &md, Span old_positions = {static_cast(old_positions_data.data), curves.points_num()}; + std::optional> deform_positions; std::optional> deform_mats; if (edit_hints) { if (!edit_hints->deform_mats.has_value()) { edit_hints->deform_mats.emplace(drawing.strokes().points_num(), float3x3::identity()); } deform_mats = edit_hints->deform_mats->as_mutable_span(); + if (has_bezier_curves) { + deform_positions = edit_hints->positions_for_write(); + } } curves_mask.foreach_index(blender::GrainSize(128), [&](const int curve_i) { @@ -171,6 +189,18 @@ static void modify_curves(ModifierData &md, dverts.slice(points), deformflag, amd.influence.vertex_group_name); + if (deform_positions) { + const IndexRange orig_points = orig_points_by_curve[curve_i]; + BKE_armature_deform_coords_with_curves(*amd.object, + *ctx.object, + &curves.vertex_group_names, + deform_positions->slice(orig_points), + {}, + {}, + orig_dverts.as_span().slice(orig_points), + deformflag, + amd.influence.vertex_group_name); + } }); drawing.tag_positions_changed(); @@ -187,6 +217,8 @@ static void modify_geometry_set(ModifierData *md, if (!geometry_set->has_grease_pencil()) { return; } + bke::GeometryComponentEditData::remember_deformed_positions_if_necessary(*geometry_set); + GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); const GreasePencil &grease_pencil_orig = *reinterpret_cast( DEG_get_original_id(&grease_pencil.id)); From 8af27ce27ef25ae4a15c5f4c22dcce048f2fa06e Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 6 Feb 2025 11:14:23 +0100 Subject: [PATCH 08/28] Fix #133969: Crazyspace broken with bezier curves and armature modifier The issue was that the topology of the drawing changes when the bezier curves get resampled to poly curves in the armature modifier. This means that the crazyspace code fails to find deformed positions with the same length as the original positions. The fix does multiple things: * First, we make sure that we create an `GeometryComponentEditData` in weight paint mode. * When the armature modifier runs, we remember the current positions in this component. * Then, we store the curve offsets and weights _before_ converting the bezier curves. * Finally we deform the positions stored in the edit hint component (which have the same length as the original positions). Since the resampling just adds new points, there might be a way to avoid running the armature deformation a second time on the edit hints, but I'll leave that for another day as a performance improvement. In any case, this is only done when we actually need the deformation (e.g. in weight paint mode when we paint the weights). Pull Request: https://projects.blender.org/blender/blender/pulls/134030 --- .../blenkernel/intern/grease_pencil.cc | 11 ++++-- .../intern/MOD_grease_pencil_armature.cc | 34 ++++++++++++++++++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index f5d9de344a7..52b53eec517 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -2201,9 +2201,14 @@ void BKE_grease_pencil_data_update(Depsgraph *depsgraph, Scene *scene, Object *o if (layer_attributes.contains("tint_color") || layer_attributes.contains("radius_offset")) { grease_pencil_do_layer_adjustments(*geometry_set.get_grease_pencil_for_write()); } - /* Only add the edit hint component in edit mode or sculpt mode for now so users can properly - * select deformed drawings. */ - if (ELEM(object->mode, OB_MODE_EDIT, OB_MODE_SCULPT_GREASE_PENCIL)) { + /* Only add the edit hint component in modes where users can potentially interact with deformed + * drawings. */ + if (ELEM(object->mode, + OB_MODE_EDIT, + OB_MODE_SCULPT_GREASE_PENCIL, + OB_MODE_VERTEX_GREASE_PENCIL, + OB_MODE_WEIGHT_GREASE_PENCIL)) + { GeometryComponentEditData &edit_component = geometry_set.get_component_for_write(); edit_component.grease_pencil_edit_hints_ = std::make_unique( diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_armature.cc b/source/blender/modifiers/intern/MOD_grease_pencil_armature.cc index acc9723c2ee..56ff0d171c4 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_armature.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_armature.cc @@ -116,7 +116,21 @@ static void modify_curves(ModifierData &md, bke::GreasePencilDrawingEditHints *edit_hints) { auto &amd = reinterpret_cast(md); - modifier::greasepencil::ensure_no_bezier_curves(drawing); + + const bool has_bezier_curves = drawing.strokes().has_curve_with_type( + CurveType::CURVE_TYPE_BEZIER); + + Array orig_offsets; + Array orig_dverts; + OffsetIndices orig_points_by_curve; + if (has_bezier_curves) { + if (edit_hints) { + orig_dverts = drawing.strokes().deform_verts(); + orig_offsets = drawing.strokes().offsets(); + orig_points_by_curve = OffsetIndices(orig_offsets.as_span()); + } + modifier::greasepencil::ensure_no_bezier_curves(drawing); + } bke::CurvesGeometry &curves = drawing.strokes_for_write(); /* The influence flag is where the "invert" flag is stored, @@ -144,12 +158,16 @@ static void modify_curves(ModifierData &md, Span old_positions = {static_cast(old_positions_data.data), curves.points_num()}; + std::optional> deform_positions; std::optional> deform_mats; if (edit_hints) { if (!edit_hints->deform_mats.has_value()) { edit_hints->deform_mats.emplace(drawing.strokes().points_num(), float3x3::identity()); } deform_mats = edit_hints->deform_mats->as_mutable_span(); + if (has_bezier_curves) { + deform_positions = edit_hints->positions_for_write(); + } } curves_mask.foreach_index(blender::GrainSize(128), [&](const int curve_i) { @@ -171,6 +189,18 @@ static void modify_curves(ModifierData &md, dverts.slice(points), deformflag, amd.influence.vertex_group_name); + if (deform_positions) { + const IndexRange orig_points = orig_points_by_curve[curve_i]; + BKE_armature_deform_coords_with_curves(*amd.object, + *ctx.object, + &curves.vertex_group_names, + deform_positions->slice(orig_points), + {}, + {}, + orig_dverts.as_span().slice(orig_points), + deformflag, + amd.influence.vertex_group_name); + } }); drawing.tag_positions_changed(); @@ -187,6 +217,8 @@ static void modify_geometry_set(ModifierData *md, if (!geometry_set->has_grease_pencil()) { return; } + bke::GeometryComponentEditData::remember_deformed_positions_if_necessary(*geometry_set); + GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write(); const GreasePencil &grease_pencil_orig = *reinterpret_cast( DEG_get_original_id(&grease_pencil.id)); From c551d2a819090d6893261e5e25a0bdfc137cc5ee Mon Sep 17 00:00:00 2001 From: Aki Sakurai Date: Thu, 6 Feb 2025 11:20:31 +0100 Subject: [PATCH 09/28] Fix: Inverted tablet pen Y tilt on macOS On macOS, the tablet pen Y tilt behavior is inverted; an increase in the tilt value corresponds to tilting the device away from the user. Account for this difference by negating the Y tilt axis in the Cocoa pen tablet handling code. Refs: * https://github.com/qt/qtbase/blob/0f128fd7c5a9ee721d1e631743f6eb61d927cf3b/src/plugins/platforms/cocoa/qnsview_tablet.mm#L63 * https://source.chromium.org/chromium/chromium/src/+/main:components/input/web_input_event_builders_mac.mm;drc=0af5ffa1e4cc4cc4f818725f8fee93ec57855e4b;l=421 Pull Request: https://projects.blender.org/blender/blender/pulls/133932 --- intern/ghost/intern/GHOST_SystemCocoa.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 5d8beec6b16..75ae530f7e9 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1478,7 +1478,9 @@ static NSSize getNSImagePixelSize(NSImage *image) ct.Pressure = event.pressure; ct.Xtilt = event.tilt.x; - ct.Ytilt = event.tilt.y; + /* On macOS, the y tilt behavior is inverted; an increase in the tilt + * value corresponds to tilting the device away from the user. */ + ct.Ytilt = -event.tilt.y; break; case NSEventTypeTabletProximity: From 3b49b5b587242de5e9324a5495aeab40b95a797b Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 6 Feb 2025 11:34:58 +0100 Subject: [PATCH 10/28] Fix: Geometry Nodes: Instance on Points ignores Grease Pencil layer transform It already doesn't work in a very fairly simple case when the Grease Pencil geometry is transformed. This simple case used to work before we changed the Transform Geometry node to transform layers instead of points. Pull Request: https://projects.blender.org/blender/blender/pulls/134131 --- .../nodes/geometry/nodes/node_geo_instance_on_points.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc index 4f090dc65a0..d59967e809f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_instance_on_points.cc @@ -228,17 +228,19 @@ static void node_geo_exec(GeoNodeExecParams params) const GreasePencil &grease_pencil = *geometry_set.get_grease_pencil(); bke::Instances *instances = new bke::Instances(); for (const int layer_index : grease_pencil.layers().index_range()) { - const Drawing *drawing = grease_pencil.get_eval_drawing(grease_pencil.layer(layer_index)); + const Layer &layer = grease_pencil.layer(layer_index); + const Drawing *drawing = grease_pencil.get_eval_drawing(layer); if (drawing == nullptr) { continue; } + const float4x4 &layer_transform = layer.local_transform(); const bke::CurvesGeometry &src_curves = drawing->strokes(); if (src_curves.is_empty()) { /* Add an empty reference so the number of layers and instances match. * This makes it easy to reconstruct the layers afterwards and keep their attributes. * Although in this particular case we don't propagate the attributes. */ const int handle = instances->add_reference(bke::InstanceReference()); - instances->add_instance(handle, float4x4::identity()); + instances->add_instance(handle, layer_transform); continue; } /* TODO: Attributes are not propagating from the curves or the points. */ @@ -253,7 +255,7 @@ static void node_geo_exec(GeoNodeExecParams params) attributes_to_propagate); GeometrySet temp_set = GeometrySet::from_instances(layer_instances); const int handle = instances->add_reference(bke::InstanceReference{temp_set}); - instances->add_instance(handle, float4x4::identity()); + instances->add_instance(handle, layer_transform); } bke::copy_attributes(geometry_set.get_grease_pencil()->attributes(), From 981f9f767decf4afe4e7aace10922d5950280712 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Thu, 6 Feb 2025 12:23:23 +0100 Subject: [PATCH 11/28] Fix #134082: Clarify description for subsurface scattering radius User may think of the `radius` vector value as RGB color, however it's meant to be the depth of scattering for R/G/B channels. Now clarified in the desctiption. Pull Request: https://projects.blender.org/blender/blender/pulls/134088 --- .../nodes/shader/nodes/node_shader_bsdf_principled.cc | 4 ++-- .../shader/nodes/node_shader_subsurface_scattering.cc | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc index 55b8b3aea6e..856685d8407 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc @@ -98,7 +98,7 @@ static void node_declare(NodeDeclarationBuilder &b) .min(0.0f) .max(100.0f) .short_label("Radius") - .description("Scattering radius to use for subsurface component (multiplied with Scale)"); + .description("Scattering radius per color channel (RGB), multiplied with Scale"); #define SOCK_SUBSURFACE_RADIUS_ID 9 sss.add_input("Subsurface Scale") .default_value(0.05f) @@ -106,7 +106,7 @@ static void node_declare(NodeDeclarationBuilder &b) .max(10.0f) .subtype(PROP_DISTANCE) .short_label("Scale") - .description("Scale of the subsurface scattering (multiplied with Radius)"); + .description("Scale factor of the subsurface scattering radius"); #define SOCK_SUBSURFACE_SCALE_ID 10 sss.add_input("Subsurface IOR") .default_value(1.4f) diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc index 2ccfb2e18fa..ae1dbef3d92 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc @@ -16,8 +16,13 @@ namespace blender::nodes::node_shader_subsurface_scattering_cc { static void node_declare(NodeDeclarationBuilder &b) { b.add_input("Color").default_value({0.8f, 0.8f, 0.8f, 1.0f}); - b.add_input("Scale").default_value(0.05f).min(0.0f).max(1000.0f); - b.add_input("Radius").default_value({1.0f, 0.2f, 0.1f}).min(0.0f).max(100.0f); + b.add_input("Scale").default_value(0.05f).min(0.0f).max(1000.0f).description( + "Scale factor of the subsurface scattering radius"); + b.add_input("Radius") + .default_value({1.0f, 0.2f, 0.1f}) + .min(0.0f) + .max(100.0f) + .description("Scattering radius per color channel (RGB), multiplied with Scale"); b.add_input("IOR").default_value(1.4f).min(1.01f).max(3.8f).subtype(PROP_FACTOR); b.add_input("Roughness") .default_value(1.0f) From 6cf73b052e42518ca4c107050132179734fd3680 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Thu, 6 Feb 2025 13:38:36 +0100 Subject: [PATCH 12/28] Fix #134159: Grease Pencil: Use "Blank" for the entry name in add menu When adding an empty grease pencil object, the menu entry should be "Blank" instead of "Empty" to be consistent with 4.2x and previous versions. Pull Request: https://projects.blender.org/blender/blender/pulls/134175 --- scripts/startup/bl_ui/space_view3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 7e8d2e38c57..7415d23ec24 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -2598,7 +2598,7 @@ class VIEW3D_MT_grease_pencil_add(Menu): def draw(self, _context): layout = self.layout - layout.operator("object.grease_pencil_add", text="Empty", icon='EMPTY_AXIS').type = 'EMPTY' + layout.operator("object.grease_pencil_add", text="Blank", icon='EMPTY_AXIS').type = 'EMPTY' layout.operator("object.grease_pencil_add", text="Stroke", icon='STROKE').type = 'STROKE' layout.operator("object.grease_pencil_add", text="Monkey", icon='MONKEY').type = 'MONKEY' layout.separator() From 31444fe5b18e024be6185bf2fe7d20b0250c45f5 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Thu, 6 Feb 2025 13:49:44 +0100 Subject: [PATCH 13/28] Refactor: Compositor: Use generic container for results This patch refactors the Result class in the compositor to use GMutableSpan and std::variant to wrap the result's data. This reduces the complexity of the code and slightly optimizes performance. This will also make it easier to add new types and interface with other code like multi-function procedures. Pull Request: https://projects.blender.org/blender/blender/pulls/134112 --- source/blender/compositor/COM_result.hh | 414 ++++-------------- .../intern/denoised_auxiliary_pass.cc | 2 +- .../multi_function_procedure_operation.cc | 6 +- .../reduce_to_single_value_operation.cc | 2 +- source/blender/compositor/intern/result.cc | 137 +++--- .../node_composite_convert_color_space.cc | 2 +- .../composite/nodes/node_composite_denoise.cc | 8 +- .../nodes/node_composite_file_output.cc | 19 +- .../composite/nodes/node_composite_glare.cc | 7 +- source/blender/render/intern/compositor.cc | 4 +- 10 files changed, 182 insertions(+), 419 deletions(-) diff --git a/source/blender/compositor/COM_result.hh b/source/blender/compositor/COM_result.hh index b0f923749f8..7bf6aba7c3b 100644 --- a/source/blender/compositor/COM_result.hh +++ b/source/blender/compositor/COM_result.hh @@ -6,8 +6,11 @@ #include #include +#include #include "BLI_assert.h" +#include "BLI_cpp_type.hh" +#include "BLI_generic_span.hh" #include "BLI_math_interp.hh" #include "BLI_math_matrix_types.hh" #include "BLI_math_vector.h" @@ -29,7 +32,7 @@ class DerivedResources; /* Make sure to update the format related static methods in the Result class. */ enum class ResultType : uint8_t { /* The following types are user facing and can be used as inputs and outputs of operations. They - * either represent the base type of the result texture or a single value result. The color type + * either represent the base type of the result's image or a single value result. The color type * represents an RGBA color. And the vector type represents a generic 4-component vector, which * can encode two 2D vectors, one 3D vector with the last component ignored, or other dimensional * data. */ @@ -56,10 +59,8 @@ enum class ResultPrecision : uint8_t { enum class ResultStorageType : uint8_t { /* Stored as a GPUTexture on the GPU. */ GPU, - /* Stored as a contiguous float buffer the CPU. */ - FloatCPU, - /* Stored as a contiguous integer buffer the CPU. */ - IntegerCPU, + /* Stored as a buffer on the CPU and wrapped in a GMutableSpan. */ + CPU, }; /* ------------------------------------------------------------------------------------------------ @@ -73,11 +74,11 @@ enum class ResultStorageType : uint8_t { * pool of the context referenced by the result or it can be allocated directly from the GPU * module, see the allocation method for more information. * - * Results are reference counted and their textures are released once their reference count reaches + * Results are reference counted and their data are released once their reference count reaches * zero. After constructing a result, the set_initial_reference_count method is called to declare * the number of operations that needs this result. Once each operation that needs the result no * longer needs it, the release method is called and the reference count is decremented, until it - * reaches zero, where the result's texture is then released. Since results are eventually + * reaches zero, where the result's data is then released. Since results are eventually * decremented to zero by the end of every evaluation, the reference count is restored before every * evaluation to its initial reference count by calling the reset method, which is why a separate * member initial_reference_count_ is stored to keep track of the initial value. @@ -96,9 +97,9 @@ enum class ResultStorageType : uint8_t { * transformation on its domain whatsoever. Proxy results can be created by calling the * pass_through method, see that method for more details. * - * A result can wrap an external texture that is not allocated nor managed by the result. This is - * set up by a call to the wrap_external method. In that case, when the reference count eventually - * reach zero, the texture will not be freed. + * A result can wrap external data that is not allocated nor managed by the result. This is set up + * by a call to the wrap_external method. In that case, when the reference count eventually reach + * zero, the data will not be freed. * * A result may store resources that are computed and cached in case they are needed by multiple * operations. Those are called Derived Resources and can be accessed using the derived_resources @@ -108,27 +109,27 @@ class Result { /* The context that the result was created within, this should be initialized during * construction. */ Context *context_ = nullptr; - /* The base type of the result's texture or single value. */ + /* The base type of the result's image or single value. */ ResultType type_ = ResultType::Float; - /* The precision of the result's texture, host-side single values are always stored using full - * precision. */ + /* The precision of the result's data. Only relevant for GPU textures. CPU buffers and single + * values are always stored using full precision. */ ResultPrecision precision_ = ResultPrecision::Half; - /* If true, the result is a single value, otherwise, the result is a texture. */ + /* If true, the result is a single value, otherwise, the result is an image. */ bool is_single_value_ = false; /* The type of storage used to hold the data. Used to correctly interpret the data union. */ ResultStorageType storage_type_ = ResultStorageType::GPU; - /* A texture storing the result pixel data, either stored in a GPU texture or a raw contagious - * array on CPU. This will be a 1x1 texture if the result is a single value, the value of which - * will be identical to that of the value member. See class description for more information. */ + /* Stores the result's pixel data, either stored in a GPU texture or a buffer that is wrapped in + * a GMutableSpan on CPU. This will represent a 1x1 image if the result is a single value, the + * value of which will be identical to that of the value member. See class description for more + * information. */ union { GPUTexture *gpu_texture_ = nullptr; - float *float_texture_; - int *integer_texture_; + GMutableSpan cpu_data_; }; /* The number of operations that currently needs this result. At the time when the result is * computed, this member will have a value that matches initial_reference_count_. Once each * operation that needs the result no longer needs it, the release method is called and the - * reference count is decremented, until it reaches zero, where the result's texture is then + * reference count is decremented, until it reaches zero, where the result's data is then * released. If this result have a master result, then this reference count is irrelevant and * shadowed by the reference count of the master result. */ int reference_count_ = 1; @@ -139,30 +140,22 @@ class Result { * should be computed by calling the should_compute method. */ int initial_reference_count_ = 1; /* If the result is a single value, this member stores the value of the result, the value of - * which will be identical to that stored in the texture member. The active union member depends + * which will be identical to that stored in the data_ member. The active variant member depends * on the type of the result. This member is uninitialized and should not be used if the result - * is a texture. */ - union { - float float_value_; - float4 vector_value_; - float4 color_value_ = float4(0.0f); - float2 float2_value_; - float3 float3_value_; - int int_value_; - int2 int2_value_; - }; - /* The domain of the result. This only matters if the result was a texture. See the discussion in - * COM_domain.hh for more information. */ + * is not a single value. */ + std::variant single_value_ = 0.0f; + /* The domain of the result. This only matters if the result was not a single value. See the + * discussion in COM_domain.hh for more information. */ Domain domain_ = Domain::identity(); /* If not nullptr, then this result wraps and shares the value of another master result. In this - * case, calls to texture-related methods like increment_reference_count and release should - * operate on the master result as opposed to this result. This member is typically set upon - * calling the pass_through method, which sets this result to be the master of a target result. - * See that method for more information. */ + * case, calls to methods like increment_reference_count and release should operate on the master + * result as opposed to this result. This member is typically set upon calling the pass_through + * method, which sets this result to be the master of a target result. See that method for more + * information. */ Result *master_ = nullptr; - /* If true, then the result wraps an external texture that is not allocated nor managed by the - * result. This is set up by a call to the wrap_external method. In that case, when the reference - * count eventually reach zero, the texture will not be freed. */ + /* If true, then the result wraps external data that is not allocated nor managed by the result. + * This is set up by a call to the wrap_external method. In that case, when the reference count + * eventually reach zero, the data will not be freed. */ bool is_external_ = false; /* If true, the GPU texture that holds the data was allocated from the texture pool of the * context and should be released back into the pool instead of being freed. For CPU storage, @@ -206,6 +199,8 @@ class Result { /* Implicit conversion to the internal GPU texture. */ operator GPUTexture *() const; + const CPPType &get_cpp_type() const; + /* Returns the appropriate texture format based on the result's type and precision. */ eGPUTextureFormat get_gpu_texture_format() const; @@ -234,12 +229,12 @@ class Result { void allocate_texture(Domain domain, bool from_pool = true); /* Declare the result to be a single value result, allocate a texture of an appropriate type with - * size 1x1 from the texture pool, and set the domain to be an identity domain. See class - * description for more information. */ + * size 1x1 from the texture pool, and set the domain to be an identity domain. The value is zero + * initialized. See class description for more information. */ void allocate_single_value(); - /* Allocate a single value result and set its value to zero. This is called for results whose - * value can't be computed and are considered invalid. */ + /* Allocate a single value result whose value is zero. This is called for results whose value + * can't be computed and are considered invalid. */ void allocate_invalid(); /* Bind the GPU texture of the result to the texture image unit with the given name in the @@ -290,11 +285,8 @@ class Result { * is assumed to have a lifetime that covers the evaluation of the compositor. */ void wrap_external(GPUTexture *texture); - /* Identical to GPU variant of wrap_external but wraps a float buffer instead. */ - void wrap_external(float *texture, int2 size); - - /* Identical to GPU variant of wrap_external but wraps an integer buffer instead. */ - void wrap_external(int *texture, int2 size); + /* Identical to GPU variant of wrap_external but wraps a CPU buffer instead. */ + void wrap_external(void *data, int2 size); /* Identical to GPU variant of wrap_external but wraps whatever the given result has instead. */ void wrap_external(const Result &result); @@ -355,7 +347,7 @@ class Result { /* Sets the precision of the result. */ void set_precision(ResultPrecision precision); - /* Returns true if the result is a single value and false of it is a texture. */ + /* Returns true if the result is a single value and false of it is an image. */ bool is_single_value() const; /* Returns true if the result is allocated. */ @@ -371,15 +363,9 @@ class Result { /* Computes the number of channels of the result based on its type. */ int64_t channels_count() const; - /* Returns a reference to the allocate float data. */ - float *float_texture() const; - - /* Returns a reference to the allocate integer data. */ - int *integer_texture() const; + GPUTexture *gpu_texture() const; - /* Returns a reference to the allocated CPU data. The returned data is untyped, use the - * float_texture() or the integer_texture() methods for typed data. */ - void *data() const; + GMutableSpan cpu_data() const; /* Gets the single value stored in the result. Assumes the result stores a value of the given * template type. */ @@ -392,7 +378,7 @@ class Result { template T get_single_value_default(const T &default_value) const; /* Sets the single value of the result to the given value, which also involves setting the single - * pixel in the texture to that value. See the class description for more information. Assumes + * pixel in the image to that value. See the class description for more information. Assumes * the result stores a value of the given template type. */ template void set_single_value(const T &value); @@ -464,46 +450,13 @@ class Result { /* Return true if the provided template type is an int or an int vector. */ template static constexpr bool is_int_type(); - /* Returns the number of channels in the provided template type, this is 1 for scalar types, and - * the number of elements for vector types. */ - template static constexpr int get_type_channels_count(); - - /* Return true if the provided template type is supported by the class. */ - template static constexpr bool is_supported_type(); - - /* Allocates the texture data for the given size, either on the GPU or CPU based on the result's + /* Allocates the image data for the given size, either on the GPU or CPU based on the result's * context. See the allocate_texture method for information about the from_pool argument. */ void allocate_data(int2 size, bool from_pool); - /* Get the index of the start of pixel at the given texel position in its result buffer. Asserts - * if the template type doesn't match the result's type. */ - template int64_t get_pixel_index(const int2 &texel) const; - /* Same as get_pixel_index but can be used when the type of the result is not known at compile * time. */ int64_t get_pixel_index(const int2 &texel) const; - - /* Get a pointer to the float pixel at the given texel position. Asserts if the template type - * doesn't match the result's type. */ - template - std::conditional_t(), int, float> *get_pixel(const int2 &texel) const; - - /* Get a pointer to the float pixel at the given texel position. */ - float *get_float_pixel(const int2 &texel) const; - - /* Get a pointer to the integer pixel at the given texel position. */ - int *get_integer_pixel(const int2 &texel) const; - - /* Copy the float pixel from the source pointer to the target pointer, assuming the given - * channels count. */ - static void copy_pixel(float *target, const float *source, const int channels_count); - - /* Copy the integer pixel from the source pointer to the target pointer, assuming the given - * channels count. */ - static void copy_pixel(int *target, const int *source, const int channels_count); - - /* Copy the float pixel from the source pointer to the target pointer. */ - void copy_pixel(float *target, const float *source) const; }; /* -------------------------------------------------------------------- */ @@ -533,65 +486,23 @@ inline int64_t Result::channels_count() const return 4; } -inline float *Result::float_texture() const +inline GPUTexture *Result::gpu_texture() const { - BLI_assert(storage_type_ == ResultStorageType::FloatCPU); - return float_texture_; + BLI_assert(storage_type_ == ResultStorageType::GPU); + return gpu_texture_; } -inline int *Result::integer_texture() const +inline GMutableSpan Result::cpu_data() const { - BLI_assert(storage_type_ == ResultStorageType::IntegerCPU); - return integer_texture_; -} - -inline void *Result::data() const -{ - switch (storage_type_) { - case ResultStorageType::FloatCPU: - return this->float_texture(); - case ResultStorageType::IntegerCPU: - return this->integer_texture(); - case ResultStorageType::GPU: - break; - } - - BLI_assert_unreachable(); - return nullptr; + BLI_assert(storage_type_ == ResultStorageType::CPU); + return cpu_data_; } template inline const T &Result::get_single_value() const { BLI_assert(this->is_single_value()); - static_assert(Result::is_supported_type()); - if constexpr (std::is_same_v) { - BLI_assert(type_ == ResultType::Float); - return float_value_; - } - else if constexpr (std::is_same_v) { - BLI_assert(type_ == ResultType::Int); - return int_value_; - } - else if constexpr (std::is_same_v) { - BLI_assert(type_ == ResultType::Float2); - return float2_value_; - } - else if constexpr (std::is_same_v) { - BLI_assert(type_ == ResultType::Float3); - return float3_value_; - } - else if constexpr (std::is_same_v) { - BLI_assert(ELEM(type_, ResultType::Color, ResultType::Vector)); - return color_value_; - } - else if constexpr (std::is_same_v) { - BLI_assert(type_ == ResultType::Int2); - return int2_value_; - } - else { - return T(0); - } + return std::get(single_value_); } template inline T &Result::get_single_value() @@ -611,48 +522,30 @@ template inline void Result::set_single_value(const T &value) { BLI_assert(this->is_allocated()); BLI_assert(this->is_single_value()); - static_assert(Result::is_supported_type()); - this->get_single_value() = value; + single_value_ = value; switch (storage_type_) { case ResultStorageType::GPU: if constexpr (Result::is_int_type()) { if constexpr (std::is_scalar_v) { - GPU_texture_update(gpu_texture_, GPU_DATA_INT, &value); + GPU_texture_update(this->gpu_texture(), GPU_DATA_INT, &value); } else { - GPU_texture_update(gpu_texture_, GPU_DATA_INT, value); + GPU_texture_update(this->gpu_texture(), GPU_DATA_INT, value); } } else { if constexpr (std::is_scalar_v) { - GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, &value); + GPU_texture_update(this->gpu_texture(), GPU_DATA_FLOAT, &value); } else { - GPU_texture_update(gpu_texture_, GPU_DATA_FLOAT, value); + GPU_texture_update(this->gpu_texture(), GPU_DATA_FLOAT, value); } } break; - case ResultStorageType::FloatCPU: - case ResultStorageType::IntegerCPU: - if constexpr (Result::is_int_type()) { - if constexpr (std::is_scalar_v) { - Result::copy_pixel( - this->integer_texture(), &value, Result::get_type_channels_count()); - } - else { - Result::copy_pixel(this->integer_texture(), value, Result::get_type_channels_count()); - } - } - else { - if constexpr (std::is_scalar_v) { - Result::copy_pixel(this->float_texture(), &value, Result::get_type_channels_count()); - } - else { - Result::copy_pixel(this->float_texture(), value, Result::get_type_channels_count()); - } - } + case ResultStorageType::CPU: + this->cpu_data().typed()[0] = value; break; } } @@ -668,12 +561,7 @@ template inline T Result::load_pixel(const BLI_assert(!this->is_single_value()); } - if constexpr (std::is_scalar_v) { - return *this->get_pixel(texel); - } - else { - return T(this->get_pixel(texel)); - } + return this->cpu_data().typed()[this->get_pixel_index(texel)]; } template @@ -689,12 +577,7 @@ inline T Result::load_pixel_extended(const int2 &texel) const } const int2 clamped_texel = math::clamp(texel, int2(0), domain_.size - int2(1)); - if constexpr (std::is_scalar_v) { - return *this->get_pixel(clamped_texel); - } - else { - return T(this->get_pixel(clamped_texel)); - } + return this->cpu_data().typed()[this->get_pixel_index(clamped_texel)]; } template @@ -713,12 +596,7 @@ inline T Result::load_pixel_fallback(const int2 &texel, const T &fallback) const return fallback; } - if constexpr (std::is_scalar_v) { - return *this->get_pixel(texel); - } - else { - return T(this->get_pixel(texel)); - } + return this->cpu_data().typed()[this->get_pixel_index(texel)]; } template @@ -731,42 +609,37 @@ inline float4 Result::load_pixel_generic_type(const int2 &texel) const { float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); } else { - this->copy_pixel(pixel_value, this->get_float_pixel(texel)); + this->get_cpp_type().copy_assign(this->cpu_data()[this->get_pixel_index(texel)], pixel_value); } return pixel_value; } template inline void Result::store_pixel(const int2 &texel, const T &pixel_value) { - if constexpr (std::is_scalar_v) { - *this->get_pixel(texel) = pixel_value; - } - else { - Result::copy_pixel( - this->get_pixel(texel), pixel_value, Result::get_type_channels_count()); - } + this->cpu_data().typed()[this->get_pixel_index(texel)] = pixel_value; } inline void Result::store_pixel_generic_type(const int2 &texel, const float4 &pixel_value) { - this->copy_pixel(this->get_float_pixel(texel), pixel_value); + this->get_cpp_type().copy_assign(pixel_value, this->cpu_data()[this->get_pixel_index(texel)]); } inline float4 Result::sample_nearest_zero(const float2 &coordinates) const { float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } const int2 size = domain_.size; const float2 texel_coordinates = coordinates * float2(size); - math::interpolate_nearest_border_fl(this->float_texture(), + const float *buffer = static_cast(this->cpu_data().data()); + math::interpolate_nearest_border_fl(buffer, pixel_value, size.x, size.y, @@ -782,15 +655,16 @@ inline float4 Result::sample_nearest_wrap(const float2 &coordinates, { float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } const int2 size = domain_.size; const float2 texel_coordinates = coordinates * float2(size); + const float *buffer = static_cast(this->cpu_data().data()); math::interpolate_nearest_wrapmode_fl( - this->float_texture(), + buffer, pixel_value, size.x, size.y, @@ -808,15 +682,16 @@ inline float4 Result::sample_bilinear_wrap(const float2 &coordinates, { float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } const int2 size = domain_.size; const float2 texel_coordinates = coordinates * float2(size) - 0.5f; + const float *buffer = static_cast(this->cpu_data().data()); math::interpolate_bilinear_wrapmode_fl( - this->float_texture(), + buffer, pixel_value, size.x, size.y, @@ -832,15 +707,16 @@ inline float4 Result::sample_cubic_wrap(const float2 &coordinates, bool wrap_x, { float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } const int2 size = domain_.size; const float2 texel_coordinates = coordinates * float2(size) - 0.5f; + const float *buffer = static_cast(this->cpu_data().data()); math::interpolate_cubic_bspline_wrapmode_fl( - this->float_texture(), + buffer, pixel_value, size.x, size.y, @@ -856,14 +732,15 @@ inline float4 Result::sample_bilinear_zero(const float2 &coordinates) const { float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } const int2 size = domain_.size; const float2 texel_coordinates = (coordinates * float2(size)) - 0.5f; - math::interpolate_bilinear_border_fl(this->float_texture(), + const float *buffer = static_cast(this->cpu_data().data()); + math::interpolate_bilinear_border_fl(buffer, pixel_value, size.x, size.y, @@ -877,14 +754,15 @@ inline float4 Result::sample_nearest_extended(const float2 &coordinates) const { float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } const int2 size = domain_.size; const float2 texel_coordinates = coordinates * float2(size); - math::interpolate_nearest_fl(this->float_texture(), + const float *buffer = static_cast(this->cpu_data().data()); + math::interpolate_nearest_fl(buffer, pixel_value, size.x, size.y, @@ -898,14 +776,15 @@ inline float4 Result::sample_bilinear_extended(const float2 &coordinates) const { float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } const int2 size = domain_.size; const float2 texel_coordinates = (coordinates * float2(size)) - 0.5f; - math::interpolate_bilinear_fl(this->float_texture(), + const float *buffer = static_cast(this->cpu_data().data()); + math::interpolate_bilinear_fl(buffer, pixel_value, size.x, size.y, @@ -934,7 +813,7 @@ inline float4 Result::sample_ewa_extended(const float2 &coordinates, float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } @@ -971,7 +850,7 @@ inline float4 Result::sample_ewa_zero(const float2 &coordinates, float4 pixel_value = float4(0.0f, 0.0f, 0.0f, 1.0f); if (is_single_value_) { - this->copy_pixel(pixel_value, float_texture_); + this->get_cpp_type().copy_assign(this->cpu_data().data(), pixel_value); return pixel_value; } @@ -999,123 +878,12 @@ template constexpr bool Result::is_int_type() } } -template constexpr int Result::get_type_channels_count() -{ - if constexpr (std::is_scalar_v) { - return 1; - } - else { - return T::type_length; - } -} - -template constexpr bool Result::is_supported_type() -{ - return is_same_any_v; -} - -template inline int64_t Result::get_pixel_index(const int2 &texel) const -{ - BLI_assert(!is_single_value_); - BLI_assert(this->is_allocated()); - BLI_assert(texel.x >= 0 && texel.y >= 0 && texel.x < domain_.size.x && texel.y < domain_.size.y); - static_assert(Result::is_supported_type()); - - constexpr int channels_count = Result::get_type_channels_count(); - BLI_assert(this->channels_count() == channels_count); - - return (int64_t(texel.y) * domain_.size.x + texel.x) * channels_count; -} - inline int64_t Result::get_pixel_index(const int2 &texel) const { BLI_assert(!is_single_value_); BLI_assert(this->is_allocated()); BLI_assert(texel.x >= 0 && texel.y >= 0 && texel.x < domain_.size.x && texel.y < domain_.size.y); - return (int64_t(texel.y) * domain_.size.x + texel.x) * this->channels_count(); -} - -template -inline std::conditional_t(), int, float> *Result::get_pixel( - const int2 &texel) const -{ - if constexpr (Result::is_int_type()) { - return this->integer_texture() + this->get_pixel_index(texel); - } - else { - return this->float_texture() + this->get_pixel_index(texel); - } -} - -inline float *Result::get_float_pixel(const int2 &texel) const -{ - BLI_assert(storage_type_ == ResultStorageType::FloatCPU); - return float_texture_ + this->get_pixel_index(texel); -} - -inline int *Result::get_integer_pixel(const int2 &texel) const -{ - BLI_assert(storage_type_ == ResultStorageType::IntegerCPU); - return integer_texture_ + this->get_pixel_index(texel); -} - -inline void Result::copy_pixel(float *target, const float *source, const int channels_count) -{ - switch (channels_count) { - case 1: - *target = *source; - break; - case 2: - copy_v2_v2(target, source); - break; - case 3: - copy_v3_v3(target, source); - break; - case 4: - copy_v4_v4(target, source); - break; - default: - BLI_assert_unreachable(); - break; - } -} - -inline void Result::copy_pixel(int *target, const int *source, const int channels_count) -{ - switch (channels_count) { - case 1: - *target = *source; - break; - case 2: - copy_v2_v2_int(target, source); - break; - default: - BLI_assert_unreachable(); - break; - } -} - -inline void Result::copy_pixel(float *target, const float *source) const -{ - switch (type_) { - case ResultType::Float: - *target = *source; - break; - case ResultType::Float2: - copy_v2_v2(target, source); - break; - case ResultType::Float3: - copy_v3_v3(target, source); - break; - case ResultType::Vector: - case ResultType::Color: - copy_v4_v4(target, source); - break; - case ResultType::Int: - case ResultType::Int2: - BLI_assert_unreachable(); - break; - } + return int64_t(texel.y) * domain_.size.x + texel.x; } } // namespace blender::compositor diff --git a/source/blender/compositor/derived_resources/intern/denoised_auxiliary_pass.cc b/source/blender/compositor/derived_resources/intern/denoised_auxiliary_pass.cc index 1b971e63d85..7e5f662dc09 100644 --- a/source/blender/compositor/derived_resources/intern/denoised_auxiliary_pass.cc +++ b/source/blender/compositor/derived_resources/intern/denoised_auxiliary_pass.cc @@ -81,7 +81,7 @@ DenoisedAuxiliaryPass::DenoisedAuxiliaryPass(Context &context, this->denoised_buffer = static_cast(GPU_texture_read(pass, GPU_DATA_FLOAT, 0)); } else { - this->denoised_buffer = static_cast(MEM_dupallocN(pass.float_texture())); + this->denoised_buffer = static_cast(MEM_dupallocN(pass.cpu_data().data())); } const int width = pass.domain().size.x; diff --git a/source/blender/compositor/intern/multi_function_procedure_operation.cc b/source/blender/compositor/intern/multi_function_procedure_operation.cc index a1ae1404370..4e274f68b63 100644 --- a/source/blender/compositor/intern/multi_function_procedure_operation.cc +++ b/source/blender/compositor/intern/multi_function_procedure_operation.cc @@ -170,8 +170,7 @@ void MultiFunctionProcedureOperation::execute() add_single_value_input_parameter(parameter_builder, input); } else { - const GSpan span{get_cpp_type(input.type()), input.data(), size}; - parameter_builder.add_readonly_single_input(span); + parameter_builder.add_readonly_single_input(input.cpu_data()); } } else { @@ -181,8 +180,7 @@ void MultiFunctionProcedureOperation::execute() } else { output.allocate_texture(domain); - const GMutableSpan span{get_cpp_type(output.type()), output.data(), size}; - parameter_builder.add_uninitialized_single_output(span); + parameter_builder.add_uninitialized_single_output(output.cpu_data()); } } } diff --git a/source/blender/compositor/intern/reduce_to_single_value_operation.cc b/source/blender/compositor/intern/reduce_to_single_value_operation.cc index d4181e6a1c7..a38204d78c3 100644 --- a/source/blender/compositor/intern/reduce_to_single_value_operation.cc +++ b/source/blender/compositor/intern/reduce_to_single_value_operation.cc @@ -38,7 +38,7 @@ void ReduceToSingleValueOperation::execute() need_to_free_pixel = true; } else { - pixel = input.float_texture(); + pixel = input.cpu_data().data(); } Result &result = get_result(); diff --git a/source/blender/compositor/intern/result.cc b/source/blender/compositor/intern/result.cc index 510c8739174..aeb2a5637f6 100644 --- a/source/blender/compositor/intern/result.cc +++ b/source/blender/compositor/intern/result.cc @@ -2,11 +2,17 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include +#include + #include "MEM_guardedalloc.h" #include "BLI_assert.h" +#include "BLI_cpp_type.hh" +#include "BLI_generic_span.hh" #include "BLI_math_matrix_types.hh" #include "BLI_math_vector_types.hh" +#include "BLI_utildefines.h" #include "GPU_shader.hh" #include "GPU_state.hh" @@ -212,8 +218,30 @@ ResultType Result::float_type(const int channels_count) Result::operator GPUTexture *() const { - BLI_assert(storage_type_ == ResultStorageType::GPU); - return gpu_texture_; + return this->gpu_texture(); +} + +const CPPType &Result::get_cpp_type() const +{ + switch (this->type()) { + case ResultType::Float: + return CPPType::get(); + case ResultType::Int: + return CPPType::get(); + case ResultType::Vector: + return CPPType::get(); + case ResultType::Color: + return CPPType::get(); + case ResultType::Float2: + return CPPType::get(); + case ResultType::Float3: + return CPPType::get(); + case ResultType::Int2: + return CPPType::get(); + } + + BLI_assert_unreachable(); + return CPPType::get(); } eGPUTextureFormat Result::get_gpu_texture_format() const @@ -238,41 +266,44 @@ void Result::allocate_texture(Domain domain, bool from_pool) void Result::allocate_single_value() { - /* Single values are stored in 1x1 textures as well as the single value members. Further, they + /* Single values are stored in 1x1 image as well as the single value members. Further, they * are always allocated from the pool. */ is_single_value_ = true; this->allocate_data(int2(1), true); domain_ = Domain::identity(); -} -void Result::allocate_invalid() -{ - allocate_single_value(); + /* It is important that we initialize single values because the variant member that stores single + * values need to have its type initialized. */ switch (type_) { case ResultType::Float: - set_single_value(0.0f); + this->set_single_value(0.0f); break; case ResultType::Vector: - set_single_value(float4(0.0f)); + this->set_single_value(float4(0.0f)); break; case ResultType::Color: - set_single_value(float4(0.0f)); + this->set_single_value(float4(0.0f)); break; case ResultType::Float2: - set_single_value(float2(0.0f)); + this->set_single_value(float2(0.0f)); break; case ResultType::Float3: - set_single_value(float3(0.0f)); + this->set_single_value(float3(0.0f)); break; case ResultType::Int: - set_single_value(0); + this->set_single_value(0); break; case ResultType::Int2: - set_single_value(int2(0)); + this->set_single_value(int2(0)); break; } } +void Result::allocate_invalid() +{ + this->allocate_single_value(); +} + void Result::bind_as_texture(GPUShader *shader, const char *texture_name) const { BLI_assert(storage_type_ == ResultStorageType::GPU); @@ -281,7 +312,7 @@ void Result::bind_as_texture(GPUShader *shader, const char *texture_name) const GPU_memory_barrier(GPU_BARRIER_TEXTURE_FETCH); const int texture_image_unit = GPU_shader_get_sampler_binding(shader, texture_name); - GPU_texture_bind(gpu_texture_, texture_image_unit); + GPU_texture_bind(this->gpu_texture(), texture_image_unit); } void Result::bind_as_image(GPUShader *shader, const char *image_name, bool read) const @@ -294,19 +325,19 @@ void Result::bind_as_image(GPUShader *shader, const char *image_name, bool read) } const int image_unit = GPU_shader_get_sampler_binding(shader, image_name); - GPU_texture_image_bind(gpu_texture_, image_unit); + GPU_texture_image_bind(this->gpu_texture(), image_unit); } void Result::unbind_as_texture() const { BLI_assert(storage_type_ == ResultStorageType::GPU); - GPU_texture_unbind(gpu_texture_); + GPU_texture_unbind(this->gpu_texture()); } void Result::unbind_as_image() const { BLI_assert(storage_type_ == ResultStorageType::GPU); - GPU_texture_image_unbind(gpu_texture_); + GPU_texture_image_unbind(this->gpu_texture()); } void Result::pass_through(Result &target) @@ -354,24 +385,14 @@ void Result::wrap_external(GPUTexture *texture) domain_ = Domain(int2(GPU_texture_width(texture), GPU_texture_height(texture))); } -void Result::wrap_external(float *texture, int2 size) +void Result::wrap_external(void *data, int2 size) { BLI_assert(!this->is_allocated()); BLI_assert(!master_); - float_texture_ = texture; - storage_type_ = ResultStorageType::FloatCPU; - is_external_ = true; - domain_ = Domain(size); -} - -void Result::wrap_external(int *texture, int2 size) -{ - BLI_assert(!this->is_allocated()); - BLI_assert(!master_); - - integer_texture_ = texture; - storage_type_ = ResultStorageType::IntegerCPU; + const int64_t array_size = int64_t(size.x) * int64_t(size.y); + cpu_data_ = GMutableSpan(this->get_cpp_type(), data, array_size); + storage_type_ = ResultStorageType::CPU; is_external_ = true; domain_ = Domain(size); } @@ -468,20 +489,16 @@ void Result::free() switch (storage_type_) { case ResultStorageType::GPU: if (is_from_pool_) { - context_->texture_pool().release(gpu_texture_); + context_->texture_pool().release(this->gpu_texture()); } else { - GPU_texture_free(gpu_texture_); + GPU_texture_free(this->gpu_texture()); } gpu_texture_ = nullptr; break; - case ResultStorageType::FloatCPU: - MEM_freeN(float_texture_); - float_texture_ = nullptr; - break; - case ResultStorageType::IntegerCPU: - MEM_freeN(integer_texture_); - integer_texture_ = nullptr; + case ResultStorageType::CPU: + MEM_freeN(this->cpu_data().data()); + cpu_data_ = GMutableSpan(); break; } @@ -535,11 +552,9 @@ bool Result::is_allocated() const { switch (storage_type_) { case ResultStorageType::GPU: - return gpu_texture_ != nullptr; - case ResultStorageType::FloatCPU: - return float_texture_ != nullptr; - case ResultStorageType::IntegerCPU: - return integer_texture_ != nullptr; + return this->gpu_texture(); + case ResultStorageType::CPU: + return this->cpu_data().data(); } return false; @@ -557,6 +572,7 @@ int Result::reference_count() const void Result::allocate_data(int2 size, bool from_pool) { if (context_->use_gpu()) { + storage_type_ = ResultStorageType::GPU; is_from_pool_ = from_pool; if (from_pool) { gpu_texture_ = context_->texture_pool().acquire(size, this->get_gpu_texture_format()); @@ -572,23 +588,18 @@ void Result::allocate_data(int2 size, bool from_pool) } } else { - switch (type_) { - case ResultType::Float: - case ResultType::Vector: - case ResultType::Color: - case ResultType::Float2: - case ResultType::Float3: - float_texture_ = static_cast(MEM_malloc_arrayN( - int64_t(size.x) * int64_t(size.y), this->channels_count() * sizeof(float), __func__)); - storage_type_ = ResultStorageType::FloatCPU; - break; - case ResultType::Int: - case ResultType::Int2: - integer_texture_ = static_cast(MEM_malloc_arrayN( - int64_t(size.x) * int64_t(size.y), this->channels_count() * sizeof(int), __func__)); - storage_type_ = ResultStorageType::IntegerCPU; - break; - } + storage_type_ = ResultStorageType::CPU; + + const CPPType &cpp_type = this->get_cpp_type(); + const int64_t item_size = cpp_type.size(); + const int64_t alignment = cpp_type.alignment(); + const int64_t array_size = int64_t(size.x) * int64_t(size.y); + const int64_t memory_size = array_size * item_size; + + void *data = MEM_mallocN_aligned(memory_size, alignment, AT); + cpp_type.default_construct_n(data, array_size); + + cpu_data_ = GMutableSpan(cpp_type, data, array_size); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc index 9d81ef983fc..9797557a166 100644 --- a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc +++ b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc @@ -140,7 +140,7 @@ class ConvertColorSpaceOperation : public NodeOperation { }); IMB_colormanagement_processor_apply(color_processor, - output_image.float_texture(), + static_cast(output_image.cpu_data().data()), domain.size.x, domain.size.y, input_image.channels_count(), diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc index 3ce1675234a..1cf132e54c8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc +++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc @@ -148,8 +148,8 @@ class DenoiseOperation : public NodeOperation { temporary_buffers_to_free.append(input_color); } else { - input_color = input_image.float_texture(); - output_color = output_image.float_texture(); + input_color = static_cast(input_image.cpu_data().data()); + output_color = static_cast(output_image.cpu_data().data()); } oidn::FilterRef filter = device.newFilter("RT"); filter.setImage("color", input_color, oidn::Format::Float3, width, height, 0, pixel_stride); @@ -179,7 +179,7 @@ class DenoiseOperation : public NodeOperation { temporary_buffers_to_free.append(albedo); } else { - albedo = input_albedo.float_texture(); + albedo = static_cast(input_albedo.cpu_data().data()); } } @@ -207,7 +207,7 @@ class DenoiseOperation : public NodeOperation { temporary_buffers_to_free.append(normal); } else { - normal = input_normal.float_texture(); + normal = static_cast(input_normal.cpu_data().data()); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_file_output.cc b/source/blender/nodes/composite/nodes/node_composite_file_output.cc index 6552c4bb655..cb2a1ab11d5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_file_output.cc +++ b/source/blender/nodes/composite/nodes/node_composite_file_output.cc @@ -659,14 +659,7 @@ class FileOutputOperation : public NodeOperation { } else { /* Copy the result into a new buffer. */ - const int64_t buffer_size = int64_t(size.x) * size.y * result.channels_count(); - buffer = static_cast( - MEM_malloc_arrayN(buffer_size, sizeof(float), "File Output Buffer Copy.")); - threading::parallel_for(IndexRange(buffer_size), 1024, [&](const IndexRange sub_range) { - for (const int64_t i : sub_range) { - buffer[i] = result.float_texture()[i]; - } - }); + buffer = static_cast(MEM_dupallocN(result.cpu_data().data())); } } @@ -750,15 +743,7 @@ class FileOutputOperation : public NodeOperation { } else { /* Copy the result into a new buffer. */ - const int2 size = result.domain().size; - const int64_t buffer_size = int64_t(size.x) * size.y * result.channels_count(); - buffer = static_cast( - MEM_malloc_arrayN(buffer_size, sizeof(float), "File Output Buffer Copy.")); - threading::parallel_for(IndexRange(buffer_size), 1024, [&](const IndexRange sub_range) { - for (const int64_t i : sub_range) { - buffer[i] = result.float_texture()[i]; - } - }); + buffer = static_cast(MEM_dupallocN(result.cpu_data().data())); } const int2 size = result.domain().size; diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.cc b/source/blender/nodes/composite/nodes/node_composite_glare.cc index a33798272f5..51816c25662 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.cc +++ b/source/blender/nodes/composite/nodes/node_composite_glare.cc @@ -1982,7 +1982,7 @@ class GlareOperation : public NodeOperation { highlights_buffer = static_cast(GPU_texture_read(highlights, GPU_DATA_FLOAT, 0)); } else { - highlights_buffer = highlights.float_texture(); + highlights_buffer = static_cast(highlights.cpu_data().data()); } /* Zero pad the image to the required spatial domain size, storing each channel in planar @@ -2060,8 +2060,9 @@ class GlareOperation : public NodeOperation { /* For GPU, write the output to the exist highlights_buffer then upload to the result after, * while for CPU, write to the result directly. */ - float *output = this->context().use_gpu() ? highlights_buffer : - fog_glow_result.float_texture(); + float *output = this->context().use_gpu() ? + highlights_buffer : + static_cast(fog_glow_result.cpu_data().data()); /* Copy the result to the output. */ threading::parallel_for(IndexRange(image_size.y), 1, [&](const IndexRange sub_y_range) { diff --git a/source/blender/render/intern/compositor.cc b/source/blender/render/intern/compositor.cc index 91f2acd18ef..bca0730f15b 100644 --- a/source/blender/render/intern/compositor.cc +++ b/source/blender/render/intern/compositor.cc @@ -507,7 +507,7 @@ class Context : public compositor::Context { MEM_malloc_arrayN(rr->rectx * rr->recty, 4 * sizeof(float), __func__)); IMB_assign_float_buffer(ibuf, data, IB_TAKE_OWNERSHIP); std::memcpy( - data, output_result_.float_texture(), rr->rectx * rr->recty * 4 * sizeof(float)); + data, output_result_.cpu_data().data(), rr->rectx * rr->recty * 4 * sizeof(float)); } } @@ -580,7 +580,7 @@ class Context : public compositor::Context { } else { std::memcpy(image_buffer->float_buffer.data, - viewer_output_result_.float_texture(), + viewer_output_result_.cpu_data().data(), size.x * size.y * 4 * sizeof(float)); } From 7b3fa03e56b5579c9c8f91e8bb07ffb7efb0f548 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 6 Feb 2025 14:29:09 +0100 Subject: [PATCH 14/28] Math: Work around Windows math::is_negative build failures Don't template size for matrix is_negative. These are causing random build failures on the Windows buildbot. Note that these already have the assumption of 3D coordinates baked in. For 2D or 4D coordinates the implementation would have to be different. So templating these for arbitrary dimensions does not make much sense. Pull Request: https://projects.blender.org/blender/blender/pulls/134137 --- source/blender/blenlib/BLI_math_matrix.hh | 9 +++------ source/blender/blenlib/intern/math_matrix.cc | 7 +++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/blender/blenlib/BLI_math_matrix.hh b/source/blender/blenlib/BLI_math_matrix.hh index 0d157def9a9..f901db12297 100644 --- a/source/blender/blenlib/BLI_math_matrix.hh +++ b/source/blender/blenlib/BLI_math_matrix.hh @@ -491,13 +491,10 @@ template /** * Returns true if matrix has inverted handedness. * - * \note It doesn't use determinant(mat4x4) as only the 3x3 components are needed - * when the matrix is used as a transformation to represent location/scale/rotation. + * \note It doesn't use determinant(mat4x4) as only the 3x3 components are needed assuming + * the matrix is used as a transformation to represent 3D location/scale/rotation. */ -template [[nodiscard]] bool is_negative(const MatBase &mat) -{ - return determinant(mat) < T(0); -} +template [[nodiscard]] bool is_negative(const MatBase &mat); template [[nodiscard]] bool is_negative(const MatBase &mat); /** diff --git a/source/blender/blenlib/intern/math_matrix.cc b/source/blender/blenlib/intern/math_matrix.cc index 0f0af0eefd6..beff2e257ad 100644 --- a/source/blender/blenlib/intern/math_matrix.cc +++ b/source/blender/blenlib/intern/math_matrix.cc @@ -139,13 +139,20 @@ template double determinant(const double2x2 &mat); template double determinant(const double3x3 &mat); template double determinant(const double4x4 &mat); +template bool is_negative(const MatBase &mat) +{ + return determinant(mat) < T(0); +} + template bool is_negative(const MatBase &mat) { return Eigen::Map, 0, Eigen::Stride<4, 1>>(mat.base_ptr()) .determinant() < T(0); } +template bool is_negative(const float3x3 &mat); template bool is_negative(const float4x4 &mat); +template bool is_negative(const double3x3 &mat); template bool is_negative(const double4x4 &mat); /** \} */ From d5823ad8959abe611fd4dac8125ed0921dbf7276 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 6 Feb 2025 14:29:42 +0100 Subject: [PATCH 15/28] Fix: MaterialX 1.39 subsurface not exporting correctly Pull Request: https://projects.blender.org/blender/blender/pulls/134139 --- .../nodes/node_shader_bsdf_principled.cc | 64 ++++++++++--------- .../node_shader_subsurface_scattering.cc | 4 ++ 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc index 856685d8407..4ce5938f5ff 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc @@ -376,35 +376,41 @@ NODE_SHADER_MATERIALX_BEGIN /* NOTE: commented inputs aren't used for node creation. */ auto bsdf_inputs = [&]() -> InputsType { - return { - {"base_color", get_input_value("Base Color", NodeItem::Type::Color3)}, - {"diffuse_roughness", get_input_value("Diffuse Roughness", NodeItem::Type::Float)}, - {"subsurface", get_input_value("Subsurface Weight", NodeItem::Type::Float)}, - {"subsurface_scale", get_input_value("Subsurface Scale", NodeItem::Type::Float)}, - {"subsurface_radius", get_input_value("Subsurface Radius", NodeItem::Type::Vector3)}, - //{"subsurface_ior", get_input_value("Subsurface IOR", NodeItem::Type::Vector3)}, - {"subsurface_anisotropy", get_input_value("Subsurface Anisotropy", NodeItem::Type::Float)}, - {"metallic", get_input_value("Metallic", NodeItem::Type::Float)}, - {"specular", get_input_value("Specular IOR Level", NodeItem::Type::Float)}, - {"specular_tint", get_input_value("Specular Tint", NodeItem::Type::Color3)}, - {"roughness", get_input_value("Roughness", NodeItem::Type::Float)}, - {"anisotropic", get_input_value("Anisotropic", NodeItem::Type::Float)}, - {"anisotropic_rotation", get_input_value("Anisotropic Rotation", NodeItem::Type::Float)}, - {"sheen", get_input_value("Sheen Weight", NodeItem::Type::Float)}, - {"sheen_roughness", get_input_value("Sheen Roughness", NodeItem::Type::Float)}, - {"sheen_tint", get_input_value("Sheen Tint", NodeItem::Type::Color3)}, - {"coat", get_input_value("Coat Weight", NodeItem::Type::Float)}, - {"coat_roughness", get_input_value("Coat Roughness", NodeItem::Type::Float)}, - {"coat_ior", get_input_value("Coat IOR", NodeItem::Type::Float)}, - {"coat_tint", get_input_value("Coat Tint", NodeItem::Type::Color3)}, - {"ior", get_input_value("IOR", NodeItem::Type::Float)}, - {"transmission", get_input_value("Transmission Weight", NodeItem::Type::Float)}, - {"thin_film_thickness", get_input_value("Thin Film Thickness", NodeItem::Type::Float)}, - {"thin_film_IOR", get_input_value("Thin Film IOR", NodeItem::Type::Float)}, - {"alpha", get_input_value("Alpha", NodeItem::Type::Float)}, - {"normal", get_input_link("Normal", NodeItem::Type::Vector3)}, - {"coat_normal", get_input_link("Coat Normal", NodeItem::Type::Vector3)}, - {"tangent", get_input_link("Tangent", NodeItem::Type::Vector3)}, + return + { + {"base_color", get_input_value("Base Color", NodeItem::Type::Color3)}, + {"diffuse_roughness", get_input_value("Diffuse Roughness", NodeItem::Type::Float)}, + {"subsurface", get_input_value("Subsurface Weight", NodeItem::Type::Float)}, + {"subsurface_scale", get_input_value("Subsurface Scale", NodeItem::Type::Float)}, +# if MATERIALX_MAJOR_VERSION <= 1 && MATERIALX_MINOR_VERSION <= 38 + {"subsurface_radius", get_input_value("Subsurface Radius", NodeItem::Type::Vector3)}, +# else + {"subsurface_radius", get_input_value("Subsurface Radius", NodeItem::Type::Color3)}, +# endif + //{"subsurface_ior", get_input_value("Subsurface IOR", NodeItem::Type::Vector3)}, + {"subsurface_anisotropy", + get_input_value("Subsurface Anisotropy", NodeItem::Type::Float)}, + {"metallic", get_input_value("Metallic", NodeItem::Type::Float)}, + {"specular", get_input_value("Specular IOR Level", NodeItem::Type::Float)}, + {"specular_tint", get_input_value("Specular Tint", NodeItem::Type::Color3)}, + {"roughness", get_input_value("Roughness", NodeItem::Type::Float)}, + {"anisotropic", get_input_value("Anisotropic", NodeItem::Type::Float)}, + {"anisotropic_rotation", get_input_value("Anisotropic Rotation", NodeItem::Type::Float)}, + {"sheen", get_input_value("Sheen Weight", NodeItem::Type::Float)}, + {"sheen_roughness", get_input_value("Sheen Roughness", NodeItem::Type::Float)}, + {"sheen_tint", get_input_value("Sheen Tint", NodeItem::Type::Color3)}, + {"coat", get_input_value("Coat Weight", NodeItem::Type::Float)}, + {"coat_roughness", get_input_value("Coat Roughness", NodeItem::Type::Float)}, + {"coat_ior", get_input_value("Coat IOR", NodeItem::Type::Float)}, + {"coat_tint", get_input_value("Coat Tint", NodeItem::Type::Color3)}, + {"ior", get_input_value("IOR", NodeItem::Type::Float)}, + {"transmission", get_input_value("Transmission Weight", NodeItem::Type::Float)}, + {"thin_film_thickness", get_input_value("Thin Film Thickness", NodeItem::Type::Float)}, + {"thin_film_IOR", get_input_value("Thin Film IOR", NodeItem::Type::Float)}, + {"alpha", get_input_value("Alpha", NodeItem::Type::Float)}, + {"normal", get_input_link("Normal", NodeItem::Type::Vector3)}, + {"coat_normal", get_input_link("Coat Normal", NodeItem::Type::Vector3)}, + {"tangent", get_input_link("Tangent", NodeItem::Type::Vector3)}, }; }; diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc index ae1dbef3d92..a6519cc623a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc @@ -89,7 +89,11 @@ NODE_SHADER_MATERIALX_BEGIN NodeItem color = get_input_value("Color", NodeItem::Type::Color3); NodeItem scale = get_input_value("Scale", NodeItem::Type::Float); +# if MATERIALX_MAJOR_VERSION <= 1 && MATERIALX_MINOR_VERSION <= 38 NodeItem radius = get_input_value("Radius", NodeItem::Type::Vector3); +# else + NodeItem radius = get_input_value("Radius", NodeItem::Type::Color3); +# endif NodeItem anisotropy = get_input_value("Anisotropy", NodeItem::Type::Float); NodeItem normal = get_input_link("Normal", NodeItem::Type::Vector3); From 78c6037741fc8d16d33f27da9576019b0c5a55ac Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 6 Feb 2025 14:39:15 +0100 Subject: [PATCH 16/28] Vulkan: Render and compositor tests This PR does some changes to the render and compositor tests - Compositor test will now test all GPU backends that are compiled - EEVEE/Workbench render tests will move the GPU backend to the front of the test name (eevee_next_opengl_bsdf) - Blacklist EEVEE render tests that fail on Vulkan. Pull Request: https://projects.blender.org/blender/blender/pulls/133981 --- tests/python/CMakeLists.txt | 69 +++++++++++++++++-------- tests/python/compositor_render_tests.py | 18 +++++-- tests/python/eevee_next_render_tests.py | 9 ++++ 3 files changed, 70 insertions(+), 26 deletions(-) diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 8fdc5a729c2..5286da585a2 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -677,10 +677,10 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS) if(WITH_OPENGL_BACKEND) foreach(render_test ${gpu_render_tests}) add_render_test( - eevee_next_${render_test}_opengl + eevee_next_opengl_${render_test} ${CMAKE_CURRENT_LIST_DIR}/eevee_next_render_tests.py --testdir "${TEST_SRC_DIR}/render/${render_test}" - --outdir "${TEST_OUT_DIR}/eevee_next" + --outdir "${TEST_OUT_DIR}/eevee_next_opengl" --gpu-backend opengl ${_gpu_render_tests_arguments} ) @@ -690,10 +690,10 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS) if(WITH_METAL_BACKEND) foreach(render_test ${gpu_render_tests}) add_render_test( - eevee_next_${render_test}_metal + eevee_next_metal_${render_test} ${CMAKE_CURRENT_LIST_DIR}/eevee_next_render_tests.py --testdir "${TEST_SRC_DIR}/render/${render_test}" - --outdir "${TEST_OUT_DIR}/eevee_next" + --outdir "${TEST_OUT_DIR}/eevee_next_metal" --gpu-backend metal ${_gpu_render_tests_arguments} ) @@ -703,10 +703,10 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS) if(WITH_VULKAN_BACKEND AND WITH_GPU_RENDER_TESTS_VULKAN) foreach(render_test ${gpu_render_tests}) add_render_test( - eevee_next_${render_test}_vulkan + eevee_next_vulkan_${render_test} ${CMAKE_CURRENT_LIST_DIR}/eevee_next_render_tests.py --testdir "${TEST_SRC_DIR}/render/${render_test}" - --outdir "${TEST_OUT_DIR}/eevee_next" + --outdir "${TEST_OUT_DIR}/eevee_next_vulkan" --gpu-backend vulkan ${_gpu_render_tests_arguments} ) @@ -717,10 +717,10 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS) if(WITH_OPENGL_BACKEND) foreach(render_test ${gpu_render_tests}) add_render_test( - workbench_${render_test}_opengl + workbench_opengl_${render_test} ${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py --testdir "${TEST_SRC_DIR}/render/${render_test}" - --outdir "${TEST_OUT_DIR}/workbench" + --outdir "${TEST_OUT_DIR}/workbench_opengl" --gpu-backend opengl ${_gpu_render_tests_arguments} ) @@ -730,10 +730,10 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS) if(WITH_METAL_BACKEND) foreach(render_test ${gpu_render_tests}) add_render_test( - workbench_${render_test}_metal + workbench_metal_${render_test} ${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py --testdir "${TEST_SRC_DIR}/render/${render_test}" - --outdir "${TEST_OUT_DIR}/workbench" + --outdir "${TEST_OUT_DIR}/workbench_metal" --gpu-backend metal ${_gpu_render_tests_arguments} ) @@ -743,10 +743,10 @@ if(WITH_CYCLES OR WITH_GPU_RENDER_TESTS) if(WITH_VULKAN_BACKEND AND WITH_GPU_RENDER_TESTS_VULKAN) foreach(render_test ${gpu_render_tests}) add_render_test( - workbench_${render_test}_vulkan + workbench_vulkan_${render_test} ${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py --testdir "${TEST_SRC_DIR}/render/${render_test}" - --outdir "${TEST_OUT_DIR}/workbench" + --outdir "${TEST_OUT_DIR}/workbench/vulkan" --gpu-backend vulkan ${_gpu_render_tests_arguments} ) @@ -830,15 +830,42 @@ if(WITH_GPU_COMPOSITOR_TESTS) list(APPEND compositor_tests distort matte) endif() - foreach(comp_test ${compositor_tests}) - add_render_test( - compositor_gpu_${comp_test} - ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py - --testdir "${TEST_SRC_DIR}/compositor/${comp_test}" - --outdir "${TEST_OUT_DIR}/compositor_gpu" - --gpu - ) - endforeach() + if(WITH_OPENGL_BACKEND) + foreach(comp_test ${compositor_tests}) + add_render_test( + compositor_opengl_${comp_test} + ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py + --testdir "${TEST_SRC_DIR}/compositor/${comp_test}" + --outdir "${TEST_OUT_DIR}/compositor_opengl" + --gpu + --gpu-backend opengl + ) + endforeach() + endif() + if(WITH_METAL_BACKEND) + foreach(comp_test ${compositor_tests}) + add_render_test( + compositor_metal_${comp_test} + ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py + --testdir "${TEST_SRC_DIR}/compositor/${comp_test}" + --outdir "${TEST_OUT_DIR}/compositor_metal" + --gpu + --gpu-backend metal + ) + endforeach() + endif() + if(WITH_VULKAN_BACKEND) + foreach(comp_test ${compositor_tests}) + add_render_test( + compositor_vulkan_${comp_test} + ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py + --testdir "${TEST_SRC_DIR}/compositor/${comp_test}" + --outdir "${TEST_OUT_DIR}/compositor_vulkan" + --gpu + --gpu-backend vulkan + ) + endforeach() + endif() endif() endif() diff --git a/tests/python/compositor_render_tests.py b/tests/python/compositor_render_tests.py index bff31b739c4..8fde6f969ff 100644 --- a/tests/python/compositor_render_tests.py +++ b/tests/python/compositor_render_tests.py @@ -21,18 +21,25 @@ def get_compositor_device_setter_script(execution_device): def get_arguments(filepath, output_filepath, execution_device): - return [ + arguments = [ "--background", "--factory-startup", "--enable-autoexec", "--debug-memory", - "--debug-exit-on-error", + "--debug-exit-on-error"] + + if execution_device != 'CPU': + arguments.extend(["--gpu-backend", execution_device]) + + arguments.extend([ filepath, "-P", os.path.realpath(__file__), - "--python-expr", get_compositor_device_setter_script(execution_device), + "--python-expr", get_compositor_device_setter_script( + execution_device if execution_device == 'CPU' else 'GPU'), "-o", output_filepath, "-F", "PNG", - "-f", "1"] + "-f", "1"]) + return arguments def create_argparse(): @@ -45,6 +52,7 @@ def create_argparse(): parser.add_argument("--oiiotool", required=True) parser.add_argument("--gpu", default=False, action='store_true') parser.add_argument('--batch', default=False, action='store_true') + parser.add_argument('--gpu-backend') return parser @@ -53,7 +61,7 @@ def main(): args = parser.parse_args() from modules import render_report - execution_device = "GPU" if args.gpu else "CPU" + execution_device = args.gpu_backend if args.gpu else "CPU" report_title = f"Compositor {execution_device}" report = render_report.Report(report_title, args.outdir, args.oiiotool) report.set_pixelated(True) diff --git a/tests/python/eevee_next_render_tests.py b/tests/python/eevee_next_render_tests.py index 667a69e14e8..21ca7b3c5f4 100644 --- a/tests/python/eevee_next_render_tests.py +++ b/tests/python/eevee_next_render_tests.py @@ -52,6 +52,13 @@ def _get_render_arguments(self, arguments_cb, filepath, base_output_filepath): "principled_bsdf_interior.blend", ] +BLOCKLIST_VULKAN = [ + # Blocked due to difference in screen space tracing (to be fixed). + "sss_reflection_clamp.blend", + # Blocked due to difference in screen space tracing (to be investigated). + "image.blend" +] + def setup(): import bpy @@ -228,6 +235,8 @@ def main(): blocklist = BLOCKLIST if args.gpu_backend == "metal": blocklist += BLOCKLIST_METAL + elif args.gpu_backend == "vulkan": + blocklist += BLOCKLIST_VULKAN report = EEVEEReport("Eevee Next", args.outdir, args.oiiotool, variation=args.gpu_backend, blocklist=blocklist) if args.gpu_backend == "vulkan": From 1540817576a402db850162f040e1bf066b9eddfe Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Thu, 6 Feb 2025 14:53:16 +0100 Subject: [PATCH 17/28] For VFX platform 2025 and more. Boost (removed!) Cython 3.0.11 Expat 2.6.4 GMP 6.3.0 MaterialX 1.39.2 Nanobind 2.1.0 (new, for OpenVDB) NumPy 1.26.4 OpenColorIO 2.4.1 OpenEXR 3.3.2 OpenImageIO 3.0.3.1 OpenVDB 12.0.0 OSL 1.14.3-beta Python 3.11.11 Robinmap 1.3.0 TBB 2021.13.0 TIFF 4.7.0 USD 25.02 libxml2 2.13.5 zlib 1.3.1 Co-authored-by: Brecht Van Lommel Co-authored-by: Jonas Holzman Co-authored-by: Sebastian Parborg Ref #128577 Pull Request: https://projects.blender.org/blender/blender/pulls/134178 --- build_files/build_environment/CMakeLists.txt | 5 +- .../build_environment/cmake/boost.cmake | 123 ---- .../cmake/boost_build_options.cmake | 36 - .../build_environment/cmake/cve_check.csv.in | 4 + .../build_environment/cmake/download.cmake | 2 +- .../build_environment/cmake/dpcpp.cmake | 1 + .../cmake/embree_windows_arm.cmake | 4 +- .../build_environment/cmake/nanobind.cmake | 35 + .../build_environment/cmake/numpy.cmake | 1 + .../build_environment/cmake/opencolorio.cmake | 8 +- .../build_environment/cmake/openimageio.cmake | 26 +- .../cmake/openpgl_windows_arm.cmake | 4 +- .../build_environment/cmake/openvdb.cmake | 31 +- .../build_environment/cmake/options.cmake | 8 +- build_files/build_environment/cmake/osl.cmake | 17 +- .../build_environment/cmake/python.cmake | 6 +- .../build_environment/cmake/sndfile.cmake | 5 + build_files/build_environment/cmake/tbb.cmake | 101 +-- .../build_environment/cmake/tiff.cmake | 2 +- build_files/build_environment/cmake/usd.cmake | 30 +- .../build_environment/cmake/versions.cmake | 114 ++-- .../build_environment/dependencies.dot | 6 - .../build_environment/patches/boost.diff | 28 - .../build_environment/patches/gmp.diff | 22 +- .../build_environment/patches/oiio_4062.diff | 28 - .../build_environment/patches/oiio_4302.diff | 174 ----- .../build_environment/patches/oiio_webp.diff | 78 --- .../patches/openimageio.diff | 8 +- .../build_environment/patches/openvdb.diff | 46 +- .../patches/openvdb_1706.diff | 81 --- .../patches/openvdb_1733.diff | 21 - .../patches/openvdb_1977.diff | 44 ++ .../patches/sndfile_1045.diff | 395 +++++++++++ .../build_environment/patches/tbb.diff | 637 ------------------ .../build_environment/patches/tbb_1478.diff | 9 +- .../build_environment/patches/usd_3243.diff | 70 ++ .../build_environment/patches/usd_3519.diff | 70 ++ .../patches/usd_forward_compat.diff | 14 + .../patches/usd_metal_edf.diff | 46 -- .../patches/usd_noboost.diff | 11 + .../build_environment/windows/build_deps.cmd | 6 +- .../cmake/platform/platform_apple.cmake | 11 + .../cmake/platform/platform_unix.cmake | 12 + .../cmake/platform/platform_win32.cmake | 67 +- source/creator/CMakeLists.txt | 146 ++-- tests/blender_as_python_module/import_bpy.py | 8 +- tests/python/bl_bundled_modules.py | 8 +- tests/python/cycles_render_tests.py | 2 + 48 files changed, 1013 insertions(+), 1598 deletions(-) delete mode 100644 build_files/build_environment/cmake/boost.cmake delete mode 100644 build_files/build_environment/cmake/boost_build_options.cmake create mode 100644 build_files/build_environment/cmake/nanobind.cmake delete mode 100644 build_files/build_environment/patches/boost.diff delete mode 100644 build_files/build_environment/patches/oiio_4062.diff delete mode 100644 build_files/build_environment/patches/oiio_4302.diff delete mode 100644 build_files/build_environment/patches/oiio_webp.diff delete mode 100644 build_files/build_environment/patches/openvdb_1706.diff delete mode 100644 build_files/build_environment/patches/openvdb_1733.diff create mode 100644 build_files/build_environment/patches/openvdb_1977.diff create mode 100644 build_files/build_environment/patches/sndfile_1045.diff delete mode 100644 build_files/build_environment/patches/tbb.diff create mode 100644 build_files/build_environment/patches/usd_3243.diff create mode 100644 build_files/build_environment/patches/usd_3519.diff create mode 100644 build_files/build_environment/patches/usd_forward_compat.diff delete mode 100644 build_files/build_environment/patches/usd_metal_edf.diff create mode 100644 build_files/build_environment/patches/usd_noboost.diff diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt index ef6672f8683..4603e9d49a6 100644 --- a/build_files/build_environment/CMakeLists.txt +++ b/build_files/build_environment/CMakeLists.txt @@ -28,7 +28,6 @@ include(cmake/options.cmake) # `versions.cmake` needs to be included after `options.cmake` # due to the `BLENDER_PLATFORM_ARM` variable being needed. include(cmake/versions.cmake) -include(cmake/boost_build_options.cmake) include(cmake/download.cmake) include(cmake/macros.cmake) # `setup_msys2.cmake` to install `perl`, @@ -85,8 +84,6 @@ include(cmake/materialx.cmake) include(cmake/openvdb.cmake) include(cmake/potrace.cmake) include(cmake/haru.cmake) -# Boost needs to be included after `python.cmake` due to the PYTHON_BINARY variable being needed. -include(cmake/boost.cmake) include(cmake/pugixml.cmake) include(cmake/fribidi.cmake) include(cmake/harfbuzz.cmake) @@ -187,5 +184,7 @@ include(cmake/shaderc_deps.cmake) include(cmake/shaderc.cmake) include(cmake/vulkan.cmake) include(cmake/pybind11.cmake) +include(cmake/nanobind.cmake) +# Keep these last include(cmake/deps_html.cmake) include(cmake/cve_check.cmake) diff --git a/build_files/build_environment/cmake/boost.cmake b/build_files/build_environment/cmake/boost.cmake deleted file mode 100644 index 0dbe5726b36..00000000000 --- a/build_files/build_environment/cmake/boost.cmake +++ /dev/null @@ -1,123 +0,0 @@ -# SPDX-FileCopyrightText: 2017-2022 Blender Authors -# -# SPDX-License-Identifier: GPL-2.0-or-later - -if(WIN32) - set(BOOST_CONFIGURE_COMMAND bootstrap.bat) - set(BOOST_BUILD_COMMAND b2) - set(BOOST_BUILD_OPTIONS runtime-link=shared) - if(BUILD_MODE STREQUAL Debug) - list(APPEND BOOST_BUILD_OPTIONS python-debugging=on variant=debug) - if(WITH_OPTIMIZED_DEBUG) - list(APPEND BOOST_BUILD_OPTIONS debug-symbols=off) - else() - list(APPEND BOOST_BUILD_OPTIONS debug-symbols=on) - endif() - else() - list(APPEND BOOST_BUILD_OPTIONS variant=release) - endif() - set(BOOST_HARVEST_CMD - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/boost/lib/ - ${HARVEST_TARGET}/boost/lib/ - ) - if(BUILD_MODE STREQUAL Release) - set(BOOST_HARVEST_CMD - ${BOOST_HARVEST_CMD} && - ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/boost/include/boost-${BOOST_VERSION_NODOTS_SHORT}/ - ${HARVEST_TARGET}/boost/include/ - ) - endif() -elseif(APPLE) - set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh) - set(BOOST_BUILD_COMMAND ./b2) - set(BOOST_BUILD_OPTIONS - toolset=clang-darwin - cxxflags=${PLATFORM_CXXFLAGS} - linkflags=${PLATFORM_LDFLAGS} - visibility=global - --disable-icu boost.locale.icu=off - ) - set(BOOST_HARVEST_CMD echo .) -else() - set(BOOST_HARVEST_CMD echo .) - set(BOOST_CONFIGURE_COMMAND ./bootstrap.sh) - set(BOOST_BUILD_COMMAND ./b2) - set(BOOST_BUILD_OPTIONS cxxflags=${PLATFORM_CXXFLAGS} --disable-icu boost.locale.icu=off) -endif() - -set(JAM_FILE ${BUILD_DIR}/boost.user-config.jam) -configure_file(${PATCH_DIR}/boost.user.jam.in ${JAM_FILE}) -set(BOOST_PYTHON_OPTIONS - --with-python - --user-config=${JAM_FILE} -) -if(WIN32 AND BUILD_MODE STREQUAL Debug) - set(BOOST_PYTHON_OPTIONS - ${BOOST_PYTHON_OPTIONS} - define=BOOST_DEBUG_PYTHON - ) -endif() - -set(BOOST_OPTIONS - --with-filesystem - --with-locale - --with-thread - --with-regex - --with-system - --with-date_time - --with-wave - --with-atomic - --with-serialization - --with-program_options - --with-iostreams - -sNO_BZIP2=1 - -sNO_LZMA=1 - -sNO_ZSTD=1 - ${BOOST_TOOLSET} - ${BOOST_PYTHON_OPTIONS} -) - -string(TOLOWER ${BUILD_MODE} BOOST_BUILD_TYPE) - -ExternalProject_Add(external_boost - URL file://${PACKAGE_DIR}/${BOOST_FILE} - DOWNLOAD_DIR ${DOWNLOAD_DIR} - URL_HASH ${BOOST_HASH_TYPE}=${BOOST_HASH} - PREFIX ${BUILD_DIR}/boost - UPDATE_COMMAND "" - - PATCH_COMMAND ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/boost/src/external_boost < - ${PATCH_DIR}/boost.diff - - CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND} - - BUILD_COMMAND - ${BOOST_BUILD_COMMAND} - ${BOOST_BUILD_OPTIONS} - -j${MAKE_THREADS} - architecture=${BOOST_ARCHITECTURE} - address-model=${BOOST_ADDRESS_MODEL} - link=shared - threading=multi - ${BOOST_OPTIONS} - --prefix=${LIBDIR}/boost - install - - BUILD_IN_SOURCE 1 - INSTALL_COMMAND "${BOOST_HARVEST_CMD}" -) - -add_dependencies( - external_boost - external_python - external_numpy - external_zlib -) - -if(NOT WIN32) - harvest(external_boost boost/include boost/include "*") - harvest_rpath_lib(external_boost boost/lib boost/lib "*${SHAREDLIBEXT}*") -endif() diff --git a/build_files/build_environment/cmake/boost_build_options.cmake b/build_files/build_environment/cmake/boost_build_options.cmake deleted file mode 100644 index b4fe14b9b97..00000000000 --- a/build_files/build_environment/cmake/boost_build_options.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Blender Authors -# -# SPDX-License-Identifier: GPL-2.0-or-later - -set(BOOST_ADDRESS_MODEL 64) -if(BLENDER_PLATFORM_ARM) - set(BOOST_ARCHITECTURE arm) -else() - set(BOOST_ARCHITECTURE x86) -endif() - -if(WIN32) - if(MSVC_TOOLSET_VERSION GREATER_EQUAL 143) # 2022 - set(BOOST_TOOLSET toolset=msvc-14.3) - set(BOOST_COMPILER_STRING -vc143) - elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 142) # 2019 - set(BOOST_TOOLSET toolset=msvc-14.2) - set(BOOST_COMPILER_STRING -vc142) - else() # 2017 - set(BOOST_TOOLSET toolset=msvc-14.1) - set(BOOST_COMPILER_STRING -vc141) - endif() -endif() - -set(DEFAULT_BOOST_FLAGS - -DBoost_COMPILER:STRING=${BOOST_COMPILER_STRING} - -DBoost_USE_MULTITHREADED=ON - -DBoost_USE_STATIC_LIBS=OFF - -DBoost_USE_STATIC_RUNTIME=OFF - -DBOOST_ROOT=${LIBDIR}/boost - -DBoost_NO_SYSTEM_PATHS=ON - -DBoost_NO_BOOST_CMAKE=ON - -DBoost_ADDITIONAL_VERSIONS=${BOOST_VERSION_SHORT} - -DBOOST_LIBRARYDIR=${LIBDIR}/boost/lib/ - -DBoost_USE_DEBUG_PYTHON=On -) diff --git a/build_files/build_environment/cmake/cve_check.csv.in b/build_files/build_environment/cmake/cve_check.csv.in index d0e850765ad..7d4096c793f 100644 --- a/build_files/build_environment/cmake/cve_check.csv.in +++ b/build_files/build_environment/cmake/cve_check.csv.in @@ -6,6 +6,8 @@ vendor,product,version,cve_number,remarks,comment @PYTHON_ID@,CVE-2009-3720,NotAffected,already fixed in libexpat version used @PYTHON_ID@,CVE-2023-36632,NotAffected,not used in blender and not considered a bug upstream @PYTHON_ID@,CVE-2023-27043,NotAffected,not used in blender +@PYTHON_ID@,CVE-2024-6232,FalsePositive,fixed in 3.11.10 upstream fix gh-121285 +@PYTHON_ID@,CVE-2024-7592,FalsePositive,fixed in 3.11.10 upstream fix gh-123067 @PYTHON_PIP_ID@,CVE-2018-20225,NotAffected,not a blender specific issue and pip is inherently affected by malicious packages @SSL_ID@,CVE-2009-1390,NotAffected,issue in mutt not used by blender @SSL_ID@,CVE-2009-3765,NotAffected,issue in mutt not used by blender @@ -36,4 +38,6 @@ vendor,product,version,cve_number,remarks,comment @SQLITE_ID@,CVE-2023-7104,NotAffected,does not affect blender use of sqlite @SQLITE_ID@,CVE-2024-0232,NotAffected,does not affect blender use of sqlite @ZLIB_ID@,CVE-2023-45853,NotAffected,only affects minizip not used by blender +@SNDFILE_ID@,CVE-2024-50612,Mitigated,patched using upstream PR 1045 +@SNDFILE_ID@,CVE-2024-50613,NotAffected,all mp3 handling in blender goes through ffmpeg @SBOMCONTENTS@ diff --git a/build_files/build_environment/cmake/download.cmake b/build_files/build_environment/cmake/download.cmake index 2b106f7d7de..b13187654eb 100644 --- a/build_files/build_environment/cmake/download.cmake +++ b/build_files/build_environment/cmake/download.cmake @@ -78,7 +78,6 @@ download_source(ZLIB) download_source(OPENAL) download_source(PNG) download_source(JPEG) -download_source(BOOST) download_source(BLOSC) download_source(PTHREADS) download_source(OPENEXR) @@ -181,3 +180,4 @@ download_source(VULKAN_LOADER) download_source(PYBIND11) download_source(DEFLATE) download_source(HIPRT) +download_source(NANOBIND) diff --git a/build_files/build_environment/cmake/dpcpp.cmake b/build_files/build_environment/cmake/dpcpp.cmake index a555c092d4d..d42f49fb218 100644 --- a/build_files/build_environment/cmake/dpcpp.cmake +++ b/build_files/build_environment/cmake/dpcpp.cmake @@ -141,6 +141,7 @@ add_dependencies( external_spirvheaders external_unifiedruntime external_unifiedmemoryframework + external_zstd ) if(WIN32) diff --git a/build_files/build_environment/cmake/embree_windows_arm.cmake b/build_files/build_environment/cmake/embree_windows_arm.cmake index c3b54ba1c5d..38ef7aed78f 100644 --- a/build_files/build_environment/cmake/embree_windows_arm.cmake +++ b/build_files/build_environment/cmake/embree_windows_arm.cmake @@ -65,8 +65,8 @@ list(GET EMBREE_INSTALLED_VCTOOLS -1 EMBREE_VCTOOLS_VERSION) # Configure our in file and temporarily store it in the build dir # (with modified extension so nothing else picks it up) -# This feels icky, but boost does something similar, and we haven't called -# `ExternalProject_Add` yet, so the embree dir does not yet exist. +# This feels icky, but we haven't called `ExternalProject_Add` yet, +# so the embree dir does not yet exist. configure_file( ${PATCH_DIR}/embree_Directory.Build.Props.in ${BUILD_DIR}/embree_Directory.Build.Props_temp diff --git a/build_files/build_environment/cmake/nanobind.cmake b/build_files/build_environment/cmake/nanobind.cmake new file mode 100644 index 00000000000..51b9ac2f8af --- /dev/null +++ b/build_files/build_environment/cmake/nanobind.cmake @@ -0,0 +1,35 @@ +# SPDX-FileCopyrightText: 2024 Blender Authors +# +# SPDX-License-Identifier: GPL-2.0-or-later + +set(NANOBIND_EXTRA_ARGS + -DNB_TEST=OFF + -DPython_EXECUTABLE=${PYTHON_BINARY} +) + +set(NANOBIND_PATCH + ${CMAKE_COMMAND} -E copy_directory + ${LIBDIR}/robinmap/include/ + ${BUILD_DIR}/nanobind/src/external_nanobind/ext/robin_map/include/ +) + +ExternalProject_Add(external_nanobind + URL file://${PACKAGE_DIR}/${NANOBIND_FILE} + DOWNLOAD_DIR ${DOWNLOAD_DIR} + URL_HASH ${NANOBIND_HASH_TYPE}=${NANOBIND_HASH} + PREFIX ${BUILD_DIR}/nanobind + CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} + + PATCH_COMMAND ${NANOBIND_PATCH} + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${LIBDIR}/nanobind + ${DEFAULT_CMAKE_FLAGS} + ${NANOBIND_EXTRA_ARGS} + + INSTALL_DIR ${LIBDIR}/nanobind +) + +add_dependencies( + external_nanobind + external_robinmap +) diff --git a/build_files/build_environment/cmake/numpy.cmake b/build_files/build_environment/cmake/numpy.cmake index 11f11de8470..58cfce6f461 100644 --- a/build_files/build_environment/cmake/numpy.cmake +++ b/build_files/build_environment/cmake/numpy.cmake @@ -25,6 +25,7 @@ ExternalProject_Add(external_numpy PATCH_COMMAND ${NUMPY_PATCH} CONFIGURE_COMMAND "" LOG_BUILD 1 + BUILD_IN_SOURCE 1 BUILD_COMMAND ${PYTHON_BINARY} ${BUILD_DIR}/numpy/src/external_numpy/setup.py diff --git a/build_files/build_environment/cmake/opencolorio.cmake b/build_files/build_environment/cmake/opencolorio.cmake index bfee9e80542..649d713e316 100644 --- a/build_files/build_environment/cmake/opencolorio.cmake +++ b/build_files/build_environment/cmake/opencolorio.cmake @@ -96,8 +96,8 @@ if(WIN32) ${LIBDIR}/opencolorio/include ${HARVEST_TARGET}/opencolorio/include COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/opencolorio/bin/OpenColorIO_2_3.dll - ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_2_3.dll + ${LIBDIR}/opencolorio/bin/OpenColorIO_2_4.dll + ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_2_4.dll COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBDIR}/opencolorio/lib ${HARVEST_TARGET}/opencolorio/lib @@ -108,8 +108,8 @@ if(WIN32) if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_opencolorio after_install COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/opencolorio/bin/OpenColorIO_d_2_3.dll - ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_d_2_3.dll + ${LIBDIR}/opencolorio/bin/OpenColorIO_d_2_4.dll + ${HARVEST_TARGET}/opencolorio/bin/OpenColorIO_d_2_4.dll COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/opencolorio/lib/Opencolorio_d.lib ${HARVEST_TARGET}/opencolorio/lib/OpenColorIO_d.lib diff --git a/build_files/build_environment/cmake/openimageio.cmake b/build_files/build_environment/cmake/openimageio.cmake index 4774022b4c0..0dcebf720e3 100644 --- a/build_files/build_environment/cmake/openimageio.cmake +++ b/build_files/build_environment/cmake/openimageio.cmake @@ -50,17 +50,12 @@ endif() set(OPENIMAGEIO_EXTRA_ARGS -DBUILD_SHARED_LIBS=ON ${OPENIMAGEIO_LINKSTATIC} - ${DEFAULT_BOOST_FLAGS} - -DREQUIRED_DEPS=WebP$JPEGTurbo$TIFF$OpenEXR$PNG$OpenJPEG$fmt$Robinmap$ZLIB$pugixml$Python - -DUSE_LIBSQUISH=OFF - -DUSE_QT5=OFF + -DOpenImageIO_REQUIRED_DEPS=WebP$JPEGTurbo$TIFF$OpenEXR$PNG$OpenJPEG$fmt$Robinmap$ZLIB$pugixml$Python -DUSE_NUKE=OFF -DUSE_OPENVDB=OFF - -DUSE_BZIP2=OFF -DUSE_FREETYPE=OFF -DUSE_DCMTK=OFF -DUSE_LIBHEIF=OFF - -DUSE_OPENGL=OFF -DUSE_TBB=ON -DUSE_QT=OFF -DUSE_PYTHON=ON @@ -71,7 +66,8 @@ set(OPENIMAGEIO_EXTRA_ARGS -DUSE_PTEX=OFF -DUSE_FREETYPE=OFF -DUSE_LIBRAW=OFF - -DUSE_OPENCOLORIO=OFF + -DUSE_JXL=OFF + -DUSE_OPENCOLORIO=ON -DUSE_WEBP=ON -DOIIO_BUILD_TOOLS=${OIIO_TOOLS} -DOIIO_BUILD_TESTS=OFF @@ -93,8 +89,8 @@ set(OPENIMAGEIO_EXTRA_ARGS -DPUGIXML_LIBRARY=${LIBDIR}/pugixml/lib/${LIBPREFIX}pugixml${LIBEXT} -DPUGIXML_INCLUDE_DIR=${LIBDIR}/pugixml/include/ -Dpugixml_DIR=${LIBDIR}/pugixml/lib/cmake/pugixml - -DBUILD_MISSING_ROBINMAP=OFF - -DBUILD_MISSING_FMT=OFF + -DOpenColorIO_DIR=${LIBDIR}/opencolorio/lib/cmake/OpenColorIO + -DOpenImageIO_BUILD_MISSING_DEPS="" -DFMT_INCLUDE_DIR=${LIBDIR}/fmt/include/ -DRobinmap_ROOT=${LIBDIR}/robinmap -DWebP_ROOT=${LIBDIR}/webp @@ -103,6 +99,7 @@ set(OPENIMAGEIO_EXTRA_ARGS -DImath_ROOT=${LIBDIR}/imath -Dpybind11_ROOT=${LIBDIR}/pybind11 -DPython_EXECUTABLE=${PYTHON_BINARY} + -DPython3_EXECUTABLE=${PYTHON_BINARY} -DTBB_ROOT=${LIBDIR}/tbb -Dlibdeflate_ROOT=${LIBDIR}/deflate -Dfmt_ROOT=${LIBDIR}/fmt @@ -134,15 +131,6 @@ ExternalProject_Add(external_openimageio ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio.diff && - ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/openimageio/src/external_openimageio/ < - ${PATCH_DIR}/oiio_webp.diff && - ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/openimageio/src/external_openimageio/ < - ${PATCH_DIR}/oiio_4062.diff && - ${PATCH_CMD} -p 1 -N -d - ${BUILD_DIR}/openimageio/src/external_openimageio/ < - ${PATCH_DIR}/oiio_4302.diff && ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_windows_arm64.diff @@ -156,12 +144,12 @@ ExternalProject_Add(external_openimageio add_dependencies( external_openimageio + external_opencolorio external_png external_zlib external_openexr external_imath external_jpeg - external_boost external_tiff external_pugixml external_fmt diff --git a/build_files/build_environment/cmake/openpgl_windows_arm.cmake b/build_files/build_environment/cmake/openpgl_windows_arm.cmake index 19cc581e626..eb9367aa1c2 100644 --- a/build_files/build_environment/cmake/openpgl_windows_arm.cmake +++ b/build_files/build_environment/cmake/openpgl_windows_arm.cmake @@ -50,8 +50,8 @@ list(GET OPENPGL_INSTALLED_VCTOOLS -1 OPENPGL_VCTOOLS_VERSION) # Configure our in file and temporarily store it in the build dir # (with modified extension so nothing else picks it up) -# This feels icky, but boost does something similar, and we haven't called -# `ExternalProject_Add` yet, so the OpenPGL dir does not yet exist. +# This feels icky, but we haven't called `ExternalProject_Add` yet, +# so the OpenPGL dir does not yet exist. configure_file( ${PATCH_DIR}/openpgl_Directory.Build.Props.in ${BUILD_DIR}/openpgl_Directory.Build.Props_temp diff --git a/build_files/build_environment/cmake/openvdb.cmake b/build_files/build_environment/cmake/openvdb.cmake index 7fa26ae7228..514121e7efe 100644 --- a/build_files/build_environment/cmake/openvdb.cmake +++ b/build_files/build_environment/cmake/openvdb.cmake @@ -7,13 +7,11 @@ if(BUILD_MODE STREQUAL Debug) endif() set(OPENVDB_EXTRA_ARGS - ${DEFAULT_BOOST_FLAGS} -DUSE_STATIC_DEPENDENCIES=OFF # This is the global toggle for static libs # Once the above switch is off, you can set it # for each individual library below. -DBLOSC_USE_STATIC_LIBS=ON -DTBB_USE_STATIC_LIBS=OFF - -DBoost_USE_STATIC_LIBS=OFF -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} -DZLIB_INCLUDE_DIR=${LIBDIR}/zlib/include/ -DBlosc_INCLUDE_DIR=${LIBDIR}/blosc/include/ @@ -25,8 +23,6 @@ set(OPENVDB_EXTRA_ARGS -DNANOVDB_BUILD_TOOLS=OFF -DBlosc_ROOT=${LIBDIR}/blosc/ -DTBB_ROOT=${LIBDIR}/tbb/ - -DTbb_INCLUDE_DIR=${LIBDIR}/tbb/include - -DTbb_LEGACY_INCLUDE_DIR=${LIBDIR}/tbb/include -DOPENVDB_CORE_SHARED=ON -DOPENVDB_CORE_STATIC=OFF -DOPENVDB_BUILD_BINARIES=OFF @@ -37,7 +33,11 @@ set(OPENVDB_EXTRA_ARGS -DOPENVDB_PYTHON_WRAP_ALL_GRID_TYPES=ON -DUSE_NUMPY=ON -DPython_EXECUTABLE=${PYTHON_BINARY} - -Dpybind11_DIR=${LIBDIR}/pybind11/share/cmake/pybind11 + -Dnanobind_DIR=${LIBDIR}/nanobind/nanobind/cmake/ + # Needed to still build with VS2019 + -DDISABLE_DEPENDENCY_VERSION_CHECKS=ON + # Not used by Blender (see e4f9c50), and removes the Boost dependency. + -DOPENVDB_USE_DELAYED_LOADING=OFF # OPENVDB_AX Disabled for now as it adds ~25MB distribution wise # with no blender code depending on it, seems wasteful. @@ -53,10 +53,7 @@ set(OPENVDB_PATCH ${PATCH_DIR}/openvdb.diff && ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/openvdb/src/openvdb < - ${PATCH_DIR}/openvdb_1706.diff && - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/openvdb/src/openvdb < - ${PATCH_DIR}/openvdb_1733.diff + ${PATCH_DIR}/openvdb_1977.diff ) ExternalProject_Add(openvdb @@ -78,12 +75,11 @@ ExternalProject_Add(openvdb add_dependencies( openvdb external_tbb - external_boost external_zlib external_blosc external_python external_numpy - external_pybind11 + external_nanobind ) if(WIN32) @@ -104,9 +100,8 @@ if(WIN32) ${LIBDIR}/openvdb/bin/openvdb.dll ${HARVEST_TARGET}/openvdb/bin/openvdb.dll COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_${OPENVDB_ARCH}.pyd - ${HARVEST_TARGET}openvdb/python/pyopenvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_${OPENVDB_ARCH}.pyd - + ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/openvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_${OPENVDB_ARCH}.pyd + ${HARVEST_TARGET}openvdb/python/openvdb.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_${OPENVDB_ARCH}.pyd DEPENDEES install ) endif() @@ -119,8 +114,8 @@ if(WIN32) ${LIBDIR}/openvdb/bin/openvdb_d.dll ${HARVEST_TARGET}/openvdb/bin/openvdb_d.dll COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/pyopenvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_${OPENVDB_ARCH}.pyd - ${HARVEST_TARGET}openvdb/python/pyopenvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_${OPENVDB_ARCH}.pyd + ${LIBDIR}/openvdb/lib/python${PYTHON_SHORT_VERSION}/site-packages/openvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_${OPENVDB_ARCH}.pyd + ${HARVEST_TARGET}openvdb/python/openvdb_d.cp${PYTHON_SHORT_VERSION_NO_DOTS}-win_${OPENVDB_ARCH}.pyd DEPENDEES install ) @@ -128,11 +123,11 @@ if(WIN32) else() harvest(openvdb openvdb/include/openvdb openvdb/include/openvdb "*.h") harvest(openvdb openvdb/include/nanovdb openvdb/include/nanovdb "*.h") - harvest_rpath_lib(openvdb openvdb/lib openvdb/lib "*${SHAREDLIBEXT}*") + harvest_rpath_lib(openvdb openvdb/lib openvdb/lib "lib*${SHAREDLIBEXT}*") harvest_rpath_python( openvdb openvdb/lib/python${PYTHON_SHORT_VERSION} python/lib/python${PYTHON_SHORT_VERSION} - "*pyopenvdb*" + "openvdb*" ) endif() diff --git a/build_files/build_environment/cmake/options.cmake b/build_files/build_environment/cmake/options.cmake index e2b1115dde3..0ea2298d219 100644 --- a/build_files/build_environment/cmake/options.cmake +++ b/build_files/build_environment/cmake/options.cmake @@ -74,9 +74,9 @@ if(WIN32) set(BLENDER_CMAKE_C_FLAGS_RELWITHDEBINFO "/MD ${COMMON_MSVC_FLAGS} /Zi /O2 /Ob1 /D NDEBUG /DPSAPI_VERSION=2 /DTINYFORMAT_ALLOW_WCHAR_STRINGS") if(WITH_OPTIMIZED_DEBUG) - set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MDd ${COMMON_MSVC_FLAGS} /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /O2 /Ob2 /D_DEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=2 /DTINYFORMAT_ALLOW_WCHAR_STRINGS /DBOOST_DEBUG_PYTHON /DBOOST_ALL_NO_LIB") + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/MDd ${COMMON_MSVC_FLAGS} /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /O2 /Ob2 /D_DEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=2 /DTINYFORMAT_ALLOW_WCHAR_STRINGS") else() - set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /D PLATFORM_WINDOWS /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /MTd ${COMMON_MSVC_FLAGS} /Zi /Ob0 /Od /RTC1 /DPSAPI_VERSION=2 /DTINYFORMAT_ALLOW_WCHAR_STRINGS /DBOOST_DEBUG_PYTHON /DBOOST_ALL_NO_LIB") + set(BLENDER_CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /D PLATFORM_WINDOWS /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /MTd ${COMMON_MSVC_FLAGS} /Zi /Ob0 /Od /RTC1 /DPSAPI_VERSION=2 /DTINYFORMAT_ALLOW_WCHAR_STRINGS") endif() set(BLENDER_CMAKE_CXX_FLAGS_MINSIZEREL "/MD /${COMMON_MSVC_FLAGS} /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /O1 /Ob1 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=2 /DTINYFORMAT_ALLOW_WCHAR_STRINGS") set(BLENDER_CMAKE_CXX_FLAGS_RELEASE "/MD ${COMMON_MSVC_FLAGS} /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS /O2 /Ob2 /D NDEBUG /D PLATFORM_WINDOWS /DPSAPI_VERSION=2 /DTINYFORMAT_ALLOW_WCHAR_STRINGS") @@ -95,9 +95,9 @@ if(WIN32) set(BLENDER_CLANG_CMAKE_C_FLAGS_RELWITHDEBINFO "${COMMON_CLANG_FLAGS} -Xclang --dependent-lib=msvcrt -g -O2 -DNDEBUG -DPSAPI_VERSION=2 -DTINYFORMAT_ALLOW_WCHAR_STRINGS") if(WITH_OPTIMIZED_DEBUG) - set(BLENDER_CLANG_CMAKE_CXX_FLAGS_DEBUG "${COMMON_CLANG_FLAGS} -Xclang --dependent-lib=msvcrtd -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -O2 -D_DEBUG -DPLATFORM_WINDOWS -DPSAPI_VERSION=2 -DTINYFORMAT_ALLOW_WCHAR_STRINGS -DBOOST_DEBUG_PYTHON -DBOOST_ALL_NO_LIB") + set(BLENDER_CLANG_CMAKE_CXX_FLAGS_DEBUG "${COMMON_CLANG_FLAGS} -Xclang --dependent-lib=msvcrtd -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -O2 -D_DEBUG -DPLATFORM_WINDOWS -DPSAPI_VERSION=2 -DTINYFORMAT_ALLOW_WCHAR_STRINGS") else() - set(BLENDER_CLANG_CMAKE_CXX_FLAGS_DEBUG "${COMMON_CLANG_FLAG} -Xclang --dependent-lib=msvcrtd -D_DEBUG -DPLATFORM_WINDOWS -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -g -DPSAPI_VERSION=2 -DTINYFORMAT_ALLOW_WCHAR_STRINGS -DBOOST_DEBUG_PYTHON -DBOOST_ALL_NO_LIB") + set(BLENDER_CLANG_CMAKE_CXX_FLAGS_DEBUG "${COMMON_CLANG_FLAG} -Xclang --dependent-lib=msvcrtd -D_DEBUG -DPLATFORM_WINDOWS -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -g -DPSAPI_VERSION=2 -DTINYFORMAT_ALLOW_WCHAR_STRINGS") endif() set(BLENDER_CLANG_CMAKE_CXX_FLAGS_MINSIZEREL "${COMMON_CLANG_FLAGS} -Xclang --dependent-lib=msvcrt -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -O2 -DNDEBUG -DPLATFORM_WINDOWS -DPSAPI_VERSION=2 -DTINYFORMAT_ALLOW_WCHAR_STRINGS") set(BLENDER_CLANG_CMAKE_CXX_FLAGS_RELEASE "${COMMON_CLANG_FLAGS} -Xclang --dependent-lib=msvcrt -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS -O2 -DNDEBUG -DPLATFORM_WINDOWS -DPSAPI_VERSION=2 -DTINYFORMAT_ALLOW_WCHAR_STRINGS") diff --git a/build_files/build_environment/cmake/osl.cmake b/build_files/build_environment/cmake/osl.cmake index b4d302f615a..afa6d9ef0dd 100644 --- a/build_files/build_environment/cmake/osl.cmake +++ b/build_files/build_environment/cmake/osl.cmake @@ -26,8 +26,6 @@ else() endif() set(OSL_EXTRA_ARGS - ${DEFAULT_BOOST_FLAGS} - -DOpenEXR_ROOT=${LIBDIR}/openexr/ -DOpenImageIO_ROOT=${LIBDIR}/openimageio/ -DOSL_BUILD_TESTS=OFF -DZLIB_LIBRARY=${LIBDIR}/zlib/lib/${ZLIB_LIBRARY} @@ -47,11 +45,13 @@ set(OSL_EXTRA_ARGS -DUSE_QT=OFF -DINSTALL_DOCS=OFF -Dpugixml_ROOT=${LIBDIR}/pugixml - -DUSE_PYTHON=OFF + -DUSE_PYTHON=ON -DImath_ROOT=${LIBDIR}/imath -DCMAKE_DEBUG_POSTFIX=_d + -Dpybind11_ROOT=${LIBDIR}/pybind11 -DPython_ROOT=${LIBDIR}/python -DPython_EXECUTABLE=${PYTHON_BINARY} + -DPython3_EXECUTABLE=${PYTHON_BINARY} -Dlibdeflate_DIR=${LIBDIR}/deflate/lib/cmake/libdeflate ) @@ -82,12 +82,13 @@ ExternalProject_Add(external_osl add_dependencies( external_osl - external_boost ll external_openexr external_zlib external_openimageio external_pugixml + external_python + external_pybind11 ) if(WIN32) add_dependencies( @@ -137,6 +138,9 @@ if(WIN32) COMMAND ${CMAKE_COMMAND} -E copy ${LIBDIR}/osl/bin/oslnoise_d.dll ${HARVEST_TARGET}/osl/bin/oslnoise_d.dll + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${LIBDIR}/osl/lib/python${PYTHON_SHORT_VERSION}/ + ${HARVEST_TARGET}/osl/lib/python${PYTHON_SHORT_VERSION}_debug/ DEPENDEES install ) @@ -146,4 +150,9 @@ else() harvest(external_osl osl/include osl/include "*.h") harvest_rpath_lib(external_osl osl/lib osl/lib "*${SHAREDLIBEXT}*") harvest(external_osl osl/share/OSL/shaders osl/share/OSL/shaders "*.h") + harvest_rpath_python(external_osl + osl/lib/python${PYTHON_SHORT_VERSION} + python/lib/python${PYTHON_SHORT_VERSION} + "*" + ) endif() diff --git a/build_files/build_environment/cmake/python.cmake b/build_files/build_environment/cmake/python.cmake index 1f95610917f..1fa29ce0159 100644 --- a/build_files/build_environment/cmake/python.cmake +++ b/build_files/build_environment/cmake/python.cmake @@ -48,11 +48,11 @@ if(WIN32) # the foldernames *HAVE* to match the ones inside pythons get_externals.cmd. # regardless of the version actually in there. PATCH_COMMAND mkdir ${PYTHON_EXTERNALS_FOLDER_DOS} && - mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\zlib-1.2.13 ${ZLIB_SOURCE_FOLDER_DOS} && - mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\openssl-3.0.11 ${SSL_SOURCE_FOLDER_DOS} && + mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\zlib-1.3.1 ${ZLIB_SOURCE_FOLDER_DOS} && + mklink /J ${PYTHON_EXTERNALS_FOLDER_DOS}\\openssl-3.0.15 ${SSL_SOURCE_FOLDER_DOS} && ${CMAKE_COMMAND} -E copy ${ZLIB_SOURCE_FOLDER}/../external_zlib-build/zconf.h - ${PYTHON_EXTERNALS_FOLDER}/zlib-1.2.13/zconf.h && + ${PYTHON_EXTERNALS_FOLDER}/zlib-1.3.1/zconf.h && ${PATCH_CMD} --verbose -p1 -d ${BUILD_DIR}/python/src/external_python < ${PATCH_DIR}/${PYTHON_PATCH_FILE} diff --git a/build_files/build_environment/cmake/sndfile.cmake b/build_files/build_environment/cmake/sndfile.cmake index c4d3bce8769..81f92db672a 100644 --- a/build_files/build_environment/cmake/sndfile.cmake +++ b/build_files/build_environment/cmake/sndfile.cmake @@ -41,6 +41,11 @@ ExternalProject_Add(external_sndfile DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${SNDFILE_HASH_TYPE}=${SNDFILE_HASH} PREFIX ${BUILD_DIR}/sndfile + CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} + + PATCH_COMMAND ${PATCH_CMD} -p 1 -d + ${BUILD_DIR}/sndfile/src/external_sndfile < + ${PATCH_DIR}/sndfile_1045.diff CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/sndfile diff --git a/build_files/build_environment/cmake/tbb.cmake b/build_files/build_environment/cmake/tbb.cmake index ff0aeb4a80d..bc4f97a245e 100644 --- a/build_files/build_environment/cmake/tbb.cmake +++ b/build_files/build_environment/cmake/tbb.cmake @@ -3,12 +3,13 @@ # SPDX-License-Identifier: GPL-2.0-or-later set(TBB_EXTRA_ARGS - -DTBB_BUILD_SHARED=On - -DTBB_BUILD_TBBMALLOC=On - -DTBB_BUILD_TBBMALLOC_PROXY=On - -DTBB_BUILD_STATIC=Off - -DTBB_BUILD_TESTS=Off + -DBUILD_SHARED_LIBS=On + -DTBBMALLOC_BUILD=On + -DTBBMALLOC_PROXY_BUILD=On + -DTBB_TEST=Off -DCMAKE_DEBUG_POSTFIX=_debug + # Don't pick up hwloc shared library from system package manager. + -DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=ON ) # TBB does not use soversion by default unlike other libs, but it's needed # to avoid conflicts with incompatible TBB system libs in LD_LIBRARY_PATH @@ -25,23 +26,11 @@ ExternalProject_Add(external_tbb DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${TBB_HASH_TYPE}=${TBB_HASH} PREFIX ${BUILD_DIR}/tbb - - PATCH_COMMAND COMMAND ${CMAKE_COMMAND} -E copy - ${PATCH_DIR}/cmakelists_tbb.txt - ${BUILD_DIR}/tbb/src/external_tbb/CMakeLists.txt && - - ${CMAKE_COMMAND} -E copy - ${BUILD_DIR}/tbb/src/external_tbb/build/vs2013/version_string.ver - ${BUILD_DIR}/tbb/src/external_tbb/build/version_string.ver.in && - - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/tbb/src/external_tbb < - ${PATCH_DIR}/tbb.diff && - - ${PATCH_CMD} -p 1 -d - ${BUILD_DIR}/tbb/src/external_tbb < - ${PATCH_DIR}/tbb_1478.diff - + CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} + PATCH_COMMAND + ${PATCH_CMD} -p 1 -d + ${BUILD_DIR}/tbb/src/external_tbb < + ${PATCH_DIR}/tbb_1478.diff CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tbb ${DEFAULT_CMAKE_FLAGS} ${TBB_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/tbb ) @@ -49,76 +38,26 @@ ExternalProject_Add(external_tbb if(WIN32) if(BUILD_MODE STREQUAL Release) ExternalProject_Add_Step(external_tbb after_install - # `findtbb.cmake` in some deps *NEEDS* to find `tbb_debug.lib` even if they are not going - # to use it to make that test pass, we place a copy with the right name in the lib folder. - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbb.lib - ${LIBDIR}/tbb/lib/tbb_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc.lib - ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbb.dll - ${LIBDIR}/tbb/bin/tbb_debug.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc.dll - ${LIBDIR}/tbb/bin/tbbmalloc_debug.dll # Normal collection of build artifacts - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbb.lib - ${HARVEST_TARGET}/tbb/lib/tbb.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbb.dll - ${HARVEST_TARGET}/tbb/bin/tbb.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc.lib - ${HARVEST_TARGET}/tbb/lib/tbbmalloc.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc.dll - ${HARVEST_TARGET}/tbb/bin/tbbmalloc.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc_proxy.lib - ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc_proxy.dll - ${HARVEST_TARGET}/tbb/bin/tbbmalloc_proxy.dll COMMAND ${CMAKE_COMMAND} -E copy_directory - ${LIBDIR}/tbb/include/ - ${HARVEST_TARGET}/tbb/include/ - + ${LIBDIR}/tbb/ + ${HARVEST_TARGET}/tbb/ DEPENDEES install ) endif() if(BUILD_MODE STREQUAL Debug) ExternalProject_Add_Step(external_tbb after_install - # `findtbb.cmake` in some deps *NEEDS* to find `tbb.lib` even if they are not going to use - # it to make that test pass, we place a copy with the right name in the lib folder. - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbb_debug.lib - ${LIBDIR}/tbb/lib/tbb.lib # Normal collection of build artifacts - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbb_debug.lib - ${HARVEST_TARGET}/tbb/lib/tbb_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbb_debug.dll - ${HARVEST_TARGET}/tbb/bin/tbb_debug.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc_debug.lib - ${HARVEST_TARGET}/tbb/lib/tbbmalloc_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/lib/tbbmalloc_proxy_debug.lib - ${HARVEST_TARGET}/tbb/lib/tbbmalloc_proxy_debug.lib - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc_debug.dll - ${HARVEST_TARGET}/tbb/bin/tbbmalloc_debug.dll - COMMAND ${CMAKE_COMMAND} -E copy - ${LIBDIR}/tbb/bin/tbbmalloc_proxy_debug.dll - ${HARVEST_TARGET}/tbb/bin/tbbmalloc_proxy_debug.dll + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${LIBDIR}/tbb/lib/ + ${HARVEST_TARGET}/tbb/lib/ + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${LIBDIR}/tbb/bin/ + ${HARVEST_TARGET}/tbb/bin/ DEPENDEES install ) endif() else() harvest(external_tbb tbb/include tbb/include "*.h") - harvest_rpath_lib(external_tbb tbb/lib tbb/lib "libtbb${SHAREDLIBEXT}*") + harvest_rpath_lib(external_tbb tbb/lib tbb/lib "*${SHAREDLIBEXT}*") endif() diff --git a/build_files/build_environment/cmake/tiff.cmake b/build_files/build_environment/cmake/tiff.cmake index 138447cd30a..d5593e4dce5 100644 --- a/build_files/build_environment/cmake/tiff.cmake +++ b/build_files/build_environment/cmake/tiff.cmake @@ -23,7 +23,7 @@ ExternalProject_Add(external_tiff DOWNLOAD_DIR ${DOWNLOAD_DIR} URL_HASH ${TIFF_HASH_TYPE}=${TIFF_HASH} PREFIX ${BUILD_DIR}/tiff - + CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/tiff ${DEFAULT_CMAKE_FLAGS} diff --git a/build_files/build_environment/cmake/usd.cmake b/build_files/build_environment/cmake/usd.cmake index 6f8407ebce5..229e00945b6 100644 --- a/build_files/build_environment/cmake/usd.cmake +++ b/build_files/build_environment/cmake/usd.cmake @@ -17,7 +17,6 @@ if(WIN32) set(USD_PLATFORM_FLAGS ${USD_OIIO_CMAKE_DEFINES} -DCMAKE_CXX_FLAGS=${USD_CXX_FLAGS} - -D_PXR_CXX_DEFINITIONS=/DBOOST_ALL_NO_LIB -DCMAKE_SHARED_LINKER_FLAGS_INIT=/LIBPATH:${LIBDIR}/tbb/lib -DPython_FIND_REGISTRY=NEVER -DPython3_EXECUTABLE=${PYTHON_BINARY} @@ -46,6 +45,11 @@ elseif(UNIX) list(APPEND USD_PLATFORM_FLAGS -DCMAKE_SHARED_LINKER_FLAGS=${USD_SHARED_LINKER_FLAGS} ) + # Metal only patch for MaterialX 1.39 issues. + set(USD_EXTRA_PATCHES + ${PATCH_CMD} -p 1 -d + ${BUILD_DIR}/usd/src/external_usd < + ${PATCH_DIR}/usd_3519.diff &&) endif() endif() @@ -54,14 +58,14 @@ endif() string(REPLACE "." "_" USD_NAMESPACE "pxrBlender_v${USD_VERSION}") set(USD_EXTRA_ARGS - ${DEFAULT_BOOST_FLAGS} ${USD_PLATFORM_FLAGS} -DOPENSUBDIV_ROOT_DIR=${LIBDIR}/opensubdiv -DOpenImageIO_ROOT=${LIBDIR}/openimageio + -DVulkan_ROOT=${LIBDIR}/vulkan_loader -DMaterialX_ROOT=${LIBDIR}/materialx -DOPENEXR_LIBRARIES=${LIBDIR}/imath/lib/${LIBPREFIX}Imath${OPENEXR_VERSION_POSTFIX}${SHAREDLIBEXT} -DOPENEXR_INCLUDE_DIR=${LIBDIR}/imath/include - -DImath_DIR=${LIBDIR}/imath + -DImath_DIR=${LIBDIR}/imath/lib/cmake/Imath -DOPENVDB_LOCATION=${LIBDIR}/openvdb -DPXR_SET_INTERNAL_NAMESPACE=${USD_NAMESPACE} -DPXR_ENABLE_PYTHON_SUPPORT=ON @@ -92,14 +96,17 @@ set(USD_EXTRA_ARGS # USD 22.03 does not support OCIO 2.x # Tracking ticket https://github.com/PixarAnimationStudios/USD/issues/1386 -DPXR_BUILD_OPENCOLORIO_PLUGIN=OFF + # We'd like Vulkan support on, but it has trouble not finding the SDK since we have + # the invididual components in the deps builder. + -DPXR_ENABLE_VULKAN_SUPPORT=OFF -DPXR_ENABLE_PTEX_SUPPORT=OFF -DPXR_BUILD_USD_TOOLS=OFF -DCMAKE_DEBUG_POSTFIX=_d -DBUILD_SHARED_LIBS=ON -DTBB_INCLUDE_DIRS=${LIBDIR}/tbb/include -DTBB_LIBRARIES=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${SHAREDLIBEXT} - -DTbb_TBB_LIBRARY=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${SHAREDLIBEXT} - -DTBB_tbb_LIBRARY_RELEASE=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${SHAREDLIBEXT} + -DTBB_LIBRARIES_DEBUG=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${SHAREDLIBEXT} + -DTBB_LIBRARIES_RELEASE=${LIBDIR}/tbb/lib/${LIBPREFIX}${TBB_LIBRARY}${SHAREDLIBEXT} ) # Ray: I'm not sure if the other platforms relied on this or not but this is no longer @@ -121,6 +128,7 @@ ExternalProject_Add(external_usd LIST_SEPARATOR ^^ PATCH_COMMAND + ${USD_EXTRA_PATCHES} ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < ${PATCH_DIR}/usd.diff && @@ -129,11 +137,16 @@ ExternalProject_Add(external_usd ${PATCH_DIR}/usd_core_profile.diff && ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < - ${PATCH_DIR}/usd_metal_edf.diff && + ${PATCH_DIR}/usd_ctor.diff && ${PATCH_CMD} -p 1 -d ${BUILD_DIR}/usd/src/external_usd < - ${PATCH_DIR}/usd_ctor.diff - + ${PATCH_DIR}/usd_3243.diff && + ${PATCH_CMD} -p 1 -d + ${BUILD_DIR}/usd/src/external_usd < + ${PATCH_DIR}/usd_forward_compat.diff && + ${PATCH_CMD} -p 1 -d + ${BUILD_DIR}/usd/src/external_usd < + ${PATCH_DIR}/usd_noboost.diff CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/usd -Wno-dev @@ -146,7 +159,6 @@ ExternalProject_Add(external_usd add_dependencies( external_usd external_tbb - external_boost external_opensubdiv external_python external_openimageio diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index cd8d95e1182..779b3cb374e 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -38,15 +38,15 @@ set(RELEASE_HIP_VERSION 5.7.*) # Note that multi-line strings *must* use [=[...]=] bounds. -set(ZLIB_VERSION 1.2.13) +set(ZLIB_VERSION 1.3.1) set(ZLIB_URI https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}/zlib-${ZLIB_VERSION}.tar.gz) -set(ZLIB_HASH 9b8aa094c4e5765dabf4da391f00d15c) +set(ZLIB_HASH 9855b6d802d7fe5b7bd5b196a2271655) set(ZLIB_HASH_TYPE MD5) set(ZLIB_FILE zlib-${ZLIB_VERSION}.tar.gz) set(ZLIB_CPE "cpe:2.3:a:zlib:zlib:${ZLIB_VERSION}:*:*:*:*:*:*:*") set(ZLIB_HOMEPAGE https://zlib.net) set(ZLIB_LICENSE SPDX:Zlib) -set(ZLIB_COPYRIGHT "Copyright (C) 1995-2017 Jean-loup Gailly") +set(ZLIB_COPYRIGHT "Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler") set(OPENAL_VERSION 1.23.1) set(OPENAL_URI https://github.com/kcat/openal-soft/releases/download/${OPENAL_VERSION}/openal-soft-${OPENAL_VERSION}.tar.bz2) @@ -92,20 +92,6 @@ Copyright (C)2009-2020 D. R. Commander. All Rights Reserved. Copyright (C)2015 Viktor Szathmáry. All Rights Reserved. ]=]) -set(BOOST_VERSION 1.82.0) -set(BOOST_VERSION_SHORT 1.82) -set(BOOST_VERSION_NODOTS 1_82_0) -set(BOOST_VERSION_NODOTS_SHORT 1_82) -set(BOOST_URI https://archives.boost.io/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_NODOTS}.tar.gz) -set(BOOST_HASH f7050f554a65f6a42ece221eaeec1660) -set(BOOST_HASH_TYPE MD5) -set(BOOST_FILE boost_${BOOST_VERSION_NODOTS}.tar.gz) -set(BOOST_CPE "cpe:2.3:a:boost:boost:${BOOST_VERSION}:*:*:*:*:*:*:*") -set(BOOST_HOMEPAGE https://www.boost.org/) -set(BOOST_NAME Boost) -set(BOOST_LICENSE SPDX:BSL-1.0) -set(BOOST_COPYRIGHT "The Boost license encourages both commercial and non-commercial use and does not require attribution for binary use.") - set(BLOSC_VERSION 1.21.1) set(BLOSC_URI https://github.com/Blosc/c-blosc/archive/v${BLOSC_VERSION}.tar.gz) set(BLOSC_HASH 134b55813b1dca57019d2a2dc1f7a923) @@ -141,9 +127,9 @@ set(DEFLATE_HOMEPAGE https://github.com/ebiggers/libdeflate) set(DEFLATE_LICENSE SPDX:MIT) set(DEFLATE_COPYRIGHT "Copyright 2016 Eric Biggers") -set(OPENEXR_VERSION 3.2.4) +set(OPENEXR_VERSION 3.3.2) set(OPENEXR_URI https://github.com/AcademySoftwareFoundation/openexr/archive/v${OPENEXR_VERSION}.tar.gz) -set(OPENEXR_HASH 83b23b937b3a76fd37680422f41b81b7) +set(OPENEXR_HASH 0ca7b46575537ff495d9914166aafa65) set(OPENEXR_HASH_TYPE MD5) set(OPENEXR_FILE openexr-${OPENEXR_VERSION}.tar.gz) set(OPENEXR_CPE "cpe:2.3:a:openexr:openexr:${OPENEXR_VERSION}:*:*:*:*:*:*:*") @@ -254,9 +240,9 @@ set(OPENCOLLADA_FILE opencollada-${OPENCOLLADA_VERSION}.tar.gz) set(OPENCOLLADA_LICENSE SPDX:MIT) set(OPENCOLLADA_COPYRIGHT "Copyright (c) 2008-2009 NetAllied Systems GmbH") -set(OPENCOLORIO_VERSION 2.3.2) +set(OPENCOLORIO_VERSION 2.4.1) set(OPENCOLORIO_URI https://github.com/AcademySoftwareFoundation/OpenColorIO/archive/v${OPENCOLORIO_VERSION}.tar.gz) -set(OPENCOLORIO_HASH 8af74fcb8c4820ab21204463a06ba490) +set(OPENCOLORIO_HASH a11368ef8f001837f29b7dd18dbd2290) set(OPENCOLORIO_HASH_TYPE MD5) set(OPENCOLORIO_FILE OpenColorIO-${OPENCOLORIO_VERSION}.tar.gz) set(OPENCOLORIO_NAME OpenColorIO) @@ -301,10 +287,10 @@ set(OPENMP_URI https://github.com/llvm/llvm-project/releases/download/llvmorg-${ set(OPENMP_HASH_TYPE MD5) set(OPENMP_FILE openmp-${OPENMP_VERSION}.src.tar.xz) -set(OPENIMAGEIO_VERSION v2.5.11.0) +set(OPENIMAGEIO_VERSION v3.0.3.1) set(OPENIMAGEIO_NAME OpenImageIO) set(OPENIMAGEIO_URI https://github.com/AcademySoftwareFoundation/OpenImageIO/archive/refs/tags/${OPENIMAGEIO_VERSION}.tar.gz) -set(OPENIMAGEIO_HASH 691e9364d25e2878e042d48980fad593) +set(OPENIMAGEIO_HASH d2d50bfe58e302c26dc7e24b86cb75fd) set(OPENIMAGEIO_HASH_TYPE MD5) set(OPENIMAGEIO_FILE OpenImageIO-${OPENIMAGEIO_VERSION}.tar.gz) set(OPENIMAGEIO_HOMEPAGE https://github.com/AcademySoftwareFoundation/OpenImageIO) @@ -325,18 +311,18 @@ set(FMT_COPYRIGHT "Copyright (c) 2012 - present, Victor Zverovich and {fmt} cont # 0.6.2 is currently oiio's preferred version although never versions may be available. # the preferred version can be found in oiio's externalpackages.cmake -set(ROBINMAP_VERSION v0.6.2) +set(ROBINMAP_VERSION v1.3.0) set(ROBINMAP_URI https://github.com/Tessil/robin-map/archive/refs/tags/${ROBINMAP_VERSION}.tar.gz) -set(ROBINMAP_HASH c08ec4b1bf1c85eb0d6432244a6a89862229da1cb834f3f90fba8dc35d8c8ef1) +set(ROBINMAP_HASH a8424ad3b0affd4c57ed26f0f3d8a29604f0e1f2ef2089f497f614b1c94c7236) set(ROBINMAP_HASH_TYPE SHA256) set(ROBINMAP_FILE robinmap-${ROBINMAP_VERSION}.tar.gz) set(ROBINMAP_HOMEPAGE https://github.com/Tessil/robin-map) set(ROBINMAP_LICENSE SPDX:MIT) set(ROBINMAP_COPYRIGHT "Copyright (c) 2017 Thibaut Goetghebuer-Planchon ") -set(TIFF_VERSION 4.6.0) +set(TIFF_VERSION 4.7.0) set(TIFF_URI http://download.osgeo.org/libtiff/tiff-${TIFF_VERSION}.tar.gz) -set(TIFF_HASH fc7d49a9348b890b29f91a4ecadd5b49) +set(TIFF_HASH 3a0fa4a270a4a192b08913f88d0cfbdd) set(TIFF_HASH_TYPE MD5) set(TIFF_FILE tiff-${TIFF_VERSION}.tar.gz) set(TIFF_CPE "cpe:2.3:a:libtiff:libtiff:${TIFF_VERSION}:*:*:*:*:*:*:*") @@ -348,13 +334,12 @@ Copyright © 1988-1997 Sam Leffler. Copyright © 1991-1997 Silicon Graphics, Inc. ]=]) -# Recent commit from 1.13.5.0 under development, which includes string table -# changes that make the Cycles OptiX implementation work. Official 1.12 OSL -# releases should also build but without OptiX support. -set(OSL_VERSION 1.13.7.0) +# Latest 1.14 (beta) main, that is compatible with OIIO 3.0 +set(OSL_VERSION 1.14.3.0-beta) +set(OSL_COMMIT "b795e3e92ae1f2c5da5024b61295b0eb41486a65") set(OSL_NAME "Open Shading Language") -set(OSL_URI https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/archive/refs/tags/v${OSL_VERSION}.tar.gz) -set(OSL_HASH 769ae444a7df0e6561b3e745fd2eb50d) +set(OSL_URI https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/archive/${OSL_COMMIT}.tar.gz) +set(OSL_HASH dbfe1a34249959f2d66296bf04317c1c) set(OSL_HASH_TYPE MD5) set(OSL_FILE OpenShadingLanguage-${OSL_VERSION}.tar.gz) set(OSL_HOMEPAGE https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/) @@ -368,18 +353,18 @@ set(OSL_COPYRIGHT "Copyright Contributors to the Open Shading Language project." # Additionally, keep the PYTHON_PIP_VERSION in sync with the pip version bundled # into Python. -set(PYTHON_VERSION 3.11.9) +set(PYTHON_VERSION 3.11.11) set(PYTHON_SHORT_VERSION 3.11) set(PYTHON_SHORT_VERSION_NO_DOTS 311) set(PYTHON_URI https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz) -set(PYTHON_HASH 22ea467e7d915477152e99d5da856ddc) +set(PYTHON_HASH 3e497037b170fe4be5f462c4964596f2) set(PYTHON_HASH_TYPE MD5) set(PYTHON_FILE Python-${PYTHON_VERSION}.tar.xz) set(PYTHON_CPE "cpe:2.3:a:python:python:${PYTHON_VERSION}:-:*:*:*:*:*:*") set(PYTHON_HOMEPAGE https://www.python.org/) set(PYTHON_NAME Python) set(PYTHON_LICENSE SPDX:Python-2.0) -set(PYTHON_COPYRIGHT "Copyright (c) 2001-2021 Python Software Foundation. All rights reserved.") +set(PYTHON_COPYRIGHT "Copyright (c) 2001-2023 Python Software Foundation. All rights reserved.") # Python bundles pip wheel, and does not track CVEs from it. Add an explicit CPE # identifier for pip, so that cve_check can detect vulnerabilities in it. @@ -390,11 +375,11 @@ set(PYTHON_COPYRIGHT "Copyright (c) 2001-2021 Python Software Foundation. All ri set(PYTHON_PIP_VERSION 24.0) set(PYTHON_PIP_CPE "cpe:2.3:a:pypa:pip:${PYTHON_PIP_VERSION}:*:*:*:*:*:*:*") -set(TBB_YEAR 2020) +set(TBB_YEAR 2021) set(TBB_NAME oneTBB) -set(TBB_VERSION ${TBB_YEAR}_U3) -set(TBB_URI https://github.com/oneapi-src/oneTBB/archive/${TBB_VERSION}.tar.gz) -set(TBB_HASH 55ec8df6eae5ed6364a47f0e671e460c) +set(TBB_VERSION v2021.13.0) +set(TBB_URI https://github.com/uxlfoundation/oneTBB/archive/refs/tags/${TBB_VERSION}.tar.gz) +set(TBB_HASH f287cd007240a838286ff13e7deaee12) set(TBB_HASH_TYPE MD5) set(TBB_FILE oneTBB-${TBB_VERSION}.tar.gz) set(TBB_CPE "cpe:2.3:a:intel:threading_building_blocks:${TBB_YEAR}:*:*:*:*:*:*:*") @@ -402,10 +387,20 @@ set(TBB_HOMEPAGE https://software.intel.com/en-us/oneapi/onetbb) set(TBB_LICENSE SPDX:Apache-2.0) set(TBB_COPYRIGHT "Copyright (c) 2005-2020 Intel Corporation") -set(OPENVDB_VERSION 11.0.0) +set(NANOBIND_VERSION v2.1.0) +set(NANOBIND_NAME NanoBind) +set(NANOBIND_URI https://github.com/wjakob/nanobind/archive/refs/tags/${NANOBIND_VERSION}.tar.gz) +set(NANOBIND_HASH 363e96957741869bb16ff983c042e72f) +set(NANOBIND_HASH_TYPE MD5) +set(NANOBIND_FILE nanobind-${NANOBIND_VERSION}.tar.gz) +set(NANOBIND_HOMEPAGE https://github.com/wjakob/nanobind) +set(NANOBIND_LICENSE SPDX:BSD-3-Clause) +set(NANOBIND_COPYRIGHT "2023, Wenzel Jakob") + +set(OPENVDB_VERSION 12.0.0) set(OPENVDB_NAME OpenVDB) set(OPENVDB_URI https://github.com/AcademySoftwareFoundation/openvdb/archive/v${OPENVDB_VERSION}.tar.gz) -set(OPENVDB_HASH 025f4fc4db58419341a4991f1a16174a) +set(OPENVDB_HASH c5cd16784b6b42aaa956b574042f374d) set(OPENVDB_HASH_TYPE MD5) set(OPENVDB_FILE openvdb-${OPENVDB_VERSION}.tar.gz) set(OPENVDB_HOMEPAGE http://www.openvdb.org/) @@ -427,7 +422,7 @@ set(CERTIFI_VERSION 2021.10.8) # Needed by: Some of Blender's add-ons (to support convenient interaction with online services). set(REQUESTS_VERSION 2.27.1) # Needed by: Python's `numpy` module (used by some add-ons). -set(CYTHON_VERSION 0.29.30) +set(CYTHON_VERSION 3.0.11) # Needed by: Python scripts that read `.blend` files, as files may use Z-standard compression. # The version of the ZSTD library used to build the Python package should match ZSTD_VERSION # defined below. At this time of writing, 0.17.0 was already released, @@ -440,10 +435,10 @@ set(PYCODESTYLE_VERSION 2.12.1) # Build system for other packages (not used by Blender at run-time). set(MESON_VERSION 0.63.0) -set(NUMPY_VERSION 1.24.3) -set(NUMPY_SHORT_VERSION 1.24) +set(NUMPY_VERSION 1.26.4) +set(NUMPY_SHORT_VERSION 1.26) set(NUMPY_URI https://github.com/numpy/numpy/releases/download/v${NUMPY_VERSION}/numpy-${NUMPY_VERSION}.tar.gz) -set(NUMPY_HASH 89e5e2e78407032290ae6acf6dcaea46) +set(NUMPY_HASH 19550cbe7bedd96a928da9d4ad69509d) set(NUMPY_HASH_TYPE MD5) set(NUMPY_FILE numpy-${NUMPY_VERSION}.tar.gz) set(NUMPY_CPE "cpe:2.3:a:numpy:numpy:${NUMPY_VERSION}:*:*:*:*:*:*:*") @@ -652,9 +647,9 @@ Copyright (C) 2009-2013 Facebook, Inc. All rights reserved. Copyright (C) 2013 Jason Evans . ]=]) -set(XML2_VERSION 2.12.3) -set(XML2_URI https://download.gnome.org/sources/libxml2/2.12/libxml2-${XML2_VERSION}.tar.xz) -set(XML2_HASH 13871e7cf2137b4b9b9da753ffef538c) +set(XML2_VERSION 2.13.5) +set(XML2_URI https://download.gnome.org/sources/libxml2/2.13/libxml2-${XML2_VERSION}.tar.xz) +set(XML2_HASH 0b919be8edff97ade9c946e1a83bdecd) set(XML2_HASH_TYPE MD5) set(XML2_FILE libxml2-${XML2_VERSION}.tar.xz) set(XML2_CPE "cpe:2.3:a:xmlsoft:libxml2:${XML2_VERSION}:*:*:*:*:*:*:*") @@ -681,10 +676,10 @@ set(PYSTRING_HOMEPAGE https://github.com/imageworks/pystring) set(PYSTRING_LICENSE SPDX:BSD-3-Clause) set(PYSTRING_COPYRIGHT "Copyright (c) 2008-2010, Sony Pictures Imageworks Inc; All rights reserved.") -set(EXPAT_VERSION 2_5_0) -set(EXPAT_VERSION_DOTS 2.5.0) +set(EXPAT_VERSION 2_6_4) +set(EXPAT_VERSION_DOTS 2.6.4) set(EXPAT_URI https://github.com/libexpat/libexpat/archive/R_${EXPAT_VERSION}.tar.gz) -set(EXPAT_HASH d375fa3571c0abb945873f5061a8f2e2) +set(EXPAT_HASH f2f8d61e2bd71d1118e1258ed9f4c0b7) set(EXPAT_HASH_TYPE MD5) set(EXPAT_FILE libexpat-${EXPAT_VERSION}.tar.gz) set(EXPAT_HOMEPAGE https://github.com/libexpat/libexpat/) @@ -799,10 +794,10 @@ set(EMBREE_HOMEPAGE https://github.com/embree/embree) set(EMBREE_LICENSE SPDX:Apache-2.0) set(EMBREE_COPYRIGHT "Copyright 2009-2020 Intel Corporation") -set(USD_VERSION 24.05) +set(USD_VERSION 25.02) set(USD_NAME USD) set(USD_URI https://github.com/PixarAnimationStudios/OpenUSD/archive/v${USD_VERSION}.tar.gz) -set(USD_HASH 44a5b976a76588b485a652f08a55e91f) +set(USD_HASH 76ee61270e67002ddb2fc76dda6a498d) set(USD_HASH_TYPE MD5) set(USD_FILE usd-v${USD_VERSION}.tar.gz) set(USD_HOMEPAGE https://openusd.org/) @@ -815,10 +810,10 @@ This product includes software developed at: Pixar (http://www.pixar.com/). ]=]) -set(MATERIALX_VERSION 1.38.8) +set(MATERIALX_VERSION 1.39.2) set(MATERIALX_NAME MaterialX) set(MATERIALX_URI https://github.com/AcademySoftwareFoundation/MaterialX/archive/refs/tags/v${MATERIALX_VERSION}.tar.gz) -set(MATERIALX_HASH fad8f4e19305fb2ee920cbff638f3560) +set(MATERIALX_HASH e3e413755f525aec96c60af631753044) set(MATERIALX_HASH_TYPE MD5) set(MATERIALX_FILE materialx-v${MATERIALX_VERSION}.tar.gz) set(MATERIALX_HOMEPAGE https://github.com/AcademySoftwareFoundation/MaterialX) @@ -964,9 +959,9 @@ set(ISPC_HASH_TYPE MD5) set(ISPC_FILE ispc-${ISPC_VERSION}.tar.gz) set(ISPC_DEPSBUILDTIMEONLY "Blender ships the produced artifact, but doesn't ship/link with any binary") -set(GMP_VERSION 6.2.1) +set(GMP_VERSION 6.3.0) set(GMP_URI https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.xz) -set(GMP_HASH 0b82665c4a92fd2ade7440c13fcaa42b) +set(GMP_HASH 956dc04e864001a9c22429f761f2c283) set(GMP_HASH_TYPE MD5) set(GMP_FILE gmp-${GMP_VERSION}.tar.xz) set(GMP_CPE "cpe:2.3:a:gmplib:gmp:${GMP_VERSION}:*:*:*:*:*:*:*") @@ -1100,8 +1095,7 @@ set(ICDLOADER_LICENSE SPDX:Apache-2.0) set(ICDLOADER_COPYRIGHT " Copyright (c) 2020 The Khronos Group Inc.") # Source sycl/cmake/modules/AddBoostMp11Headers.cmake -# Using external MP11 here, getting AddBoostMp11Headers.cmake to recognize -# our copy in boost directly was more trouble than it was worth. +# Using external MP11 here so we don't have to pull in all of Boost. set(MP11_VERSION 863d8b8d2b20f2acd0b5870f23e553df9ce90e6c) set(MP11_URI https://github.com/boostorg/mp11/archive/${MP11_VERSION}.tar.gz) set(MP11_HASH 525692267abb8086bb9cc2fe81fb96d73ac645dfa6825cb5114686aafe244e9f) diff --git a/build_files/build_environment/dependencies.dot b/build_files/build_environment/dependencies.dot index 5c341086e5f..e6806a33dac 100644 --- a/build_files/build_environment/dependencies.dot +++ b/build_files/build_environment/dependencies.dot @@ -4,8 +4,6 @@ graph[autosize = false, size = "25.7,8.3!", resolution = 300]; external_alembic -- external_imath; external_blosc -- external_zlib; external_blosc -- external_pthreads; - external_boost -- external_python; - external_boost -- external_numpy; external_dpcpp -- external_python; external_dpcpp -- external_python_site_packages; external_dpcpp -- external_vcintrinsics; @@ -66,7 +64,6 @@ graph[autosize = false, size = "25.7,8.3!", resolution = 300]; external_openimageio -- external_openexr; external_openimageio -- external_imath; external_openimageio -- external_jpeg; - external_openimageio -- external_boost; external_openimageio -- external_tiff; external_openimageio -- external_pugixml; external_openimageio -- external_fmt; @@ -77,10 +74,8 @@ graph[autosize = false, size = "25.7,8.3!", resolution = 300]; external_openpgl -- external_tbb; external_opensubdiv -- external_tbb; openvdb -- external_tbb; - openvdb -- external_boost; openvdb -- external_zlib; openvdb -- external_blosc; - external_osl -- external_boost; external_osl -- ll; external_osl -- external_openexr; external_osl -- external_zlib; @@ -103,7 +98,6 @@ graph[autosize = false, size = "25.7,8.3!", resolution = 300]; external_theora -- external_ogg; external_tiff -- external_zlib; external_usd -- external_tbb; - external_usd -- external_boost; external_usd -- external_opensubdiv; external_vorbis -- external_ogg; external_wayland -- external_expat; diff --git a/build_files/build_environment/patches/boost.diff b/build_files/build_environment/patches/boost.diff deleted file mode 100644 index b4158657677..00000000000 --- a/build_files/build_environment/patches/boost.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- a/boost/python//detail/wrap_python.hpp 2022-12-09 19:16:17 -+++ b/boost/python//detail/wrap_python.hpp 2022-12-09 19:18:08 -@@ -206,7 +206,8 @@ - - #ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H - # undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H --# define _DEBUG -+// BLENDER: TBB expects this to have a value. -+# define _DEBUG 1 - # ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H - # undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H - # undef _CRT_NOFORCE_MANIFEST ---- a/boost/config/stdlib/libcpp.hpp 2022-08-03 22:47:07.000000000 -0400 -+++ b/boost/config/stdlib/libcpp.hpp 2022-09-16 22:16:17.044119011 -0400 -@@ -168,4 +168,13 @@ - # define BOOST_NO_CXX14_HDR_SHARED_MUTEX - #endif - -+#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 15000 -+// -+// Unary function is now deprecated in C++11 and later: -+// -+#if __cplusplus >= 201103L -+#define BOOST_NO_CXX98_FUNCTION_BASE -+#endif -+#endif -+ - // --- end --- diff --git a/build_files/build_environment/patches/gmp.diff b/build_files/build_environment/patches/gmp.diff index d6baca50b28..d86331ecd2c 100644 --- a/build_files/build_environment/patches/gmp.diff +++ b/build_files/build_environment/patches/gmp.diff @@ -14,9 +14,9 @@ diff -Naur gmp-6.2.1-clean/Makefile.in gmp-6.2.1-dirty/Makefile.in --- gmp-6.2.1-clean/Makefile.in 2020-11-14 18:45:16.000000000 +0000 +++ gmp-6.2.1-dirty/Makefile.in 2023-01-24 13:06:47.691201700 +0000 @@ -572,7 +572,7 @@ - LIBGMPXX_LT_CURRENT = 10 - LIBGMPXX_LT_REVISION = 1 - LIBGMPXX_LT_AGE = 6 + LIBGMPXX_LT_CURRENT = 11 + LIBGMPXX_LT_REVISION = 0 + LIBGMPXX_LT_AGE = 7 -SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc +SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune @@ -48,19 +48,3 @@ diff -Naur gmp-6.2.1-clean/gmp-h.in gmp-6.2.1-dirty/gmp-h.in #endif /* Recent enough Sun C compilers want "inline" */ -diff -Naur gmp-6.2.1-clean/mpz/inp_raw.c gmp-6.2.1-dirty/mpz/inp_raw.c ---- gmp-6.2.1-clean/mpz/inp_raw.c 2020-11-14 18:45:09.000000000 +0000 -+++ gmp-6.2.1-dirty/mpz/inp_raw.c 2023-01-24 10:24:26.379294800 +0000 -@@ -88,8 +88,11 @@ - - abs_csize = ABS (csize); - -+ if (UNLIKELY (abs_csize > ~(mp_bitcnt_t) 0 / 8)) -+ return 0; /* Bit size overflows */ -+ - /* round up to a multiple of limbs */ -- abs_xsize = BITS_TO_LIMBS (abs_csize*8); -+ abs_xsize = BITS_TO_LIMBS ((mp_bitcnt_t) abs_csize * 8); - - if (abs_xsize != 0) - { diff --git a/build_files/build_environment/patches/oiio_4062.diff b/build_files/build_environment/patches/oiio_4062.diff deleted file mode 100644 index 7f5fd33ff42..00000000000 --- a/build_files/build_environment/patches/oiio_4062.diff +++ /dev/null @@ -1,28 +0,0 @@ -diff --git a/src/include/OpenImageIO/simd.h b/src/include/OpenImageIO/simd.h -index f888b29fe..e0cdebdc1 100644 ---- a/src/include/OpenImageIO/simd.h -+++ b/src/include/OpenImageIO/simd.h -@@ -46,10 +46,6 @@ - - #include - --// Without SSE, we need to fall back on Imath for matrix44 invert --#if !OIIO_SIMD_SSE --# include --#endif - - - ////////////////////////////////////////////////////////////////////////// -@@ -279,6 +275,12 @@ - #endif - - -+// Without SSE, we need to fall back on Imath for matrix44 invert -+#if !OIIO_SIMD_SSE -+# include -+#endif -+ -+ - OIIO_NAMESPACE_BEGIN - - namespace simd { diff --git a/build_files/build_environment/patches/oiio_4302.diff b/build_files/build_environment/patches/oiio_4302.diff deleted file mode 100644 index 36bb6bd79ab..00000000000 --- a/build_files/build_environment/patches/oiio_4302.diff +++ /dev/null @@ -1,174 +0,0 @@ -diff --git a/src/doc/builtinplugins.rst b/src/doc/builtinplugins.rst -index 1654105918..9ad185ce21 100644 ---- a/src/doc/builtinplugins.rst -+++ b/src/doc/builtinplugins.rst -@@ -1964,7 +1964,7 @@ Lab or duotone modes. - - **Custom I/O Overrides** - --PSD output supports the "custom I/O" feature via the special ``"oiio:ioproxy"`` -+PSD input supports the "custom I/O" feature via the special ``"oiio:ioproxy"`` - attributes (see Sections :ref:`sec-imageoutput-ioproxy` and - :ref:`sec-imageinput-ioproxy`) as well as the `set_ioproxy()` methods. - -diff --git a/src/psd.imageio/psdinput.cpp b/src/psd.imageio/psdinput.cpp -index e3972d087f..fd472385bb 100644 ---- a/src/psd.imageio/psdinput.cpp -+++ b/src/psd.imageio/psdinput.cpp -@@ -1890,6 +1890,8 @@ PSDInput::load_image_data() - // setup some generic properties and read any RLE lengths - // Image Data Section has RLE lengths for all channels stored first - for (ChannelInfo& channel_info : m_image_data.channel_info) { -+ channel_info.width = m_header.width; -+ channel_info.height = m_header.height; - channel_info.compression = compression; - channel_info.channel_id = id++; - channel_info.data_length = row_length * m_header.height; -@@ -2045,39 +2047,39 @@ PSDInput::read_channel_row(ChannelInfo& channel_info, uint32_t row, char* data) - case 16: swap_endian((uint16_t*)data, channel_info.width); break; - case 32: swap_endian((uint32_t*)data, channel_info.width); break; - } -- break; -- case Compression_RLE: { -- if (!ioseek(channel_info.row_pos[row])) -- return false; -- uint32_t rle_length = channel_info.rle_lengths[row]; -- char* rle_buffer; -- OIIO_ALLOCATE_STACK_OR_HEAP(rle_buffer, char, rle_length); -- if (!ioread(rle_buffer, rle_length) -- || !decompress_packbits(rle_buffer, data, rle_length, -- channel_info.row_length)) -- return false; -- } break; -- case Compression_ZIP: { -- OIIO_ASSERT(channel_info.decompressed_data.size() -- == static_cast(channel_info.width) -- * channel_info.height * (m_header.depth / 8)); -- // We simply copy over the row into destination -- uint64_t row_index = static_cast(row) * channel_info.width -- * (m_header.depth / 8); -- std::memcpy(data, channel_info.decompressed_data.data() + row_index, -- channel_info.row_length); -- } break; -- case Compression_ZIP_Predict: { -- OIIO_ASSERT(channel_info.decompressed_data.size() -- == static_cast(channel_info.width) -- * channel_info.height * (m_header.depth / 8)); -- // We simply copy over the row into destination -- uint64_t row_index = static_cast(row) * channel_info.width -- * (m_header.depth / 8); -- std::memcpy(data, channel_info.decompressed_data.data() + row_index, -- channel_info.row_length); -- } break; - } -+ break; -+ case Compression_RLE: { -+ if (!ioseek(channel_info.row_pos[row])) -+ return false; -+ uint32_t rle_length = channel_info.rle_lengths[row]; -+ char* rle_buffer; -+ OIIO_ALLOCATE_STACK_OR_HEAP(rle_buffer, char, rle_length); -+ if (!ioread(rle_buffer, rle_length) -+ || !decompress_packbits(rle_buffer, data, rle_length, -+ channel_info.row_length)) -+ return false; -+ } break; -+ case Compression_ZIP: { -+ OIIO_ASSERT(channel_info.decompressed_data.size() -+ == static_cast(channel_info.width) -+ * channel_info.height * (m_header.depth / 8)); -+ // We simply copy over the row into destination -+ uint64_t row_index = static_cast(row) * channel_info.width -+ * (m_header.depth / 8); -+ std::memcpy(data, channel_info.decompressed_data.data() + row_index, -+ channel_info.row_length); -+ } break; -+ case Compression_ZIP_Predict: { -+ OIIO_ASSERT(channel_info.decompressed_data.size() -+ == static_cast(channel_info.width) -+ * channel_info.height * (m_header.depth / 8)); -+ // We simply copy over the row into destination -+ uint64_t row_index = static_cast(row) * channel_info.width -+ * (m_header.depth / 8); -+ std::memcpy(data, channel_info.decompressed_data.data() + row_index, -+ channel_info.row_length); -+ } break; - } - - return true; -diff --git a/testsuite/psd-colormodes/ref/out.txt b/testsuite/psd-colormodes/ref/out.txt -index b521061822..0cc89d8f3b 100644 ---- a/testsuite/psd-colormodes/ref/out.txt -+++ b/testsuite/psd-colormodes/ref/out.txt -@@ -22,7 +22,7 @@ Comparing "pattern2-8-rgb.psd.tif" and "ref/pattern2.tif" - PASS - Comparing "pattern2-16-rgb.psd.tif" and "ref/pattern2.tif" - PASS --Comparing "pattern2-8-cmyk.psd.tif" and "ref/pattern2-cmyk.tif" -+Comparing "pattern2-8-cmyk.psd.tif" and "ref/pattern2-8-cmyk.psd.tif" - PASS - Comparing "pattern2-16-cmyk.psd.tif" and "ref/pattern2-16-cmyk.psd.tif" - PASS -@@ -30,7 +30,7 @@ Comparing "pattern2-8-multichannel.psd.tif" and "ref/pattern2.tif" - PASS - Comparing "pattern2-16-multichannel.psd.tif" and "ref/pattern2.tif" - PASS --Comparing "pattern2-8-grayscale.psd.tif" and "ref/pattern2-gray.tif" -+Comparing "pattern2-8-grayscale.psd.tif" and "ref/pattern2-8-grayscale.psd.tif" - PASS - Comparing "pattern2-16-grayscale.psd.tif" and "ref/pattern2-16-grayscale.psd.tif" - PASS -diff --git a/testsuite/psd-colormodes/ref/pattern2-16-cmyk.psd.tif b/testsuite/psd-colormodes/ref/pattern2-16-cmyk.psd.tif -index d01cca324e..f6e8c9f458 100644 -Binary files a/testsuite/psd-colormodes/ref/pattern2-16-cmyk.psd.tif and b/testsuite/psd-colormodes/ref/pattern2-16-cmyk.psd.tif differ -diff --git a/testsuite/psd-colormodes/ref/pattern2-16-grayscale.psd.tif b/testsuite/psd-colormodes/ref/pattern2-16-grayscale.psd.tif -index db88e52ad2..1943c31f05 100644 -Binary files a/testsuite/psd-colormodes/ref/pattern2-16-grayscale.psd.tif and b/testsuite/psd-colormodes/ref/pattern2-16-grayscale.psd.tif differ -diff --git a/testsuite/psd-colormodes/ref/pattern2-cmyk.tif b/testsuite/psd-colormodes/ref/pattern2-8-cmyk.psd.tif -similarity index 100% -rename from testsuite/psd-colormodes/ref/pattern2-cmyk.tif -rename to testsuite/psd-colormodes/ref/pattern2-8-cmyk.psd.tif -diff --git a/testsuite/psd-colormodes/ref/pattern2-gray.tif b/testsuite/psd-colormodes/ref/pattern2-8-grayscale.psd.tif -similarity index 100% -rename from testsuite/psd-colormodes/ref/pattern2-gray.tif -rename to testsuite/psd-colormodes/ref/pattern2-8-grayscale.psd.tif -diff --git a/testsuite/psd/ref/out.txt b/testsuite/psd/ref/out.txt -index 7c0319d6a0..047d6a6281 100644 ---- a/testsuite/psd/ref/out.txt -+++ b/testsuite/psd/ref/out.txt -@@ -584,7 +584,7 @@ Reading ../oiio-images/psd_rgb_8.psd - stRef:originalDocumentID: "E146B3E37A92795EE3EA6577040DE6D5" - Reading ../oiio-images/psd_rgb_16.psd - ../oiio-images/psd_rgb_16.psd : 320 x 240, 3 channel, uint16 psd -- SHA-1: 591F6850EB0B548DF2CE7177661440CB812E5C31 -+ SHA-1: E42334B0F0684E3C3BF9125F2920B07C44C17B11 - channel list: R, G, B - Artist: "Daniel Wyatt" - DateTime: "2007-01-18T15:49:21" -@@ -655,7 +655,7 @@ Reading ../oiio-images/psd_rgb_16.psd - stRef:originalDocumentID: "E146B3E37A92795EE3EA6577040DE6D5" - Reading ../oiio-images/psd_rgb_32.psd - ../oiio-images/psd_rgb_32.psd : 320 x 240, 3 channel, float psd -- SHA-1: B7F8CE4B4259A92AA13333EA8112C3E37C6BAB39 -+ SHA-1: 63CF8F7B010D24EFD3C41F51C16D8D285FE07313 - channel list: R, G, B - Artist: "Daniel Wyatt" - DateTime: "2007-01-18T15:49:21" -@@ -1459,7 +1459,7 @@ Reading src/Layers_16bit_RGB.psd - src/Layers_16bit_RGB.psd : 48 x 27, 3 channel, uint16 psd - 4 subimages: 48x27 [u16,u16,u16], 48x27 [u16,u16,u16,u16], 48x27 [u16,u16,u16,u16], 48x27 [u16,u16,u16,u16] - subimage 0: 48 x 27, 3 channel, uint16 psd -- SHA-1: 22EAC1FF517BCCEA8EBA31AB240C11518EE42424 -+ SHA-1: 0228B2F3AA493695E9653E1C32D303022DDEFAE4 - channel list: R, G, B - DateTime: "2024-03-06T15:22:40+01:00" - ICCProfile: 0, 0, 12, 72, 76, 105, 110, 111, 2, 16, 0, 0, 109, 110, 116, 114, ... [3144 x uint8] -@@ -1653,7 +1653,7 @@ Reading src/Layers_32bit_RGB.psd - src/Layers_32bit_RGB.psd : 48 x 27, 3 channel, float psd - 4 subimages: 48x27 [f,f,f], 48x27 [f,f,f,f], 48x27 [f,f,f,f], 48x27 [f,f,f,f] - subimage 0: 48 x 27, 3 channel, float psd -- SHA-1: 90D05324071E32026D22E44FA9EF027C80D97308 -+ SHA-1: C9C84C45C64884BD4D6F1B1E91CCA6744EA3C06C - channel list: R, G, B - DateTime: "2024-03-06T15:22:40+01:00" - ICCProfile: 0, 0, 2, 56, 108, 99, 109, 115, 4, 48, 0, 0, 109, 110, 116, 114, ... [568 x uint8] diff --git a/build_files/build_environment/patches/oiio_webp.diff b/build_files/build_environment/patches/oiio_webp.diff deleted file mode 100644 index 5adfc7d000c..00000000000 --- a/build_files/build_environment/patches/oiio_webp.diff +++ /dev/null @@ -1,78 +0,0 @@ -diff -Naur oiio-2.4.15.0/src/cmake/modules/FindWebP.cmake external_openimageio/src/cmake/modules/FindWebP.cmake ---- oiio-2.4.15.0/src/cmake/modules/FindWebP.cmake 2023-09-01 10:48:29.000000000 -0600 -+++ external_openimageio/src/cmake/modules/FindWebP.cmake 2023-09-21 14:47:19.366083900 -0600 -@@ -25,15 +25,30 @@ - ENV WEBP_INCLUDE_PATH - DOC "The directory where Webp headers reside") - --find_library (WEBP_LIBRARY webp -+find_library (WEBP_LIBRARY -+ NAMES -+ webp -+ libwebp - HINTS - ${WEBP_LIBRARY_PATH} - ENV WEBP_LIBRARY_PATH) --find_library (WEBPDEMUX_LIBRARY webpdemux -+find_library (WEBPDEMUX_LIBRARY -+ NAMES -+ webpdemux -+ libwebpdemux -+ HINTS -+ ${WEBP_LIBRARY_PATH} -+ ENV WEBP_LIBRARY_PATH) -+# New in WebP 1.3 -+find_library (WEBP_SHARPYUV_LIBRARY -+ NAMES -+ sharpyuv -+ libsharpyuv - HINTS - ${WEBP_LIBRARY_PATH} - ENV WEBP_LIBRARY_PATH) - -+ - include (FindPackageHandleStandardArgs) - find_package_handle_standard_args (WebP - REQUIRED_VARS WEBP_INCLUDE_DIR -@@ -42,7 +57,7 @@ - - if (WebP_FOUND) - set (WEBP_INCLUDES "${WEBP_INCLUDE_DIR}") -- set (WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBPDEMUX_LIBRARY}) -+ set (WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBPDEMUX_LIBRARY} ${WEBP_SHARPYUV_LIBRARY}) - - if (NOT TARGET WebP::webp) - add_library(WebP::webp UNKNOWN IMPORTED) -@@ -58,10 +73,18 @@ - set_property(TARGET WebP::webpdemux APPEND PROPERTY - IMPORTED_LOCATION ${WEBPDEMUX_LIBRARY}) - endif () -+ if (WEBP_SHARPYUV_LIBRARY AND NOT TARGET WebP::sharpyuv) -+ add_library(WebP::sharpyuv UNKNOWN IMPORTED) -+ set_target_properties(WebP::sharpyuv PROPERTIES -+ INTERFACE_INCLUDE_DIRECTORIES ${WEBP_INCLUDES}) -+ set_property(TARGET WebP::sharpyuv APPEND PROPERTY -+ IMPORTED_LOCATION ${WEBP_SHARPYUV_LIBRARY}) -+ endif () - endif () - - mark_as_advanced ( - WEBP_INCLUDE_DIR - WEBP_LIBRARY - WEBPDEMUX_LIBRARY -+ WEBP_SHARPYUV_LIBRARY - ) - -diff --git a/src/webp.imageio/CMakeLists.txt b/src/webp.imageio/CMakeLists.txt -index ccf1146..c646e99 100644 ---- a/src/webp.imageio/CMakeLists.txt -+++ b/src/webp.imageio/CMakeLists.txt -@@ -4,7 +4,7 @@ - - if (WebP_FOUND) - add_oiio_plugin (webpinput.cpp webpoutput.cpp -- LINK_LIBRARIES WebP::webp WebP::webpdemux -+ LINK_LIBRARIES WebP::webp WebP::webpdemux WebP::sharpyuv - DEFINITIONS "-DUSE_WEBP=1") - else () - message (STATUS "WebP plugin will not be built") diff --git a/build_files/build_environment/patches/openimageio.diff b/build_files/build_environment/patches/openimageio.diff index 50d561dc056..6ef9b47b155 100644 --- a/build_files/build_environment/patches/openimageio.diff +++ b/build_files/build_environment/patches/openimageio.diff @@ -14,10 +14,10 @@ diff -Naur orig/src/cmake/compiler.cmake external_openimageio/src/cmake/compiler --- orig/src/cmake/compiler.cmake 2020-05-10 21:43:52 -0600 +++ external_openimageio/src/cmake/compiler.cmake 2020-05-13 17:02:54 -0600 @@ -188,6 +189,7 @@ - add_definitions (-D_CRT_NONSTDC_NO_WARNINGS) - add_definitions (-D_SCL_SECURE_NO_WARNINGS) - add_definitions (-DJAS_WIN_MSVC_BUILD) -+ add_definitions (-DOPJ_STATIC) + add_compile_definitions (_CRT_NONSTDC_NO_WARNINGS) + add_compile_definitions (_SCL_SECURE_NO_WARNINGS) + add_compile_definitions (JAS_WIN_MSVC_BUILD) ++ add_compile_definitions (OPJ_STATIC) endif (MSVC) if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" diff --git a/build_files/build_environment/patches/openvdb.diff b/build_files/build_environment/patches/openvdb.diff index b231b54afb4..2170ce3449b 100644 --- a/build_files/build_environment/patches/openvdb.diff +++ b/build_files/build_environment/patches/openvdb.diff @@ -1,15 +1,23 @@ -diff -Naur openvdb-8.0.0/openvdb/openvdb/CMakeLists.txt openvdb/openvdb/openvdb/CMakeLists.txt ---- openvdb-8.0.0/openvdb/openvdb/CMakeLists.txt 2020-12-24 10:13:14 -0700 -+++ openvdb/openvdb/openvdb/CMakeLists.txt 2021-02-05 11:18:33 -0700 -@@ -146,6 +148,7 @@ - Boost::disable_autolinking # add -DBOOST_ALL_NO_LIB - ) +diff -Naur openvdb-12.0.0/openvdb/openvdb/CMakeLists.txt openvdb/openvdb/openvdb/CMakeLists.txt +--- openvdb-12.0.0/openvdb/openvdb/CMakeLists.txt 2024-10-31 16:59:05.000000000 -0700 ++++ openvdb/openvdb/openvdb/CMakeLists.txt 2024-12-11 08:47:05.635327200 -0800 +@@ -148,6 +148,15 @@ endif() -+ add_definitions(-D__TBB_NO_IMPLICIT_LINKAGE -DOPENVDB_OPENEXR_STATICLIB) endif() - if(USE_EXR) -@@ -379,7 +382,12 @@ ++add_compile_definitions( ++ #Blender: prevent implicit TBB linkage ++ __TBB_NO_IMPLICIT_LINKAGE ++ #Blender: OpenEXR is static ++ OPENVDB_OPENEXR_STATICLIB ++ #Blender: Link the debug python libs rather than the release ones ++ $<$:Py_DEBUG> ++) ++ + if(USE_BLOSC) + # Find Blosc libraries + find_package(Blosc ${MINIMUM_BLOSC_VERSION} REQUIRED) +@@ -608,7 +617,12 @@ # imported targets. if(OPENVDB_CORE_SHARED) @@ -23,9 +31,23 @@ diff -Naur openvdb-8.0.0/openvdb/openvdb/CMakeLists.txt openvdb/openvdb/openvdb/ endif() if(OPENVDB_CORE_STATIC) -diff -Naur openvdb-8.0.0/openvdb/openvdb/version.rc.in openvdb/openvdb/openvdb/version.rc.in ---- openvdb-8.0.0/openvdb/openvdb/version.rc.in 1969-12-31 17:00:00 -0700 -+++ openvdb/openvdb/openvdb/version.rc.in 2021-02-05 11:18:33 -0700 +diff -Naur openvdb-12.0.0/openvdb/openvdb/python/CMakeLists.txt openvdb/openvdb/openvdb/python/CMakeLists.txt +--- openvdb-12.0.0/openvdb/openvdb/python/CMakeLists.txt 2024-10-31 16:59:05.000000000 -0700 ++++ openvdb/openvdb/openvdb/python/CMakeLists.txt 2024-12-11 09:02:05.377733900 -0800 +@@ -22,7 +22,9 @@ + option(OPENVDB_BUILD_PYTHON_UNITTESTS [=[ + "Include the OpenVDB Python unit test. Requires a python interpreter]=] + ${OPENVDB_BUILD_UNITTESTS}) +- ++#blender: prevent double _d for the python module ++set(CMAKE_DEBUG_POSTFIX "") ++add_compile_definitions($<$:Py_DEBUG> __TBB_NO_IMPLICIT_LINKAGE) + ######################################################################### + + message(STATUS "----------------------------------------------------") +diff -Naur openvdb-12.0.0/openvdb/openvdb/version.rc.in openvdb/openvdb/openvdb/version.rc.in +--- openvdb-12.0.0/openvdb/openvdb/version.rc.in 1969-12-31 16:00:00.000000000 -0800 ++++ openvdb/openvdb/openvdb/version.rc.in 2024-12-11 08:47:05.697536200 -0800 @@ -0,0 +1,48 @@ +#include + diff --git a/build_files/build_environment/patches/openvdb_1706.diff b/build_files/build_environment/patches/openvdb_1706.diff deleted file mode 100644 index 590a241477a..00000000000 --- a/build_files/build_environment/patches/openvdb_1706.diff +++ /dev/null @@ -1,81 +0,0 @@ -diff --git a/openvdb/openvdb/python/pyGrid.h b/openvdb/openvdb/python/pyGrid.h -index 9249eaf6d..f4c859110 100644 ---- a/openvdb/openvdb/python/pyGrid.h -+++ b/openvdb/openvdb/python/pyGrid.h -@@ -322,7 +322,7 @@ copyToArray(GridType&, const py::object&, py::object) - - #else // if defined(PY_OPENVDB_USE_NUMPY) - --using ArrayDimVec = std::vector; -+using ArrayDimVec = std::vector; - - // ID numbers for supported value types - enum class DtId { NONE, FLOAT, DOUBLE, BOOL, INT16, INT32, INT64, UINT32, UINT64/*, HALF*/ }; -@@ -768,12 +768,12 @@ template - inline typename GridType::Ptr - meshToLevelSet(py::array_t pointsObj, py::array_t trianglesObj, py::array_t quadsObj, math::Transform::Ptr xform, float halfWidth) - { -- auto validate2DArray = [](py::array array, ssize_t N) { -+ auto validate2DArray = [](py::array array, Py_ssize_t N) { - if (array.ndim() != 2 || array.shape(1) != N) { - std::ostringstream os; - os << "Expected a 2-dimensional numpy.ndarray with shape(1) = "<< N; - os << ", found " << array.ndim() << "-dimensional array with shape = ("; -- for (ssize_t i = 0; i < array.ndim(); ++i) { -+ for (Py_ssize_t i = 0; i < array.ndim(); ++i) { - os << array.shape(i); - if (i != array.ndim() - 1) - os << ", "; -@@ -826,12 +826,12 @@ volumeToQuadMesh(const GridType& grid, double isovalue) - std::vector quads; - tools::volumeToMesh(grid, points, quads, isovalue); - -- std::vector shape = { static_cast(points.size()), 3 }; -- std::vector strides = { 3 * static_cast(sizeof(float)), static_cast(sizeof(float))}; -+ std::vector shape = { static_cast(points.size()), 3 }; -+ std::vector strides = { 3 * static_cast(sizeof(float)), static_cast(sizeof(float))}; - py::array_t pointArrayObj(py::buffer_info(points.data(), sizeof(float), py::format_descriptor::format(), 2, shape, strides)); - -- shape = { static_cast(quads.size()), 4 }; -- strides = { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; -+ shape = { static_cast(quads.size()), 4 }; -+ strides = { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; - py::array_t quadArrayObj(py::buffer_info(quads.data(), sizeof(Index32), py::format_descriptor::format(), 2, shape, strides)); - - return std::make_tuple(pointArrayObj, quadArrayObj); -@@ -857,18 +857,18 @@ volumeToMesh(const GridType& grid, double isovalue, double adaptivity) - // Create a deep copy of the array (because the point vector will be destroyed - // when this function returns). - -- std::vector shape = { static_cast(points.size()), 3 }; -- std::vector strides = { 3 * static_cast(sizeof(float)), static_cast(sizeof(float))}; -+ std::vector shape = { static_cast(points.size()), 3 }; -+ std::vector strides = { 3 * static_cast(sizeof(float)), static_cast(sizeof(float))}; - py::buffer_info pointInfo(points.data(), sizeof(float), py::format_descriptor::format(), 2, shape, strides); - py::array_t pointArray(pointInfo); - -- shape = { static_cast(triangles.size()), 3 }; -- strides = { 3 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; -+ shape = { static_cast(triangles.size()), 3 }; -+ strides = { 3 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; - py::buffer_info triangleInfo(triangles.data(), sizeof(Index32), py::format_descriptor::format(), 2, shape, strides); - py::array_t triangleArray(triangleInfo); - -- shape = { static_cast(quads.size()), 4 }; -- strides = { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; -+ shape = { static_cast(quads.size()), 4 }; -+ strides = { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; - py::buffer_info quadInfo(quads.data(), sizeof(Index32), py::format_descriptor::format(), 2, shape, strides); - py::array_t quadArray(quadInfo); - -@@ -1590,8 +1590,8 @@ exportGrid(py::module_ m) - &pyGrid::meshToLevelSet, - py::arg("points"), - #ifdef PY_OPENVDB_USE_NUMPY -- py::arg("triangles")=py::array_t({ 0, 3 }, { 3 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))} ), -- py::arg("quads")=py::array_t({ 0, 4 }, { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))} ), -+ py::arg("triangles")=py::array_t({ 0, 3 }, { 3 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))} ), -+ py::arg("quads")=py::array_t({ 0, 4 }, { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))} ), - #else - py::arg("triangles")=std::vector(), - py::arg("quads")=std::vector(), diff --git a/build_files/build_environment/patches/openvdb_1733.diff b/build_files/build_environment/patches/openvdb_1733.diff deleted file mode 100644 index 13d3f4d7f44..00000000000 --- a/build_files/build_environment/patches/openvdb_1733.diff +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/openvdb/openvdb/math/Half.h b/openvdb/openvdb/math/Half.h -index b8045ba441..ba72b0e6df 100644 ---- a/openvdb/openvdb/math/Half.h -+++ b/openvdb/openvdb/math/Half.h -@@ -342,8 +342,14 @@ imath_half_to_float (imath_half_bits_t h) - // other compilers may provide count-leading-zeros primitives, - // but we need the community to inform us of the variants - uint32_t lc; --# if defined(_MSC_VER) && (_M_IX86 || _M_X64) -- lc = __lzcnt (hexpmant); -+# if defined(_MSC_VER) -+ // The direct intrinsic for this is __lznct, but that is not supported -+ // on older x86_64 hardware or ARM. Instead uses the bsr instruction -+ // and one additional subtraction. This assumes hexpmant != 0, for 0 -+ // bsr and lznct would behave differently. -+ unsigned long bsr; -+ _BitScanReverse (&bsr, hexpmant); -+ lc = (31 - bsr); - # elif defined(__GNUC__) || defined(__clang__) - lc = (uint32_t) __builtin_clz (hexpmant); - # else diff --git a/build_files/build_environment/patches/openvdb_1977.diff b/build_files/build_environment/patches/openvdb_1977.diff new file mode 100644 index 00000000000..d94a9609f62 --- /dev/null +++ b/build_files/build_environment/patches/openvdb_1977.diff @@ -0,0 +1,44 @@ +diff --git a/nanovdb/nanovdb/tools/GridBuilder.h b/nanovdb/nanovdb/tools/GridBuilder.h +index 30385661d0..428215ba65 100644 +--- a/nanovdb/nanovdb/tools/GridBuilder.h ++++ b/nanovdb/nanovdb/tools/GridBuilder.h +@@ -1158,7 +1158,7 @@ struct LeafNode + ValueIterator& operator=(const ValueIterator&) = default; + ValueType operator*() const { NANOVDB_ASSERT(*this); return mParent->mValues[mPos];} + Coord getCoord() const { NANOVDB_ASSERT(*this); return mParent->offsetToGlobalCoord(mPos);} +- bool isActive() const { NANOVDB_ASSERT(*this); return mParent->isActive(mPos);} ++ bool isActive() const { NANOVDB_ASSERT(*this); return mParent->mValueMask.isOn(mPos);} + operator bool() const {return mPos < SIZE;} + ValueIterator& operator++() {++mPos; return *this;} + ValueIterator operator++(int) { +diff --git a/openvdb/openvdb/tree/NodeManager.h b/openvdb/openvdb/tree/NodeManager.h +index 27a3f82012..1023c00748 100644 +--- a/openvdb/openvdb/tree/NodeManager.h ++++ b/openvdb/openvdb/tree/NodeManager.h +@@ -328,7 +328,7 @@ class NodeList + void operator()(const NodeRange& range) const + { + for (typename NodeRange::Iterator it = range.begin(); it; ++it) { +- OpT::template eval(mNodeOp, it); ++ OpT::eval(mNodeOp, it); + } + } + const NodeOp mNodeOp; +@@ -348,7 +348,7 @@ class NodeList + void operator()(const NodeRange& range) const + { + for (typename NodeRange::Iterator it = range.begin(); it; ++it) { +- OpT::template eval(mNodeOp, it); ++ OpT::eval(mNodeOp, it); + } + } + const NodeOp& mNodeOp; +@@ -373,7 +373,7 @@ class NodeList + void operator()(const NodeRange& range) + { + for (typename NodeRange::Iterator it = range.begin(); it; ++it) { +- OpT::template eval(*mNodeOp, it); ++ OpT::eval(*mNodeOp, it); + } + } + void join(const NodeReducer& other) diff --git a/build_files/build_environment/patches/sndfile_1045.diff b/build_files/build_environment/patches/sndfile_1045.diff new file mode 100644 index 00000000000..2587d85bf74 --- /dev/null +++ b/build_files/build_environment/patches/sndfile_1045.diff @@ -0,0 +1,395 @@ +diff --git a/src/ogg.c b/src/ogg.c +index 529941af8..e2d679d41 100644 +--- a/src/ogg.c ++++ b/src/ogg.c +@@ -211,12 +211,16 @@ ogg_read_first_page (SF_PRIVATE *psf, OGG_PRIVATE *odata) + + int + ogg_write_page (SF_PRIVATE *psf, ogg_page *page) +-{ int bytes ; ++{ int n ; + +- bytes = psf_fwrite (page->header, 1, page->header_len, psf) ; +- bytes += psf_fwrite (page->body, 1, page->body_len, psf) ; ++ n = psf_fwrite (page->header, 1, page->header_len, psf) ; ++ if (n == page->header_len) ++ n += psf_fwrite (page->body, 1, page->body_len, psf) ; + +- return bytes == page->header_len + page->body_len ; ++ if (n != page->body_len + page->header_len) ++ return -1 ; ++ ++ return n ; + } /* ogg_write_page */ + + sf_count_t +diff --git a/src/ogg_opus.c b/src/ogg_opus.c +index 511653ecc..e01224b99 100644 +--- a/src/ogg_opus.c ++++ b/src/ogg_opus.c +@@ -827,15 +827,16 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) + + /* The first page MUST only contain the header, so flush it out now */ + ogg_stream_packetin (&odata->ostream, &op) ; +- for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; ) +- { if (! (nn = ogg_write_page (psf, &odata->opage))) ++ while (ogg_stream_flush (&odata->ostream, &odata->opage)) ++ { nn = ogg_write_page (psf, &odata->opage) ; ++ if (nn < 0) + { psf_log_printf (psf, "Opus : Failed to write header!\n") ; + if (psf->error) + return psf->error ; + return SFE_INTERNAL ; + } ; + psf->dataoffset += nn ; +- } ++ } ; + + /* + ** Metadata Tags (manditory) +@@ -850,15 +851,16 @@ ogg_opus_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) + vorbiscomment_write_tags (psf, &op, &opustags_ident, opus_get_version_string (), - (OGG_OPUS_COMMENT_PAD)) ; + op.packetno = 2 ; + ogg_stream_packetin (&odata->ostream, &op) ; +- for ( ; (nn = ogg_stream_flush (&odata->ostream, &odata->opage)) ; ) +- { if (! (nn = ogg_write_page (psf, &odata->opage))) ++ while (ogg_stream_flush (&odata->ostream, &odata->opage)) ++ { nn = ogg_write_page (psf, &odata->opage) ; ++ if (nn < 0) + { psf_log_printf (psf, "Opus : Failed to write comments!\n") ; + if (psf->error) + return psf->error ; + return SFE_INTERNAL ; + } ; + psf->dataoffset += nn ; +- } ++ } ; + + return 0 ; + } /* ogg_opus_write_header */ +@@ -1132,7 +1134,8 @@ ogg_opus_write_out (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) + if (nbytes > 0) + { oopus->u.encode.last_segments -= ogg_page_segments (&odata->opage) ; + oopus->pg_pos = oopus->pkt_pos ; +- ogg_write_page (psf, &odata->opage) ; ++ if (ogg_write_page (psf, &odata->opage) < 0) ++ return -1 ; + } + else + break ; +diff --git a/src/ogg_vorbis.c b/src/ogg_vorbis.c +index add123966..fae252ca0 100644 +--- a/src/ogg_vorbis.c ++++ b/src/ogg_vorbis.c +@@ -82,28 +82,6 @@ + /* How many seconds in the future to not bother bisection searching for. */ + #define VORBIS_SEEK_THRESHOLD 2 + +-typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ; +- +-static int vorbis_read_header (SF_PRIVATE *psf) ; +-static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ; +-static int vorbis_close (SF_PRIVATE *psf) ; +-static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; +-static int vorbis_byterate (SF_PRIVATE *psf) ; +-static int vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) ; +-static int vorbis_skip (SF_PRIVATE *psf, uint64_t target_gp) ; +-static int vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) ; +-static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; +-static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; +-static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; +-static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; +-static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; +-static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; +-static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; +-static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; +-static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; +-static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ; +-static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ; +- + typedef struct + { int id ; + const char *name ; +@@ -145,6 +123,45 @@ typedef struct + sf_count_t last_page ; + } VORBIS_PRIVATE ; + ++typedef int convert_func (SF_PRIVATE *psf, int, void *, int, int, float **) ; ++ ++static int vorbis_read_header (SF_PRIVATE *psf) ; ++static int vorbis_write_header (SF_PRIVATE *psf, int calc_length) ; ++static int vorbis_close (SF_PRIVATE *psf) ; ++static int vorbis_command (SF_PRIVATE *psf, int command, void *data, int datasize) ; ++static int vorbis_byterate (SF_PRIVATE *psf) ; ++static int vorbis_calculate_granulepos (SF_PRIVATE *psf, uint64_t *gp_out) ; ++static int vorbis_skip (SF_PRIVATE *psf, uint64_t target_gp) ; ++static int vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) ; ++static sf_count_t vorbis_seek (SF_PRIVATE *psf, int mode, sf_count_t offset) ; ++static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ; ++static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ; ++static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ; ++static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ; ++static sf_count_t vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ; ++static sf_count_t vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ; ++static sf_count_t vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ; ++static sf_count_t vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ; ++static sf_count_t vorbis_read_sample (SF_PRIVATE *psf, void *ptr, sf_count_t lens, convert_func *transfn) ; ++static int vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) ; ++static int vorbis_rnull (SF_PRIVATE *psf, int samples, void *vptr, int off , int channels, float **pcm) ; ++static void vorbis_log_error (SF_PRIVATE *psf, int error) ; ++ ++ ++static void ++vorbis_log_error(SF_PRIVATE *psf, int error) { ++ switch (error) ++ { case 0: return; ++ case OV_EIMPL: psf->error = SFE_UNIMPLEMENTED ; break ; ++ case OV_ENOTVORBIS: psf->error = SFE_MALFORMED_FILE ; break ; ++ case OV_EBADHEADER: psf->error = SFE_MALFORMED_FILE ; break ; ++ case OV_EVERSION: psf->error = SFE_UNSUPPORTED_ENCODING ; break ; ++ case OV_EFAULT: ++ case OV_EINVAL: ++ default: psf->error = SFE_INTERNAL ; ++ } ; ++} ; ++ + static int + vorbis_read_header (SF_PRIVATE *psf) + { OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; +@@ -380,7 +397,6 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) + { ogg_packet header ; + ogg_packet header_comm ; + ogg_packet header_code ; +- int result ; + + vorbis_analysis_headerout (&vdata->vdsp, &vdata->vcomment, &header, &header_comm, &header_code) ; + ogg_stream_packetin (&odata->ostream, &header) ; /* automatically placed in its own page */ +@@ -390,9 +406,9 @@ vorbis_write_header (SF_PRIVATE *psf, int UNUSED (calc_length)) + /* This ensures the actual + * audio data will start on a new page, as per spec + */ +- while ((result = ogg_stream_flush (&odata->ostream, &odata->opage)) != 0) +- { ogg_write_page (psf, &odata->opage) ; +- } ; ++ while (ogg_stream_flush (&odata->ostream, &odata->opage)) ++ if (ogg_write_page (psf, &odata->opage) < 0) ++ return -1 ; + } + + return 0 ; +@@ -402,6 +418,7 @@ static int + vorbis_close (SF_PRIVATE *psf) + { OGG_PRIVATE* odata = psf->container_data ; + VORBIS_PRIVATE *vdata = psf->codec_data ; ++ int ret = 0 ; + + if (odata == NULL || vdata == NULL) + return 0 ; +@@ -412,34 +429,14 @@ vorbis_close (SF_PRIVATE *psf) + if (psf->file.mode == SFM_WRITE) + { + if (psf->write_current <= 0) +- vorbis_write_header (psf, 0) ; +- +- vorbis_analysis_wrote (&vdata->vdsp, 0) ; +- while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1) +- { ++ ret = vorbis_write_header (psf, 0) ; + +- /* analysis, assume we want to use bitrate management */ +- vorbis_analysis (&vdata->vblock, NULL) ; +- vorbis_bitrate_addblock (&vdata->vblock) ; +- +- while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) +- { /* weld the packet into the bitstream */ +- ogg_stream_packetin (&odata->ostream, &odata->opacket) ; +- +- /* write out pages (if any) */ +- while (!odata->eos) +- { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ; +- if (result == 0) break ; +- ogg_write_page (psf, &odata->opage) ; +- +- /* this could be set above, but for illustrative purposes, I do +- it here (to show that vorbis does know where the stream ends) */ +- +- if (ogg_page_eos (&odata->opage)) odata->eos = 1 ; +- } +- } +- } +- } ++ if (ret == 0) ++ { /* A write of zero samples tells Vorbis the stream is done and to ++ flush. */ ++ ret = vorbis_write_samples (psf, odata, vdata, 0) ; ++ } ; ++ } ; + + /* ogg_page and ogg_packet structs always point to storage in + libvorbis. They are never freed or manipulated directly */ +@@ -449,7 +446,7 @@ vorbis_close (SF_PRIVATE *psf) + vorbis_comment_clear (&vdata->vcomment) ; + vorbis_info_clear (&vdata->vinfo) ; + +- return 0 ; ++ return ret ; + } /* vorbis_close */ + + int +@@ -688,33 +685,40 @@ vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens) + /*============================================================================== + */ + +-static void ++static int + vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata, int in_frames) +-{ +- vorbis_analysis_wrote (&vdata->vdsp, in_frames) ; ++{ int ret ; ++ ++ if ((ret = vorbis_analysis_wrote (&vdata->vdsp, in_frames)) != 0) ++ return ret ; + + /* + ** Vorbis does some data preanalysis, then divvies up blocks for + ** more involved (potentially parallel) processing. Get a single + ** block for encoding now. + */ +- while (vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock) == 1) ++ while ((ret = vorbis_analysis_blockout (&vdata->vdsp, &vdata->vblock)) == 1) + { + /* analysis, assume we want to use bitrate management */ +- vorbis_analysis (&vdata->vblock, NULL) ; +- vorbis_bitrate_addblock (&vdata->vblock) ; ++ if ((ret = vorbis_analysis (&vdata->vblock, NULL)) != 0) ++ return ret ; ++ if ((ret = vorbis_bitrate_addblock (&vdata->vblock)) != 0) ++ return ret ; + +- while (vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) ++ while ((ret = vorbis_bitrate_flushpacket (&vdata->vdsp, &odata->opacket)) == 1) + { + /* weld the packet into the bitstream */ +- ogg_stream_packetin (&odata->ostream, &odata->opacket) ; ++ if ((ret = ogg_stream_packetin (&odata->ostream, &odata->opacket)) != 0) ++ return ret ; + + /* write out pages (if any) */ + while (!odata->eos) +- { int result = ogg_stream_pageout (&odata->ostream, &odata->opage) ; +- if (result == 0) ++ { ret = ogg_stream_pageout (&odata->ostream, &odata->opage) ; ++ if (ret == 0) + break ; +- ogg_write_page (psf, &odata->opage) ; ++ ++ if (ogg_write_page (psf, &odata->opage) < 0) ++ return -1 ; + + /* This could be set above, but for illustrative purposes, I do + ** it here (to show that vorbis does know where the stream ends) */ +@@ -722,16 +726,22 @@ vorbis_write_samples (SF_PRIVATE *psf, OGG_PRIVATE *odata, VORBIS_PRIVATE *vdata + odata->eos = 1 ; + } ; + } ; ++ if (ret != 0) ++ return ret ; + } ; ++ if (ret != 0) ++ return ret ; + + vdata->gp += in_frames ; ++ ++ return 0 ; + } /* vorbis_write_data */ + + + static sf_count_t + vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens) + { +- int i, m, j = 0 ; ++ int i, m, j = 0, ret ; + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int in_frames = lens / psf->sf.channels ; +@@ -740,14 +750,17 @@ vorbis_write_s (SF_PRIVATE *psf, const short *ptr, sf_count_t lens) + for (m = 0 ; m < psf->sf.channels ; m++) + buffer [m][i] = (float) (ptr [j++]) / 32767.0f ; + +- vorbis_write_samples (psf, odata, vdata, in_frames) ; ++ if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames))) ++ { vorbis_log_error (psf, ret) ; ++ return 0 ; ++ } ; + + return lens ; + } /* vorbis_write_s */ + + static sf_count_t + vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens) +-{ int i, m, j = 0 ; ++{ int i, m, j = 0, ret ; + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int in_frames = lens / psf->sf.channels ; +@@ -756,14 +769,17 @@ vorbis_write_i (SF_PRIVATE *psf, const int *ptr, sf_count_t lens) + for (m = 0 ; m < psf->sf.channels ; m++) + buffer [m][i] = (float) (ptr [j++]) / 2147483647.0f ; + +- vorbis_write_samples (psf, odata, vdata, in_frames) ; ++ if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames))) ++ { vorbis_log_error (psf, ret) ; ++ return 0 ; ++ } ; + + return lens ; + } /* vorbis_write_i */ + + static sf_count_t + vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens) +-{ int i, m, j = 0 ; ++{ int i, m, j = 0, ret ; + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int in_frames = lens / psf->sf.channels ; +@@ -772,14 +788,17 @@ vorbis_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t lens) + for (m = 0 ; m < psf->sf.channels ; m++) + buffer [m][i] = ptr [j++] ; + +- vorbis_write_samples (psf, odata, vdata, in_frames) ; ++ if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0) ++ { vorbis_log_error (psf, ret) ; ++ return 0 ; ++ } ; + + return lens ; + } /* vorbis_write_f */ + + static sf_count_t + vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens) +-{ int i, m, j = 0 ; ++{ int i, m, j = 0, ret ; + OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; + VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; + int in_frames = lens / psf->sf.channels ; +@@ -788,7 +807,10 @@ vorbis_write_d (SF_PRIVATE *psf, const double *ptr, sf_count_t lens) + for (m = 0 ; m < psf->sf.channels ; m++) + buffer [m][i] = (float) ptr [j++] ; + +- vorbis_write_samples (psf, odata, vdata, in_frames) ; ++ if ((ret = vorbis_write_samples (psf, odata, vdata, in_frames)) != 0) ++ { vorbis_log_error (psf, ret) ; ++ return 0 ; ++ } ; + + return lens ; + } /* vorbis_write_d */ +@@ -884,7 +906,7 @@ vorbis_seek_trysearch (SF_PRIVATE *psf, uint64_t target_gp) + return 0 ; + + /* Search for a position a half large-block before our target. As Vorbis is +- ** lapped, every sample position come from two blocks, the "left" half of ++ ** lapped, every sample position comes from two blocks, the "left" half of + ** one block and the "right" half of the previous block. The granule + ** position of an Ogg page of a Vorbis stream is the sample offset of the + ** last finished sample in the stream that can be decoded from a page. A diff --git a/build_files/build_environment/patches/tbb.diff b/build_files/build_environment/patches/tbb.diff deleted file mode 100644 index 72c53356abf..00000000000 --- a/build_files/build_environment/patches/tbb.diff +++ /dev/null @@ -1,637 +0,0 @@ -diff --git a/include/tbb/machine/msvc_armv8.h b/include/tbb/machine/msvc_armv8.h -new file mode 100644 -index 00000000..13d56678 ---- /dev/null -+++ b/include/tbb/machine/msvc_armv8.h -@@ -0,0 +1,167 @@ -+/* -+ Copyright (c) 2005-2020 Intel Corporation -+ -+ Licensed under the Apache License, Version 2.0 (the "License"); -+ you may not use this file except in compliance with the License. -+ You may obtain a copy of the License at -+ -+ http://www.apache.org/licenses/LICENSE-2.0 -+ -+ Unless required by applicable law or agreed to in writing, software -+ distributed under the License is distributed on an "AS IS" BASIS, -+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+ See the License for the specific language governing permissions and -+ limitations under the License. -+*/ -+ -+#if !defined(__TBB_machine_H) || defined(__TBB_msvc_armv8_H) -+#error Do not #include this internal file directly; use public TBB headers instead. -+#endif -+ -+#define __TBB_msvc_armv8_H -+ -+#include -+#include -+ -+#define __TBB_WORDSIZE 8 -+ -+#define __TBB_ENDIANNESS __TBB_ENDIAN_UNSUPPORTED -+ -+#if defined(TBB_WIN32_USE_CL_BUILTINS) -+// We can test this on _M_IX86 -+#pragma intrinsic(_ReadWriteBarrier) -+#pragma intrinsic(_mm_mfence) -+#define __TBB_compiler_fence() _ReadWriteBarrier() -+#define __TBB_full_memory_fence() _mm_mfence() -+#define __TBB_control_consistency_helper() __TBB_compiler_fence() -+#define __TBB_acquire_consistency_helper() __TBB_compiler_fence() -+#define __TBB_release_consistency_helper() __TBB_compiler_fence() -+#else -+//Now __dmb(_ARM_BARRIER_SY) is used for both compiler and memory fences -+//This might be changed later after testing -+#define __TBB_compiler_fence() __dmb(_ARM64_BARRIER_SY) -+#define __TBB_full_memory_fence() __dmb(_ARM64_BARRIER_SY) -+#define __TBB_control_consistency_helper() __TBB_compiler_fence() -+#define __TBB_acquire_consistency_helper() __TBB_full_memory_fence() -+#define __TBB_release_consistency_helper() __TBB_full_memory_fence() -+#endif -+ -+//-------------------------------------------------- -+// Compare and swap -+//-------------------------------------------------- -+ -+/** -+ * Atomic CAS for 32 bit values, if *ptr==comparand, then *ptr=value, returns *ptr -+ * @param ptr pointer to value in memory to be swapped with value if *ptr==comparand -+ * @param value value to assign *ptr to if *ptr==comparand -+ * @param comparand value to compare with *ptr -+ * @return value originally in memory at ptr, regardless of success -+*/ -+ -+#define __TBB_MACHINE_DEFINE_ATOMICS_CMPSWP(S,T,F) \ -+inline T __TBB_machine_cmpswp##S( volatile void *ptr, T value, T comparand ) { \ -+ return _InterlockedCompareExchange##F(reinterpret_cast(ptr),value,comparand); \ -+} \ -+ -+#define __TBB_MACHINE_DEFINE_ATOMICS_FETCHADD(S,T,F) \ -+inline T __TBB_machine_fetchadd##S( volatile void *ptr, T value ) { \ -+ return _InterlockedExchangeAdd##F(reinterpret_cast(ptr),value); \ -+} \ -+ -+__TBB_MACHINE_DEFINE_ATOMICS_CMPSWP(1,char,8) -+__TBB_MACHINE_DEFINE_ATOMICS_CMPSWP(2,short,16) -+__TBB_MACHINE_DEFINE_ATOMICS_CMPSWP(4,long,) -+__TBB_MACHINE_DEFINE_ATOMICS_CMPSWP(8,__int64,64) -+__TBB_MACHINE_DEFINE_ATOMICS_FETCHADD(4,long,) -+#if defined(TBB_WIN32_USE_CL_BUILTINS) -+// No _InterlockedExchangeAdd64 intrinsic on _M_IX86 -+#define __TBB_64BIT_ATOMICS 0 -+#else -+__TBB_MACHINE_DEFINE_ATOMICS_FETCHADD(8,__int64,64) -+#endif -+ -+inline void __TBB_machine_pause (int32_t delay ) -+{ -+ while(delay>0) -+ { -+ __TBB_compiler_fence(); -+ delay--; -+ } -+} -+ -+// API to retrieve/update FPU control setting -+#define __TBB_CPU_CTL_ENV_PRESENT 1 -+ -+namespace tbb { -+namespace internal { -+ -+template -+struct machine_load_store_relaxed { -+ static inline T load ( const volatile T& location ) { -+ const T value = location; -+ -+ /* -+ * An extra memory barrier is required for errata #761319 -+ * Please see http://infocenter.arm.com/help/topic/com.arm.doc.uan0004a -+ */ -+ __TBB_acquire_consistency_helper(); -+ return value; -+ } -+ -+ static inline void store ( volatile T& location, T value ) { -+ location = value; -+ } -+}; -+ -+class cpu_ctl_env { -+private: -+ unsigned int my_ctl; -+public: -+ bool operator!=( const cpu_ctl_env& ctl ) const { return my_ctl != ctl.my_ctl; } -+ void get_env() { my_ctl = _control87(0, 0); } -+ void set_env() const { _control87( my_ctl, ~0U ); } -+}; -+ -+} // namespace internal -+} // namespaces tbb -+ -+// Machine specific atomic operations -+#define __TBB_CompareAndSwap4(P,V,C) __TBB_machine_cmpswp4(P,V,C) -+#define __TBB_CompareAndSwap8(P,V,C) __TBB_machine_cmpswp8(P,V,C) -+#define __TBB_Pause(V) __TBB_machine_pause(V) -+ -+// Use generics for some things -+#define __TBB_USE_FETCHSTORE_AS_FULL_FENCED_STORE 1 -+#define __TBB_USE_GENERIC_HALF_FENCED_LOAD_STORE 1 -+#define __TBB_USE_GENERIC_PART_WORD_FETCH_ADD 1 -+#define __TBB_USE_GENERIC_PART_WORD_FETCH_STORE 1 -+#define __TBB_USE_GENERIC_FETCH_STORE 1 -+#define __TBB_USE_GENERIC_DWORD_LOAD_STORE 0 -+#define __TBB_USE_GENERIC_SEQUENTIAL_CONSISTENCY_LOAD_STORE 1 -+ -+#if defined(TBB_WIN32_USE_CL_BUILTINS) -+#if !__TBB_WIN8UI_SUPPORT -+extern "C" __declspec(dllimport) int __stdcall SwitchToThread( void ); -+#define __TBB_Yield() SwitchToThread() -+#else -+#include -+#define __TBB_Yield() std::this_thread::yield() -+#endif -+#else -+#define __TBB_Yield() __yield() -+#endif -+ -+// Machine specific atomic operations -+#define __TBB_AtomicOR(P,V) __TBB_machine_OR(P,V) -+#define __TBB_AtomicAND(P,V) __TBB_machine_AND(P,V) -+ -+template -+inline void __TBB_machine_OR( T1 *operand, T2 addend ) { -+ _InterlockedOr((long volatile *)operand, (long)addend); -+} -+ -+template -+inline void __TBB_machine_AND( T1 *operand, T2 addend ) { -+ _InterlockedAnd((long volatile *)operand, (long)addend); -+} -+ -diff --git a/include/tbb/tbb_config.h b/include/tbb/tbb_config.h -index 7a8d06a0..80b4e3a6 100644 ---- a/include/tbb/tbb_config.h -+++ b/include/tbb/tbb_config.h -@@ -209,10 +209,10 @@ - #elif __clang__ - /** TODO: these options need to be rechecked **/ - #define __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT __has_feature(__cxx_variadic_templates__) -- #define __TBB_CPP11_RVALUE_REF_PRESENT (__has_feature(__cxx_rvalue_references__) && (_LIBCPP_VERSION || __TBB_GLIBCXX_VERSION >= 40500)) -+ #define __TBB_CPP11_RVALUE_REF_PRESENT (__has_feature(__cxx_rvalue_references__) && (_LIBCPP_VERSION || __TBB_GLIBCXX_VERSION >= 40500 || _MSC_VER >= 1700)) - #define __TBB_IMPLICIT_MOVE_PRESENT __has_feature(cxx_implicit_moves) - /** TODO: extend exception_ptr related conditions to cover libstdc++ **/ -- #define __TBB_EXCEPTION_PTR_PRESENT (__cplusplus >= 201103L && (_LIBCPP_VERSION || __TBB_GLIBCXX_VERSION >= 40600)) -+ #define __TBB_EXCEPTION_PTR_PRESENT (__cplusplus >= 201103L && (_LIBCPP_VERSION || __TBB_GLIBCXX_VERSION >= 40600 || _MSC_VER >= 1600)) - #define __TBB_STATIC_ASSERT_PRESENT __has_feature(__cxx_static_assert__) - #if (__cplusplus >= 201103L && __has_include()) - #define __TBB_CPP11_TUPLE_PRESENT 1 -diff --git a/include/tbb/tbb_machine.h b/include/tbb/tbb_machine.h -index 9752be58..ebb98ec2 100644 ---- a/include/tbb/tbb_machine.h -+++ b/include/tbb/tbb_machine.h -@@ -208,6 +208,8 @@ template<> struct atomic_selector<8> { - #include "machine/windows_intel64.h" - #elif defined(_M_ARM) || defined(__TBB_WIN32_USE_CL_BUILTINS) - #include "machine/msvc_armv7.h" -+ #elif defined(_M_ARM64) -+ #include "machine/msvc_armv8.h" - #endif - - #ifdef _MANAGED -diff --git a/src/tbb/tools_api/ittnotify_config.h b/src/tbb/tools_api/ittnotify_config.h -index bdb4ec29..7c363f4f 100644 ---- a/src/tbb/tools_api/ittnotify_config.h -+++ b/src/tbb/tools_api/ittnotify_config.h -@@ -162,7 +162,7 @@ - # define ITT_ARCH ITT_ARCH_IA32E - # elif defined _M_IA64 || defined __ia64__ - # define ITT_ARCH ITT_ARCH_IA64 --# elif defined _M_ARM || defined __arm__ -+# elif defined _M_ARM || defined _M_ARM64 || defined __arm__ || defined __arm64__ - # define ITT_ARCH ITT_ARCH_ARM - # elif defined __powerpc64__ - # define ITT_ARCH ITT_ARCH_PPC64 -diff --git a/src/tbb/winarm64-tbb-export.def b/src/tbb/winarm64-tbb-export.def -new file mode 100644 -index 00000000..813eb002 ---- /dev/null -+++ b/src/tbb/winarm64-tbb-export.def -@@ -0,0 +1,21 @@ -+; Copyright (c) 2005-2020 Intel Corporation -+; Copyright (c) 2022 Linaro Ltd. -+; -+; Licensed under the Apache License, Version 2.0 (the "License"); -+; you may not use this file except in compliance with the License. -+; You may obtain a copy of the License at -+; -+; http://www.apache.org/licenses/LICENSE-2.0 -+; -+; Unless required by applicable law or agreed to in writing, software -+; distributed under the License is distributed on an "AS IS" BASIS, -+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+; See the License for the specific language governing permissions and -+; limitations under the License. -+ -+EXPORTS -+ -+#define __TBB_SYMBOL( sym ) sym -+#include "winarm64-tbb-export.lst" -+ -+ -diff --git a/src/tbb/winarm64-tbb-export.lst b/src/tbb/winarm64-tbb-export.lst -new file mode 100644 -index 00000000..a25d545e ---- /dev/null -+++ b/src/tbb/winarm64-tbb-export.lst -@@ -0,0 +1,310 @@ -+; Copyright (c) 2005-2020 Intel Corporation -+; -+; Licensed under the Apache License, Version 2.0 (the "License"); -+; you may not use this file except in compliance with the License. -+; You may obtain a copy of the License at -+; -+; http://www.apache.org/licenses/LICENSE-2.0 -+; -+; Unless required by applicable law or agreed to in writing, software -+; distributed under the License is distributed on an "AS IS" BASIS, -+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+; See the License for the specific language governing permissions and -+; limitations under the License. -+ -+#include "tbb/tbb_config.h" -+ -+// cache_aligned_allocator.cpp -+__TBB_SYMBOL( ?NFS_Allocate@internal@tbb@@YAPEAX_K0PEAX@Z ) -+__TBB_SYMBOL( ?NFS_GetLineSize@internal@tbb@@YA_KXZ ) -+__TBB_SYMBOL( ?NFS_Free@internal@tbb@@YAXPEAX@Z ) -+__TBB_SYMBOL( ?allocate_via_handler_v3@internal@tbb@@YAPEAX_K@Z ) -+__TBB_SYMBOL( ?deallocate_via_handler_v3@internal@tbb@@YAXPEAX@Z ) -+__TBB_SYMBOL( ?is_malloc_used_v3@internal@tbb@@YA_NXZ ) -+ -+// task.cpp v3 -+__TBB_SYMBOL( ?allocate@allocate_additional_child_of_proxy@internal@tbb@@QEBAAEAVtask@3@_K@Z ) -+__TBB_SYMBOL( ?allocate@allocate_child_proxy@internal@tbb@@QEBAAEAVtask@3@_K@Z ) -+__TBB_SYMBOL( ?allocate@allocate_continuation_proxy@internal@tbb@@QEBAAEAVtask@3@_K@Z ) -+__TBB_SYMBOL( ?allocate@allocate_root_proxy@internal@tbb@@SAAEAVtask@3@_K@Z ) -+__TBB_SYMBOL( ?destroy@task_base@internal@interface5@tbb@@SAXAEAVtask@4@@Z ) -+__TBB_SYMBOL( ?free@allocate_additional_child_of_proxy@internal@tbb@@QEBAXAEAVtask@3@@Z ) -+__TBB_SYMBOL( ?free@allocate_child_proxy@internal@tbb@@QEBAXAEAVtask@3@@Z ) -+__TBB_SYMBOL( ?free@allocate_continuation_proxy@internal@tbb@@QEBAXAEAVtask@3@@Z ) -+__TBB_SYMBOL( ?free@allocate_root_proxy@internal@tbb@@SAXAEAVtask@3@@Z ) -+__TBB_SYMBOL( ?internal_set_ref_count@task@tbb@@AEAAXH@Z ) -+__TBB_SYMBOL( ?internal_decrement_ref_count@task@tbb@@AEAA_JXZ ) -+__TBB_SYMBOL( ?is_owned_by_current_thread@task@tbb@@QEBA_NXZ ) -+__TBB_SYMBOL( ?note_affinity@task@tbb@@UEAAXG@Z ) -+__TBB_SYMBOL( ?resize@affinity_partitioner_base_v3@internal@tbb@@AEAAXI@Z ) -+__TBB_SYMBOL( ?self@task@tbb@@SAAEAV12@XZ ) -+__TBB_SYMBOL( ?spawn_and_wait_for_all@task@tbb@@QEAAXAEAVtask_list@2@@Z ) -+__TBB_SYMBOL( ?default_num_threads@task_scheduler_init@tbb@@SAHXZ ) -+__TBB_SYMBOL( ?initialize@task_scheduler_init@tbb@@QEAAXH_K@Z ) -+__TBB_SYMBOL( ?initialize@task_scheduler_init@tbb@@QEAAXH@Z ) -+__TBB_SYMBOL( ?terminate@task_scheduler_init@tbb@@QEAAXXZ ) -+#if __TBB_SCHEDULER_OBSERVER -+__TBB_SYMBOL( ?observe@task_scheduler_observer_v3@internal@tbb@@QEAAX_N@Z ) -+#endif /* __TBB_SCHEDULER_OBSERVER */ -+ -+/* arena.cpp */ -+__TBB_SYMBOL( ?internal_max_concurrency@task_arena_base@internal@interface7@tbb@@KAHPEBVtask_arena@34@@Z ) -+__TBB_SYMBOL( ?internal_current_slot@task_arena_base@internal@interface7@tbb@@KAHXZ ) -+__TBB_SYMBOL( ?internal_initialize@task_arena_base@internal@interface7@tbb@@IEAAXXZ ) -+__TBB_SYMBOL( ?internal_terminate@task_arena_base@internal@interface7@tbb@@IEAAXXZ ) -+__TBB_SYMBOL( ?internal_attach@task_arena_base@internal@interface7@tbb@@IEAAXXZ ) -+__TBB_SYMBOL( ?internal_enqueue@task_arena_base@internal@interface7@tbb@@IEBAXAEAVtask@4@_J@Z ) -+__TBB_SYMBOL( ?internal_execute@task_arena_base@internal@interface7@tbb@@IEBAXAEAVdelegate_base@234@@Z ) -+__TBB_SYMBOL( ?internal_wait@task_arena_base@internal@interface7@tbb@@IEBAXXZ ) -+#if __TBB_TASK_ISOLATION -+__TBB_SYMBOL( ?isolate_within_arena@internal@interface7@tbb@@YAXAEAVdelegate_base@123@_J@Z ) -+#endif /* __TBB_TASK_ISOLATION */ -+ -+#if !TBB_NO_LEGACY -+// task_v2.cpp -+__TBB_SYMBOL( ?destroy@task@tbb@@QEAAXAEAV12@@Z ) -+#endif -+ -+// exception handling support -+#if __TBB_TASK_GROUP_CONTEXT -+__TBB_SYMBOL( ?allocate@allocate_root_with_context_proxy@internal@tbb@@QEBAAEAVtask@3@_K@Z ) -+__TBB_SYMBOL( ?free@allocate_root_with_context_proxy@internal@tbb@@QEBAXAEAVtask@3@@Z ) -+__TBB_SYMBOL( ?change_group@task@tbb@@QEAAXAEAVtask_group_context@2@@Z ) -+__TBB_SYMBOL( ?is_group_execution_cancelled@task_group_context@tbb@@QEBA_NXZ ) -+__TBB_SYMBOL( ?cancel_group_execution@task_group_context@tbb@@QEAA_NXZ ) -+__TBB_SYMBOL( ?reset@task_group_context@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?capture_fp_settings@task_group_context@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?init@task_group_context@tbb@@IEAAXXZ ) -+__TBB_SYMBOL( ?register_pending_exception@task_group_context@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ??1task_group_context@tbb@@QEAA@XZ ) -+#if __TBB_TASK_PRIORITY -+__TBB_SYMBOL( ?set_priority@task_group_context@tbb@@QEAAXW4priority_t@2@@Z ) -+__TBB_SYMBOL( ?priority@task_group_context@tbb@@QEBA?AW4priority_t@2@XZ ) -+#endif /* __TBB_TASK_PRIORITY */ -+__TBB_SYMBOL( ?name@captured_exception@tbb@@UEBAPEBDXZ ) -+__TBB_SYMBOL( ?what@captured_exception@tbb@@UEBAPEBDXZ ) -+__TBB_SYMBOL( ??1captured_exception@tbb@@UEAA@XZ ) -+__TBB_SYMBOL( ?move@captured_exception@tbb@@UEAAPEAV12@XZ ) -+__TBB_SYMBOL( ?destroy@captured_exception@tbb@@UEAAXXZ ) -+__TBB_SYMBOL( ?set@captured_exception@tbb@@QEAAXPEBD0@Z ) -+__TBB_SYMBOL( ?clear@captured_exception@tbb@@QEAAXXZ ) -+#endif /* __TBB_TASK_GROUP_CONTEXT */ -+ -+// Symbols for exceptions thrown from TBB -+__TBB_SYMBOL( ?throw_bad_last_alloc_exception_v4@internal@tbb@@YAXXZ ) -+__TBB_SYMBOL( ?throw_exception_v4@internal@tbb@@YAXW4exception_id@12@@Z ) -+__TBB_SYMBOL( ?what@bad_last_alloc@tbb@@UEBAPEBDXZ ) -+__TBB_SYMBOL( ?what@missing_wait@tbb@@UEBAPEBDXZ ) -+__TBB_SYMBOL( ?what@invalid_multiple_scheduling@tbb@@UEBAPEBDXZ ) -+__TBB_SYMBOL( ?what@improper_lock@tbb@@UEBAPEBDXZ ) -+__TBB_SYMBOL( ?what@user_abort@tbb@@UEBAPEBDXZ ) -+ -+// tbb_misc.cpp -+__TBB_SYMBOL( ?assertion_failure@tbb@@YAXPEBDH00@Z ) -+__TBB_SYMBOL( ?get_initial_auto_partitioner_divisor@internal@tbb@@YA_KXZ ) -+__TBB_SYMBOL( ?handle_perror@internal@tbb@@YAXHPEBD@Z ) -+__TBB_SYMBOL( ?set_assertion_handler@tbb@@YAP6AXPEBDH00@ZP6AX0H00@Z@Z ) -+__TBB_SYMBOL( ?runtime_warning@internal@tbb@@YAXPEBDZZ ) -+__TBB_SYMBOL( TBB_runtime_interface_version ) -+ -+// tbb_main.cpp -+__TBB_SYMBOL( ?itt_load_pointer_with_acquire_v3@internal@tbb@@YAPEAXPEBX@Z ) -+__TBB_SYMBOL( ?itt_store_pointer_with_release_v3@internal@tbb@@YAXPEAX0@Z ) -+__TBB_SYMBOL( ?call_itt_notify_v5@internal@tbb@@YAXHPEAX@Z ) -+__TBB_SYMBOL( ?itt_set_sync_name_v3@internal@tbb@@YAXPEAXPEB_W@Z ) -+__TBB_SYMBOL( ?itt_load_pointer_v3@internal@tbb@@YAPEAXPEBX@Z ) -+__TBB_SYMBOL( ?itt_make_task_group_v7@internal@tbb@@YAXW4itt_domain_enum@12@PEAX_K12W4string_index@12@@Z ) -+__TBB_SYMBOL( ?itt_metadata_str_add_v7@internal@tbb@@YAXW4itt_domain_enum@12@PEAX_KW4string_index@12@PEBD@Z ) -+__TBB_SYMBOL( ?itt_relation_add_v7@internal@tbb@@YAXW4itt_domain_enum@12@PEAX_KW4itt_relation@12@12@Z ) -+__TBB_SYMBOL( ?itt_task_begin_v7@internal@tbb@@YAXW4itt_domain_enum@12@PEAX_K12W4string_index@12@@Z ) -+__TBB_SYMBOL( ?itt_task_end_v7@internal@tbb@@YAXW4itt_domain_enum@12@@Z ) -+__TBB_SYMBOL( ?itt_region_begin_v9@internal@tbb@@YAXW4itt_domain_enum@12@PEAX_K12W4string_index@12@@Z ) -+__TBB_SYMBOL( ?itt_region_end_v9@internal@tbb@@YAXW4itt_domain_enum@12@PEAX_K@Z ) -+ -+ -+// pipeline.cpp -+__TBB_SYMBOL( ??0pipeline@tbb@@QEAA@XZ ) -+__TBB_SYMBOL( ??1filter@tbb@@UEAA@XZ ) -+__TBB_SYMBOL( ??1pipeline@tbb@@UEAA@XZ ) -+__TBB_SYMBOL( ??_7pipeline@tbb@@6B@ ) -+__TBB_SYMBOL( ?add_filter@pipeline@tbb@@QEAAXAEAVfilter@2@@Z ) -+__TBB_SYMBOL( ?clear@pipeline@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?inject_token@pipeline@tbb@@AEAAXAEAVtask@2@@Z ) -+__TBB_SYMBOL( ?run@pipeline@tbb@@QEAAX_K@Z ) -+#if __TBB_TASK_GROUP_CONTEXT -+__TBB_SYMBOL( ?run@pipeline@tbb@@QEAAX_KAEAVtask_group_context@2@@Z ) -+#endif -+__TBB_SYMBOL( ?process_item@thread_bound_filter@tbb@@QEAA?AW4result_type@12@XZ ) -+__TBB_SYMBOL( ?try_process_item@thread_bound_filter@tbb@@QEAA?AW4result_type@12@XZ ) -+__TBB_SYMBOL( ?set_end_of_input@filter@tbb@@IEAAXXZ ) -+ -+// queuing_rw_mutex.cpp -+__TBB_SYMBOL( ?internal_construct@queuing_rw_mutex@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?acquire@scoped_lock@queuing_rw_mutex@tbb@@QEAAXAEAV23@_N@Z ) -+__TBB_SYMBOL( ?downgrade_to_reader@scoped_lock@queuing_rw_mutex@tbb@@QEAA_NXZ ) -+__TBB_SYMBOL( ?release@scoped_lock@queuing_rw_mutex@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?upgrade_to_writer@scoped_lock@queuing_rw_mutex@tbb@@QEAA_NXZ ) -+__TBB_SYMBOL( ?try_acquire@scoped_lock@queuing_rw_mutex@tbb@@QEAA_NAEAV23@_N@Z ) -+ -+// reader_writer_lock.cpp -+__TBB_SYMBOL( ?try_lock_read@reader_writer_lock@interface5@tbb@@QEAA_NXZ ) -+__TBB_SYMBOL( ?try_lock@reader_writer_lock@interface5@tbb@@QEAA_NXZ ) -+__TBB_SYMBOL( ?unlock@reader_writer_lock@interface5@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?lock_read@reader_writer_lock@interface5@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?lock@reader_writer_lock@interface5@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?internal_construct@reader_writer_lock@interface5@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_destroy@reader_writer_lock@interface5@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_construct@scoped_lock@reader_writer_lock@interface5@tbb@@AEAAXAEAV234@@Z ) -+__TBB_SYMBOL( ?internal_destroy@scoped_lock@reader_writer_lock@interface5@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_construct@scoped_lock_read@reader_writer_lock@interface5@tbb@@AEAAXAEAV234@@Z ) -+__TBB_SYMBOL( ?internal_destroy@scoped_lock_read@reader_writer_lock@interface5@tbb@@AEAAXXZ ) -+ -+#if !TBB_NO_LEGACY -+// spin_rw_mutex.cpp v2 -+__TBB_SYMBOL( ?internal_acquire_reader@spin_rw_mutex@tbb@@CAXPEAV12@@Z ) -+__TBB_SYMBOL( ?internal_acquire_writer@spin_rw_mutex@tbb@@CA_NPEAV12@@Z ) -+__TBB_SYMBOL( ?internal_downgrade@spin_rw_mutex@tbb@@CAXPEAV12@@Z ) -+__TBB_SYMBOL( ?internal_itt_releasing@spin_rw_mutex@tbb@@CAXPEAV12@@Z ) -+__TBB_SYMBOL( ?internal_release_reader@spin_rw_mutex@tbb@@CAXPEAV12@@Z ) -+__TBB_SYMBOL( ?internal_release_writer@spin_rw_mutex@tbb@@CAXPEAV12@@Z ) -+__TBB_SYMBOL( ?internal_upgrade@spin_rw_mutex@tbb@@CA_NPEAV12@@Z ) -+__TBB_SYMBOL( ?internal_try_acquire_writer@spin_rw_mutex@tbb@@CA_NPEAV12@@Z ) -+__TBB_SYMBOL( ?internal_try_acquire_reader@spin_rw_mutex@tbb@@CA_NPEAV12@@Z ) -+#endif -+ -+// spin_rw_mutex v3 -+__TBB_SYMBOL( ?internal_construct@spin_rw_mutex_v3@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_upgrade@spin_rw_mutex_v3@tbb@@AEAA_NXZ ) -+__TBB_SYMBOL( ?internal_downgrade@spin_rw_mutex_v3@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_acquire_reader@spin_rw_mutex_v3@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_acquire_writer@spin_rw_mutex_v3@tbb@@AEAA_NXZ ) -+__TBB_SYMBOL( ?internal_release_reader@spin_rw_mutex_v3@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_release_writer@spin_rw_mutex_v3@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_try_acquire_reader@spin_rw_mutex_v3@tbb@@AEAA_NXZ ) -+__TBB_SYMBOL( ?internal_try_acquire_writer@spin_rw_mutex_v3@tbb@@AEAA_NXZ ) -+ -+// spin_mutex.cpp -+__TBB_SYMBOL( ?internal_construct@spin_mutex@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?internal_acquire@scoped_lock@spin_mutex@tbb@@AEAAXAEAV23@@Z ) -+__TBB_SYMBOL( ?internal_release@scoped_lock@spin_mutex@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_try_acquire@scoped_lock@spin_mutex@tbb@@AEAA_NAEAV23@@Z ) -+ -+// mutex.cpp -+__TBB_SYMBOL( ?internal_acquire@scoped_lock@mutex@tbb@@AEAAXAEAV23@@Z ) -+__TBB_SYMBOL( ?internal_release@scoped_lock@mutex@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_try_acquire@scoped_lock@mutex@tbb@@AEAA_NAEAV23@@Z ) -+__TBB_SYMBOL( ?internal_construct@mutex@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_destroy@mutex@tbb@@AEAAXXZ ) -+ -+// recursive_mutex.cpp -+__TBB_SYMBOL( ?internal_acquire@scoped_lock@recursive_mutex@tbb@@AEAAXAEAV23@@Z ) -+__TBB_SYMBOL( ?internal_release@scoped_lock@recursive_mutex@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_try_acquire@scoped_lock@recursive_mutex@tbb@@AEAA_NAEAV23@@Z ) -+__TBB_SYMBOL( ?internal_construct@recursive_mutex@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_destroy@recursive_mutex@tbb@@AEAAXXZ ) -+ -+// queuing_mutex.cpp -+__TBB_SYMBOL( ?internal_construct@queuing_mutex@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?acquire@scoped_lock@queuing_mutex@tbb@@QEAAXAEAV23@@Z ) -+__TBB_SYMBOL( ?release@scoped_lock@queuing_mutex@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?try_acquire@scoped_lock@queuing_mutex@tbb@@QEAA_NAEAV23@@Z ) -+ -+// critical_section.cpp -+__TBB_SYMBOL( ?internal_construct@critical_section_v4@internal@tbb@@QEAAXXZ ) -+ -+#if !TBB_NO_LEGACY -+// concurrent_hash_map.cpp -+__TBB_SYMBOL( ?internal_grow_predicate@hash_map_segment_base@internal@tbb@@QEBA_NXZ ) -+ -+// concurrent_queue.cpp v2 -+__TBB_SYMBOL( ?advance@concurrent_queue_iterator_base@internal@tbb@@IEAAXXZ ) -+__TBB_SYMBOL( ?assign@concurrent_queue_iterator_base@internal@tbb@@IEAAXAEBV123@@Z ) -+__TBB_SYMBOL( ?internal_size@concurrent_queue_base@internal@tbb@@IEBA_JXZ ) -+__TBB_SYMBOL( ??0concurrent_queue_base@internal@tbb@@IEAA@_K@Z ) -+__TBB_SYMBOL( ??0concurrent_queue_iterator_base@internal@tbb@@IEAA@AEBVconcurrent_queue_base@12@@Z ) -+__TBB_SYMBOL( ??1concurrent_queue_base@internal@tbb@@MEAA@XZ ) -+__TBB_SYMBOL( ??1concurrent_queue_iterator_base@internal@tbb@@IEAA@XZ ) -+__TBB_SYMBOL( ?internal_pop@concurrent_queue_base@internal@tbb@@IEAAXPEAX@Z ) -+__TBB_SYMBOL( ?internal_pop_if_present@concurrent_queue_base@internal@tbb@@IEAA_NPEAX@Z ) -+__TBB_SYMBOL( ?internal_push@concurrent_queue_base@internal@tbb@@IEAAXPEBX@Z ) -+__TBB_SYMBOL( ?internal_push_if_not_full@concurrent_queue_base@internal@tbb@@IEAA_NPEBX@Z ) -+__TBB_SYMBOL( ?internal_set_capacity@concurrent_queue_base@internal@tbb@@IEAAX_J_K@Z ) -+#endif -+ -+// concurrent_queue v3 -+__TBB_SYMBOL( ??1concurrent_queue_iterator_base_v3@internal@tbb@@IEAA@XZ ) -+__TBB_SYMBOL( ??0concurrent_queue_iterator_base_v3@internal@tbb@@IEAA@AEBVconcurrent_queue_base_v3@12@@Z ) -+__TBB_SYMBOL( ??0concurrent_queue_iterator_base_v3@internal@tbb@@IEAA@AEBVconcurrent_queue_base_v3@12@_K@Z ) -+__TBB_SYMBOL( ?advance@concurrent_queue_iterator_base_v3@internal@tbb@@IEAAXXZ ) -+__TBB_SYMBOL( ?assign@concurrent_queue_iterator_base_v3@internal@tbb@@IEAAXAEBV123@@Z ) -+__TBB_SYMBOL( ??0concurrent_queue_base_v3@internal@tbb@@IEAA@_K@Z ) -+__TBB_SYMBOL( ??1concurrent_queue_base_v3@internal@tbb@@MEAA@XZ ) -+__TBB_SYMBOL( ?internal_pop@concurrent_queue_base_v3@internal@tbb@@IEAAXPEAX@Z ) -+__TBB_SYMBOL( ?internal_pop_if_present@concurrent_queue_base_v3@internal@tbb@@IEAA_NPEAX@Z ) -+__TBB_SYMBOL( ?internal_abort@concurrent_queue_base_v3@internal@tbb@@IEAAXXZ ) -+__TBB_SYMBOL( ?internal_push@concurrent_queue_base_v3@internal@tbb@@IEAAXPEBX@Z ) -+__TBB_SYMBOL( ?internal_push_move@concurrent_queue_base_v8@internal@tbb@@IEAAXPEBX@Z ) -+__TBB_SYMBOL( ?internal_push_if_not_full@concurrent_queue_base_v3@internal@tbb@@IEAA_NPEBX@Z ) -+__TBB_SYMBOL( ?internal_push_move_if_not_full@concurrent_queue_base_v8@internal@tbb@@IEAA_NPEBX@Z ) -+__TBB_SYMBOL( ?internal_size@concurrent_queue_base_v3@internal@tbb@@IEBA_JXZ ) -+__TBB_SYMBOL( ?internal_empty@concurrent_queue_base_v3@internal@tbb@@IEBA_NXZ ) -+__TBB_SYMBOL( ?internal_set_capacity@concurrent_queue_base_v3@internal@tbb@@IEAAX_J_K@Z ) -+__TBB_SYMBOL( ?internal_finish_clear@concurrent_queue_base_v3@internal@tbb@@IEAAXXZ ) -+__TBB_SYMBOL( ?internal_throw_exception@concurrent_queue_base_v3@internal@tbb@@IEBAXXZ ) -+__TBB_SYMBOL( ?assign@concurrent_queue_base_v3@internal@tbb@@IEAAXAEBV123@@Z ) -+__TBB_SYMBOL( ?move_content@concurrent_queue_base_v8@internal@tbb@@IEAAXAEAV123@@Z ) -+ -+#if !TBB_NO_LEGACY -+// concurrent_vector.cpp v2 -+__TBB_SYMBOL( ?internal_assign@concurrent_vector_base@internal@tbb@@IEAAXAEBV123@_KP6AXPEAX1@ZP6AX2PEBX1@Z5@Z ) -+__TBB_SYMBOL( ?internal_capacity@concurrent_vector_base@internal@tbb@@IEBA_KXZ ) -+__TBB_SYMBOL( ?internal_clear@concurrent_vector_base@internal@tbb@@IEAAXP6AXPEAX_K@Z_N@Z ) -+__TBB_SYMBOL( ?internal_copy@concurrent_vector_base@internal@tbb@@IEAAXAEBV123@_KP6AXPEAXPEBX1@Z@Z ) -+__TBB_SYMBOL( ?internal_grow_by@concurrent_vector_base@internal@tbb@@IEAA_K_K0P6AXPEAX0@Z@Z ) -+__TBB_SYMBOL( ?internal_grow_to_at_least@concurrent_vector_base@internal@tbb@@IEAAX_K0P6AXPEAX0@Z@Z ) -+__TBB_SYMBOL( ?internal_push_back@concurrent_vector_base@internal@tbb@@IEAAPEAX_KAEA_K@Z ) -+__TBB_SYMBOL( ?internal_reserve@concurrent_vector_base@internal@tbb@@IEAAX_K00@Z ) -+#endif -+ -+// concurrent_vector v3 -+__TBB_SYMBOL( ??1concurrent_vector_base_v3@internal@tbb@@IEAA@XZ ) -+__TBB_SYMBOL( ?internal_assign@concurrent_vector_base_v3@internal@tbb@@IEAAXAEBV123@_KP6AXPEAX1@ZP6AX2PEBX1@Z5@Z ) -+__TBB_SYMBOL( ?internal_capacity@concurrent_vector_base_v3@internal@tbb@@IEBA_KXZ ) -+__TBB_SYMBOL( ?internal_clear@concurrent_vector_base_v3@internal@tbb@@IEAA_KP6AXPEAX_K@Z@Z ) -+__TBB_SYMBOL( ?internal_copy@concurrent_vector_base_v3@internal@tbb@@IEAAXAEBV123@_KP6AXPEAXPEBX1@Z@Z ) -+__TBB_SYMBOL( ?internal_grow_by@concurrent_vector_base_v3@internal@tbb@@IEAA_K_K0P6AXPEAXPEBX0@Z2@Z ) -+__TBB_SYMBOL( ?internal_grow_to_at_least@concurrent_vector_base_v3@internal@tbb@@IEAAX_K0P6AXPEAXPEBX0@Z2@Z ) -+__TBB_SYMBOL( ?internal_push_back@concurrent_vector_base_v3@internal@tbb@@IEAAPEAX_KAEA_K@Z ) -+__TBB_SYMBOL( ?internal_reserve@concurrent_vector_base_v3@internal@tbb@@IEAAX_K00@Z ) -+__TBB_SYMBOL( ?internal_compact@concurrent_vector_base_v3@internal@tbb@@IEAAPEAX_KPEAXP6AX10@ZP6AX1PEBX0@Z@Z ) -+__TBB_SYMBOL( ?internal_swap@concurrent_vector_base_v3@internal@tbb@@IEAAXAEAV123@@Z ) -+__TBB_SYMBOL( ?internal_throw_exception@concurrent_vector_base_v3@internal@tbb@@IEBAX_K@Z ) -+__TBB_SYMBOL( ?internal_resize@concurrent_vector_base_v3@internal@tbb@@IEAAX_K00PEBXP6AXPEAX0@ZP6AX210@Z@Z ) -+__TBB_SYMBOL( ?internal_grow_to_at_least_with_result@concurrent_vector_base_v3@internal@tbb@@IEAA_K_K0P6AXPEAXPEBX0@Z2@Z ) -+ -+// tbb_thread -+__TBB_SYMBOL( ?join@tbb_thread_v3@internal@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?detach@tbb_thread_v3@internal@tbb@@QEAAXXZ ) -+__TBB_SYMBOL( ?internal_start@tbb_thread_v3@internal@tbb@@AEAAXP6AIPEAX@Z0@Z ) -+__TBB_SYMBOL( ?allocate_closure_v3@internal@tbb@@YAPEAX_K@Z ) -+__TBB_SYMBOL( ?free_closure_v3@internal@tbb@@YAXPEAX@Z ) -+__TBB_SYMBOL( ?hardware_concurrency@tbb_thread_v3@internal@tbb@@SAIXZ ) -+__TBB_SYMBOL( ?thread_yield_v3@internal@tbb@@YAXXZ ) -+__TBB_SYMBOL( ?thread_sleep_v3@internal@tbb@@YAXAEBVinterval_t@tick_count@2@@Z ) -+__TBB_SYMBOL( ?move_v3@internal@tbb@@YAXAEAVtbb_thread_v3@12@0@Z ) -+__TBB_SYMBOL( ?thread_get_id_v3@internal@tbb@@YA?AVid@tbb_thread_v3@12@XZ ) -+ -+// condition_variable -+__TBB_SYMBOL( ?internal_initialize_condition_variable@internal@interface5@tbb@@YAXAEATcondvar_impl_t@123@@Z ) -+__TBB_SYMBOL( ?internal_condition_variable_wait@internal@interface5@tbb@@YA_NAEATcondvar_impl_t@123@PEAVmutex@3@PEBVinterval_t@tick_count@3@@Z ) -+__TBB_SYMBOL( ?internal_condition_variable_notify_one@internal@interface5@tbb@@YAXAEATcondvar_impl_t@123@@Z ) -+__TBB_SYMBOL( ?internal_condition_variable_notify_all@internal@interface5@tbb@@YAXAEATcondvar_impl_t@123@@Z ) -+__TBB_SYMBOL( ?internal_destroy_condition_variable@internal@interface5@tbb@@YAXAEATcondvar_impl_t@123@@Z ) -+ -+ -+// global parameter -+__TBB_SYMBOL( ?active_value@global_control@interface9@tbb@@CA_KH@Z ) -+__TBB_SYMBOL( ?internal_create@global_control@interface9@tbb@@AEAAXXZ ) -+__TBB_SYMBOL( ?internal_destroy@global_control@interface9@tbb@@AEAAXXZ ) -+ -+#undef __TBB_SYMBOL -diff --git a/src/tbbmalloc/TypeDefinitions.h b/src/tbbmalloc/TypeDefinitions.h -index aa6763b0..fffef73d 100644 ---- a/src/tbbmalloc/TypeDefinitions.h -+++ b/src/tbbmalloc/TypeDefinitions.h -@@ -25,7 +25,7 @@ - # define __ARCH_ipf 1 - # elif defined(_M_IX86)||defined(__i386__) // the latter for MinGW support - # define __ARCH_x86_32 1 --# elif defined(_M_ARM) -+# elif defined(_M_ARM)||defined(_M_ARM64) - # define __ARCH_other 1 - # else - # error Unknown processor architecture for Windows -diff --git a/src/tbbmalloc/winarm64-tbbmalloc-export.def b/src/tbbmalloc/winarm64-tbbmalloc-export.def -new file mode 100644 -index 00000000..ec64b015 ---- /dev/null -+++ b/src/tbbmalloc/winarm64-tbbmalloc-export.def -@@ -0,0 +1,46 @@ -+; Copyright (c) 2005-2020 Intel Corporation -+; Copyright (c) 2022 Linaro Ltd -+; -+; Licensed under the Apache License, Version 2.0 (the "License"); -+; you may not use this file except in compliance with the License. -+; You may obtain a copy of the License at -+; -+; http://www.apache.org/licenses/LICENSE-2.0 -+; -+; Unless required by applicable law or agreed to in writing, software -+; distributed under the License is distributed on an "AS IS" BASIS, -+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -+; See the License for the specific language governing permissions and -+; limitations under the License. -+ -+EXPORTS -+ -+; frontend.cpp -+scalable_calloc -+scalable_free -+scalable_malloc -+scalable_realloc -+scalable_posix_memalign -+scalable_aligned_malloc -+scalable_aligned_realloc -+scalable_aligned_free -+scalable_msize -+scalable_allocation_mode -+scalable_allocation_command -+__TBB_malloc_safer_free -+__TBB_malloc_safer_realloc -+__TBB_malloc_safer_msize -+__TBB_malloc_safer_aligned_msize -+__TBB_malloc_safer_aligned_realloc -+?pool_create@rml@@YAPEAVMemoryPool@1@_JPEBUMemPoolPolicy@1@@Z -+?pool_create_v1@rml@@YA?AW4MemPoolError@1@_JPEBUMemPoolPolicy@1@PEAPEAVMemoryPool@1@@Z -+?pool_destroy@rml@@YA_NPEAVMemoryPool@1@@Z -+?pool_malloc@rml@@YAPEAXPEAVMemoryPool@1@_K@Z -+?pool_free@rml@@YA_NPEAVMemoryPool@1@PEAX@Z -+?pool_reset@rml@@YA_NPEAVMemoryPool@1@@Z -+?pool_realloc@rml@@YAPEAXPEAVMemoryPool@1@PEAX_K@Z -+?pool_aligned_realloc@rml@@YAPEAXPEAVMemoryPool@1@PEAX_K2@Z -+?pool_aligned_malloc@rml@@YAPEAXPEAVMemoryPool@1@_K1@Z -+?pool_identify@rml@@YAPEAVMemoryPool@1@PEAX@Z -+?pool_msize@rml@@YA_KPEAVMemoryPool@1@PEAX@Z -+ -diff --git a/src/test/harness_fp.h b/src/test/harness_fp.h -index b007e2b8..f6d0066e 100644 ---- a/src/test/harness_fp.h -+++ b/src/test/harness_fp.h -@@ -84,7 +84,7 @@ inline void SetSseMode ( int mode ) { - ctl.set_env(); - } - --#elif defined(_M_ARM) || defined(__TBB_WIN32_USE_CL_BUILTINS) -+#elif defined(_M_ARM) || defined(_M_ARM64) || defined(__TBB_WIN32_USE_CL_BUILTINS) - const int NumSseModes = 1; - const int SseModes[NumSseModes] = { 0 }; - diff --git a/build_files/build_environment/patches/tbb_1478.diff b/build_files/build_environment/patches/tbb_1478.diff index cb3f6320c66..367b26051c1 100644 --- a/build_files/build_environment/patches/tbb_1478.diff +++ b/build_files/build_environment/patches/tbb_1478.diff @@ -1,7 +1,8 @@ -diff -Naur orig/src/tbbmalloc/proxy.cpp external_tbb/src/tbbmalloc/proxy.cpp ---- orig/src/tbbmalloc/proxy.cpp 2024-10-08 14:43:58 -0600 -+++ external_tbb/src/tbbmalloc/proxy.cpp 2024-10-08 14:48:26 -0600 -@@ -452,14 +452,12 @@ +diff --git a/src/tbbmalloc_proxy/proxy.cpp b/src/tbbmalloc_proxy/proxy.cpp +index a6d3dea06f..954583ba5f 100644 +--- a/src/tbbmalloc_proxy/proxy.cpp ++++ b/src/tbbmalloc_proxy/proxy.cpp +@@ -431,14 +431,12 @@ void __TBB_malloc__free_base(void *ptr) const char* known_bytecodes[] = { #if _WIN64 // "========================================================" - 56 symbols diff --git a/build_files/build_environment/patches/usd_3243.diff b/build_files/build_environment/patches/usd_3243.diff new file mode 100644 index 00000000000..6e9e6a2b363 --- /dev/null +++ b/build_files/build_environment/patches/usd_3243.diff @@ -0,0 +1,70 @@ +diff --git a/pxr/usd/usdMtlx/reader.cpp b/pxr/usd/usdMtlx/reader.cpp +index f04ab07ac1..aa4d1e65de 100644 +--- a/pxr/usd/usdMtlx/reader.cpp ++++ b/pxr/usd/usdMtlx/reader.cpp +@@ -9,6 +9,7 @@ + #include "pxr/usd/usdMtlx/reader.h" + #include "pxr/usd/usdMtlx/utils.h" + ++#include "pxr/usd/usdGeom/metrics.h" + #include "pxr/usd/usdGeom/primvar.h" + #include "pxr/usd/usdGeom/primvarsAPI.h" + #include "pxr/usd/usdShade/material.h" +@@ -740,11 +741,11 @@ _NodeGraphBuilder::Build(ShaderNamesByOutputName* outputs) + return UsdPrim(); + } + +- const bool isInsideNodeGraph = _mtlxContainer->isA(); ++ const bool isExplicitNodeGraph = _mtlxContainer->isA(); + + // Create the USD nodegraph. + UsdPrim usdPrim; +- if (isInsideNodeGraph) { ++ if (isExplicitNodeGraph) { + // Create the nodegraph. + auto usdNodeGraph = UsdShadeNodeGraph::Define(_usdStage, _usdPath); + if (!usdNodeGraph) { +@@ -769,7 +770,7 @@ _NodeGraphBuilder::Build(ShaderNamesByOutputName* outputs) + } + } + else { +- usdPrim = _usdStage->DefinePrim(_usdPath); ++ usdPrim = UsdShadeNodeGraph::Define(_usdStage, _usdPath).GetPrim(); + } + + // Build the graph of nodes. +@@ -783,19 +784,7 @@ _NodeGraphBuilder::Build(ShaderNamesByOutputName* outputs) + _AddNode(mtlxNode, usdPrim); + } + _ConnectNodes(); +- +- if (isInsideNodeGraph) { +- _ConnectTerminals(_mtlxContainer, UsdShadeConnectableAPI(usdPrim)); +- } +- else if (outputs) { +- // Collect the outputs on the existing shader nodes. +- for (mx::OutputPtr& mtlxOutput : +- _mtlxContainer->getChildrenOfType()) { +- if (auto nodeName = _Attr(mtlxOutput, names.nodename)) { +- (*outputs)[_Name(mtlxOutput)] = TfToken(nodeName); +- } +- } +- } ++ _ConnectTerminals(_mtlxContainer, UsdShadeConnectableAPI(usdPrim)); + + return usdPrim; + } +@@ -2623,6 +2612,13 @@ UsdMtlxRead( + // Translate all materials. + ReadMaterials(mtlxDoc, context); + ++ if (!mtlxDoc->getChildren().empty()) { ++ // This metadata is required to pass usdchecker ++ UsdGeomSetStageUpAxis(stage, UsdGeomGetFallbackUpAxis()); ++ UsdGeomSetStageMetersPerUnit(stage, UsdGeomLinearUnits::centimeters); ++ stage->SetDefaultPrim(stage->GetPrimAtPath(internalPath)); ++ } ++ + // If there are no looks then we're done. + if (mtlxDoc->getLooks().empty()) { + return; diff --git a/build_files/build_environment/patches/usd_3519.diff b/build_files/build_environment/patches/usd_3519.diff new file mode 100644 index 00000000000..3ed4fa7ac92 --- /dev/null +++ b/build_files/build_environment/patches/usd_3519.diff @@ -0,0 +1,70 @@ +commit 84c1a9f8e5a8c413dea56852894541f0cc28193b +Author: Brecht Van Lommel +Date: Tue Feb 4 23:33:50 2025 +0100 + + Fix Metal shader errors with MaterialX 1.39 + + * mx_microfacet.glsl uses functions from mx_math.metal, so the + latter must be included first. + * Defining atan(y, x) for GLSL compatibility conflicts with + mx_math.metal using ::atan(y_over_x). Work around this by tweaking + the definition. + * textureQueryLevels(u_envRadiance) does not take into account that + this texture is wrapped in a MetalTexture class. + + Signed-off-by: Brecht Van Lommel + +diff --git a/pxr/imaging/hdSt/materialXShaderGen.cpp b/pxr/imaging/hdSt/materialXShaderGen.cpp +index 58687a760..8345b6fb2 100644 +--- a/pxr/imaging/hdSt/materialXShaderGen.cpp ++++ b/pxr/imaging/hdSt/materialXShaderGen.cpp +@@ -447,8 +447,17 @@ HdStMaterialXShaderGen::_EmitMxInitFunction( + emitLine("u_envIrradiance = HdGetSampler_domeLightFallback()", mxStage); + emitLine("u_envRadiance = HdGetSampler_domeLightFallback()", mxStage); + emitLine("#endif", mxStage, false); ++ emitLine("u_envRadianceMips = textureQueryLevels(u_envRadiance)", mxStage); ++ } ++ else { ++ if (std::is_same_v) { ++ // Msl has this wrapped in a MetalTexture class ++ emitLine("u_envRadianceMips = textureQueryLevels(u_envRadiance.tex)", mxStage); ++ } ++ else { ++ emitLine("u_envRadianceMips = textureQueryLevels(u_envRadiance)", mxStage); ++ } + } +- emitLine("u_envRadianceMips = textureQueryLevels(u_envRadiance)", mxStage); + Base::emitLineBreak(mxStage); + + // Initialize MaterialX Texture samplers with HdGetSampler equivalents +@@ -1309,12 +1318,12 @@ HdStMaterialXShaderGenMsl::_EmitMxFunctions( + mx::GenContext& mxContext, + mx::ShaderStage& mxStage) const + { +- mx::ShaderGenerator::emitLibraryInclude( +- "pbrlib/" + mx::GlslShaderGenerator::TARGET +- + "/lib/mx_microfacet.glsl", mxContext, mxStage); + mx::ShaderGenerator::emitLibraryInclude( + "stdlib/" + mx::MslShaderGenerator::TARGET + + "/lib/mx_math.metal", mxContext, mxStage); ++ mx::ShaderGenerator::emitLibraryInclude( ++ "pbrlib/" + mx::GlslShaderGenerator::TARGET ++ + "/lib/mx_microfacet.glsl", mxContext, mxStage); + _EmitConstantsUniformsAndTypeDefs( + mxContext, mxStage,_syntax->getConstantQualifier()); + +diff --git a/pxr/imaging/hgiMetal/shaderGenerator.mm b/pxr/imaging/hgiMetal/shaderGenerator.mm +index f1db1beb1..6ace76999 100644 +--- a/pxr/imaging/hgiMetal/shaderGenerator.mm ++++ b/pxr/imaging/hgiMetal/shaderGenerator.mm +@@ -515,7 +515,9 @@ _ComputeHeader(id device, HgiShaderStage stage) + "template \n" + "T mod(T y, T x) { return fmod(y, x); }\n\n" + "template \n" +- "T atan(T y, T x) { return atan2(y, x); }\n\n" ++ "T atan(T y_over_x) { return ::atan(y_over_x); }\n\n" ++ "template \n" ++ "T atan(T y, T x) { return ::atan2(y, x); }\n\n" + "template \n" + "T bitfieldReverse(T x) { return reverse_bits(x); }\n\n" + "template \n" diff --git a/build_files/build_environment/patches/usd_forward_compat.diff b/build_files/build_environment/patches/usd_forward_compat.diff new file mode 100644 index 00000000000..9cc81dfe1c5 --- /dev/null +++ b/build_files/build_environment/patches/usd_forward_compat.diff @@ -0,0 +1,14 @@ +diff --git a/pxr/usd/usd/crateFile.cpp b/pxr/usd/usd/crateFile.cpp +index 55c6d71e1..5d0fcbcfa 100644 +--- a/pxr/usd/usd/crateFile.cpp ++++ b/pxr/usd/usd/crateFile.cpp +@@ -102,7 +102,8 @@ TF_REGISTRY_FUNCTION(TfType) { + TfType::Define(); + } + +-#define DEFAULT_NEW_VERSION "0.10.0" ++// BLENDER: Keep USD files forward compatible for longer. ++#define DEFAULT_NEW_VERSION "0.9.0" + TF_DEFINE_ENV_SETTING( + USD_WRITE_NEW_USDC_FILES_AS_VERSION, DEFAULT_NEW_VERSION, + "When writing new Usd Crate files, write them as this version. " diff --git a/build_files/build_environment/patches/usd_metal_edf.diff b/build_files/build_environment/patches/usd_metal_edf.diff deleted file mode 100644 index 5acfa7c6e75..00000000000 --- a/build_files/build_environment/patches/usd_metal_edf.diff +++ /dev/null @@ -1,46 +0,0 @@ -From 4f05a62018ee5134843f7cefed826585f13a509b Mon Sep 17 00:00:00 2001 -From: Dhruv Govil -Date: Mon, 3 Jun 2024 15:31:34 -0700 -Subject: [PATCH] Fix shader compile bug when using EDF in Storm - -Fixes -https://github.com/PixarAnimationStudios/OpenUSD/issues/3105 - -Thanks to Lee Kerley for the fix ---- - pxr/imaging/hdSt/materialXShaderGen.cpp | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/pxr/imaging/hdSt/materialXShaderGen.cpp b/pxr/imaging/hdSt/materialXShaderGen.cpp -index ca1806bf03..8b0e1a3a41 100644 ---- a/pxr/imaging/hdSt/materialXShaderGen.cpp -+++ b/pxr/imaging/hdSt/materialXShaderGen.cpp -@@ -692,7 +692,6 @@ HdStMaterialXShaderGen::_EmitConstantsUniformsAndTypeDefs( - mxContext.getOptions().hwDirectionalAlbedoMethod)), - mxStage, false); - Base::emitLineBreak(mxStage); -- Base::emitTypeDefinitions(mxContext, mxStage); - - // Add all constants and ensure that values are initialized - const mx::VariableBlock& constants = mxStage.getConstantBlock(); -@@ -945,6 +944,10 @@ HdStMaterialXShaderGenGlsl::_EmitMxFunctions( - mx::ShaderGenerator::emitLibraryInclude( - "stdlib/" + mx::GlslShaderGenerator::TARGET - + "/lib/mx_math.glsl", mxContext, mxStage); -+ -+ // Add type definitions -+ emitTypeDefinitions(mxContext, mxStage); -+ - _EmitConstantsUniformsAndTypeDefs( - mxContext, mxStage, _syntax->getConstantQualifier()); - -@@ -1106,6 +1109,9 @@ HdStMaterialXShaderGenMsl::_EmitGlslfxMetalShader( - addStageUniform(mx::HW::LIGHT_DATA, mx::Type::FLOAT, - "shadowOcclusion", mxStage); - -+ // Add type definitions -+ emitTypeDefinitions(mxContext, mxStage); -+ - // Add type definitions - emitConstantBufferDeclarations(mxContext, resourceBindingCtx, mxStage); - diff --git a/build_files/build_environment/patches/usd_noboost.diff b/build_files/build_environment/patches/usd_noboost.diff new file mode 100644 index 00000000000..4150b1df136 --- /dev/null +++ b/build_files/build_environment/patches/usd_noboost.diff @@ -0,0 +1,11 @@ +--- a/cmake/defaults/Packages.cmake 2025-01-22 08:14:27 ++++ b/cmake/defaults/Packages.cmake 2025-01-22 08:14:41 +@@ -20,7 +20,7 @@ + find_package(Threads REQUIRED) + set(PXR_THREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}") + +-if((PXR_ENABLE_PYTHON_SUPPORT AND PXR_USE_BOOST_PYTHON) OR PXR_ENABLE_OPENVDB_SUPPORT) ++if(PXR_ENABLE_PYTHON_SUPPORT AND PXR_USE_BOOST_PYTHON) + # Find Boost package before getting any boost specific components as we need to + # disable boost-provided cmake config, based on the boost version found. + find_package(Boost REQUIRED) diff --git a/build_files/build_environment/windows/build_deps.cmd b/build_files/build_environment/windows/build_deps.cmd index 6764e4d6895..433723a538e 100644 --- a/build_files/build_environment/windows/build_deps.cmd +++ b/build_files/build_environment/windows/build_deps.cmd @@ -129,11 +129,10 @@ if %ERRORLEVEL% NEQ 0 ( set StatusFile=%BUILD_DIR%\%1_%2.log set original_path=%path% set oiio_paths=%Staging%\%BuildDir%%ARCH%R\Release\openimageio\bin -set boost_paths=%Staging%\%BuildDir%%ARCH%R\Release\boost\lib set openexr_paths=%Staging%\%BuildDir%%ARCH%R\Release\openexr\bin set imath_paths=%Staging%\%BuildDir%%ARCH%R\Release\imath\bin set tbb_paths=%Staging%\%BuildDir%%ARCH%R\Release\tbb\bin -set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads\nasm-2.12.01\;%original_path%;%boost_paths%;%oiio_paths%;%openexr_paths%;%imath_paths%;%tbb_paths% +set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads\nasm-2.12.01\;%original_path%;%oiio_paths%;%openexr_paths%;%imath_paths%;%tbb_paths% mkdir %STAGING%\%BuildDir%%ARCH%R cd %Staging%\%BuildDir%%ARCH%R echo %DATE% %TIME% : Start > %StatusFile% @@ -150,11 +149,10 @@ cd %BUILD_DIR% mkdir %STAGING%\%BuildDir%%ARCH%D cd %Staging%\%BuildDir%%ARCH%D set oiio_paths=%Staging%\%BuildDir%%ARCH%D\Debug\openimageio\bin -set boost_paths=%Staging%\%BuildDir%%ARCH%D\Debug\boost\lib set openexr_paths=%Staging%\%BuildDir%%ARCH%D\Debug\openexr\bin set imath_paths=%Staging%\%BuildDir%%ARCH%D\Debug\imath\bin set tbb_paths=%Staging%\%BuildDir%%ARCH%D\Debug\tbb\bin -set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads\nasm-2.12.01\;%original_path%;%boost_paths%;%oiio_paths%;%openexr_paths%;%imath_paths%;%tbb_paths% +set path=%BUILD_DIR%\downloads\mingw\mingw64\msys\1.0\bin\;%BUILD_DIR%\downloads\nasm-2.12.01\;%original_path%;%oiio_paths%;%openexr_paths%;%imath_paths%;%tbb_paths% cmake -G "%CMAKE_BUILDER%" %CMAKE_BUILD_ARCH% %SOURCE_DIR% -DPACKAGE_DIR=%BUILD_DIR%/packages -DDOWNLOAD_DIR=%BUILD_DIR%/downloads -DCMAKE_BUILD_TYPE=Debug -DBUILD_MODE=Debug -DHARVEST_TARGET=%HARVEST_DIR%/%HARVESTROOT%%VSVER_SHORT%/ %CMAKE_DEBUG_OPTIONS% echo %DATE% %TIME% : Debug Configuration done >> %StatusFile% if "%dobuild%" == "1" ( diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index ecec37efed4..d863005f840 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -251,6 +251,17 @@ if(WITH_IMAGE_WEBP) find_package(WebP REQUIRED) endif() +# With Blender 4.4 libraries there is no more Boost. This code is only +# here until we can reasonably assume everyone has upgraded to them. +if(WITH_BOOST) + if(DEFINED LIBDIR AND NOT EXISTS "${LIBDIR}/boost") + set(WITH_BOOST OFF) + set(BOOST_LIBRARIES) + set(BOOST_PYTHON_LIBRARIES) + set(BOOST_INCLUDE_DIR) + endif() +endif() + if(WITH_BOOST) set(Boost_NO_BOOST_CMAKE ON) set(Boost_ROOT ${LIBDIR}/boost) diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake index 1c7a13f69b4..5b7e5ecfb17 100644 --- a/build_files/cmake/platform/platform_unix.cmake +++ b/build_files/cmake/platform/platform_unix.cmake @@ -464,6 +464,18 @@ if(WITH_MATERIALX) endif() add_bundled_libraries(materialx/lib) +# With Blender 4.4 libraries there is no more Boost. But Linux distros may have +# older versions of libs like USD with a header dependency on Boost, so can't +# remove this entirely yet. +if(WITH_BOOST) + if(DEFINED LIBDIR AND NOT EXISTS "${LIBDIR}/boost") + set(WITH_BOOST OFF) + set(BOOST_LIBRARIES) + set(BOOST_PYTHON_LIBRARIES) + set(BOOST_INCLUDE_DIR) + endif() +endif() + if(WITH_BOOST) # uses in build instructions to override include and library variables if(NOT BOOST_CUSTOM) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index a4be8842d9a..0b735664636 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -99,7 +99,7 @@ endif() list(APPEND PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 Comctl32 version advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp Shlwapi - pathcch Shcore Dwmapi Crypt32 + pathcch Shcore Dwmapi Crypt32 Bcrypt ) if(WITH_INPUT_IME) @@ -652,30 +652,40 @@ if(WITH_PYTHON) endif() if(NOT WITH_WINDOWS_FIND_MODULES) - # even if boost is off, we still need to install the dlls when we use our lib folder since - # some of the other dependencies may need them. For this to work, BOOST_VERSION, - # BOOST_POSTFIX, and BOOST_DEBUG_POSTFIX need to be set. set(BOOST ${LIBDIR}/boost) set(BOOST_INCLUDE_DIR ${BOOST}/include) set(BOOST_LIBPATH ${BOOST}/lib) - set(BOOST_VERSION_HEADER ${BOOST_INCLUDE_DIR}/boost/version.hpp) - if(EXISTS ${BOOST_VERSION_HEADER}) - file(STRINGS "${BOOST_VERSION_HEADER}" BOOST_LIB_VERSION REGEX "#define BOOST_LIB_VERSION ") - if(BOOST_LIB_VERSION MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"") - set(BOOST_VERSION "${CMAKE_MATCH_1}") - endif() - endif() - if(NOT BOOST_VERSION) - message(FATAL_ERROR "Unable to determine Boost version") - endif() - if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") - set(BOOST_POSTFIX "vc143-mt-a64-${BOOST_VERSION}") - set(BOOST_DEBUG_POSTFIX "vc143-mt-gyd-a64-${BOOST_VERSION}") - set(BOOST_PREFIX "") + + # With Blender 4.4 libraries there is no more Boost. This code is only + # here until we can reasonably assume everyone has upgraded to them. + if(EXISTS "${LIBDIR}" AND NOT EXISTS "${BOOST}") + set(WITH_BOOST OFF) + set(BOOST_LIBRARIES) + set(BOOST_PYTHON_LIBRARIES) + set(BOOST_INCLUDE_DIR) else() - set(BOOST_POSTFIX "vc142-mt-x64-${BOOST_VERSION}") - set(BOOST_DEBUG_POSTFIX "vc142-mt-gyd-x64-${BOOST_VERSION}") - set(BOOST_PREFIX "") + # For older libraries when boost is off, we still need to install the dlls when + # since some of the other dependencies may need them. For this to work, BOOST_VERSION, + # BOOST_POSTFIX, and BOOST_DEBUG_POSTFIX need to be set. + set(BOOST_VERSION_HEADER ${BOOST_INCLUDE_DIR}/boost/version.hpp) + if(EXISTS ${BOOST_VERSION_HEADER}) + file(STRINGS "${BOOST_VERSION_HEADER}" BOOST_LIB_VERSION REGEX "#define BOOST_LIB_VERSION ") + if(BOOST_LIB_VERSION MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"") + set(BOOST_VERSION "${CMAKE_MATCH_1}") + endif() + endif() + if(NOT BOOST_VERSION) + message(FATAL_ERROR "Unable to determine Boost version") + endif() + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") + set(BOOST_POSTFIX "vc143-mt-a64-${BOOST_VERSION}") + set(BOOST_DEBUG_POSTFIX "vc143-mt-gyd-a64-${BOOST_VERSION}") + set(BOOST_PREFIX "") + else() + set(BOOST_POSTFIX "vc142-mt-x64-${BOOST_VERSION}") + set(BOOST_DEBUG_POSTFIX "vc142-mt-gyd-x64-${BOOST_VERSION}") + set(BOOST_PREFIX "") + endif() endif() endif() @@ -910,10 +920,17 @@ endif() if(WITH_TBB) windows_find_package(TBB) if(NOT TBB_FOUND) - set(TBB_LIBRARIES - optimized ${LIBDIR}/tbb/lib/tbb.lib - debug ${LIBDIR}/tbb/lib/tbb_debug.lib - ) + if(EXISTS ${LIBDIR}/tbb/lib/tbb12.lib) # 4.4 + set(TBB_LIBRARIES + optimized ${LIBDIR}/tbb/lib/tbb12.lib + debug ${LIBDIR}/tbb/lib/tbb12_debug.lib + ) + else() # 4.3- + set(TBB_LIBRARIES + optimized ${LIBDIR}/tbb/lib/tbb.lib + debug ${LIBDIR}/tbb/lib/tbb_debug.lib + ) + endif() set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include) set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR}) if(WITH_TBB_MALLOC_PROXY) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 77347a31b6c..f73877018f5 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -558,6 +558,18 @@ if(WITH_OPENCOLORIO) ) endif() if(WIN32) + if(EXISTS ${LIBDIR}/osl/lib/python${PYTHON_VERSION}/site-packages/oslquery) # 4.4+ + install( + DIRECTORY ${LIBDIR}/osl/lib/python${PYTHON_VERSION}/site-packages/oslquery + DESTINATION ${TARGETDIR_SITE_PACKAGES} + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + ) + install( + DIRECTORY ${LIBDIR}/osl/lib/python${PYTHON_VERSION}_debug/site-packages/oslquery + DESTINATION ${TARGETDIR_SITE_PACKAGES} + CONFIGURATIONS Debug + ) + endif() if(EXISTS ${LIBDIR}/osl/bin/oslquery.dll) # 4.1+ windows_install_shared_manifest( FILES @@ -576,25 +588,15 @@ if(WIN32) DEBUG ) endif() - if(EXISTS ${LIBDIR}/opencolorio/bin/opencolorio_2_2.dll) # 3.5 + if(EXISTS ${LIBDIR}/opencolorio/bin/opencolorio_2_4.dll) # 4.4 windows_install_shared_manifest( - FILES ${LIBDIR}/opencolorio/bin/opencolorio_2_2.dll + FILES ${LIBDIR}/opencolorio/bin/opencolorio_2_4.dll RELEASE ) windows_install_shared_manifest( - FILES ${LIBDIR}/opencolorio/bin/opencolorio_d_2_2.dll + FILES ${LIBDIR}/opencolorio/bin/opencolorio_d_2_4.dll DEBUG ) - install( - FILES ${LIBDIR}/opencolorio/lib/site-packages-debug/PyOpenColorIO_d.pyd - DESTINATION ${TARGETDIR_SITE_PACKAGES} - CONFIGURATIONS Debug - ) - install( - FILES ${LIBDIR}/opencolorio/lib/site-packages/PyOpenColorIO.pyd - DESTINATION ${TARGETDIR_SITE_PACKAGES} - CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel - ) endif() if(EXISTS ${LIBDIR}/opencolorio/bin/opencolorio_2_3.dll) # 4.1 windows_install_shared_manifest( @@ -605,17 +607,17 @@ if(WIN32) FILES ${LIBDIR}/opencolorio/bin/opencolorio_d_2_3.dll DEBUG ) - install( - DIRECTORY ${LIBDIR}/opencolorio/lib/site-packages-debug/PyOpenColorIO - DESTINATION ${TARGETDIR_SITE_PACKAGES} - CONFIGURATIONS Debug - ) - install( - DIRECTORY ${LIBDIR}/opencolorio/lib/site-packages/PyOpenColorIO - DESTINATION ${TARGETDIR_SITE_PACKAGES} - CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel - ) endif() + install( + DIRECTORY ${LIBDIR}/opencolorio/lib/site-packages-debug/PyOpenColorIO + DESTINATION ${TARGETDIR_SITE_PACKAGES} + CONFIGURATIONS Debug + ) + install( + DIRECTORY ${LIBDIR}/opencolorio/lib/site-packages/PyOpenColorIO + DESTINATION ${TARGETDIR_SITE_PACKAGES} + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + ) if(EXISTS ${LIBDIR}/OpenImageDenoise/bin/openimagedenoise.dll) # 4.0 windows_install_shared_manifest( FILES @@ -1238,7 +1240,8 @@ elseif(WIN32) endif() endif() - if(WITH_PYTHON_INSTALL) + # VFX libs are bundled with both Blender executable and Python module. + if(WITH_PYTHON_INSTALL OR WITH_PYTHON_MODULE) # NOTE: as far as python is concerned `RelWithDebInfo` # is not debug since its without debug flags. @@ -1293,25 +1296,6 @@ elseif(WIN32) CONFIGURATIONS Debug ) - if(WINDOWS_PYTHON_DEBUG) - install( - FILES - ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}.pdb - DESTINATION "." - CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel - ) - - install( - FILES - ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}_d.pdb - DESTINATION "." - CONFIGURATIONS Debug - ) - endif() - endif() - - # VFX libs are bundled with both Blender executable and Python module. - if(WITH_PYTHON_INSTALL OR WITH_PYTHON_MODULE) # This will only exist for 3.5+. if(EXISTS ${LIBDIR}/openimageio/lib/python${PYTHON_VERSION}/site-packages) install( @@ -1379,6 +1363,7 @@ elseif(WIN32) set(_openvdb_arch amd64) endif() + # 4.3 if(EXISTS ${LIBDIR}/openvdb/python/pyopenvdb_d.cp${_PYTHON_VERSION_NO_DOTS}-win_${_openvdb_arch}.pyd) install( FILES ${LIBDIR}/openvdb/python/pyopenvdb_d.cp${_PYTHON_VERSION_NO_DOTS}-win_${_openvdb_arch}.pyd @@ -1391,7 +1376,19 @@ elseif(WIN32) CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel ) endif() - + # 4.4 + if(EXISTS ${LIBDIR}/openvdb/python/openvdb_d.cp${_PYTHON_VERSION_NO_DOTS}-win_${_openvdb_arch}.pyd) + install( + FILES ${LIBDIR}/openvdb/python/openvdb_d.cp${_PYTHON_VERSION_NO_DOTS}-win_${_openvdb_arch}.pyd + DESTINATION ${TARGETDIR_SITE_PACKAGES} + CONFIGURATIONS Debug + ) + install( + FILES ${LIBDIR}/openvdb/python/openvdb.cp${_PYTHON_VERSION_NO_DOTS}-win_${_openvdb_arch}.pyd + DESTINATION ${TARGETDIR_SITE_PACKAGES} + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + ) + endif() # MaterialX python bindings install( DIRECTORY ${LIBDIR}/materialx/python/Release/MaterialX @@ -1411,6 +1408,24 @@ elseif(WIN32) ) endif() + if(WITH_PYTHON_INSTALL) + if(WINDOWS_PYTHON_DEBUG) + install( + FILES + ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}.pdb + DESTINATION "." + CONFIGURATIONS Release;RelWithDebInfo;MinSizeRel + ) + + install( + FILES + ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}_d.pdb + DESTINATION "." + CONFIGURATIONS Debug + ) + endif() + endif() + endif() # Filenames change slightly between FFMPEG versions check both 6.0 and fallback to 5.0 @@ -1438,16 +1453,29 @@ elseif(WIN32) ALL ) endif() - windows_install_shared_manifest( - FILES - ${LIBDIR}/tbb/bin/tbb.dll - RELEASE - ) - windows_install_shared_manifest( - FILES - ${LIBDIR}/tbb/bin/tbb_debug.dll - DEBUG - ) + if(EXISTS ${LIBDIR}/tbb/bin/tbb12.dll) # 4.4 + windows_install_shared_manifest( + FILES + ${LIBDIR}/tbb/bin/tbb12.dll + RELEASE + ) + windows_install_shared_manifest( + FILES + ${LIBDIR}/tbb/bin/tbb12_debug.dll + DEBUG + ) + else() + windows_install_shared_manifest( + FILES + ${LIBDIR}/tbb/bin/tbb.dll + RELEASE + ) + windows_install_shared_manifest( + FILES + ${LIBDIR}/tbb/bin/tbb_debug.dll + DEBUG + ) + endif() if(WITH_TBB_MALLOC_PROXY) windows_install_shared_manifest( FILES @@ -1711,18 +1739,18 @@ if(WITH_PYTHON_MODULE AND LIBDIR AND NOT WIN32) DIRECTORY ${LIBDIR}/python/lib/python${PYTHON_VERSION}/site-packages/PyOpenColorIO DESTINATION ${TARGETDIR_SITE_PACKAGES}) install( - FILES ${LIBDIR}/python/lib/python${PYTHON_VERSION}/site-packages/oslquery.so + DIRECTORY ${LIBDIR}/python/lib/python${PYTHON_VERSION}/site-packages/oslquery DESTINATION ${TARGETDIR_SITE_PACKAGES} OPTIONAL) install( DIRECTORY ${LIBDIR}/python/lib/python${PYTHON_VERSION}/site-packages/pxr DESTINATION ${TARGETDIR_SITE_PACKAGES}) if(APPLE) - set(_pyopenvdb_filename pyopenvdb.cpython-${PYTHON_VERSION_NO_DOTS}-darwin.so) + set(_openvdb_filename openvdb.cpython-${PYTHON_VERSION_NO_DOTS}-darwin.so) else() - set(_pyopenvdb_filename pyopenvdb.cpython-${PYTHON_VERSION_NO_DOTS}-${CMAKE_SYSTEM_PROCESSOR}-linux-gnu.so) + set(_openvdb_filename openvdb.cpython-${PYTHON_VERSION_NO_DOTS}-${CMAKE_SYSTEM_PROCESSOR}-linux-gnu.so) endif() install( - FILES ${LIBDIR}/python/lib/python${PYTHON_VERSION}/site-packages/${_pyopenvdb_filename} + FILES ${LIBDIR}/python/lib/python${PYTHON_VERSION}/site-packages/${_openvdb_filename} DESTINATION ${TARGETDIR_SITE_PACKAGES}) endif() @@ -1916,7 +1944,7 @@ if((DEFINED LIBDIR) AND TARGETDIR_LIB AND WITH_MATERIALX) ) endif() -if(WIN32) +if(WIN32 AND EXISTS ${BOOST_LIBPATH}) set(BOOST_COMPONENTS atomic chrono date_time filesystem iostreams locale program_options regex serialization system thread wave wserialization diff --git a/tests/blender_as_python_module/import_bpy.py b/tests/blender_as_python_module/import_bpy.py index 46617208764..5477a77672d 100644 --- a/tests/blender_as_python_module/import_bpy.py +++ b/tests/blender_as_python_module/import_bpy.py @@ -16,4 +16,10 @@ import MaterialX import OpenImageIO import PyOpenColorIO -import pyopenvdb + +# Test both old and new names, remove when all 4.4 libs have landed. +try: + import pyopenvdb +except ModuleNotFoundError: + import openvdb + import oslquery diff --git a/tests/python/bl_bundled_modules.py b/tests/python/bl_bundled_modules.py index e9a6f03dfab..4602e87916e 100644 --- a/tests/python/bl_bundled_modules.py +++ b/tests/python/bl_bundled_modules.py @@ -34,7 +34,13 @@ import MaterialX import OpenImageIO import PyOpenColorIO -import pyopenvdb + +# Test both old and new names, remove when all 4.4 libs have landed. +try: + import pyopenvdb +except ModuleNotFoundError: + import openvdb + import oslquery # Test modules in bundled Python standalone executable. if app == "Blender": diff --git a/tests/python/cycles_render_tests.py b/tests/python/cycles_render_tests.py index fc46178ec49..b2554547578 100644 --- a/tests/python/cycles_render_tests.py +++ b/tests/python/cycles_render_tests.py @@ -20,6 +20,8 @@ "hair_instancer_uv.blend", "principled_hair_directcoloring.blend", "visibility_particles.blend", + # Temporarily blocked for 4.4 lib upgrade, due to PNG alpha minor difference. + "image_log_osl.blend", ] # Blocklist that disables OSL specific tests for configurations that do not support OSL backend. From 3b0742ea7cc298debd6c52427e540ef03b06432c Mon Sep 17 00:00:00 2001 From: Patrick Mours Date: Thu, 6 Feb 2025 15:04:18 +0100 Subject: [PATCH 18/28] Build: Add Blackwell to OIDN GPU architectures Pretty straight forward modification to OIDN to increase the max SM version check and include binaries for the Blackwell GPU architecture. Requires CUDA toolkit 12.8+. Co-authored-by: Brecht Van Lommel Co-authored-by: Ray Molenkamp Pull Request: https://projects.blender.org/blender/blender/pulls/134115 --- .../cmake/openimagedenoise.cmake | 5 ++- .../build_environment/cmake/versions.cmake | 2 +- .../patches/oidn_blackwell.diff | 41 +++++++++++++++++++ .../build_environment/windows/vmprep.cmd.txt | 14 +++---- 4 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 build_files/build_environment/patches/oidn_blackwell.diff diff --git a/build_files/build_environment/cmake/openimagedenoise.cmake b/build_files/build_environment/cmake/openimagedenoise.cmake index 6888111b53c..95659231cc3 100644 --- a/build_files/build_environment/cmake/openimagedenoise.cmake +++ b/build_files/build_environment/cmake/openimagedenoise.cmake @@ -67,7 +67,10 @@ endif() set(ODIN_PATCH_COMMAND ${PATCH_CMD} --verbose -p 1 -N -d ${BUILD_DIR}/openimagedenoise/src/external_openimagedenoise < - ${PATCH_DIR}/oidn.diff + ${PATCH_DIR}/oidn.diff && + ${PATCH_CMD} --verbose -p 1 -N -d + ${BUILD_DIR}/openimagedenoise/src/external_openimagedenoise < + ${PATCH_DIR}/oidn_blackwell.diff ) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index 779b3cb374e..865af284c5a 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -9,7 +9,7 @@ # needed but it can be a useful reference. set(RELEASE_GCC_VERSION 11.2.*) -set(RELEASE_CUDA_VERSION 12.3.*) +set(RELEASE_CUDA_VERSION 12.8.*) set(RELEASE_HIP_VERSION 5.7.*) # Libraries diff --git a/build_files/build_environment/patches/oidn_blackwell.diff b/build_files/build_environment/patches/oidn_blackwell.diff new file mode 100644 index 00000000000..dd7ac71dc60 --- /dev/null +++ b/build_files/build_environment/patches/oidn_blackwell.diff @@ -0,0 +1,41 @@ +diff -Naur orig/devices/cuda/CMakeLists.txt external_openimagedenoise/devices/cuda/CMakeLists.txt +--- orig/devices/cuda/CMakeLists.txt ++++ external_openimagedenoise/devices/cuda/CMakeLists.txt +@@ -51,13 +52,15 @@ + set(OIDN_NVCC_SM75_FLAGS "-gencode arch=compute_75,code=sm_75") + set(OIDN_NVCC_SM80_FLAGS "-gencode arch=compute_80,code=sm_80") + set(OIDN_NVCC_SM90_FLAGS "-gencode arch=compute_90,code=sm_90") ++set(OIDN_NVCC_SM100_FLAGS "-gencode arch=compute_100,code=sm_100") ++set(OIDN_NVCC_SM120_FLAGS "-gencode arch=compute_120,code=sm_120") + + set_source_files_properties( + cuda_conv.cu + cuda_device.cu + cuda_engine.cu + PROPERTIES COMPILE_FLAGS +- "${OIDN_NVCC_SM70_FLAGS} ${OIDN_NVCC_SM75_FLAGS} ${OIDN_NVCC_SM80_FLAGS} ${OIDN_NVCC_SM90_FLAGS}" ++ "${OIDN_NVCC_SM70_FLAGS} ${OIDN_NVCC_SM75_FLAGS} ${OIDN_NVCC_SM80_FLAGS} ${OIDN_NVCC_SM90_FLAGS} ${OIDN_NVCC_SM100_FLAGS} ${OIDN_NVCC_SM120_FLAGS}" + ) + + set_source_files_properties( +@@ -72,7 +75,7 @@ + + set_source_files_properties( + cutlass_conv_sm80.cu +- PROPERTIES COMPILE_FLAGS "${OIDN_NVCC_SM80_FLAGS} ${OIDN_NVCC_SM90_FLAGS}" ++ PROPERTIES COMPILE_FLAGS "${OIDN_NVCC_SM80_FLAGS} ${OIDN_NVCC_SM90_FLAGS} ${OIDN_NVCC_SM100_FLAGS} ${OIDN_NVCC_SM120_FLAGS}" + ) + + add_library(OpenImageDenoise_device_cuda SHARED ${OIDN_CUDA_SOURCES} ${OIDN_GPU_SOURCES} ${OIDN_RESOURCE_FILE}) +diff -Naur orig/devices/cuda/cuda_device.h external_openimagedenoise/devices/cuda/cuda_device.h +--- orig/devices/cuda/cuda_device.h ++++ external_openimagedenoise/devices/cuda/cuda_device.h +@@ -50,7 +50,7 @@ + + // Supported compute capabilities + static constexpr int minSMArch = 70; +- static constexpr int maxSMArch = 99; ++ static constexpr int maxSMArch = 120; + + int deviceID = 0; + #if defined(OIDN_DEVICE_CUDA_API_DRIVER) diff --git a/build_files/build_environment/windows/vmprep.cmd.txt b/build_files/build_environment/windows/vmprep.cmd.txt index bf13381278b..4c79b19be79 100644 --- a/build_files/build_environment/windows/vmprep.cmd.txt +++ b/build_files/build_environment/windows/vmprep.cmd.txt @@ -27,7 +27,7 @@ echo # - Meson 1.6.0 echo # - Visual Studio 2010 X64 redist (required for the yaml binary) echo # - Git 2.38.0 echo # - CMake 3.24.2 -echo # - Cuda 12.3.2 +echo # - Cuda 12.8.0 echo # - HIP 5.7.1 echo # echo # Additionally this will also create and populate the following folders : @@ -92,18 +92,18 @@ curl https://download.microsoft.com/download/3/2/2/3224B87F-CFA0-4E70-BDA3-3DE65 echo Installing Visual studio 2010 x64 redist start /wait c:\install\vcredist_x64.exe /passive /norestart -echo Obtaining cuda 12.3.2 -curl https://developer.download.nvidia.com/compute/cuda/12.3.2/local_installers/cuda_12.3.2_546.12_windows.exe -o c:\install\cuda_12.3.2_546.12_windows.exe -echo Installing cuda 12.3.2 +echo Obtaining cuda 12.8.0 +curl https://developer.download.nvidia.com/compute/cuda/12.8.0/local_installers/cuda_12.8.0_571.96_windows.exe -o c:\install\cuda_12.8.0_571.96_windows.exe +echo Installing cuda 12.8.0 echo ********************************************************************* echo ** CUDA is a bit of a pain to install due to it lacking features ** echo ** for unattended installs, the installer should have just started ** -echo ** manually install it to c:\tools\cuda\12.3.2\ this HAS to be the ** +echo ** manually install it to c:\tools\cuda\12.8.0\ this HAS to be the ** echo ** place, don't use anything else, This folder has been created ** echo ** so you should be able to just browse to it in the installer ** echo ********************************************************************* -mkdir c:\tools\cuda\12.3.2\ -start /wait c:\install\cuda_12.3.2_546.12_windows.exe +mkdir c:\tools\cuda\12.8.0\ +start /wait c:\install\cuda_12.8.0_571.96_windows.exe echo Obtaining Hip SDK 5.7.1 curl https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-23.Q4-WinSvr2022-For-HIP.exe -o c:\install\AMD-Software-PRO-Edition-23.Q4-WinSvr2022-For-HIP.exe From fc43f4e1e8ca6dd449f2070d2772d117124192b9 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Thu, 6 Feb 2025 15:08:07 +0100 Subject: [PATCH 19/28] Fix #134035: Grease Pencil: Correct index for multistroke modifier The stroke index was wrong when a influence filter is active in the modifier, this would lead to crashes. Now corrected this by only iterating duplicated strokes in front of the curves geometry. Pull Request: https://projects.blender.org/blender/blender/pulls/134038 --- .../intern/MOD_grease_pencil_multiply.cc | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_multiply.cc b/source/blender/modifiers/intern/MOD_grease_pencil_multiply.cc index 7690dfc1759..fee1432c84c 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_multiply.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_multiply.cc @@ -89,13 +89,15 @@ static bke::CurvesGeometry duplicate_strokes(const bke::CurvesGeometry &curves, const IndexMask curves_mask, const IndexMask unselected_mask, const int count, - int &r_original_point_count) + int &r_original_point_count, + int &r_original_curve_count) { bke::CurvesGeometry masked_curves = bke::curves_copy_curve_selection(curves, curves_mask, {}); bke::CurvesGeometry unselected_curves = bke::curves_copy_curve_selection( curves, unselected_mask, {}); r_original_point_count = masked_curves.points_num(); + r_original_curve_count = masked_curves.curves_num(); Curves *masked_curves_id = bke::curves_new_nomain(masked_curves); Curves *unselected_curves_id = bke::curves_new_nomain(unselected_curves); @@ -136,9 +138,9 @@ static void generate_curves(GreasePencilMultiModifierData &mmd, const IndexMask unselected_mask = curves_mask.complement(curves.curves_range(), mask_memory); - int src_point_count; - bke::CurvesGeometry duplicated_strokes = duplicate_strokes( - curves, curves_mask, unselected_mask, mmd.duplications, src_point_count); + int src_point_count, src_curve_count; + curves = duplicate_strokes( + curves, curves_mask, unselected_mask, mmd.duplications, src_point_count, src_curve_count); const float offset = math::length(math::to_scale(ctx.object->object_to_world())) * mmd.offset; const float distance = mmd.distance; @@ -147,11 +149,11 @@ static void generate_curves(GreasePencilMultiModifierData &mmd, const float fading_opacity = mmd.fading_opacity; const float fading_center = mmd.fading_center; - MutableSpan positions = duplicated_strokes.positions_for_write(); - const Span tangents = duplicated_strokes.evaluated_tangents(); + MutableSpan positions = curves.positions_for_write(); + const Span tangents = curves.evaluated_tangents(); const Span normals = drawing.curve_plane_normals(); - bke::MutableAttributeAccessor attributes = duplicated_strokes.attributes_for_write(); + bke::MutableAttributeAccessor attributes = curves.attributes_for_write(); bke::SpanAttributeWriter opacities = attributes.lookup_or_add_for_write_span( "opacity", bke::AttrDomain::Point); bke::SpanAttributeWriter radii = attributes.lookup_or_add_for_write_span( @@ -162,15 +164,15 @@ static void generate_curves(GreasePencilMultiModifierData &mmd, Array pos_l(src_point_count); Array pos_r(src_point_count); - threading::parallel_for(curves.curves_range(), 128, [&](const IndexRange range) { - for (const int curve : range) { - for (const int point : points_by_curve[curve]) { - const float3 miter = math::cross(normals[curve], tangents[point]) * distance; - pos_l[point] = positions[point] + miter; - pos_r[point] = positions[point] - miter; - } + int src_point_i = 0; + for (const int src_curve_i : IndexRange(src_curve_count)) { + for (const int point : points_by_curve[src_curve_i]) { + const float3 miter = math::cross(normals[src_curve_i], tangents[point]) * distance; + pos_l[src_point_i] = positions[point] + miter; + pos_r[src_point_i] = positions[point] - miter; + src_point_i++; } - }); + } const Span stroke_pos_l = pos_l.as_span(); const Span stroke_pos_r = pos_r.as_span(); @@ -202,7 +204,6 @@ static void generate_curves(GreasePencilMultiModifierData &mmd, radii.finish(); opacities.finish(); - curves = std::move(duplicated_strokes); drawing.tag_topology_changed(); } From b26221a06a11a44cb8f970e9c44614089012b1d1 Mon Sep 17 00:00:00 2001 From: Weizhen Huang Date: Thu, 6 Feb 2025 16:22:19 +0100 Subject: [PATCH 20/28] Fix #74979: Cycles: Support Normal texture for bump mapping on triangles The derivatives of the normal were simply not computed. The offsetted normals are computed by perturbating the barycentric coordinates. At triangle boundaries, the normals are extrapolated, so discontinuities might be visible. Currently only supported on triangles. Pull Request: https://projects.blender.org/blender/blender/pulls/133769 --- intern/cycles/kernel/geom/motion_triangle.h | 36 ++++++++++++ intern/cycles/kernel/geom/triangle.h | 37 ++++++++++++ intern/cycles/kernel/osl/CMakeLists.txt | 1 + intern/cycles/kernel/osl/services.cpp | 9 +++ intern/cycles/kernel/osl/services.h | 1 + intern/cycles/kernel/osl/services_gpu.h | 11 ++++ intern/cycles/kernel/osl/services_shared.h | 57 +++++++++++++++++++ .../osl/shaders/node_texture_coordinate.osl | 8 +++ intern/cycles/kernel/svm/tex_coord.h | 43 ++++++++++++-- tests/data | 2 +- 10 files changed, 198 insertions(+), 7 deletions(-) create mode 100644 intern/cycles/kernel/osl/services_shared.h diff --git a/intern/cycles/kernel/geom/motion_triangle.h b/intern/cycles/kernel/geom/motion_triangle.h index 328c19f81e0..86ae2ab1baa 100644 --- a/intern/cycles/kernel/geom/motion_triangle.h +++ b/intern/cycles/kernel/geom/motion_triangle.h @@ -17,6 +17,8 @@ #include "kernel/bvh/util.h" +#include "kernel/geom/triangle.h" + CCL_NAMESPACE_BEGIN /* Time interpolation of vertex positions and normals */ @@ -216,4 +218,38 @@ ccl_device_inline float3 motion_triangle_smooth_normal(KernelGlobals kg, return motion_triangle_smooth_normal(kg, Ng, object, tri_vindex, numsteps, step, t, u, v); } +/* Compute motion triangle normals at the hit position, and offsetted positions in x and y + * direction for bump mapping. */ +ccl_device_inline float3 motion_triangle_smooth_normal(KernelGlobals kg, + const float3 Ng, + const int object, + const int prim, + const float time, + const float u, + const float v, + const differential du, + const differential dv, + ccl_private float3 &N_x, + ccl_private float3 &N_y) +{ + int numsteps, step; + float t; + uint3 tri_vindex; + motion_triangle_compute_info(kg, object, time, prim, &tri_vindex, &numsteps, &step, &t); + + float3 n[3]; + const int numverts = kernel_data_fetch(objects, object).numverts; + motion_triangle_normals(kg, object, tri_vindex, numsteps, numverts, step, t, n); + + const float3 N = safe_normalize(triangle_interpolate(u, v, n[0], n[1], n[2])); + N_x = safe_normalize( + triangle_interpolate(u + du.dx * BUMP_DX, v + dv.dx * BUMP_DX, n[0], n[1], n[2])); + N_y = safe_normalize( + triangle_interpolate(u + du.dy * BUMP_DY, v + dv.dy * BUMP_DY, n[0], n[1], n[2])); + + N_x = is_zero(N_x) ? Ng : N_x; + N_y = is_zero(N_y) ? Ng : N_y; + return is_zero(N) ? Ng : N; +} + CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/geom/triangle.h b/intern/cycles/kernel/geom/triangle.h index 62a0116b2d4..912918f45e1 100644 --- a/intern/cycles/kernel/geom/triangle.h +++ b/intern/cycles/kernel/geom/triangle.h @@ -18,6 +18,15 @@ CCL_NAMESPACE_BEGIN +/* Evaluate a quantity at barycentric coordinates u, v, given the values at three triangle + * vertices. */ +template +ccl_device_inline T +triangle_interpolate(const float u, const float v, const T f0, const T f1, const T f2) +{ + return (1.0f - u - v) * f0 + u * f1 + v * f2; +} + /* Normal on triangle. */ ccl_device_inline float3 triangle_normal(KernelGlobals kg, ccl_private ShaderData *sd) { @@ -110,6 +119,34 @@ triangle_smooth_normal(KernelGlobals kg, const float3 Ng, const int prim, const return is_zero(N) ? Ng : N; } +/* Compute triangle normals at the hit position, and offsetted positions in x and y direction for + * bump mapping. */ +ccl_device_inline float3 triangle_smooth_normal(KernelGlobals kg, + const float3 Ng, + const int prim, + const float u, + float v, + const differential du, + const differential dv, + ccl_private float3 &N_x, + ccl_private float3 &N_y) +{ + /* Load triangle vertices. */ + const uint3 tri_vindex = kernel_data_fetch(tri_vindex, prim); + + const float3 n0 = kernel_data_fetch(tri_vnormal, tri_vindex.x); + const float3 n1 = kernel_data_fetch(tri_vnormal, tri_vindex.y); + const float3 n2 = kernel_data_fetch(tri_vnormal, tri_vindex.z); + + const float3 N = safe_normalize(triangle_interpolate(u, v, n0, n1, n2)); + N_x = safe_normalize(triangle_interpolate(u + du.dx * BUMP_DX, v + dv.dx * BUMP_DX, n0, n1, n2)); + N_y = safe_normalize(triangle_interpolate(u + du.dy * BUMP_DY, v + dv.dy * BUMP_DY, n0, n1, n2)); + + N_x = is_zero(N_x) ? Ng : N_x; + N_y = is_zero(N_y) ? Ng : N_y; + return is_zero(N) ? Ng : N; +} + ccl_device_inline float3 triangle_smooth_normal_unnormalized(KernelGlobals kg, const ccl_private ShaderData *sd, const float3 Ng, diff --git a/intern/cycles/kernel/osl/CMakeLists.txt b/intern/cycles/kernel/osl/CMakeLists.txt index a2c48c90c29..ccb52e37b30 100644 --- a/intern/cycles/kernel/osl/CMakeLists.txt +++ b/intern/cycles/kernel/osl/CMakeLists.txt @@ -23,6 +23,7 @@ set(HEADER_SRC globals.h osl.h services.h + services_shared.h types.h ) diff --git a/intern/cycles/kernel/osl/services.cpp b/intern/cycles/kernel/osl/services.cpp index 3ca5c7ddb79..662639af4fe 100644 --- a/intern/cycles/kernel/osl/services.cpp +++ b/intern/cycles/kernel/osl/services.cpp @@ -23,6 +23,7 @@ #include "kernel/osl/globals.h" #include "kernel/osl/services.h" +#include "kernel/osl/services_shared.h" #include "kernel/osl/types.h" #include "kernel/integrator/state.h" @@ -69,6 +70,7 @@ ustring OSLRenderServices::u_object_color("object:color"); ustring OSLRenderServices::u_object_alpha("object:alpha"); ustring OSLRenderServices::u_object_index("object:index"); ustring OSLRenderServices::u_object_is_light("object:is_light"); +ustring OSLRenderServices::u_bump_map_normal("geom:bump_map_normal"); ustring OSLRenderServices::u_geom_dupli_generated("geom:dupli_generated"); ustring OSLRenderServices::u_geom_dupli_uv("geom:dupli_uv"); ustring OSLRenderServices::u_material_index("material:index"); @@ -991,6 +993,13 @@ bool OSLRenderServices::get_object_standard_attribute( } return false; } + if (name == u_bump_map_normal) { + float3 f[3]; + if (!attribute_bump_map_normal(kg, sd, f)) { + return false; + } + return set_attribute_float3(f, type, derivatives, val); + } return get_background_attribute(globals, name, type, derivatives, val); } diff --git a/intern/cycles/kernel/osl/services.h b/intern/cycles/kernel/osl/services.h index e806d40ae6f..621be16713c 100644 --- a/intern/cycles/kernel/osl/services.h +++ b/intern/cycles/kernel/osl/services.h @@ -270,6 +270,7 @@ class OSLRenderServices : public OSL::RendererServices { static ustring u_object_alpha; static ustring u_object_index; static ustring u_object_is_light; + static ustring u_bump_map_normal; static ustring u_geom_dupli_generated; static ustring u_geom_dupli_uv; static ustring u_material_index; diff --git a/intern/cycles/kernel/osl/services_gpu.h b/intern/cycles/kernel/osl/services_gpu.h index 5731d4d14ff..b3d8a5ead5e 100644 --- a/intern/cycles/kernel/osl/services_gpu.h +++ b/intern/cycles/kernel/osl/services_gpu.h @@ -11,6 +11,7 @@ #include "kernel/geom/attribute.h" #include "kernel/geom/curve.h" +#include "kernel/geom/motion_triangle.h" #include "kernel/geom/object.h" #include "kernel/geom/point.h" #include "kernel/geom/primitive.h" @@ -27,6 +28,7 @@ #include "util/transform.h" #include "kernel/osl/osl.h" +#include "kernel/osl/services_shared.h" namespace DeviceStrings { @@ -68,6 +70,8 @@ ccl_device_constant DeviceString u_object_alpha = 11165053919428293151ull; ccl_device_constant DeviceString u_object_index = 6588325838217472556ull; /* "object:is_light" */ ccl_device_constant DeviceString u_object_is_light = 13979755312845091842ull; +/* "geom:bump_map_normal" */ +ccl_device_constant DeviceString u_bump_map_normal = 9592102745179132106ull; /* "geom:dupli_generated" */ ccl_device_constant DeviceString u_geom_dupli_generated = 6715607178003388908ull; /* "geom:dupli_uv" */ @@ -1353,6 +1357,13 @@ ccl_device_inline bool get_object_standard_attribute(KernelGlobals kg, return false; } } + if (name == DeviceStrings::u_bump_map_normal) { + float3 f[3]; + if (!attribute_bump_map_normal(kg, sd, f)) { + return false; + } + return set_attribute_float3(f, type, derivatives, val); + } return get_background_attribute(kg, sg, sd, name, type, derivatives, val); } diff --git a/intern/cycles/kernel/osl/services_shared.h b/intern/cycles/kernel/osl/services_shared.h new file mode 100644 index 00000000000..3d3b44dca7b --- /dev/null +++ b/intern/cycles/kernel/osl/services_shared.h @@ -0,0 +1,57 @@ +/* SPDX-FileCopyrightText: 2025 Blender Foundation + * + * SPDX-License-Identifier: Apache-2.0 */ + +/* Shared functions between OSL on CPU and GPU. */ + +#pragma once + +#include "kernel/geom/motion_triangle.h" +#include "kernel/geom/triangle.h" + +CCL_NAMESPACE_BEGIN + +/* TODO: deduplicate function `set_attribute_float3()` in CPU and GPU. */ + +bool attribute_bump_map_normal(KernelGlobals kg, ccl_private const ShaderData *sd, float3 f[3]) +{ + if (!(sd->type & PRIMITIVE_TRIANGLE) || !(sd->shader & SHADER_SMOOTH_NORMAL)) { + /* TODO: implement for curve. */ + return false; + } + + const bool backfacing = (sd->flag & SD_BACKFACING); + + /* Fallback when the smooth normal is zero. */ + float3 Ng = backfacing ? -sd->Ng : sd->Ng; + object_inverse_normal_transform(kg, sd, &Ng); + + if (sd->type == PRIMITIVE_TRIANGLE) { + f[0] = triangle_smooth_normal(kg, Ng, sd->prim, sd->u, sd->v, sd->du, sd->dv, f[1], f[2]); + } + else { + assert(sd->type & PRIMITIVE_MOTION_TRIANGLE); + f[0] = motion_triangle_smooth_normal( + kg, Ng, sd->object, sd->prim, sd->time, sd->u, sd->v, sd->du, sd->dv, f[1], f[2]); + } + + if (sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED) { + /* Transform to local space. */ + object_inverse_normal_transform(kg, sd, f); + object_inverse_normal_transform(kg, sd, f + 1); + object_inverse_normal_transform(kg, sd, f + 2); + } + + if (backfacing) { + f[0] = -f[0]; + f[1] = -f[1]; + f[2] = -f[2]; + } + + f[1] -= f[0]; + f[2] -= f[0]; + + return true; +} + +CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl b/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl index 214c4c6af70..9c611195d70 100644 --- a/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl +++ b/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl @@ -80,6 +80,11 @@ shader node_texture_coordinate( Object += Dx(Object) * BUMP_DX; Camera += Dx(Camera) * BUMP_DX; Window += Dx(Window) * BUMP_DX; + if (getattribute("geom:bump_map_normal", Normal)) { + /* A scaling of `BUMP_DX` is already applied when computing the derivatives, no additional + * scaling is needed here. */ + Normal = normalize(Normal + Dx(Normal)); + } } else if (bump_offset == "dy") { if (!from_dupli) { @@ -89,6 +94,9 @@ shader node_texture_coordinate( Object += Dy(Object) * BUMP_DY; Camera += Dy(Camera) * BUMP_DY; Window += Dy(Window) * BUMP_DY; + if (getattribute("geom:bump_map_normal", Normal)) { + Normal = normalize(Normal + Dy(Normal)); + } } Window[2] = 0.0; diff --git a/intern/cycles/kernel/svm/tex_coord.h b/intern/cycles/kernel/svm/tex_coord.h index 2f369755f91..16444e272d9 100644 --- a/intern/cycles/kernel/svm/tex_coord.h +++ b/intern/cycles/kernel/svm/tex_coord.h @@ -6,6 +6,7 @@ #include "kernel/camera/camera.h" +#include "kernel/geom/motion_triangle.h" #include "kernel/geom/object.h" #include "kernel/geom/primitive.h" @@ -105,6 +106,38 @@ ccl_device_noinline int svm_node_tex_coord(KernelGlobals kg, return offset; } +ccl_device_inline float3 texco_normal_from_uv(KernelGlobals kg, + ccl_private ShaderData *sd, + const float u, + const float v) +{ + float3 N; + if ((sd->type & PRIMITIVE_TRIANGLE) && (sd->shader & SHADER_SMOOTH_NORMAL)) { + N = (sd->type == PRIMITIVE_TRIANGLE) ? + triangle_smooth_normal(kg, zero_float3(), sd->prim, u, v) : + motion_triangle_smooth_normal(kg, zero_float3(), sd->object, sd->prim, u, v, sd->time); + if (is_zero(N)) { + N = sd->Ng; + object_inverse_normal_transform(kg, sd, &N); + } + else { + if (sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED) { + /* Transform to local space. */ + object_inverse_normal_transform(kg, sd, &N); + } + if (sd->flag & SD_BACKFACING) { + N = -N; + } + } + } + else { + /* TODO: implement for curve. */ + N = sd->N; + object_inverse_normal_transform(kg, sd, &N); + } + return N; +} + ccl_device_noinline int svm_node_tex_coord_bump_dx(KernelGlobals kg, ccl_private ShaderData *sd, const uint32_t path_flag, @@ -135,9 +168,8 @@ ccl_device_noinline int svm_node_tex_coord_bump_dx(KernelGlobals kg, break; } case NODE_TEXCO_NORMAL: { - /* TODO(weizhen): implement. */ - data = sd->N; - object_inverse_normal_transform(kg, sd, &data); + data = texco_normal_from_uv( + kg, sd, sd->u + sd->du.dx * BUMP_DX, sd->v + sd->dv.dx * BUMP_DX); break; } case NODE_TEXCO_CAMERA: { @@ -229,9 +261,8 @@ ccl_device_noinline int svm_node_tex_coord_bump_dy(KernelGlobals kg, break; } case NODE_TEXCO_NORMAL: { - /* TODO(weizhen): implement. */ - data = sd->N; - object_inverse_normal_transform(kg, sd, &data); + data = texco_normal_from_uv( + kg, sd, sd->u + sd->du.dy * BUMP_DY, sd->v + sd->dv.dy * BUMP_DY); break; } case NODE_TEXCO_CAMERA: { diff --git a/tests/data b/tests/data index 841659d63a8..447bf418171 160000 --- a/tests/data +++ b/tests/data @@ -1 +1 @@ -Subproject commit 841659d63a8cda07cff17d6ac7a5e7a69d5b9207 +Subproject commit 447bf418171ba4db28c6d7cecd51c396c2171168 From 7f1b8d947f3a62a4492d8259f9855995f9ed12ef Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 6 Feb 2025 11:23:40 -0500 Subject: [PATCH 21/28] Fix: Potential crash in attribute search code Need to properly account for the change to StringRef when checking if the string is empty. --- .../templates/interface_template_attribute_search.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/interface/templates/interface_template_attribute_search.cc b/source/blender/editors/interface/templates/interface_template_attribute_search.cc index c896da16124..7375241b685 100644 --- a/source/blender/editors/interface/templates/interface_template_attribute_search.cc +++ b/source/blender/editors/interface/templates/interface_template_attribute_search.cc @@ -62,7 +62,7 @@ void attribute_search_add_items(StringRef str, static GeometryAttributeInfo dummy_info; /* Any string may be valid, so add the current search string along with the hints. */ - if (str[0] != '\0') { + if (!str.is_empty()) { bool contained = false; for (const GeometryAttributeInfo *attribute_info : infos) { if (attribute_info->name == str) { @@ -77,7 +77,7 @@ void attribute_search_add_items(StringRef str, } } - if (str[0] == '\0' && !is_first) { + if (str.is_empty() && !is_first) { /* Allow clearing the text field when the string is empty, but not on the first pass, * or opening an attribute field for the first time would show this search item. */ dummy_info.name = str; From 4f833b0b5f93a8da891621e25063d76a100d2f07 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 6 Feb 2025 17:47:52 +0100 Subject: [PATCH 22/28] Refactor: Add StringRef overloads to translation functions Currently UI code always has to use char pointers when interacting with the translation system. This makes benefiting from the use C++ strings and StringRef more difficult. That means we're leaving some type safety and performance on the table. This PR adds StringRef overloads to the translation API functions and removes the few calls to `.c_str()` that are now unnecessary. Pull Request: https://projects.blender.org/blender/blender/pulls/133887 --- source/blender/blenkernel/intern/node.cc | 2 +- .../blenkernel/intern/node_tree_update.cc | 4 +- .../blenloader/intern/versioning_common.cc | 2 +- .../blentranslation/BLT_translation.hh | 7 ++ .../blentranslation/intern/blt_translation.cc | 113 ++++++++++++++---- .../blentranslation/intern/messages.cc | 17 ++- .../blentranslation/intern/messages.hh | 3 +- .../editors/asset/intern/asset_menu_utils.cc | 2 +- .../editors/geometry/node_group_operator.cc | 4 +- source/blender/editors/interface/interface.cc | 2 +- .../regions/interface_region_tooltip.cc | 9 +- .../interface_template_node_inputs.cc | 2 +- .../editors/interface/views/tree_view.cc | 2 +- .../editors/object/add_modifier_assets.cc | 4 +- .../editors/space_node/add_menu_assets.cc | 4 +- .../blender/editors/space_node/node_draw.cc | 8 +- .../editors/space_node/node_templates.cc | 2 +- .../nodes/node_geo_attribute_statistic.cc | 2 +- .../nodes/intern/socket_search_link.cc | 4 +- source/blender/python/BPY_extern.hh | 11 +- .../python/intern/bpy_app_translations.cc | 11 +- 21 files changed, 151 insertions(+), 64 deletions(-) diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 94ad3fb3ef5..0b3ab4f54fc 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1459,7 +1459,7 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node) * Data have their own translation option! * This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler * than adding "do_translate" flags to this func (and labelfunc() as well). */ - STRNCPY_UTF8(node->name, DATA_(ntype->ui_name.c_str())); + DATA_(ntype->ui_name).copy_utf8_truncated(node->name); node_unique_name(ntree, node); /* Generally sockets should be added after the initialization, because the set of sockets might diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index 700985aa6eb..6f08b55a744 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -1216,8 +1216,8 @@ class NodeTreeMainUpdater { NodeLinkError{fmt::format("{}: {} " BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE " {}", TIP_("Conversion is not supported"), - TIP_(link->fromsock->typeinfo->label.c_str()), - TIP_(link->tosock->typeinfo->label.c_str()))}); + TIP_(link->fromsock->typeinfo->label), + TIP_(link->tosock->typeinfo->label))}); continue; } } diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index 2174da5d963..66cae31f3a0 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -213,7 +213,7 @@ bNode &version_node_add_empty(bNodeTree &ntree, const char *idname) blender::bke::node_unique_id(&ntree, node); STRNCPY(node->idname, idname); - STRNCPY_UTF8(node->name, DATA_(ntype->ui_name.c_str())); + DATA_(ntype->ui_name).copy_utf8_truncated(node->name); blender::bke::node_unique_name(&ntree, node); node->flag = NODE_SELECT | NODE_OPTIONS | NODE_INIT; diff --git a/source/blender/blentranslation/BLT_translation.hh b/source/blender/blentranslation/BLT_translation.hh index a25f26eb687..db936d78467 100644 --- a/source/blender/blentranslation/BLT_translation.hh +++ b/source/blender/blentranslation/BLT_translation.hh @@ -14,6 +14,7 @@ bool BLT_is_default_context(blender::StringRef msgctxt); const char *BLT_pgettext(const char *msgctxt, const char *msgid); +blender::StringRef BLT_pgettext(blender::StringRef msgctxt, blender::StringRef msgid); /* Translation */ /* - iface includes buttons in the user interface: short labels displayed in windows, panels, @@ -27,10 +28,16 @@ bool BLT_translate_tooltips(); bool BLT_translate_reports(); bool BLT_translate_new_dataname(); const char *BLT_translate_do(const char *msgctxt, const char *msgid); +blender::StringRef BLT_translate_do(blender::StringRef msgctxt, blender::StringRef msgid); const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid); +blender::StringRef BLT_translate_do_iface(blender::StringRef msgctxt, blender::StringRef msgid); const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid); +blender::StringRef BLT_translate_do_tooltip(blender::StringRef msgctxt, blender::StringRef msgid); const char *BLT_translate_do_report(const char *msgctxt, const char *msgid); +blender::StringRef BLT_translate_do_report(blender::StringRef msgctxt, blender::StringRef msgid); const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid); +blender::StringRef BLT_translate_do_new_dataname(blender::StringRef msgctxt, + blender::StringRef msgid); /* The "translation-marker" macro. */ #define N_(msgid) msgid diff --git a/source/blender/blentranslation/intern/blt_translation.cc b/source/blender/blentranslation/intern/blt_translation.cc index a259be32756..563432482de 100644 --- a/source/blender/blentranslation/intern/blt_translation.cc +++ b/source/blender/blentranslation/intern/blt_translation.cc @@ -26,6 +26,7 @@ #endif /* WITH_INTERNATIONAL */ using blender::StringRef; +using blender::StringRefNull; bool BLT_is_default_context(const StringRef msgctxt) { @@ -36,35 +37,47 @@ bool BLT_is_default_context(const StringRef msgctxt) return (msgctxt.is_empty() || msgctxt[0] == BLT_I18NCONTEXT_DEFAULT_BPYRNA[0]); } -const char *BLT_pgettext(const char *msgctxt, const char *msgid) +static std::optional pgettext(StringRef msgctxt, const StringRef msgid) { #ifdef WITH_INTERNATIONAL - const char *ret = msgid; - - if (msgid && msgid[0]) { - if (BLT_is_default_context(msgctxt)) { - msgctxt = BLT_I18NCONTEXT_DEFAULT; - } - - ret = blender::locale::translate(0, msgctxt, msgid); - - /* No translation found? Try py script translations. */ - if (ret == nullptr) { + if (msgid.is_empty()) { + return std::nullopt; + } + if (BLT_is_default_context(msgctxt)) { + msgctxt = BLT_I18NCONTEXT_DEFAULT; + } + if (const std::optional translation = blender::locale::translate( + 0, msgctxt, msgid)) + { + return translation; + } # ifdef WITH_PYTHON - ret = BPY_app_translations_py_pgettext(msgctxt, msgid); -# else - ret = msgid; + return BPY_app_translations_py_pgettext(msgctxt, msgid); # endif - } - } - - return ret; #else (void)msgctxt; - return msgid; + return std::nullopt; #endif } +const char *BLT_pgettext(const char *msgctxt, const char *msgid) +{ + const std::optional translation = pgettext(msgctxt, msgid); + if (!translation) { + return msgid; + } + return translation->c_str(); +} + +blender::StringRef BLT_pgettext(blender::StringRef msgctxt, blender::StringRef msgid) +{ + const std::optional translation = pgettext(msgctxt, msgid); + if (!translation) { + return msgid; + } + return *translation; +} + bool BLT_translate() { #ifdef WITH_INTERNATIONAL @@ -110,7 +123,7 @@ bool BLT_translate_new_dataname() #endif } -const char *BLT_translate_do(const char *msgctxt, const char *msgid) +template StringT translate_do(StringT msgctxt, StringT msgid) { #ifdef WITH_INTERNATIONAL if (BLT_translate()) { @@ -125,7 +138,17 @@ const char *BLT_translate_do(const char *msgctxt, const char *msgid) #endif } -const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid) +const char *BLT_translate_do(const char *msgctxt, const char *msgid) +{ + return translate_do(msgctxt, msgid); +} + +StringRef BLT_translate_do(StringRef msgctxt, StringRef msgid) +{ + return translate_do(msgctxt, msgid); +} + +template StringT translate_do_iface(StringT msgctxt, StringT msgid) { #ifdef WITH_INTERNATIONAL if (BLT_translate_iface()) { @@ -140,7 +163,17 @@ const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid) #endif } -const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid) +const char *BLT_translate_do_iface(const char *msgctxt, const char *msgid) +{ + return translate_do_iface(msgctxt, msgid); +} + +StringRef BLT_translate_do_iface(StringRef msgctxt, StringRef msgid) +{ + return translate_do_iface(msgctxt, msgid); +} + +template StringT translate_do_tooltip(StringT msgctxt, StringT msgid) { #ifdef WITH_INTERNATIONAL if (BLT_translate_tooltips()) { @@ -155,7 +188,17 @@ const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid) #endif } -const char *BLT_translate_do_report(const char *msgctxt, const char *msgid) +const char *BLT_translate_do_tooltip(const char *msgctxt, const char *msgid) +{ + return translate_do_tooltip(msgctxt, msgid); +} + +StringRef BLT_translate_do_tooltip(StringRef msgctxt, StringRef msgid) +{ + return translate_do_tooltip(msgctxt, msgid); +} + +template StringT translate_do_report(StringT msgctxt, StringT msgid) { #ifdef WITH_INTERNATIONAL if (BLT_translate_reports()) { @@ -170,7 +213,17 @@ const char *BLT_translate_do_report(const char *msgctxt, const char *msgid) #endif } -const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid) +const char *BLT_translate_do_report(const char *msgctxt, const char *msgid) +{ + return translate_do_report(msgctxt, msgid); +} + +StringRef BLT_translate_do_report(StringRef msgctxt, StringRef msgid) +{ + return translate_do_report(msgctxt, msgid); +} + +template StringT translate_do_new_dataname(StringT msgctxt, StringT msgid) { #ifdef WITH_INTERNATIONAL if (BLT_translate_new_dataname()) { @@ -184,3 +237,13 @@ const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid return msgid; #endif } + +const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid) +{ + return translate_do_new_dataname(msgctxt, msgid); +} + +StringRef BLT_translate_do_new_dataname(StringRef msgctxt, StringRef msgid) +{ + return translate_do_new_dataname(msgctxt, msgid); +} diff --git a/source/blender/blentranslation/intern/messages.cc b/source/blender/blentranslation/intern/messages.cc index ff1281e4b5a..88737f9c1e0 100644 --- a/source/blender/blentranslation/intern/messages.cc +++ b/source/blender/blentranslation/intern/messages.cc @@ -461,14 +461,19 @@ class MOMessages { } } - const char *translate(const int domain, const StringRef context, const StringRef str) const + std::optional translate(const int domain, + const StringRef context, + const StringRef str) const { if (domain < 0 || domain >= catalogs_.size()) { - return nullptr; + return std::nullopt; } const MessageKeyRef key{context, str}; const std::string *result = catalogs_[domain].lookup_ptr_as(key); - return (result) ? result->c_str() : nullptr; + if (!result) { + return std::nullopt; + } + return *result; } const std::string &error() @@ -598,10 +603,12 @@ void free() global_full_name = ""; } -const char *translate(const int domain, const StringRef context, const StringRef key) +std::optional translate(const int domain, + const StringRef context, + const StringRef key) { if (!global_messages) { - return nullptr; + return std::nullopt; } return global_messages->translate(domain, context, key); diff --git a/source/blender/blentranslation/intern/messages.hh b/source/blender/blentranslation/intern/messages.hh index 862b139920d..6d7489e4448 100644 --- a/source/blender/blentranslation/intern/messages.hh +++ b/source/blender/blentranslation/intern/messages.hh @@ -8,6 +8,7 @@ * Adapted from `boost::locale`. */ +#include #include #include "BLI_string_ref.hh" @@ -20,7 +21,7 @@ void init(const StringRef locale_full_name, /* Local name. */ const Vector &paths); /* Search paths for .mo files. */ void free(); -const char *translate(const int domain, const StringRef context, const StringRef key); +std::optional translate(int domain, StringRef context, StringRef key); const char *full_name(); #if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL) diff --git a/source/blender/editors/asset/intern/asset_menu_utils.cc b/source/blender/editors/asset/intern/asset_menu_utils.cc index acdd41e5114..cbe1e24b586 100644 --- a/source/blender/editors/asset/intern/asset_menu_utils.cc +++ b/source/blender/editors/asset/intern/asset_menu_utils.cc @@ -141,7 +141,7 @@ void draw_menu_for_catalog(const asset_system::AssetCatalogTreeItem &item, { uiLayout *col = uiLayoutColumn(&layout, false); uiLayoutSetContextString(col, "asset_catalog_path", item.catalog_path().c_str()); - uiItemM(col, menu_name, IFACE_(item.get_name().c_str()), ICON_NONE); + uiItemM(col, menu_name, IFACE_(item.get_name()), ICON_NONE); } } // namespace blender::ed::asset diff --git a/source/blender/editors/geometry/node_group_operator.cc b/source/blender/editors/geometry/node_group_operator.cc index 09c4b22b301..55db53cf3b9 100644 --- a/source/blender/editors/geometry/node_group_operator.cc +++ b/source/blender/editors/geometry/node_group_operator.cc @@ -1214,7 +1214,7 @@ static void catalog_assets_draw(const bContext *C, Menu *menu) PointerRNA props_ptr; uiItemFullO_ptr(layout, ot, - IFACE_(asset->get_name().c_str()), + IFACE_(asset->get_name()), ICON_NONE, nullptr, WM_OP_INVOKE_REGION_WIN, @@ -1294,7 +1294,7 @@ static void catalog_assets_draw_unassigned(const bContext *C, Menu *menu) PointerRNA props_ptr; uiItemFullO_ptr(layout, ot, - IFACE_(asset->get_name().c_str()), + IFACE_(asset->get_name()), ICON_NONE, nullptr, WM_OP_INVOKE_REGION_WIN, diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 244e9090042..9de593eea8f 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -6789,7 +6789,7 @@ std::string UI_but_context_menu_title_from_button(uiBut &but) return ""; } const blender::ui::AbstractView &tree_view = view_item_but.view_item->get_view(); - return IFACE_(tree_view.get_context_menu_title().c_str()); + return IFACE_(tree_view.get_context_menu_title()); } return UI_but_string_get_label(but); } diff --git a/source/blender/editors/interface/regions/interface_region_tooltip.cc b/source/blender/editors/interface/regions/interface_region_tooltip.cc index 6e6bb7cc6c3..b28391fc23c 100644 --- a/source/blender/editors/interface/regions/interface_region_tooltip.cc +++ b/source/blender/editors/interface/regions/interface_region_tooltip.cc @@ -801,27 +801,26 @@ static std::string ui_tooltip_color_string(const blender::float4 &color, rgba_float_to_uchar(hex, color); if (show_alpha) { return fmt::format("{}: #{:02X}{:02X}{:02X}{:02X}", - TIP_(title.c_str()), + TIP_(title), int(hex[0]), int(hex[1]), int(hex[2]), int(hex[3])); } return fmt::format( - "{}: #{:02X}{:02X}{:02X}", TIP_(title.c_str()), int(hex[0]), int(hex[1]), int(hex[2])); + "{}: #{:02X}{:02X}{:02X}", TIP_(title), int(hex[0]), int(hex[1]), int(hex[2])); } if (show_alpha) { return fmt::format("{}: {:.3f} {:.3f} {:.3f} {:.3f}", - TIP_(title.c_str()), + TIP_(title), color[0], color[1], color[2], color[3]); } - return fmt::format( - "{}: {:.3f} {:.3f} {:.3f}", TIP_(title.c_str()), color[0], color[1], color[2]); + return fmt::format("{}: {:.3f} {:.3f} {:.3f}", TIP_(title), color[0], color[1], color[2]); }; static std::unique_ptr ui_tooltip_data_from_button_or_extra_icon( diff --git a/source/blender/editors/interface/templates/interface_template_node_inputs.cc b/source/blender/editors/interface/templates/interface_template_node_inputs.cc index d914449d69d..dd99dbb9751 100644 --- a/source/blender/editors/interface/templates/interface_template_node_inputs.cc +++ b/source/blender/editors/interface/templates/interface_template_node_inputs.cc @@ -107,7 +107,7 @@ static void draw_node_inputs_recursive(bContext *C, PanelLayout panel = uiLayoutPanel(C, layout, panel_idname.c_str(), panel_decl.default_collapsed); const bool has_used_inputs = panel_has_input_affecting_node_output(node, panel_decl); uiLayoutSetActive(panel.header, has_used_inputs); - uiItemL(panel.header, IFACE_(panel_decl.name.c_str()), ICON_NONE); + uiItemL(panel.header, IFACE_(panel_decl.name), ICON_NONE); if (!panel.body) { return; } diff --git a/source/blender/editors/interface/views/tree_view.cc b/source/blender/editors/interface/views/tree_view.cc index d009dc41b22..a93aa37bfd9 100644 --- a/source/blender/editors/interface/views/tree_view.cc +++ b/source/blender/editors/interface/views/tree_view.cc @@ -985,7 +985,7 @@ void BasicTreeViewItem::build_row(uiLayout &row) void BasicTreeViewItem::add_label(uiLayout &layout, StringRefNull label_override) { const StringRefNull label = label_override.is_empty() ? StringRefNull(label_) : label_override; - uiItemL(&layout, IFACE_(label.c_str()), icon); + uiItemL(&layout, IFACE_(label), icon); } void BasicTreeViewItem::on_activate(bContext &C) diff --git a/source/blender/editors/object/add_modifier_assets.cc b/source/blender/editors/object/add_modifier_assets.cc index 05cc9bd8223..b5b037ebdd5 100644 --- a/source/blender/editors/object/add_modifier_assets.cc +++ b/source/blender/editors/object/add_modifier_assets.cc @@ -101,7 +101,7 @@ static void catalog_assets_draw(const bContext *C, Menu *menu) PointerRNA props_ptr; uiItemFullO_ptr(layout, ot, - IFACE_(asset->get_name().c_str()), + IFACE_(asset->get_name()), ICON_NONE, nullptr, WM_OP_INVOKE_DEFAULT, @@ -142,7 +142,7 @@ static void unassigned_assets_draw(const bContext *C, Menu *menu) PointerRNA props_ptr; uiItemFullO_ptr(layout, ot, - IFACE_(asset->get_name().c_str()), + IFACE_(asset->get_name()), ICON_NONE, nullptr, WM_OP_INVOKE_DEFAULT, diff --git a/source/blender/editors/space_node/add_menu_assets.cc b/source/blender/editors/space_node/add_menu_assets.cc index d4523e8418c..023de805932 100644 --- a/source/blender/editors/space_node/add_menu_assets.cc +++ b/source/blender/editors/space_node/add_menu_assets.cc @@ -187,7 +187,7 @@ static void node_add_catalog_assets_draw(const bContext *C, Menu *menu) PointerRNA op_ptr; uiItemFullO(layout, "NODE_OT_add_group_asset", - IFACE_(asset->get_name().c_str()), + IFACE_(asset->get_name()), ICON_NONE, nullptr, WM_OP_INVOKE_REGION_WIN, @@ -227,7 +227,7 @@ static void node_add_unassigned_assets_draw(const bContext *C, Menu *menu) PointerRNA op_ptr; uiItemFullO(menu->layout, "NODE_OT_add_group_asset", - IFACE_(asset->get_name().c_str()), + IFACE_(asset->get_name()), ICON_NONE, nullptr, WM_OP_INVOKE_REGION_WIN, diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 1c2ac1ab75f..e57cace0c7d 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1647,8 +1647,8 @@ static void create_inspection_string_for_field_info(const bNodeSocket &socket, fmt::format_to(fmt::appender(buf), "\n"); for (const int i : input_tooltips.index_range()) { - const blender::StringRefNull tooltip = input_tooltips[i]; - fmt::format_to(fmt::appender(buf), fmt::runtime(TIP_("\u2022 {}")), TIP_(tooltip.c_str())); + const blender::StringRef tooltip = input_tooltips[i]; + fmt::format_to(fmt::appender(buf), fmt::runtime(TIP_("\u2022 {}")), TIP_(tooltip)); if (i < input_tooltips.size() - 1) { fmt::format_to(fmt::appender(buf), ".\n"); } @@ -1849,7 +1849,7 @@ static std::optional create_description_inspection_string(const bNo return std::nullopt; } - return TIP_(description.c_str()); + return TIP_(description); } static std::optional create_log_inspection_string(geo_log::GeoTreeLog *geo_tree_log, @@ -2516,7 +2516,7 @@ static void node_draw_panels(bNodeTree &ntree, const bNode &node, uiBlock &block &block, UI_BTYPE_LABEL, 0, - IFACE_(panel_decl.name.c_str()), + IFACE_(panel_decl.name), int(draw_bounds.xmin + NODE_MARGIN_X + 0.4f), int(*panel_runtime.header_center_y - NODE_DYS), short(draw_bounds.xmax - draw_bounds.xmin - (30.0f * UI_SCALE_FAC)), diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index 59361aa3768..72932d2a723 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -755,7 +755,7 @@ static void ui_node_draw_panel(uiLayout &layout, UI_BTYPE_BUT, 0, panel_state.is_collapsed() ? ICON_RIGHTARROW : ICON_DOWNARROW_HLT, - IFACE_(panel_decl.name.c_str()), + IFACE_(panel_decl.name), 0, 0, UI_UNIT_X * 4, diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc index 0afbcd766d3..7d4a936c4ed 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc @@ -92,7 +92,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) for (const StringRefNull name : {"Mean", "Median", "Sum", "Min", "Max", "Range", "Standard Deviation", "Variance"}) { - params.add_item(IFACE_(name.c_str()), [node_type, name, type](LinkSearchOpParams ¶ms) { + params.add_item(IFACE_(name), [node_type, name, type](LinkSearchOpParams ¶ms) { bNode &node = params.add_node(node_type); node.custom1 = *type; params.update_and_connect_available_socket(node, name); diff --git a/source/blender/nodes/intern/socket_search_link.cc b/source/blender/nodes/intern/socket_search_link.cc index 6f1aeb914f0..e802b2a0af3 100644 --- a/source/blender/nodes/intern/socket_search_link.cc +++ b/source/blender/nodes/intern/socket_search_link.cc @@ -25,7 +25,7 @@ void GatherLinkSearchOpParams::add_item(std::string socket_name, { std::string name = fmt::format("{}{} " UI_MENU_ARROW_SEP " {}", - IFACE_(node_type_.ui_name.c_str()), + IFACE_(node_type_.ui_name), node_type_.deprecation_notice ? IFACE_(" (Deprecated)") : "", socket_name); @@ -134,7 +134,7 @@ void search_link_ops_for_declarations(GatherLinkSearchOpParams ¶ms, * sockets. */ const int weight = (&socket == main_socket) ? 0 : -1 - i; params.add_item( - IFACE_(socket.name.c_str()), + IFACE_(socket.name), [&node_type, &socket](LinkSearchOpParams ¶ms) { bNode &node = params.add_node(node_type); socket.make_available(node); diff --git a/source/blender/python/BPY_extern.hh b/source/blender/python/BPY_extern.hh index 0705771c9ea..e0e6cb6f908 100644 --- a/source/blender/python/BPY_extern.hh +++ b/source/blender/python/BPY_extern.hh @@ -10,6 +10,14 @@ #include "BLI_sys_types.h" +#ifdef WITH_INTERNATIONAL + +# include + +# include "BLI_string_ref.hh" + +#endif + struct ARegionType; struct AnimationEvalContext; struct ChannelDriver; /* DNA_anim_types.h */ @@ -142,5 +150,6 @@ void BPY_callback_wm_free(wmWindowManager *wm); /* I18n for addons */ #ifdef WITH_INTERNATIONAL -const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid); +std::optional BPY_app_translations_py_pgettext(blender::StringRef msgctxt, + blender::StringRef msgid); #endif diff --git a/source/blender/python/intern/bpy_app_translations.cc b/source/blender/python/intern/bpy_app_translations.cc index 71170bb5539..5beb6a039d8 100644 --- a/source/blender/python/intern/bpy_app_translations.cc +++ b/source/blender/python/intern/bpy_app_translations.cc @@ -236,7 +236,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) } /* Do not overwrite existing keys! */ - if (BPY_app_translations_py_pgettext(msgctxt, msgid) == msgid) { + if (!BPY_app_translations_py_pgettext(msgctxt, msgid).has_value()) { MessageKey key; key.context = BLT_is_default_context(msgctxt) ? BLT_I18NCONTEXT_DEFAULT_BPYRNA : msgctxt; key.str = msgid; @@ -254,7 +254,8 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) MEM_SAFE_FREE(language_variant); } -const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *msgid) +std::optional BPY_app_translations_py_pgettext(const StringRef msgctxt, + const StringRef msgid) { # define STATIC_LOCALE_SIZE 32 /* Should be more than enough! */ @@ -263,7 +264,7 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms /* Just in case, should never happen! */ if (!_translations) { - return msgid; + return std::nullopt; } tmp = BLT_lang_get(); @@ -288,9 +289,9 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms const std::string *result = get_translations_cache()->lookup_ptr_as(key); if (!result) { - return msgid; + return std::nullopt; } - return result->c_str(); + return *result; # undef STATIC_LOCALE_SIZE } From f9a45702fa481c5306b814d3e2620d2b881cbb1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 6 Feb 2025 17:49:45 +0100 Subject: [PATCH 23/28] Anim: remove `ActionLayer.mix_mode` and `.influence` from RNA Remove the `ActionLayer.mix_mode` and `ActionLayer.influence` properties from RNA. The animation evaluation already takes these into account, but there is no guarantee that the mixing that is currently implemented is going to be mathematically identical to the eventual implementation. So better to not expose the properties quite yet. Pull Request: https://projects.blender.org/blender/blender/pulls/134186 --- source/blender/makesrna/intern/rna_action.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/blender/makesrna/intern/rna_action.cc b/source/blender/makesrna/intern/rna_action.cc index 53d52782dc4..1fcb9875f01 100644 --- a/source/blender/makesrna/intern/rna_action.cc +++ b/source/blender/makesrna/intern/rna_action.cc @@ -29,6 +29,8 @@ using namespace blender; +/* Disabled for now, see comment in `rna_def_action_layer()` for more info. */ +#if 0 const EnumPropertyItem rna_enum_layer_mix_mode_items[] = { {int(animrig::Layer::MixMode::Replace), "REPLACE", @@ -57,6 +59,7 @@ const EnumPropertyItem rna_enum_layer_mix_mode_items[] = { "Channels in this layer are multiplied with underlying layers on a per-channel basis"}, {0, nullptr, 0, nullptr, nullptr}, }; +#endif const EnumPropertyItem rna_enum_strip_type_items[] = { {int(animrig::Strip::Type::Keyframe), @@ -127,11 +130,14 @@ static animrig::Strip &rna_data_strip(const PointerRNA *ptr) return reinterpret_cast(ptr->data)->wrap(); } +/* Disabled for now, see comment in `rna_def_action_layer()` for more info. */ +# if 0 static void rna_Action_tag_animupdate(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr) { animrig::Action &action = rna_action(ptr); DEG_id_tag_update(&action.id, ID_RECALC_ANIMATION); } +# endif static animrig::Channelbag &rna_data_channelbag(const PointerRNA *ptr) { @@ -2209,6 +2215,12 @@ static void rna_def_action_layer(BlenderRNA *brna) prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_struct_name_property(srna, prop); + /* Disabled in RNA until layered animation is actually implemented. + * + * The animation evaluation already takes these into account, but there is no guarantee that the + * mixing that is currently implemented is going to be mathematically identical to the eventual + * implementation. */ +# if 0 prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text( @@ -2224,6 +2236,7 @@ static void rna_def_action_layer(BlenderRNA *brna) RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_enum_items(prop, rna_enum_layer_mix_mode_items); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN, "rna_Action_tag_animupdate"); +# endif /* Collection properties. */ prop = RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE); From 0f8eed340e64b48944c2a1a6fe90a8254c048d97 Mon Sep 17 00:00:00 2001 From: weizhen Date: Thu, 6 Feb 2025 18:42:46 +0100 Subject: [PATCH 24/28] Fix: Cycles: Compilation issue with OSL on GPU --- intern/cycles/kernel/osl/services_shared.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/intern/cycles/kernel/osl/services_shared.h b/intern/cycles/kernel/osl/services_shared.h index 3d3b44dca7b..e4daf2e6625 100644 --- a/intern/cycles/kernel/osl/services_shared.h +++ b/intern/cycles/kernel/osl/services_shared.h @@ -13,7 +13,9 @@ CCL_NAMESPACE_BEGIN /* TODO: deduplicate function `set_attribute_float3()` in CPU and GPU. */ -bool attribute_bump_map_normal(KernelGlobals kg, ccl_private const ShaderData *sd, float3 f[3]) +ccl_device bool attribute_bump_map_normal(KernelGlobals kg, + ccl_private const ShaderData *sd, + float3 f[3]) { if (!(sd->type & PRIMITIVE_TRIANGLE) || !(sd->shader & SHADER_SMOOTH_NORMAL)) { /* TODO: implement for curve. */ From 59db8d427fb7586b3bc38a128346163de1b9fc52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 6 Feb 2025 19:29:47 +0100 Subject: [PATCH 25/28] Fix #132663: Selection: Object selection is broken on Intel Macs Copy the fix that is used by EEVEE shadow code. --- source/blender/draw/engines/select/select_instance.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/draw/engines/select/select_instance.hh b/source/blender/draw/engines/select/select_instance.hh index 95be4f16e64..82a28f6dbe0 100644 --- a/source/blender/draw/engines/select/select_instance.hh +++ b/source/blender/draw/engines/select/select_instance.hh @@ -260,6 +260,11 @@ struct SelectMap { } GPU_memory_barrier(GPU_BARRIER_BUFFER_UPDATE); + /* This flush call should not be required. Still, on non-unified mem arch apple devices this is + * needed for the result to be host visible. This is likely to be a bug in the GPU backend. So + * it should eventually be transformed into a backend workaround instead of being fixed in user + * code. */ + select_output_buf.async_flush_to_host(); select_output_buf.read(); Vector hit_results; From fd97a8f5787fab644932dcb7b60a0a193e33f1c2 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Thu, 6 Feb 2025 20:15:44 +0100 Subject: [PATCH 26/28] Fix #134166: Show Context Menus as "Options" on Status Bar The Status Bar often shows context menu items as the name of that menu, which is confusing in this context. For example in Object mode it shows "Object" as the right-click operation. In Grease Pencil it shows this as "Draw" even though you don't draw with it. In "Sculpt" mode you see two items as "Sculpt", one on left click and the other on right click. This PR makes all these show as "Options" instead. This seems like a very succinct description of what is available on right-click. Pull Request: https://projects.blender.org/blender/blender/pulls/134191 --- .../windowmanager/intern/wm_event_system.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index c0dbbcc8e66..8fc38eba296 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -6585,9 +6585,21 @@ void WM_window_cursor_keymap_status_refresh(bContext *C, wmWindow *win) } if (kmi) { wmOperatorType *ot = WM_operatortype_find(kmi->idname, false); - const std::string operator_name = WM_operatortype_name(ot, kmi->ptr); - const char *name = (ot) ? operator_name.c_str() : kmi->idname; - STRNCPY(cd->text[button_index][type_index], name); + std::string name; + + if (kmi->type == RIGHTMOUSE && kmi->val == KM_PRESS && + STR_ELEM(kmi->idname, "WM_OT_call_menu", "WM_OT_call_menu_pie", "WM_OT_call_panel")) + { + name = TIP_("Options"); + } + else if (ot) { + name = WM_operatortype_name(ot, kmi->ptr); + } + else { + name = kmi->idname; + } + + STRNCPY(cd->text[button_index][type_index], name.c_str()); } } From d279a807f229bb4bbb630f7c4b907e2c400b0b3a Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 6 Feb 2025 14:21:30 -0500 Subject: [PATCH 27/28] Fix: Potential build error from missing include --- source/blender/blentranslation/intern/blt_translation.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blentranslation/intern/blt_translation.cc b/source/blender/blentranslation/intern/blt_translation.cc index 563432482de..a27d5183605 100644 --- a/source/blender/blentranslation/intern/blt_translation.cc +++ b/source/blender/blentranslation/intern/blt_translation.cc @@ -11,6 +11,7 @@ #include #include +#include #include "BLT_translation.hh" From 54dc692d7b67c7d434f48d7b99bb39eada51845a Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 6 Feb 2025 21:38:19 +0100 Subject: [PATCH 28/28] Refactor: Use StringRef for attribute API and BMesh CustomData functions Replace `const char *` with `StringRef` for the API in `BKE_attribute.h`. The benefits are slightly simpler code and possibly slightly improved performance through avoiding the need to measure string length. Pull Request: https://projects.blender.org/blender/blender/pulls/134183 --- intern/cycles/blender/mesh.cpp | 3 +- source/blender/blenkernel/BKE_attribute.h | 43 +++-- source/blender/blenkernel/BKE_curves.h | 4 +- .../blender/blenkernel/BKE_grease_pencil.hh | 3 +- source/blender/blenkernel/BKE_mesh.h | 3 +- source/blender/blenkernel/BKE_pointcloud.hh | 3 +- source/blender/blenkernel/intern/attribute.cc | 172 +++++++++--------- source/blender/blenkernel/intern/curves.cc | 4 +- .../blenkernel/intern/data_transfer.cc | 20 +- .../blenkernel/intern/grease_pencil.cc | 4 +- source/blender/blenkernel/intern/mesh.cc | 4 +- .../blenkernel/intern/mesh_legacy_convert.cc | 28 ++- source/blender/blenkernel/intern/paint.cc | 4 +- .../blender/blenkernel/intern/pointcloud.cc | 5 +- source/blender/bmesh/intern/bmesh_interp.cc | 14 +- source/blender/bmesh/intern/bmesh_interp.hh | 14 +- .../bmesh/intern/bmesh_mesh_convert.cc | 50 ++--- source/blender/bmesh/intern/bmesh_query_uv.cc | 3 +- .../editors/curves/intern/curves_ops.cc | 2 +- .../editors/geometry/geometry_attributes.cc | 16 +- source/blender/editors/mesh/mesh_data.cc | 10 +- .../editors/sculpt_paint/paint_vertex.cc | 3 +- .../blender/makesrna/intern/rna_attribute.cc | 32 ++-- source/blender/makesrna/intern/rna_mesh.cc | 25 +-- 24 files changed, 250 insertions(+), 219 deletions(-) diff --git a/intern/cycles/blender/mesh.cpp b/intern/cycles/blender/mesh.cpp index 3c5862f355c..a69357af442 100644 --- a/intern/cycles/blender/mesh.cpp +++ b/intern/cycles/blender/mesh.cpp @@ -281,7 +281,8 @@ static void attr_create_generic(Scene *scene, const blender::bke::AttributeAccessor b_attributes = b_mesh.attributes(); AttributeSet &attributes = (subdivision) ? mesh->subd_attributes : mesh->attributes; static const ustring u_velocity("velocity"); - const ustring default_color_name{BKE_id_attributes_default_color_name(&b_mesh.id)}; + const ustring default_color_name{ + std::string_view(BKE_id_attributes_default_color_name(&b_mesh.id).value_or(""))}; b_attributes.foreach_attribute([&](const blender::bke::AttributeIter &iter) { const ustring name{std::string_view(iter.name)}; diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h index 09044e39d99..fded32c03eb 100644 --- a/source/blender/blenkernel/BKE_attribute.h +++ b/source/blender/blenkernel/BKE_attribute.h @@ -9,6 +9,7 @@ #pragma once +#include #include #include "BLI_string_ref.hh" @@ -81,31 +82,33 @@ class AttributeOwner { * Create a new attribute layer. */ struct CustomDataLayer *BKE_attribute_new(AttributeOwner &owner, - const char *name, + blender::StringRef name, eCustomDataType type, blender::bke::AttrDomain domain, struct ReportList *reports); -bool BKE_attribute_remove(AttributeOwner &owner, const char *name, struct ReportList *reports); +bool BKE_attribute_remove(AttributeOwner &owner, + blender::StringRef name, + struct ReportList *reports); /** * Creates a duplicate attribute layer. */ struct CustomDataLayer *BKE_attribute_duplicate(AttributeOwner &owner, - const char *name, + blender::StringRef name, struct ReportList *reports); struct CustomDataLayer *BKE_attribute_find(const AttributeOwner &owner, - const char *name, + blender::StringRef name, eCustomDataType type, blender::bke::AttrDomain domain); const struct CustomDataLayer *BKE_attribute_search(const AttributeOwner &owner, - const char *name, + blender::StringRef name, eCustomDataMask type, AttrDomainMask domain_mask); struct CustomDataLayer *BKE_attribute_search_for_write(AttributeOwner &owner, - const char *name, + blender::StringRef name, eCustomDataMask type, AttrDomainMask domain_mask); @@ -113,10 +116,10 @@ blender::bke::AttrDomain BKE_attribute_domain(const AttributeOwner &owner, const struct CustomDataLayer *layer); int BKE_attribute_domain_size(const AttributeOwner &owner, int domain); int BKE_attribute_data_length(AttributeOwner &owner, struct CustomDataLayer *layer); -bool BKE_attribute_required(const AttributeOwner &owner, const char *name); +bool BKE_attribute_required(const AttributeOwner &owner, blender::StringRef name); bool BKE_attribute_rename(AttributeOwner &owner, - const char *old_name, - const char *new_name, + blender::StringRef old_name, + blender::StringRef new_name, struct ReportList *reports); int BKE_attributes_length(const AttributeOwner &owner, @@ -124,7 +127,7 @@ int BKE_attributes_length(const AttributeOwner &owner, eCustomDataMask mask); struct CustomDataLayer *BKE_attributes_active_get(AttributeOwner &owner); -void BKE_attributes_active_set(AttributeOwner &owner, const char *name); +void BKE_attributes_active_set(AttributeOwner &owner, blender::StringRef name); void BKE_attributes_active_clear(AttributeOwner &owner); int *BKE_attributes_active_index_p(AttributeOwner &owner); @@ -141,18 +144,22 @@ int BKE_attribute_to_index(const AttributeOwner &owner, AttrDomainMask domain_mask, eCustomDataMask layer_mask); -const char *BKE_id_attributes_active_color_name(const struct ID *id); -const char *BKE_id_attributes_default_color_name(const struct ID *id); -void BKE_id_attributes_active_color_set(struct ID *id, const char *name); +std::optional BKE_id_attributes_active_color_name(const struct ID *id); +std::optional BKE_id_attributes_default_color_name(const struct ID *id); +void BKE_id_attributes_active_color_set(struct ID *id, std::optional name); void BKE_id_attributes_active_color_clear(struct ID *id); -void BKE_id_attributes_default_color_set(struct ID *id, const char *name); +void BKE_id_attributes_default_color_set(struct ID *id, std::optional name); -const struct CustomDataLayer *BKE_id_attributes_color_find(const struct ID *id, const char *name); +const struct CustomDataLayer *BKE_id_attributes_color_find(const struct ID *id, + blender::StringRef name); bool BKE_color_attribute_supported(const struct Mesh &mesh, const blender::StringRef name); std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, const blender::StringRef name); -const char *BKE_uv_map_vert_select_name_get(const char *uv_map_name, char *buffer); -const char *BKE_uv_map_edge_select_name_get(const char *uv_map_name, char *buffer); -const char *BKE_uv_map_pin_name_get(const char *uv_map_name, char *buffer); +[[nodiscard]] blender::StringRef BKE_uv_map_vert_select_name_get(blender::StringRef uv_map_name, + char *buffer); +[[nodiscard]] blender::StringRef BKE_uv_map_edge_select_name_get(blender::StringRef uv_map_name, + char *buffer); +[[nodiscard]] blender::StringRef BKE_uv_map_pin_name_get(blender::StringRef uv_map_name, + char *buffer); diff --git a/source/blender/blenkernel/BKE_curves.h b/source/blender/blenkernel/BKE_curves.h index 755069554ab..c8c65dd1ed3 100644 --- a/source/blender/blenkernel/BKE_curves.h +++ b/source/blender/blenkernel/BKE_curves.h @@ -6,6 +6,8 @@ #include "DNA_curves_types.h" +#include "BLI_string_ref.hh" + /** \file * \ingroup bke * \brief Low-level operations for curves that cannot be defined in the C++ header yet. @@ -23,7 +25,7 @@ struct Scene; struct Curves *BKE_curves_add(struct Main *bmain, const char *name); -bool BKE_curves_attribute_required(const struct Curves *curves, const char *name); +bool BKE_curves_attribute_required(const struct Curves *curves, blender::StringRef name); /* Depsgraph */ diff --git a/source/blender/blenkernel/BKE_grease_pencil.hh b/source/blender/blenkernel/BKE_grease_pencil.hh index a5e0d87ef45..d89f5eeae86 100644 --- a/source/blender/blenkernel/BKE_grease_pencil.hh +++ b/source/blender/blenkernel/BKE_grease_pencil.hh @@ -1061,7 +1061,8 @@ inline bool GreasePencil::has_active_group() const return (this->active_node != nullptr) && (this->active_node->wrap().is_group()); } -bool BKE_grease_pencil_drawing_attribute_required(const GreasePencilDrawing *, const char *name); +bool BKE_grease_pencil_drawing_attribute_required(const GreasePencilDrawing *, + blender::StringRef name); GreasePencil *BKE_grease_pencil_add(Main *bmain, const char *name); GreasePencil *BKE_grease_pencil_new_nomain(); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index b722d85e8d5..6fc79655422 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -10,6 +10,7 @@ #include #include "BLI_array.hh" +#include "BLI_string_ref.hh" #include "DNA_mesh_types.h" @@ -137,7 +138,7 @@ Mesh *BKE_mesh_copy_for_eval(const Mesh &source); Mesh *BKE_mesh_new_nomain_from_curve(const Object *ob); Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *dispbase); -bool BKE_mesh_attribute_required(const char *name); +bool BKE_mesh_attribute_required(blender::StringRef name); blender::Array BKE_mesh_orco_verts_get(const Object *ob); void BKE_mesh_orco_verts_transform(Mesh *mesh, diff --git a/source/blender/blenkernel/BKE_pointcloud.hh b/source/blender/blenkernel/BKE_pointcloud.hh index db0b69d9020..5535e87f02c 100644 --- a/source/blender/blenkernel/BKE_pointcloud.hh +++ b/source/blender/blenkernel/BKE_pointcloud.hh @@ -12,6 +12,7 @@ #include "BLI_bounds_types.hh" #include "BLI_math_vector_types.hh" #include "BLI_shared_cache.hh" +#include "BLI_string_ref.hh" #include "DNA_pointcloud_types.h" @@ -53,7 +54,7 @@ PointCloud *BKE_pointcloud_add_default(Main *bmain, const char *name); PointCloud *BKE_pointcloud_new_nomain(int totpoint); void BKE_pointcloud_nomain_to_pointcloud(PointCloud *pointcloud_src, PointCloud *pointcloud_dst); -bool BKE_pointcloud_attribute_required(const PointCloud *pointcloud, const char *name); +bool BKE_pointcloud_attribute_required(const PointCloud *pointcloud, blender::StringRef name); /* Dependency Graph */ diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 1b6cd824baa..826aa8a6c2c 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -21,7 +21,6 @@ #include "BLI_index_range.hh" #include "BLI_string.h" -#include "BLI_string_utf8.h" #include "BLI_string_utils.hh" #include "BLT_translation.hh" @@ -35,7 +34,10 @@ #include "BKE_pointcloud.hh" #include "BKE_report.hh" +#include + using blender::IndexRange; +using blender::StringRef; using blender::bke::AttrDomain; AttributeOwner AttributeOwner::from_id(ID *id) @@ -206,8 +208,8 @@ static std::optional get_attribute_acces } // namespace blender::bke static bool bke_attribute_rename_if_exists(AttributeOwner &owner, - const char *old_name, - const char *new_name, + const StringRef old_name, + const StringRef new_name, ReportList *reports) { CustomDataLayer *layer = BKE_attribute_search_for_write( @@ -220,18 +222,22 @@ static bool bke_attribute_rename_if_exists(AttributeOwner &owner, static bool name_valid_for_builtin_domain_and_type( const blender::bke::AttributeAccessor attributes, - const blender::StringRefNull name, + const StringRef name, const AttrDomain domain, const eCustomDataType data_type, ReportList *reports) { if (const std::optional metadata = attributes.get_builtin_domain_and_type(name)) { if (domain != metadata->domain) { - BKE_reportf(reports, RPT_ERROR, "Domain unsupported for \"%s\" attribute", name.c_str()); + BKE_reportf(reports, + RPT_ERROR, + "Domain unsupported for \"%s\" attribute", + std::string(name).c_str()); return false; } if (data_type != metadata->data_type) { - BKE_reportf(reports, RPT_ERROR, "Type unsupported for \"%s\" attribute", name.c_str()); + BKE_reportf( + reports, RPT_ERROR, "Type unsupported for \"%s\" attribute", std::string(name).c_str()); return false; } } @@ -239,7 +245,7 @@ static bool name_valid_for_builtin_domain_and_type( } static bool mesh_attribute_valid(const Mesh &mesh, - const blender::StringRefNull name, + const StringRef name, const AttrDomain domain, const eCustomDataType data_type, ReportList *reports) @@ -259,8 +265,8 @@ static bool mesh_attribute_valid(const Mesh &mesh, } bool BKE_attribute_rename(AttributeOwner &owner, - const char *old_name, - const char *new_name, + const StringRef old_name, + const StringRef new_name, ReportList *reports) { using namespace blender; @@ -268,7 +274,7 @@ bool BKE_attribute_rename(AttributeOwner &owner, BLI_assert_msg(0, "Required attribute name is not editable"); return false; } - if (STREQ(new_name, "")) { + if (new_name.is_empty()) { BKE_report(reports, RPT_ERROR, "Attribute name cannot be empty"); return false; } @@ -280,8 +286,8 @@ bool BKE_attribute_rename(AttributeOwner &owner, const int new_name_maxncpy = CustomData_name_maxncpy_calc(new_name); /* NOTE: A function that performs a clamped comparison without copying would be handy here. */ char new_name_clamped[MAX_CUSTOMDATA_LAYER_NAME]; - BLI_strncpy_utf8(new_name_clamped, new_name, new_name_maxncpy); - if (STREQ(old_name, new_name_clamped)) { + new_name.copy_utf8_truncated(new_name_clamped, new_name_maxncpy); + if (old_name == new_name_clamped) { return false; } } @@ -323,38 +329,36 @@ bool BKE_attribute_rename(AttributeOwner &owner, char buffer_src[MAX_CUSTOMDATA_LAYER_NAME]; char buffer_dst[MAX_CUSTOMDATA_LAYER_NAME]; - bke_attribute_rename_if_exists( - owner, - BKE_uv_map_vert_select_name_get(layer->name, buffer_src), - BKE_uv_map_vert_select_name_get(result_name.c_str(), buffer_dst), - reports); - bke_attribute_rename_if_exists( - owner, - BKE_uv_map_edge_select_name_get(layer->name, buffer_src), - BKE_uv_map_edge_select_name_get(result_name.c_str(), buffer_dst), - reports); + bke_attribute_rename_if_exists(owner, + BKE_uv_map_vert_select_name_get(layer->name, buffer_src), + BKE_uv_map_vert_select_name_get(result_name, buffer_dst), + reports); + bke_attribute_rename_if_exists(owner, + BKE_uv_map_edge_select_name_get(layer->name, buffer_src), + BKE_uv_map_edge_select_name_get(result_name, buffer_dst), + reports); bke_attribute_rename_if_exists(owner, BKE_uv_map_pin_name_get(layer->name, buffer_src), - BKE_uv_map_pin_name_get(result_name.c_str(), buffer_dst), + BKE_uv_map_pin_name_get(result_name, buffer_dst), reports); } if (owner.type() == AttributeOwnerType::Mesh) { Mesh *mesh = owner.get_mesh(); - if (StringRef(old_name) == BKE_id_attributes_active_color_name(&mesh->id)) { - BKE_id_attributes_active_color_set(&mesh->id, result_name.c_str()); + if (old_name == BKE_id_attributes_active_color_name(&mesh->id)) { + BKE_id_attributes_active_color_set(&mesh->id, result_name); } - if (StringRef(old_name) == BKE_id_attributes_default_color_name(&mesh->id)) { - BKE_id_attributes_default_color_set(&mesh->id, result_name.c_str()); + if (old_name == BKE_id_attributes_default_color_name(&mesh->id)) { + BKE_id_attributes_default_color_set(&mesh->id, result_name); } } - STRNCPY_UTF8(layer->name, result_name.c_str()); + StringRef(result_name).copy_utf8_truncated(layer->name); return true; } -static bool attribute_name_exists(const AttributeOwner &owner, const blender::StringRef name) +static bool attribute_name_exists(const AttributeOwner &owner, const StringRef name) { const std::array info = get_domains(owner); @@ -376,17 +380,16 @@ static bool attribute_name_exists(const AttributeOwner &owner, const blender::St return false; } -std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, - const blender::StringRef name) +std::string BKE_attribute_calc_unique_name(const AttributeOwner &owner, const StringRef name) { return BLI_uniquename_cb( - [&](const blender::StringRef new_name) { return attribute_name_exists(owner, new_name); }, + [&](const StringRef new_name) { return attribute_name_exists(owner, new_name); }, '.', name.is_empty() ? DATA_("Attribute") : name); } CustomDataLayer *BKE_attribute_new(AttributeOwner &owner, - const char *name, + const StringRef name, const eCustomDataType type, const AttrDomain domain, ReportList *reports) @@ -430,8 +433,8 @@ CustomDataLayer *BKE_attribute_new(AttributeOwner &owner, } static void bke_attribute_copy_if_exists(AttributeOwner &owner, - const char *srcname, - const char *dstname) + const StringRef srcname, + const StringRef dstname) { using namespace blender::bke; @@ -450,7 +453,7 @@ static void bke_attribute_copy_if_exists(AttributeOwner &owner, } CustomDataLayer *BKE_attribute_duplicate(AttributeOwner &owner, - const char *name, + const StringRef name, ReportList *reports) { using namespace blender::bke; @@ -485,20 +488,19 @@ CustomDataLayer *BKE_attribute_duplicate(AttributeOwner &owner, bke_attribute_copy_if_exists(owner, BKE_uv_map_vert_select_name_get(name, buffer_src), - BKE_uv_map_vert_select_name_get(uniquename.c_str(), buffer_dst)); + BKE_uv_map_vert_select_name_get(uniquename, buffer_dst)); bke_attribute_copy_if_exists(owner, BKE_uv_map_edge_select_name_get(name, buffer_src), - BKE_uv_map_edge_select_name_get(uniquename.c_str(), buffer_dst)); + BKE_uv_map_edge_select_name_get(uniquename, buffer_dst)); bke_attribute_copy_if_exists(owner, BKE_uv_map_pin_name_get(name, buffer_src), - BKE_uv_map_pin_name_get(uniquename.c_str(), buffer_dst)); + BKE_uv_map_pin_name_get(uniquename, buffer_dst)); } - return BKE_attribute_search_for_write( - owner, uniquename.c_str(), CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL); + return BKE_attribute_search_for_write(owner, uniquename, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL); } -static int color_name_to_index(AttributeOwner &owner, const char *name) +static int color_name_to_index(AttributeOwner &owner, const StringRef name) { const CustomDataLayer *layer = BKE_attribute_search( owner, name, CD_MASK_COLOR_ALL, ATTR_DOMAIN_MASK_COLOR); @@ -511,18 +513,18 @@ static int color_clamp_index(AttributeOwner &owner, int index) return min_ii(index, length - 1); } -static const char *color_name_from_index(AttributeOwner &owner, int index) +static StringRef color_name_from_index(AttributeOwner &owner, int index) { const CustomDataLayer *layer = BKE_attribute_from_index( owner, index, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL); - return layer ? layer->name : nullptr; + return layer ? layer->name : ""; } -bool BKE_attribute_remove(AttributeOwner &owner, const char *name, ReportList *reports) +bool BKE_attribute_remove(AttributeOwner &owner, const StringRef name, ReportList *reports) { using namespace blender; using namespace blender::bke; - if (!name || name[0] == '\0') { + if (name.is_empty()) { BKE_report(reports, RPT_ERROR, "The attribute name must not be empty"); return false; } @@ -571,11 +573,10 @@ bool BKE_attribute_remove(AttributeOwner &owner, const char *name, ReportList *r if (type == CD_PROP_FLOAT2 && domain == int(AttrDomain::Corner)) { char buffer[MAX_CUSTOMDATA_LAYER_NAME]; BM_data_layer_free_named( - em->bm, data, BKE_uv_map_vert_select_name_get(name_copy.c_str(), buffer)); - BM_data_layer_free_named( - em->bm, data, BKE_uv_map_edge_select_name_get(name_copy.c_str(), buffer)); + em->bm, data, BKE_uv_map_vert_select_name_get(name_copy, buffer)); BM_data_layer_free_named( - em->bm, data, BKE_uv_map_pin_name_get(name_copy.c_str(), buffer)); + em->bm, data, BKE_uv_map_edge_select_name_get(name_copy, buffer)); + BM_data_layer_free_named(em->bm, data, BKE_uv_map_pin_name_get(name_copy, buffer)); } return true; } @@ -618,9 +619,9 @@ bool BKE_attribute_remove(AttributeOwner &owner, const char *name, ReportList *r if (metadata->data_type == CD_PROP_FLOAT2 && metadata->domain == AttrDomain::Corner) { char buffer[MAX_CUSTOMDATA_LAYER_NAME]; - attributes->remove(BKE_uv_map_vert_select_name_get(name_copy.c_str(), buffer)); - attributes->remove(BKE_uv_map_edge_select_name_get(name_copy.c_str(), buffer)); - attributes->remove(BKE_uv_map_pin_name_get(name_copy.c_str(), buffer)); + attributes->remove(BKE_uv_map_vert_select_name_get(name_copy, buffer)); + attributes->remove(BKE_uv_map_edge_select_name_get(name_copy, buffer)); + attributes->remove(BKE_uv_map_pin_name_get(name_copy, buffer)); } return true; } @@ -629,11 +630,11 @@ bool BKE_attribute_remove(AttributeOwner &owner, const char *name, ReportList *r } CustomDataLayer *BKE_attribute_find(const AttributeOwner &owner, - const char *name, + const StringRef name, const eCustomDataType type, const AttrDomain domain) { - if (!name) { + if (name.is_empty()) { return nullptr; } const std::array info = get_domains(owner); @@ -645,7 +646,7 @@ CustomDataLayer *BKE_attribute_find(const AttributeOwner &owner, for (int i = 0; i < customdata->totlayer; i++) { CustomDataLayer *layer = &customdata->layers[i]; - if (layer->type == type && STREQ(layer->name, name)) { + if (layer->type == type && layer->name == name) { return layer; } } @@ -654,11 +655,11 @@ CustomDataLayer *BKE_attribute_find(const AttributeOwner &owner, } const CustomDataLayer *BKE_attribute_search(const AttributeOwner &owner, - const char *name, + const StringRef name, const eCustomDataMask type_mask, const AttrDomainMask domain_mask) { - if (!name) { + if (name.is_empty()) { return nullptr; } const std::array info = get_domains(owner); @@ -677,7 +678,7 @@ const CustomDataLayer *BKE_attribute_search(const AttributeOwner &owner, for (int i = 0; i < customdata->totlayer; i++) { CustomDataLayer *layer = &customdata->layers[i]; - if ((CD_TYPE_AS_MASK(layer->type) & type_mask) && STREQ(layer->name, name)) { + if ((CD_TYPE_AS_MASK(layer->type) & type_mask) && layer->name == name) { return layer; } } @@ -687,7 +688,7 @@ const CustomDataLayer *BKE_attribute_search(const AttributeOwner &owner, } CustomDataLayer *BKE_attribute_search_for_write(AttributeOwner &owner, - const char *name, + const StringRef name, const eCustomDataMask type_mask, const AttrDomainMask domain_mask) { @@ -781,7 +782,7 @@ int BKE_attribute_data_length(AttributeOwner &owner, CustomDataLayer *layer) return 0; } -bool BKE_attribute_required(const AttributeOwner &owner, const char *name) +bool BKE_attribute_required(const AttributeOwner &owner, const StringRef name) { switch (owner.type()) { case AttributeOwnerType::PointCloud: @@ -834,7 +835,7 @@ CustomDataLayer *BKE_attributes_active_get(AttributeOwner &owner) return nullptr; } -void BKE_attributes_active_set(AttributeOwner &owner, const char *name) +void BKE_attributes_active_set(AttributeOwner &owner, const StringRef name) { const CustomDataLayer *layer = BKE_attribute_search( owner, name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL); @@ -966,30 +967,30 @@ int BKE_attribute_to_index(const AttributeOwner &owner, return -1; } -const char *BKE_id_attributes_active_color_name(const ID *id) +std::optional BKE_id_attributes_active_color_name(const ID *id) { if (GS(id->name) == ID_ME) { return reinterpret_cast(id)->active_color_attribute; } - return nullptr; + return std::nullopt; } -const char *BKE_id_attributes_default_color_name(const ID *id) +std::optional BKE_id_attributes_default_color_name(const ID *id) { if (GS(id->name) == ID_ME) { return reinterpret_cast(id)->default_color_attribute; } - return nullptr; + return std::nullopt; } -void BKE_id_attributes_active_color_set(ID *id, const char *name) +void BKE_id_attributes_active_color_set(ID *id, const std::optional name) { switch (GS(id->name)) { case ID_ME: { Mesh *mesh = reinterpret_cast(id); MEM_SAFE_FREE(mesh->active_color_attribute); if (name) { - mesh->active_color_attribute = BLI_strdup(name); + mesh->active_color_attribute = BLI_strdupn(name->data(), name->size()); } break; } @@ -1011,14 +1012,14 @@ void BKE_id_attributes_active_color_clear(ID *id) } } -void BKE_id_attributes_default_color_set(ID *id, const char *name) +void BKE_id_attributes_default_color_set(ID *id, const std::optional name) { switch (GS(id->name)) { case ID_ME: { Mesh *mesh = reinterpret_cast(id); MEM_SAFE_FREE(mesh->default_color_attribute); if (name) { - mesh->default_color_attribute = BLI_strdup(name); + mesh->default_color_attribute = BLI_strdupn(name->data(), name->size()); } break; } @@ -1027,13 +1028,13 @@ void BKE_id_attributes_default_color_set(ID *id, const char *name) } } -const CustomDataLayer *BKE_id_attributes_color_find(const ID *id, const char *name) +const CustomDataLayer *BKE_id_attributes_color_find(const ID *id, const StringRef name) { AttributeOwner owner = AttributeOwner::from_id(const_cast(id)); return BKE_attribute_search(owner, name, CD_MASK_COLOR_ALL, ATTR_DOMAIN_MASK_COLOR); } -bool BKE_color_attribute_supported(const Mesh &mesh, const blender::StringRef name) +bool BKE_color_attribute_supported(const Mesh &mesh, const StringRef name) { std::optional meta_data = mesh.attributes().lookup_meta_data( name); @@ -1049,26 +1050,29 @@ bool BKE_color_attribute_supported(const Mesh &mesh, const blender::StringRef na return true; } -const char *BKE_uv_map_vert_select_name_get(const char *uv_map_name, char *buffer) +StringRef BKE_uv_map_vert_select_name_get(const StringRef uv_map_name, char *buffer) { BLI_assert(strlen(UV_VERTSEL_NAME) == 2); - BLI_assert(strlen(uv_map_name) < MAX_CUSTOMDATA_LAYER_NAME - 4); - BLI_snprintf(buffer, MAX_CUSTOMDATA_LAYER_NAME, ".%s.%s", UV_VERTSEL_NAME, uv_map_name); - return buffer; + BLI_assert(uv_map_name.size() < MAX_CUSTOMDATA_LAYER_NAME - 4); + const auto result = fmt::format_to_n( + buffer, MAX_CUSTOMDATA_LAYER_NAME, ".{}.{}", UV_VERTSEL_NAME, uv_map_name); + return StringRef(buffer, result.size); } -const char *BKE_uv_map_edge_select_name_get(const char *uv_map_name, char *buffer) +StringRef BKE_uv_map_edge_select_name_get(const StringRef uv_map_name, char *buffer) { BLI_assert(strlen(UV_EDGESEL_NAME) == 2); - BLI_assert(strlen(uv_map_name) < MAX_CUSTOMDATA_LAYER_NAME - 4); - BLI_snprintf(buffer, MAX_CUSTOMDATA_LAYER_NAME, ".%s.%s", UV_EDGESEL_NAME, uv_map_name); - return buffer; + BLI_assert(uv_map_name.size() < MAX_CUSTOMDATA_LAYER_NAME - 4); + const auto result = fmt::format_to_n( + buffer, MAX_CUSTOMDATA_LAYER_NAME, ".{}.{}", UV_EDGESEL_NAME, uv_map_name); + return StringRef(buffer, result.size); } -const char *BKE_uv_map_pin_name_get(const char *uv_map_name, char *buffer) +StringRef BKE_uv_map_pin_name_get(const StringRef uv_map_name, char *buffer) { BLI_assert(strlen(UV_PINNED_NAME) == 2); - BLI_assert(strlen(uv_map_name) < MAX_CUSTOMDATA_LAYER_NAME - 4); - BLI_snprintf(buffer, MAX_CUSTOMDATA_LAYER_NAME, ".%s.%s", UV_PINNED_NAME, uv_map_name); - return buffer; + BLI_assert(uv_map_name.size() < MAX_CUSTOMDATA_LAYER_NAME - 4); + const auto result = fmt::format_to_n( + buffer, MAX_CUSTOMDATA_LAYER_NAME, ".{}.{}", UV_PINNED_NAME, uv_map_name); + return StringRef(buffer, result.size); } diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 92a7d5ab74e..086b7a49eb1 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -173,9 +173,9 @@ Curves *BKE_curves_add(Main *bmain, const char *name) return curves; } -bool BKE_curves_attribute_required(const Curves * /*curves*/, const char *name) +bool BKE_curves_attribute_required(const Curves * /*curves*/, const blender::StringRef name) { - return STREQ(name, ATTR_POSITION); + return name == ATTR_POSITION; } Curves *BKE_curves_copy_for_eval(const Curves *curves_src) diff --git a/source/blender/blenkernel/intern/data_transfer.cc b/source/blender/blenkernel/intern/data_transfer.cc index 6233d05ee55..d54132f2ff2 100644 --- a/source/blender/blenkernel/intern/data_transfer.cc +++ b/source/blender/blenkernel/intern/data_transfer.cc @@ -35,6 +35,8 @@ #include "data_transfer_intern.hh" +using blender::StringRef; + void BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types, CustomData_MeshMasks *r_data_masks) { @@ -259,7 +261,8 @@ static void data_transfer_mesh_attributes_transfer_active_color_string( const AttributeOwner owner_src = AttributeOwner::from_id(const_cast(&mesh_src->id)); AttributeOwner owner_dst = AttributeOwner::from_id(&mesh_dst->id); - const char *active_color_src = BKE_id_attributes_active_color_name(&mesh_src->id); + const StringRef active_color_src = + BKE_id_attributes_active_color_name(&mesh_src->id).value_or(""); if ((data_type == CD_PROP_COLOR) && !BKE_attribute_search( @@ -278,13 +281,15 @@ static void data_transfer_mesh_attributes_transfer_active_color_string( BKE_attribute_search( owner_dst, active_color_src, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_COLOR)) { - mesh_dst->active_color_attribute = BLI_strdup(active_color_src); + mesh_dst->active_color_attribute = BLI_strdupn(active_color_src.data(), + active_color_src.size()); } else if ((data_type == CD_PROP_BYTE_COLOR) && BKE_attribute_search( owner_dst, active_color_src, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_COLOR)) { - mesh_dst->active_color_attribute = BLI_strdup(active_color_src); + mesh_dst->active_color_attribute = BLI_strdupn(active_color_src.data(), + active_color_src.size()); } else { CustomDataLayer *first_color_layer = BKE_attribute_from_index( @@ -310,7 +315,8 @@ static void data_transfer_mesh_attributes_transfer_default_color_string( const AttributeOwner owner_src = AttributeOwner::from_id(const_cast(&mesh_src->id)); AttributeOwner owner_dst = AttributeOwner::from_id(&mesh_dst->id); - const char *default_color_src = BKE_id_attributes_default_color_name(&mesh_src->id); + const StringRef default_color_src = + BKE_id_attributes_default_color_name(&mesh_src->id).value_or(""); if ((data_type == CD_PROP_COLOR) && !BKE_attribute_search( @@ -329,13 +335,15 @@ static void data_transfer_mesh_attributes_transfer_default_color_string( BKE_attribute_search( owner_dst, default_color_src, CD_MASK_PROP_COLOR, ATTR_DOMAIN_MASK_COLOR)) { - mesh_dst->default_color_attribute = BLI_strdup(default_color_src); + mesh_dst->default_color_attribute = BLI_strdupn(default_color_src.data(), + default_color_src.size()); } else if ((data_type == CD_PROP_BYTE_COLOR) && BKE_attribute_search( owner_dst, default_color_src, CD_MASK_PROP_BYTE_COLOR, ATTR_DOMAIN_MASK_COLOR)) { - mesh_dst->default_color_attribute = BLI_strdup(default_color_src); + mesh_dst->default_color_attribute = BLI_strdupn(default_color_src.data(), + default_color_src.size()); } else { CustomDataLayer *first_color_layer = BKE_attribute_from_index( diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index 52b53eec517..d904230cb67 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -1912,9 +1912,9 @@ std::optional> GreasePencilDrawingEditHints::positions_for_w * \{ */ bool BKE_grease_pencil_drawing_attribute_required(const GreasePencilDrawing * /*drawing*/, - const char *name) + const blender::StringRef name) { - return STREQ(name, ATTR_POSITION); + return name == ATTR_POSITION; } GreasePencil *BKE_grease_pencil_add(Main *bmain, const char *name) diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index e7feb899bed..731a2fa25ac 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -478,9 +478,9 @@ IDTypeInfo IDType_ID_ME = { /*lib_override_apply_post*/ nullptr, }; -bool BKE_mesh_attribute_required(const char *name) +bool BKE_mesh_attribute_required(const StringRef name) { - return ELEM(StringRef(name), "position", ".corner_vert", ".corner_edge", ".edge_verts"); + return ELEM(name, "position", ".corner_vert", ".corner_edge", ".edge_verts"); } void BKE_mesh_ensure_skin_customdata(Mesh *mesh) diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index fe7e11cbea8..2332b5a7f96 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -1774,29 +1774,27 @@ void BKE_mesh_legacy_convert_uvs_to_generic(Mesh *mesh) &mesh->corner_data, CD_PROP_FLOAT2, coords, mesh->corners_num, new_name, nullptr); char buffer[MAX_CUSTOMDATA_LAYER_NAME]; if (vert_selection) { - CustomData_add_layer_named_with_data( - &mesh->corner_data, - CD_PROP_BOOL, - vert_selection, - mesh->corners_num, - BKE_uv_map_vert_select_name_get(new_name.c_str(), buffer), - nullptr); + CustomData_add_layer_named_with_data(&mesh->corner_data, + CD_PROP_BOOL, + vert_selection, + mesh->corners_num, + BKE_uv_map_vert_select_name_get(new_name, buffer), + nullptr); } if (edge_selection) { - CustomData_add_layer_named_with_data( - &mesh->corner_data, - CD_PROP_BOOL, - edge_selection, - mesh->corners_num, - BKE_uv_map_edge_select_name_get(new_name.c_str(), buffer), - nullptr); + CustomData_add_layer_named_with_data(&mesh->corner_data, + CD_PROP_BOOL, + edge_selection, + mesh->corners_num, + BKE_uv_map_edge_select_name_get(new_name, buffer), + nullptr); } if (pin) { CustomData_add_layer_named_with_data(&mesh->corner_data, CD_PROP_BOOL, pin, mesh->corners_num, - BKE_uv_map_pin_name_get(new_name.c_str(), buffer), + BKE_uv_map_pin_name_get(new_name, buffer), nullptr); } } diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 52500e6dcca..475422309d9 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -2559,8 +2559,8 @@ void BKE_sculpt_color_layer_create_if_needed(Object *object) return; } - BKE_id_attributes_active_color_set(&orig_me->id, unique_name.c_str()); - BKE_id_attributes_default_color_set(&orig_me->id, unique_name.c_str()); + BKE_id_attributes_active_color_set(&orig_me->id, unique_name); + BKE_id_attributes_default_color_set(&orig_me->id, unique_name); DEG_id_tag_update(&orig_me->id, ID_RECALC_GEOMETRY_ALL_MODES); BKE_mesh_tessface_clear(orig_me); } diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc index efac5e079da..920517ac616 100644 --- a/source/blender/blenkernel/intern/pointcloud.cc +++ b/source/blender/blenkernel/intern/pointcloud.cc @@ -305,9 +305,10 @@ blender::bke::MutableAttributeAccessor PointCloud::attributes_for_write() this, blender::bke::pointcloud_attribute_accessor_functions()); } -bool BKE_pointcloud_attribute_required(const PointCloud * /*pointcloud*/, const char *name) +bool BKE_pointcloud_attribute_required(const PointCloud * /*pointcloud*/, + const blender::StringRef name) { - return STREQ(name, POINTCLOUD_ATTR_POSITION); + return name == POINTCLOUD_ATTR_POSITION; } /* Dependency Graph */ diff --git a/source/blender/bmesh/intern/bmesh_interp.cc b/source/blender/bmesh/intern/bmesh_interp.cc index 6e4d53cfbe6..4da76cd9d33 100644 --- a/source/blender/bmesh/intern/bmesh_interp.cc +++ b/source/blender/bmesh/intern/bmesh_interp.cc @@ -27,6 +27,8 @@ #include "bmesh.hh" #include "intern/bmesh_private.hh" +using blender::StringRef; + /* edge and vertex share, currently there's no need to have different logic */ static void bm_data_interp_from_elem(CustomData *data_layer, const BMElem *ele_src_1, @@ -850,7 +852,7 @@ void BM_data_layer_add(BMesh *bm, CustomData *data, int type) } } -void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name) +void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const StringRef name) { CustomData olddata = *data; olddata.layers = (olddata.layers) ? @@ -867,7 +869,7 @@ void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char * } } -void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const char *name) +void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const StringRef name) { if (CustomData_get_named_layer_index(data, eCustomDataType(type), name) == -1) { BM_data_layer_add_named(bm, data, type, name); @@ -901,21 +903,21 @@ void BM_uv_map_ensure_select_and_pin_attrs(BMesh *bm) } } -void BM_uv_map_ensure_vert_select_attr(BMesh *bm, const char *uv_map_name) +void BM_uv_map_ensure_vert_select_attr(BMesh *bm, const StringRef uv_map_name) { char name[MAX_CUSTOMDATA_LAYER_NAME]; BM_data_layer_ensure_named( bm, &bm->ldata, CD_PROP_BOOL, BKE_uv_map_vert_select_name_get(uv_map_name, name)); } -void BM_uv_map_ensure_edge_select_attr(BMesh *bm, const char *uv_map_name) +void BM_uv_map_ensure_edge_select_attr(BMesh *bm, const StringRef uv_map_name) { char name[MAX_CUSTOMDATA_LAYER_NAME]; BM_data_layer_ensure_named( bm, &bm->ldata, CD_PROP_BOOL, BKE_uv_map_edge_select_name_get(uv_map_name, name)); } -void BM_uv_map_ensure_pin_attr(BMesh *bm, const char *uv_map_name) +void BM_uv_map_ensure_pin_attr(BMesh *bm, const StringRef uv_map_name) { char name[MAX_CUSTOMDATA_LAYER_NAME]; BM_data_layer_ensure_named( @@ -942,7 +944,7 @@ void BM_data_layer_free(BMesh *bm, CustomData *data, int type) } } -bool BM_data_layer_free_named(BMesh *bm, CustomData *data, const char *name) +bool BM_data_layer_free_named(BMesh *bm, CustomData *data, StringRef name) { CustomData olddata = *data; olddata.layers = (olddata.layers) ? diff --git a/source/blender/bmesh/intern/bmesh_interp.hh b/source/blender/bmesh/intern/bmesh_interp.hh index 689b8108a98..1e70dffff4d 100644 --- a/source/blender/bmesh/intern/bmesh_interp.hh +++ b/source/blender/bmesh/intern/bmesh_interp.hh @@ -8,6 +8,8 @@ * \ingroup bmesh */ +#include "BLI_string_ref.hh" + #include "bmesh_class.hh" struct LinkNode; @@ -61,21 +63,21 @@ void BM_data_interp_from_edges( void BM_data_interp_face_vert_edge( BMesh *bm, const BMVert *v_src_1, const BMVert *v_src_2, BMVert *v, BMEdge *e, float fac); void BM_data_layer_add(BMesh *bm, CustomData *data, int type); -void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *name); -void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, const char *name); +void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, blender::StringRef name); +void BM_data_layer_ensure_named(BMesh *bm, CustomData *data, int type, blender::StringRef name); void BM_data_layer_free(BMesh *bm, CustomData *data, int type); /** Ensure the dependent boolean layers exist for all face corner #CD_PROP_FLOAT2 layers. */ void BM_uv_map_ensure_select_and_pin_attrs(BMesh *bm); -void BM_uv_map_ensure_vert_select_attr(BMesh *bm, const char *uv_map_name); -void BM_uv_map_ensure_edge_select_attr(BMesh *bm, const char *uv_map_name); -void BM_uv_map_ensure_pin_attr(BMesh *bm, const char *uv_map_name); +void BM_uv_map_ensure_vert_select_attr(BMesh *bm, blender::StringRef uv_map_name); +void BM_uv_map_ensure_edge_select_attr(BMesh *bm, blender::StringRef uv_map_name); +void BM_uv_map_ensure_pin_attr(BMesh *bm, blender::StringRef uv_map_name); /** * Remove a named custom data layer, if it existed. Return true if the layer was removed. */ -bool BM_data_layer_free_named(BMesh *bm, CustomData *data, const char *name); +bool BM_data_layer_free_named(BMesh *bm, CustomData *data, blender::StringRef name); void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n); void BM_data_layer_copy(BMesh *bm, CustomData *data, int type, int src_n, int dst_n); diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index 5289fe46d3f..c4f65a2703d 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -237,27 +237,33 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *mesh, const BMeshFromMeshParams * for (const int layer_index : IndexRange(CustomData_number_of_layers(&mesh_ldata, CD_PROP_FLOAT2))) { - char name[MAX_CUSTOMDATA_LAYER_NAME]; - BKE_uv_map_vert_select_name_get( - CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), name); - if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) { - CustomData_add_layer_named( - &mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name); - temporary_layers_to_delete.append(std::string(name)); - } - BKE_uv_map_edge_select_name_get( - CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), name); - if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) { - CustomData_add_layer_named( - &mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name); - temporary_layers_to_delete.append(std::string(name)); - } - BKE_uv_map_pin_name_get(CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), - name); - if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) { - CustomData_add_layer_named( - &mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name); - temporary_layers_to_delete.append(std::string(name)); + char buffer[MAX_CUSTOMDATA_LAYER_NAME]; + { + const StringRef name = BKE_uv_map_vert_select_name_get( + CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), buffer); + if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) { + CustomData_add_layer_named( + &mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name); + temporary_layers_to_delete.append(std::string(name)); + } + } + { + const StringRef name = BKE_uv_map_edge_select_name_get( + CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), buffer); + if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) { + CustomData_add_layer_named( + &mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name); + temporary_layers_to_delete.append(std::string(name)); + } + } + { + const StringRef name = BKE_uv_map_pin_name_get( + CustomData_get_layer_name(&mesh_ldata, CD_PROP_FLOAT2, layer_index), buffer); + if (CustomData_get_named_layer_index(&mesh_ldata, CD_PROP_BOOL, name) < 0) { + CustomData_add_layer_named( + &mesh_ldata, CD_PROP_BOOL, CD_SET_DEFAULT, mesh->corners_num, name); + temporary_layers_to_delete.append(std::string(name)); + } } } @@ -1155,7 +1161,7 @@ static void bm_face_loop_table_build(BMesh &bm, for (const int i : IndexRange(CustomData_number_of_layers(&ldata, CD_PROP_FLOAT2))) { char const *layer_name = CustomData_get_layer_name(&ldata, CD_PROP_FLOAT2, i); char sub_layer_name[MAX_CUSTOMDATA_LAYER_NAME]; - auto add_bool_layer = [&](Vector &layers, const char *name) { + auto add_bool_layer = [&](Vector &layers, const StringRef name) { const int layer_index = CustomData_get_named_layer_index(&ldata, CD_PROP_BOOL, name); if (layer_index != -1) { layers.append(layer_index); diff --git a/source/blender/bmesh/intern/bmesh_query_uv.cc b/source/blender/bmesh/intern/bmesh_query_uv.cc index 67cbe55f544..b23ce633786 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.cc +++ b/source/blender/bmesh/intern/bmesh_query_uv.cc @@ -10,6 +10,7 @@ #include "BLI_math_geom.h" #include "BLI_math_vector.h" #include "BLI_math_vector_types.hh" +#include "BLI_string_ref.hh" #include "BKE_attribute.h" #include "BKE_customdata.hh" @@ -25,7 +26,7 @@ BMUVOffsets BM_uv_map_get_offsets_from_layer(const BMesh *bm, const int layer) return {-1, -1, -1, -1}; } - char const *name = bm->ldata.layers[layer_index].name; + const StringRef name = bm->ldata.layers[layer_index].name; char buffer[MAX_CUSTOMDATA_LAYER_NAME]; BMUVOffsets offsets; diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index 43ea36c60f4..5718290d281 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -822,7 +822,7 @@ static int curves_set_selection_domain_exec(bContext *C, wmOperator *op) } } if (!active_attribute.empty()) { - BKE_attributes_active_set(owner, active_attribute.c_str()); + BKE_attributes_active_set(owner, active_attribute); } /* Use #ID_RECALC_GEOMETRY instead of #ID_RECALC_SELECT because it is handled as a generic diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index 218b7713e11..b8451329937 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -416,7 +416,7 @@ static int geometry_color_attribute_add_exec(bContext *C, wmOperator *op) BKE_id_attributes_active_color_set(id, layer->name); - if (!BKE_id_attributes_color_find(id, BKE_id_attributes_default_color_name(id))) { + if (!BKE_id_attributes_color_find(id, BKE_id_attributes_default_color_name(id).value_or(""))) { BKE_id_attributes_default_color_set(id, layer->name); } @@ -634,12 +634,12 @@ static int geometry_color_attribute_remove_exec(bContext *C, wmOperator *op) { Object *ob = object::context_object(C); ID *id = static_cast(ob->data); - const std::string active_name = StringRef(BKE_id_attributes_active_color_name(id)); + const std::string active_name = BKE_id_attributes_active_color_name(id).value_or(""); if (active_name.empty()) { return OPERATOR_CANCELLED; } AttributeOwner owner = AttributeOwner::from_id(id); - if (!BKE_attribute_remove(owner, active_name.c_str(), op->reports)) { + if (!BKE_attribute_remove(owner, active_name, op->reports)) { return OPERATOR_CANCELLED; } @@ -658,7 +658,7 @@ static bool geometry_color_attributes_remove_poll(bContext *C) const Object *ob = object::context_object(C); const ID *data = static_cast(ob->data); - if (BKE_id_attributes_color_find(data, BKE_id_attributes_active_color_name(data))) { + if (BKE_id_attributes_color_find(data, BKE_id_attributes_active_color_name(data).value_or(""))) { return true; } @@ -684,13 +684,13 @@ static int geometry_color_attribute_duplicate_exec(bContext *C, wmOperator *op) { Object *ob = object::context_object(C); ID *id = static_cast(ob->data); - const char *active_name = BKE_id_attributes_active_color_name(id); - if (active_name == nullptr) { + const std::optional active_name = BKE_id_attributes_active_color_name(id); + if (!active_name) { return OPERATOR_CANCELLED; } AttributeOwner owner = AttributeOwner::from_id(id); - CustomDataLayer *new_layer = BKE_attribute_duplicate(owner, active_name, op->reports); + CustomDataLayer *new_layer = BKE_attribute_duplicate(owner, *active_name, op->reports); if (new_layer == nullptr) { return OPERATOR_CANCELLED; } @@ -716,7 +716,7 @@ static bool geometry_color_attributes_duplicate_poll(bContext *C) const Object *ob = object::context_object(C); const ID *data = static_cast(ob->data); - if (BKE_id_attributes_color_find(data, BKE_id_attributes_active_color_name(data))) { + if (BKE_id_attributes_color_find(data, BKE_id_attributes_active_color_name(data).value_or(""))) { return true; } diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index 9d3ff05ee31..31b44ba25c5 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -45,6 +45,7 @@ using blender::float2; using blender::float3; using blender::MutableSpan; using blender::Span; +using blender::StringRef; static CustomData *mesh_customdata_get_type(Mesh *mesh, const char htype, int *r_tot) { @@ -290,7 +291,8 @@ int ED_mesh_uv_add( return layernum_dst; } -static const bool *mesh_loop_boolean_custom_data_get_by_name(const Mesh &mesh, const char *name) +static const bool *mesh_loop_boolean_custom_data_get_by_name(const Mesh &mesh, + const StringRef name) { return static_cast( CustomData_get_layer_named(&mesh.corner_data, CD_PROP_BOOL, name)); @@ -325,7 +327,7 @@ const bool *ED_mesh_uv_map_pin_layer_get(const Mesh *mesh, const int uv_index) BKE_uv_map_pin_name_get(uv_name, buffer)); } -static bool *ensure_corner_boolean_attribute(Mesh &mesh, const blender::StringRefNull name) +static bool *ensure_corner_boolean_attribute(Mesh &mesh, const StringRef name) { bool *data = static_cast(CustomData_get_layer_named_for_write( &mesh.corner_data, CD_PROP_BOOL, name, mesh.corners_num)); @@ -436,8 +438,8 @@ bool ED_mesh_color_ensure(Mesh *mesh, const char *name) return false; } - BKE_id_attributes_active_color_set(&mesh->id, unique_name.c_str()); - BKE_id_attributes_default_color_set(&mesh->id, unique_name.c_str()); + BKE_id_attributes_active_color_set(&mesh->id, unique_name); + BKE_id_attributes_default_color_set(&mesh->id, unique_name); BKE_mesh_tessface_clear(mesh); DEG_id_tag_update(&mesh->id, 0); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 3f759a86273..01f6f00d16b 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -2201,8 +2201,7 @@ static void fill_mesh_color(Mesh &mesh, { if (BMEditMesh *em = mesh.runtime->edit_mesh.get()) { BMesh *bm = em->bm; - const std::string name = attribute_name; - const CustomDataLayer *layer = BKE_id_attributes_color_find(&mesh.id, name.c_str()); + const CustomDataLayer *layer = BKE_id_attributes_color_find(&mesh.id, attribute_name); AttributeOwner owner = AttributeOwner::from_id(&mesh.id); const AttrDomain domain = BKE_attribute_domain(owner, layer); if (layer->type == CD_PROP_COLOR) { diff --git a/source/blender/makesrna/intern/rna_attribute.cc b/source/blender/makesrna/intern/rna_attribute.cc index 0651ea7bcf2..cbe0042a52a 100644 --- a/source/blender/makesrna/intern/rna_attribute.cc +++ b/source/blender/makesrna/intern/rna_attribute.cc @@ -182,6 +182,8 @@ const EnumPropertyItem rna_enum_attribute_curves_domain_items[] = { # include "WM_api.hh" +using blender::StringRef; + /* Attribute */ static AttributeOwner owner_from_attribute_pointer_rna(PointerRNA *ptr) @@ -740,7 +742,7 @@ static PointerRNA rna_AttributeGroupMesh_active_color_get(PointerRNA *ptr) AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id); CustomDataLayer *layer = BKE_attribute_search_for_write( owner, - BKE_id_attributes_active_color_name(ptr->owner_id), + BKE_id_attributes_active_color_name(ptr->owner_id).value_or(""), CD_MASK_COLOR_ALL, ATTR_DOMAIN_MASK_COLOR); @@ -767,7 +769,7 @@ static int rna_AttributeGroupMesh_active_color_index_get(PointerRNA *ptr) AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id); const CustomDataLayer *layer = BKE_attribute_search( owner, - BKE_id_attributes_active_color_name(ptr->owner_id), + BKE_id_attributes_active_color_name(ptr->owner_id).value_or(""), CD_MASK_COLOR_ALL, ATTR_DOMAIN_MASK_COLOR); @@ -803,7 +805,7 @@ static int rna_AttributeGroupMesh_render_color_index_get(PointerRNA *ptr) { AttributeOwner owner = AttributeOwner::from_id(ptr->owner_id); const CustomDataLayer *layer = BKE_id_attributes_color_find( - ptr->owner_id, BKE_id_attributes_default_color_name(ptr->owner_id)); + ptr->owner_id, BKE_id_attributes_default_color_name(ptr->owner_id).value_or("")); return BKE_attribute_to_index(owner, layer, ATTR_DOMAIN_MASK_COLOR, CD_MASK_COLOR_ALL); } @@ -836,19 +838,15 @@ static void rna_AttributeGroupMesh_render_color_index_range( static void rna_AttributeGroupMesh_default_color_name_get(PointerRNA *ptr, char *value) { const ID *id = ptr->owner_id; - const char *name = BKE_id_attributes_default_color_name(id); - if (!name) { - value[0] = '\0'; - return; - } - strcpy(value, name); + const StringRef name = BKE_id_attributes_default_color_name(id).value_or(""); + name.copy_unsafe(value); } static int rna_AttributeGroupMesh_default_color_name_length(PointerRNA *ptr) { const ID *id = ptr->owner_id; - const char *name = BKE_id_attributes_default_color_name(id); - return name ? strlen(name) : 0; + const StringRef name = BKE_id_attributes_default_color_name(id).value_or(""); + return name.size(); } static void rna_AttributeGroupMesh_default_color_name_set(PointerRNA *ptr, const char *value) @@ -866,19 +864,15 @@ static void rna_AttributeGroupMesh_default_color_name_set(PointerRNA *ptr, const static void rna_AttributeGroupMesh_active_color_name_get(PointerRNA *ptr, char *value) { const ID *id = ptr->owner_id; - const char *name = BKE_id_attributes_active_color_name(id); - if (!name) { - value[0] = '\0'; - return; - } - strcpy(value, name); + const StringRef name = BKE_id_attributes_active_color_name(id).value_or(""); + name.copy_unsafe(value); } static int rna_AttributeGroupMesh_active_color_name_length(PointerRNA *ptr) { const ID *id = ptr->owner_id; - const char *name = BKE_id_attributes_active_color_name(id); - return name ? strlen(name) : 0; + const StringRef name = BKE_id_attributes_active_color_name(id).value_or(""); + return name.size(); } static void rna_AttributeGroupMesh_active_color_name_set(PointerRNA *ptr, const char *value) diff --git a/source/blender/makesrna/intern/rna_mesh.cc b/source/blender/makesrna/intern/rna_mesh.cc index f3616f77ba7..13d6cb47e39 100644 --- a/source/blender/makesrna/intern/rna_mesh.cc +++ b/source/blender/makesrna/intern/rna_mesh.cc @@ -65,6 +65,8 @@ static const EnumPropertyItem rna_enum_mesh_remesh_mode_items[] = { # include "rna_mesh_utils.hh" +using blender::StringRef; + /* -------------------------------------------------------------------- */ /** \name Generic Helpers * \{ */ @@ -951,7 +953,7 @@ static int rna_MeshUVLoopLayer_data_length(PointerRNA *ptr) return (mesh->runtime->edit_mesh) ? 0 : mesh->corners_num; } -static MBoolProperty *MeshUVLoopLayer_get_bool_layer(Mesh *mesh, char const *name) +static MBoolProperty *MeshUVLoopLayer_get_bool_layer(Mesh *mesh, const StringRef name) { void *layer = CustomData_get_layer_named_for_write( &mesh->corner_data, CD_PROP_BOOL, name, mesh->corners_num); @@ -967,16 +969,16 @@ static MBoolProperty *MeshUVLoopLayer_get_bool_layer(Mesh *mesh, char const *nam static void bool_layer_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, - const char *(*layername_func)(const char *uv_name, char *name)) + StringRef (*layername_func)(const StringRef uv_name, char *buffer)) { - char bool_layer_name[MAX_CUSTOMDATA_LAYER_NAME]; + char buffer[MAX_CUSTOMDATA_LAYER_NAME]; Mesh *mesh = rna_mesh(ptr); CustomDataLayer *layer = (CustomDataLayer *)ptr->data; - layername_func(layer->name, bool_layer_name); + const StringRef name = layername_func(layer->name, buffer); rna_iterator_array_begin(iter, ptr, - MeshUVLoopLayer_get_bool_layer(mesh, bool_layer_name), + MeshUVLoopLayer_get_bool_layer(mesh, name), sizeof(MBoolProperty), (mesh->runtime->edit_mesh) ? 0 : mesh->corners_num, 0, @@ -986,19 +988,18 @@ static void bool_layer_begin(CollectionPropertyIterator *iter, static bool bool_layer_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr, - const char *(*layername_func)(const char *uv_name, char *name)) + StringRef (*layername_func)(const StringRef uv_name, + char *buffer)) { - char bool_layer_name[MAX_CUSTOMDATA_LAYER_NAME]; + char buffer[MAX_CUSTOMDATA_LAYER_NAME]; Mesh *mesh = rna_mesh(ptr); if (mesh->runtime->edit_mesh || index < 0 || index >= mesh->corners_num) { return 0; } CustomDataLayer *layer = (CustomDataLayer *)ptr->data; - layername_func(layer->name, bool_layer_name); - rna_pointer_create_with_ancestors(*ptr, - &RNA_BoolAttributeValue, - MeshUVLoopLayer_get_bool_layer(mesh, bool_layer_name) + index, - *r_ptr); + const StringRef name = layername_func(layer->name, buffer); + rna_pointer_create_with_ancestors( + *ptr, &RNA_BoolAttributeValue, MeshUVLoopLayer_get_bool_layer(mesh, name) + index, *r_ptr); return 1; }