Skip to content

Commit 14f7c4a

Browse files
committed
Correction
1 parent 89ec473 commit 14f7c4a

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

include/nbl/asset/utils/IMeshPackerV2.h

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -591,40 +591,6 @@ class IMeshPackerV2 : public IMeshPacker<MeshBufferType,MDIStructType>, public I
591591
template <typename MeshBufferIterator>
592592
bool alloc(ReservedAllocationMeshBuffers* rambOut, const MeshBufferIterator mbBegin, const MeshBufferIterator mbEnd);
593593

594-
template <typename MeshBufferIterator>
595-
void freeAllocatedAddressesOnAllocFail(ReservedAllocationMeshBuffers* rambOut, const MeshBufferIterator mbBegin, const MeshBufferIterator mbEnd)
596-
{
597-
size_t i = 0ull;
598-
for (auto it = mbBegin; it != mbEnd; it++)
599-
{
600-
ReservedAllocationMeshBuffers& ramb = *(rambOut + i);
601-
602-
if (ramb.indexAllocationOffset == INVALID_ADDRESS)
603-
return;
604-
605-
m_idxBuffAlctr.free_addr(ramb.indexAllocationOffset, ramb.indexAllocationReservedCnt);
606-
607-
const auto& mbVtxInputParams = (*it)->getPipeline()->getVertexInputParams();
608-
for (uint16_t attrBit = 0x0001, location = 0; location < SVertexInputParams::MAX_ATTR_BUF_BINDING_COUNT; attrBit <<= 1, location++)
609-
{
610-
if (!(attrBit & mbVtxInputParams.enabledAttribFlags))
611-
continue;
612-
613-
if (ramb.attribAllocParams[location].offset == INVALID_ADDRESS)
614-
return;
615-
616-
m_vtxBuffAlctr.free_addr(ramb.attribAllocParams[location].offset, ramb.attribAllocParams[location].size);
617-
}
618-
619-
if (ramb.mdiAllocationOffset == INVALID_ADDRESS)
620-
return;
621-
622-
m_MDIDataAlctr.free_addr(ramb.mdiAllocationOffset, ramb.mdiAllocationReservedCnt);
623-
624-
i++;
625-
}
626-
}
627-
628594
void free(const ReservedAllocationMeshBuffers* rambIn, uint32_t meshBuffersToFreeCnt)
629595
{
630596
for (uint32_t i = 0u; i < meshBuffersToFreeCnt; i++)
@@ -671,6 +637,40 @@ class IMeshPackerV2 : public IMeshPacker<MeshBufferType,MDIStructType>, public I
671637
);
672638
};
673639

640+
template <typename MeshBufferIterator>
641+
void freeAllocatedAddressesOnAllocFail(ReservedAllocationMeshBuffers* rambOut, const MeshBufferIterator mbBegin, const MeshBufferIterator mbEnd)
642+
{
643+
size_t i = 0ull;
644+
for (auto it = mbBegin; it != mbEnd; it++)
645+
{
646+
ReservedAllocationMeshBuffers& ramb = *(rambOut + i);
647+
648+
if (ramb.indexAllocationOffset == INVALID_ADDRESS)
649+
return;
650+
651+
m_idxBuffAlctr.free_addr(ramb.indexAllocationOffset, ramb.indexAllocationReservedCnt);
652+
653+
const auto& mbVtxInputParams = (*it)->getPipeline()->getVertexInputParams();
654+
for (uint16_t attrBit = 0x0001, location = 0; location < SVertexInputParams::MAX_ATTR_BUF_BINDING_COUNT; attrBit <<= 1, location++)
655+
{
656+
if (!(attrBit & mbVtxInputParams.enabledAttribFlags))
657+
continue;
658+
659+
if (ramb.attribAllocParams[location].offset == INVALID_ADDRESS)
660+
return;
661+
662+
m_vtxBuffAlctr.free_addr(ramb.attribAllocParams[location].offset, ramb.attribAllocParams[location].size);
663+
}
664+
665+
if (ramb.mdiAllocationOffset == INVALID_ADDRESS)
666+
return;
667+
668+
m_MDIDataAlctr.free_addr(ramb.mdiAllocationOffset, ramb.mdiAllocationReservedCnt);
669+
670+
i++;
671+
}
672+
}
673+
674674
PackerDataStore m_packerDataStore;
675675

676676
};
@@ -739,8 +739,6 @@ bool IMeshPackerV2<BufferType,DescriptorSetType,MeshBufferType,MDIStructType>::a
739739

740740
if (ramb.attribAllocParams[location].offset == INVALID_ADDRESS)
741741
return false;
742-
743-
//TODO: reset state when allocation fails
744742
}
745743

746744
//allocate MDI structs

0 commit comments

Comments
 (0)