Skip to content

Commit

Permalink
Reconsider larger workgroups again.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Jan 13, 2024
1 parent 7ddc4d3 commit 1ea6798
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 9 additions & 1 deletion assets/shaders/inc/meshlet_primitive_cull.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,15 @@ void meshlet_init_shared()

uint meshlet_get_meshlet_index()
{
return gl_WorkGroupID.y;
return gl_WorkGroupSize.y == 8 ? gl_WorkGroupID.x : gl_WorkGroupID.y;
}

uint meshlet_get_sublet_index(uint meshlet_index, uint sublet_index)
{
if (gl_WorkGroupSize.y == 8)
return 8u * meshlet_index + sublet_index;
else
return 8u * meshlet_index + gl_WorkGroupSize.y * gl_WorkGroupID.x + sublet_index;
}

void meshlet_emit_primitive(uvec3 prim, vec4 clip_pos, vec4 viewport)
Expand Down
10 changes: 7 additions & 3 deletions tests/assets/shaders/meshlet_debug_plain.mesh
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,16 @@ void main()
#endif

#if defined(MESHLET_PRIMITIVE_CULL_WAVE32) && MESHLET_PRIMITIVE_CULL_WAVE32
uint linear_index = gl_SubgroupID * gl_SubgroupSize + gl_SubgroupInvocationID;
uint linear_index = gl_SubgroupInvocationID;
uint sublet_index = gl_SubgroupID;
#else
uint linear_index = gl_LocalInvocationIndex;
uint linear_index = gl_LocalInvocationID.x;
uint sublet_index = gl_LocalInvocationID.y;
#endif

IndirectDrawMesh meshlet = indirect_commands_mesh.draws[8u * task.meshlet_index + gl_WorkGroupID.x];
sublet_index = meshlet_get_sublet_index(task.meshlet_index, sublet_index);
IndirectDrawMesh meshlet = indirect_commands_mesh.draws[sublet_index];

mat4 M = transforms.data[task.node_offset];

// Transform positions.
Expand Down

0 comments on commit 1ea6798

Please sign in to comment.