Skip to content

Commit 16fff5a

Browse files
friendship with CGPUMeshPackerV2 ended, now Salman is CCPUMeshPackerV2's best friend.
1 parent bd3ebf2 commit 16fff5a

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

include/nbl/asset/utils/CCPUMeshPackerV2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CCPUMeshPackerV2 final : public IMeshPackerV2<ICPUBuffer,ICPUDescriptorSet
3030

3131
public:
3232
CCPUMeshPackerV2(const AllocationParams& allocParams, uint16_t minTriangleCountPerMDIData = 256u, uint16_t maxTriangleCountPerMDIData = 1024u)
33-
:IMeshPackerV2<ICPUBuffer, ICPUMeshBuffer, MDIStructType>(allocParams, minTriangleCountPerMDIData, maxTriangleCountPerMDIData)
33+
: base_t(allocParams,minTriangleCountPerMDIData,maxTriangleCountPerMDIData)
3434
{}
3535

3636
void instantiateDataStorage();

include/nbl/asset/utils/IMeshPackerV2.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,12 @@ class IMeshPackerV2Base
222222
}
223223
};
224224

225+
IMeshPackerV2Base() : m_virtualAttribConfig() {}
226+
explicit IMeshPackerV2Base(const VirtualAttribConfig& cfg) : m_virtualAttribConfig()
227+
{
228+
m_virtualAttribConfig = cfg;
229+
}
230+
225231
VirtualAttribConfig m_virtualAttribConfig;
226232
};
227233

@@ -358,7 +364,7 @@ class IMeshPackerV2 : public IMeshPacker<MeshBufferType,MDIStructType>, public I
358364
std::function<core::smart_refctd_ptr<IDescriptor>(E_FORMAT)> createBufferView, const DSLayoutParamsUTB& params = {}
359365
) const
360366
{
361-
const uint32_t writeCount = getDSlayoutBindingsForUTB_internal(nullptr);
367+
const uint32_t writeCount = getDSlayoutBindingsForUTB(nullptr);
362368
const uint32_t infoCount = 1u + // for the index buffer
363369
m_virtualAttribConfig.uintArrayElementsCnt +
364370
m_virtualAttribConfig.floatArrayElementsCnt +
@@ -391,33 +397,33 @@ class IMeshPackerV2 : public IMeshPacker<MeshBufferType,MDIStructType>, public I
391397
};
392398

393399
auto* write = outWrites;
394-
auto writeBinding = [&bnd,dstSet,&info](uint32_t binding, uint32_t count)
400+
auto writeBinding = [&write,dstSet,&info](uint32_t binding, uint32_t count)
395401
{
396402
write->binding = binding;
397403
write->arrayElement = 0u;
398404
write->count = count;
399405
write->descriptorType = asset::EDT_UNIFORM_TEXEL_BUFFER;
400406
write->dstSet = dstSet;
401407
write->info = info;
402-
write++
408+
write++;
403409
};
404410

405411
writeBinding(params.usamplersBinding,1u+m_virtualAttribConfig.uintArrayElementsCnt);
406412
if (m_virtualAttribConfig.uintArrayElementsCnt)
407-
fillInfoStruct(EUAT_INT);
413+
fillInfoStruct(E_UTB_ARRAY_TYPE::EUAT_UINT);
408414
info->desc = createBufferView(EF_R16G16_UINT);
409415
info->buffer.offset = 0u;
410416
info->buffer.size = m_packerDataStore.indexBuffer->getSize();
411417
info++;
412418
if (m_virtualAttribConfig.floatArrayElementsCnt)
413419
{
414420
writeBinding(params.fsamplersBinding,1u+m_virtualAttribConfig.floatArrayElementsCnt);
415-
fillInfoStruct(EUAT_FLOAT);
421+
fillInfoStruct(E_UTB_ARRAY_TYPE::EUAT_FLOAT);
416422
}
417423
if (m_virtualAttribConfig.intArrayElementsCnt)
418424
{
419425
writeBinding(params.isamplersBinding,1u+m_virtualAttribConfig.intArrayElementsCnt);
420-
fillInfoStruct(EUAT_INT);
426+
fillInfoStruct(E_UTB_ARRAY_TYPE::EUAT_INT);
421427
}
422428

