Skip to content

Commit 100ae7d

Browse files
author
devsh
committed
Realize that compacted acceleration structures need an allocator for their storage.
Change more stuff to span in `ICPUBottomLevelAccelerationStructure` Use a semantically better typedef/alias in `ILogicalDevice::createBottomLevelAccelerationStructure`
1 parent 19e3e57 commit 100ae7d

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

include/nbl/asset/ICPUAccelerationStructure.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ class ICPUBottomLevelAccelerationStructure final : public IBottomLevelAccelerati
8787
}
8888

8989
//
90-
inline core::SRange<AABBs<asset::ICPUBuffer>> getAABBGeometries()
90+
inline std::span<AABBs<asset::ICPUBuffer>> getAABBGeometries()
9191
{
9292
if (!isMutable() || !m_AABBGeoms)
9393
return {nullptr,nullptr};
94-
return {m_AABBGeoms->begin(),m_AABBGeoms->end()};
94+
return {m_AABBGeoms->data(),m_AABBGeoms->size()};
9595
}
96-
inline core::SRange<const AABBs<asset::ICPUBuffer>> getAABBGeometries() const
96+
inline std::span<const AABBs<asset::ICPUBuffer>> getAABBGeometries() const
9797
{
9898
if (!m_AABBGeoms)
9999
return {nullptr,nullptr};
100-
return {m_AABBGeoms->begin(),m_AABBGeoms->end()};
100+
return {m_AABBGeoms->data(),m_AABBGeoms->size()};
101101
}
102102
inline bool setGeometries(core::smart_refctd_dynamic_array<AABBs<ICPUBuffer>>&& geometries, core::smart_refctd_dynamic_array<uint32_t>&& ranges)
103103
{

include/nbl/video/ILogicalDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ class NBL_API2 ILogicalDevice : public core::IReferenceCounted, public IDeviceMe
358358
// Create a sampler object to use with ImageViews
359359
virtual core::smart_refctd_ptr<IGPUSampler> createSampler(const IGPUSampler::SParams& _params) = 0;
360360
// acceleration structures
361-
inline core::smart_refctd_ptr<IGPUBottomLevelAccelerationStructure> createBottomLevelAccelerationStructure(IGPUAccelerationStructure::SCreationParams&& params)
361+
inline core::smart_refctd_ptr<IGPUBottomLevelAccelerationStructure> createBottomLevelAccelerationStructure(IGPUBottomLevelAccelerationStructure::SCreationParams&& params)
362362
{
363363
if (invalidCreationParams(params))
364364
{

include/nbl/video/utilities/CAssetConverter.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ class CAssetConverter : public core::IReferenceCounted
885885
{
886886
// By default the last to queue to touch a GPU object will own it after any transfer or compute operations are complete.
887887
// If you want to record a pipeline barrier that will release ownership to another family, override this.
888+
// The overload for the IGPUBuffer may be called with a hash belonging to a Acceleration Structure, this means that its the storage buffer backing the AS
888889
virtual inline uint32_t getFinalOwnerQueueFamily(const IGPUBuffer* buffer, const core::blake3_hash_t& createdFrom)
889890
{
890891
return IQueue::FamilyIgnored;
@@ -923,6 +924,8 @@ class CAssetConverter : public core::IReferenceCounted
923924
std::span<const IQueue::SSubmitInfo::SSemaphoreInfo> extraSignalSemaphores = {};
924925
// specific to Acceleration Structure Build, they need to be at least as large as the largest amount of scratch required for an AS build
925926
CAsyncSingleBufferSubAllocatorST<>* scratchForASBuild = nullptr;
927+
//
928+
IDeviceMemoryAllocator* compactedASAllocator = nullptr;
926929
// specific to mip-map recomputation, these are okay defaults for the size of our Descriptor Indexed temporary descriptor set
927930
uint32_t sampledImageBindingCount = 1<<10;
928931
uint32_t storageImageBindingCount = 11<<10;
@@ -951,6 +954,8 @@ class CAssetConverter : public core::IReferenceCounted
951954
inline uint64_t getMinASBuildScratchSize() const {return m_minASBuildScratchSize;}
952955
// enough memory to build and compact the all Acceleration Structures at once, obviously respecting order of BLAS (build->compact) -> TLAS (build->compact)
953956
inline uint64_t getMaxASBuildScratchSize() const {return m_maxASBuildScratchSize;}
957+
// if returns NONE means there are no acceleration structures to build
958+
inline auto getASBuildScratchUsages() const {return m_ASBuildScratchUsages;}
954959

955960
//
956961
inline operator bool() const {return bool(m_converter);}
@@ -1016,8 +1021,17 @@ class CAssetConverter : public core::IReferenceCounted
10161021
core::smart_refctd_ptr<const AssetType> canonical;
10171022
// gpu object to transfer canonical's data to or build it from
10181023
asset_traits<AssetType>::video_t* gpuObj;
1019-
// only relevant for images
1020-
uint16_t recomputeMips = 0;
1024+
union
1025+
{
1026+
// only relevant for images
1027+
uint16_t recomputeMips = 0;
1028+
//
1029+
struct ASBuildParams
1030+
{
1031+
uint8_t host : 1;
1032+
uint8_t compact : 1;
1033+
} asBuildParams;
1034+
};
10211035
};
10221036
template<asset::Asset AssetType>
10231037
using conversion_requests_t = core::vector<ConversionRequest<AssetType>>;
@@ -1032,6 +1046,7 @@ class CAssetConverter : public core::IReferenceCounted
10321046
//
10331047
uint64_t m_minASBuildScratchSize = 0;
10341048
uint64_t m_maxASBuildScratchSize = 0;
1049+
core::bitflag<IGPUBuffer::E_USAGE_FLAGS> m_ASBuildScratchUsages = IGPUBuffer::E_USAGE_FLAGS::EUF_NONE;
10351050
//
10361051
core::bitflag<IQueue::FAMILY_FLAGS> m_queueFlags = IQueue::FAMILY_FLAGS::NONE;
10371052
};

0 commit comments

Comments
 (0)