From 806521f7037a5a50bba9d332ab5de3b0172c5a22 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 Oct 2021 13:18:28 +0100 Subject: Fix T92671: confusing Cycles debug logs about CPU architecture Instead of printing debug flags listing various CPU and GPU settings that may or may not be used, print when we are using them. This include CPU kernel types, OptiX debugging and CUDA and HIP adaptive compilation. BVH type was already printed. --- intern/cycles/blender/python.cpp | 5 ----- intern/cycles/device/cpu/device_impl.cpp | 3 +-- intern/cycles/device/cuda/device_impl.cpp | 10 +++++++--- intern/cycles/device/hip/device_impl.cpp | 12 ++++++++---- intern/cycles/device/optix/device_impl.cpp | 1 + intern/cycles/integrator/path_trace_work_gpu.cpp | 4 ++-- intern/cycles/util/debug.cpp | 22 ---------------------- intern/cycles/util/debug.h | 2 -- 8 files changed, 19 insertions(+), 40 deletions(-) diff --git a/intern/cycles/blender/python.cpp b/intern/cycles/blender/python.cpp index 20bf6385999..bb9b0a74424 100644 --- a/intern/cycles/blender/python.cpp +++ b/intern/cycles/blender/python.cpp @@ -157,8 +157,6 @@ static PyObject *init_func(PyObject * /*self*/, PyObject *args) DebugFlags().running_inside_blender = true; - VLOG(2) << "Debug flags initialized to:\n" << DebugFlags(); - Py_RETURN_NONE; } @@ -885,8 +883,6 @@ static PyObject *debug_flags_update_func(PyObject * /*self*/, PyObject *args) debug_flags_sync_from_scene(b_scene); - VLOG(2) << "Debug flags set to:\n" << DebugFlags(); - debug_flags_set = true; Py_RETURN_NONE; @@ -896,7 +892,6 @@ static PyObject *debug_flags_reset_func(PyObject * /*self*/, PyObject * /*args*/ { debug_flags_reset(); if (debug_flags_set) { - VLOG(2) << "Debug flags reset to:\n" << DebugFlags(); debug_flags_set = false; } Py_RETURN_NONE; diff --git a/intern/cycles/device/cpu/device_impl.cpp b/intern/cycles/device/cpu/device_impl.cpp index dbad332f896..d494b40f71d 100644 --- a/intern/cycles/device/cpu/device_impl.cpp +++ b/intern/cycles/device/cpu/device_impl.cpp @@ -68,8 +68,7 @@ CPUDevice::CPUDevice(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_ { /* Pick any kernel, all of them are supposed to have same level of microarchitecture * optimization. */ - VLOG(1) << "Will be using " << kernels.integrator_init_from_camera.get_uarch_name() - << " kernels."; + VLOG(1) << "Using " << kernels.integrator_init_from_camera.get_uarch_name() << " CPU kernels."; if (info.cpu_threads == 0) { info.cpu_threads = TaskScheduler::num_threads(); diff --git a/intern/cycles/device/cuda/device_impl.cpp b/intern/cycles/device/cuda/device_impl.cpp index 2f9a1394ad8..2bb0592bcc5 100644 --- a/intern/cycles/device/cuda/device_impl.cpp +++ b/intern/cycles/device/cuda/device_impl.cpp @@ -378,7 +378,9 @@ string CUDADevice::compile_kernel(const uint kernel_features, cubin.c_str(), common_cflags.c_str()); - printf("Compiling CUDA kernel ...\n%s\n", command.c_str()); + printf("Compiling %sCUDA kernel ...\n%s\n", + (use_adaptive_compilation()) ? "adaptive " : "", + command.c_str()); # ifdef _WIN32 command = "call " + command; @@ -405,13 +407,15 @@ string CUDADevice::compile_kernel(const uint kernel_features, bool CUDADevice::load_kernels(const uint kernel_features) { - /* TODO(sergey): Support kernels re-load for CUDA devices. + /* TODO(sergey): Support kernels re-load for CUDA devices adaptive compile. * * Currently re-loading kernel will invalidate memory pointers, * causing problems in cuCtxSynchronize. */ if (cuModule) { - VLOG(1) << "Skipping kernel reload, not currently supported."; + if (use_adaptive_compilation()) { + VLOG(1) << "Skipping CUDA kernel reload for adaptive compilation, not currently supported."; + } return true; } diff --git a/intern/cycles/device/hip/device_impl.cpp b/intern/cycles/device/hip/device_impl.cpp index 31b7b07383b..1ea387513d5 100644 --- a/intern/cycles/device/hip/device_impl.cpp +++ b/intern/cycles/device/hip/device_impl.cpp @@ -360,7 +360,9 @@ string HIPDevice::compile_kernel(const uint kernel_features, source_path.c_str(), fatbin.c_str()); - printf("Compiling HIP kernel ...\n%s\n", command.c_str()); + printf("Compiling %sHIP kernel ...\n%s\n", + (use_adaptive_compilation()) ? "adaptive " : "", + command.c_str()); # ifdef _WIN32 command = "call " + command; @@ -387,13 +389,15 @@ string HIPDevice::compile_kernel(const uint kernel_features, bool HIPDevice::load_kernels(const uint kernel_features) { - /* TODO(sergey): Support kernels re-load for HIP devices. + /* TODO(sergey): Support kernels re-load for CUDA devices adaptive compile. * * Currently re-loading kernel will invalidate memory pointers, - * causing problems in hipCtxSynchronize. + * causing problems in cuCtxSynchronize. */ if (hipModule) { - VLOG(1) << "Skipping kernel reload, not currently supported."; + if (use_adaptive_compilation()) { + VLOG(1) << "Skipping HIP kernel reload for adaptive compilation, not currently supported."; + } return true; } diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp index e9164cc0a76..9b9a5ac0de7 100644 --- a/intern/cycles/device/optix/device_impl.cpp +++ b/intern/cycles/device/optix/device_impl.cpp @@ -91,6 +91,7 @@ OptiXDevice::OptiXDevice(const DeviceInfo &info, Stats &stats, Profiler &profile }; # endif if (DebugFlags().optix.use_debug) { + VLOG(1) << "Using OptiX debug mode."; options.validationMode = OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_ALL; } optix_assert(optixDeviceContextCreate(cuContext, &options, &context)); diff --git a/intern/cycles/integrator/path_trace_work_gpu.cpp b/intern/cycles/integrator/path_trace_work_gpu.cpp index 251bec0dc8f..dfc1362ab09 100644 --- a/intern/cycles/integrator/path_trace_work_gpu.cpp +++ b/intern/cycles/integrator/path_trace_work_gpu.cpp @@ -807,10 +807,10 @@ bool PathTraceWorkGPU::should_use_graphics_interop() interop_use_ = device->should_use_graphics_interop(); if (interop_use_) { - VLOG(2) << "Will be using graphics interop GPU display update."; + VLOG(2) << "Using graphics interop GPU display update."; } else { - VLOG(2) << "Will be using naive GPU display update."; + VLOG(2) << "Using naive GPU display update."; } interop_use_checked_ = true; diff --git a/intern/cycles/util/debug.cpp b/intern/cycles/util/debug.cpp index b49df3d42bc..7d5b6d4e54e 100644 --- a/intern/cycles/util/debug.cpp +++ b/intern/cycles/util/debug.cpp @@ -99,26 +99,4 @@ void DebugFlags::reset() optix.reset(); } -std::ostream &operator<<(std::ostream &os, DebugFlagsConstRef debug_flags) -{ - os << "CPU flags:\n" - << " AVX2 : " << string_from_bool(debug_flags.cpu.avx2) << "\n" - << " AVX : " << string_from_bool(debug_flags.cpu.avx) << "\n" - << " SSE4.1 : " << string_from_bool(debug_flags.cpu.sse41) << "\n" - << " SSE3 : " << string_from_bool(debug_flags.cpu.sse3) << "\n" - << " SSE2 : " << string_from_bool(debug_flags.cpu.sse2) << "\n" - << " BVH layout : " << bvh_layout_name(debug_flags.cpu.bvh_layout) << "\n"; - - os << "CUDA flags:\n" - << " Adaptive Compile : " << string_from_bool(debug_flags.cuda.adaptive_compile) << "\n"; - - os << "OptiX flags:\n" - << " Debug : " << string_from_bool(debug_flags.optix.use_debug) << "\n"; - - os << "HIP flags:\n" - << " HIP streams : " << string_from_bool(debug_flags.hip.adaptive_compile) << "\n"; - - return os; -} - CCL_NAMESPACE_END diff --git a/intern/cycles/util/debug.h b/intern/cycles/util/debug.h index 58b2b047261..548c67600e5 100644 --- a/intern/cycles/util/debug.h +++ b/intern/cycles/util/debug.h @@ -160,8 +160,6 @@ inline DebugFlags &DebugFlags() return DebugFlags::get(); } -std::ostream &operator<<(std::ostream &os, DebugFlagsConstRef debug_flags); - CCL_NAMESPACE_END #endif /* __UTIL_DEBUG_H__ */ -- cgit v1.2.3 From 6bc54cddfbf78fd880d5183e8949f19236ad0aaa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 Oct 2021 13:30:56 +0100 Subject: Fix Cycles logging some excessive detail with default --debug-cycles --- intern/cycles/blender/camera.cpp | 2 +- intern/cycles/blender/curves.cpp | 25 ++----------------------- intern/cycles/blender/sync.cpp | 4 +++- intern/cycles/scene/constant_fold.cpp | 8 ++++---- intern/cycles/scene/shader_nodes.cpp | 12 ++++++------ intern/cycles/scene/svm.cpp | 2 +- 6 files changed, 17 insertions(+), 36 deletions(-) diff --git a/intern/cycles/blender/camera.cpp b/intern/cycles/blender/camera.cpp index f87ebe39d21..b5afcfa7fda 100644 --- a/intern/cycles/blender/camera.cpp +++ b/intern/cycles/blender/camera.cpp @@ -639,7 +639,7 @@ void BlenderSync::sync_camera_motion( /* TODO(sergey): De-duplicate calculation with camera sync. */ float fov = 2.0f * atanf((0.5f * sensor_size) / bcam.lens / aspectratio); if (fov != cam->get_fov()) { - VLOG(1) << "Camera " << b_ob.name() << " FOV change detected."; + VLOG(3) << "Camera " << b_ob.name() << " FOV change detected."; if (motion_time == 0.0f) { cam->set_fov(fov); } diff --git a/intern/cycles/blender/curves.cpp b/intern/cycles/blender/curves.cpp index fb2b329e61d..ffe0c553738 100644 --- a/intern/cycles/blender/curves.cpp +++ b/intern/cycles/blender/curves.cpp @@ -304,10 +304,6 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa } } - if (num_curves > 0) { - VLOG(1) << "Exporting curve segments for mesh " << hair->name; - } - hair->reserve_curves(hair->num_curves() + num_curves, hair->get_curve_keys().size() + num_keys); num_keys = 0; @@ -356,7 +352,7 @@ static void ExportCurveSegments(Scene *scene, Hair *hair, ParticleCurveData *CDa /* check allocation */ if ((hair->get_curve_keys().size() != num_keys) || (hair->num_curves() != num_curves)) { - VLOG(1) << "Allocation failed, clearing data"; + VLOG(1) << "Hair memory allocation failed, clearing data."; hair->clear(true); } } @@ -412,16 +408,11 @@ static void export_hair_motion_validate_attribute(Hair *hair, if (num_motion_keys != num_keys || !have_motion) { /* No motion or hair "topology" changed, remove attributes again. */ if (num_motion_keys != num_keys) { - VLOG(1) << "Hair topology changed, removing attribute."; - } - else { - VLOG(1) << "No motion, removing attribute."; + VLOG(1) << "Hair topology changed, removing motion attribute."; } hair->attributes.remove(ATTR_STD_MOTION_VERTEX_POSITION); } else if (motion_step > 0) { - VLOG(1) << "Filling in new motion vertex position for motion_step " << motion_step; - /* Motion, fill up previous steps that we might have skipped because * they had no motion, but we need them anyway now. */ for (int step = 0; step < motion_step; step++) { @@ -437,16 +428,12 @@ static void export_hair_motion_validate_attribute(Hair *hair, static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, int motion_step) { - VLOG(1) << "Exporting curve motion segments for hair " << hair->name << ", motion step " - << motion_step; - /* find attribute */ Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); bool new_attribute = false; /* add new attribute if it doesn't exist already */ if (!attr_mP) { - VLOG(1) << "Creating new motion vertex position attribute"; attr_mP = hair->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION); new_attribute = true; } @@ -682,10 +669,6 @@ static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair) const int num_keys = b_hair.points.length(); const int num_curves = b_hair.curves.length(); - if (num_curves > 0) { - VLOG(1) << "Exporting curve segments for hair " << hair->name; - } - hair->reserve_curves(num_curves, num_keys); /* Export curves and points. */ @@ -743,15 +726,11 @@ static void export_hair_curves(Scene *scene, Hair *hair, BL::Hair b_hair) static void export_hair_curves_motion(Hair *hair, BL::Hair b_hair, int motion_step) { - VLOG(1) << "Exporting curve motion segments for hair " << hair->name << ", motion step " - << motion_step; - /* Find or add attribute. */ Attribute *attr_mP = hair->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); bool new_attribute = false; if (!attr_mP) { - VLOG(1) << "Creating new motion vertex position attribute"; attr_mP = hair->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION); new_attribute = true; } diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp index e0a13625962..cf0b77a9b16 100644 --- a/intern/cycles/blender/sync.cpp +++ b/intern/cycles/blender/sync.cpp @@ -366,7 +366,9 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background) if ((preview && !preview_scrambling_distance) || use_adaptive_sampling) scrambling_distance = 1.0f; - VLOG(1) << "Used Scrambling Distance: " << scrambling_distance; + if (scrambling_distance != 1.0f) { + VLOG(3) << "Using scrambling distance: " << scrambling_distance; + } integrator->set_scrambling_distance(scrambling_distance); if (get_boolean(cscene, "use_fast_gi")) { diff --git a/intern/cycles/scene/constant_fold.cpp b/intern/cycles/scene/constant_fold.cpp index a1fa34e7628..a5fb68bf229 100644 --- a/intern/cycles/scene/constant_fold.cpp +++ b/intern/cycles/scene/constant_fold.cpp @@ -43,7 +43,7 @@ bool ConstantFolder::all_inputs_constant() const void ConstantFolder::make_constant(float value) const { - VLOG(1) << "Folding " << node->name << "::" << output->name() << " to constant (" << value + VLOG(3) << "Folding " << node->name << "::" << output->name() << " to constant (" << value << ")."; foreach (ShaderInput *sock, output->links) { @@ -56,7 +56,7 @@ void ConstantFolder::make_constant(float value) const void ConstantFolder::make_constant(float3 value) const { - VLOG(1) << "Folding " << node->name << "::" << output->name() << " to constant " << value << "."; + VLOG(3) << "Folding " << node->name << "::" << output->name() << " to constant " << value << "."; foreach (ShaderInput *sock, output->links) { sock->set(value); @@ -112,7 +112,7 @@ void ConstantFolder::bypass(ShaderOutput *new_output) const { assert(new_output); - VLOG(1) << "Folding " << node->name << "::" << output->name() << " to socket " + VLOG(3) << "Folding " << node->name << "::" << output->name() << " to socket " << new_output->parent->name << "::" << new_output->name() << "."; /* Remove all outgoing links from socket and connect them to new_output instead. @@ -131,7 +131,7 @@ void ConstantFolder::discard() const { assert(output->type() == SocketType::CLOSURE); - VLOG(1) << "Discarding closure " << node->name << "."; + VLOG(3) << "Discarding closure " << node->name << "."; graph->disconnect(output); } diff --git a/intern/cycles/scene/shader_nodes.cpp b/intern/cycles/scene/shader_nodes.cpp index 14d051350fb..94c96d473b6 100644 --- a/intern/cycles/scene/shader_nodes.cpp +++ b/intern/cycles/scene/shader_nodes.cpp @@ -2397,7 +2397,7 @@ void GlossyBsdfNode::simplify_settings(Scene *scene) * Note: Keep the epsilon in sync with kernel! */ if (!roughness_input->link && roughness <= 1e-4f) { - VLOG(1) << "Using sharp glossy BSDF."; + VLOG(3) << "Using sharp glossy BSDF."; distribution = CLOSURE_BSDF_REFLECTION_ID; } } @@ -2406,7 +2406,7 @@ void GlossyBsdfNode::simplify_settings(Scene *scene) * benefit from closure blur to remove unwanted noise. */ if (roughness_input->link == NULL && distribution == CLOSURE_BSDF_REFLECTION_ID) { - VLOG(1) << "Using GGX glossy with filter glossy."; + VLOG(3) << "Using GGX glossy with filter glossy."; distribution = CLOSURE_BSDF_MICROFACET_GGX_ID; roughness = 0.0f; } @@ -2490,7 +2490,7 @@ void GlassBsdfNode::simplify_settings(Scene *scene) * Note: Keep the epsilon in sync with kernel! */ if (!roughness_input->link && roughness <= 1e-4f) { - VLOG(1) << "Using sharp glass BSDF."; + VLOG(3) << "Using sharp glass BSDF."; distribution = CLOSURE_BSDF_SHARP_GLASS_ID; } } @@ -2499,7 +2499,7 @@ void GlassBsdfNode::simplify_settings(Scene *scene) * benefit from closure blur to remove unwanted noise. */ if (roughness_input->link == NULL && distribution == CLOSURE_BSDF_SHARP_GLASS_ID) { - VLOG(1) << "Using GGX glass with filter glossy."; + VLOG(3) << "Using GGX glass with filter glossy."; distribution = CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID; roughness = 0.0f; } @@ -2583,7 +2583,7 @@ void RefractionBsdfNode::simplify_settings(Scene *scene) * Note: Keep the epsilon in sync with kernel! */ if (!roughness_input->link && roughness <= 1e-4f) { - VLOG(1) << "Using sharp refraction BSDF."; + VLOG(3) << "Using sharp refraction BSDF."; distribution = CLOSURE_BSDF_REFRACTION_ID; } } @@ -2592,7 +2592,7 @@ void RefractionBsdfNode::simplify_settings(Scene *scene) * benefit from closure blur to remove unwanted noise. */ if (roughness_input->link == NULL && distribution == CLOSURE_BSDF_REFRACTION_ID) { - VLOG(1) << "Using GGX refraction with filter glossy."; + VLOG(3) << "Using GGX refraction with filter glossy."; distribution = CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID; roughness = 0.0f; } diff --git a/intern/cycles/scene/svm.cpp b/intern/cycles/scene/svm.cpp index 6da0df302ad..d121765bbdd 100644 --- a/intern/cycles/scene/svm.cpp +++ b/intern/cycles/scene/svm.cpp @@ -64,7 +64,7 @@ void SVMShaderManager::device_update_shader(Scene *scene, compiler.background = (shader == scene->background->get_shader(scene)); compiler.compile(shader, *svm_nodes, 0, &summary); - VLOG(2) << "Compilation summary:\n" + VLOG(3) << "Compilation summary:\n" << "Shader name: " << shader->name << "\n" << summary.full_report(); } -- cgit v1.2.3 From cedc80c08d8340cb7db8af52051f9a6f9469fcb7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 Oct 2021 21:59:21 +0100 Subject: Fix Cycles denoising depth pass missing in compositor --- intern/cycles/blender/addon/engine.py | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index c402df12ba9..e5bb77a834a 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -233,6 +233,7 @@ def list_render_passes(scene, srl): if crl.denoising_store_passes: yield ("Denoising Normal", "XYZ", 'VECTOR') yield ("Denoising Albedo", "RGB", 'COLOR') + yield ("Denoising Depth", "Z", 'VALUE') # Custom AOV passes. for aov in srl.aovs: -- cgit v1.2.3 From 0ab1b19de4da2db53548d82d66c8ea5ed40e0f6c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 Oct 2021 22:11:36 +0100 Subject: Fix T92684: Cycles does not fall back to OIDN if OptiX is not available --- intern/cycles/integrator/denoiser.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/intern/cycles/integrator/denoiser.cpp b/intern/cycles/integrator/denoiser.cpp index b6ca96faebf..b89024e0c85 100644 --- a/intern/cycles/integrator/denoiser.cpp +++ b/intern/cycles/integrator/denoiser.cpp @@ -29,23 +29,11 @@ unique_ptr Denoiser::create(Device *path_trace_device, const DenoisePa { DCHECK(params.use); - switch (params.type) { - case DENOISER_OPTIX: - return make_unique(path_trace_device, params); - - case DENOISER_OPENIMAGEDENOISE: - return make_unique(path_trace_device, params); - - case DENOISER_NUM: - case DENOISER_NONE: - case DENOISER_ALL: - /* pass */ - break; + if (params.type == DENOISER_OPTIX && Device::available_devices(DEVICE_MASK_OPTIX).size()) { + return make_unique(path_trace_device, params); } - LOG(FATAL) << "Unhandled denoiser type " << params.type << ", should never happen."; - - return nullptr; + return make_unique(path_trace_device, params); } Denoiser::Denoiser(Device *path_trace_device, const DenoiseParams ¶ms) -- cgit v1.2.3 From 0b060905d98cf4b266e73d9be5471dc0b3e71ecc Mon Sep 17 00:00:00 2001 From: William Leeson Date: Sun, 31 Oct 2021 22:13:30 +0100 Subject: Fix T92575: Cycles black pixels when rendering with > 65k samples Differential Revision: https://developer.blender.org/D13039 --- intern/cycles/kernel/integrator/shadow_state_template.h | 2 +- intern/cycles/kernel/integrator/state_template.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/kernel/integrator/shadow_state_template.h b/intern/cycles/kernel/integrator/shadow_state_template.h index 1fbadde2642..da25e58ff1b 100644 --- a/intern/cycles/kernel/integrator/shadow_state_template.h +++ b/intern/cycles/kernel/integrator/shadow_state_template.h @@ -20,7 +20,7 @@ KERNEL_STRUCT_BEGIN(shadow_path) /* Index of a pixel within the device render buffer. */ KERNEL_STRUCT_MEMBER(shadow_path, uint32_t, render_pixel_index, KERNEL_FEATURE_PATH_TRACING) /* Current sample number. */ -KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, sample, KERNEL_FEATURE_PATH_TRACING) +KERNEL_STRUCT_MEMBER(shadow_path, uint32_t, sample, KERNEL_FEATURE_PATH_TRACING) /* Random number generator seed. */ KERNEL_STRUCT_MEMBER(shadow_path, uint32_t, rng_hash, KERNEL_FEATURE_PATH_TRACING) /* Random number dimension offset. */ diff --git a/intern/cycles/kernel/integrator/state_template.h b/intern/cycles/kernel/integrator/state_template.h index b1a6fd36fae..e082424fabd 100644 --- a/intern/cycles/kernel/integrator/state_template.h +++ b/intern/cycles/kernel/integrator/state_template.h @@ -25,7 +25,7 @@ KERNEL_STRUCT_BEGIN(path) * The multiplication is delayed for later, so that state can use 32bit integer. */ KERNEL_STRUCT_MEMBER(path, uint32_t, render_pixel_index, KERNEL_FEATURE_PATH_TRACING) /* Current sample number. */ -KERNEL_STRUCT_MEMBER(path, uint16_t, sample, KERNEL_FEATURE_PATH_TRACING) +KERNEL_STRUCT_MEMBER(path, uint32_t, sample, KERNEL_FEATURE_PATH_TRACING) /* Current ray bounce depth. */ KERNEL_STRUCT_MEMBER(path, uint16_t, bounce, KERNEL_FEATURE_PATH_TRACING) /* Current transparent ray bounce depth. */ -- cgit v1.2.3 From 28eaa81f1e9a59c41b58834fcef6b5f3581a2581 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 Oct 2021 22:23:37 +0100 Subject: Fix Cycles Python warnings when removed OpenCL device was enabled --- intern/cycles/blender/addon/properties.py | 21 ++++++++++++++------- intern/cycles/blender/addon/version_update.py | 8 +++++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 1e98e6d0a7c..c92e0ec65af 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -1360,7 +1360,7 @@ class CyclesPreferences(bpy.types.AddonPreferences): elif entry.type == 'CPU': cpu_devices.append(entry) # Extend all GPU devices with CPU. - if compute_device_type != 'CPU': + if len(devices) and compute_device_type != 'CPU': devices.extend(cpu_devices) return devices @@ -1378,12 +1378,18 @@ class CyclesPreferences(bpy.types.AddonPreferences): self.refresh_devices() return None + def get_compute_device_type(self): + if self.compute_device_type == '': + return 'NONE' + return self.compute_device_type + def get_num_gpu_devices(self): import _cycles - device_list = _cycles.available_devices(self.compute_device_type) + compute_device_type = self.get_compute_device_type() + device_list = _cycles.available_devices(compute_device_type) num = 0 for device in device_list: - if device[1] != self.compute_device_type: + if device[1] != compute_device_type: continue for dev in self.devices: if dev.use and dev.id == device[2]: @@ -1425,15 +1431,16 @@ class CyclesPreferences(bpy.types.AddonPreferences): row = layout.row() row.prop(self, "compute_device_type", expand=True) - if self.compute_device_type == 'NONE': + compute_device_type = self.get_compute_device_type() + if compute_device_type == 'NONE': return row = layout.row() - devices = self.get_devices_for_type(self.compute_device_type) - self._draw_devices(row, self.compute_device_type, devices) + devices = self.get_devices_for_type(compute_device_type) + self._draw_devices(row, compute_device_type, devices) import _cycles has_peer_memory = 0 - for device in _cycles.available_devices(self.compute_device_type): + for device in _cycles.available_devices(compute_device_type): if device[3] and self.find_existing_device_entry(device).use: has_peer_memory += 1 if has_peer_memory > 1: diff --git a/intern/cycles/blender/addon/version_update.py b/intern/cycles/blender/addon/version_update.py index b3e8e755903..90ed8873c02 100644 --- a/intern/cycles/blender/addon/version_update.py +++ b/intern/cycles/blender/addon/version_update.py @@ -86,7 +86,7 @@ def do_versions(self): # Device might not currently be available so this can fail try: if system.legacy_compute_device_type == 1: - prop.compute_device_type = 'OPENCL' + prop.compute_device_type = 'NONE' # Was OpenCL elif system.legacy_compute_device_type == 2: prop.compute_device_type = 'CUDA' else: @@ -97,6 +97,12 @@ def do_versions(self): # Init device list for UI prop.get_devices(prop.compute_device_type) + if bpy.context.preferences.version <= (3, 0, 40): + # Disable OpenCL device + prop = bpy.context.preferences.addons[__package__].preferences + if prop['compute_device_type'] == 4: + prop.compute_device_type = 'NONE' + # We don't modify startup file because it assumes to # have all the default values only. if not bpy.data.is_saved: -- cgit v1.2.3 From 894096a5287f7d25a02338dd5188b67cb9328851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 1 Nov 2021 12:08:46 +0100 Subject: GPUState: Fix enum max value for enum operator macro Simple oversight. --- source/blender/gpu/GPU_state.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index a338728804c..1c1211d2a3e 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -42,7 +42,7 @@ typedef enum eGPUBarrier { GPU_BARRIER_SHADER_STORAGE = (1 << 2), } eGPUBarrier; -ENUM_OPERATORS(eGPUBarrier, GPU_BARRIER_TEXTURE_FETCH) +ENUM_OPERATORS(eGPUBarrier, GPU_BARRIER_SHADER_STORAGE) /** * Defines the fixed pipeline blending equation. -- cgit v1.2.3 From 81bd49d4fea41f6e569f3778724b33f15e95f853 Mon Sep 17 00:00:00 2001 From: Jarrett Johnson Date: Mon, 1 Nov 2021 11:24:50 +0100 Subject: Pointcloud selection support This patch adds support for selecting pointclouds. Since pointclouds were not properly drawn to the selection buffer (as diagonsed by output from `glReadPixels` and Renderdoc), they were not able to be selectable by depth picking or occlusion queries. In `basic_engine`, objects were rendered with a shader which draws to a depth buffer but only assumes a single position vertex attribute. Pointclouds, though, require at least another vertex attribute `pos_inst` which provides the instance offsets. Thus, this patch adds another shader variant for pointclouds which supports these two attributes and renders the points appropriately. {F11652666} Addresses T92415 Reviewed By: fclem Differential Revision: https://developer.blender.org/D13059 --- source/blender/draw/engines/basic/basic_engine.c | 62 +++++++++++++++++++++- .../draw/engines/basic/shaders/depth_vert.glsl | 7 +++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/engines/basic/basic_engine.c b/source/blender/draw/engines/basic/basic_engine.c index 87f5c6f5857..f4fdb9d0912 100644 --- a/source/blender/draw/engines/basic/basic_engine.c +++ b/source/blender/draw/engines/basic/basic_engine.c @@ -45,6 +45,7 @@ extern char datatoc_depth_vert_glsl[]; extern char datatoc_conservative_depth_geom_glsl[]; extern char datatoc_common_view_lib_glsl[]; +extern char datatoc_common_pointcloud_lib_glsl[]; /* *********** LISTS *********** */ @@ -56,6 +57,7 @@ typedef struct BASIC_StorageList { typedef struct BASIC_PassList { struct DRWPass *depth_pass[2]; + struct DRWPass *depth_pass_pointcloud[2]; struct DRWPass *depth_pass_cull[2]; } BASIC_PassList; @@ -70,7 +72,9 @@ typedef struct BASIC_Data { typedef struct BASIC_Shaders { /* Depth Pre Pass */ struct GPUShader *depth; + struct GPUShader *pointcloud_depth; struct GPUShader *depth_conservative; + struct GPUShader *pointcloud_depth_conservative; } BASIC_Shaders; /* *********** STATIC *********** */ @@ -83,6 +87,7 @@ typedef struct BASIC_PrivateData { DRWShadingGroup *depth_shgrp[2]; DRWShadingGroup *depth_shgrp_cull[2]; DRWShadingGroup *depth_hair_shgrp[2]; + DRWShadingGroup *depth_pointcloud_shgrp[2]; bool use_material_slot_selection; } BASIC_PrivateData; /* Transient data */ @@ -106,6 +111,20 @@ static void basic_engine_init(void *UNUSED(vedata)) .defs = (const char *[]){sh_cfg->def, NULL}, }); + sh_data->pointcloud_depth = GPU_shader_create_from_arrays({ + .vert = (const char *[]){sh_cfg->lib, + datatoc_common_view_lib_glsl, + datatoc_common_pointcloud_lib_glsl, + datatoc_depth_vert_glsl, + NULL}, + .frag = (const char *[]){datatoc_depth_frag_glsl, NULL}, + .defs = (const char *[]){sh_cfg->def, + "#define POINTCLOUD\n", + "#define INSTANCED_ATTR\n", + "#define UNIFORM_RESOURCE_ID\n", + NULL}, + }); + sh_data->depth_conservative = GPU_shader_create_from_arrays({ .vert = (const char *[]){sh_cfg->lib, datatoc_common_view_lib_glsl, @@ -118,6 +137,25 @@ static void basic_engine_init(void *UNUSED(vedata)) .frag = (const char *[]){datatoc_depth_frag_glsl, NULL}, .defs = (const char *[]){sh_cfg->def, "#define CONSERVATIVE_RASTER\n", NULL}, }); + + sh_data->pointcloud_depth_conservative = GPU_shader_create_from_arrays({ + .vert = (const char *[]){sh_cfg->lib, + datatoc_common_view_lib_glsl, + datatoc_common_pointcloud_lib_glsl, + datatoc_depth_vert_glsl, + NULL}, + .geom = (const char *[]){sh_cfg->lib, + datatoc_common_view_lib_glsl, + datatoc_conservative_depth_geom_glsl, + NULL}, + .frag = (const char *[]){datatoc_depth_frag_glsl, NULL}, + .defs = (const char *[]){sh_cfg->def, + "#define CONSERVATIVE_RASTER\n", + "#define POINTCLOUD\n", + "#define INSTANCED_ATTR\n", + "#define UNIFORM_RESOURCE_ID\n", + NULL}, + }); } } @@ -150,9 +188,17 @@ static void basic_cache_init(void *vedata) DRW_shgroup_uniform_vec2(grp, "sizeViewport", DRW_viewport_size_get(), 1); DRW_shgroup_uniform_vec2(grp, "sizeViewportInv", DRW_viewport_invert_size_get(), 1); + sh = DRW_state_is_select() ? sh_data->pointcloud_depth_conservative : sh_data->pointcloud_depth; + DRW_PASS_CREATE(psl->depth_pass_pointcloud[i], state | clip_state | infront_state); + stl->g_data->depth_pointcloud_shgrp[i] = grp = DRW_shgroup_create(sh, psl->depth_pass_pointcloud[i]); + DRW_shgroup_uniform_vec2(grp, "sizeViewport", DRW_viewport_size_get(), 1); + DRW_shgroup_uniform_vec2(grp, "sizeViewportInv", DRW_viewport_invert_size_get(), 1); + stl->g_data->depth_hair_shgrp[i] = grp = DRW_shgroup_create(sh_data->depth, psl->depth_pass[i]); + + sh = DRW_state_is_select() ? sh_data->depth_conservative : sh_data->depth; state |= DRW_STATE_CULL_BACK; DRW_PASS_CREATE(psl->depth_pass_cull[i], state | clip_state | infront_state); stl->g_data->depth_shgrp_cull[i] = grp = DRW_shgroup_create(sh, psl->depth_pass_cull[i]); @@ -231,8 +277,16 @@ static void basic_cache_populate(void *vedata, Object *ob) !DRW_state_is_image_render(); const bool do_cull = (draw_ctx->v3d && (draw_ctx->v3d->shading.flag & V3D_SHADING_BACKFACE_CULLING)); - DRWShadingGroup *shgrp = (do_cull) ? stl->g_data->depth_shgrp_cull[do_in_front] : - stl->g_data->depth_shgrp[do_in_front]; + + 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]; + } if (use_sculpt_pbvh) { DRW_shgroup_call_sculpt(shgrp, ob, false, false); @@ -273,8 +327,10 @@ static void basic_draw_scene(void *vedata) BASIC_PassList *psl = ((BASIC_Data *)vedata)->psl; DRW_draw_pass(psl->depth_pass[0]); + DRW_draw_pass(psl->depth_pass_pointcloud[0]); DRW_draw_pass(psl->depth_pass_cull[0]); DRW_draw_pass(psl->depth_pass[1]); + DRW_draw_pass(psl->depth_pass_pointcloud[1]); DRW_draw_pass(psl->depth_pass_cull[1]); } @@ -284,6 +340,8 @@ static void basic_engine_free(void) BASIC_Shaders *sh_data = &e_data.sh_data[i]; DRW_SHADER_FREE_SAFE(sh_data->depth); DRW_SHADER_FREE_SAFE(sh_data->depth_conservative); + DRW_SHADER_FREE_SAFE(sh_data->pointcloud_depth); + DRW_SHADER_FREE_SAFE(sh_data->pointcloud_depth_conservative); } } diff --git a/source/blender/draw/engines/basic/shaders/depth_vert.glsl b/source/blender/draw/engines/basic/shaders/depth_vert.glsl index 318d0acef6f..be2a7d56d19 100644 --- a/source/blender/draw/engines/basic/shaders/depth_vert.glsl +++ b/source/blender/draw/engines/basic/shaders/depth_vert.glsl @@ -3,7 +3,9 @@ RESOURCE_ID_VARYING #endif +#ifndef POINTCLOUD in vec3 pos; +#endif void main() { @@ -12,7 +14,12 @@ void main() PASS_RESOURCE_ID #endif +#ifdef POINTCLOUD + vec3 world_pos = pointcloud_get_pos(); +#else vec3 world_pos = point_object_to_world(pos); +#endif + gl_Position = point_world_to_ndc(world_pos); #ifdef USE_WORLD_CLIP_PLANES -- cgit v1.2.3