423429
return std::make_pair(writeCount, infoCount);
@@ -566,8 +572,13 @@ class IMeshPackerV2 : public IMeshPacker<MeshBufferType,MDIStructType>, public I
566572

567573
protected:
568574
IMeshPackerV2(const AllocationParams& allocParams, uint16_t minTriangleCountPerMDIData, uint16_t maxTriangleCountPerMDIData)
569-
:base_t(minTriangleCountPerMDIData, maxTriangleCountPerMDIData),
570-
m_allocParams(allocParams)
575+
: base_t(minTriangleCountPerMDIData, maxTriangleCountPerMDIData), m_allocParams(allocParams)
576+
{
577+
initializeCommonAllocators(allocParams);
578+
};
579+
template<class OtherBufferType, class OtherDescriptorSetType, class OtherMeshBufferType>
580+
explicit IMeshPackerV2(const IMeshPackerV2<OtherBufferType,OtherDescriptorSetType,OtherMeshBufferType,MDIStructType>* otherMp)
581+
: base_t(cpuMP->m_minTriangleCountPerMDIData,cpuMP->m_maxTriangleCountPerMDIData), IMeshPackerV2Base(cpuMP->m_virtualAttribConfig), m_allocParams(otherMp->m_allocParams)
571582
{
572583
initializeCommonAllocators(allocParams);
573584
};

include/nbl/video/CGPUMeshPackerV2.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,21 @@ class CGPUMeshPackerV2 final : public asset::IMeshPackerV2<IGPUBuffer,IGPUDescri
3232

3333
public:
3434
CGPUMeshPackerV2(IVideoDriver* driver, const AllocationParams& allocParams, uint16_t minTriangleCountPerMDIData = 256u, uint16_t maxTriangleCountPerMDIData = 1024u)
35-
:IMeshPackerV2<IGPUBuffer, IGPUMeshBuffer, MDIStructType>(allocParams, minTriangleCountPerMDIData, maxTriangleCountPerMDIData),
36-
m_driver(driver)
35+
: base_t(allocParams,minTriangleCountPerMDIData,maxTriangleCountPerMDIData), m_driver(driver)
3736
{}
3837

3938
// TODO: protect against empty cpuMP (no allocations and then shrinked)
4039
CGPUMeshPackerV2(IVideoDriver* driver, const asset::CCPUMeshPackerV2<MDIStructType>* cpuMP)
41-
:IMeshPackerV2<IGPUBuffer,IGPUMeshBuffer,MDIStructType>(cpuMP->m_allocParams,cpuMP->m_minTriangleCountPerMDIData,cpuMP->m_maxTriangleCountPerMDIData),
42-
m_driver(driver)
40+
: base_t(cpuMP), m_driver(driver)
4341
{
44-
m_virtualAttribConfig = cpuMP->m_virtualAttribConfig;
45-
46-
auto& cpuMDIBuff = cpuMP->m_packerDataStore.MDIDataBuffer;
47-
auto& cpuIdxBuff = cpuMP->m_packerDataStore.indexBuffer;
48-
auto& cpuVtxBuff = cpuMP->m_packerDataStore.vertexBuffer;
42+
// TODO: protect against unitiliazed storage of cpuMP
43+
auto& cpuMDIBuff = cpuMP->getPackerDataStore().MDIDataBuffer;
44+
auto& cpuIdxBuff = cpuMP->getPackerDataStore().indexBuffer;
45+
auto& cpuVtxBuff = cpuMP->getPackerDataStore().vertexBuffer;
4946

5047
// TODO: why are the allocators not copied!?
5148

52-
// TODO: call instantiateDataStorage() here and then copy CPU data to the initialized storage
49+
// TODO: call this->instantiateDataStorage() here and then copy CPU data to the initialized storage
5350
m_packerDataStore.MDIDataBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem(cpuMDIBuff->getSize(), cpuMDIBuff->getPointer());
5451
m_packerDataStore.indexBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem(cpuMDIBuff->getSize(), cpuMDIBuff->getPointer());
5552
m_packerDataStore.vertexBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem(cpuMDIBuff->getSize(), cpuMDIBuff->getPointer());

0 commit comments

Comments
 (0)