Skip to content

Commit d9ddf41

Browse files
committed
Nuke code that won't be used (for now)
1 parent adc4d57 commit d9ddf41

File tree

7 files changed

+71
-116
lines changed

7 files changed

+71
-116
lines changed

include/nbl/builtin/hlsl/property_pool/copy.comp.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#include "nbl/builtin/hlsl/property_pool/transfer.hlsl"
44

55
// https://github.com/microsoft/DirectXShaderCompiler/issues/6144
6-
template<typename capability_traits=nbl::hlsl::jit::device_capabilities_traits>
7-
uint32_t3 nbl::hlsl::glsl::gl_WorkGroupSize() {
8-
return uint32_t3(capability_traits::maxOptimallyResidentWorkgroupInvocations, 1, 1);
9-
}
6+
// template<typename capability_traits=nbl::hlsl::jit::device_capabilities_traits>
7+
// uint32_t3 nbl::hlsl::glsl::gl_WorkGroupSize() {
8+
// return uint32_t3(capability_traits::maxOptimallyResidentWorkgroupInvocations, 1, 1);
9+
// }
1010

1111
[[numthreads(1, 1, 1)]
1212
void main(uint32_t3 dispatchId : SV_DispatchThreadID)

include/nbl/builtin/hlsl/property_pool/transfer.hlsl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef _NBL_BUILTIN_HLSL_GLSL_PROPERTY_POOLS_TRANSFER_
2+
#define _NBL_BUILTIN_HLSL_GLSL_PROPERTY_POOLS_TRANSFER_
3+
14
namespace nbl
25
{
36
namespace hlsl
@@ -30,7 +33,9 @@ struct GlobalPushContants
3033
// BDA address (GPU pointer) into the transfer commands buffer
3134
uint64_t transferCommandsAddress;
3235
};
33-
3436
}
3537
}
3638
}
39+
40+
#endif
41+

include/nbl/scene/ITransformTreeManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ class ITransformTreeManager : public virtual core::IReferenceCounted
253253
return true;
254254
}
255255

256+
#if 0 // TODO: upstreaming cpropertypoolhandler
256257
//
257258
struct UpstreamRequestBase : RequestBase
258259
{
@@ -496,6 +497,7 @@ class ITransformTreeManager : public virtual core::IReferenceCounted
496497
waitSemaphoreCount,semaphoresToWaitBeforeOverwrite,stagesToWaitForPerSemaphore,request.logger,maxWaitPoint
497498
);
498499
}
500+
#endif
499501

500502

501503

include/nbl/video/utilities/CPropertyPoolHandler.h

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,15 @@
1212
#include "nbl/video/utilities/IDescriptorSetCache.h"
1313
#include "nbl/video/utilities/IPropertyPool.h"
1414

15+
#include "glm/glm/glm.hpp"
16+
#include <nbl/builtin/hlsl/cpp_compat/matrix.hlsl>
17+
#include <nbl/builtin/hlsl/cpp_compat/vector.hlsl>
18+
#include "nbl/builtin/hlsl/property_pool/transfer.hlsl"
1519

