From f89728a5e49abf01bf5f80d0b77da3f2eb758ca0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 6 Mar 2025 11:57:51 +0100 Subject: [PATCH] Fix: HIP-RT creates copy of vector during build Is harmless from functional perspective, but uses more resources and potentially slower than it should be. Although, probably something hard to measure in practice, but still better not follow this anti- pattern. Pull Request: https://projects.blender.org/blender/blender/pulls/135529 --- intern/cycles/device/hiprt/device_impl.cpp | 10 ++++------ intern/cycles/device/hiprt/device_impl.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/intern/cycles/device/hiprt/device_impl.cpp b/intern/cycles/device/hiprt/device_impl.cpp index 2a4d3471f41..eecb4e60adb 100644 --- a/intern/cycles/device/hiprt/device_impl.cpp +++ b/intern/cycles/device/hiprt/device_impl.cpp @@ -805,7 +805,7 @@ void HIPRTDevice::build_blas(BVHHIPRT *bvh, Geometry *geom, hiprtBuildOptions op } hiprtScene HIPRTDevice::build_tlas(BVHHIPRT *bvh, - vector objects, + const vector &objects, hiprtBuildOptions options, bool refit) { @@ -1097,18 +1097,16 @@ void HIPRTDevice::build_bvh(BVH *bvh, Progress &progress, bool refit) HIPContextScope scope(this); if (!bvh_rt->is_tlas()) { - vector geometry = bvh_rt->geometry; + const vector &geometry = bvh_rt->geometry; assert(geometry.size() == 1); - Geometry *geom = geometry[0]; - build_blas(bvh_rt, geom, options); + build_blas(bvh_rt, geometry[0], options); } else { - const vector objects = bvh_rt->objects; if (scene) { hiprtDestroyScene(hiprt_context, scene); } - scene = build_tlas(bvh_rt, objects, options, refit); + scene = build_tlas(bvh_rt, bvh_rt->objects, options, refit); } } CCL_NAMESPACE_END diff --git a/intern/cycles/device/hiprt/device_impl.h b/intern/cycles/device/hiprt/device_impl.h index 294d1086a2b..a6465d787dd 100644 --- a/intern/cycles/device/hiprt/device_impl.h +++ b/intern/cycles/device/hiprt/device_impl.h @@ -62,7 +62,7 @@ class HIPRTDevice : public HIPDevice { hiprtGeometryBuildInput prepare_point_blas(BVHHIPRT *bvh, PointCloud *pointcloud); void build_blas(BVHHIPRT *bvh, Geometry *geom, hiprtBuildOptions options); hiprtScene build_tlas(BVHHIPRT *bvh, - vector objects, + const vector &objects, hiprtBuildOptions options, bool refit);