Calling EmitMeshTasksEXT With Zero Mesh Tasks

This article examines the graphics pipeline behavior and architectural consequences when a GLSL task shader invokes EmitMeshTasksEXT with a task count of zero. It covers the direct impact on downstream execution stages, the behavior of the calling task workgroup, memory payload handling, and the primary performance benefits for GPU-driven geometry culling.

Pipeline Termination for Downstream Stages

When a task shader executes EmitMeshTasksEXT(0, 0, 0)—or provides a zero for any of the three dimension arguments—the immediate consequence is that the pipeline dispatches zero mesh shader workgroups for that specific task shader workgroup.

Because no mesh workgroups are spawned, the subsequent stages of the graphics pipeline associated with that task invocation are completely bypassed. This means:

  • Mesh Shading Stage: No mesh shaders are executed.
  • Primitive Assembly: No primitives (triangles, lines, or points) are produced.
  • Rasterization and Fragment Shading: No fragments are generated, skipping depth/stencil testing, fragment shading, and color attachment writes.

Task Shader Execution and Side Effects

Invoking EmitMeshTasksEXT with zero tasks does not terminate or abort the calling task shader workgroup. The task shader invocations will continue executing their instruction stream until they reach the end of the shader entry point or a return statement.

Any operations performed by the task shader—such as atomic operations, storage buffer (SSBO) reads and writes, or image store operations—still execute and remain visible to the rest of the application according to standard Vulkan or OpenGL memory model synchronization rules.

Payload Handling

The task payload defined via the taskPayloadSharedEXT storage qualifier is intended to pass data from the task shader to child mesh shaders. When the spawned mesh task count is zero:

  • The task payload data is essentially discarded.
  • The hardware does not allocate or preserve space in high-speed on-chip cache or VRAM to transition the payload to non-existent mesh shader invocations.
  • No data hazard occurs regarding unread payload data.

Practical Usage: GPU-Driven Culling

Passing zero to EmitMeshTasksEXT is the intended hardware mechanism for early culling in modern mesh shading pipelines. Task shaders routinely test bounding boxes or spheres against a camera's view frustum, perform occlusion queries, or evaluate level-of-detail (LOD) metrics. If a cluster of geometry fails these tests, setting the output count to zero discards the entire geometry cluster immediately. This eliminates the overhead of processing vertices, topology, and fragments down the pipeline without requiring CPU intervention.