Reverting to 32 bit indices
This commit is contained in:
@@ -15,7 +15,7 @@ public:
|
||||
MeshId id;
|
||||
uint64 vertexCount;
|
||||
PMaterialInstanceAsset referencedMaterial;
|
||||
Array<uint16> indices;
|
||||
Array<uint32> indices;
|
||||
Array<Meshlet> meshlets;
|
||||
void save(ArchiveBuffer& buffer) const;
|
||||
void load(ArchiveBuffer& buffer);
|
||||
|
||||
@@ -61,20 +61,26 @@ void addTriangle(Array<Meshlet>& meshlets, Meshlet& current, Triangle tri)
|
||||
}
|
||||
}
|
||||
|
||||
void Meshlet::build(const Array<Vector>& positions, const Array<uint16>& indices, Array<Meshlet>& meshlets)
|
||||
void Meshlet::build(const Array<Vector>& positions, const Array<uint32>& indices, Array<Meshlet>& meshlets)
|
||||
{
|
||||
Meshlet current = {
|
||||
.numVertices = 0,
|
||||
.numPrimitives = 0,
|
||||
};
|
||||
for (size_t i = 0; i < indices.size() / 3; ++i)
|
||||
Array<Triangle> triangles(indices.size() / 3);
|
||||
for (size_t i = 0; i < triangles.size(); ++i)
|
||||
{
|
||||
addTriangle(meshlets, current, Triangle{
|
||||
triangles.add(Triangle{
|
||||
.indices = {
|
||||
indices[i * 3 + 0],
|
||||
indices[i * 3 + 1],
|
||||
indices[i * 3 + 2],
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
if (current.numVertices > 0)
|
||||
{
|
||||
completeMeshlet(meshlets, current);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ namespace Seele
|
||||
struct Meshlet
|
||||
{
|
||||
AABB boundingBox;
|
||||
uint16 uniqueVertices[Gfx::numVerticesPerMeshlet]; // unique vertiex indices in the vertex data
|
||||
uint32 uniqueVertices[Gfx::numVerticesPerMeshlet]; // unique vertiex indices in the vertex data
|
||||
uint8 primitiveLayout[Gfx::numPrimitivesPerMeshlet * 3]; // indices into the uniqueVertices array, only uint8 needed
|
||||
uint32 numVertices;
|
||||
uint32 numPrimitives;
|
||||
static void build(const Array<Vector>& positions, const Array<uint16>& indices, Array<Meshlet>& meshlets);
|
||||
static void build(const Array<Vector>& positions, const Array<uint32>& indices, Array<Meshlet>& meshlets);
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -142,7 +142,7 @@ void VertexData::createDescriptors()
|
||||
}
|
||||
}
|
||||
|
||||
void VertexData::loadMesh(MeshId id, Array<uint16> loadedIndices, Array<Meshlet> loadedMeshlets)
|
||||
void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet> loadedMeshlets)
|
||||
{
|
||||
meshlets.reserve(meshlets.size() + loadedMeshlets.size());
|
||||
vertexIndices.reserve(vertexIndices.size() + loadedMeshlets.size() * Gfx::numVerticesPerMeshlet);
|
||||
@@ -183,13 +183,13 @@ void VertexData::loadMesh(MeshId id, Array<uint16> loadedIndices, Array<Meshlet>
|
||||
meshData[id][0].firstIndex = indices.size();
|
||||
meshData[id][0].numIndices = loadedIndices.size();
|
||||
indices.resize(indices.size() + loadedIndices.size());
|
||||
std::memcpy(indices.data() + meshData[id][0].firstIndex, loadedIndices.data(), loadedIndices.size() * sizeof(uint16));
|
||||
std::memcpy(indices.data() + meshData[id][0].firstIndex, loadedIndices.data(), loadedIndices.size() * sizeof(uint32));
|
||||
indexBuffer = graphics->createIndexBuffer(IndexBufferCreateInfo{
|
||||
.sourceData = {
|
||||
.size = sizeof(uint16) * indices.size(),
|
||||
.size = sizeof(uint32) * indices.size(),
|
||||
.data = (uint8*)indices.data(),
|
||||
},
|
||||
.indexType = Gfx::SE_INDEX_TYPE_UINT16,
|
||||
.indexType = Gfx::SE_INDEX_TYPE_UINT32,
|
||||
});
|
||||
meshletBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData = {
|
||||
@@ -201,7 +201,7 @@ void VertexData::loadMesh(MeshId id, Array<uint16> loadedIndices, Array<Meshlet>
|
||||
});
|
||||
vertexIndicesBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.sourceData = {
|
||||
.size = sizeof(uint16) * vertexIndices.size(),
|
||||
.size = sizeof(uint32) * vertexIndices.size(),
|
||||
.data = (uint8*)vertexIndices.data(),
|
||||
},
|
||||
.numElements = vertexIndices.size(),
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
void resetMeshData();
|
||||
void updateMesh(PMesh mesh, Component::Transform& transform);
|
||||
void createDescriptors();
|
||||
void loadMesh(MeshId id, Array<uint16> indices, Array<Meshlet> meshlets);
|
||||
void loadMesh(MeshId id, Array<uint32> indices, Array<Meshlet> meshlets);
|
||||
MeshId allocateVertexData(uint64 numVertices);
|
||||
uint64 getMeshOffset(MeshId id);
|
||||
uint64 getMeshVertexCount(MeshId id);
|
||||
@@ -100,8 +100,8 @@ protected:
|
||||
Map<MeshId, uint64> meshVertexCounts;
|
||||
Array<MeshletDescription> meshlets;
|
||||
Array<uint8> primitiveIndices;
|
||||
Array<uint16> vertexIndices;
|
||||
Array<uint16> indices;
|
||||
Array<uint32> vertexIndices;
|
||||
Array<uint32> indices;
|
||||
Gfx::PGraphics graphics;
|
||||
Gfx::ODescriptorLayout instanceDataLayout;
|
||||
// for mesh shading
|
||||
|
||||
Reference in New Issue
Block a user