Skip to content

Commit 31c9a61

Browse files
author
devsh
committed
simplify the Conversion ReserveResult API
1 parent 9a998cb commit 31c9a61

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

include/nbl/video/utilities/CAssetConverter.h

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -965,34 +965,27 @@ class CAssetConverter : public core::IReferenceCounted
965965
inline uint64_t getMinASBuildScratchSize(const bool forHostOps) const
966966
{
967967
assert(m_minASBuildScratchSize[forHostOps]<=m_maxASBuildScratchSize[forHostOps]);
968-
assert((forHostOps ? willHostASBuild():willDeviceASBuild()) == (m_maxASBuildScratchSize[forHostOps]>0));
969968
return m_minASBuildScratchSize[forHostOps];
970969
}
971970
// Enough memory to build and compact all the Acceleration Structures at once, obviously respecting order of BLAS (build->compact) -> TLAS (build->compact)
972971
inline uint64_t getMaxASBuildScratchSize(const bool forHostOps) const
973972
{
974973
assert(m_minASBuildScratchSize[forHostOps]<=m_maxASBuildScratchSize[forHostOps]);
975-
assert((forHostOps ? willHostASBuild():willDeviceASBuild()) == (m_maxASBuildScratchSize[forHostOps]>0));
976974
return m_maxASBuildScratchSize[forHostOps];
977975
}
978-
// What usage flags your scratch buffer must have, if returns NONE means are no Device AS Builds to perform.
979-
inline auto getASBuildScratchUsages() const
980-
{
981-
assert((m_ASBuildScratchUsages!=IGPUBuffer::E_USAGE_FLAGS::EUF_NONE)==willDeviceASBuild());
982-
return m_ASBuildScratchUsages;
983-
}
984976
// tells you if you need to provide a valid `SConvertParams::scratchForDeviceASBuild`
985-
inline bool willDeviceASBuild() const {return m_willDeviceBuildSomeAS;}
977+
inline bool willDeviceASBuild() const {return getMinASBuildScratchSize(false)>0;}
986978
// tells you if you need to provide a valid `SConvertParams::scratchForHostASBuild`
987979
inline bool willHostASBuild() const
988980
{
989-
assert(m_willHostBuildSomeAS==false); // host builds not supported yet
990-
return m_willHostBuildSomeAS;
981+
const bool retval = getMinASBuildScratchSize(true)>0;
982+
assert(!retval); // host builds not supported yet
983+
return retval;
991984
}
992985
// tells you if you need to provide a valid `SConvertParams::compactedASAllocator`
993986
inline bool willCompactAS() const
994987
{
995-
assert((willDeviceASBuild()||willHostASBuild())==m_willCompactSomeAS);
988+
assert(!m_willCompactSomeAS || willDeviceASBuild() || willHostASBuild());
996989
return m_willCompactSomeAS;
997990
}
998991

@@ -1089,11 +1082,7 @@ class CAssetConverter : public core::IReferenceCounted
10891082
// 0 for device builds, 1 for host builds
10901083
uint64_t m_minASBuildScratchSize[2] = {0,0};
10911084
uint64_t m_maxASBuildScratchSize[2] = {0,0};
1092-
// is there even more than one usage needed?
1093-
core::bitflag<IGPUBuffer::E_USAGE_FLAGS> m_ASBuildScratchUsages = IGPUBuffer::E_USAGE_FLAGS::EUF_NONE;
1094-
// TODO: do we need those bools?
1095-
uint8_t m_willDeviceBuildSomeAS : 1 = false;
1096-
uint8_t m_willHostBuildSomeAS : 1 = false;
1085+
// We do all compactions on the Device for simplicity
10971086
uint8_t m_willCompactSomeAS : 1 = false;
10981087

10991088
//

src/nbl/video/utilities/CAssetConverter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,17 +3462,15 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
34623462
}
34633463
}
34643464

3465-
#ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
34663465
// check things necessary for building Acceleration Structures
3467-
using buffer_usage_f = IGPUBuffer::E_USAGE_FLAGS;
3468-
if (reservations.m_ASBuildScratchUsages!=buffer_usage_f::EUF_NONE)
3466+
if (reservations.willDeviceASBuild())
34693467
{
34703468
if (!params.scratchForDeviceASBuild)
34713469
{
34723470
logger.log("An Acceleration Structure will be built on Device but no scratch allocator provided!",system::ILogger::ELL_ERROR);
34733471
return retval;
34743472
}
3475-
// TODO: do the build input buffers also need `EUF_STORAGE_BUFFER_BIT` ?
3473+
using buffer_usage_f = IGPUBuffer::E_USAGE_FLAGS;
34763474
constexpr buffer_usage_f asBuildInputFlags = buffer_usage_f::EUF_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT|buffer_usage_f::EUF_TRANSFER_DST_BIT|buffer_usage_f::EUF_SHADER_DEVICE_ADDRESS_BIT;
34773475
// we may use the staging buffer directly to skip an extra copy on small enough geometries
34783476
if (!params.utilities->getDefaultUpStreamingBuffer()->getBuffer()->getCreationParams().usage.hasFlags(asBuildInputFlags))
@@ -3496,7 +3494,7 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
34963494
}
34973495
}
34983496
// the elusive and exotic host builds
3499-
if (reservations.m_willHostBuildSomeAS && !params.scratchForHostASBuild)
3497+
if (reservations.willHostASBuild() && !params.scratchForHostASBuild)
35003498
{
35013499
logger.log("An Acceleration Structure will be built on the Host but no Scratch Memory Allocator provided!", system::ILogger::ELL_ERROR);
35023500
return retval;
@@ -3507,7 +3505,6 @@ ISemaphore::future_t<IQueue::RESULT> CAssetConverter::convert_impl(SReserveResul
35073505
logger.log("An Acceleration Structure will be compacted but no Device Memory Allocator provided!", system::ILogger::ELL_ERROR);
35083506
return retval;
35093507
}
3510-
#endif
35113508

35123509
//
35133510
auto findInStaging = [&reservations]<Asset AssetType>(const typename asset_traits<AssetType>::video_t* gpuObj)->core::blake3_hash_t*

0 commit comments

Comments
 (0)