Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Meshlet
struct Meshlet { // Meshlet data. uint VertexOffset; uint VertexCount; uint PrimitiveOffset; uint PrimitiveCount; // Culling data. ... }; std::vector<MyVertex> Vertices; std::vector<Meshlet> Meshlets; std::vector<uint16_t> UniqueVertexIndices; std::vector<uint8_t> PrimitiveIndices;
#define MAX_MESHLET_SIZE 128 StructureBuffer<MyVertex> Vertices; StructureBuffer<Meshlet> Meshlets; StructuredBuffer<uint> UniqueVertexIndices; StructureBuffer<uint3> PrimitiveIndices; VertexOut TransformVertex(MyVertex v) { ... } [NumThreads(MAX_MESHLET_SIZE, 1, 1)] [OutputTopology("triangle")] void main( uint groupThreadId : SV_GroupIndex, uint groupId : SV_GroupID, out vertices VertexOut verts[MAX_MESHLET_SIZE], out indices uint3 tris[MAX_MESHLET_SIZE]) { Meshlet m = Meshlets[groupId]; SetMeshOutputCounts(m.VertCount, m.PrimCount); if (groupThreadId < m.PrimCount) { tris[groupThreadId] = PrimitiveIndices[m.PrimOffset + groupThreadId]; } if (groupThreadId < m.VertCount) { uint index = UniqueVertexIndices[m.VertOffset + groupThreadId]; MyVertex vin = Vertices[index]; verts[groupThreadId] = TransformVertex(vin); } }
相關主題
這個頁面有幫助嗎?