4
4
#define _NBL_VIDEO_C_ASSET_CONVERTER_INCLUDED_
5
5
6
6
7
+ #include " nbl/asset/utils/ISPIRVOptimizer.h"
7
8
#include " nbl/video/utilities/IUtilities.h"
8
9
#include " nbl/video/asset_traits.h"
9
10
#include " nbl/builtin/hlsl/cpp_compat.hlsl"
@@ -38,8 +39,10 @@ class CAssetConverter : public core::IReferenceCounted
38
39
asset::ICPUSampler,
39
40
asset::ICPUShader,
40
41
asset::ICPUBuffer,
42
+ #ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
41
43
asset::ICPUBottomLevelAccelerationStructure,
42
44
asset::ICPUTopLevelAccelerationStructure,
45
+ #endif
43
46
asset::ICPUImage,
44
47
asset::ICPUBufferView,
45
48
asset::ICPUImageView,
@@ -77,7 +80,8 @@ class CAssetConverter : public core::IReferenceCounted
77
80
{
78
81
using pass_e = asset::ISPIRVOptimizer::E_OPTIMIZER_PASS;
79
82
// shall we do others?
80
- params.optimizer = core::make_smart_rectd_ptr<asset::ISPIRVOptimizer>({EOP_STRIP_DEBUG_INFO});
83
+ const pass_e passes[] = {pass_e::EOP_STRIP_DEBUG_INFO};
84
+ params.optimizer = core::make_smart_refctd_ptr<asset::ISPIRVOptimizer>(passes);
81
85
}
82
86
#endif
83
87
return core::smart_refctd_ptr<CAssetConverter>(new CAssetConverter (std::move (params)),core::dont_grab);
@@ -192,6 +196,8 @@ class CAssetConverter : public core::IReferenceCounted
192
196
retval.allowCompaction |= other.allowCompaction ;
193
197
retval.allowDataAccess |= other.allowDataAccess ;
194
198
retval.lowMemory |= other.lowMemory ;
199
+ // Host Builds are presumed to be "beter quality" and lower staging resource pressure,
200
+ // we may change the behaviour here in the future
195
201
retval.hostBuild |= other.hostBuild ;
196
202
retval.compactAfterBuild |= other.compactAfterBuild ;
197
203
return {true ,retval};
@@ -536,8 +542,10 @@ class CAssetConverter : public core::IReferenceCounted
536
542
virtual const patch_t <asset::ICPUSampler>* operator ()(const lookup_t <asset::ICPUSampler>&) const = 0;
537
543
virtual const patch_t <asset::ICPUShader>* operator ()(const lookup_t <asset::ICPUShader>&) const = 0;
538
544
virtual const patch_t <asset::ICPUBuffer>* operator ()(const lookup_t <asset::ICPUBuffer>&) const = 0;
545
+ #ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
539
546
virtual const patch_t <asset::ICPUBottomLevelAccelerationStructure>* operator ()(const lookup_t <asset::ICPUBottomLevelAccelerationStructure>&) const = 0;
540
547
virtual const patch_t <asset::ICPUTopLevelAccelerationStructure>* operator ()(const lookup_t <asset::ICPUTopLevelAccelerationStructure>&) const = 0;
548
+ #endif
541
549
virtual const patch_t <asset::ICPUImage>* operator ()(const lookup_t <asset::ICPUImage>&) const = 0;
542
550
virtual const patch_t <asset::ICPUBufferView>* operator ()(const lookup_t <asset::ICPUBufferView>&) const = 0;
543
551
virtual const patch_t <asset::ICPUImageView>* operator ()(const lookup_t <asset::ICPUImageView>&) const = 0;
@@ -799,7 +807,7 @@ class CAssetConverter : public core::IReferenceCounted
799
807
return {};
800
808
}
801
809
802
- // this a weird signature, but its for an acceleration structure backing IGPUBuffer
810
+ // this a weird signature, but its for the IGPUBuffer backing an acceleration structure
803
811
virtual inline std::span<const uint32_t > getSharedOwnershipQueueFamilies (const size_t groupCopyID, const asset::ICPUBottomLevelAccelerationStructure* blas, const patch_t <asset::ICPUBottomLevelAccelerationStructure>& patch) const
804
812
{
805
813
return {};
@@ -922,11 +930,13 @@ class CAssetConverter : public core::IReferenceCounted
922
930
IUtilities* utilities = nullptr ;
923
931
// optional, last submit (compute, transfer if no compute needed) signals these in addition to the scratch semaphore
924
932
std::span<const IQueue::SSubmitInfo::SSemaphoreInfo> extraSignalSemaphores = {};
933
+ #ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
925
934
// 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
935
CAsyncSingleBufferSubAllocatorST</* TODO: try uint64_t GP Address Allocator*/ >* scratchForDeviceASBuild = nullptr ;
927
936
std::pmr::memory_resource* scratchForHostASBuild = nullptr ;
928
937
// needs to service allocations without limit, unlike the above where failure will just force a flush and performance of already queued up builds
929
938
IDeviceMemoryAllocator* compactedASAllocator = nullptr ;
939
+ #endif
930
940
// specific to mip-map recomputation, these are okay defaults for the size of our Descriptor Indexed temporary descriptor set
931
941
uint32_t sampledImageBindingCount = 1 <<10 ;
932
942
uint32_t storageImageBindingCount = 11 <<10 ;
@@ -951,6 +961,7 @@ class CAssetConverter : public core::IReferenceCounted
951
961
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBufferToImage.html#VUID-vkCmdCopyBufferToImage-commandBuffer-07739
952
962
inline core::bitflag<IQueue::FAMILY_FLAGS> getRequiredQueueFlags () const {return m_queueFlags;}
953
963
964
+ #ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
954
965
// 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
966
inline uint64_t getMinASBuildScratchSize (const bool forHostOps) const {return m_minASBuildScratchSize[forHostOps];}
956
967
// Enough memory to build and compact all the Acceleration Structures at once, obviously respecting order of BLAS (build->compact) -> TLAS (build->compact)
@@ -961,6 +972,7 @@ class CAssetConverter : public core::IReferenceCounted
961
972
inline bool willHostASBuild () const {return m_willHostBuildSomeAS;}
962
973
// tells you if you need to provide a valid `SConvertParams::compactedASAllocator`
963
974
inline bool willCompactAS () const {return m_willHostBuildSomeAS;}
975
+ #endif
964
976
965
977
//
966
978
inline operator bool () const {return bool (m_converter);}
@@ -1032,7 +1044,7 @@ class CAssetConverter : public core::IReferenceCounted
1032
1044
core::vector<SConvReqBuffer> m_bufferConversions;
1033
1045
struct SConvReqImage : SConversionRequestBase<asset::ICPUImage>
1034
1046
{
1035
- bool recomputeMips = 0 ;
1047
+ uint16_t recomputeMips = 0 ;
1036
1048
};
1037
1049
core::vector<SConvReqImage> m_imageConversions;
1038
1050
template <typename CPUAccelerationStructure>// requires std::is_base_of_v<asset::ICPUAccelerationStructure,CPUAccelerationStructure>
0 commit comments