forked from microsoft/DirectXShaderCompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements the Shader Model 6.5 WaveMultiPrefix* intrinsic functions using the group operation from SPV_NV_shader_subgroup_partitioned, PartitionedExclusiveScanNV, which performs a partitioned exclusive scan operation across a subset of invocations ("lanes") in a subgroup ("wave"). The subset of the partition is determined by the provided ballot ("mask") parameter, which follows the same requirements for valid partitioning and active invocations/lanes as the HLSL parameter. Note that WaveMultiPrefixCountBits remains unimplemented because it does not directly map to a SPIR-V GroupNonUniformArithmetic instruction that accepts the PartitionedExclusiveScanNV Group Operation. DirectX Spec: https://microsoft.github.io/DirectX-Specs/d3d/HLSL_ShaderModel6_5.html#wavemultiprefix-functions SPIR-V Extension: https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/NV/SPV_NV_shader_subgroup_partitioned.html Depends on microsoft#6596 Fixes microsoft#6600
- Loading branch information
1 parent
9376983
commit d46fc48
Showing
7 changed files
with
125 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
tools/clang/test/CodeGenSPIRV/intrinsics.sm6_5.multiprefix.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// RUN: %dxc -E main -T ps_6_5 -spirv -O0 -fspv-target-env=vulkan1.1 %s | FileCheck %s | ||
// RUN: not %dxc -E main -T ps_6_5 -spirv -O0 %s 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR | ||
|
||
// CHECK-ERROR: error: Vulkan 1.1 is required for Wave Operation but not permitted to use | ||
|
||
// CHECK: OpCapability GroupNonUniformPartitionedNV | ||
// CHECK: OpExtension "SPV_NV_shader_subgroup_partitioned" | ||
|
||
StructuredBuffer<uint4> g_mask; | ||
|
||
uint4 main(int4 input0 : ATTR0, uint4 input1 : ATTR1) : SV_Target { | ||
uint4 mask = g_mask[0]; | ||
|
||
// CHECK: [[input0:%[0-9]+]] = OpLoad %v4int %input0 | ||
// CHECK: [[mask:%[0-9]+]] = OpLoad %v4uint %mask | ||
// CHECK: {{%[0-9]+}} = OpGroupNonUniformIMul %v4int %uint_3 PartitionedExclusiveScanNV [[input0]] [[mask]] | ||
int4 res = WaveMultiPrefixProduct(input0, mask); | ||
|
||
// CHECK: [[input1:%[0-9]+]] = OpLoad %v4uint %input1 | ||
// CHECK: [[mask:%[0-9]+]] = OpLoad %v4uint %mask | ||
// CHECK: {{%[0-9]+}} = OpGroupNonUniformIMul %v4uint %uint_3 PartitionedExclusiveScanNV [[input1]] [[mask]] | ||
res += WaveMultiPrefixProduct(input1, mask); | ||
|
||
// CHECK: [[input0:%[0-9]+]] = OpLoad %v4int %input0 | ||
// CHECK: [[mask:%[0-9]+]] = OpLoad %v4uint %mask | ||
// CHECK: {{%[0-9]+}} = OpGroupNonUniformIAdd %v4int %uint_3 PartitionedExclusiveScanNV [[input0]] [[mask]] | ||
res += WaveMultiPrefixSum(input0, mask); | ||
|
||
// CHECK: [[input1:%[0-9]+]] = OpLoad %v4uint %input1 | ||
// CHECK: [[mask:%[0-9]+]] = OpLoad %v4uint %mask | ||
// CHECK: {{%[0-9]+}} = OpGroupNonUniformIAdd %v4uint %uint_3 PartitionedExclusiveScanNV [[input1]] [[mask]] | ||
res += WaveMultiPrefixSum(input1, mask); | ||
|
||
// CHECK: [[input1:%[0-9]+]] = OpLoad %v4uint %input1 | ||
// CHECK: [[mask:%[0-9]+]] = OpLoad %v4uint %mask | ||
// CHECK: {{%[0-9]+}} = OpGroupNonUniformBitwiseAnd %v4uint %uint_3 PartitionedExclusiveScanNV [[input1]] [[mask]] | ||
res += WaveMultiPrefixBitAnd(input1, mask); | ||
|
||
// CHECK: [[input1:%[0-9]+]] = OpLoad %v4uint %input1 | ||
// CHECK: [[mask:%[0-9]+]] = OpLoad %v4uint %mask | ||
// CHECK: {{%[0-9]+}} = OpGroupNonUniformBitwiseOr %v4uint %uint_3 PartitionedExclusiveScanNV [[input1]] [[mask]] | ||
res += WaveMultiPrefixBitOr(input1, mask); | ||
|
||
// CHECK: [[input1:%[0-9]+]] = OpLoad %v4uint %input1 | ||
// CHECK: [[mask:%[0-9]+]] = OpLoad %v4uint %mask | ||
// CHECK: {{%[0-9]+}} = OpGroupNonUniformBitwiseXor %v4uint %uint_3 PartitionedExclusiveScanNV [[input1]] [[mask]] | ||
res += WaveMultiPrefixBitXor(input1, mask); | ||
return res; | ||
} |
13 changes: 13 additions & 0 deletions
13
tools/clang/test/CodeGenSPIRV/intrinsics.sm6_5.multiprefix.unimplemented.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: not %dxc -T ps_6_5 -E main -fcgl %s -spirv 2>&1 | FileCheck %s | ||
|
||
StructuredBuffer<uint4> g_mask; | ||
|
||
uint main(uint input : ATTR0) : SV_Target { | ||
uint4 mask = g_mask[0]; | ||
|
||
uint res = uint4(0, 0, 0, 0); | ||
// CHECK: error: WaveMultiPrefixCountBits intrinsic function unimplemented | ||
res.x += WaveMultiPrefixCountBits((input.x == 1), mask); | ||
|
||
return res; | ||
} |