Basic meshlet generation algorithm
This commit is contained in:
@@ -15,6 +15,17 @@ namespace Component
|
||||
struct MeshId
|
||||
{
|
||||
uint64 id;
|
||||
std::strong_ordering operator<=>(const MeshId& other) const
|
||||
{
|
||||
return id <=> other.id;
|
||||
}
|
||||
};
|
||||
struct Meshlet
|
||||
{
|
||||
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;
|
||||
};
|
||||
class VertexData
|
||||
{
|
||||
@@ -44,9 +55,11 @@ public:
|
||||
{
|
||||
uint32 numMeshlets;
|
||||
uint32 meshletOffset;
|
||||
uint32 vertexOffset;
|
||||
};
|
||||
void resetMeshData();
|
||||
void updateMesh(const Component::Transform& transform, const Component::Mesh& mesh);
|
||||
void loadMesh(MeshId id, Array<Meshlet> meshlets);
|
||||
void createDescriptors();
|
||||
virtual MeshId allocateVertexData(uint64 numVertices) = 0;
|
||||
virtual void bindBuffers(Gfx::PRenderCommand command) = 0;
|
||||
@@ -57,7 +70,10 @@ public:
|
||||
const Map<std::string, MaterialData>& getMaterialData() const { return materialData; }
|
||||
const Array<MeshData>& getMeshData(MeshId id) { return meshData[id]; }
|
||||
static List<VertexData*> getList();
|
||||
virtual void init(Gfx::PGraphics graphics);
|
||||
protected:
|
||||
virtual void updateBuffers() = 0;
|
||||
VertexData();
|
||||
struct MeshletAABB
|
||||
{
|
||||
Vector min;
|
||||
@@ -65,24 +81,26 @@ protected:
|
||||
Vector max;
|
||||
float pad1;
|
||||
};
|
||||
struct MeshletData
|
||||
struct MeshletDescription
|
||||
{
|
||||
MeshletAABB boundingBox;
|
||||
uint32_t vertexCount;
|
||||
uint32_t primiticeCount;
|
||||
uint32_t primitiveCount;
|
||||
uint32_t vertexOffset;
|
||||
uint32_t primitiveOffset;
|
||||
};
|
||||
Map<std::string, MaterialData> materialData;
|
||||
Map<MeshId, Array<MeshData>> meshData;
|
||||
Array<MeshletData> meshlets;
|
||||
Gfx::PDescriptorLayout instanceDataLayout;
|
||||
Array<MeshletDescription> meshlets;
|
||||
Array<uint8> primitiveIndices;
|
||||
Array<uint32> vertexIndices;
|
||||
Gfx::PGraphics graphics;
|
||||
Gfx::PDescriptorLayout instanceDataLayout;
|
||||
// for mesh shading
|
||||
Gfx::PShaderBuffer meshletBuffer;
|
||||
// for legacy pipeline
|
||||
Gfx::PIndexBuffer indexBuffer;
|
||||
VertexData(Gfx::PGraphics graphics);
|
||||
uint64 idCounter;
|
||||
bool dirty;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user