Skip to content

Commit 6d793d7

Browse files
author
devsh
committed
remind self to never reinterpret_cast between virtual base and derived
1 parent 340cb75 commit 6d793d7

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

include/nbl/video/IGPUCommandBuffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ class NBL_API2 IGPUCommandBuffer : public IBackendObject
884884
// If the user wants the builds to be tracking, and make the TLAS remember the BLASes that have been built into it.
885885
// NOTE: We know that a TLAS may be rebuilt multiple times per frame on purpose and not only the final BLASes need to be kept alive till submission finishes.
886886
// However, the Command Pool already tracks resources referenced in the Build Infos, so we only need pointers into those records.
887-
core::unordered_map<IGPUTopLevelAccelerationStructure*,std::span<const IGPUTopLevelAccelerationStructure::blas_smart_ptr_t>> m_TLASToBLASReferenceSets;
887+
core::unordered_map<IGPUTopLevelAccelerationStructure*,std::span<const core::smart_refctd_ptr<const IReferenceCounted>>> m_TLASToBLASReferenceSets;
888888

889889
const IGPUGraphicsPipeline* m_boundGraphicsPipeline;
890890
const IGPUComputePipeline* m_boundComputePipeline;

include/nbl/video/ILogicalDevice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
580580
}
581581

582582
// the rawpointers are already smartpointers in whatever else the `fillTracking` declared above writes
583-
core::unordered_map<IGPUTopLevelAccelerationStructure*,std::span<const IGPUTopLevelAccelerationStructure::blas_smart_ptr_t>> m_TLASToBLASReferenceSets;
583+
core::unordered_map<IGPUTopLevelAccelerationStructure*,std::span<const core::smart_refctd_ptr<const IReferenceCounted>>> m_TLASToBLASReferenceSets;
584584
} callback = {};
585585

586586
auto& tracking = deferredOperation->m_resourceTracking;
@@ -593,7 +593,7 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
593593
{
594594
const auto blasCount = info.trackedBLASes.size();
595595
if (blasCount)
596-
callback.m_TLASToBLASReferenceSets[info.dstAS] = {reinterpret_cast<const IGPUTopLevelAccelerationStructure::blas_smart_ptr_t*>(oit-blasCount),blasCount};
596+
callback.m_TLASToBLASReferenceSets[info.dstAS] = {oit-blasCount,blasCount};
597597
else
598598
callback.m_TLASToBLASReferenceSets[info.dstAS] = {};
599599
}

src/nbl/video/IGPUCommandBuffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ uint32_t IGPUCommandBuffer::buildAccelerationStructures_common(const std::span<c
843843
{
844844
const auto blasCount = info.trackedBLASes.size();
845845
if (blasCount)
846-
m_TLASToBLASReferenceSets[info.dstAS] = {reinterpret_cast<const IGPUTopLevelAccelerationStructure::blas_smart_ptr_t*>(oit-blasCount),blasCount};
846+
m_TLASToBLASReferenceSets[info.dstAS] = {oit-blasCount,blasCount};
847847
else
848848
m_TLASToBLASReferenceSets[info.dstAS] = {};
849849
}

src/nbl/video/IQueue.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ IQueue::DeferredSubmitCallback::DeferredSubmitCallback(const SSubmitInfo& info)
157157
{
158158
const auto tlas = refSet.first;
159159
// in theory could assert no duplicate entries, but thats obvious
160-
m_TLASToBLASReferenceSets[tlas] = { .m_BLASes = {refSet.second.begin(),refSet.second.end()}, .m_buildVer = tlas->registerNextBuildVer()};
160+
auto& out = m_TLASToBLASReferenceSets[tlas];
161+
out.m_BLASes.reserve(refSet.second.size());
162+
for (const auto& refCtd : refSet.second)
163+
out.m_BLASes.emplace(dynamic_cast<const IGPUBottomLevelAccelerationStructure*>(refCtd.get()));
164+
out.m_buildVer = tlas->registerNextBuildVer();
161165
}
162166
}
163167
// We don't hold the last signal semaphore, because the timeline does as an Event trigger.

0 commit comments

Comments
 (0)