Skip to content

Move dispatch dimensions and vertex count to new DispatchParameters with defaults#1153

Merged
manon-traverse merged 3 commits into
llvm:mainfrom
Traverse-Research:dispatch-parameters
May 7, 2026
Merged

Move dispatch dimensions and vertex count to new DispatchParameters with defaults#1153
manon-traverse merged 3 commits into
llvm:mainfrom
Traverse-Research:dispatch-parameters

Conversation

@manon-traverse
Copy link
Copy Markdown
Contributor

Fixes #1152

There was no way to specify the vertex count for a test that uses the TraditionalRaster pipeline.
Since vertex buffers are not required for doing rasterization, and is actually quite a common use case, we need to be able to specify that as well.
In the future we will also need to support indexed and instanced draws, for which more parameters need to be specified.
Specifying these parameters are part of the shader doesn't really make sense since they apply to the whole pipeline.
For those reasons I am introducing a DispatchParameters field where the user can specify the exact parameters for how a pipeline should be dispatched.

While making this change I found that 99% of the compute shader tests dispatch a single threadgroup. Since there is no use-case for dispatching no threads (as far as I am aware), I made dispatching a single thread group a default value. This simplifies writing tests.

For TraditionalRaster tests we can still rely on calculating the vertex count from the size of the vertex buffer and vertex stride if it is not specified in the .yaml section.

@manon-traverse manon-traverse force-pushed the dispatch-parameters branch from e036a23 to 3de99f6 Compare May 7, 2026 12:43
Comment thread README.md Outdated
Comment thread lib/Support/Pipeline.cpp
Comment on lines +604 to +610
case ShaderPipelineKind::TraditionalRaster:
if (DispatchParameters.DispatchGroupCount !=
std::array<uint32_t, 3>{1, 1, 1})
return llvm::createStringError(
"DispatchParameters.DispatchGroupCount set on a TraditionalRaster "
"pipeline. Only allowed on a Compute pipeline.");
break;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate that VertexCount is not set if a vertex buffer was provided, or are there sensible reasons to override the "default" number of vertices in a buffer?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are valid reasons to specify this manually even though you have defined a vertex buffer. Especially when we start passing arguments like FirstVertex.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only validation would be if FirstVertex + VertexCount <= NumVerticesInBuffer perhaps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically that would still be a valid case though, but you would be reading zeroes.

@manon-traverse manon-traverse requested a review from MarijnS95 May 7, 2026 14:21
@MarijnS95 MarijnS95 changed the title Introduce DispatchParameters. Allow more flexibility and introduce useful default values. Move dispatch dimensions and vertex count to new DispatchParameters with defaults May 7, 2026
@manon-traverse manon-traverse merged commit 9f7bb31 into llvm:main May 7, 2026
22 of 23 checks passed
Icohedron pushed a commit that referenced this pull request May 11, 2026
…atch size. (#1166)

[#1163](#1163) got
merged, but was not rebased on
[#1153](#1153), causing
`main` to now fail CI.

This PR updates the `InterlockedAdd` tests to use the new DispatchArgs
format, including the use of the default dispatch size of [1, 1, 1].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move DispatchSize out of the Shader struct, add support for specifying VertexCount

3 participants