2024-05-30 16:56:22 +02:00
|
|
|
import Common;
|
|
|
|
|
import Scene;
|
|
|
|
|
|
|
|
|
|
groupshared MeshPayload p;
|
|
|
|
|
groupshared uint head;
|
2024-05-30 21:24:21 +02:00
|
|
|
groupshared MeshData mesh;
|
2024-05-30 16:56:22 +02:00
|
|
|
|
|
|
|
|
[numthreads(TASK_GROUP_SIZE, 1, 1)]
|
|
|
|
|
[shader("amplification")]
|
|
|
|
|
void taskMain(
|
2024-06-07 09:19:47 +02:00
|
|
|
uint threadID: SV_GroupThreadID,
|
2024-05-30 16:56:22 +02:00
|
|
|
uint groupID: SV_GroupID, )
|
|
|
|
|
{
|
|
|
|
|
if (threadID == 0)
|
|
|
|
|
{
|
|
|
|
|
head = 0;
|
2024-05-30 21:24:21 +02:00
|
|
|
mesh = pScene.meshData[pOffsets.instanceOffset + groupID];
|
2024-05-30 16:56:22 +02:00
|
|
|
p.instanceId = pOffsets.instanceOffset + groupID;
|
2025-04-15 00:33:49 +02:00
|
|
|
p.meshletOffset = mesh.meshletRange.offset;
|
2024-05-30 21:24:21 +02:00
|
|
|
p.cullingOffset = pScene.cullingOffsets[p.instanceId];
|
2024-05-30 16:56:22 +02:00
|
|
|
}
|
|
|
|
|
GroupMemoryBarrierWithGroupSync();
|
2025-04-15 00:33:49 +02:00
|
|
|
for (uint i = threadID; i < mesh.meshletRange.size; i += TASK_GROUP_SIZE)
|
2024-05-30 16:56:22 +02:00
|
|
|
{
|
2024-05-30 21:24:21 +02:00
|
|
|
uint m = p.meshletOffset + i;
|
|
|
|
|
uint cull = p.cullingOffset + i;
|
|
|
|
|
MeshletDescription meshlet = pScene.meshletInfos[m];
|
2024-06-07 09:19:47 +02:00
|
|
|
MeshletCullingInfo culling = pScene.cullingInfos[cull];
|
2025-05-06 19:36:43 +02:00
|
|
|
//if(culling.wasVisible())
|
2024-05-30 16:56:22 +02:00
|
|
|
{
|
|
|
|
|
uint index;
|
|
|
|
|
InterlockedAdd(head, 1, index);
|
2024-05-30 21:24:21 +02:00
|
|
|
p.culledMeshlets[index] = i;
|
2024-05-30 16:56:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
GroupMemoryBarrierWithGroupSync();
|
2024-05-30 21:24:21 +02:00
|
|
|
DispatchMesh(head, 1, 1, p);
|
2024-05-30 16:56:22 +02:00
|
|
|
}
|