[Bf-blender-cvs] [89349067b6f] master: Merge branch 'blender-v3.4-release'
Commit: 89349067b6f55971e3b25779d5e527660cd3c298 Author: Hans Goudey Date: Mon Nov 21 18:01:29 2022 -0600 Branches: master https://developer.blender.org/rB89349067b6f55971e3b25779d5e527660cd3c298 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b53c4fa8daa] blender-v3.4-release: Fix T102522: Geometry nodes boolean doesent respect material index
Commit: b53c4fa8daa199a8ccd4080baf2267c82d8b69a8 Author: Hans Goudey Date: Mon Nov 21 15:49:18 2022 -0600 Branches: blender-v3.4-release https://developer.blender.org/rBb53c4fa8daa199a8ccd4080baf2267c82d8b69a8 Fix T102522: Geometry nodes boolean doesent respect material index The refactor in f1c0249f34c417 incorrectly placed the material index remapping before the transfer of generic attributes. Now that the material index is a generic attribute, it was overwritten. === M source/blender/blenkernel/intern/mesh_boolean_convert.cc === diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc index 360c7da2ae2..21d9baf7f7e 100644 --- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc +++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc @@ -410,16 +410,6 @@ static void copy_poly_attributes(Mesh *dest_mesh, Span material_remap, MutableSpan dst_material_indices) { - const VArray src_material_indices = orig_me->attributes().lookup_or_default( - "material_index", ATTR_DOMAIN_FACE, 0); - const int src_index = src_material_indices[index_in_orig_me]; - if (material_remap.size() > 0 && material_remap.index_range().contains(src_index)) { -dst_material_indices[mp_index] = material_remap[src_index]; - } - else { -dst_material_indices[mp_index] = src_index; - } - mp->flag = orig_mp->flag; CustomData *target_cd = &dest_mesh->pdata; const CustomData *source_cd = &orig_me->pdata; @@ -435,6 +425,17 @@ static void copy_poly_attributes(Mesh *dest_mesh, source_cd, target_cd, source_layer_i, target_layer_i, index_in_orig_me, mp_index, 1); } } + + /* Fix material indices after they have been transferred as a generic attribute. */ + const VArray src_material_indices = orig_me->attributes().lookup_or_default( + "material_index", ATTR_DOMAIN_FACE, 0); + const int src_index = src_material_indices[index_in_orig_me]; + if (material_remap.size() > 0 && material_remap.index_range().contains(src_index)) { +dst_material_indices[mp_index] = material_remap[src_index]; + } + else { +dst_material_indices[mp_index] = src_index; + } } /* Similar to copy_vert_attributes but for edge attributes. */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2f385b0df1e] tmp-vfx-platform-2023: Merge remote-tracking branch 'origin/master' into tmp-vfx-platform-2023
Commit: 2f385b0df1e745aa4daab9c655da1a381af15bb0 Author: Ray Molenkamp Date: Mon Nov 21 14:02:13 2022 -0700 Branches: tmp-vfx-platform-2023 https://developer.blender.org/rB2f385b0df1e745aa4daab9c655da1a381af15bb0 Merge remote-tracking branch 'origin/master' into tmp-vfx-platform-2023 === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1c33d1813df] tmp-vfx-platform-2023: deps/win: support building against older lib folder
Commit: 1c33d1813dfd48b7553ada45065043cf8dcb82bd Author: Ray Molenkamp Date: Mon Nov 21 12:58:26 2022 -0700 Branches: tmp-vfx-platform-2023 https://developer.blender.org/rB1c33d1813dfd48b7553ada45065043cf8dcb82bd deps/win: support building against older lib folder We try to support both 3.4 and 3.5 lib folders to make bisecting a little easier. Disable materialX if it is not found in the windows library folder. Linux already does this. === M build_files/cmake/platform/platform_win32.cmake === diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 6cbc7656165..1cab2ee70ad 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -285,6 +285,11 @@ if(CMAKE_GENERATOR MATCHES "^Visual Studio.+" AND WITH_CLANG_TIDY) set(VS_CLANG_TIDY ON) endif() +# To support building against both 3.4 and 3.5 lib folders, disable materialX if it is not found +set(MATERIALX_LIB_FOLDER_EXISTS EXISTS ${LIBDIR}/materialx) +set_and_warn_library_found("MaterialX" MATERIALX_LIB_FOLDER_EXISTS WITH_MATERIALX) +unset(MATERIALX_LIB_FOLDER_EXISTS) + # Mark libdir as system headers with a lower warn level, to resolve some warnings # that we have very little control over if(NOT MSVC_CLANG AND # Available with MSVC 15.7+ but not for CLANG. ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [efbede5bc22] soc-2022-many-lights-sampling: Refactor: pre-allocate `light_prims`
Commit: efbede5bc221fd57992b4721a3eaf73d90d9b63c Author: Weizhen Huang Date: Mon Nov 21 20:27:52 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBefbede5bc221fd57992b4721a3eaf73d90d9b63c Refactor: pre-allocate `light_prims` === M intern/cycles/scene/light.cpp === diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index de133d03939..b2d85256523 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -274,24 +274,17 @@ void LightManager::device_update_distribution(Device *device, KernelIntegrator *kintegrator = &dscene->data.integrator; KernelFilm *kfilm = &dscene->data.film; - if (kintegrator->use_light_tree) { -dscene->light_distribution.free(); -return; - } - /* Update CDF over lights. */ progress.set_status("Updating Lights", "Computing distribution"); /* Counts emissive triangles in the scene. */ size_t num_triangles = 0; - int object_id = 0; foreach (Object *object, scene->objects) { if (progress.get_cancel()) return; if (!object_usable_as_light(object)) { - object_id++; continue; } @@ -309,15 +302,22 @@ void LightManager::device_update_distribution(Device *device, num_triangles++; } } - -object_id++; } const size_t num_lights = kintegrator->num_lights; const size_t num_background_lights = kintegrator->num_background_lights; const size_t num_distribution = num_triangles + num_lights; + + /* Distribution size. */ + kintegrator->num_distribution = num_distribution; + VLOG_INFO << "Total " << num_distribution << " of light distribution primitives."; + if (kintegrator->use_light_tree) { +dscene->light_distribution.free(); +return; + } + /* Emission area. */ KernelLightDistribution *distribution = dscene->light_distribution.alloc(num_distribution + 1); float totarea = 0.0f; @@ -435,9 +435,6 @@ void LightManager::device_update_distribution(Device *device, /* Update integrator state. */ kintegrator->use_direct_light = (totarea > 0.0f); - /* Distribution size. */ - kintegrator->num_distribution = num_distribution; - /* Precompute pdfs for distribution sampling. * Sample one, with 0.5 probability of light or triangle. */ kintegrator->distribution_pdf_triangles = 0.0f; @@ -496,7 +493,9 @@ void LightManager::device_update_tree(Device *device, /* Add both lights and emissive triangles to this vector for light tree construction. */ vector light_prims; + light_prims.reserve(kintegrator->num_distribution - kintegrator->num_distant_lights); vector distant_lights; + distant_lights.reserve(kintegrator->num_distant_lights); vector object_lookup_offsets(scene->objects.size()); /* When we keep track of the light index, only contributing lights will be added to the device. @@ -506,15 +505,12 @@ void LightManager::device_update_tree(Device *device, int scene_light_index = 0; foreach (Light *light, scene->lights) { if (light->is_enabled) { - /* -prim_id - 1 is a light source index. */ - LightTreePrimitive light_prim(scene, ~device_light_index, scene_light_index); - /* Distant lights get added to a separate vector. */ if (light->light_type == LIGHT_BACKGROUND || light->light_type == LIGHT_DISTANT) { -distant_lights.push_back(light_prim); +distant_lights.emplace_back(scene, ~device_light_index, scene_light_index); } else { -light_prims.push_back(light_prim); +light_prims.emplace_back(scene, ~device_light_index, scene_light_index); } device_light_index++; @@ -524,7 +520,6 @@ void LightManager::device_update_tree(Device *device, } /* Similarly, we also want to keep track of the index of triangles that are emissive. */ - size_t num_triangles = 0; size_t total_triangles = 0; int object_id = 0; foreach (Object *object, scene->objects) { @@ -549,10 +544,7 @@ void LightManager::device_update_tree(Device *device, scene->default_surface; if (shader->emission_sampling != EMISSION_SAMPLING_NONE) { -LightTreePrimitive light_prim(scene, i, object_id); -light_prims.push_back(light_prim); - -num_triangles++; +light_prims.emplace_back(scene, i, object_id); } } @@ -567,7 +559,7 @@ void LightManager::device_update_tree(Device *device, /* TODO: this shadow scale mechanism does not work for light tree. */ kfilm->pass_shadow_scale = 1.0f; - /* For now, we'll start with a smaller number of max lights in a node. + /* TODO: For now, we'll start with a smaller number of max lights in a node. * More benchmarking is needed to determine what number works best. */ LightTree light_tree(light_prims, 8); @@ -1215,11 +1207,14 @@ void L
[Bf-blender-cvs] [25ddb576ff1] master: Cleanup: add ATTR_FALLTHROGUH
Commit: 25ddb576ff167271bc8e796eb2702d2599002ed5 Author: Joseph Eagar Date: Mon Nov 21 10:42:53 2022 -0800 Branches: master https://developer.blender.org/rB25ddb576ff167271bc8e796eb2702d2599002ed5 Cleanup: add ATTR_FALLTHROGUH === M source/blender/blenkernel/intern/pbvh.c === diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index ac4c1e94c1c..3d1a20bb688 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -3656,6 +3656,7 @@ void BKE_pbvh_face_iter_init(PBVH *pbvh, PBVHNode *node, PBVHFaceIter *fd) switch (BKE_pbvh_type(pbvh)) { case PBVH_GRIDS: fd->subdiv_ccg_ = pbvh->subdiv_ccg; + ATTR_FALLTHROUGH; case PBVH_FACES: fd->mpoly_ = pbvh->mpoly; fd->mloop_ = pbvh->mloop; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [02e045ffbee] master: Merge branch 'blender-v3.4-release'
Commit: 02e045ffbeefa248d4abab6bef02fa2a41d9db86 Author: Brecht Van Lommel Date: Mon Nov 21 19:19:58 2022 +0100 Branches: master https://developer.blender.org/rB02e045ffbeefa248d4abab6bef02fa2a41d9db86 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9702eac251b] soc-2022-many-lights-sampling: Cleanup: `sample_reservoir()` should not choose -1 now
Commit: 9702eac251b8bc1f763a383b175d489276f28daa Author: Weizhen Huang Date: Mon Nov 21 19:29:41 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB9702eac251b8bc1f763a383b175d489276f28daa Cleanup: `sample_reservoir()` should not choose -1 now === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index 560c25e9197..58c51c529b3 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -432,9 +432,6 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg, rand); has_importance >>= 1; } - if (selected_index == -1) { -return -1; - } float discard; light_tree_emitter_importance( ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9a0e08c828a] soc-2022-many-lights-sampling: Refactor: merge `PackedLightTreeNode` and `LightTreeBuildNode` to `LightTreeNode` `flatten_tree()` is not needed for sequential build, mig
Commit: 9a0e08c828aa4714c20974559e0f1c055bfbf284 Author: Weizhen Huang Date: Mon Nov 21 19:23:02 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB9a0e08c828aa4714c20974559e0f1c055bfbf284 Refactor: merge `PackedLightTreeNode` and `LightTreeBuildNode` to `LightTreeNode` `flatten_tree()` is not needed for sequential build, might need to be added back if converting to parallel build in the future === M intern/cycles/scene/light.cpp M intern/cycles/scene/light_tree.cpp M intern/cycles/scene/light_tree.h === diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index cf5019aa664..de133d03939 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -569,8 +569,7 @@ void LightManager::device_update_tree(Device *device, /* For now, we'll start with a smaller number of max lights in a node. * More benchmarking is needed to determine what number works best. */ - LightTree light_tree(light_prims, scene, 8); - light_prims = light_tree.get_prims(); + LightTree light_tree(light_prims, 8); /* We want to create separate arrays corresponding to triangles and lights, * which will be used to index back into the light tree for PDF calculations. */ @@ -584,12 +583,12 @@ void LightManager::device_update_tree(Device *device, } /* First initialize the light tree's nodes. */ - const vector &linearized_bvh = light_tree.get_nodes(); + const vector &linearized_bvh = light_tree.get_nodes(); KernelLightTreeNode *light_tree_nodes = dscene->light_tree_nodes.alloc(linearized_bvh.size()); KernelLightTreeEmitter *light_tree_emitters = dscene->light_tree_emitters.alloc( light_prims.size()); for (int index = 0; index < linearized_bvh.size(); index++) { -const PackedLightTreeNode &node = linearized_bvh[index]; +const LightTreeNode &node = linearized_bvh[index]; light_tree_nodes[index].energy = node.energy; @@ -604,11 +603,11 @@ void LightManager::device_update_tree(Device *device, light_tree_nodes[index].bit_trail = node.bit_trail; /* Here we need to make a distinction between interior and leaf nodes. */ -if (node.is_leaf_node) { - light_tree_nodes[index].num_prims = node.num_lights; +if (node.is_leaf()) { + light_tree_nodes[index].num_prims = node.num_prims; light_tree_nodes[index].child_index = -node.first_prim_index; - for (int i = 0; i < node.num_lights; i++) { + for (int i = 0; i < node.num_prims; i++) { int emitter_index = i + node.first_prim_index; LightTreePrimitive &prim = light_prims[emitter_index]; @@ -661,7 +660,7 @@ void LightManager::device_update_tree(Device *device, } } else { - light_tree_nodes[index].child_index = node.second_child_index; + light_tree_nodes[index].child_index = node.right_child_index; } } diff --git a/intern/cycles/scene/light_tree.cpp b/intern/cycles/scene/light_tree.cpp index fca8345150f..f051f30a5fe 100644 --- a/intern/cycles/scene/light_tree.cpp +++ b/intern/cycles/scene/light_tree.cpp @@ -185,103 +185,59 @@ LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id) } } -void LightTreeBuildNode::init_leaf(const uint &offset, - const uint &n, - const BoundBox &b, - const OrientationBounds &c, - const float &e, - const uint &bits) -{ - bbox = b; - bcone = c; - energy = e; - first_prim_index = offset; - num_lights = n; - - children[0] = children[1] = nullptr; - bit_trail = bits; - is_leaf = true; -} - -void LightTreeBuildNode::init_interior(LightTreeBuildNode *c0, - LightTreeBuildNode *c1, - const BoundBox &b, - const OrientationBounds &c, - const float &e, - const uint &bits) -{ - bbox = b; - bcone = c; - energy = e; - first_prim_index = 0; - num_lights = 0; - - children[0] = c0; - children[1] = c1; - bit_trail = bits; - is_leaf = false; -} - -LightTree::LightTree(const vector &prims, - Scene *scene, - uint max_lights_in_leaf) +LightTree::LightTree(vector &prims, uint max_lights_in_leaf) { if (prims.empty()) { return; } - prims_ = prims; - scene_ = scene; max_lights_in_leaf_ = max_lights_in_leaf; for (int i = 0; i < prims.size(); i++) { -prims_[i].prim_num = i; +prims[i].prim_num = i; } - int total_nodes = 0; vector ordered_prims; - LightTreeBuildNode *root = recursive_build(0, prims.size(), total_nodes, ordered_prims, 0, 0); -
[Bf-blender-cvs] [03b5be4e3cd] blender-v3.4-release: Cycles: use more PMJ patterns and make their size adaptive.
Commit: 03b5be4e3cdf6a4967cb438dacd595c23075db79 Author: Nathan Vegdahl Date: Mon Nov 21 18:16:27 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB03b5be4e3cdf6a4967cb438dacd595c23075db79 Cycles: use more PMJ patterns and make their size adaptive. This resolves some issues with correlation artifacts at higher sample counts. Fix T101356, correlation issues in new PMJ pattern. Differential Revision: https://developer.blender.org/D16561 === M intern/cycles/kernel/data_template.h M intern/cycles/kernel/sample/jitter.h M intern/cycles/kernel/types.h M intern/cycles/scene/integrator.cpp === diff --git a/intern/cycles/kernel/data_template.h b/intern/cycles/kernel/data_template.h index 6b89de13797..c7b50b20c70 100644 --- a/intern/cycles/kernel/data_template.h +++ b/intern/cycles/kernel/data_template.h @@ -183,6 +183,7 @@ KERNEL_STRUCT_MEMBER(integrator, int, use_lamp_mis) KERNEL_STRUCT_MEMBER(integrator, int, use_caustics) /* Sampling pattern. */ KERNEL_STRUCT_MEMBER(integrator, int, sampling_pattern) +KERNEL_STRUCT_MEMBER(integrator, int, pmj_sequence_size) KERNEL_STRUCT_MEMBER(integrator, float, scrambling_distance) /* Volume render. */ KERNEL_STRUCT_MEMBER(integrator, int, use_volumes) @@ -205,6 +206,11 @@ KERNEL_STRUCT_MEMBER(integrator, int, use_surface_guiding) KERNEL_STRUCT_MEMBER(integrator, int, use_volume_guiding) KERNEL_STRUCT_MEMBER(integrator, int, use_guiding_direct_light) KERNEL_STRUCT_MEMBER(integrator, int, use_guiding_mis_weights) + +/* Padding. */ +KERNEL_STRUCT_MEMBER(integrator, int, pad1) +KERNEL_STRUCT_MEMBER(integrator, int, pad2) +KERNEL_STRUCT_MEMBER(integrator, int, pad3) KERNEL_STRUCT_END(KernelIntegrator) /* SVM. For shader specialization. */ diff --git a/intern/cycles/kernel/sample/jitter.h b/intern/cycles/kernel/sample/jitter.h index e748f95fc7d..1cde9f9d3de 100644 --- a/intern/cycles/kernel/sample/jitter.h +++ b/intern/cycles/kernel/sample/jitter.h @@ -7,6 +7,25 @@ #pragma once CCL_NAMESPACE_BEGIN +ccl_device uint pmj_shuffled_sample_index(KernelGlobals kg, uint sample, uint dimension, uint seed) +{ + const uint sample_count = kernel_data.integrator.pmj_sequence_size; + + /* Shuffle the pattern order and sample index to better decorrelate + * dimensions and make the most of the finite patterns we have. + * The funky sample mask stuff is to ensure that we only shuffle + * *within* the current sample pattern, which is necessary to avoid + * early repeat pattern use. */ + const uint pattern_i = hash_shuffle_uint(dimension, NUM_PMJ_PATTERNS, seed); + /* sample_count should always be a power of two, so this results in a mask. */ + const uint sample_mask = sample_count - 1; + const uint sample_shuffled = nested_uniform_scramble(sample, + hash_wang_seeded_uint(dimension, seed)); + sample = (sample & ~sample_mask) | (sample_shuffled & sample_mask); + + return ((pattern_i * sample_count) + sample) % (sample_count * NUM_PMJ_PATTERNS); +} + ccl_device float pmj_sample_1D(KernelGlobals kg, uint sample, const uint rng_hash, @@ -20,22 +39,9 @@ ccl_device float pmj_sample_1D(KernelGlobals kg, seed = kernel_data.integrator.seed; } - /* Shuffle the pattern order and sample index to better decorrelate - * dimensions and make the most of the finite patterns we have. - * The funky sample mask stuff is to ensure that we only shuffle - * *within* the current sample pattern, which is necessary to avoid - * early repeat pattern use. */ - const uint pattern_i = hash_shuffle_uint(dimension, NUM_PMJ_PATTERNS, seed); - /* NUM_PMJ_SAMPLES should be a power of two, so this results in a mask. */ - const uint sample_mask = NUM_PMJ_SAMPLES - 1; - const uint sample_shuffled = nested_uniform_scramble(sample, - hash_wang_seeded_uint(dimension, seed)); - sample = (sample & ~sample_mask) | (sample_shuffled & sample_mask); - /* Fetch the sample. */ - const uint index = ((pattern_i * NUM_PMJ_SAMPLES) + sample) % - (NUM_PMJ_SAMPLES * NUM_PMJ_PATTERNS); - float x = kernel_data_fetch(sample_pattern_lut, index * 2); + const uint index = pmj_shuffled_sample_index(kg, sample, dimension, seed); + float x = kernel_data_fetch(sample_pattern_lut, index * NUM_PMJ_DIMENSIONS); /* Do limited Cranley-Patterson rotation when using scrambling distance. */ if (kernel_data.integrator.scrambling_distance < 1.0f) { @@ -61,23 +67,10 @@ ccl_device float2 pmj_sample_2D(KernelGlobals kg, seed = kernel_data.integrator.seed; } - /* Shuffle the pattern order and sample index to better decorrelate - * dimensions and make the most of the finite patterns we have. - * The funky sample ma
[Bf-blender-cvs] [41a3de878f6] blender-v3.4-release: Fix part of T102450: Cycles OSL render issues for with normals in shader nodes
Commit: 41a3de878f64ae19e4f80c58102cc64e583d3a5f Author: Patrick Mours Date: Fri Nov 11 16:42:49 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB41a3de878f64ae19e4f80c58102cc64e583d3a5f Fix part of T102450: Cycles OSL render issues for with normals in shader nodes Commit c8dd33f5a37b6a6db0b6950d24f9a7cff5ceb799 in OSL changed behavior of parameters that reference each other and are also overwritten with an instance value. This is causing the "NormalIn" parameter of a few OSL nodes in Cycles to be set to zero somehow, which should instead have received the value from a "node_geometry" node Cycles generates and connects automatically. I am not entirely sure why that is happening, but these parameters are superfluous anyway, since OSL already provides the necessary data in the global variable "N". So this patch simply removes those parameters (which mimics SVM, where these parameters do not exist either), which also fixes the rendering artifacts that occured with recent OSL. While this fixes built-in shader nodes, custom OSL scripts can still have this problem. Ref T101222 Differential Revision: https://developer.blender.org/D16470 === M intern/cycles/kernel/osl/shaders/node_geometry.osl M intern/cycles/kernel/osl/shaders/node_normal_map.osl M intern/cycles/kernel/osl/shaders/node_tangent.osl M intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl M intern/cycles/scene/shader_nodes.cpp M intern/cycles/scene/shader_nodes.h === diff --git a/intern/cycles/kernel/osl/shaders/node_geometry.osl b/intern/cycles/kernel/osl/shaders/node_geometry.osl index cc891abd6e3..5d9284deac2 100644 --- a/intern/cycles/kernel/osl/shaders/node_geometry.osl +++ b/intern/cycles/kernel/osl/shaders/node_geometry.osl @@ -3,8 +3,7 @@ #include "stdcycles.h" -shader node_geometry(normal NormalIn = N, - string bump_offset = "center", +shader node_geometry(string bump_offset = "center", output point Position = point(0.0, 0.0, 0.0), output normal Normal = normal(0.0, 0.0, 0.0), @@ -17,7 +16,7 @@ shader node_geometry(normal NormalIn = N, output float RandomPerIsland = 0.0) { Position = P; - Normal = NormalIn; + Normal = N; TrueNormal = Ng; Incoming = I; Parametric = point(1.0 - u - v, u, 0.0); diff --git a/intern/cycles/kernel/osl/shaders/node_normal_map.osl b/intern/cycles/kernel/osl/shaders/node_normal_map.osl index 3cda485c686..7e41bbf1720 100644 --- a/intern/cycles/kernel/osl/shaders/node_normal_map.osl +++ b/intern/cycles/kernel/osl/shaders/node_normal_map.osl @@ -3,13 +3,12 @@ #include "stdcycles.h" -shader node_normal_map(normal NormalIn = N, - float Strength = 1.0, +shader node_normal_map(float Strength = 1.0, color Color = color(0.5, 0.5, 1.0), string space = "tangent", string attr_name = "geom:tangent", string attr_sign_name = "geom:tangent_sign", - output normal Normal = NormalIn) + output normal Normal = N) { color mcolor = 2.0 * color(Color[0] - 0.5, Color[1] - 0.5, Color[2] - 0.5); int is_backfacing = backfacing(); @@ -71,5 +70,5 @@ shader node_normal_map(normal NormalIn = N, } if (Strength != 1.0) -Normal = normalize(NormalIn + (Normal - NormalIn) * max(Strength, 0.0)); +Normal = normalize(N + (Normal - N) * max(Strength, 0.0)); } diff --git a/intern/cycles/kernel/osl/shaders/node_tangent.osl b/intern/cycles/kernel/osl/shaders/node_tangent.osl index a302c001f08..b3808778b2f 100644 --- a/intern/cycles/kernel/osl/shaders/node_tangent.osl +++ b/intern/cycles/kernel/osl/shaders/node_tangent.osl @@ -3,8 +3,7 @@ #include "stdcycles.h" -shader node_tangent(normal NormalIn = N, -string attr_name = "geom:tangent", +shader node_tangent(string attr_name = "geom:tangent", string direction_type = "radial", string axis = "z", output normal Tangent = normalize(dPdu)) @@ -29,5 +28,5 @@ shader node_tangent(normal NormalIn = N, } T = transform("object", "world", T); - Tangent = cross(NormalIn, normalize(cross(T, NormalIn))); + Tangent = cross(N, normalize(cross(T, N))); } diff --git a/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl b/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl index 24875ce140a..cd2fdae3cb3 100644 --- a/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl +++ b/intern/cycles/kernel/osl/shaders/node_texture_coordinate.osl @@ -4,7 +4,6 @@ #include "stdcycles.h" shader node_texture_coordinate( -normal NormalIn = N, int is_background = 0, int is_volume = 0, int from_dupli =
[Bf-blender-cvs] [a444e9ce2f2] soc-2022-many-lights-sampling: Fix division by zero in reservoir sampling, add some asserts
Commit: a444e9ce2f214dccf6c4724f130ddbb9c2897b96 Author: Brecht Van Lommel Date: Mon Nov 21 17:00:22 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rBa444e9ce2f214dccf6c4724f130ddbb9c2897b96 Fix division by zero in reservoir sampling, add some asserts === M intern/cycles/kernel/light/tree.h === diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h index d7b8ebad2cf..560c25e9197 100644 --- a/intern/cycles/kernel/light/tree.h +++ b/intern/cycles/kernel/light/tree.h @@ -354,7 +354,7 @@ ccl_device_inline void sample_resevoir(const int current_index, } total_weight += current_weight; float thresh = current_weight / total_weight; - if (*rand < thresh) { + if (*rand <= thresh) { selected_index = current_index; selected_weight = current_weight; *rand = *rand / thresh; @@ -362,6 +362,7 @@ ccl_device_inline void sample_resevoir(const int current_index, else { *rand = (*rand - thresh) / (1.0f - thresh); } + kernel_assert(*rand >= 0.0f && *rand <= 1.0f); return; } @@ -525,11 +526,15 @@ ccl_device bool light_tree_sample(KernelGlobals kg, } if (*randu < left_probability) { /* go left */ + kernel_assert(left_probability > 0.0f); + node_index = left_index; *randu /= left_probability; *pdf_factor *= left_probability; } else { + kernel_assert((1.0f - left_probability) > 0.0f); + node_index = right_index; *randu = (*randu - left_probability) / (1.0f - left_probability); *pdf_factor *= (1.0f - left_probability); @@ -822,6 +827,8 @@ ccl_device bool light_tree_sample(KernelGlobals kg, float pdf_factor = 1.0f; bool ret; if (randu < light_tree_probability) { +kernel_assert(light_tree_probability > 0.0f); + randu = randu / light_tree_probability; pdf_factor *= light_tree_probability; ret = light_tree_sample(kg, @@ -838,6 +845,8 @@ ccl_device bool light_tree_sample(KernelGlobals kg, &pdf_factor); } else { +kernel_assert((1.0f - light_tree_probability) > 0.0f); + randu = (randu - light_tree_probability) / (1.0f - light_tree_probability); pdf_factor *= (1.0f - light_tree_probability); ret = light_tree_sample_distant_lights(kg, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4c48a1f7c73] tmp-vfx-platform-2023: deps_builder: Add materialX 1.38.6
Commit: 4c48a1f7c7357826173cc3eeef02b879f413049f Author: Georgiy Markelov Date: Mon Nov 21 11:07:55 2022 -0700 Branches: tmp-vfx-platform-2023 https://developer.blender.org/rB4c48a1f7c7357826173cc3eeef02b879f413049f deps_builder: Add materialX 1.38.6 This adds materialX to the deps builder, short term only the python bindings are expected to be used, but libraries are included for future use by blender as well. Some further work may need to be done in having MaterialX find its library. Reviewed by: brecht lazydodo Differential Revision: https://developer.blender.org/D15989 === M CMakeLists.txt M build_files/build_environment/CMakeLists.txt M build_files/build_environment/cmake/download.cmake M build_files/build_environment/cmake/harvest.cmake M build_files/build_environment/cmake/versions.cmake M build_files/cmake/config/blender_full.cmake M build_files/cmake/config/blender_lite.cmake M build_files/cmake/config/blender_release.cmake M build_files/cmake/platform/platform_unix.cmake R065release/windows/python/usercustomize.py release/scripts/site/usercustomize.py M source/creator/CMakeLists.txt === diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a621b859e7..1e80e0ffcdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,6 +330,9 @@ option(WITH_ALEMBIC "Enable Alembic Support" ON) # Universal Scene Description support option(WITH_USD "Enable Universal Scene Description (USD) Support" ON) +# MaterialX +option(WITH_MATERIALX "Enable MaterialX Support" ON) + # 3D format support # Disable opencollada when we don't have precompiled libs option(WITH_OPENCOLLADA "Enable OpenCollada Support (http://www.opencollada.org)" ON) @@ -1921,6 +1924,7 @@ if(FIRST_RUN) info_cfg_option(WITH_QUADRIFLOW) info_cfg_option(WITH_TBB) info_cfg_option(WITH_USD) + info_cfg_option(WITH_MATERIALX) info_cfg_option(WITH_XR_OPENXR) info_cfg_text("Compiler Options:") diff --git a/build_files/build_environment/CMakeLists.txt b/build_files/build_environment/CMakeLists.txt index 75591333c12..0e3df021a25 100644 --- a/build_files/build_environment/CMakeLists.txt +++ b/build_files/build_environment/CMakeLists.txt @@ -88,6 +88,7 @@ endif() include(cmake/python_site_packages.cmake) include(cmake/package_python.cmake) include(cmake/usd.cmake) +include(cmake/materialx.cmake) include(cmake/openvdb.cmake) include(cmake/potrace.cmake) include(cmake/haru.cmake) diff --git a/build_files/build_environment/cmake/download.cmake b/build_files/build_environment/cmake/download.cmake index f2681bd33d6..292cc994a44 100644 --- a/build_files/build_environment/cmake/download.cmake +++ b/build_files/build_environment/cmake/download.cmake @@ -126,6 +126,7 @@ download_source(SSL) download_source(SQLITE) download_source(EMBREE) download_source(USD) +download_source(MATERIALX) download_source(OIDN) download_source(LIBGLU) download_source(MESA) diff --git a/build_files/build_environment/cmake/harvest.cmake b/build_files/build_environment/cmake/harvest.cmake index fc8845405dd..8b2a3a77ca7 100644 --- a/build_files/build_environment/cmake/harvest.cmake +++ b/build_files/build_environment/cmake/harvest.cmake @@ -241,6 +241,16 @@ harvest_rpath_lib(usd/lib usd/lib "libusd_ms${SHAREDLIBEXT}") harvest(usd/lib/usd usd/lib/usd "*") harvest_rpath_python(usd/lib/python/pxr python/lib/python${PYTHON_SHORT_VERSION}/site-packages/pxr "*") harvest(usd/plugin usd/plugin "*") +harvest(materialx/include materialx/include "*.h") +harvest(materialx/lib materialx/lib "*") +harvest(materialx/libraries materialx/libraries "*") +harvest(materialx/python materialx/python "*") +harvest(materialx/lib/cmake/MaterialX materialx/lib/cmake/MaterialX "*.cmake") +harvest_rpath_python(materialx/python/MaterialX python/lib/python${PYTHON_SHORT_VERSION}/site-packages/MaterialX "*") +# We do not need anything from the resources folder, but the MaterialX config +# file will complain if the folder does not exist, so just copy the readme.md +# files to ensure the folder will exist. +harvest(materialx/resources materialx/resources "README.md") harvest(potrace/include potrace/include "*.h") harvest(potrace/lib potrace/lib "*.a") harvest(haru/include haru/include "*.h") diff --git a/build_files/build_environment/cmake/versions.cmake b/build_files/build_environment/cmake/versions.cmake index c57e9da55e0..46ff62a79df 100644 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@ -473,6 +473,12 @@ set(USD_HASH 8c89459e48a2ef0e7ae9e7e490377507) set(USD_HASH_TYPE MD5) set(USD_FILE usd-v${USD_VERSION}.tar.gz) +set(MATERIALX_VERSION 1.38.6) +set(MATERIALX_URI https://github.com/AcademySoftwareFoundation/MaterialX/archive/refs/tags/v${MATERIALX_VERSION}.tar.gz) +
[Bf-blender-cvs] [b3910374242] master: Nodes: Use topology cache for node exec node list
Commit: b3910374242d7f8d43c908a2f0b9cc370d0a8f54 Author: Hans Goudey Date: Mon Nov 21 11:30:49 2022 -0600 Branches: master https://developer.blender.org/rBb3910374242d7f8d43c908a2f0b9cc370d0a8f54 Nodes: Use topology cache for node exec node list Instead of generating a dependency sorted node list whenever evaluating texture or EEVEE/viewport shader nodes, use the existing sorted array from the topology cache. This may be more efficient because the algorithm isn't quadratic. It's also the second-to-last place to use `node.runtime->level`, which can be removed soon. Differential Revision: https://developer.blender.org/D16565 === M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/BKE_node_runtime.hh M source/blender/blenkernel/intern/node.cc M source/blender/makesdna/DNA_node_types.h M source/blender/nodes/intern/node_exec.cc M source/blender/nodes/shader/node_shader_tree.cc === diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 7efc28a3ab3..680cf4c283d 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -512,9 +512,6 @@ bool ntreeHasTree(const struct bNodeTree *ntree, const struct bNodeTree *lookup) void ntreeUpdateAllNew(struct Main *main); void ntreeUpdateAllUsers(struct Main *main, struct ID *id); -void ntreeGetDependencyList(struct bNodeTree *ntree, -struct bNode ***r_deplist, -int *r_deplist_len); void ntreeUpdateNodeLevels(struct bNodeTree *ntree); /** diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh index 831b5330a2f..48c6c7d3643 100644 --- a/source/blender/blenkernel/BKE_node_runtime.hh +++ b/source/blender/blenkernel/BKE_node_runtime.hh @@ -289,6 +289,18 @@ inline blender::Span bNodeTree::toposort_right_to_left() const return this->runtime->toposort_right_to_left; } +inline blender::Span bNodeTree::toposort_left_to_right() +{ + BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*this)); + return this->runtime->toposort_left_to_right; +} + +inline blender::Span bNodeTree::toposort_right_to_left() +{ + BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*this)); + return this->runtime->toposort_right_to_left; +} + inline blender::Span bNodeTree::all_nodes() const { BLI_assert(blender::bke::node_tree_runtime::topology_cache_is_available(*this)); diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 81ee2bdd34b..17fc4b51b95 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -4118,32 +4118,6 @@ static int node_get_deplist_recurs(bNodeTree *ntree, bNode *node, bNode ***nsort return level; } -void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***r_deplist, int *r_deplist_len) -{ - *r_deplist_len = 0; - - /* first clear data */ - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { -node->runtime->done = false; -(*r_deplist_len)++; - } - if (*r_deplist_len == 0) { -*r_deplist = nullptr; -return; - } - - bNode **nsort; - nsort = *r_deplist = (bNode **)MEM_callocN((*r_deplist_len) * sizeof(bNode *), - "sorted node array"); - - /* recursive check */ - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { -if (node->runtime->done == 0) { - node->runtime->level = node_get_deplist_recurs(ntree, node, &nsort); -} - } -} - /* only updates node->level for detecting cycles links */ void ntreeUpdateNodeLevels(bNodeTree *ntree) { diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 515740335a0..2399207464b 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -620,7 +620,9 @@ typedef struct bNodeTree { * toposort. However, if a connected component does not contain a cycle, this component is sorted * correctly. Use #has_available_link_cycle to check for cycles. */ + blender::Span toposort_left_to_right(); blender::Span toposort_left_to_right() const; + blender::Span toposort_right_to_left(); blender::Span toposort_right_to_left() const; /** True when there are any cycles in the node tree. */ bool has_available_link_cycle() const; diff --git a/source/blender/nodes/intern/node_exec.cc b/source/blender/nodes/intern/node_exec.cc index 53d6e2ea29e..3d8eafec75a 100644 --- a/source/blender/nodes/intern/node_exec.cc +++ b/source/blender/nodes/intern/node_exec.cc @@ -144,6 +144,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNodeInstanceKey parent
[Bf-blender-cvs] [be1745425ca] master: Nodes: Remove "level" building pass on update
Commit: be1745425cad0a87f6ea35aaacf78bf4404a91ac Author: Hans Goudey Date: Mon Nov 21 11:34:22 2022 -0600 Branches: master https://developer.blender.org/rBbe1745425cad0a87f6ea35aaacf78bf4404a91ac Nodes: Remove "level" building pass on update The node level was an indication of how deep the node was in the tree. It was only used for detecting link cycles. Now that the node topology cache from 25e307d725d0b9 exists, this calculation can be removed completely. The level calculation was quadratic and very slow on larger node trees. In the mouse house file with a few thousand nodes, it took 23ms on every single update. Another benefit is storing slightly less runtime data, though this was only 2 bytes per node. Differential Revision: https://developer.blender.org/D16566 === M source/blender/blenkernel/BKE_node.h M source/blender/blenkernel/BKE_node_runtime.hh M source/blender/blenkernel/intern/node.cc M source/blender/blenkernel/intern/node_tree_update.cc === diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 680cf4c283d..dd035dbf537 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -512,8 +512,6 @@ bool ntreeHasTree(const struct bNodeTree *ntree, const struct bNodeTree *lookup) void ntreeUpdateAllNew(struct Main *main); void ntreeUpdateAllUsers(struct Main *main, struct ID *id); -void ntreeUpdateNodeLevels(struct bNodeTree *ntree); - /** * XXX: old trees handle output flags automatically based on special output * node types and last active selection. diff --git a/source/blender/blenkernel/BKE_node_runtime.hh b/source/blender/blenkernel/BKE_node_runtime.hh index 48c6c7d3643..ea523da0c55 100644 --- a/source/blender/blenkernel/BKE_node_runtime.hh +++ b/source/blender/blenkernel/BKE_node_runtime.hh @@ -146,9 +146,8 @@ class bNodeRuntime : NonCopyable, NonMovable { /** #eNodeTreeChangedFlag. */ uint32_t changed_flag = 0; - /** Both for dependency and sorting. */ + /** For dependency and sorting. */ short done = 0; - short level = 0; /** Used as a boolean for execution. */ uint8_t need_exec = 0; diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 17fc4b51b95..d8451cab0f5 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -4078,62 +4078,6 @@ void BKE_node_instance_hash_remove_untagged(bNodeInstanceHash *hash, MEM_freeN(untagged); } -/* ** dependency stuff *** */ - -/* node is guaranteed to be not checked before */ -static int node_get_deplist_recurs(bNodeTree *ntree, bNode *node, bNode ***nsort) -{ - int level = 0xFFF; - - node->runtime->done = true; - - /* check linked nodes */ - LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { -if (link->tonode == node) { - bNode *fromnode = link->fromnode; - if (fromnode->runtime->done == 0) { -fromnode->runtime->level = node_get_deplist_recurs(ntree, fromnode, nsort); - } - if (fromnode->runtime->level <= level) { -level = fromnode->runtime->level - 1; - } -} - } - - /* check parent node */ - if (node->parent) { -if (node->parent->runtime->done == 0) { - node->parent->runtime->level = node_get_deplist_recurs(ntree, node->parent, nsort); -} -if (node->parent->runtime->level <= level) { - level = node->parent->runtime->level - 1; -} - } - - if (nsort) { -**nsort = node; -(*nsort)++; - } - - return level; -} - -/* only updates node->level for detecting cycles links */ -void ntreeUpdateNodeLevels(bNodeTree *ntree) -{ - /* first clear tag */ - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { -node->runtime->done = false; - } - - /* recursive check */ - LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { -if (node->runtime->done == 0) { - node->runtime->level = node_get_deplist_recurs(ntree, node, nullptr); -} - } -} - void ntreeUpdateAllNew(Main *main) { Vector new_ntrees; diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index 75ae8b8e0c1..f204e8fbddc 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -998,7 +998,6 @@ class NodeTreeMainUpdater { result.output_changed = this->check_if_output_changed(ntree); this->update_socket_link_and_use(ntree); -this->update_node_levels(ntree); this->update_link_validation(ntree); if (ntree.type == NTREE_TEXTURE) { @@ -1269,25 +1268,32 @@ class NodeTreeMainUpdater { } } - void update_node_levels(bNodeTree &ntree) - { -ntreeUpdateNodeLevels(&ntree); - } - void update_link_validation(bNodeTree &ntree) { +const Spa
[Bf-blender-cvs] [b0e38f4d043] master: Cleanup: Strict compiler warnings
Commit: b0e38f4d04331a20b88e6c058641ae2491060028 Author: Sergey Sharybin Date: Mon Nov 21 16:57:46 2022 +0100 Branches: master https://developer.blender.org/rBb0e38f4d04331a20b88e6c058641ae2491060028 Cleanup: Strict compiler warnings Remove `private:` from the PBVHFaceIter. This is not really a C++ class, and the C++ code generates a lot of warnings about unused fields. Also mark function static and run clang-format. === M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/pbvh.c === diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 757a2e0f396..1c2e4193596 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -685,11 +685,6 @@ typedef struct PBVHFaceIter { PBVHVertRef *verts; int verts_num; - /* Private. */ -#ifdef __cplusplus - private: -#endif - PBVHVertRef verts_reserved_[PBVH_FACE_ITER_VERTS_RESERVED]; const PBVHNode *node_; PBVHType pbvh_type_; diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index c2299f2a4ea..ac4c1e94c1c 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -841,7 +841,7 @@ void BKE_pbvh_build_grids(PBVH *pbvh, for (int i = 0; i < me->totpoly; i++) { max_grids = max_ii(max_grids, mpoly[i].totloop); } - + /* Ensure leaf limit is at least 4 so there's room * to split at original face boundaries. * Fixes T102209. @@ -3151,7 +3151,6 @@ void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float (*vertCos)[3], const int } } - for (int a = 0; a < pbvh->totnode; a++) { BKE_pbvh_node_mark_update(&pbvh->nodes[a]); } @@ -3548,7 +3547,7 @@ BLI_INLINE int face_iter_prim_to_face(PBVHFaceIter *fd, int prim_index) } } -void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step) +static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step) { if (do_step) { fd->i++; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cd6ecb8d432] gpencil-new-data-proposal: Merge branch 'master' into gpencil-new-data-proposal
Commit: cd6ecb8d432a4163df5eae21007491b70a212231 Author: Antonio Vazquez Date: Mon Nov 21 16:38:33 2022 +0100 Branches: gpencil-new-data-proposal https://developer.blender.org/rBcd6ecb8d432a4163df5eae21007491b70a212231 Merge branch 'master' into gpencil-new-data-proposal === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2f69266c643] master: Cleanup: use topology cache for frame timings overlay
Commit: 2f69266c643ee4aab38a2221aeefc87f081c7782 Author: Iliya Katueshenock Date: Mon Nov 21 16:10:05 2022 +0100 Branches: master https://developer.blender.org/rB2f69266c643ee4aab38a2221aeefc87f081c7782 Cleanup: use topology cache for frame timings overlay Differential Revision: https://developer.blender.org/D16571 === M source/blender/editors/space_node/node_draw.cc === diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 6dd3f07b4c2..3d553ff3b0b 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -1705,16 +1705,13 @@ static std::optional node_get_execution_time( if (node.type == NODE_GROUP_OUTPUT) { return tree_log->run_time_sum; } - if (node.type == NODE_FRAME) { + else if (node.is_frame()) { /* Could be cached in the future if this recursive code turns out to be slow. */ std::chrono::nanoseconds run_time{0}; bool found_node = false; -LISTBASE_FOREACH (bNode *, tnode, &ntree.nodes) { - if (tnode->parent != &node) { -continue; - } - if (tnode->type == NODE_FRAME) { +for (const bNode *tnode : node.direct_children_in_frame()) { + if (tnode->is_frame()) { std::optional sub_frame_run_time = node_get_execution_time( tree_draw_ctx, ntree, *tnode); if (sub_frame_run_time.has_value()) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5d083969706] master: Merge branch 'blender-v3.4-release'
Commit: 5d083969706ac3fa1725da01943df5044f54a991 Author: Jeroen Bakker Date: Mon Nov 21 15:53:42 2022 +0100 Branches: master https://developer.blender.org/rB5d083969706ac3fa1725da01943df5044f54a991 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8fe423a7a97] blender-v3.4-release: DRW: Fix pointcloud selection
Commit: 8fe423a7a97dc978759e03da1c5fb04f6853f806 Author: Jarrett Johnson Date: Mon Nov 21 15:49:33 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB8fe423a7a97dc978759e03da1c5fb04f6853f806 DRW: Fix pointcloud selection Fixes point cloud selection by using new draw call. Reviewed By: fclem Maniphest Tasks: T102659 Differential Revision: https://developer.blender.org/D16501 === M source/blender/draw/engines/basic/basic_engine.c === diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 05e62764bb1..44857cd87e1 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -164,6 +164,11 @@ static void basic_cache_populate(void *vedata, Object *ob) DRW_shgroup_curves_create_sub(ob, stl->g_data->depth_curves_shgrp[do_in_front], NULL); } + if (ob->type == OB_POINTCLOUD) { +DRW_shgroup_pointcloud_create_sub(ob, stl->g_data->depth_pointcloud_shgrp[do_in_front], NULL); +return; + } + /* Make flat object selectable in ortho view if wireframe is enabled. */ if ((draw_ctx->v3d->overlay.flag & V3D_OVERLAY_WIREFRAMES) || (draw_ctx->v3d->shading.type == OB_WIRE) || (ob->dtx & OB_DRAWWIRE) || (ob->dt == OB_WIRE)) { @@ -187,15 +192,8 @@ static void basic_cache_populate(void *vedata, Object *ob) const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); - DRWShadingGroup *shgrp = NULL; - - if (ob->type == OB_POINTCLOUD) { -shgrp = stl->g_data->depth_pointcloud_shgrp[do_in_front]; - } - else { -shgrp = (do_cull) ? stl->g_data->depth_shgrp_cull[do_in_front] : -stl->g_data->depth_shgrp[do_in_front]; - } + DRWShadingGroup *shgrp = (do_cull) ? stl->g_data->depth_shgrp_cull[do_in_front] : + stl->g_data->depth_shgrp[do_in_front]; if (use_sculpt_pbvh) { DRW_shgroup_call_sculpt(shgrp, ob, false, false, false, false, false); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [1c0f5e79fa1] master: DRW: Fix pointcloud selection
Commit: 1c0f5e79fa105747c0e71b33a00bba2c79b0cc74 Author: Jarrett Johnson Date: Mon Nov 21 15:49:33 2022 +0100 Branches: master https://developer.blender.org/rB1c0f5e79fa105747c0e71b33a00bba2c79b0cc74 DRW: Fix pointcloud selection Fixes point cloud selection by using new draw call. Reviewed By: fclem Maniphest Tasks: T102659 Differential Revision: https://developer.blender.org/D16501 === M source/blender/draw/engines/basic/basic_engine.c === diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 05e62764bb1..44857cd87e1 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -164,6 +164,11 @@ static void basic_cache_populate(void *vedata, Object *ob) DRW_shgroup_curves_create_sub(ob, stl->g_data->depth_curves_shgrp[do_in_front], NULL); } + if (ob->type == OB_POINTCLOUD) { +DRW_shgroup_pointcloud_create_sub(ob, stl->g_data->depth_pointcloud_shgrp[do_in_front], NULL); +return; + } + /* Make flat object selectable in ortho view if wireframe is enabled. */ if ((draw_ctx->v3d->overlay.flag & V3D_OVERLAY_WIREFRAMES) || (draw_ctx->v3d->shading.type == OB_WIRE) || (ob->dtx & OB_DRAWWIRE) || (ob->dt == OB_WIRE)) { @@ -187,15 +192,8 @@ static void basic_cache_populate(void *vedata, Object *ob) const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); - DRWShadingGroup *shgrp = NULL; - - if (ob->type == OB_POINTCLOUD) { -shgrp = stl->g_data->depth_pointcloud_shgrp[do_in_front]; - } - else { -shgrp = (do_cull) ? stl->g_data->depth_shgrp_cull[do_in_front] : -stl->g_data->depth_shgrp[do_in_front]; - } + DRWShadingGroup *shgrp = (do_cull) ? stl->g_data->depth_shgrp_cull[do_in_front] : + stl->g_data->depth_shgrp[do_in_front]; if (use_sculpt_pbvh) { DRW_shgroup_call_sculpt(shgrp, ob, false, false, false, false, false); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [44ad59592b6] temp-vulkan-shader: Vulkan: compile shader to spirv.
Commit: 44ad59592b6824d83074f3cb2008c3bd86689575 Author: Jeroen Bakker Date: Mon Nov 21 14:01:47 2022 +0100 Branches: temp-vulkan-shader https://developer.blender.org/rB44ad59592b6824d83074f3cb2008c3bd86689575 Vulkan: compile shader to spirv. === M build_files/cmake/platform/platform_apple.cmake M source/blender/gpu/vulkan/vk_backend.cc M source/blender/gpu/vulkan/vk_backend.hh M source/blender/gpu/vulkan/vk_shader.cc M source/blender/gpu/vulkan/vk_shader.hh === diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake index 403d131cbfa..3f1b87ec0b0 100644 --- a/build_files/cmake/platform/platform_apple.cmake +++ b/build_files/cmake/platform/platform_apple.cmake @@ -107,7 +107,7 @@ if(WITH_VULKAN_BACKEND) set(VULKAN_INCLUDE_DIR ${VULKAN_ROOT_DIR}/include) set(VULKAN_INCLUDE_DIRS ${VULKAN_INCLUDE_DIR}) set(VULKAN_LIBRARY ${VULKAN_ROOT_DIR}/lib/libvulkan.1.dylib) -set(SHADERC_LIBRARY ${VULKAN_ROOT_DIR}/lib/libshaderc.a) +set(SHADERC_LIBRARY ${VULKAN_ROOT_DIR}/lib/libshaderc_combined.a) set(VULKAN_LIBRARIES ${VULKAN_LIBRARY} ${SHADERC_LIBRARY}) else() message(WARNING "Vulkan was not found, disabling WITH_VULKAN_BACKEND") diff --git a/source/blender/gpu/vulkan/vk_backend.cc b/source/blender/gpu/vulkan/vk_backend.cc index d22275cebef..c6241e03652 100644 --- a/source/blender/gpu/vulkan/vk_backend.cc +++ b/source/blender/gpu/vulkan/vk_backend.cc @@ -132,4 +132,9 @@ void VKBackend::render_step() { } +shaderc::Compiler &VKBackend::get_shaderc_compiler() +{ + return shaderc_compiler_; +} + } // namespace blender::gpu \ No newline at end of file diff --git a/source/blender/gpu/vulkan/vk_backend.hh b/source/blender/gpu/vulkan/vk_backend.hh index b52f17ae40c..d4ceb3dcd9d 100644 --- a/source/blender/gpu/vulkan/vk_backend.hh +++ b/source/blender/gpu/vulkan/vk_backend.hh @@ -9,10 +9,19 @@ #include "gpu_backend.hh" +#ifdef __APPLE__ +# include +#else +# include +#endif +#include "shaderc/shaderc.hpp" namespace blender::gpu { class VKBackend : public GPUBackend { + private: + shaderc::Compiler shaderc_compiler_; + public: VKBackend() { @@ -49,6 +58,8 @@ class VKBackend : public GPUBackend { void render_end() override; void render_step() override; + shaderc::Compiler &get_shaderc_compiler(); + private: static void init_platform(); static void platform_exit(); diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc index 6ebca5d5904..37d26767c7a 100644 --- a/source/blender/gpu/vulkan/vk_shader.cc +++ b/source/blender/gpu/vulkan/vk_shader.cc @@ -7,14 +7,45 @@ #include "vk_shader.hh" -#ifdef __APPLE__ -# include -#else -# include -#endif -#include "shaderc/shaderc.hpp" +#include "vk_backend.hh" + +#include "BLI_string_utils.h" +#include "BLI_vector.hh" namespace blender::gpu { + +static std::string combine_sources(MutableSpan sources) +{ + char *sources_combined = BLI_string_join_arrayN((const char **)sources.data(), sources.size()); + return std::string(sources_combined); +} + +Vector VKShader::compile_glsl_to_spirv(StringRef source, shaderc_shader_kind kind) +{ + VKBackend &backend = static_cast(*VKBackend::get()); + shaderc::Compiler &compiler = backend.get_shaderc_compiler(); + shaderc::CompileOptions options; + + shaderc::SpvCompilationResult module = compiler.CompileGlslToSpv(source, kind, name, options); + + if (module.GetCompilationStatus() != shaderc_compilation_status_success) { +// TODO(jbakker): error handling. + } + + return Vector(module.cbegin(), module.cend()); +} + +void VKShader::build_shader_module(Span spirv_module, VkShaderModule *r_shader_module) +{ + VkShaderModuleCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; + createInfo.codeSize = spirv_module.size() * sizeof(uint32_t); + createInfo.pCode = spirv_module.data(); + + // TODO(jbakker): retrieve allocator and device + // VkResult result = vkCreateShaderModule(*device, &create_info, nullptr, r_shader_module); +} + void VKShader::vertex_shader_from_glsl(MutableSpan /*sources*/) { } @@ -27,8 +58,12 @@ void VKShader::fragment_shader_from_glsl(MutableSpan /*sources*/) { } -void VKShader::compute_shader_from_glsl(MutableSpan /*sources*/) +void VKShader::compute_shader_from_glsl(MutableSpan sources) { + std::string source = combine_sources(sources); + + Vector spirv_module = compile_glsl_to_spirv(StringRef(source), shaderc_compute_shader); + build_shader_module(spirv_module, &compute_module_); } bool VKShader::finalize(const shader::ShaderCreateInfo * /*info*/) diff --git a/source/blender/gpu/vulkan/vk_shader.hh b/source/blender/gpu/vulkan/vk_shader.hh index 9ab0aca67eb..e6cdf246f3e 100644 --- a/source/blender/gpu/vulkan/vk_shad
[Bf-blender-cvs] [2910be8f19c] master: Cleanup: Correct semantics for .blend listing in file/asset browser
Commit: 2910be8f19cf87dd57bdc3a81ce5b26fed2a8beb Author: Julian Eisel Date: Mon Nov 21 12:16:30 2022 +0100 Branches: master https://developer.blender.org/rB2910be8f19cf87dd57bdc3a81ce5b26fed2a8beb Cleanup: Correct semantics for .blend listing in file/asset browser When attempting to load contents of a .blend, the code would just assume if the number of added items is 0, that means it's not a .blend (but a directory, although the previous commit fixed that part already). However there may be situations where a .blend file simply doesn't contain anything of interest to be added (e.g. when listing assets only), so have a proper "none" value for this. === M source/blender/editors/space_file/filelist.cc === diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 46211a72a82..dc59bb1286d 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #ifndef WIN32 @@ -3116,11 +3117,15 @@ static int filelist_readjob_list_lib_populate_from_index(FileList *filelist, return read_from_index + navigate_to_parent_len; } -static int filelist_readjob_list_lib(FileList *filelist, - const char *root, - ListBase *entries, - const ListLibOptions options, - FileIndexer *indexer_runtime) +/** + * \return The number of entries found if the \a root path points to a valid library file. + * Otherwise returns no value (#std::nullopt). + */ +static std::optional filelist_readjob_list_lib(FileList *filelist, +const char *root, +ListBase *entries, +const ListLibOptions options, +FileIndexer *indexer_runtime) { BLI_assert(indexer_runtime); @@ -3135,7 +3140,7 @@ static int filelist_readjob_list_lib(FileList *filelist, * call it directly from `filelist_readjob_do` to increase readability. */ const bool is_lib = BLO_library_path_explode(root, dir, &group, nullptr); if (!is_lib) { -return 0; +return std::nullopt; } const bool group_came_from_path = group != nullptr; @@ -3166,7 +3171,7 @@ static int filelist_readjob_list_lib(FileList *filelist, BlendFileReadReport bf_reports{}; libfiledata = BLO_blendhandle_from_file(dir, &bf_reports); if (libfiledata == nullptr) { -return 0; +return std::nullopt; } /* Add current parent when requested. */ @@ -3557,10 +3562,11 @@ static void filelist_readjob_recursive_dir_add_items(const bool do_lib, if (filelist->asset_library_ref) { list_lib_options |= LIST_LIB_ASSETS_ONLY; } - entries_num = filelist_readjob_list_lib( + std::optional lib_entries_num = filelist_readjob_list_lib( filelist, subdir, &entries, list_lib_options, &indexer_runtime); - if (entries_num > 0) { + if (lib_entries_num) { is_lib = true; +entries_num += *lib_entries_num; } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c58e7da43e0] master: Asset Browser: Avoid non-existent directory prints
Commit: c58e7da43e03d6b24408305654b63c37007e7227 Author: Julian Eisel Date: Mon Nov 21 12:11:52 2022 +0100 Branches: master https://developer.blender.org/rBc58e7da43e03d6b24408305654b63c37007e7227 Asset Browser: Avoid non-existent directory prints When loading asset libraries, there would be a bunch of "non-existent directory" prints because we were calling a function to list directory contents on .blend file paths. Make sure the path actually points to a directory. === M source/blender/editors/space_file/filelist.cc === diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 22c94065234..46211a72a82 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -3564,7 +3564,7 @@ static void filelist_readjob_recursive_dir_add_items(const bool do_lib, } } -if (!is_lib) { +if (!is_lib && BLI_is_dir(subdir)) { entries_num = filelist_readjob_list_dir( subdir, &entries, filter_glob, do_lib, job_params->main_name, skip_currpar); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9f83ef2149e] master: BLI: make different pointer types compatible in hash tables
Commit: 9f83ef2149e085f847ac5bde353ba9682036cede Author: Jacques Lucke Date: Mon Nov 21 12:02:10 2022 +0100 Branches: master https://developer.blender.org/rB9f83ef2149e085f847ac5bde353ba9682036cede BLI: make different pointer types compatible in hash tables For example, this allows doing a lookup using a raw pointer in a hash table that uses `std::unique_ptr` as key. === M source/blender/blenlib/BLI_hash.hh M source/blender/blenlib/BLI_hash_tables.hh M source/blender/blenlib/BLI_map.hh M source/blender/blenlib/BLI_set.hh M source/blender/blenlib/BLI_vector_set.hh M source/blender/blenlib/tests/BLI_set_test.cc === diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh index 693d4a8a71c..c29dc74599a 100644 --- a/source/blender/blenlib/BLI_hash.hh +++ b/source/blender/blenlib/BLI_hash.hh @@ -246,18 +246,17 @@ uint64_t get_default_hash_4(const T1 &v1, const T2 &v2, const T3 &v3, const T4 & return h1 ^ (h2 * 19349669) ^ (h3 * 83492791) ^ (h4 * 3632623); } -template struct DefaultHash> { - uint64_t operator()(const std::unique_ptr &value) const +/** Support hashing different kinds of pointer types. */ +template struct PointerHashes { + template uint64_t operator()(const U &value) const { -return get_default_hash(value.get()); +return get_default_hash(&*value); } }; -template struct DefaultHash> { - uint64_t operator()(const std::shared_ptr &value) const - { -return get_default_hash(value.get()); - } +template struct DefaultHash> : public PointerHashes { +}; +template struct DefaultHash> : public PointerHashes { }; template struct DefaultHash> { diff --git a/source/blender/blenlib/BLI_hash_tables.hh b/source/blender/blenlib/BLI_hash_tables.hh index de65c58d4db..fff2411f94c 100644 --- a/source/blender/blenlib/BLI_hash_tables.hh +++ b/source/blender/blenlib/BLI_hash_tables.hh @@ -331,11 +331,26 @@ class HashTableStats { * requires the parameters to be of type T. Our hash tables support lookups using other types * without conversion, therefore DefaultEquality needs to be more generic. */ -struct DefaultEquality { +template struct DefaultEquality { template bool operator()(const T1 &a, const T2 &b) const { return a == b; } }; +/** + * Support comparing different kinds of raw and smart pointers. + */ +struct PointerComparison { + template bool operator()(const T1 &a, const T2 &b) const + { +return &*a == &*b; + } +}; + +template struct DefaultEquality> : public PointerComparison { +}; +template struct DefaultEquality> : public PointerComparison { +}; + } // namespace blender diff --git a/source/blender/blenlib/BLI_map.hh b/source/blender/blenlib/BLI_map.hh index 6d281420c47..fb048102153 100644 --- a/source/blender/blenlib/BLI_map.hh +++ b/source/blender/blenlib/BLI_map.hh @@ -92,7 +92,7 @@ template< * The equality operator used to compare keys. By default it will simply compare keys using the * `==` operator. */ -typename IsEqual = DefaultEquality, +typename IsEqual = DefaultEquality, /** * This is what will actually be stored in the hash table array. At a minimum a slot has to be * able to hold a key, a value and information about whether the slot is empty, occupied or @@ -1263,7 +1263,7 @@ template, - typename IsEqual = DefaultEquality, + typename IsEqual = DefaultEquality, typename Slot = typename DefaultMapSlot::type> using RawMap = Map; diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh index 8fb618edeb6..548195e48f7 100644 --- a/source/blender/blenlib/BLI_set.hh +++ b/source/blender/blenlib/BLI_set.hh @@ -89,7 +89,7 @@ template< * The equality operator used to compare keys. By default it will simply compare keys using the * `==` operator. */ -typename IsEqual = DefaultEquality, +typename IsEqual = DefaultEquality, /** * This is what will actually be stored in the hash table array. At a minimum a slot has to * be able to hold a key and information about whether the slot is empty, occupied or removed. @@ -949,7 +949,7 @@ template, - typename IsEqual = DefaultEquality, + typename IsEqual = DefaultEquality, typename Slot = typename DefaultSetSlot::type> using RawSet = Set; diff --git a/source/blender/blenlib/BLI_vector_set.hh b/source/blender/blenlib/BLI_vector_set.hh index d182e1f1678..9805e8a7d59 100644 --- a/source/blender/blenlib/BLI_vector_set.hh +++ b/source/blender/blenlib/BLI_vector_set.hh @@ -72,7 +72,7 @@ template< * The equality operator used to compare keys. By default it will simply compare keys using the * `==` operator. */ -typename IsEqual = DefaultEquality, +typename IsEqual = DefaultEquality, /** * Thi
[Bf-blender-cvs] [9a89fca8b13] soc-2022-many-lights-sampling: Refactor: reduce the size of `LightTreePrimitive`
Commit: 9a89fca8b13f02925693d92f874b6f874ba9a21b Author: Weizhen Huang Date: Mon Nov 21 11:45:58 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB9a89fca8b13f02925693d92f874b6f874ba9a21b Refactor: reduce the size of `LightTreePrimitive` === M intern/cycles/scene/light_tree.cpp M intern/cycles/scene/light_tree.h === diff --git a/intern/cycles/scene/light_tree.cpp b/intern/cycles/scene/light_tree.cpp index 2973f21ba9a..fca8345150f 100644 --- a/intern/cycles/scene/light_tree.cpp +++ b/intern/cycles/scene/light_tree.cpp @@ -62,95 +62,37 @@ OrientationBounds merge(const OrientationBounds &cone_a, const OrientationBounds LightTreePrimitive::LightTreePrimitive(Scene *scene, int prim_id, int object_id) : prim_id(prim_id), object_id(object_id) { - if (is_triangle()) { -calculate_triangle_vertices(scene); - } - calculate_centroid(scene); - calculate_bbox(scene); - calculate_bcone(scene); - calculate_energy(scene); -} - -void LightTreePrimitive::calculate_triangle_vertices(Scene *scene) -{ - assert(is_triangle()); - Object *object = scene->objects[object_id]; - Mesh *mesh = static_cast(object->get_geometry()); - Mesh::Triangle triangle = mesh->get_triangle(prim_id); - - for (int i = 0; i < 3; i++) { -vertices[i] = mesh->get_verts()[triangle.v[i]]; - } - - /* instanced mesh lights have not applied their transform at this point. - * in this case, these points have to be transformed to get the proper - * spatial bound. */ - if (!mesh->transform_applied) { -const Transform &tfm = object->get_tfm(); -for (int i = 0; i < 3; i++) { - vertices[i] = transform_point(&tfm, vertices[i]); -} - } -} - -void LightTreePrimitive::calculate_centroid(Scene *scene) -{ - if (is_triangle()) { -/* NOTE: the original implementation used the bounding box centroid, but primitive centroid - * seems to work fine */ -centroid = (vertices[0] + vertices[1] + vertices[2]) / 3.0f; - } - else { -centroid = scene->lights[object_id]->get_co(); - } -} - -void LightTreePrimitive::calculate_bbox(Scene *scene) -{ + bcone = OrientationBounds::empty; bbox = BoundBox::empty; if (is_triangle()) { -for (int i = 0; i < 3; i++) { - bbox.grow(vertices[i]); -} - } - else { -Light *lamp = scene->lights[object_id]; -LightType type = lamp->get_light_type(); -const float size = lamp->get_size(); +float3 vertices[3]; +Object *object = scene->objects[object_id]; +Mesh *mesh = static_cast(object->get_geometry()); +Mesh::Triangle triangle = mesh->get_triangle(prim_id); +Shader *shader = static_cast(mesh->get_used_shaders()[mesh->get_shader()[prim_id]]); -if (type == LIGHT_POINT || type == LIGHT_SPOT) { - /* Point and spot lights can emit light from any point within its radius. */ - const float3 radius = make_float3(size); - bbox.grow(centroid - radius); - bbox.grow(centroid + radius); +for (int i = 0; i < 3; i++) { + vertices[i] = mesh->get_verts()[triangle.v[i]]; } -else if (type == LIGHT_AREA) { - /* For an area light, sizeu and sizev determine the 2 dimensions of the area light, - * while axisu and axisv determine the orientation of the 2 dimensions. - * We want to add all 4 corners to our bounding box. */ - const float3 half_extentu = 0.5 * lamp->get_sizeu() * lamp->get_axisu() * size; - const float3 half_extentv = 0.5 * lamp->get_sizev() * lamp->get_axisv() * size; - bbox.grow(centroid + half_extentu + half_extentv); - bbox.grow(centroid + half_extentu - half_extentv); - bbox.grow(centroid - half_extentu + half_extentv); - bbox.grow(centroid - half_extentu - half_extentv); -} -else { - /* No bounding box for distant lights */ +/* instanced mesh lights have not applied their transform at this point. + * in this case, these points have to be transformed to get the proper + * spatial bound. */ +if (!mesh->transform_applied) { + const Transform &tfm = object->get_tfm(); + for (int i = 0; i < 3; i++) { +vertices[i] = transform_point(&tfm, vertices[i]); + } } - } -} -void LightTreePrimitive::calculate_bcone(Scene *scene) -{ - bcone = OrientationBounds::empty; +/* TODO: need a better way to handle this when textures are used. */ +float area = triangle_area(vertices[0], vertices[1], vertices[2]); +energy = area * scene->shader_manager->linear_rgb_to_gray(shader->emission_estimate); - if (is_triangle()) { -Object *object = scene->objects[object_id]; -Mesh *mesh = static_cast(object->get_geometry()); -Shader *shader = static_cast(mesh->get_used_shaders()[mesh->get_shader()[prim_id]]); +/* NOTE: the original implementation used the bounding box centroid, but primitive centroid + *
[Bf-blender-cvs] [85990c877cb] master: Merge branch 'blender-v3.4-release'
Commit: 85990c877cb6529660de19d8eb831803e2e22aa1 Author: Leon Schittek Date: Mon Nov 21 11:45:12 2022 +0100 Branches: master https://developer.blender.org/rB85990c877cb6529660de19d8eb831803e2e22aa1 Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b75946bcb6a] blender-v3.4-release: Fix T102620: Display dynamic socket label in uiTemplateNodeView
Commit: b75946bcb6ab14cd37f6be5dbbf0b14d74d297e8 Author: Leon Schittek Date: Mon Nov 21 11:39:58 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rBb75946bcb6ab14cd37f6be5dbbf0b14d74d297e8 Fix T102620: Display dynamic socket label in uiTemplateNodeView Some nodes, like Combine Color or the math nodes, label sockets differently depending on the mode to be more descriptive. `uiTemplateNodeView` now also uses this dynamic label rather than the socket's name for labeling in the UI so the shown labels always match the ones on the node itself. Reviewed By: Hans Goudey Differential Revision: http://developer.blender.org/D16563 === M source/blender/editors/space_node/node_templates.cc === diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index 1b7eadd336a..0027a965267 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -830,7 +830,7 @@ static void ui_node_draw_input( sub = uiLayoutRow(sub, true); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); -uiItemL(sub, IFACE_(input.name), ICON_NONE); +uiItemL(sub, IFACE_(nodeSocketLabel(&input)), ICON_NONE); } if (dependency_loop) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [71efb7805ba] master: Merge branch 'blender-v3.4-release'
Commit: 71efb7805ba0cebc1c266b541d1c63db2f089add Author: Jacques Lucke Date: Mon Nov 21 11:23:18 2022 +0100 Branches: master https://developer.blender.org/rB71efb7805ba0cebc1c266b541d1c63db2f089add Merge branch 'blender-v3.4-release' === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3648fd9917d] blender-v3.4-release: Fix: node frame boundaries incorrect when opening files
Commit: 3648fd9917dbd03ff5747ca1b65ede6629d86338 Author: Jacques Lucke Date: Mon Nov 21 11:22:44 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB3648fd9917dbd03ff5747ca1b65ede6629d86338 Fix: node frame boundaries incorrect when opening files Make sure that frame dimensions are updated in the correct order. === M source/blender/editors/space_node/node_draw.cc === diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 151f04e0a2d..7b2d7e61543 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -2712,7 +2712,6 @@ static void node_update_nodetree(const bContext &C, count_multi_input_socket_links(ntree, *snode); - /* Update nodes front to back, so children sizes get updated before parents. */ for (const int i : nodes.index_range()) { bNode &node = *nodes[i]; uiBlock &block = *blocks[i]; @@ -2734,8 +2733,9 @@ static void node_update_nodetree(const bContext &C, } } - /* Now calculate the size of frame nodes, which can depend on the size of other nodes. */ - for (const int i : nodes.index_range()) { + /* Now calculate the size of frame nodes, which can depend on the size of other nodes. + * Update nodes in reverse, so children sizes get updated before parents. */ + for (int i = nodes.size() - 1; i >= 0; i--) { if (nodes[i]->type == NODE_FRAME) { frame_node_prepare_for_draw(*nodes[i], nodes); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [092ac7e83b9] soc-2022-many-lights-sampling: Merge branch 'master' into soc-2022-many-lights-sampling
Commit: 092ac7e83b99b8660f230b58e04be1b53287790f Author: Weizhen Huang Date: Mon Nov 21 10:46:36 2022 +0100 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB092ac7e83b99b8660f230b58e04be1b53287790f Merge branch 'master' into soc-2022-many-lights-sampling === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs