Skip to content

Commit

Permalink
Don't try to build TLSs if BLS array is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
szellmann committed Oct 28, 2024
1 parent f8207bf commit f7243b9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
14 changes: 9 additions & 5 deletions scene/VisionarayScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ void VisionaraySceneImpl::commit()
}

// Build TLS
lbvh_builder tlsBuilder;
m_worldTLS = tlsBuilder.build(
WorldTLS{}, m_worldBLSs.hostPtr(), m_worldBLSs.size());
if (!m_worldBLSs.empty()) {
lbvh_builder tlsBuilder;
m_worldTLS = tlsBuilder.build(
WorldTLS{}, m_worldBLSs.hostPtr(), m_worldBLSs.size());
}

// Build flat list of lights
m_allLights.clear();
Expand Down Expand Up @@ -247,8 +249,10 @@ void VisionaraySceneImpl::commit()
}

// Build TLS
lbvh_builder tlsBuilder;
m_TLS = tlsBuilder.build(TLS{}, m_BLSs.hostPtr(), m_BLSs.size());
if (!m_BLSs.empty()) {
lbvh_builder tlsBuilder;
m_TLS = tlsBuilder.build(TLS{}, m_BLSs.hostPtr(), m_BLSs.size());
}
}
#endif

Expand Down
20 changes: 12 additions & 8 deletions scene/VisionaraySceneGPU.cu
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ void VisionaraySceneGPU::commit()
}

// Build TLS
lbvh_builder tlsBuilder;
m_impl->m_worldTLS = tlsBuilder.build(
GPU::WorldTLS{}, m_impl->parent->m_worldBLSs.devicePtr(),
m_impl->parent->m_worldBLSs.size());
if (!m_impl->parent->m_worldBLSs.empty()) {
lbvh_builder tlsBuilder;
m_impl->m_worldTLS = tlsBuilder.build(
GPU::WorldTLS{}, m_impl->parent->m_worldBLSs.devicePtr(),
m_impl->parent->m_worldBLSs.size());
}

// Build flat list of lights
m_impl->parent->m_allLights.clear();
Expand Down Expand Up @@ -354,10 +356,12 @@ void VisionaraySceneGPU::commit()
}

// Build TLS
lbvh_builder tlsBuilder;
m_impl->m_TLS = tlsBuilder.build(
GPU::TLS{}, m_impl->parent->m_BLSs.devicePtr(),
m_impl->parent->m_BLSs.size());
if (!m_impl->parent->m_BLSs.empty()) {
lbvh_builder tlsBuilder;
m_impl->m_TLS = tlsBuilder.build(
GPU::TLS{}, m_impl->parent->m_BLSs.devicePtr(),
m_impl->parent->m_BLSs.size());
}
}
}

Expand Down
28 changes: 16 additions & 12 deletions scene/VisionaraySceneGPU.hip
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ void VisionaraySceneGPU::commit()
}

// Build TLS
binned_sah_builder tlsBuilder;
typedef index_bvh<dco::Instance> WorldTLS;
auto h_worldTLS = tlsBuilder.build(
WorldTLS{}, m_impl->parent->m_worldBLSs.devicePtr(),
m_impl->parent->m_worldBLSs.size());
m_impl->m_worldTLS = GPU::WorldTLS(h_worldTLS);
if (!m_impl->parent->m_worldBLSs.empty()) {
binned_sah_builder tlsBuilder;
typedef index_bvh<dco::Instance> WorldTLS;
auto h_worldTLS = tlsBuilder.build(
WorldTLS{}, m_impl->parent->m_worldBLSs.devicePtr(),
m_impl->parent->m_worldBLSs.size());
m_impl->m_worldTLS = GPU::WorldTLS(h_worldTLS);
}

// Build flat list of lights
m_impl->parent->m_allLights.clear();
Expand Down Expand Up @@ -369,12 +371,14 @@ void VisionaraySceneGPU::commit()
}

// Build TLS
binned_sah_builder tlsBuilder;
typedef index_bvh<dco::BLS> TLS;
auto h_TLS = tlsBuilder.build(
TLS{}, m_impl->parent->m_BLSs.devicePtr(),
m_impl->parent->m_BLSs.size());
m_impl->m_TLS = GPU::TLS(h_TLS);
if (!m_impl->parent->m_BLSs.empty()) {
binned_sah_builder tlsBuilder;
typedef index_bvh<dco::BLS> TLS;
auto h_TLS = tlsBuilder.build(
TLS{}, m_impl->parent->m_BLSs.devicePtr(),
m_impl->parent->m_BLSs.size());
m_impl->m_TLS = GPU::TLS(h_TLS);
}
}
}

Expand Down

0 comments on commit f7243b9

Please sign in to comment.