Skip to content

Commit 02beb55

Browse files
authored
[SPIR-V] Warn when wave size is used (microsoft#6542)
Specifying a wave size is not supported in Vulkan SPIR-V, so warn when it is used in a shader.
1 parent c3115dd commit 02beb55

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12574,6 +12574,20 @@ void SpirvEmitter::processComputeShaderAttributes(const FunctionDecl *decl) {
1257412574

1257512575
spvBuilder.addExecutionMode(entryFunction, spv::ExecutionMode::LocalSize,
1257612576
{x, y, z}, decl->getLocation());
12577+
12578+
auto *waveSizeAttr = decl->getAttr<HLSLWaveSizeAttr>();
12579+
if (waveSizeAttr) {
12580+
// Not supported in Vulkan SPIR-V, warn and ignore.
12581+
12582+
// SPIR-V SubgroupSize execution mode would work but it is Kernel only
12583+
// (requires the SubgroupDispatch capability, which implies the
12584+
// DeviceEnqueue capability, which is Kernel only). Subgroup sizes can be
12585+
// specified in Vulkan on the application side via
12586+
// VK_EXT_subgroup_size_control.
12587+
emitWarning("Wave size is not supported by Vulkan SPIR-V. Consider using "
12588+
"VK_EXT_subgroup_size_control.",
12589+
waveSizeAttr->getLocation());
12590+
}
1257712591
}
1257812592

1257912593
bool SpirvEmitter::processTessellationShaderAttributes(
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %dxc -T cs_6_6 -E main -fcgl -spirv %s 2>&1 | FileCheck %s
2+
3+
// CHECK: warning: Wave size is not supported by Vulkan SPIR-V. Consider using VK_EXT_subgroup_size_control.
4+
5+
[WaveSize(32)]
6+
[numthreads(1, 1, 1)]
7+
void main() {}

0 commit comments

Comments
 (0)