Perform delayed freeing of the geometry BVHs similar to OptiX. Previously BLAS memory was allocated in the device class as part of device_update, but released in the BVHHIPRT destructor which gets called when deleting geometry outside of device_update. To avoid the GPU accessing unmapped memory, do a delayed free of this memory in the device class as part of either device_update or device destruction. This ensures it is in sync with other device memory changes. Fix #148276 Fix #139013 Fix #138043 Fix #140763 Pull Request: https://projects.blender.org/blender/blender/pulls/147247
42 lines
984 B
C++
42 lines
984 B
C++
/* SPDX-FileCopyrightText: 2011-2023 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#ifdef WITH_HIPRT
|
|
|
|
# include "bvh/hiprt.h"
|
|
|
|
# include "scene/mesh.h"
|
|
# include "scene/object.h"
|
|
|
|
# include "device/hiprt/device_impl.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
BVHHIPRT::BVHHIPRT(const BVHParams ¶ms,
|
|
const vector<Geometry *> &geometry,
|
|
const vector<Object *> &objects,
|
|
Device *in_device)
|
|
: BVH(params, geometry, objects),
|
|
hiprt_geom(nullptr),
|
|
custom_primitive_bound(in_device, "Custom Primitive Bound", MEM_READ_ONLY),
|
|
triangle_index(in_device, "HIPRT Triangle Index", MEM_READ_ONLY),
|
|
vertex_data(in_device, "vertex_data", MEM_READ_ONLY),
|
|
device(in_device)
|
|
{
|
|
triangle_mesh = {nullptr};
|
|
custom_prim_aabb = {nullptr};
|
|
}
|
|
|
|
BVHHIPRT::~BVHHIPRT()
|
|
{
|
|
custom_primitive_bound.free();
|
|
triangle_index.free();
|
|
vertex_data.free();
|
|
device->release_bvh(this);
|
|
}
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
#endif
|