From 8cf4d47fe2d1e2449cfd129ef9cbe619cf7a901d Mon Sep 17 00:00:00 2001 From: Alaska Date: Tue, 3 Sep 2024 16:31:41 +0200 Subject: [PATCH] Fix: Improve Cycles point clouds in HIPRT Fixes a few issues with point clouds with HIPRT. 1. Crashing when building the BLAS due to an incorrect sized array. 2. A typo leading to all point cloud intersections being skipped. 3. A typo leading to some motion blurred point clouds rendering as if they were stationary, or not rendering at all. Pointclouds, with deformable motion blur, with BVH time steps set to >0 still do not render. Curves seem to have the same issue. Ref #125086 Pull Request: https://projects.blender.org/blender/blender/pulls/125834 --- intern/cycles/device/hiprt/device_impl.cpp | 12 +++++++----- intern/cycles/kernel/device/hiprt/common.h | 4 +--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/intern/cycles/device/hiprt/device_impl.cpp b/intern/cycles/device/hiprt/device_impl.cpp index a241eb45b28..8fab9fed969 100644 --- a/intern/cycles/device/hiprt/device_impl.cpp +++ b/intern/cycles/device/hiprt/device_impl.cpp @@ -637,6 +637,7 @@ hiprtGeometryBuildInput HIPRTDevice::prepare_point_blas(BVHHIPRT *bvh, PointClou int num_bounds = 0; if (point_attr_mP == NULL) { + bvh->custom_prim_info.resize(num_points); bvh->custom_primitive_bound.alloc(num_points); for (uint j = 0; j < num_points; j++) { const PointCloud::Point point = pointcloud->get_point(j); @@ -651,8 +652,8 @@ hiprtGeometryBuildInput HIPRTDevice::prepare_point_blas(BVHHIPRT *bvh, PointClou } } else if (bvh->params.num_motion_point_steps == 0) { - - bvh->custom_primitive_bound.alloc(num_points * num_steps); + bvh->custom_prim_info.resize(num_points); + bvh->custom_primitive_bound.alloc(num_points); for (uint j = 0; j < num_points; j++) { const PointCloud::Point point = pointcloud->get_point(j); @@ -664,17 +665,18 @@ hiprtGeometryBuildInput HIPRTDevice::prepare_point_blas(BVHHIPRT *bvh, PointClou if (bounds.valid()) { bvh->custom_primitive_bound[num_bounds] = bounds; bvh->custom_prim_info[num_bounds].x = j; - bvh->custom_prim_info[num_bounds].y = PRIMITIVE_POINT; + bvh->custom_prim_info[num_bounds].y = PRIMITIVE_MOTION_POINT; num_bounds++; } } } else { - const int num_bvh_steps = bvh->params.num_motion_point_steps * 2 + 1; const float num_bvh_steps_inv_1 = 1.0f / (num_bvh_steps - 1); + bvh->custom_prim_info.resize(num_points * num_bvh_steps); bvh->custom_primitive_bound.alloc(num_points * num_bvh_steps); + bvh->prims_time.resize(num_points * num_bvh_steps); for (uint j = 0; j < num_points; j++) { const PointCloud::Point point = pointcloud->get_point(j); @@ -908,7 +910,7 @@ hiprtScene HIPRTDevice::build_tlas(BVHHIPRT *bvh, current_header.frameIndex = transform_matrix.size(); if (ob->get_motion().size()) { int motion_size = ob->get_motion().size(); - assert(motion_size == 1); + assert(motion_size != 1); array tfm_array = ob->get_motion(); float time_iternval = 1 / (float)(motion_size - 1); diff --git a/intern/cycles/kernel/device/hiprt/common.h b/intern/cycles/kernel/device/hiprt/common.h index 61cae664330..378a841047f 100644 --- a/intern/cycles/kernel/device/hiprt/common.h +++ b/intern/cycles/kernel/device/hiprt/common.h @@ -319,7 +319,7 @@ ccl_device_inline bool point_custom_intersect(const hiprtRay &ray, void *payload, hiprtHit &hit) { -# ifdef POINT_CLOUD +# ifdef __POINTCLOUD__ RayPayload *local_payload = (RayPayload *)payload; KernelGlobals kg = local_payload->kg; int object_id = kernel_data_fetch(user_instance_id, hit.instanceID); @@ -334,8 +334,6 @@ ccl_device_inline bool point_custom_intersect(const hiprtRay &ray, int type = prim_info.y; # ifdef __SHADOW_LINKING__ - /* TODO: Needs further testing as point clouds crash when using HIP-RT - * at the time this change was made. */ if (intersection_skip_shadow_link(nullptr, local_payload->self, object_id)) { /* Ignore hit - continue traversal */ return false;