From edbf3b73b4183a852f4900218b7ae1a866c96a31 Mon Sep 17 00:00:00 2001 From: iaomw Date: Fri, 18 Oct 2024 16:27:19 +0800 Subject: [PATCH 1/2] Fix StaticMeshes leak --- zenovis/xinxinoptix/optixPathTracer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zenovis/xinxinoptix/optixPathTracer.cpp b/zenovis/xinxinoptix/optixPathTracer.cpp index 5cbee114f7..1122010de4 100644 --- a/zenovis/xinxinoptix/optixPathTracer.cpp +++ b/zenovis/xinxinoptix/optixPathTracer.cpp @@ -788,7 +788,7 @@ static void buildMeshIAS(PathTracerState& state, int rayTypeCount, std::vector &mtlidlut) void UpdateMeshGasAndIas(bool staticNeedUpdate) { - buildMeshAccel(state, StaticMeshes); - tbb::parallel_for(static_cast(0), g_meshPieces.size(), [](size_t i){ buildMeshAccel(state, g_meshPieces[i]); }); @@ -2555,6 +2553,8 @@ static void updateStaticDrawObjects() { tri_offset += dat.tris.size() / 3; ver_offset += dat.verts.size() / 3; } + + buildMeshAccel(state, StaticMeshes); } static void updateDynamicDrawObjects() { From ef15eecfad4e5ab136f6233d862e46f00baf57f6 Mon Sep 17 00:00:00 2001 From: iaomw Date: Fri, 18 Oct 2024 16:27:34 +0800 Subject: [PATCH 2/2] Minor update --- zenovis/xinxinoptix/XAS.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zenovis/xinxinoptix/XAS.h b/zenovis/xinxinoptix/XAS.h index 87d2c6e42c..c46ef6868f 100644 --- a/zenovis/xinxinoptix/XAS.h +++ b/zenovis/xinxinoptix/XAS.h @@ -118,6 +118,13 @@ namespace xinxinoptix { inline void buildIAS(OptixDeviceContext& context, OptixAccelBuildOptions& accel_options, std::vector& instances, raii& bufferIAS, OptixTraversableHandle& handleIAS) { + + if (instances.empty()) { + bufferIAS.reset(); + handleIAS = 0llu; + return; + } + raii d_instances; const size_t size_in_bytes = sizeof( OptixInstance ) * instances.size(); CUDA_CHECK( cudaMalloc( reinterpret_cast( &d_instances.reset() ), size_in_bytes ) );