Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions gpu/examples/trenchTriangles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,5 @@ int main(int argc, char **argv) {
std::cout << "Trace count: " << rayCount << std::endl;
#endif

tracer.freeBuffers();

context->destroy();
}
44 changes: 40 additions & 4 deletions gpu/include/raygTrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ template <class T, int D> class Trace {
initRayTracer();
}

~Trace() { freeBuffers(); }
~Trace() {
freeBuffers();
destroyMembers();
}

void setCallables(std::string fileName, const std::filesystem::path &path) {
// check if filename ends in .optixir
Expand Down Expand Up @@ -359,6 +362,39 @@ template <class T, int D> 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();
Expand Down Expand Up @@ -711,11 +747,11 @@ template <class T, int D> 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<OptixProgramGroup> directCallablePGs;
CudaBuffer directCallableRecordBuffer;
Expand Down