From bbb14b95bb12ea8ce2cfb523fe2e10bedc169836 Mon Sep 17 00:00:00 2001 From: Hoshinova Date: Wed, 6 Mar 2024 15:42:22 +0100 Subject: [PATCH 1/3] Fix: Crash when creating Noise Texture node with link-drag-search Fix crash when creating a Noise Texture through dragging and releasing another output and connecting it to the "Gain" or "Offset" sockets. Pull Request: https://projects.blender.org/blender/blender/pulls/119097 --- source/blender/nodes/shader/nodes/node_shader_tex_noise.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc index 715bc7972b5..9cd56d411eb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -40,8 +40,10 @@ static void sh_node_tex_noise_declare(NodeDeclarationBuilder &b) .max(1000.0f) .default_value(2.0f) .description("The scale of a Perlin noise octave relative to that of the previous octave"); - b.add_input("Offset").min(-1000.0f).max(1000.0f).default_value(0.0f); - b.add_input("Gain").min(0.0f).max(1000.0f).default_value(1.0f); + b.add_input("Offset").min(-1000.0f).max(1000.0f).default_value(0.0f).make_available( + [](bNode &node) { node_storage(node).type = SHD_NOISE_RIDGED_MULTIFRACTAL; }); + b.add_input("Gain").min(0.0f).max(1000.0f).default_value(1.0f).make_available( + [](bNode &node) { node_storage(node).type = SHD_NOISE_RIDGED_MULTIFRACTAL; }); b.add_input("Distortion").min(-1000.0f).max(1000.0f).default_value(0.0f); b.add_output("Fac").no_muted_links(); b.add_output("Color").no_muted_links(); From 010651466983693936fb215626058ecb94527066 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 6 Mar 2024 16:16:43 +0100 Subject: [PATCH 2/3] Fix #107232: Creating builtin attributes in edit mode can cause crash For example, creating the "position" attribute with the wrong name or type could crash Blender when exiting edit mode. This is because some data isn't stored as attributes in Blender, and the attribute API doesn't work very well with BMesh. Two parts to the solution: - Remove builtin attributes with incorrect domains or names when converting from BMesh to Mesh. - Add error messages when creating builtin attributes in edit mode. It's still possible to create name-convention attributes, because Blender should be able to handle different types and domains for them. Pull Request: https://projects.blender.org/blender/blender/pulls/119110 --- source/blender/blenkernel/intern/attribute.cc | 44 +++++++++++++++++++ .../bmesh/intern/bmesh_mesh_convert.cc | 8 +++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index b9837058413..a09470ab21a 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -165,6 +165,36 @@ static bool bke_id_attribute_rename_if_exists(ID *id, return BKE_id_attribute_rename(id, old_name, new_name, reports); } +static bool mesh_edit_mode_attribute_valid(const blender::StringRef name, + const AttrDomain domain, + const eCustomDataType data_type, + ReportList *reports) +{ + if (ELEM(name, + "position", + ".edge_verts", + ".corner_vert", + ".corner_edge", + "sharp_edge", + "sharp_face", + "material_index")) + { + BKE_report(reports, RPT_ERROR, "Unable to create builtin attribute in edit mode"); + return false; + } + if (name == "id") { + if (domain != AttrDomain::Point) { + BKE_report(reports, RPT_ERROR, "Domain unsupported for \"id\" attribute"); + return false; + } + if (data_type != CD_PROP_INT32) { + BKE_report(reports, RPT_ERROR, "Type unsupported for \"id\" attribute"); + return false; + } + } + return true; +} + bool BKE_id_attribute_rename(ID *id, const char *old_name, const char *new_name, @@ -200,6 +230,17 @@ bool BKE_id_attribute_rename(ID *id, return false; } + if (GS(id->name) == ID_ME) { + Mesh *mesh = reinterpret_cast(id); + if (mesh->edit_mesh) { + if (!mesh_edit_mode_attribute_valid( + new_name, BKE_id_attribute_domain(id, layer), eCustomDataType(layer->type), reports)) + { + return false; + } + } + } + std::string result_name = BKE_id_attribute_calc_unique_name(*id, new_name); if (layer->type == CD_PROP_FLOAT2 && GS(id->name) == ID_ME) { @@ -286,6 +327,9 @@ CustomDataLayer *BKE_id_attribute_new(ID *id, if (GS(id->name) == ID_ME) { Mesh *mesh = reinterpret_cast(id); if (BMEditMesh *em = mesh->edit_mesh) { + if (!mesh_edit_mode_attribute_valid(name, domain, type, reports)) { + return nullptr; + } BM_data_layer_add_named(em->bm, customdata, type, uniquename.c_str()); const int index = CustomData_get_named_layer_index(customdata, type, uniquename.c_str()); return (index == -1) ? nullptr : &(customdata->layers[index]); diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index 42c81157513..f4b6c0a3c5a 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -1257,6 +1257,7 @@ static void bm_to_mesh_verts(const BMesh &bm, MutableSpan select_vert, MutableSpan hide_vert) { + CustomData_free_layer_named(&mesh.vert_data, "position", mesh.verts_num); CustomData_add_layer_named( &mesh.vert_data, CD_PROP_FLOAT3, CD_CONSTRUCT, mesh.verts_num, "position"); const Vector info = bm_to_mesh_copy_info_calc(bm.vdata, mesh.vert_data); @@ -1299,6 +1300,7 @@ static void bm_to_mesh_edges(const BMesh &bm, MutableSpan sharp_edge, MutableSpan uv_seams) { + CustomData_free_layer_named(&mesh.edge_data, ".edge_verts", mesh.edges_num); CustomData_add_layer_named( &mesh.edge_data, CD_PROP_INT32_2D, CD_CONSTRUCT, mesh.edges_num, ".edge_verts"); const Vector info = bm_to_mesh_copy_info_calc(bm.edata, mesh.edge_data); @@ -1385,10 +1387,12 @@ static void bm_to_mesh_faces(const BMesh &bm, static void bm_to_mesh_loops(const BMesh &bm, const Span bm_loops, Mesh &mesh) { + CustomData_free_layer_named(&mesh.corner_data, ".corner_vert", mesh.corners_num); + CustomData_free_layer_named(&mesh.corner_data, ".corner_edge", mesh.corners_num); CustomData_add_layer_named( - &mesh.corner_data, CD_PROP_INT32, CD_CONSTRUCT, bm.totloop, ".corner_vert"); + &mesh.corner_data, CD_PROP_INT32, CD_CONSTRUCT, mesh.corners_num, ".corner_vert"); CustomData_add_layer_named( - &mesh.corner_data, CD_PROP_INT32, CD_CONSTRUCT, bm.totloop, ".corner_edge"); + &mesh.corner_data, CD_PROP_INT32, CD_CONSTRUCT, mesh.corners_num, ".corner_edge"); const Vector info = bm_to_mesh_copy_info_calc(bm.ldata, mesh.corner_data); MutableSpan dst_corner_verts = mesh.corner_verts_for_write(); MutableSpan dst_corner_edges = mesh.corner_edges_for_write(); From 216637ab56c8f976986137bb1e4cef66e71e8bf9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 6 Mar 2024 16:34:27 +0100 Subject: [PATCH 3/3] Build: Upgrade OSL to 1.13.7, OIDN to 2.2.1 Fix #118020: Crash with OptiX OSL on Windows Maybe help with #119035: Memory leaks with OIDN GPU Ref #113157 Pull Request: https://projects.blender.org/blender/blender/pulls/119095 --- build_files/build_environment/cmake/versions.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index f9962bc4c91..d74f389d3da 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -219,9 +219,9 @@ set(TIFF_HOMEPAGE http://www.simplesystems.org/libtiff/) # 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 3d52f3906b12d38ad0f4b991a8f9ea678171bd28) -set(OSL_URI https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/archive/${OSL_VERSION}.tar.gz) -set(OSL_HASH dfe5d69f48930badc1ad39a4e11e2e98) +set(OSL_VERSION 1.13.7.0) +set(OSL_URI https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/archive/refs/tags/v${OSL_VERSION}.tar.gz) +set(OSL_HASH 769ae444a7df0e6561b3e745fd2eb50d) set(OSL_HASH_TYPE MD5) set(OSL_FILE OpenShadingLanguage-${OSL_VERSION}.tar.gz) @@ -529,9 +529,9 @@ set(MATERIALX_HASH fad8f4e19305fb2ee920cbff638f3560) set(MATERIALX_HASH_TYPE MD5) set(MATERIALX_FILE materialx-v${MATERIALX_VERSION}.tar.gz) -set(OIDN_VERSION 2.2.0-rc2) +set(OIDN_VERSION 2.2.1) set(OIDN_URI https://github.com/OpenImageDenoise/oidn/releases/download/v${OIDN_VERSION}/oidn-${OIDN_VERSION}.src.tar.gz) -set(OIDN_HASH 14b261af3a719c49ab10e71583f1a61a) +set(OIDN_HASH a1c5299b2b640a0e0569afcf405c82bf) set(OIDN_HASH_TYPE MD5) set(OIDN_FILE oidn-${OIDN_VERSION}.src.tar.gz)