void swapBytes(Triple::EnvironmentType Stage) { StageInfo.swapBytes(Stage); }
};
+struct ResourceBindInfo {
+ uint32_t Type;
+ uint32_t Space;
+ uint32_t LowerBound;
+ uint32_t UpperBound;
+
+ void swapBytes() {
+ sys::swapByteOrder(Type);
+ sys::swapByteOrder(Space);
+ sys::swapByteOrder(LowerBound);
+ sys::swapByteOrder(UpperBound);
+ }
+};
+
} // namespace v0
namespace v1 {
}
};
+struct ResourceBindInfo : public v0::ResourceBindInfo {
+ uint32_t Kind;
+ uint32_t Flags;
+
+ void swapBytes() {
+ sys::swapByteOrder(Kind);
+ sys::swapByteOrder(Flags);
+ }
+};
+
} // namespace v2
} // namespace PSV
// RuntimeInfo.
struct PSVRuntimeInfo {
dxbc::PSV::v2::RuntimeInfo BaseData;
+ std::vector<dxbc::PSV::v2::ResourceBindInfo> Resources;
// Serialize PSVInfo into the provided raw_ostream. The version field
// specifies the data version to encode, the default value specifies encoding
void swapBytes(Triple::EnvironmentType Stage) {
BaseData.swapBytes();
BaseData.swapBytes(Stage);
+ for (auto Res : Resources)
+ Res.swapBytes();
}
};
namespace DirectX {
class PSVRuntimeInfo {
+
+ // This class provides a view into the underlying resource array. The Resource
+ // data is little-endian encoded and may not be properly aligned to read
+ // directly from. The dereference operator creates a copy of the data and byte
+ // swaps it as appropriate.
+ struct ResourceArray {
+ StringRef Data;
+ size_t Stride; // size of each element in the list.
+
+ ResourceArray() = default;
+ ResourceArray(StringRef D, size_t S) : Data(D), Stride(S) {}
+
+ using value_type = dxbc::PSV::v2::ResourceBindInfo;
+
+ struct iterator {
+ StringRef Data;
+ size_t Stride; // size of each element in the list.
+ const char *Current;
+
+ iterator(const ResourceArray &A, const char *C)
+ : Data(A.Data), Stride(A.Stride), Current(C) {}
+ iterator(const iterator &) = default;
+
+ value_type operator*() {
+ // Explicitly zero the structure so that unused fields are zeroed. It is
+ // up to the user to know if the fields are used by verifying the PSV
+ // version.
+ value_type Val = {{0, 0, 0, 0}, 0, 0};
+ if (Current >= Data.end())
+ return Val;
+ memcpy(static_cast<void *>(&Val), Current, Stride);
+ if (sys::IsBigEndianHost)
+ Val.swapBytes();
+ return Val;
+ }
+
+ iterator operator++() {
+ if (Current < Data.end())
+ Current += Stride;
+ return *this;
+ }
+
+ iterator operator++(int) {
+ iterator Tmp = *this;
+ ++*this;
+ return Tmp;
+ }
+
+ iterator operator--() {
+ if (Current > Data.begin())
+ Current -= Stride;
+ return *this;
+ }
+
+ iterator operator--(int) {
+ iterator Tmp = *this;
+ --*this;
+ return Tmp;
+ }
+
+ bool operator==(const iterator I) { return I.Current == Current; }
+ bool operator!=(const iterator I) { return !(*this == I); }
+ };
+
+ iterator begin() const { return iterator(*this, Data.begin()); }
+
+ iterator end() const { return iterator(*this, Data.end()); }
+
+ size_t size() const { return Data.size() / Stride; }
+ };
+
StringRef Data;
uint32_t Size;
using InfoStruct =
std::variant<std::monostate, dxbc::PSV::v0::RuntimeInfo,
dxbc::PSV::v1::RuntimeInfo, dxbc::PSV::v2::RuntimeInfo>;
InfoStruct BasicInfo;
+ ResourceArray Resources;
public:
PSVRuntimeInfo(StringRef D) : Data(D), Size(0) {}
Error parse(uint16_t ShaderKind);
uint32_t getSize() const { return Size; }
+ uint32_t getResourceCount() const { return Resources.size(); }
+ ResourceArray getResources() const { return Resources; }
+
uint32_t getVersion() const {
return Size >= sizeof(dxbc::PSV::v2::RuntimeInfo)
? 2
std::vector<llvm::yaml::Hex8> Digest;
};
+using ResourceBindInfo = dxbc::PSV::v2::ResourceBindInfo;
+
struct PSVInfo {
// The version field isn't actually encoded in the file, but it is inferred by
// the size of data regions. We include it in the yaml because it simplifies
uint32_t Version;
dxbc::PSV::v2::RuntimeInfo Info;
+ std::vector<ResourceBindInfo> Resources;
void mapInfoForVersion(yaml::IO &IO);
} // namespace llvm
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::Part)
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::ResourceBindInfo)
namespace llvm {
class raw_ostream;
static void mapping(IO &IO, DXContainerYAML::Object &Obj);
};
+template <> struct MappingTraits<DXContainerYAML::ResourceBindInfo> {
+ static void mapping(IO &IO, DXContainerYAML::ResourceBindInfo &Res);
+};
+
} // namespace yaml
} // namespace llvm
using namespace llvm;
using namespace llvm::mcdxbc;
+using namespace llvm::dxbc::PSV;
void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const {
uint32_t InfoSize;
OS.write(reinterpret_cast<const char *>(&InfoSizeSwapped), sizeof(uint32_t));
// Write the info itself.
OS.write(reinterpret_cast<const char *>(&BaseData), InfoSize);
+
+ uint32_t ResourceCount = static_cast<uint32_t>(Resources.size());
+ if (sys::IsBigEndianHost)
+ sys::swapByteOrder(ResourceCount);
+ OS.write(reinterpret_cast<const char *>(&ResourceCount), sizeof(uint32_t));
+
+ size_t BindingSize = (Version < 2) ? sizeof(v0::ResourceBindInfo)
+ : sizeof(v2::ResourceBindInfo);
+ for (const auto &Res : Resources)
+ OS.write(reinterpret_cast<const char *>(&Res), BindingSize);
}
}
Current += Size;
+ uint32_t ResourceCount = 0;
+ if (Error Err = readInteger(Data, Current, ResourceCount))
+ return Err;
+ Current += sizeof(uint32_t);
+
+ Resources.Stride = (PSVVersion < 2) ? sizeof(v0::ResourceBindInfo)
+ : sizeof(v2::ResourceBindInfo);
+ size_t BindingDataSize = Resources.Stride * ResourceCount;
+ Resources.Data = Data.substr(Current - Data.begin(), BindingDataSize);
+
+ Current += BindingDataSize;
+
return Error::success();
}
continue;
mcdxbc::PSVRuntimeInfo PSV;
memcpy(&PSV.BaseData, &P.Info->Info, sizeof(dxbc::PSV::v2::RuntimeInfo));
+ PSV.Resources = P.Info->Resources;
if (sys::IsBigEndianHost)
PSV.swapBytes(static_cast<Triple::EnvironmentType>(
IO &IO, DXContainerYAML::PSVInfo &PSV) {
IO.mapRequired("Version", PSV.Version);
+ // Store the PSV version in the YAML context.
+ void *OldContext = IO.getContext();
+ uint32_t Version = PSV.Version;
+ IO.setContext(&Version);
+
// Shader stage is only included in binaries for v1 and later, but we always
// include it since it simplifies parsing and file construction.
IO.mapRequired("ShaderStage", PSV.Info.ShaderStage);
PSV.mapInfoForVersion(IO);
+
+ IO.mapRequired("Resources", PSV.Resources);
+
+ // Restore the YAML context.
+ IO.setContext(OldContext);
}
void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
IO.mapRequired("Parts", Obj.Parts);
}
+void MappingTraits<DXContainerYAML::ResourceBindInfo>::mapping(
+ IO &IO, DXContainerYAML::ResourceBindInfo &Res) {
+ IO.mapRequired("Type", Res.Type);
+ IO.mapRequired("Space", Res.Space);
+ IO.mapRequired("LowerBound", Res.LowerBound);
+ IO.mapRequired("UpperBound", Res.UpperBound);
+
+ const uint32_t *PSVVersion = static_cast<uint32_t *>(IO.getContext());
+ if (*PSVVersion < 2)
+ return;
+
+ IO.mapRequired("Kind", Res.Kind);
+ IO.mapRequired("Flags", Res.Flags);
+}
+
} // namespace yaml
void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) {
PayloadSizeInBytes: 4092
MinimumWaveLaneCount: 0
MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: PayloadSizeInBytes: 4092
# CHECK-NEXT: MinimumWaveLaneCount: 0
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
ShaderStage: 5
MinimumWaveLaneCount: 0
MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: ShaderStage: 5
# CHECK-NEXT: MinimumWaveLaneCount: 0
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
TessellatorDomain: 2056
MinimumWaveLaneCount: 0
MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: TessellatorDomain: 2056
# CHECK-NEXT: MinimumWaveLaneCount: 0
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
OutputPositionPresent: 1
MinimumWaveLaneCount: 0
MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: OutputPositionPresent: 1
# CHECK-NEXT: MinimumWaveLaneCount: 0
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
TessellatorOutputPrimitive: 8192
MinimumWaveLaneCount: 0
MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: TessellatorOutputPrimitive: 8192
# CHECK-NEXT: MinimumWaveLaneCount: 0
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
MaxOutputPrimitives: 4092
MinimumWaveLaneCount: 0
MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: MaxOutputPrimitives: 4092
# CHECK-NEXT: MinimumWaveLaneCount: 0
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SampleFrequency: 96
MinimumWaveLaneCount: 0
MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SampleFrequency: 96
# CHECK-NEXT: MinimumWaveLaneCount: 0
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
OutputPositionPresent: 1
MinimumWaveLaneCount: 0
MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: OutputPositionPresent: 1
# CHECK-NEXT: MinimumWaveLaneCount: 0
# CHECK-NEXT: MaximumWaveLaneCount: 4294967295
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SigPatchConstOrPrimElements: 32
SigInputVectors: 64
SigOutputVectors: [ 8, 16, 32, 64 ]
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SigPatchConstOrPrimElements: 32
# CHECK-NEXT: SigInputVectors: 64
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SigPatchConstOrPrimElements: 32
SigInputVectors: 64
SigOutputVectors: [ 8, 16, 32, 64 ]
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SigPatchConstOrPrimElements: 32
# CHECK-NEXT: SigInputVectors: 64
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SigPatchConstOrPrimElements: 32
SigInputVectors: 64
SigOutputVectors: [ 8, 16, 32, 64 ]
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SigPatchConstOrPrimElements: 32
# CHECK-NEXT: SigInputVectors: 64
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SigPatchConstOrPrimElements: 32
SigInputVectors: 64
SigOutputVectors: [ 8, 16, 32, 64 ]
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SigPatchConstOrPrimElements: 32
# CHECK-NEXT: SigInputVectors: 64
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SigPatchConstOrPrimElements: 32
SigInputVectors: 64
SigOutputVectors: [ 8, 16, 32, 64 ]
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SigPatchConstOrPrimElements: 32
# CHECK-NEXT: SigInputVectors: 64
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SigPatchConstOrPrimElements: 32
SigInputVectors: 64
SigOutputVectors: [ 8, 16, 32, 64 ]
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SigPatchConstOrPrimElements: 32
# CHECK-NEXT: SigInputVectors: 64
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SigPatchConstOrPrimElements: 32
SigInputVectors: 64
SigOutputVectors: [ 8, 16, 32, 64 ]
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SigPatchConstOrPrimElements: 32
# CHECK-NEXT: SigInputVectors: 64
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
SigPatchConstOrPrimElements: 32
SigInputVectors: 64
SigOutputVectors: [ 8, 16, 32, 64 ]
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: SigPatchConstOrPrimElements: 32
# CHECK-NEXT: SigInputVectors: 64
# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ]
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
# CHECK-NEXT: Name
NumThreadsX: 512
NumThreadsY: 1024
NumThreadsZ: 2048
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ Kind: 5
+ Flags: 6
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
+ Kind: 65535
+ Flags: 16776960
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: NumThreadsX: 512
# CHECK-NEXT: NumThreadsY: 1024
# CHECK-NEXT: NumThreadsZ: 2048
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: Kind: 5
+# CHECK-NEXT: Flags: 6
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
+# CHECK-NEXT: Kind: 65535
+# CHECK-NEXT: Flags: 16776960
# CHECK-NEXT: Name
NumThreadsX: 512
NumThreadsY: 1024
NumThreadsZ: 2048
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ Kind: 5
+ Flags: 6
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
+ Kind: 65535
+ Flags: 16776960
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: NumThreadsX: 512
# CHECK-NEXT: NumThreadsY: 1024
# CHECK-NEXT: NumThreadsZ: 2048
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: Kind: 5
+# CHECK-NEXT: Flags: 6
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
+# CHECK-NEXT: Kind: 65535
+# CHECK-NEXT: Flags: 16776960
# CHECK-NEXT: Name
NumThreadsX: 512
NumThreadsY: 1024
NumThreadsZ: 2048
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ Kind: 5
+ Flags: 6
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
+ Kind: 65535
+ Flags: 16776960
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: NumThreadsX: 512
# CHECK-NEXT: NumThreadsY: 1024
# CHECK-NEXT: NumThreadsZ: 2048
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: Kind: 5
+# CHECK-NEXT: Flags: 6
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
+# CHECK-NEXT: Kind: 65535
+# CHECK-NEXT: Flags: 16776960
# CHECK-NEXT: Name
NumThreadsX: 512
NumThreadsY: 1024
NumThreadsZ: 2048
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ Kind: 5
+ Flags: 6
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
+ Kind: 65535
+ Flags: 16776960
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: NumThreadsX: 512
# CHECK-NEXT: NumThreadsY: 1024
# CHECK-NEXT: NumThreadsZ: 2048
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: Kind: 5
+# CHECK-NEXT: Flags: 6
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
+# CHECK-NEXT: Kind: 65535
+# CHECK-NEXT: Flags: 16776960
# CHECK-NEXT: Name
NumThreadsX: 512
NumThreadsY: 1024
NumThreadsZ: 2048
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ Kind: 5
+ Flags: 6
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
+ Kind: 65535
+ Flags: 16776960
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: NumThreadsX: 512
# CHECK-NEXT: NumThreadsY: 1024
# CHECK-NEXT: NumThreadsZ: 2048
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: Kind: 5
+# CHECK-NEXT: Flags: 6
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
+# CHECK-NEXT: Kind: 65535
+# CHECK-NEXT: Flags: 16776960
# CHECK-NEXT: Name
NumThreadsX: 512
NumThreadsY: 1024
NumThreadsZ: 2048
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ Kind: 5
+ Flags: 6
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
+ Kind: 65535
+ Flags: 16776960
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: NumThreadsX: 512
# CHECK-NEXT: NumThreadsY: 1024
# CHECK-NEXT: NumThreadsZ: 2048
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: Kind: 5
+# CHECK-NEXT: Flags: 6
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
+# CHECK-NEXT: Kind: 65535
+# CHECK-NEXT: Flags: 16776960
# CHECK-NEXT: Name
NumThreadsX: 512
NumThreadsY: 1024
NumThreadsZ: 2048
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ Kind: 5
+ Flags: 6
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
+ Kind: 65535
+ Flags: 16776960
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: NumThreadsX: 512
# CHECK-NEXT: NumThreadsY: 1024
# CHECK-NEXT: NumThreadsZ: 2048
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: Kind: 5
+# CHECK-NEXT: Flags: 6
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
+# CHECK-NEXT: Kind: 65535
+# CHECK-NEXT: Flags: 16776960
# CHECK-NEXT: Name
NumThreadsX: 512
NumThreadsY: 1024
NumThreadsZ: 2048
+ Resources:
+ - Type: 1
+ Space: 2
+ LowerBound: 3
+ UpperBound: 4
+ Kind: 5
+ Flags: 6
+ - Type: 128
+ Space: 32768
+ LowerBound: 8388608
+ UpperBound: 2147483648
+ Kind: 65535
+ Flags: 16776960
- Name: DXIL
Size: 24
Program:
# CHECK-NEXT: NumThreadsX: 512
# CHECK-NEXT: NumThreadsY: 1024
# CHECK-NEXT: NumThreadsZ: 2048
+# CHECK-NEXT: Resources:
+# CHECK-NEXT: - Type: 1
+# CHECK-NEXT: Space: 2
+# CHECK-NEXT: LowerBound: 3
+# CHECK-NEXT: UpperBound: 4
+# CHECK-NEXT: Kind: 5
+# CHECK-NEXT: Flags: 6
+# CHECK-NEXT: - Type: 128
+# CHECK-NEXT: Space: 32768
+# CHECK-NEXT: LowerBound: 8388608
+# CHECK-NEXT: UpperBound: 2147483648
+# CHECK-NEXT: Kind: 65535
+# CHECK-NEXT: Flags: 16776960
# CHECK-NEXT: Name
else if (const auto *P =
std::get_if<dxbc::PSV::v2::RuntimeInfo>(&PSVInfo->getInfo()))
NewPart.Info = DXContainerYAML::PSVInfo(P);
+ for (auto Res : PSVInfo->getResources())
+ NewPart.Info->Resources.push_back(Res);
break;
}
case dxbc::PartType::Unknown:
#include "llvm/Object/DXContainer.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/ObjectYAML/DXContainerYAML.h"
+#include "llvm/ObjectYAML/yaml2obj.h"
#include "llvm/Support/MemoryBufferRef.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
EXPECT_TRUE(memcmp(It->Part.Name, "FKE6", 4) == 0);
}
}
+
+static Expected<DXContainer>
+generateDXContainer(StringRef Yaml, SmallVectorImpl<char> &BinaryData) {
+ DXContainerYAML::Object Obj;
+ SMDiagnostic GenerateDiag;
+ yaml::Input YIn(
+ Yaml, /*Ctxt=*/nullptr,
+ [](const SMDiagnostic &Diag, void *DiagContext) {
+ *static_cast<SMDiagnostic *>(DiagContext) = Diag;
+ },
+ &GenerateDiag);
+
+ YIn >> Obj;
+ if (YIn.error())
+ return createStringError(YIn.error(), GenerateDiag.getMessage());
+
+ raw_svector_ostream OS(BinaryData);
+ std::string ErrorMsg;
+ if (!yaml::yaml2dxcontainer(
+ Obj, OS, [&ErrorMsg](const Twine &Msg) { ErrorMsg = Msg.str(); }))
+ return createStringError(YIn.error(), ErrorMsg);
+
+ MemoryBufferRef BinaryDataRef = MemoryBufferRef(OS.str(), "");
+
+ return DXContainer::create(BinaryDataRef);
+}
+
+TEST(DXCFile, PSVResourceIterators) {
+ const char *Yaml = R"(
+--- !dxcontainer
+Header:
+ Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+ Version:
+ Major: 1
+ Minor: 0
+ PartCount: 2
+Parts:
+ - Name: PSV0
+ Size: 144
+ PSVInfo:
+ Version: 0
+ ShaderStage: 14
+ PayloadSizeInBytes: 4092
+ MinimumWaveLaneCount: 0
+ MaximumWaveLaneCount: 4294967295
+ Resources:
+ - Type: 1
+ Space: 1
+ LowerBound: 1
+ UpperBound: 1
+ - Type: 2
+ Space: 2
+ LowerBound: 2
+ UpperBound: 2
+ - Type: 3
+ Space: 3
+ LowerBound: 3
+ UpperBound: 3
+ - Name: DXIL
+ Size: 24
+ Program:
+ MajorVersion: 6
+ MinorVersion: 0
+ ShaderKind: 14
+ Size: 6
+ DXILMajorVersion: 0
+ DXILMinorVersion: 1
+ DXILSize: 0
+...
+)";
+
+ SmallVector<char, 256> BinaryData;
+ auto C = generateDXContainer(Yaml, BinaryData);
+
+ ASSERT_THAT_EXPECTED(C, Succeeded());
+
+ const auto &PSVInfo = C->getPSVInfo();
+ ASSERT_TRUE(PSVInfo.has_value());
+
+ EXPECT_EQ(PSVInfo->getResourceCount(), 3u);
+
+ auto It = PSVInfo->getResources().begin();
+
+ EXPECT_TRUE(It == PSVInfo->getResources().begin());
+
+ dxbc::PSV::v2::ResourceBindInfo Binding;
+
+ Binding = *It;
+ EXPECT_EQ(Binding.Type, 1u);
+ EXPECT_EQ(Binding.Flags, 0u);
+
+ ++It;
+ Binding = *It;
+
+ EXPECT_EQ(Binding.Type, 2u);
+ EXPECT_EQ(Binding.Flags, 0u);
+
+ --It;
+ Binding = *It;
+
+ EXPECT_TRUE(It == PSVInfo->getResources().begin());
+
+ EXPECT_EQ(Binding.Type, 1u);
+ EXPECT_EQ(Binding.Flags, 0u);
+
+ --It;
+ Binding = *It;
+
+ EXPECT_EQ(Binding.Type, 1u);
+ EXPECT_EQ(Binding.Flags, 0u);
+
+ ++It;
+ Binding = *It;
+
+ EXPECT_EQ(Binding.Type, 2u);
+ EXPECT_EQ(Binding.Flags, 0u);
+
+ ++It;
+ Binding = *It;
+
+ EXPECT_EQ(Binding.Type, 3u);
+ EXPECT_EQ(Binding.Flags, 0u);
+
+ EXPECT_FALSE(It == PSVInfo->getResources().end());
+
+ ++It;
+ Binding = *It;
+
+ EXPECT_TRUE(It == PSVInfo->getResources().end());
+ EXPECT_FALSE(It != PSVInfo->getResources().end());
+
+ EXPECT_EQ(Binding.Type, 0u);
+ EXPECT_EQ(Binding.Flags, 0u);
+
+ {
+ auto Old = It++;
+ Binding = *Old;
+
+ EXPECT_TRUE(Old == PSVInfo->getResources().end());
+ EXPECT_FALSE(Old != PSVInfo->getResources().end());
+
+ EXPECT_EQ(Binding.Type, 0u);
+ EXPECT_EQ(Binding.Flags, 0u);
+ }
+
+ Binding = *It;
+
+ EXPECT_TRUE(It == PSVInfo->getResources().end());
+
+ EXPECT_EQ(Binding.Type, 0u);
+ EXPECT_EQ(Binding.Flags, 0u);
+
+ {
+ auto Old = It--;
+ Binding = *Old;
+ EXPECT_TRUE(Old == PSVInfo->getResources().end());
+
+ EXPECT_EQ(Binding.Type, 0u);
+ EXPECT_EQ(Binding.Flags, 0u);
+ }
+
+ Binding = *It;
+
+ EXPECT_EQ(Binding.Type, 3u);
+ EXPECT_EQ(Binding.Flags, 0u);
+}