diff --git a/CMakeLists.txt b/CMakeLists.txt index 43fecfe..2c8bfd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR) project( ViennaRay LANGUAGES CXX - VERSION 3.8.1) + VERSION 3.8.2) # -------------------------------------------------------------------------------------------------------- # Library switches diff --git a/README.md b/README.md index c1afc10..8bbff3c 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ We recommend using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to consum * Installation with CPM ```cmake - CPMAddPackage("gh:viennatools/viennaray@3.8.1") # Use the latest release version + CPMAddPackage("gh:viennatools/viennaray@3.8.2") # Use the latest release version ``` * With a local installation diff --git a/gpu/examples/trenchTriangles.cpp b/gpu/examples/trenchTriangles.cpp index 2886095..8443246 100644 --- a/gpu/examples/trenchTriangles.cpp +++ b/gpu/examples/trenchTriangles.cpp @@ -69,7 +69,5 @@ int main(int argc, char **argv) { std::cout << "Trace count: " << rayCount << std::endl; #endif - tracer.freeBuffers(); - context->destroy(); } diff --git a/gpu/include/raygTrace.hpp b/gpu/include/raygTrace.hpp index 59114fe..e6078a4 100644 --- a/gpu/include/raygTrace.hpp +++ b/gpu/include/raygTrace.hpp @@ -48,7 +48,10 @@ template class Trace { initRayTracer(); } - ~Trace() { freeBuffers(); } + ~Trace() { + freeBuffers(); + destroyMembers(); + } void setCallables(std::string fileName, const std::filesystem::path &path) { // check if filename ends in .optixir @@ -359,6 +362,39 @@ template class Trace { } } + void destroyMembers() { + if (pipeline_) { + optixPipelineDestroy(pipeline_); + pipeline_ = nullptr; + } + if (module_) { + optixModuleDestroy(module_); + module_ = nullptr; + } + if (moduleCallable_) { + optixModuleDestroy(moduleCallable_); + moduleCallable_ = nullptr; + } + if (raygenPG) { + optixProgramGroupDestroy(raygenPG); + raygenPG = nullptr; + } + if (missPG) { + optixProgramGroupDestroy(missPG); + missPG = nullptr; + } + if (hitgroupPG) { + optixProgramGroupDestroy(hitgroupPG); + hitgroupPG = nullptr; + } + for (auto &pg : directCallablePGs) { + if (pg) { + optixProgramGroupDestroy(pg); + } + } + directCallablePGs.clear(); + } + unsigned int prepareParticlePrograms() { if (particles_.empty()) { Logger::getInstance().addWarning("No particles defined.").print(); @@ -711,11 +747,11 @@ template class Trace { OptixModuleCompileOptions moduleCompileOptions_ = {}; // program groups, and the SBT built around - OptixProgramGroup raygenPG; + OptixProgramGroup raygenPG{}; CudaBuffer raygenRecordBuffer; - OptixProgramGroup missPG; + OptixProgramGroup missPG{}; CudaBuffer missRecordBuffer; - OptixProgramGroup hitgroupPG; + OptixProgramGroup hitgroupPG{}; CudaBuffer hitgroupRecordBuffer; std::vector directCallablePGs; CudaBuffer directCallableRecordBuffer;