1620
namespace nbl::video
1721
{
1822

19-
#define int int32_t
20-
#define uint uint32_t
21-
#include "nbl/builtin/glsl/property_pool/transfer.glsl"
22-
#undef uint
23-
#undef int
24-
static_assert(NBL_BUILTIN_PROPERTY_POOL_INVALID==IPropertyPool::invalid);
23+
//static_assert(NBL_BUILTIN_PROPERTY_POOL_INVALID==IPropertyPool::invalid);
2524

2625
// property pool factory is externally synchronized
2726
// TODO: could rename to CSparseStreamingSystem/CSparseStreamingHandler
@@ -36,30 +35,22 @@ class NBL_API2 CPropertyPoolHandler final : public core::IReferenceCounted, publ
3635
//
3736
inline ILogicalDevice* getDevice() {return m_device.get();}
3837

39-
//
40-
inline const uint32_t getMaxPropertiesPerTransferDispatch() {return m_maxPropertiesPerPass;}
41-
42-
//
43-
inline uint32_t getMaxScratchSize() const {return sizeof(nbl_glsl_property_pool_transfer_t)*m_maxPropertiesPerPass;}
44-
4538
//
4639
inline IGPUComputePipeline* getPipeline() {return m_pipeline.get();}
4740
inline const IGPUComputePipeline* getPipeline() const {return m_pipeline.get();}
4841

49-
//
50-
inline const IGPUDescriptorSetLayout* getCanonicalLayout() const { return m_dsCache->getCanonicalLayout(); }
51-
5242
//
5343
struct TransferRequest
5444
{
5545
//
5646
enum E_FLAG : uint16_t
5747
{
5848
EF_NONE=0,
59-
EF_DOWNLOAD=NBL_BUILTIN_PROPERTY_POOL_TRANSFER_EF_DOWNLOAD,
49+
// this wasn't used anywhere in the hlsl
50+
EF_DOWNLOAD=1,
6051
// this flag will make the `srcAddresses ? srcAddresses[0]:0` be used as the source address for all reads, effectively "filling" with uniform value
61-
EF_FILL=NBL_BUILTIN_PROPERTY_POOL_TRANSFER_EF_SRC_FILL,
62-
EF_BIT_COUNT=NBL_BUILTIN_PROPERTY_POOL_TRANSFER_EF_BIT_COUNT
52+
EF_FILL=2,
53+
EF_BIT_COUNT=3
6354
};
6455
//
6556
static inline constexpr uint32_t invalid_offset = ~0u;
@@ -71,9 +62,6 @@ class NBL_API2 CPropertyPoolHandler final : public core::IReferenceCounted, publ
7162
elementSize = pool->getPropertySize(propertyID);
7263
}
7364

74-
//
75-
inline bool isDownload() const {return flags&EF_DOWNLOAD;}
76-
7765
//
7866
inline uint32_t getSourceElementCount() const
7967
{
@@ -101,6 +89,7 @@ class NBL_API2 CPropertyPoolHandler final : public core::IReferenceCounted, publ
10189
system::logger_opt_ptr logger, const uint32_t baseDWORD=0u, const uint32_t endDWORD=~0ull
10290
);
10391

92+
#if 0 // TODO: Up streaming requests
10493
//
10594
struct UpStreamingRequest
10695
{
@@ -189,7 +178,9 @@ class NBL_API2 CPropertyPoolHandler final : public core::IReferenceCounted, publ
189178
uint32_t& waitSemaphoreCount, IGPUSemaphore* const*& semaphoresToWaitBeforeOverwrite, const asset::E_PIPELINE_STAGE_FLAGS*& stagesToWaitForPerSemaphore,
190179
system::logger_opt_ptr logger, const std::chrono::steady_clock::time_point& maxWaitPoint=std::chrono::steady_clock::now()+std::chrono::microseconds(500u)
191180
);
181+
#endif
192182

183+
#if 0 // TODO: freeing properties
193184
// utility to help you fill out the tail move scatter request after the free, properly, returns if you actually need to transfer anything
194185
static inline bool freeProperties(IPropertyPool* pool, UpStreamingRequest* requests, const uint32_t* indicesBegin, const uint32_t* indicesEnd, uint32_t* srcAddresses, uint32_t* dstAddresses)
195186
{
@@ -210,31 +201,18 @@ class NBL_API2 CPropertyPoolHandler final : public core::IReferenceCounted, publ
210201
}
211202
return false;
212203
}
204+
#endif
213205

214206
protected:
215207
~CPropertyPoolHandler() {}
216208

