Fix: HIP-RT creates copy of vector<Object *> 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
This commit is contained in:
Sergey Sharybin
2025-03-06 11:57:51 +01:00
committed by Sergey Sharybin
parent e726357962
commit f89728a5e4
2 changed files with 5 additions and 7 deletions

View File

@@ -805,7 +805,7 @@ void HIPRTDevice::build_blas(BVHHIPRT *bvh, Geometry *geom, hiprtBuildOptions op
}
hiprtScene HIPRTDevice::build_tlas(BVHHIPRT *bvh,
vector<Object *> objects,
const vector<Object *> &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 *> geometry = bvh_rt->geometry;
const vector<Geometry *> &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<Object *> 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

View File

@@ -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<Object *> objects,
const vector<Object *> &objects,
hiprtBuildOptions options,
bool refit);