Basic meshlet generation algorithm

This commit is contained in:
Dynamitos
2023-10-31 16:16:23 +01:00
parent 7773c55e1a
commit d53492d07b
15 changed files with 350 additions and 191 deletions
+36 -3
View File
@@ -9,6 +9,10 @@ using namespace Seele;
void VertexData::resetMeshData()
{
materialData.clear();
if (dirty)
{
updateBuffers();
}
}
void VertexData::updateMesh(const Component::Transform& transform, const Component::Mesh& mesh)
@@ -24,6 +28,30 @@ void VertexData::updateMesh(const Component::Transform& transform, const Compone
});
}
void VertexData::loadMesh(MeshId id, Array<Meshlet> meshlets)
{
meshData[id].clear();
uint32 head = 0;
while (head < meshlets.size())
{
uint32 numMeshlets = std::min<uint32>(512, meshlets.size() - head);
Array<MeshletDescription> desc(numMeshlets);
for (uint32 i = 0; i < numMeshlets; ++i)
{
Meshlet& m = meshlets[head + i];
vertexIndices.resize()
desc.add(MeshletDescription{
.boundingBox = MeshletAABB(),
.vertexCount = m.numVertices,
.primitiveCount = m.numPrimitives,
});
}
meshData[id].add();
head += numMeshlets;
}
}
void VertexData::createDescriptors()
{
for (const auto& [_, mat] : materialData)
@@ -74,10 +102,9 @@ List<VertexData*> VertexData::getList()
return vertexDataList;
}
VertexData::VertexData(Gfx::PGraphics graphics)
: graphics(graphics)
, idCounter(0)
void Seele::VertexData::init(Gfx::PGraphics graphics)
{
this->graphics = graphics;
instanceDataLayout = graphics->createDescriptorLayout("VertexDataInstanceLayout");
instanceDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
if (Gfx::useMeshShading)
@@ -96,3 +123,9 @@ VertexData::VertexData(Gfx::PGraphics graphics)
}
instanceDataLayout->create();
}
VertexData::VertexData()
: idCounter(0)
, dirty(false)
{
}