217-
static inline constexpr auto MaxPropertiesPerDispatch = NBL_BUILTIN_PROPERTY_POOL_MAX_PROPERTIES_PER_DISPATCH;
209+
static inline constexpr auto MaxPropertiesPerDispatch = 0u; // TODO
218210
static inline constexpr auto DescriptorCacheSize = 128u;
219211

220212

221213
core::smart_refctd_ptr<ILogicalDevice> m_device;
222214
core::smart_refctd_ptr<IGPUComputePipeline> m_pipeline;
223-
// TODO: investigate using Push Descriptors for this
224-
class TransferDescriptorSetCache : public IDescriptorSetCache
225-
{
226-
public:
227-
using IDescriptorSetCache::IDescriptorSetCache;
228-
229-
//
230-
uint32_t acquireSet(
231-
CPropertyPoolHandler* handler, const asset::SBufferBinding<video::IGPUBuffer>& scratch, const asset::SBufferBinding<video::IGPUBuffer>& addresses,
232-
const TransferRequest* requests, const uint32_t propertyCount
233-
);
234-
};
235-
core::smart_refctd_ptr<TransferDescriptorSetCache> m_dsCache;
236215

237-
uint16_t m_maxPropertiesPerPass;
238216
uint32_t m_alignment;
239217
};
240218

include/nbl/video/utilities/IPropertyPool.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
#include "nbl/video/ILogicalDevice.h"
1212
#include "nbl/video/IGPUDescriptorSetLayout.h"
1313

