Nothing works
This commit is contained in:
@@ -7,7 +7,7 @@ import Scene;
|
||||
FragmentParameter vertexMain(
|
||||
VertexInput input
|
||||
){
|
||||
InstanceData inst = pScene.instances[input.instanceId];
|
||||
InstanceData inst = pScene.instances[pOffsets.instanceOffset + input.instanceId];
|
||||
VertexAttributes attr = pVertexData.getAttributes(input.vertexId);
|
||||
return attr.getParameter(inst.transformMatrix);
|
||||
}
|
||||
@@ -18,8 +18,9 @@ void meshMain(
|
||||
out vertices FragmentParameter vertices[MAX_VERTICES],
|
||||
out indices uint3 indices[MAX_PRIMITIVES]
|
||||
){
|
||||
InstanceData inst = pScene.instances[meshPayload.instanceId];
|
||||
MeshletDescription m = pScene.meshletInfos[pScene.culledMeshlets[meshPayload.cullingOffset + groupID]];
|
||||
InstanceData inst = meshPayload.instanceData;
|
||||
MeshData data = meshPayload.meshData;
|
||||
MeshletDescription m = pScene.meshletInfos[data.meshletOffset + groupID];
|
||||
SetMeshOutputCounts(m.vertexCount, m.primitiveCount);
|
||||
|
||||
for(uint i = threadID; i < MAX_PRIMITIVES; i += MESH_GROUP_SIZE)
|
||||
@@ -32,7 +33,7 @@ void meshMain(
|
||||
indices[p] = uint3(local_idx0, local_idx1, local_idx2);
|
||||
}
|
||||
}
|
||||
for(uint i = threadID; i < MAX_VERTICES; i+=MESH_GROUP_SIZE)
|
||||
for(uint i = threadID; i < MAX_VERTICES; i += MESH_GROUP_SIZE)
|
||||
{
|
||||
uint v = min(i, m.vertexCount - 1);
|
||||
{
|
||||
|
||||
@@ -28,21 +28,24 @@ void taskMain(
|
||||
viewFrustum.sides[1] = computePlane(origin, corners[1], corners[3]);
|
||||
viewFrustum.sides[2] = computePlane(origin, corners[0], corners[1]);
|
||||
viewFrustum.sides[3] = computePlane(origin, corners[3], corners[2]);
|
||||
p.instanceId = pOffsets.instanceOffset + groupID;
|
||||
p.cullingOffset = pScene.cullingOffsets[pOffsets.cullingCounterOffset + groupID];
|
||||
//p.instanceId = pOffsets.instanceOffset + groupID;
|
||||
p.instanceData = instance;
|
||||
p.meshData = mesh;
|
||||
//p.cullingOffset = pScene.cullingOffsets[pOffsets.cullingCounterOffset + groupID];
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
for(uint i = threadID; i < mesh.numMeshlets; i += TASK_GROUP_SIZE)
|
||||
{
|
||||
uint m = mesh.meshletOffset + i;
|
||||
MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||
if(meshlet.bounding.insideFrustum(viewFrustum))
|
||||
{
|
||||
uint index;
|
||||
InterlockedAdd(head, 1, index);
|
||||
pScene.culledMeshlets[p.cullingOffset + index] = m;
|
||||
}
|
||||
}
|
||||
GroupMemoryBarrierWithGroupSync();
|
||||
DispatchMesh(head, 1, 1, p);
|
||||
//for(uint i = threadID; i < mesh.numMeshlets; i += TASK_GROUP_SIZE)
|
||||
//{
|
||||
// uint m = mesh.meshletOffset + i;
|
||||
// MeshletDescription meshlet = pScene.meshletInfos[m];
|
||||
// //if(meshlet.bounding.insideFrustum(viewFrustum))
|
||||
// {
|
||||
// uint index;
|
||||
// InterlockedAdd(head, 1, index);
|
||||
// p.culledMeshlets[index] = m;
|
||||
// //pScene.culledMeshlets[p.cullingOffset + index] = m;
|
||||
// }
|
||||
//}
|
||||
//GroupMemoryBarrierWithGroupSync();
|
||||
DispatchMesh(mesh.numMeshlets, 1, 1, p);
|
||||
}
|
||||
@@ -34,7 +34,6 @@ struct InstanceData
|
||||
struct DrawCallOffsets
|
||||
{
|
||||
uint32_t instanceOffset;
|
||||
uint32_t cullingCounterOffset;
|
||||
};
|
||||
layout(push_constant)
|
||||
ConstantBuffer<DrawCallOffsets> pOffsets;
|
||||
@@ -46,15 +45,16 @@ struct Scene
|
||||
StructuredBuffer<MeshletDescription> meshletInfos;
|
||||
StructuredBuffer<uint8_t> primitiveIndices;
|
||||
StructuredBuffer<uint32_t> vertexIndices;
|
||||
StructuredBuffer<uint32_t> cullingOffsets;
|
||||
RWStructuredBuffer<uint32_t> culledMeshlets;
|
||||
// StructuredBuffer<uint32_t> cullingOffsets;
|
||||
// RWStructuredBuffer<uint32_t> culledMeshlets;
|
||||
};
|
||||
layout(set=2)
|
||||
ParameterBlock<Scene> pScene;
|
||||
|
||||
struct MeshPayload
|
||||
{
|
||||
uint instanceId;
|
||||
uint cullingOffset;
|
||||
InstanceData instanceData;
|
||||
MeshData meshData;
|
||||
uint culledMeshlets[2048];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user