-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DirectX] add enum for PSV resource type/kind/flag. #106227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add ResourceType, ResourceKind and ResourceFlag enum class for PSV resource. This is for llvm#103275
@llvm/pr-subscribers-backend-directx @llvm/pr-subscribers-llvm-binary-utilities Author: Xiang Li (python3kgae) ChangesAdd ResourceType, ResourceKind and ResourceFlag enum class for PSV resource. This is for #103275 Patch is 64.55 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/106227.diff 40 Files Affected:
diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h
index 013431faff2728..d0e8fab219d5e8 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -299,6 +299,27 @@ enum class InterpolationMode : uint8_t {
ArrayRef<EnumEntry<InterpolationMode>> getInterpolationModes();
+#define RESOURCE_TYPE(Val, Enum) Enum = Val,
+enum class ResourceType : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+ArrayRef<EnumEntry<ResourceType>> getResourceTypes();
+
+#define RESOURCE_KIND(Val, Enum) Enum = Val,
+enum class ResourceKind : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+ArrayRef<EnumEntry<ResourceKind>> getResourceKinds();
+
+#define RESOURCE_FLAG(Val, Enum) Enum = Val,
+enum class ResourceFlag : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+ArrayRef<EnumEntry<ResourceFlag>> getResourceFlags();
+
namespace v0 {
struct RuntimeInfo {
PipelinePSVInfo StageInfo;
@@ -315,7 +336,7 @@ struct RuntimeInfo {
};
struct ResourceBindInfo {
- uint32_t Type;
+ ResourceType Type;
uint32_t Space;
uint32_t LowerBound;
uint32_t UpperBound;
@@ -417,8 +438,8 @@ struct RuntimeInfo : public v1::RuntimeInfo {
};
struct ResourceBindInfo : public v0::ResourceBindInfo {
- uint32_t Kind;
- uint32_t Flags;
+ ResourceKind Kind;
+ ResourceFlag Flags;
void swapBytes() {
v0::ResourceBindInfo::swapBytes();
diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
index 62dc573555198b..4111cecb018bb3 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
+++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
@@ -150,6 +150,52 @@ INTERPOLATION_MODE(8, Invalid)
#undef INTERPOLATION_MODE
#endif // INTERPOLATION_MODE
+#ifdef RESOURCE_TYPE
+RESOURCE_TYPE(0, Invalid)
+RESOURCE_TYPE(1, Sampler)
+RESOURCE_TYPE(2, CBV)
+RESOURCE_TYPE(3, SRVTyped)
+RESOURCE_TYPE(4, SRVRaw)
+RESOURCE_TYPE(5, SRVStructured)
+RESOURCE_TYPE(6, UAVTyped)
+RESOURCE_TYPE(7, UAVRaw)
+RESOURCE_TYPE(8, UAVStructured)
+RESOURCE_TYPE(9, UAVStructuredWithCounter)
+
+#undef RESOURCE_TYPE
+#endif // RESOURCE_TYPE
+
+#ifdef RESOURCE_KIND
+RESOURCE_KIND(0, Invalid)
+RESOURCE_KIND(1, Texture1D)
+RESOURCE_KIND(2, Texture2D)
+RESOURCE_KIND(3, Texture2DMS)
+RESOURCE_KIND(4, Texture3D)
+RESOURCE_KIND(5, TextureCube)
+RESOURCE_KIND(6, Texture1DArray)
+RESOURCE_KIND(7, Texture2DArray)
+RESOURCE_KIND(8, Texture2DMSArray)
+RESOURCE_KIND(9, TextureCubeArray)
+RESOURCE_KIND(10, TypedBuffer)
+RESOURCE_KIND(11, RawBuffer)
+RESOURCE_KIND(12, StructuredBuffer)
+RESOURCE_KIND(13, CBuffer)
+RESOURCE_KIND(14, Sampler)
+RESOURCE_KIND(15, TBuffer)
+RESOURCE_KIND(16, RTAccelerationStructure)
+RESOURCE_KIND(17, FeedbackTexture2D)
+RESOURCE_KIND(18, FeedbackTexture2DArray)
+
+#undef RESOURCE_KIND
+#endif // RESOURCE_KIND
+
+#ifdef RESOURCE_FLAG
+RESOURCE_FLAG(0, None)
+RESOURCE_FLAG(1, UsedByAtomic64)
+
+#undef RESOURCE_FLAG
+#endif // RESOURCE_FLAG
+
#ifdef D3D_SYSTEM_VALUE
D3D_SYSTEM_VALUE(0, Undefined)
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index 9c4d9e19f11ba3..e432359b7bbd07 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -176,6 +176,9 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::SignatureParameter)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::SemanticKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::ComponentType)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::InterpolationMode)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::ResourceType)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::ResourceKind)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::ResourceFlag)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::D3DSystemValue)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::SigComponentType)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::SigMinPrecision)
diff --git a/llvm/lib/BinaryFormat/DXContainer.cpp b/llvm/lib/BinaryFormat/DXContainer.cpp
index 9c0e657b069697..efeb67acd3edc2 100644
--- a/llvm/lib/BinaryFormat/DXContainer.cpp
+++ b/llvm/lib/BinaryFormat/DXContainer.cpp
@@ -89,3 +89,34 @@ static const EnumEntry<PSV::InterpolationMode> InterpolationModeNames[] = {
ArrayRef<EnumEntry<PSV::InterpolationMode>> PSV::getInterpolationModes() {
return ArrayRef(InterpolationModeNames);
}
+
+#define RESOURCE_TYPE(Val, Enum) {#Enum, PSV::ResourceType::Enum},
+
+static const EnumEntry<PSV::ResourceType> ResourceTypeNames[] = {
+#include "llvm/BinaryFormat/DXContainerConstants.def"
+};
+
+ArrayRef<EnumEntry<PSV::ResourceType>> PSV::getResourceTypes() {
+ return ArrayRef(ResourceTypeNames);
+}
+
+#define RESOURCE_KIND(Val, Enum) {#Enum, PSV::ResourceKind::Enum},
+
+static const EnumEntry<PSV::ResourceKind> ResourceKindNames[] = {
+#include "llvm/BinaryFormat/DXContainerConstants.def"
+};
+
+ArrayRef<EnumEntry<PSV::ResourceKind>> PSV::getResourceKinds() {
+ return ArrayRef(ResourceKindNames);
+}
+
+#define RESOURCE_FLAG(Val, Enum) {#Enum, PSV::ResourceFlag::Enum},
+
+static const EnumEntry<PSV::ResourceFlag> ResourceFlagNames[] = {
+#include "llvm/BinaryFormat/DXContainerConstants.def"
+};
+
+ArrayRef<EnumEntry<PSV::ResourceFlag>> PSV::getResourceFlags() {
+ return ArrayRef(ResourceFlagNames);
+}
+
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 38063670aee6e8..21a966d5abd132 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -254,6 +254,24 @@ void ScalarEnumerationTraits<dxbc::PSV::InterpolationMode>::enumeration(
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
}
+void ScalarEnumerationTraits<dxbc::PSV::ResourceType>::enumeration(
+ IO &IO, dxbc::PSV::ResourceType &Value) {
+ for (const auto &E : dxbc::PSV::getResourceTypes())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::PSV::ResourceKind>::enumeration(
+ IO &IO, dxbc::PSV::ResourceKind &Value) {
+ for (const auto &E : dxbc::PSV::getResourceKinds())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::PSV::ResourceFlag>::enumeration(
+ IO &IO, dxbc::PSV::ResourceFlag &Value) {
+ for (const auto &E : dxbc::PSV::getResourceFlags())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
void ScalarEnumerationTraits<dxbc::D3DSystemValue>::enumeration(
IO &IO, dxbc::D3DSystemValue &Value) {
for (const auto &E : dxbc::getD3DSystemValues())
diff --git a/llvm/test/ObjectYAML/DXContainer/DomainMaskVectors.yaml b/llvm/test/ObjectYAML/DXContainer/DomainMaskVectors.yaml
index 713fbc61e094b5..04e9edd7398ec0 100644
--- a/llvm/test/ObjectYAML/DXContainer/DomainMaskVectors.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/DomainMaskVectors.yaml
@@ -70,12 +70,12 @@ Parts:
NumThreadsZ: 0
ResourceStride: 24
Resources:
- - Type: 2
+ - Type: CBV
Space: 0
LowerBound: 0
UpperBound: 0
- Kind: 13
- Flags: 0
+ Kind: CBuffer
+ Flags: None
SigInputElements:
- Name: AAA_HSFoo
Indices: [ 0 ]
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml
index d15bfadda41f07..3597b684fa032a 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml
@@ -19,11 +19,11 @@ Parts:
MaximumWaveLaneCount: 4294967295
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -48,11 +48,11 @@ Parts:
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-compute.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-compute.yaml
index 7e9f2fbd8b54de..4f8e60b780c560 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv0-compute.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-compute.yaml
@@ -18,11 +18,11 @@ Parts:
MaximumWaveLaneCount: 4294967295
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -46,11 +46,11 @@ Parts:
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml
index db2aee954b3466..fb8d148c286343 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml
@@ -21,11 +21,11 @@ Parts:
MaximumWaveLaneCount: 4294967295
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -52,11 +52,11 @@ Parts:
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-geometry.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-geometry.yaml
index 5509ac669e2d6b..cd59c6a10d1a3e 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv0-geometry.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-geometry.yaml
@@ -22,11 +22,11 @@ Parts:
MaximumWaveLaneCount: 4294967295
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -54,11 +54,11 @@ Parts:
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml
index cd60f2b192b2e2..a672f9260516a4 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml
@@ -22,11 +22,11 @@ Parts:
MaximumWaveLaneCount: 4294967295
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -54,11 +54,11 @@ Parts:
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml
index 07fb656c5b72a7..07fee2ff65e5bf 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml
@@ -23,11 +23,11 @@ Parts:
MaximumWaveLaneCount: 4294967295
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -56,11 +56,11 @@ Parts:
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml
index c7f956e5740cca..6bf18f340c3399 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml
@@ -20,11 +20,11 @@ Parts:
MaximumWaveLaneCount: 4294967295
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -50,11 +50,11 @@ Parts:
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml
index 6df9169b73e2f5..e0690fba0e8c4c 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml
@@ -19,11 +19,11 @@ Parts:
MaximumWaveLaneCount: 4294967295
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -48,11 +48,11 @@ Parts:
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml
index 982235549cddc6..beb85ee9828207 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml
@@ -22,11 +22,11 @@ Parts:
SigOutputVectors: [ 8, 16, 32, 64 ]
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -62,11 +62,11 @@ Parts:
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml
index 629d45c65a2081..6c90fbb206c6af 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml
@@ -21,11 +21,11 @@ Parts:
SigOutputVectors: [ 8, 16, 32, 64 ]
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - Type: Invalid
Space: 32768
LowerBound: 8388608
UpperBound: 2147483648
@@ -60,11 +60,11 @@ Parts:
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
# CHECK-NEXT: ResourceStride: 16
# CHECK-NEXT: Resources:
-# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: - Type: Sampler
# CHECK-NEXT: Space: 2
# CHECK-NEXT: LowerBound: 3
# CHECK-NEXT: UpperBound: 4
-# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: - Type: Invalid
# CHECK-NEXT: Space: 32768
# CHECK-NEXT: LowerBound: 8388608
# CHECK-NEXT: UpperBound: 2147483648
diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml
index 941ec16544a2df..28a4884d1228f3 100644
--- a/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml
@@ -25,11 +25,11 @@ Parts:
SigOutputVectors: [ 0, 16, 32, 64 ]
ResourceStride: 16
Resources:
- - Type: 1
+ - Type: Sampler
Space: 2
LowerBound: 3
UpperBound: 4
- - Type: 128
+ - T...
[truncated]
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
#define RESOURCE_TYPE(Val, Enum) {#Enum, PSV::ResourceType::Enum}, | ||
|
||
static const EnumEntry<PSV::ResourceType> ResourceTypeNames[] = { | ||
#include "llvm/BinaryFormat/DXContainerConstants.def" | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Style-wise, we usually put the #define
immediately before #include
of a def file, like so:
#define RESOURCE_TYPE(Val, Enum) {#Enum, PSV::ResourceType::Enum}, | |
static const EnumEntry<PSV::ResourceType> ResourceTypeNames[] = { | |
#include "llvm/BinaryFormat/DXContainerConstants.def" | |
}; | |
static const EnumEntry<PSV::ResourceType> ResourceTypeNames[] = { | |
#define RESOURCE_TYPE(Val, Enum) {#Enum, PSV::ResourceType::Enum}, | |
#include "llvm/BinaryFormat/DXContainerConstants.def" | |
}; |
I find this makes it more obvious that the two things are connected. This suggestion also applies to the enum definitions in the header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to give similar feedback in that llvm/include/llvm/BinaryFormat/DXContainer.h but it pretty consistently puts the #define
before the enum.
I wonder if a fix here, or maybe in a follow up, to update DXContainer to this way would be worth doing?
- Type: 128 | ||
- Type: Invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if this is a dumb question, but I'm not very familiar with the YAML printer. Is this printing the enum value of 0
(ie, "Invalid") or is the value in memory 128
and anything outside of the enum range prints "Invalid"? If it's 0
, what part of this change caused the value to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that for enum class types, you cannot say 128 anymore.
Have to choose from the enum names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just confused because I see some new definitions and I see test changes, but I don't see the producer of the value changing anywhere so it isn't clear to me what the actual difference in behaviour is. I'm guessing the new ScalarEnumerationTraits
specializations are the cause, but is the value different in the actual DXContainer or is it just a display thing with the YAML?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value should not change, unless it does not have a mapping to the enum values.
It just YAML now require the names instead of integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems kind of unfortunate to not see the actual value that's in the structure in our debug tools - couldn't this mean that we end up putting garbage values in the actual container without noticing it in our tests? I guess if that's how the yaml printing works it's a wider issue and doesn't need to block this change in particular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. 128
is garbage value which should not happen.
# CHECK-NEXT: Kind: 5 | ||
# CHECK-NEXT: Flags: 6 | ||
# CHECK-NEXT: - Type: 128 | ||
# CHECK-NEXT: Kind: TextureCube | ||
# CHECK-NEXT: Flags: 0 | ||
# CHECK-NEXT: - Type: Invalid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did "Flags" change from 6
to 0
? Also shouldn't a value of 0
for flags print "None" since that's the name of the value in the ResourceFlag enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flags need to be able express FlagA | FlagB, so it has to be uint. But we only have 0 and 1 now, so maybe make it enum is OK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, fair. Using the actual value for flags seems fine. Is that a heuristic in the yaml printer or something? I don't see any code that explicitly opts in or out of the enum value printing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. We don't actually use the ResourceFlag enum in this change at all, so LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::ResourceFlag)
and ScalarEnumerationTraits<dxbc::PSV::ResourceFlag>::enumeration
are just entirely dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right.
I'll remove these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in #106617
Add ResourceType, ResourceKind and ResourceFlag enum class for PSV resource.
This is for #103275