Skip to content

Commit 11a141c

Browse files
author
devsh
committed
realize that scratches need to be provided separately for Device and Host builds
1 parent 0763416 commit 11a141c

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

include/nbl/video/utilities/CAssetConverter.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,9 @@ class CAssetConverter : public core::IReferenceCounted
923923
// optional, last submit (compute, transfer if no compute needed) signals these in addition to the scratch semaphore
924924
std::span<const IQueue::SSubmitInfo::SSemaphoreInfo> extraSignalSemaphores = {};
925925
// specific to Acceleration Structure Build, they need to be at least as large as the largest amount of scratch required for an AS build
926-
CAsyncSingleBufferSubAllocatorST<>* scratchForASBuild = nullptr;
927-
//
926+
CAsyncSingleBufferSubAllocatorST</*TODO: try uint64_t GP Address Allocator*/>* scratchForDeviceASBuild = nullptr;
927+
std::pmr::memory_resource* scratchForHostASBuild = nullptr;
928+
// needs to service allocations without limit, unlike the above where failure will just force a flush and performance of already queued up builds
928929
IDeviceMemoryAllocator* compactedASAllocator = nullptr;
929930
// specific to mip-map recomputation, these are okay defaults for the size of our Descriptor Indexed temporary descriptor set
930931
uint32_t sampledImageBindingCount = 1<<10;
@@ -950,12 +951,16 @@ class CAssetConverter : public core::IReferenceCounted
950951
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBufferToImage.html#VUID-vkCmdCopyBufferToImage-commandBuffer-07739
951952
inline core::bitflag<IQueue::FAMILY_FLAGS> getRequiredQueueFlags() const {return m_queueFlags;}
952953

953-
// just enough memory to build the Acceleration Structures one by one waiting for each build to complete inbetween
954-
inline uint64_t getMinASBuildScratchSize() const {return m_minASBuildScratchSize;}
955-
// enough memory to build and compact the all Acceleration Structures at once, obviously respecting order of BLAS (build->compact) -> TLAS (build->compact)
956-
inline uint64_t getMaxASBuildScratchSize() const {return m_maxASBuildScratchSize;}
957-
// if returns NONE means there are no acceleration structures to build
954+
// This is just enough memory to build the Acceleration Structures one by one waiting for each Device Build to complete inbetween. If 0 there are no Device AS Builds or Compactions to perform.
955+
inline uint64_t getMinASBuildScratchSize(const bool forHostOps) const {return m_minASBuildScratchSize[forHostOps];}
956+
// Enough memory to build and compact all the Acceleration Structures at once, obviously respecting order of BLAS (build->compact) -> TLAS (build->compact)
957+
inline uint64_t getMaxASBuildScratchSize(const bool forHostOps) const {return m_maxASBuildScratchSize[forHostOps];}
958+
// What usage flags your scratch buffer must have, if returns NONE means are no Device AS Builds to perform.
958959
inline auto getASBuildScratchUsages() const {return m_ASBuildScratchUsages;}
960+
// tells you if you need to provide a valid `SConvertParams::scratchForHostASBuild`
961+
inline bool willHostASBuild() const {return m_willHostBuildSomeAS;}
962+
// tells you if you need to provide a valid `SConvertParams::compactedASAllocator`
963+
inline bool willCompactAS() const {return m_willHostBuildSomeAS;}
959964

960965
//
961966
inline operator bool() const {return bool(m_converter);}
@@ -1028,6 +1033,7 @@ class CAssetConverter : public core::IReferenceCounted
10281033
//
10291034
struct ASBuildParams
10301035
{
1036+
// TODO: buildFlags
10311037
uint8_t host : 1;
10321038
uint8_t compact : 1;
10331039
} asBuildParams;
@@ -1044,9 +1050,12 @@ class CAssetConverter : public core::IReferenceCounted
10441050
core::tuple_transform_t<conversion_requests_t,convertible_asset_types> m_conversionRequests;
10451051

10461052
//
1047-
uint64_t m_minASBuildScratchSize = 0;
1048-
uint64_t m_maxASBuildScratchSize = 0;
1053+
uint64_t m_minASBuildScratchSize[2] = {0,0};
1054+
uint64_t m_maxASBuildScratchSize[2] = {0,0};
10491055
core::bitflag<IGPUBuffer::E_USAGE_FLAGS> m_ASBuildScratchUsages = IGPUBuffer::E_USAGE_FLAGS::EUF_NONE;
1056+
uint8_t m_willHostBuildSomeAS : 1 = false;
1057+
uint8_t m_willCompactSomeAS : 1 = false;
1058+
10501059
//
10511060
core::bitflag<IQueue::FAMILY_FLAGS> m_queueFlags = IQueue::FAMILY_FLAGS::NONE;
10521061
};

0 commit comments

Comments
 (0)