Skip to content

Commit 5955a67

Browse files
Icohedronbogner
andcommitted
Simplify the logic for setting UAVsAtEveryStage
- Move the logic for setting UAVsAtEveryStage out into its own function to not increase the length of ModuleShaderFlags::initialize - Use one switch statement to handle both special cases with regards to DXIL validator version Co-authored-by: Justin Bogner <[email protected]>
1 parent 1f11675 commit 5955a67

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

llvm/lib/Target/DirectX/DXILShaderFlags.cpp

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,34 @@
3232
using namespace llvm;
3333
using namespace llvm::dxil;
3434

35+
static bool hasUAVsAtEveryStage(DXILResourceMap &DRM, const ModuleMetadataInfo &MMDI) {
36+
if (DRM.uavs().empty())
37+
return false;
38+
39+
switch (MMDI.ShaderProfile) {
40+
default:
41+
return false;
42+
case Triple::EnvironmentType::Compute:
43+
case Triple::EnvironmentType::Pixel:
44+
return false;
45+
case Triple::EnvironmentType::Vertex:
46+
case Triple::EnvironmentType::Geometry:
47+
case Triple::EnvironmentType::Hull:
48+
case Triple::EnvironmentType::Domain:
49+
return true;
50+
case Triple::EnvironmentType::Library:
51+
case Triple::EnvironmentType::RayGeneration:
52+
case Triple::EnvironmentType::Intersection:
53+
case Triple::EnvironmentType::AnyHit:
54+
case Triple::EnvironmentType::ClosestHit:
55+
case Triple::EnvironmentType::Miss:
56+
case Triple::EnvironmentType::Callable:
57+
case Triple::EnvironmentType::Mesh:
58+
case Triple::EnvironmentType::Amplification:
59+
return MMDI.ValidatorVersion < VersionTuple(1, 8);
60+
}
61+
}
62+
3563
static bool checkWaveOps(Intrinsic::ID IID) {
3664
// Currently unsupported intrinsics
3765
// case Intrinsic::dx_wave_getlanecount:
@@ -266,25 +294,7 @@ void ModuleShaderFlags::initialize(Module &M, DXILResourceTypeMap &DRTM,
266294
if (NumUAVs > 8)
267295
CombinedSFMask.Max64UAVs = true;
268296

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-
}
297+
CombinedSFMask.UAVsAtEveryStage = hasUAVsAtEveryStage(DRM, MMDI);
288298
}
289299

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

0 commit comments

Comments
 (0)