Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static Meshes #2042

Merged
merged 2 commits into from
Oct 18, 2024
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
7 changes: 7 additions & 0 deletions zenovis/xinxinoptix/XAS.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ namespace xinxinoptix {
inline void buildIAS(OptixDeviceContext& context, OptixAccelBuildOptions& accel_options, std::vector<OptixInstance>& instances,
raii<CUdeviceptr>& bufferIAS, OptixTraversableHandle& handleIAS)
{

if (instances.empty()) {
bufferIAS.reset();
handleIAS = 0llu;
return;
}

raii<CUdeviceptr> d_instances;
const size_t size_in_bytes = sizeof( OptixInstance ) * instances.size();
CUDA_CHECK( cudaMalloc( reinterpret_cast<void**>( &d_instances.reset() ), size_in_bytes ) );
Expand Down
6 changes: 3 additions & 3 deletions zenovis/xinxinoptix/optixPathTracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ static void buildMeshIAS(PathTracerState& state, int rayTypeCount, std::vector<s
float3 defaultInstClr = {1, 1, 1};
float3 defaultInstTang = {1, 0, 0};

std::size_t num_meshes = (StaticMeshes != nullptr)? 1:0 + g_meshPieces.size();
std::size_t num_meshes = g_meshPieces.size() + (StaticMeshes != nullptr? 1:0);
std::size_t num_instances = num_meshes;

for (const auto &[instID, instData] : g_instLUT)
Expand Down Expand Up @@ -1620,8 +1620,6 @@ void UpdateInstMesh(const std::map<std::string, int> &mtlidlut)

void UpdateMeshGasAndIas(bool staticNeedUpdate)
{
buildMeshAccel(state, StaticMeshes);

tbb::parallel_for(static_cast<size_t>(0), g_meshPieces.size(), [](size_t i){
buildMeshAccel(state, g_meshPieces[i]);
});
Expand Down Expand Up @@ -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() {
Expand Down
Loading