Skip to content

Commit 9dbf0d1

Browse files
compiles
1 parent ed9bfa1 commit 9dbf0d1

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

include/nbl/asset/IMeshPackerV2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ bool IMeshPackerV2<MeshBufferType, BufferType, MDIStructType>::alloc(ReservedAll
250250
ReservedAllocationMeshBuffers& ramb = *(rambOut + i);
251251
const size_t idxCnt = (*it)->getIndexCount();
252252
// TODO: deal with per-instance attributes!!
253-
const size_t maxVtxCnt = calcVertexCountBoundWithBatchDuplication(IMeshManipulator::getPolyCount(*it));
253+
const size_t maxVtxCnt = calcVertexCountBoundWithBatchDuplication(*it);
254254

255255
//allocate indices
256256
ramb.indexAllocationOffset = m_idxBuffAlctr.alloc_addr(idxCnt, 1u);
@@ -309,7 +309,7 @@ uint32_t IMeshPackerV2<MeshBufferType, BufferType, MDIStructType>::calcMDIStruct
309309
const uint32_t triCnt = idxCnt / 3;
310310
assert(idxCnt % 3 == 0);
311311

312-
acc += calcBatchCount(triCnt);
312+
acc += calcBatchCountBound(triCnt);
313313
}
314314

315315
return acc;

include/nbl/asset/utils/CCPUMeshPackerV1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ typename CCPUMeshPackerV1<MDIStructType>::ReservedAllocationMeshBuffers CCPUMesh
258258
{
259259
ICPUMeshBuffer* mb = *it;
260260
idxCnt += mb->getIndexCount();
261-
vtxCnt += calcVertexCountBoundWithBatchDuplication(IMeshManipulator::getPolyCount(mb));
261+
vtxCnt += calcVertexCountBoundWithBatchDuplication(mb);
262262
}
263263

264264
const uint32_t minIdxCntPerPatch = m_minTriangleCountPerMDIData * 3;

include/nbl/asset/utils/IMeshPacker.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class IMeshPacker : public IMeshPackerBase
115115
protected:
116116
virtual ~IMeshPacker() {}
117117

118-
inline size_t calcVertexSize(const SVertexInputParams& vtxInputParams, const E_VERTEX_INPUT_RATE inputRate) const
118+
static inline size_t calcVertexSize(const SVertexInputParams& vtxInputParams, const E_VERTEX_INPUT_RATE inputRate)
119119
{
120120
size_t size = 0ull;
121121
for (size_t i = 0; i < SVertexInputParams::MAX_VERTEX_ATTRIB_COUNT; ++i)
@@ -128,12 +128,15 @@ class IMeshPacker : public IMeshPackerBase
128128
return size;
129129
}
130130

131-
inline constexpr uint32_t calcVertexCountBoundWithBatchDuplication(uint32_t triCnt)
131+
static inline uint32_t calcVertexCountBoundWithBatchDuplication(const MeshBufferType* meshBuffer)
132132
{
133-
return triCnt*3u;
133+
uint32_t triCnt;
134+
if (IMeshManipulator::getPolyCount(triCnt,meshBuffer))
135+
return triCnt*3u;
136+
return 0u;
134137
}
135138

136-
inline constexpr uint32_t calcBatchCountBound(uint32_t triCnt)
139+
inline uint32_t calcBatchCountBound(uint32_t triCnt) const
137140
{
138141
if (triCnt!=0u)
139142
return (triCnt-1u)/m_minTriangleCountPerMDIData+1u;
@@ -150,10 +153,10 @@ class IMeshPacker : public IMeshPackerBase
150153
core::vector<Triangle> triangles;
151154
};
152155

153-
core::vector<TriangleBatch> constructTriangleBatches(MeshBufferType* meshBuffer)
156+
core::vector<TriangleBatch> constructTriangleBatches(const MeshBufferType* meshBuffer) const
154157
{
155158
uint32_t triCnt;
156-
const bool success = IMeshManipulator::getPolyCount(meshBuffer);
159+
const bool success = IMeshManipulator::getPolyCount(triCnt,meshBuffer);
157160
assert(success);
158161

159162
const uint32_t batchCount = calcBatchCountBound(triCnt);
@@ -191,9 +194,10 @@ class IMeshPacker : public IMeshPackerBase
191194
{
192195
if (i == (batchCount - 1))
193196
{
194-
if (triCnt % m_maxTriangleCountPerMDIData)
197+
const auto lastBatchLen = triCnt % uint32_t(m_maxTriangleCountPerMDIData);
198+
if (lastBatchLen)
195199
{
196-
output[i].triangles = core::vector<Triangle>(triCnt % m_maxTriangleCountPerMDIData);
200+
output[i].triangles = core::vector<Triangle>(lastBatchLen);
197201
continue;
198202
}
199203
}
@@ -231,7 +235,7 @@ class IMeshPacker : public IMeshPackerBase
231235
return output;
232236
}
233237

234-
core::unordered_map<uint32_t, uint16_t> constructNewIndicesFromTriangleBatch(TriangleBatch& batch, uint16_t*& indexBuffPtr)
238+
static core::unordered_map<uint32_t, uint16_t> constructNewIndicesFromTriangleBatch(TriangleBatch& batch, uint16_t*& indexBuffPtr)
235239
{
236240
core::unordered_map<uint32_t, uint16_t> usedVertices;
237241
core::vector<Triangle> newIdxTris = batch.triangles;
@@ -264,7 +268,7 @@ class IMeshPacker : public IMeshPackerBase
264268
return usedVertices;
265269
}
266270

267-
void deinterleaveAndCopyAttribute(MeshBufferType* meshBuffer, uint16_t attrLocation, const core::unordered_map<uint32_t, uint16_t>& usedVertices, uint8_t* dstAttrPtr)
271+
static void deinterleaveAndCopyAttribute(MeshBufferType* meshBuffer, uint16_t attrLocation, const core::unordered_map<uint32_t, uint16_t>& usedVertices, uint8_t* dstAttrPtr)
268272
{
269273
uint8_t* srcAttrPtr = meshBuffer->getAttribPointer(attrLocation);
270274
SVertexInputParams& mbVtxInputParams = meshBuffer->getPipeline()->getVertexInputParams();

0 commit comments

Comments
 (0)