Description
- Implement
SetMeshOutputCounts
clang builtin,LinkSetMeshOutputCounts
clang builtin withhlsl_intrinsics.h
Add sema checks forSetMeshOutputCounts
toCheckHLSLBuiltinFunctionCall
inSemaChecking.cpp
Add codegen forSetMeshOutputCounts
toEmitHLSLBuiltinExpr
inCGBuiltin.cpp
Add codegen tests toclang/test/CodeGenHLSL/builtins/SetMeshOutputCounts.hlsl
Add sema tests toclang/test/SemaHLSL/BuiltIns/SetMeshOutputCounts-errors.hlsl
Create theint_dx_SetMeshOutputCounts
intrinsic inIntrinsicsDirectX.td
Create theDXILOpMapping
ofint_dx_SetMeshOutputCounts
to168
inDXIL.td
Create theSetMeshOutputCounts.ll
andSetMeshOutputCounts_errors.ll
tests inllvm/test/CodeGen/DirectX/
Create theint_spv_SetMeshOutputCounts
intrinsic inIntrinsicsSPIRV.td
In SPIRVInstructionSelector.cpp create theSetMeshOutputCounts
lowering and map it toint_spv_SetMeshOutputCounts
inSPIRVInstructionSelector::selectIntrinsic
.Create SPIR-V backend test case inllvm/test/CodeGen/SPIRV/hlsl-intrinsics/SetMeshOutputCounts.ll
DirectX
DXIL Opcode | DXIL OpName | Shader Model | Shader Stages |
---|---|---|---|
168 | SetMeshOutputCounts | 6.5 | ('mesh',) |
SPIR-V
OpSetMeshOutputsEXT:
Description:
Reserved.
Capability:
MeshShadingEXT
Word Count | Opcode | Results | Operands |
---|---|---|---|
3 |
5295 |
<id> |
<id> |
Test Case(s)
Example 1
//dxc SetMeshOutputCounts_test.hlsl -T lib_6_8 -enable-16bit-types -O0
[numthreads(1, 1, 1)]
[outputtopology("triangle")]
[shader("mesh")]
void fn(in uint gi : SV_GroupIndex, in uint vi : SV_ViewID) {
SetMeshOutputCounts(1, 1);
}
SPIRV Example(s):
Example 2
//dxc SetMeshOutputCounts_spirv_test.hlsl -T lib_6_8 -E fn -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0
struct MeshPerVertex {
float4 position : SV_Position;
};
[numthreads(1, 1, 1)]
[outputtopology("triangle")]
[shader("mesh")]
void fn(in uint gi : SV_GroupIndex, in uint vi : SV_ViewID,
out vertices MeshPerVertex verts[3], out indices uint3 primitiveInd[3]) {
SetMeshOutputCounts(1, 1);
}
HLSL:
This function sets the actual number of outputs from the threadgroup.
Syntax
void SetMeshOutputCounts(
uint numVertices,
uint numPrimitives);
Remarks
At the beginning of the shader the implementation internally sets a
count of vertices and primitives to be exported from a threadgroup to 0.
It means that if a mesh shader returns without calling this function,
it will not output any mesh. This function sets the actual number of
outputs from the threadgroup.
Some restrictions on the function use and interactions with output arrays follow.
-
This function can only be called once per shader.
-
This call must occur before any writes to any of the
shared output arrays.
The validator will verify this is the case. -
If the compiler can prove that this function is not called,
then the threadgroup doesn't have any output.
If the shader writes to any of the
shared output arrays,
compilation and shader validation will fail.
If the shader does not call any of these functions,
the compiler will issue a warning,
and no rasterization work will be issued. -
Only the input values from the first active thread are used.
-
This call must dominate all writes to
shared output arrays.
In other words, there must not be any execution path
that even appears to reach any writes to any output array
without first having executed this call.
Metadata
Metadata
Assignees
Type
Projects
Status
Activity
damyanp commentedon Jan 21, 2025
@farzonl - think about grouping these with other mesh shader intrinsics?