14+
#include "glm/glm/glm.hpp"
15+
#include <nbl/builtin/hlsl/cpp_compat/matrix.hlsl>
16+
#include <nbl/builtin/hlsl/cpp_compat/vector.hlsl>
17+
#include "nbl/builtin/hlsl/property_pool/transfer.hlsl"
18+
1419
namespace nbl::video
1520
{
1621

@@ -21,8 +26,7 @@ class NBL_API2 IPropertyPool : public core::IReferenceCounted
2126
public:
2227
using PropertyAddressAllocator = core::PoolAddressAllocatorST<uint32_t>;
2328

24-
static inline constexpr auto invalid = PropertyAddressAllocator::invalid_address;
25-
29+
static inline constexpr uint64_t invalid = 0;
2630
//
2731
virtual const asset::SBufferRange<IGPUBuffer>& getPropertyMemoryBlock(uint32_t ix) const =0;
2832

@@ -34,19 +38,19 @@ class NBL_API2 IPropertyPool : public core::IReferenceCounted
3438
inline bool isContiguous() const {return m_indexToAddr;}
3539

3640
//
37-
inline uint32_t getAllocated() const
41+
inline uint64_t getAllocated() const
3842
{
3943
return indexAllocator.get_allocated_size();
4044
}
4145

4246
//
43-
inline uint32_t getFree() const
47+
inline uint64_t getFree() const
4448
{
4549
return indexAllocator.get_free_size();
4650
}
4751

4852
//
49-
inline uint32_t getCapacity() const
53+
inline uint64_t getCapacity() const
5054
{
5155
// special case allows us to use `get_total_size`, because the pool allocator has no added offsets
5256
return indexAllocator.get_total_size();
@@ -217,8 +221,8 @@ class NBL_API2 IPropertyPool : public core::IReferenceCounted
217221
static bool validateBlocks(const ILogicalDevice* device, const uint32_t propertyCount, const size_t* propertySizes, const uint32_t capacity, const asset::SBufferRange<IGPUBuffer>* _memoryBlocks);
218222

219223
PropertyAddressAllocator indexAllocator;
220-
uint32_t* m_indexToAddr;
221-
uint32_t* m_addrToIndex;
224+
uint64_t* m_indexToAddr;
225+
uint64_t* m_addrToIndex;
222226
};
223227

224228

src/nbl/video/utilities/CPropertyPoolHandler.cpp

Lines changed: 33 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,32 @@ using namespace nbl;
66
using namespace video;
77

88
//
9-
CPropertyPoolHandler::CPropertyPoolHandler(core::smart_refctd_ptr<ILogicalDevice>&& device) : m_device(std::move(device)), m_dsCache()
9+
CPropertyPoolHandler::CPropertyPoolHandler(core::smart_refctd_ptr<ILogicalDevice>&& device) : m_device(std::move(device))
1010
{
11-
// TODO: rewrite in HLSL!
11+
auto system = m_device->getPhysicalDevice()->getSystem();
12+
// TODO: Reuse asset manager from elsewhere?
13+
auto assetManager = core::make_smart_refctd_ptr<asset::IAssetManager>(core::smart_refctd_ptr<system::ISystem>(system));
14+
15+
video::IGPUObjectFromAssetConverter CPU2GPU;
16+
video::IGPUObjectFromAssetConverter::SParams cpu2gpuParams;
17+
cpu2gpuParams.assetManager = assetManager.get();
18+
cpu2gpuParams.device = m_device.get();
19+
20+
auto loadShader = [&](const char* path)
21+
{
22+
asset::IAssetLoader::SAssetLoadParams params = {};
23+
auto shader = core::smart_refctd_ptr_static_cast<asset::ICPUSpecializedShader>(*assetManager->getAsset(path, params).getContents().begin());
24+
shader->setSpecializationInfo(asset::ISpecializedShader::SInfo(nullptr, nullptr, "main"));
25+
assert(shader);
26+
27+
auto gpuShaders = CPU2GPU.getGPUObjectsFromAssets(&shader, &shader + 1u, cpu2gpuParams);
28+
auto gpuShader = gpuShaders->begin()[0u];
29+
assert(gpuShader);
30+
31+
return gpuShader;
32+
};
33+
auto shader = loadShader("../../../include/nbl/builtin/hlsl/property_pool/copy.comp.hlsl");
34+
1235
#if 0
1336
const auto& deviceLimits = m_device->getPhysicalDevice()->getLimits();
1437
m_maxPropertiesPerPass = core::min<uint32_t>((deviceLimits.maxPerStageDescriptorSSBOs-2u)/2u,MaxPropertiesPerDispatch);
@@ -66,6 +89,7 @@ bool CPropertyPoolHandler::transferProperties(
6689
system::logger_opt_ptr logger, const uint32_t baseDWORD, const uint32_t endDWORD
6790
)
6891
{
92+
#if 0
6993
if (requestsBegin==requestsEnd)
7094
return true;
7195
if (!scratch.buffer || !scratch.buffer->getCreationParams().usage.hasFlags(IGPUBuffer::EUF_INLINE_UPDATE_VIA_CMDBUF))
@@ -180,15 +204,20 @@ bool CPropertyPoolHandler::transferProperties(
180204
result = copyPass(requests,leftOverProps)&&result;
181205

182206
return result;
207+
#endif
208+
return false;
183209
}
184210

211+
#if 0 // TODO: up streaming requests
212+
185213
uint32_t CPropertyPoolHandler::transferProperties(
186214
StreamingTransientDataBufferMT<>* const upBuff, IGPUCommandBuffer* const cmdbuf, IGPUFence* const fence, IGPUQueue* const queue,
187215
const asset::SBufferBinding<video::IGPUBuffer>& scratch, UpStreamingRequest* &requests, const uint32_t requestCount,
188216
uint32_t& waitSemaphoreCount, IGPUSemaphore* const*& semaphoresToWaitBeforeOverwrite, const asset::E_PIPELINE_STAGE_FLAGS*& stagesToWaitForPerSemaphore,
189217
system::logger_opt_ptr logger, const std::chrono::steady_clock::time_point& maxWaitPoint
190218
)
191219
{
220+
#if 0
192221
if (!requestCount)
193222
return 0u;
194223

@@ -526,72 +555,9 @@ uint32_t CPropertyPoolHandler::transferProperties(
526555
const auto leftOverProps = requestCount-fullPasses*m_maxPropertiesPerPass;
527556
if (leftOverProps)
528557
return copyPass(requests,leftOverProps);
558+
#endif
529559

530560
return 0u;
531561
}
532562

533-
uint32_t CPropertyPoolHandler::TransferDescriptorSetCache::acquireSet(
534-
CPropertyPoolHandler* handler, const asset::SBufferBinding<video::IGPUBuffer>& scratch, const asset::SBufferBinding<video::IGPUBuffer>& addresses,
535-
const TransferRequest* requests, const uint32_t propertyCount
536-
)
537-
{
538-
auto retval = IDescriptorSetCache::acquireSet();
539-
if (retval==IDescriptorSetCache::invalid_index)
540-
return IDescriptorSetCache::invalid_index;
541-
542-
543-
auto device = handler->getDevice();
544-
const auto maxPropertiesPerPass = handler->getMaxPropertiesPerTransferDispatch();
545-
546-
547-
IGPUDescriptorSet::SDescriptorInfo infos[MaxPropertiesPerDispatch*2u+2u];
548-
infos[0] = scratch;
549-
infos[0].info.buffer.size = sizeof(nbl_glsl_property_pool_transfer_t)*propertyCount;
550-
infos[1] = addresses;
551-
auto* inDescInfo = infos+2;
552-
auto* outDescInfo = infos+2+maxPropertiesPerPass;
553-
for (uint32_t i=0u; i<propertyCount; i++)
554-
{
555-
const auto& request = requests[i];
556-
557-
const auto& memblock = request.memblock;
558-
559-
// no not attempt to bind sized ranges of the buffers, remember that the copies are indexed, so the reads and writes may be scattered
560-
if (request.isDownload())
561-
{
562-
inDescInfo[i] = memblock;
563-
outDescInfo[i] = request.buffer;
564-
}
565-
else
566-
{
567-
inDescInfo[i] = request.buffer;
568-
outDescInfo[i] = memblock;
569-
}
570-
}
571-
// just to make Vulkan shut up
572-
for (uint32_t i=propertyCount; i<maxPropertiesPerPass; i++)
573-
{
574-
inDescInfo[i] = scratch;
575-
outDescInfo[i] = scratch;
576-
}
577-
IGPUDescriptorSet::SWriteDescriptorSet writes[4u];
578-
IGPUDescriptorSet* const set = IDescriptorSetCache::getSet(retval);
579-
for (auto i=0u; i<4u; i++)
580-
{
581-
writes[i].dstSet = set;
582-
writes[i].binding = i;
583-
writes[i].arrayElement = 0u;
584-
writes[i].descriptorType = asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER;
585-
}
586-
writes[0].count = 1u;
587-
writes[0].info = infos;
588-
writes[1].count = 1u;
589-
writes[1].info = infos+1u;
590-
writes[2].count = maxPropertiesPerPass;
591-
writes[2].info = inDescInfo;
592-
writes[3].count = maxPropertiesPerPass;
593-
writes[3].info = outDescInfo;
594-
device->updateDescriptorSets(4u, writes, 0u, nullptr);
595-
596-
return retval;
597-
}
563+
#endif

src/nbl/video/utilities/IPropertyPool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ IPropertyPool::IPropertyPool(uint32_t capacity, void* reserved, bool contiguous)
2020
{
2121
if (contiguous)
2222
{
23-
m_indexToAddr = reinterpret_cast<uint32_t*>(reinterpret_cast<uint8_t*>(reserved)+getReservedSize(capacity));
23+
m_indexToAddr = reinterpret_cast<uint64_t*>(reinterpret_cast<uint8_t*>(reserved)+getReservedSize(capacity));
2424
m_addrToIndex = m_indexToAddr+capacity;
2525

2626
std::fill_n(m_indexToAddr,capacity,invalid);

0 commit comments

Comments
 (0)