Skip to content

Commit 8342b32

Browse files
committed
Implement UAVsAtEveryStage shader flag
1 parent f418981 commit 8342b32

13 files changed

+173
-1
lines changed

llvm/lib/Target/DirectX/DXILShaderFlags.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,26 @@ void ModuleShaderFlags::initialize(Module &M, DXILResourceTypeMap &DRTM,
265265
NumUAVs += UAV.getBinding().Size;
266266
if (NumUAVs > 8)
267267
CombinedSFMask.Max64UAVs = true;
268+
269+
// Set UAVsAtEveryStage flag based on the presence of UAVs, the shader
270+
// model version, and the shader environment
271+
if (!DRM.uavs().empty()) {
272+
if (MMDI.ValidatorVersion < VersionTuple(1, 8))
273+
CombinedSFMask.UAVsAtEveryStage =
274+
MMDI.ShaderProfile != Triple::EnvironmentType::Compute &&
275+
MMDI.ShaderProfile != Triple::EnvironmentType::Pixel;
276+
else // MMDI.ValidatorVersion >= VersionTuple(1, 8)
277+
switch (MMDI.ShaderProfile) {
278+
default:
279+
break;
280+
case Triple::EnvironmentType::Vertex:
281+
case Triple::EnvironmentType::Hull:
282+
case Triple::EnvironmentType::Domain:
283+
case Triple::EnvironmentType::Geometry:
284+
CombinedSFMask.UAVsAtEveryStage = true;
285+
break;
286+
}
287+
}
268288
}
269289

270290
void ComputedShaderFlags::print(raw_ostream &OS) const {

llvm/test/CodeGen/DirectX/ShaderFlags/max-64-uavs-array-sm6_5.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,10 @@ define void @test() "hlsl.export" {
2929
ret void
3030
}
3131

32+
; Set dx.valver and dx.resmayalias to prevent flags ResMayNotAlias and
33+
; UAVsAtEveryStage from being set, as to not distract from the flag that is
34+
; actually being tested
3235
!llvm.module.flags = !{!0}
36+
!dx.valver = !{!1}
3337
!0 = !{i32 1, !"dx.resmayalias", i32 1}
38+
!1 = !{i32 1, i32 8}

llvm/test/CodeGen/DirectX/ShaderFlags/max-64-uavs-array-sm6_6.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,10 @@ define void @test() "hlsl.export" {
2929
ret void
3030
}
3131

32+
; Set dx.valver and dx.resmayalias to prevent flags ResMayNotAlias and
33+
; UAVsAtEveryStage from being set, as to not distract from the flag that is
34+
; actually being tested
3235
!llvm.module.flags = !{!0}
36+
!dx.valver = !{!1}
3337
!0 = !{i32 1, !"dx.resmayalias", i32 1}
38+
!1 = !{i32 1, i32 8}

llvm/test/CodeGen/DirectX/ShaderFlags/max-64-uavs.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,10 @@ define void @test() "hlsl.export" {
5656
ret void
5757
}
5858

59+
; Set dx.valver and dx.resmayalias to prevent flags ResMayNotAlias and
60+
; UAVsAtEveryStage from being set, as to not distract from the flag that is
61+
; actually being tested
5962
!llvm.module.flags = !{!0}
63+
!dx.valver = !{!1}
6064
!0 = !{i32 1, !"dx.resmayalias", i32 1}
65+
!1 = !{i32 1, i32 8}

llvm/test/CodeGen/DirectX/ShaderFlags/res-may-alias-0.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ define float @loadSRV() #0 {
4040
; But if it does, ensure that it has no effect.
4141
!0 = !{i32 1, !"dx.resmayalias", i32 0}
4242

43+
; Set dx.valver to prevent the flag UAVsAtEveryStage from being set, as to not
44+
; distract from the flag that is actually being tested
45+
!dx.valver = !{!1}
46+
!1 = !{i32 1, i32 8}
47+
4348
attributes #0 = { convergent norecurse nounwind "hlsl.export"}

llvm/test/CodeGen/DirectX/ShaderFlags/res-may-alias-1.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ define float @loadSRV() #0 {
3535
}
3636

3737
!llvm.module.flags = !{!0}
38-
3938
!0 = !{i32 1, !"dx.resmayalias", i32 1}
4039

40+
; Set dx.valver to prevent the flag UAVsAtEveryStage from being set, as to not
41+
; distract from the flag that is actually being tested
42+
!dx.valver = !{!1}
43+
!1 = !{i32 1, i32 8}
44+
4145
attributes #0 = { convergent norecurse nounwind "hlsl.export"}

llvm/test/CodeGen/DirectX/ShaderFlags/res-may-not-alias-shadermodel6.6.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ define float @loadSRV() #0 {
3434
ret float %val
3535
}
3636

37+
; Set dx.valver to prevent the flag UAVsAtEveryStage from being set, as to not
38+
; distract from the flag that is actually being tested
39+
!dx.valver = !{!0}
40+
!0 = !{i32 1, i32 8}
41+
3742
attributes #0 = { convergent norecurse nounwind "hlsl.export"}

llvm/test/CodeGen/DirectX/ShaderFlags/res-may-not-alias-shadermodel6.7.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ define float @loadSRV() #0 {
3535
ret float %val
3636
}
3737

38+
; Set dx.valver to prevent the flag UAVsAtEveryStage from being set, as to not
39+
; distract from the flag that is actually being tested
40+
!dx.valver = !{!0}
41+
!0 = !{i32 1, i32 8}
42+
3843
attributes #0 = { convergent norecurse nounwind "hlsl.export"}

llvm/test/CodeGen/DirectX/ShaderFlags/res-may-not-alias-shadermodel6.8.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ define float @loadSRV() #0 {
3535
ret float %val
3636
}
3737

38+
; Set dx.valver to prevent the flag UAVsAtEveryStage from being set, as to not
39+
; distract from the flag that is actually being tested
40+
!dx.valver = !{!0}
41+
!0 = !{i32 1, i32 8}
42+
3843
attributes #0 = { convergent norecurse nounwind "hlsl.export"}

llvm/test/CodeGen/DirectX/ShaderFlags/typed-uav-load-additional-formats.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ define void @noload(<4 x float> %val) #0 {
4343
ret void
4444
}
4545

46+
; Set dx.valver and dx.resmayalias to prevent flags ResMayNotAlias and
47+
; UAVsAtEveryStage from being set, as to not distract from the flag that is
48+
; actually being tested
4649
!llvm.module.flags = !{!0}
50+
!dx.valver = !{!1}
4751
!0 = !{i32 1, !"dx.resmayalias", i32 1}
52+
!1 = !{i32 1, i32 8}
4853

4954
attributes #0 = { convergent norecurse nounwind "hlsl.export"}
5055

0 commit comments

Comments
 (0)