Skip to content

Commit ca211cc

Browse files
author
devsh
committed
cauterize the CAssetConverter changes (its still broken)
1 parent b9be039 commit ca211cc

File tree

2 files changed

+68
-10
lines changed

2 files changed

+68
-10
lines changed

include/nbl/video/utilities/CAssetConverter.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define _NBL_VIDEO_C_ASSET_CONVERTER_INCLUDED_
55

66

7+
#include "nbl/asset/utils/ISPIRVOptimizer.h"
78
#include "nbl/video/utilities/IUtilities.h"
89
#include "nbl/video/asset_traits.h"
910
#include "nbl/builtin/hlsl/cpp_compat.hlsl"
@@ -38,8 +39,10 @@ class CAssetConverter : public core::IReferenceCounted
3839
asset::ICPUSampler,
3940
asset::ICPUShader,
4041
asset::ICPUBuffer,
42+
#ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
4143
asset::ICPUBottomLevelAccelerationStructure,
4244
asset::ICPUTopLevelAccelerationStructure,
45+
#endif
4346
asset::ICPUImage,
4447
asset::ICPUBufferView,
4548
asset::ICPUImageView,
@@ -77,7 +80,8 @@ class CAssetConverter : public core::IReferenceCounted
7780
{
7881
using pass_e = asset::ISPIRVOptimizer::E_OPTIMIZER_PASS;
7982
// 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);
8185
}
8286
#endif
8387
return core::smart_refctd_ptr<CAssetConverter>(new CAssetConverter(std::move(params)),core::dont_grab);
@@ -192,6 +196,8 @@ class CAssetConverter : public core::IReferenceCounted
192196
retval.allowCompaction |= other.allowCompaction;
193197
retval.allowDataAccess |= other.allowDataAccess;
194198
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
195201
retval.hostBuild |= other.hostBuild;
196202
retval.compactAfterBuild |= other.compactAfterBuild;
197203
return {true,retval};
@@ -536,8 +542,10 @@ class CAssetConverter : public core::IReferenceCounted
536542
virtual const patch_t<asset::ICPUSampler>* operator()(const lookup_t<asset::ICPUSampler>&) const = 0;
537543
virtual const patch_t<asset::ICPUShader>* operator()(const lookup_t<asset::ICPUShader>&) const = 0;
538544
virtual const patch_t<asset::ICPUBuffer>* operator()(const lookup_t<asset::ICPUBuffer>&) const = 0;
545+
#ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
539546
virtual const patch_t<asset::ICPUBottomLevelAccelerationStructure>* operator()(const lookup_t<asset::ICPUBottomLevelAccelerationStructure>&) const = 0;
540547
virtual const patch_t<asset::ICPUTopLevelAccelerationStructure>* operator()(const lookup_t<asset::ICPUTopLevelAccelerationStructure>&) const = 0;
548+
#endif
541549
virtual const patch_t<asset::ICPUImage>* operator()(const lookup_t<asset::ICPUImage>&) const = 0;
542550
virtual const patch_t<asset::ICPUBufferView>* operator()(const lookup_t<asset::ICPUBufferView>&) const = 0;
543551
virtual const patch_t<asset::ICPUImageView>* operator()(const lookup_t<asset::ICPUImageView>&) const = 0;
@@ -799,7 +807,7 @@ class CAssetConverter : public core::IReferenceCounted
799807
return {};
800808
}
801809

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
803811
virtual inline std::span<const uint32_t> getSharedOwnershipQueueFamilies(const size_t groupCopyID, const asset::ICPUBottomLevelAccelerationStructure* blas, const patch_t<asset::ICPUBottomLevelAccelerationStructure>& patch) const
804812
{
805813
return {};
@@ -922,11 +930,13 @@ class CAssetConverter : public core::IReferenceCounted
922930
IUtilities* utilities = nullptr;
923931
// optional, last submit (compute, transfer if no compute needed) signals these in addition to the scratch semaphore
924932
std::span<const IQueue::SSubmitInfo::SSemaphoreInfo> extraSignalSemaphores = {};
933+
#ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
925934
// specific to Acceleration Structure Build, they need to be at least as large as the largest amount of scratch required for an AS build
926935
CAsyncSingleBufferSubAllocatorST</*TODO: try uint64_t GP Address Allocator*/>* scratchForDeviceASBuild = nullptr;
927936
std::pmr::memory_resource* scratchForHostASBuild = nullptr;
928937
// needs to service allocations without limit, unlike the above where failure will just force a flush and performance of already queued up builds
929938
IDeviceMemoryAllocator* compactedASAllocator = nullptr;
939+
#endif
930940
// specific to mip-map recomputation, these are okay defaults for the size of our Descriptor Indexed temporary descriptor set
931941
uint32_t sampledImageBindingCount = 1<<10;
932942
uint32_t storageImageBindingCount = 11<<10;
@@ -951,6 +961,7 @@ class CAssetConverter : public core::IReferenceCounted
951961
// https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCmdCopyBufferToImage.html#VUID-vkCmdCopyBufferToImage-commandBuffer-07739
952962
inline core::bitflag<IQueue::FAMILY_FLAGS> getRequiredQueueFlags() const {return m_queueFlags;}
953963

964+
#ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
954965
// 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.
955966
inline uint64_t getMinASBuildScratchSize(const bool forHostOps) const {return m_minASBuildScratchSize[forHostOps];}
956967
// 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
961972
inline bool willHostASBuild() const {return m_willHostBuildSomeAS;}
962973
// tells you if you need to provide a valid `SConvertParams::compactedASAllocator`
963974
inline bool willCompactAS() const {return m_willHostBuildSomeAS;}
975+
#endif
964976

965977
//
966978
inline operator bool() const {return bool(m_converter);}
@@ -1032,7 +1044,7 @@ class CAssetConverter : public core::IReferenceCounted
10321044
core::vector<SConvReqBuffer> m_bufferConversions;
10331045
struct SConvReqImage : SConversionRequestBase<asset::ICPUImage>
10341046
{
1035-
bool recomputeMips = 0;
1047+
uint16_t recomputeMips = 0;
10361048
};
10371049
core::vector<SConvReqImage> m_imageConversions;
10381050
template<typename CPUAccelerationStructure>// requires std::is_base_of_v<asset::ICPUAccelerationStructure,CPUAccelerationStructure>

0 commit comments

Comments
 (0)