7
7
8
8
#include < nbl/video/IGPUMesh.h>
9
9
#include < nbl/video/IGPUDescriptorSetLayout.h>
10
- #include < nbl/asset/IMeshPackerV2.h>
11
- #include < nbl/asset/CCPUMeshPackerV2.h>
10
+ #include < nbl/asset/utils/ IMeshPackerV2.h>
11
+ #include < nbl/asset/utils/ CCPUMeshPackerV2.h>
12
12
13
13
using namespace nbl ::video;
14
14
@@ -18,91 +18,91 @@ namespace asset
18
18
{
19
19
20
20
template <typename MDIStructType = DrawElementsIndirectCommand_t>
21
- class CGPUMeshPackerV2 final : public IMeshPackerV2<video::IGPUBuffer, video::IGPUMeshBuffer, MDIStructType>
21
+ class CGPUMeshPackerV2 final : public IMeshPackerV2<video::IGPUBuffer,video::IGPUMeshBuffer,MDIStructType>
22
22
{
23
- using base_t = IMeshPackerV2<video::IGPUBuffer, video::IGPUMeshBuffer, MDIStructType>;
24
- using Triangle = typename base_t ::Triangle;
25
- using TriangleBatches = typename base_t ::TriangleBatches;
26
-
27
- public:
28
- using AllocationParams = IMeshPackerBase::AllocationParamsCommon;
29
- using PackerDataStore = typename base_t ::PackerDataStore;
30
- using ReservedAllocationMeshBuffers = typename base_t ::ReservedAllocationMeshBuffers;
31
- using AttribAllocParams = typename base_t ::AttribAllocParams;
32
-
33
- public:
34
- CGPUMeshPackerV2 (video::IVideoDriver* driver, const AllocationParams& allocParams, uint16_t minTriangleCountPerMDIData = 256u , uint16_t maxTriangleCountPerMDIData = 1024u )
35
- :IMeshPackerV2<video::IGPUBuffer, video::IGPUMeshBuffer, MDIStructType>(allocParams, minTriangleCountPerMDIData, maxTriangleCountPerMDIData),
36
- m_driver (driver)
37
- {}
38
-
39
- CGPUMeshPackerV2 (video::IVideoDriver* driver, const asset::CCPUMeshPackerV2<MDIStructType>& cpuMP)
40
- :IMeshPackerV2<video::IGPUBuffer, video::IGPUMeshBuffer, MDIStructType>(cpuMP.m_allocParams, cpuMP.m_minTriangleCountPerMDIData, cpuMP.m_maxTriangleCountPerMDIData),
41
- m_driver (driver)
42
- {
43
- m_virtualAttribConfig = cpuMP.m_virtualAttribConfig ;
44
-
45
- auto & cpuMDIBuff = cpuMP.m_packerDataStore .MDIDataBuffer ;
46
- auto & cpuIdxBuff = cpuMP.m_packerDataStore .indexBuffer ;
47
- auto & cpuVtxBuff = cpuMP.m_packerDataStore .vertexBuffer ;
48
-
49
- m_packerDataStore.MDIDataBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuMDIBuff->getSize (), cpuMDIBuff->getPointer ());
50
- m_packerDataStore.indexBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuMDIBuff->getSize (), cpuMDIBuff->getPointer ());
51
- m_packerDataStore.vertexBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuMDIBuff->getSize (), cpuMDIBuff->getPointer ());
52
- }
53
-
54
- CGPUMeshPackerV2 (video::IVideoDriver* driver, asset::CCPUMeshPackerV2<MDIStructType>&& cpuMP)
55
- :IMeshPackerV2<video::IGPUBuffer, video::IGPUMeshBuffer, MDIStructType>(cpuMP.m_allocParams, cpuMP.m_minTriangleCountPerMDIData, cpuMP.m_maxTriangleCountPerMDIData),
56
- m_driver (driver)
57
- {
58
- m_virtualAttribConfig = std::move (cpuMP.m_virtualAttribConfig );
59
-
60
- auto cpuMDIBuff = std::move (cpuMP.m_packerDataStore .MDIDataBuffer );
61
- auto cpuIdxBuff = std::move (cpuMP.m_packerDataStore .indexBuffer );
62
- auto cpuVtxBuff = std::move (cpuMP.m_packerDataStore .vertexBuffer );
63
-
64
- m_packerDataStore.MDIDataBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuMDIBuff->getSize (), cpuMDIBuff->getPointer ());
65
- m_packerDataStore.indexBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuIdxBuff->getSize (), cpuIdxBuff->getPointer ());
66
- m_packerDataStore.vertexBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuVtxBuff->getSize (), cpuVtxBuff->getPointer ());
67
-
68
- cpuMP.m_vtxBuffAlctr .reset ();
69
- cpuMP.m_idxBuffAlctr .reset ();
70
- cpuMP.m_MDIDataAlctr .reset ();
71
- }
72
-
73
-
74
- void instantiateDataStorage ();
75
-
76
- template <typename MeshBufferIterator>
77
- bool commit (IMeshPackerBase::PackedMeshBufferData* pmbdOut, ReservedAllocationMeshBuffers* rambIn, const MeshBufferIterator mbBegin, const MeshBufferIterator mbEnd);
78
-
79
- uint32_t getDSlayoutBindingsForUTB (IGPUDescriptorSetLayout::SBinding* outBindings, uint32_t fsamplersBinding = 0u , uint32_t isamplersBinding = 1u , uint32_t usamplersBinding = 2u ) const
80
- {
81
- return getDSlayoutBindingsForUTB_internal<IGPUDescriptorSetLayout>(outBindings, fsamplersBinding, isamplersBinding, usamplersBinding);
82
- }
83
-
84
- std::pair<uint32_t , uint32_t > getDescriptorSetWritesForUTB (IGPUDescriptorSet::SWriteDescriptorSet* outWrites, IGPUDescriptorSet::SDescriptorInfo* outInfo, IGPUDescriptorSet* dstSet, uint32_t fBuffersBinding = 0u , uint32_t iBuffersBinding = 1u , uint32_t uBuffersBinding = 2u ) const
85
- {
86
- auto createBufferView = [&](E_FORMAT format) -> core::smart_refctd_ptr<IGPUBufferView>
23
+ using base_t = IMeshPackerV2<video::IGPUBuffer,video::IGPUMeshBuffer,MDIStructType>;
24
+ using Triangle = typename base_t ::Triangle;
25
+ using TriangleBatches = typename base_t ::TriangleBatches;
26
+
27
+ public:
28
+ using AllocationParams = IMeshPackerBase::AllocationParamsCommon;
29
+ using PackerDataStore = typename base_t ::PackerDataStore;
30
+ using ReservedAllocationMeshBuffers = typename base_t ::ReservedAllocationMeshBuffers;
31
+ using AttribAllocParams = typename base_t ::AttribAllocParams;
32
+
33
+ public:
34
+ CGPUMeshPackerV2 (video::IVideoDriver* driver, const AllocationParams& allocParams, uint16_t minTriangleCountPerMDIData = 256u , uint16_t maxTriangleCountPerMDIData = 1024u )
35
+ :IMeshPackerV2<video::IGPUBuffer, video::IGPUMeshBuffer, MDIStructType>(allocParams, minTriangleCountPerMDIData, maxTriangleCountPerMDIData),
36
+ m_driver (driver)
37
+ {}
38
+
39
+ CGPUMeshPackerV2 (video::IVideoDriver* driver, const asset::CCPUMeshPackerV2<MDIStructType>& cpuMP)
40
+ :IMeshPackerV2<video::IGPUBuffer, video::IGPUMeshBuffer, MDIStructType>(cpuMP.m_allocParams, cpuMP.m_minTriangleCountPerMDIData, cpuMP.m_maxTriangleCountPerMDIData),
41
+ m_driver (driver)
87
42
{
88
- return m_driver->createGPUBufferView (m_packerDataStore.vertexBuffer .get (), format);
89
- };
43
+ m_virtualAttribConfig = cpuMP.m_virtualAttribConfig ;
90
44
91
- return getDescriptorSetWritesForUTB_internal<IGPUDescriptorSet, IGPUBufferView>(outWrites, outInfo, dstSet, createBufferView, fBuffersBinding , iBuffersBinding, uBuffersBinding);
92
- }
45
+ auto & cpuMDIBuff = cpuMP.m_packerDataStore .MDIDataBuffer ;
46
+ auto & cpuIdxBuff = cpuMP.m_packerDataStore .indexBuffer ;
47
+ auto & cpuVtxBuff = cpuMP.m_packerDataStore .vertexBuffer ;
93
48
94
- uint32_t getDSlayoutBindingsForSSBO (IGPUDescriptorSetLayout::SBinding* outBindings, uint32_t uintBufferBinding = 0u , uint32_t uvec2BufferBinding = 1u , uint32_t uvec3BufferBinding = 2u , uint32_t uvec4BufferBinding = 3u ) const
95
- {
96
- return getDSlayoutBindingsForSSBO_internal<IGPUDescriptorSetLayout>(outBindings, uintBufferBinding, uvec2BufferBinding, uvec3BufferBinding, uvec4BufferBinding );
97
- }
49
+ m_packerDataStore. MDIDataBuffer = driver-> createFilledDeviceLocalGPUBufferOnDedMem (cpuMDIBuff-> getSize (), cpuMDIBuff-> getPointer ());
50
+ m_packerDataStore. indexBuffer = driver-> createFilledDeviceLocalGPUBufferOnDedMem (cpuMDIBuff-> getSize (), cpuMDIBuff-> getPointer ());
51
+ m_packerDataStore. vertexBuffer = driver-> createFilledDeviceLocalGPUBufferOnDedMem (cpuMDIBuff-> getSize (), cpuMDIBuff-> getPointer () );
52
+ }
98
53
99
- uint32_t getDescriptorSetWritesForSSBO (IGPUDescriptorSet::SWriteDescriptorSet* outWrites, IGPUDescriptorSet::SDescriptorInfo* outInfo, IGPUDescriptorSet* dstSet, uint32_t uintBufferBinding = 0u , uint32_t uvec2BufferBinding = 1u , uint32_t uvec3BufferBinding = 2u , uint32_t uvec4BufferBinding = 3u ) const
100
- {
101
- return getDescriptorSetWritesForSSBO_internal<IGPUDescriptorSet>(outWrites, outInfo, dstSet, m_packerDataStore.vertexBuffer , uintBufferBinding, uvec2BufferBinding, uvec3BufferBinding, uvec4BufferBinding);
102
- }
54
+ CGPUMeshPackerV2 (video::IVideoDriver* driver, asset::CCPUMeshPackerV2<MDIStructType>&& cpuMP)
55
+ :IMeshPackerV2<video::IGPUBuffer, video::IGPUMeshBuffer, MDIStructType>(cpuMP.m_allocParams, cpuMP.m_minTriangleCountPerMDIData, cpuMP.m_maxTriangleCountPerMDIData),
56
+ m_driver (driver)
57
+ {
58
+ m_virtualAttribConfig = std::move (cpuMP.m_virtualAttribConfig );
59
+
60
+ auto cpuMDIBuff = std::move (cpuMP.m_packerDataStore .MDIDataBuffer );
61
+ auto cpuIdxBuff = std::move (cpuMP.m_packerDataStore .indexBuffer );
62
+ auto cpuVtxBuff = std::move (cpuMP.m_packerDataStore .vertexBuffer );
63
+
64
+ m_packerDataStore.MDIDataBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuMDIBuff->getSize (), cpuMDIBuff->getPointer ());
65
+ m_packerDataStore.indexBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuIdxBuff->getSize (), cpuIdxBuff->getPointer ());
66
+ m_packerDataStore.vertexBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem (cpuVtxBuff->getSize (), cpuVtxBuff->getPointer ());
67
+
68
+ cpuMP.m_vtxBuffAlctr .reset ();
69
+ cpuMP.m_idxBuffAlctr .reset ();
70
+ cpuMP.m_MDIDataAlctr .reset ();
71
+ }
72
+
73
+
74
+ void instantiateDataStorage ();
75
+
76
+ template <typename MeshBufferIterator>
77
+ bool commit (IMeshPackerBase::PackedMeshBufferData* pmbdOut, ReservedAllocationMeshBuffers* rambIn, const MeshBufferIterator mbBegin, const MeshBufferIterator mbEnd);
78
+
79
+ uint32_t getDSlayoutBindingsForUTB (IGPUDescriptorSetLayout::SBinding* outBindings, uint32_t fsamplersBinding = 0u , uint32_t isamplersBinding = 1u , uint32_t usamplersBinding = 2u ) const
80
+ {
81
+ return getDSlayoutBindingsForUTB_internal<IGPUDescriptorSetLayout>(outBindings, fsamplersBinding, isamplersBinding, usamplersBinding);
82
+ }
83
+
84
+ std::pair<uint32_t , uint32_t > getDescriptorSetWritesForUTB (IGPUDescriptorSet::SWriteDescriptorSet* outWrites, IGPUDescriptorSet::SDescriptorInfo* outInfo, IGPUDescriptorSet* dstSet, uint32_t fBuffersBinding = 0u , uint32_t iBuffersBinding = 1u , uint32_t uBuffersBinding = 2u ) const
85
+ {
86
+ auto createBufferView = [&](E_FORMAT format) -> core::smart_refctd_ptr<IGPUBufferView>
87
+ {
88
+ return m_driver->createGPUBufferView (m_packerDataStore.vertexBuffer .get (), format);
89
+ };
90
+
91
+ return getDescriptorSetWritesForUTB_internal<IGPUDescriptorSet, IGPUBufferView>(outWrites, outInfo, dstSet, createBufferView, fBuffersBinding , iBuffersBinding, uBuffersBinding);
92
+ }
93
+
94
+ uint32_t getDSlayoutBindingsForSSBO (IGPUDescriptorSetLayout::SBinding* outBindings, uint32_t uintBufferBinding = 0u , uint32_t uvec2BufferBinding = 1u , uint32_t uvec3BufferBinding = 2u , uint32_t uvec4BufferBinding = 3u ) const
95
+ {
96
+ return getDSlayoutBindingsForSSBO_internal<IGPUDescriptorSetLayout>(outBindings, uintBufferBinding, uvec2BufferBinding, uvec3BufferBinding, uvec4BufferBinding);
97
+ }
98
+
99
+ uint32_t getDescriptorSetWritesForSSBO (IGPUDescriptorSet::SWriteDescriptorSet* outWrites, IGPUDescriptorSet::SDescriptorInfo* outInfo, IGPUDescriptorSet* dstSet, uint32_t uintBufferBinding = 0u , uint32_t uvec2BufferBinding = 1u , uint32_t uvec3BufferBinding = 2u , uint32_t uvec4BufferBinding = 3u ) const
100
+ {
101
+ return getDescriptorSetWritesForSSBO_internal<IGPUDescriptorSet>(outWrites, outInfo, dstSet, m_packerDataStore.vertexBuffer , uintBufferBinding, uvec2BufferBinding, uvec3BufferBinding, uvec4BufferBinding);
102
+ }
103
103
104
- private:
105
- video::IVideoDriver* m_driver;
104
+ private:
105
+ video::IVideoDriver* m_driver;
106
106
107
107
};
108
108
0 commit comments