From ad93908e3b5593773dfb0484ec06a36fafb5736a Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Wed, 1 Feb 2023 18:39:01 -0600 Subject: [PATCH] [DX] Begin adding support for pipeline state DirectX shader pipeline state validation information is a fairly complicated to serialize data structure. This patch adds the first bit of support for reading and writing the runtime info structure which comes first in the encoded data. Subsequent patches will flesh out the remaining fields of the data structure. There is no official documentation for the format, but the format is roughly documented in the code comment here: https://github.com/microsoft/DirectXShaderCompiler/blob/main/include/dxc /DxilContainer/DxilPipelineStateValidation.h#L731 Reviewed By: python3kgae Differential Revision: https://reviews.llvm.org/D141649 --- llvm/include/llvm/BinaryFormat/DXContainer.h | 209 +++++++++++++++++++++ .../llvm/BinaryFormat/DXContainerConstants.def | 1 + llvm/include/llvm/MC/DXContainerPSVInfo.h | 48 +++++ llvm/include/llvm/Object/DXContainer.h | 37 +++- llvm/include/llvm/ObjectYAML/DXContainerYAML.h | 21 +++ llvm/lib/MC/CMakeLists.txt | 1 + llvm/lib/MC/DXContainerPSVInfo.cpp | 33 ++++ llvm/lib/Object/DXContainer.cpp | 65 +++++++ llvm/lib/ObjectYAML/DXContainerEmitter.cpp | 13 ++ llvm/lib/ObjectYAML/DXContainerYAML.cpp | 131 +++++++++++++ .../DXContainer/PSVv0-amplification.yaml | 39 ++++ .../test/ObjectYAML/DXContainer/PSVv0-compute.yaml | 37 ++++ llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml | 43 +++++ .../ObjectYAML/DXContainer/PSVv0-geometry.yaml | 45 +++++ llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml | 45 +++++ llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml | 47 +++++ llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml | 41 ++++ llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml | 39 ++++ .../DXContainer/PSVv1-amplification.yaml | 51 +++++ .../test/ObjectYAML/DXContainer/PSVv1-compute.yaml | 49 +++++ llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml | 57 ++++++ .../ObjectYAML/DXContainer/PSVv1-geometry.yaml | 59 ++++++ llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml | 59 ++++++ llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml | 63 +++++++ llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml | 53 ++++++ llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml | 51 +++++ .../DXContainer/PSVv2-amplification.yaml | 57 ++++++ .../test/ObjectYAML/DXContainer/PSVv2-compute.yaml | 55 ++++++ llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml | 63 +++++++ .../ObjectYAML/DXContainer/PSVv2-geometry.yaml | 65 +++++++ llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml | 65 +++++++ llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml | 69 +++++++ llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml | 59 ++++++ llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml | 57 ++++++ llvm/tools/obj2yaml/dxcontainer2yaml.cpp | 18 ++ 35 files changed, 1844 insertions(+), 1 deletion(-) create mode 100644 llvm/include/llvm/MC/DXContainerPSVInfo.h create mode 100644 llvm/lib/MC/DXContainerPSVInfo.cpp create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv0-compute.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv0-geometry.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml create mode 100644 llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h index 44b77b1..9c975de 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainer.h +++ b/llvm/include/llvm/BinaryFormat/DXContainer.h @@ -15,6 +15,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/SwapByteOrder.h" +#include "llvm/TargetParser/Triple.h" #include @@ -36,6 +37,12 @@ namespace llvm { namespace dxbc { +inline Triple::EnvironmentType getShaderStage(uint32_t Kind) { + assert(Kind <= Triple::Amplification - Triple::Pixel && + "Shader kind out of expected range."); + return static_cast(Triple::Pixel + Kind); +} + struct Hash { uint8_t Digest[16]; }; @@ -142,6 +149,208 @@ static_assert((uint64_t)FeatureFlags::NextUnusedBit <= 1ull << 63, PartType parsePartType(StringRef S); +struct VertexPSVInfo { + uint8_t OutputPositionPresent; + uint8_t Unused[3]; + + void swapBytes() { + // nothing to swap + } +}; + +struct HullPSVInfo { + uint32_t InputControlPointCount; + uint32_t OutputControlPointCount; + uint32_t TessellatorDomain; + uint32_t TessellatorOutputPrimitive; + + void swapBytes() { + sys::swapByteOrder(InputControlPointCount); + sys::swapByteOrder(OutputControlPointCount); + sys::swapByteOrder(TessellatorDomain); + sys::swapByteOrder(TessellatorOutputPrimitive); + } +}; + +struct DomainPSVInfo { + uint32_t InputControlPointCount; + uint8_t OutputPositionPresent; + uint8_t Unused[3]; + uint32_t TessellatorDomain; + + void swapBytes() { + sys::swapByteOrder(InputControlPointCount); + sys::swapByteOrder(TessellatorDomain); + } +}; + +struct GeometryPSVInfo { + uint32_t InputPrimitive; + uint32_t OutputTopology; + uint32_t OutputStreamMask; + uint8_t OutputPositionPresent; + uint8_t Unused[3]; + + void swapBytes() { + sys::swapByteOrder(InputPrimitive); + sys::swapByteOrder(OutputTopology); + sys::swapByteOrder(OutputStreamMask); + } +}; + +struct PixelPSVInfo { + uint8_t DepthOutput; + uint8_t SampleFrequency; + uint8_t Unused[2]; + + void swapBytes() { + // nothing to swap + } +}; + +struct MeshPSVInfo { + uint32_t GroupSharedBytesUsed; + uint32_t GroupSharedBytesDependentOnViewID; + uint32_t PayloadSizeInBytes; + uint16_t MaxOutputVertices; + uint16_t MaxOutputPrimitives; + + void swapBytes() { + sys::swapByteOrder(GroupSharedBytesUsed); + sys::swapByteOrder(GroupSharedBytesDependentOnViewID); + sys::swapByteOrder(PayloadSizeInBytes); + sys::swapByteOrder(MaxOutputVertices); + sys::swapByteOrder(MaxOutputPrimitives); + } +}; + +struct AmplificationPSVInfo { + uint32_t PayloadSizeInBytes; + + void swapBytes() { sys::swapByteOrder(PayloadSizeInBytes); } +}; + +union PipelinePSVInfo { + VertexPSVInfo VS; + HullPSVInfo HS; + DomainPSVInfo DS; + GeometryPSVInfo GS; + PixelPSVInfo PS; + MeshPSVInfo MS; + AmplificationPSVInfo AS; + + void swapBytes(Triple::EnvironmentType Stage) { + switch (Stage) { + case Triple::EnvironmentType::Pixel: + PS.swapBytes(); + break; + case Triple::EnvironmentType::Vertex: + VS.swapBytes(); + break; + case Triple::EnvironmentType::Geometry: + GS.swapBytes(); + break; + case Triple::EnvironmentType::Hull: + HS.swapBytes(); + break; + case Triple::EnvironmentType::Domain: + DS.swapBytes(); + break; + case Triple::EnvironmentType::Mesh: + MS.swapBytes(); + break; + case Triple::EnvironmentType::Amplification: + AS.swapBytes(); + break; + default: + break; + } + } +}; + +static_assert(sizeof(PipelinePSVInfo) == 4 * sizeof(uint32_t), + "Pipeline-specific PSV info must fit in 16 bytes."); + +namespace PSV { + +namespace v0 { +struct RuntimeInfo { + PipelinePSVInfo StageInfo; + uint32_t MinimumWaveLaneCount; // minimum lane count required, 0 if unused + uint32_t MaximumWaveLaneCount; // maximum lane count required, + // 0xffffffff if unused + void swapBytes() { + // Skip the union because we don't know which field it has + sys::swapByteOrder(MinimumWaveLaneCount); + sys::swapByteOrder(MaximumWaveLaneCount); + } + + void swapBytes(Triple::EnvironmentType Stage) { StageInfo.swapBytes(Stage); } +}; + +} // namespace v0 + +namespace v1 { + +struct MeshRuntimeInfo { + uint8_t SigPrimVectors; // Primitive output for MS + uint8_t MeshOutputTopology; +}; + +union GeometryExtraInfo { + uint16_t MaxVertexCount; // MaxVertexCount for GS only (max 1024) + uint8_t SigPatchConstOrPrimVectors; // Output for HS; Input for DS; + // Primitive output for MS (overlaps + // MeshInfo::SigPrimVectors) + MeshRuntimeInfo MeshInfo; +}; +struct RuntimeInfo : public v0::RuntimeInfo { + uint8_t ShaderStage; // PSVShaderKind + uint8_t UsesViewID; + GeometryExtraInfo GeomData; + + // PSVSignatureElement counts + uint8_t SigInputElements; + uint8_t SigOutputElements; + uint8_t SigPatchConstOrPrimElements; + + // Number of packed vectors per signature + uint8_t SigInputVectors; + uint8_t SigOutputVectors[4]; + + void swapBytes() { + // nothing to swap since everything is single-byte or a union field + } + + void swapBytes(Triple::EnvironmentType Stage) { + v0::RuntimeInfo::swapBytes(Stage); + if (Stage == Triple::EnvironmentType::Geometry) + sys::swapByteOrder(GeomData.MaxVertexCount); + } +}; + +} // namespace v1 + +namespace v2 { +struct RuntimeInfo : public v1::RuntimeInfo { + uint32_t NumThreadsX; + uint32_t NumThreadsY; + uint32_t NumThreadsZ; + + void swapBytes() { + sys::swapByteOrder(NumThreadsX); + sys::swapByteOrder(NumThreadsY); + sys::swapByteOrder(NumThreadsZ); + } + + void swapBytes(Triple::EnvironmentType Stage) { + v1::RuntimeInfo::swapBytes(Stage); + } +}; + +} // namespace v2 +} // namespace PSV + } // namespace dxbc } // namespace llvm diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def index 7907bfc..0073abc 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def +++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def @@ -3,6 +3,7 @@ CONTAINER_PART(DXIL) CONTAINER_PART(SFI0) CONTAINER_PART(HASH) +CONTAINER_PART(PSV0) #undef CONTAINER_PART #endif diff --git a/llvm/include/llvm/MC/DXContainerPSVInfo.h b/llvm/include/llvm/MC/DXContainerPSVInfo.h new file mode 100644 index 0000000..b0c5c43 --- /dev/null +++ b/llvm/include/llvm/MC/DXContainerPSVInfo.h @@ -0,0 +1,48 @@ +//===- llvm/MC/DXContainerPSVInfo.h - DXContainer PSVInfo -*- C++ -------*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MC_DXCONTAINERPSVINFO_H +#define LLVM_MC_DXCONTAINERPSVINFO_H + +#include "llvm/BinaryFormat/DXContainer.h" +#include "llvm/TargetParser/Triple.h" + +#include +#include +#include + +namespace llvm { + +class raw_ostream; + +namespace mcdxbc { +// This data structure is a helper for reading and writing PSV RuntimeInfo data. +// It is implemented in the BinaryFormat library so that it can be used by both +// the MC layer and Object tools. +// This structure is used to represent the extracted data in an inspectable and +// modifiable format, and can be used to serialize the data back into valid PSV +// RuntimeInfo. +struct PSVRuntimeInfo { + dxbc::PSV::v2::RuntimeInfo BaseData; + + // Serialize PSVInfo into the provided raw_ostream. The version field + // specifies the data version to encode, the default value specifies encoding + // the highest supported version. + void write(raw_ostream &OS, + uint32_t Version = std::numeric_limits::max()) const; + + void swapBytes(Triple::EnvironmentType Stage) { + BaseData.swapBytes(); + BaseData.swapBytes(Stage); + } +}; + +} // namespace mcdxbc +} // namespace llvm + +#endif // LLVM_MC_DXCONTAINERPSVINFO_H diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h index ffa2db4..23f7503 100644 --- a/llvm/include/llvm/Object/DXContainer.h +++ b/llvm/include/llvm/Object/DXContainer.h @@ -20,9 +20,38 @@ #include "llvm/BinaryFormat/DXContainer.h" #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBufferRef.h" +#include "llvm/TargetParser/Triple.h" namespace llvm { namespace object { + +namespace DirectX { +class PSVRuntimeInfo { + StringRef Data; + uint32_t Size; + using InfoStruct = + std::variant; + InfoStruct BasicInfo; + +public: + PSVRuntimeInfo(StringRef D) : Data(D), Size(0) {} + + // Parsing depends on the shader kind + Error parse(uint16_t ShaderKind); + + uint32_t getSize() const { return Size; } + uint32_t getVersion() const { + return Size >= sizeof(dxbc::PSV::v2::RuntimeInfo) + ? 2 + : (Size >= sizeof(dxbc::PSV::v1::RuntimeInfo) ? 1 : 0); + } + + const InfoStruct &getInfo() const { return BasicInfo; } +}; + +} // namespace DirectX + class DXContainer { public: using DXILData = std::pair; @@ -36,12 +65,14 @@ private: std::optional DXIL; std::optional ShaderFlags; std::optional Hash; + std::optional PSVInfo; Error parseHeader(); Error parsePartOffsets(); Error parseDXILHeader(StringRef Part); Error parseShaderFlags(StringRef Part); Error parseHash(StringRef Part); + Error parsePSVInfo(StringRef Part); friend class PartIterator; public: @@ -118,11 +149,15 @@ public: const dxbc::Header &getHeader() const { return Header; } - std::optional getDXIL() const { return DXIL; } + const std::optional &getDXIL() const { return DXIL; } std::optional getShaderFlags() const { return ShaderFlags; } std::optional getShaderHash() const { return Hash; } + + const std::optional &getPSVInfo() const { + return PSVInfo; + }; }; } // namespace object diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h index 55c61ff..6fc8ed8 100644 --- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h +++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h @@ -71,6 +71,22 @@ struct ShaderHash { std::vector Digest; }; +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 + // the format. + uint32_t Version; + + dxbc::PSV::v2::RuntimeInfo Info; + + void mapInfoForVersion(yaml::IO &IO); + + PSVInfo(); + PSVInfo(const dxbc::PSV::v0::RuntimeInfo *P, uint16_t Stage); + PSVInfo(const dxbc::PSV::v1::RuntimeInfo *P); + PSVInfo(const dxbc::PSV::v2::RuntimeInfo *P); +}; + struct Part { Part() = default; Part(std::string N, uint32_t S) : Name(N), Size(S) {} @@ -79,6 +95,7 @@ struct Part { std::optional Program; std::optional Flags; std::optional Hash; + std::optional Info; }; struct Object { @@ -116,6 +133,10 @@ template <> struct MappingTraits { static void mapping(IO &IO, DXContainerYAML::ShaderHash &Hash); }; +template <> struct MappingTraits { + static void mapping(IO &IO, DXContainerYAML::PSVInfo &PSV); +}; + template <> struct MappingTraits { static void mapping(IO &IO, DXContainerYAML::Part &Version); }; diff --git a/llvm/lib/MC/CMakeLists.txt b/llvm/lib/MC/CMakeLists.txt index 2cb0021..90f66e2 100644 --- a/llvm/lib/MC/CMakeLists.txt +++ b/llvm/lib/MC/CMakeLists.txt @@ -1,5 +1,6 @@ add_llvm_component_library(LLVMMC ConstantPools.cpp + DXContainerPSVInfo.cpp ELFObjectWriter.cpp MCAsmBackend.cpp MCAsmInfo.cpp diff --git a/llvm/lib/MC/DXContainerPSVInfo.cpp b/llvm/lib/MC/DXContainerPSVInfo.cpp new file mode 100644 index 0000000..5463f85 --- /dev/null +++ b/llvm/lib/MC/DXContainerPSVInfo.cpp @@ -0,0 +1,33 @@ +//===- llvm/MC/DXContainerPSVInfo.cpp - DXContainer PSVInfo -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/MC/DXContainerPSVInfo.h" +#include "llvm/BinaryFormat/DXContainer.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; +using namespace llvm::mcdxbc; + +void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { + uint32_t InfoSize; + switch (Version) { + case 0: + InfoSize = sizeof(dxbc::PSV::v0::RuntimeInfo); + break; + case 1: + InfoSize = sizeof(dxbc::PSV::v1::RuntimeInfo); + break; + case 2: + default: + InfoSize = sizeof(dxbc::PSV::v2::RuntimeInfo); + } + // Write the size of the info. + OS.write(reinterpret_cast(&InfoSize), sizeof(uint32_t)); + // Write the info itself. + OS.write(reinterpret_cast(&BaseData), InfoSize); +} diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp index 4d8f261..9c797a3 100644 --- a/llvm/lib/Object/DXContainer.cpp +++ b/llvm/lib/Object/DXContainer.cpp @@ -91,6 +91,15 @@ Error DXContainer::parseHash(StringRef Part) { return Error::success(); } +Error DXContainer::parsePSVInfo(StringRef Part) { + if (PSVInfo) + return parseFailed("More than one PSV0 part is present in the file"); + PSVInfo = DirectX::PSVRuntimeInfo(Part); + // Parsing the PSVRuntime info occurs late because we need to read data from + // other parts first. + return Error::success(); +} + Error DXContainer::parsePartOffsets() { uint32_t LastOffset = sizeof(dxbc::Header) + (Header.PartCount * sizeof(uint32_t)); @@ -140,10 +149,24 @@ Error DXContainer::parsePartOffsets() { if (Error Err = parseHash(PartData)) return Err; break; + case dxbc::PartType::PSV0: + if (Error Err = parsePSVInfo(PartData)) + return Err; + break; case dxbc::PartType::Unknown: break; } } + + // Fully parsing the PSVInfo requires knowing the shader kind which we read + // out of the program header in the DXIL part. + if (PSVInfo) { + if (!DXIL) + return parseFailed("Cannot fully parse pipeline state validation " + "information without DXIL part."); + if (Error Err = PSVInfo->parse(DXIL->first.ShaderKind)) + return Err; + } return Error::success(); } @@ -166,3 +189,45 @@ void DXContainer::PartIterator::updateIteratorImpl(const uint32_t Offset) { StringRef(Current + sizeof(dxbc::PartHeader), IteratorState.Part.Size); IteratorState.Offset = Offset; } + +Error DirectX::PSVRuntimeInfo::parse(uint16_t ShaderKind) { + Triple::EnvironmentType ShaderStage = dxbc::getShaderStage(ShaderKind); + + const char *Current = Data.begin(); + if (Error Err = readInteger(Data, Current, Size)) + return Err; + Current += sizeof(uint32_t); + + StringRef PSVInfoData = Data.substr(sizeof(uint32_t), Size); + + using namespace dxbc::PSV; + + const uint32_t PSVVersion = getVersion(); + + // Detect the PSVVersion by looking at the size field. + if (PSVVersion == 2) { + v2::RuntimeInfo Info; + if (Error Err = readStruct(PSVInfoData, Current, Info)) + return Err; + if (sys::IsBigEndianHost) + Info.swapBytes(ShaderStage); + BasicInfo = Info; + } else if (PSVVersion == 1) { + v1::RuntimeInfo Info; + if (Error Err = readStruct(PSVInfoData, Current, Info)) + return Err; + if (sys::IsBigEndianHost) + Info.swapBytes(ShaderStage); + BasicInfo = Info; + } else { + v0::RuntimeInfo Info; + if (Error Err = readStruct(PSVInfoData, Current, Info)) + return Err; + if (sys::IsBigEndianHost) + Info.swapBytes(ShaderStage); + BasicInfo = Info; + } + Current += Size; + + return Error::success(); +} diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp index a5c60a6..3e3e3e1 100644 --- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp +++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/BinaryFormat/DXContainer.h" +#include "llvm/MC/DXContainerPSVInfo.h" #include "llvm/ObjectYAML/ObjectYAML.h" #include "llvm/ObjectYAML/yaml2obj.h" #include "llvm/Support/Errc.h" @@ -193,6 +194,18 @@ void DXContainerWriter::writeParts(raw_ostream &OS) { OS.write(reinterpret_cast(&Hash), sizeof(dxbc::ShaderHash)); break; } + case dxbc::PartType::PSV0: { + if (!P.Info.has_value()) + continue; + mcdxbc::PSVRuntimeInfo PSV; + memcpy(&PSV.BaseData, &P.Info->Info, sizeof(dxbc::PSV::v2::RuntimeInfo)); + + if (sys::IsBigEndianHost) + PSV.swapBytes(static_cast( + Triple::Pixel + P.Info->Info.ShaderStage)); + PSV.write(OS, P.Info->Version); + break; + } case dxbc::PartType::Unknown: break; // Skip any handling for unrecognized parts. } diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp index 1d1dd42..98615c5 100644 --- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp +++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp @@ -43,6 +43,35 @@ DXContainerYAML::ShaderHash::ShaderHash(const dxbc::ShaderHash &Data) memcpy(Digest.data(), &Data.Digest[0], 16); } +DXContainerYAML::PSVInfo::PSVInfo() : Version(0) { + memset(&Info, 0, sizeof(Info)); +} + +DXContainerYAML::PSVInfo::PSVInfo(const dxbc::PSV::v0::RuntimeInfo *P, + uint16_t Stage) + : Version(0) { + memset(&Info, 0, sizeof(Info)); + memcpy(&Info, P, sizeof(dxbc::PSV::v0::RuntimeInfo)); + + assert(Stage < std::numeric_limits::max() && + "Stage should be a very small number"); + // We need to bring the stage in separately since it isn't part of the v1 data + // structure. + Info.ShaderStage = static_cast(Stage); +} + +DXContainerYAML::PSVInfo::PSVInfo(const dxbc::PSV::v1::RuntimeInfo *P) + : Version(1) { + memset(&Info, 0, sizeof(Info)); + memcpy(&Info, P, sizeof(dxbc::PSV::v1::RuntimeInfo)); +} + +DXContainerYAML::PSVInfo::PSVInfo(const dxbc::PSV::v2::RuntimeInfo *P) + : Version(2) { + memset(&Info, 0, sizeof(Info)); + memcpy(&Info, P, sizeof(dxbc::PSV::v2::RuntimeInfo)); +} + namespace yaml { void MappingTraits::mapping( @@ -84,6 +113,16 @@ void MappingTraits::mapping( IO.mapRequired("Digest", Hash.Digest); } +void MappingTraits::mapping( + IO &IO, DXContainerYAML::PSVInfo &PSV) { + IO.mapRequired("Version", PSV.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); +} + void MappingTraits::mapping(IO &IO, DXContainerYAML::Part &P) { IO.mapRequired("Name", P.Name); @@ -91,6 +130,7 @@ void MappingTraits::mapping(IO &IO, IO.mapOptional("Program", P.Program); IO.mapOptional("Flags", P.Flags); IO.mapOptional("Hash", P.Hash); + IO.mapOptional("PSVInfo", P.Info); } void MappingTraits::mapping( @@ -101,4 +141,95 @@ void MappingTraits::mapping( } } // namespace yaml + +void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) { + dxbc::PipelinePSVInfo &StageInfo = Info.StageInfo; + Triple::EnvironmentType Stage = dxbc::getShaderStage(Info.ShaderStage); + + switch (Stage) { + case Triple::EnvironmentType::Pixel: + IO.mapRequired("DepthOutput", StageInfo.PS.DepthOutput); + IO.mapRequired("SampleFrequency", StageInfo.PS.SampleFrequency); + break; + case Triple::EnvironmentType::Vertex: + IO.mapRequired("OutputPositionPresent", StageInfo.VS.OutputPositionPresent); + break; + case Triple::EnvironmentType::Geometry: + IO.mapRequired("InputPrimitive", StageInfo.GS.InputPrimitive); + IO.mapRequired("OutputTopology", StageInfo.GS.OutputTopology); + IO.mapRequired("OutputStreamMask", StageInfo.GS.OutputStreamMask); + IO.mapRequired("OutputPositionPresent", StageInfo.GS.OutputPositionPresent); + break; + case Triple::EnvironmentType::Hull: + IO.mapRequired("InputControlPointCount", + StageInfo.HS.InputControlPointCount); + IO.mapRequired("OutputControlPointCount", + StageInfo.HS.OutputControlPointCount); + IO.mapRequired("TessellatorDomain", StageInfo.HS.TessellatorDomain); + IO.mapRequired("TessellatorOutputPrimitive", + StageInfo.HS.TessellatorOutputPrimitive); + break; + case Triple::EnvironmentType::Domain: + IO.mapRequired("InputControlPointCount", + StageInfo.DS.InputControlPointCount); + IO.mapRequired("OutputPositionPresent", StageInfo.DS.OutputPositionPresent); + IO.mapRequired("TessellatorDomain", StageInfo.DS.TessellatorDomain); + break; + case Triple::EnvironmentType::Mesh: + IO.mapRequired("GroupSharedBytesUsed", StageInfo.MS.GroupSharedBytesUsed); + IO.mapRequired("GroupSharedBytesDependentOnViewID", + StageInfo.MS.GroupSharedBytesDependentOnViewID); + IO.mapRequired("PayloadSizeInBytes", StageInfo.MS.PayloadSizeInBytes); + IO.mapRequired("MaxOutputVertices", StageInfo.MS.MaxOutputVertices); + IO.mapRequired("MaxOutputPrimitives", StageInfo.MS.MaxOutputPrimitives); + break; + case Triple::EnvironmentType::Amplification: + IO.mapRequired("PayloadSizeInBytes", StageInfo.AS.PayloadSizeInBytes); + break; + default: + break; + } + + IO.mapRequired("MinimumWaveLaneCount", Info.MinimumWaveLaneCount); + IO.mapRequired("MaximumWaveLaneCount", Info.MaximumWaveLaneCount); + + if (Version == 0) + return; + + IO.mapRequired("UsesViewID", Info.UsesViewID); + + switch (Stage) { + case Triple::EnvironmentType::Geometry: + IO.mapRequired("MaxVertexCount", Info.GeomData.MaxVertexCount); + break; + case Triple::EnvironmentType::Hull: + case Triple::EnvironmentType::Domain: + IO.mapRequired("SigPatchConstOrPrimVectors", + Info.GeomData.SigPatchConstOrPrimVectors); + break; + case Triple::EnvironmentType::Mesh: + IO.mapRequired("SigPrimVectors", Info.GeomData.MeshInfo.SigPrimVectors); + IO.mapRequired("MeshOutputTopology", + Info.GeomData.MeshInfo.MeshOutputTopology); + break; + default: + break; + } + + IO.mapRequired("SigInputElements", Info.SigInputElements); + IO.mapRequired("SigOutputElements", Info.SigOutputElements); + IO.mapRequired("SigPatchConstOrPrimElements", + Info.SigPatchConstOrPrimElements); + IO.mapRequired("SigInputVectors", Info.SigInputVectors); + MutableArrayRef Vec(Info.SigOutputVectors); + IO.mapRequired("SigOutputVectors", Vec); + + if (Version == 1) + return; + + IO.mapRequired("NumThreadsX", Info.NumThreadsX); + IO.mapRequired("NumThreadsY", Info.NumThreadsY); + IO.mapRequired("NumThreadsZ", Info.NumThreadsZ); +} + } // namespace llvm diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml new file mode 100644 index 0000000..3ae3efb --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-amplification.yaml @@ -0,0 +1,39 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 14 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 0 +# CHECK-NEXT: ShaderStage: 14 +# CHECK-NEXT: PayloadSizeInBytes: 4092 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-compute.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-compute.yaml new file mode 100644 index 0000000..bf21d400f --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-compute.yaml @@ -0,0 +1,37 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 5 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 5 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 0 +# CHECK-NEXT: ShaderStage: 5 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml new file mode 100644 index 0000000..b034232 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-domain.yaml @@ -0,0 +1,43 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 4 + InputControlPointCount: 1024 + OutputPositionPresent: 1 + TessellatorDomain: 2056 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 4 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 0 +# CHECK-NEXT: ShaderStage: 4 +# CHECK-NEXT: InputControlPointCount: 1024 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: TessellatorDomain: 2056 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-geometry.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-geometry.yaml new file mode 100644 index 0000000..87b6ba7 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-geometry.yaml @@ -0,0 +1,45 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + InputPrimitive: 1024 + OutputTopology: 4096 + OutputStreamMask: 2056 + OutputPositionPresent: 1 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 2 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 0 +# CHECK-NEXT: ShaderStage: 2 +# CHECK-NEXT: InputPrimitive: 1024 +# CHECK-NEXT: OutputTopology: 4096 +# CHECK-NEXT: OutputStreamMask: 2056 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml new file mode 100644 index 0000000..5d68a47 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-hull.yaml @@ -0,0 +1,45 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 3 + InputControlPointCount: 1024 + OutputControlPointCount: 4096 + TessellatorDomain: 2056 + TessellatorOutputPrimitive: 8192 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 3 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 0 +# CHECK-NEXT: ShaderStage: 3 +# CHECK-NEXT: InputControlPointCount: 1024 +# CHECK-NEXT: OutputControlPointCount: 4096 +# CHECK-NEXT: TessellatorDomain: 2056 +# CHECK-NEXT: TessellatorOutputPrimitive: 8192 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml new file mode 100644 index 0000000..23822a0 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-mesh.yaml @@ -0,0 +1,47 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 13 + GroupSharedBytesUsed: 1024 + GroupSharedBytesDependentOnViewID: 2056 + PayloadSizeInBytes: 4092 + MaxOutputVertices: 8196 + MaxOutputPrimitives: 4092 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 13 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 0 +# CHECK-NEXT: ShaderStage: 13 +# CHECK-NEXT: GroupSharedBytesUsed: 1024 +# CHECK-NEXT: GroupSharedBytesDependentOnViewID: 2056 +# CHECK-NEXT: PayloadSizeInBytes: 4092 +# CHECK-NEXT: MaxOutputVertices: 8196 +# CHECK-NEXT: MaxOutputPrimitives: 4092 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml new file mode 100644 index 0000000..b655b4f --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-pixel.yaml @@ -0,0 +1,41 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 0 + DepthOutput: 7 + SampleFrequency: 96 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 0 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 0 +# CHECK-NEXT: ShaderStage: 0 +# CHECK-NEXT: DepthOutput: 7 +# CHECK-NEXT: SampleFrequency: 96 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml new file mode 100644 index 0000000..8c22a8f --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv0-vertex.yaml @@ -0,0 +1,39 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + OutputPositionPresent: 1 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 1 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 0 +# CHECK-NEXT: ShaderStage: 1 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml new file mode 100644 index 0000000..7b0e1f5 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml @@ -0,0 +1,51 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + ShaderStage: 14 + PayloadSizeInBytes: 4092 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 14 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: ShaderStage: 14 +# CHECK-NEXT: PayloadSizeInBytes: 4092 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml new file mode 100644 index 0000000..9c21808 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml @@ -0,0 +1,49 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + ShaderStage: 5 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 5 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: ShaderStage: 5 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml new file mode 100644 index 0000000..86e44d5 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml @@ -0,0 +1,57 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + ShaderStage: 4 + InputControlPointCount: 1024 + OutputPositionPresent: 1 + TessellatorDomain: 2056 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigPatchConstOrPrimVectors: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 4 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: ShaderStage: 4 +# CHECK-NEXT: InputControlPointCount: 1024 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: TessellatorDomain: 2056 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigPatchConstOrPrimVectors: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml new file mode 100644 index 0000000..755959c --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml @@ -0,0 +1,59 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + ShaderStage: 2 + InputPrimitive: 1024 + OutputTopology: 4096 + OutputStreamMask: 2056 + OutputPositionPresent: 1 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + MaxVertexCount: 4096 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 2 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: ShaderStage: 2 +# CHECK-NEXT: InputPrimitive: 1024 +# CHECK-NEXT: OutputTopology: 4096 +# CHECK-NEXT: OutputStreamMask: 2056 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: MaxVertexCount: 4096 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml new file mode 100644 index 0000000..60fb396 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml @@ -0,0 +1,59 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + ShaderStage: 3 + InputControlPointCount: 1024 + OutputControlPointCount: 4096 + TessellatorDomain: 2056 + TessellatorOutputPrimitive: 8192 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigPatchConstOrPrimVectors: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 3 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: ShaderStage: 3 +# CHECK-NEXT: InputControlPointCount: 1024 +# CHECK-NEXT: OutputControlPointCount: 4096 +# CHECK-NEXT: TessellatorDomain: 2056 +# CHECK-NEXT: TessellatorOutputPrimitive: 8192 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigPatchConstOrPrimVectors: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml new file mode 100644 index 0000000..e7b865c --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml @@ -0,0 +1,63 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + ShaderStage: 13 + GroupSharedBytesUsed: 1024 + GroupSharedBytesDependentOnViewID: 2056 + PayloadSizeInBytes: 4092 + MaxOutputVertices: 8196 + MaxOutputPrimitives: 4092 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigPrimVectors: 128 + MeshOutputTopology: 16 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 13 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: ShaderStage: 13 +# CHECK-NEXT: GroupSharedBytesUsed: 1024 +# CHECK-NEXT: GroupSharedBytesDependentOnViewID: 2056 +# CHECK-NEXT: PayloadSizeInBytes: 4092 +# CHECK-NEXT: MaxOutputVertices: 8196 +# CHECK-NEXT: MaxOutputPrimitives: 4092 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigPrimVectors: 128 +# CHECK-NEXT: MeshOutputTopology: 16 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml new file mode 100644 index 0000000..bd9364a --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml @@ -0,0 +1,53 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + ShaderStage: 0 + DepthOutput: 7 + SampleFrequency: 96 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 0 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: ShaderStage: 0 +# CHECK-NEXT: DepthOutput: 7 +# CHECK-NEXT: SampleFrequency: 96 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml new file mode 100644 index 0000000..19e8e98 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml @@ -0,0 +1,51 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 1 + ShaderStage: 1 + OutputPositionPresent: 1 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 1 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 1 +# CHECK-NEXT: ShaderStage: 1 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml new file mode 100644 index 0000000..058ec0f --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml @@ -0,0 +1,57 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + ShaderStage: 14 + PayloadSizeInBytes: 4092 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + NumThreadsX: 512 + NumThreadsY: 1024 + NumThreadsZ: 2048 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 14 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 2 +# CHECK-NEXT: ShaderStage: 14 +# CHECK-NEXT: PayloadSizeInBytes: 4092 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: NumThreadsX: 512 +# CHECK-NEXT: NumThreadsY: 1024 +# CHECK-NEXT: NumThreadsZ: 2048 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml new file mode 100644 index 0000000..932da42 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml @@ -0,0 +1,55 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + ShaderStage: 5 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + NumThreadsX: 512 + NumThreadsY: 1024 + NumThreadsZ: 2048 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 5 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 2 +# CHECK-NEXT: ShaderStage: 5 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: NumThreadsX: 512 +# CHECK-NEXT: NumThreadsY: 1024 +# CHECK-NEXT: NumThreadsZ: 2048 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml new file mode 100644 index 0000000..7258a82 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml @@ -0,0 +1,63 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + ShaderStage: 4 + InputControlPointCount: 1024 + OutputPositionPresent: 1 + TessellatorDomain: 2056 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigPatchConstOrPrimVectors: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + NumThreadsX: 512 + NumThreadsY: 1024 + NumThreadsZ: 2048 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 4 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 2 +# CHECK-NEXT: ShaderStage: 4 +# CHECK-NEXT: InputControlPointCount: 1024 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: TessellatorDomain: 2056 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigPatchConstOrPrimVectors: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: NumThreadsX: 512 +# CHECK-NEXT: NumThreadsY: 1024 +# CHECK-NEXT: NumThreadsZ: 2048 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml new file mode 100644 index 0000000..c540257 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml @@ -0,0 +1,65 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + ShaderStage: 2 + InputPrimitive: 1024 + OutputTopology: 4096 + OutputStreamMask: 2056 + OutputPositionPresent: 1 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + MaxVertexCount: 4096 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + NumThreadsX: 512 + NumThreadsY: 1024 + NumThreadsZ: 2048 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 2 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 2 +# CHECK-NEXT: ShaderStage: 2 +# CHECK-NEXT: InputPrimitive: 1024 +# CHECK-NEXT: OutputTopology: 4096 +# CHECK-NEXT: OutputStreamMask: 2056 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: MaxVertexCount: 4096 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: NumThreadsX: 512 +# CHECK-NEXT: NumThreadsY: 1024 +# CHECK-NEXT: NumThreadsZ: 2048 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml new file mode 100644 index 0000000..29760b49d --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml @@ -0,0 +1,65 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + ShaderStage: 3 + InputControlPointCount: 1024 + OutputControlPointCount: 4096 + TessellatorDomain: 2056 + TessellatorOutputPrimitive: 8192 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigPatchConstOrPrimVectors: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + NumThreadsX: 512 + NumThreadsY: 1024 + NumThreadsZ: 2048 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 3 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 2 +# CHECK-NEXT: ShaderStage: 3 +# CHECK-NEXT: InputControlPointCount: 1024 +# CHECK-NEXT: OutputControlPointCount: 4096 +# CHECK-NEXT: TessellatorDomain: 2056 +# CHECK-NEXT: TessellatorOutputPrimitive: 8192 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigPatchConstOrPrimVectors: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: NumThreadsX: 512 +# CHECK-NEXT: NumThreadsY: 1024 +# CHECK-NEXT: NumThreadsZ: 2048 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml new file mode 100644 index 0000000..26441a7 --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml @@ -0,0 +1,69 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + ShaderStage: 13 + GroupSharedBytesUsed: 1024 + GroupSharedBytesDependentOnViewID: 2056 + PayloadSizeInBytes: 4092 + MaxOutputVertices: 8196 + MaxOutputPrimitives: 4092 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigPrimVectors: 128 + MeshOutputTopology: 16 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + NumThreadsX: 512 + NumThreadsY: 1024 + NumThreadsZ: 2048 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 13 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 2 +# CHECK-NEXT: ShaderStage: 13 +# CHECK-NEXT: GroupSharedBytesUsed: 1024 +# CHECK-NEXT: GroupSharedBytesDependentOnViewID: 2056 +# CHECK-NEXT: PayloadSizeInBytes: 4092 +# CHECK-NEXT: MaxOutputVertices: 8196 +# CHECK-NEXT: MaxOutputPrimitives: 4092 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigPrimVectors: 128 +# CHECK-NEXT: MeshOutputTopology: 16 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: NumThreadsX: 512 +# CHECK-NEXT: NumThreadsY: 1024 +# CHECK-NEXT: NumThreadsZ: 2048 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml new file mode 100644 index 0000000..3a82bbe --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml @@ -0,0 +1,59 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + ShaderStage: 0 + DepthOutput: 7 + SampleFrequency: 96 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + NumThreadsX: 512 + NumThreadsY: 1024 + NumThreadsZ: 2048 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 0 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 2 +# CHECK-NEXT: ShaderStage: 0 +# CHECK-NEXT: DepthOutput: 7 +# CHECK-NEXT: SampleFrequency: 96 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: NumThreadsX: 512 +# CHECK-NEXT: NumThreadsY: 1024 +# CHECK-NEXT: NumThreadsZ: 2048 +# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml new file mode 100644 index 0000000..c0abacf --- /dev/null +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml @@ -0,0 +1,57 @@ +# RUN: yaml2obj %s | obj2yaml | FileCheck %s + +--- !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: 2 + ShaderStage: 1 + OutputPositionPresent: 1 + MinimumWaveLaneCount: 0 + MaximumWaveLaneCount: 4294967295 + UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 + SigInputVectors: 64 + SigOutputVectors: [ 8, 16, 32, 64 ] + NumThreadsX: 512 + NumThreadsY: 1024 + NumThreadsZ: 2048 + - Name: DXIL + Size: 24 + Program: + MajorVersion: 6 + MinorVersion: 0 + ShaderKind: 1 + Size: 6 + DXILMajorVersion: 0 + DXILMinorVersion: 1 + DXILSize: 0 +... + +# CHECK: Name: PSV0 +# CHECK: PSVInfo: +# CHECK-NEXT: Version: 2 +# CHECK-NEXT: ShaderStage: 1 +# CHECK-NEXT: OutputPositionPresent: 1 +# CHECK-NEXT: MinimumWaveLaneCount: 0 +# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 +# CHECK-NEXT: UsesViewID: 128 +# CHECK-NEXT: SigInputElements: 8 +# CHECK-NEXT: SigOutputElements: 16 +# CHECK-NEXT: SigPatchConstOrPrimElements: 32 +# CHECK-NEXT: SigInputVectors: 64 +# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] +# CHECK-NEXT: NumThreadsX: 512 +# CHECK-NEXT: NumThreadsY: 1024 +# CHECK-NEXT: NumThreadsZ: 2048 +# CHECK-NEXT: Name diff --git a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp index 462d87a..518f113 100644 --- a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp +++ b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp @@ -73,6 +73,24 @@ dumpDXContainer(MemoryBufferRef Source) { NewPart.Hash = DXContainerYAML::ShaderHash(*Hash); break; } + case dxbc::PartType::PSV0: { + const auto &PSVInfo = Container.getPSVInfo(); + if (!PSVInfo) + break; + if (const auto *P = + std::get_if(&PSVInfo->getInfo())) { + if (!Container.getDXIL()) + break; + NewPart.Info = + DXContainerYAML::PSVInfo(P, Container.getDXIL()->first.ShaderKind); + } else if (const auto *P = std::get_if( + &PSVInfo->getInfo())) + NewPart.Info = DXContainerYAML::PSVInfo(P); + else if (const auto *P = + std::get_if(&PSVInfo->getInfo())) + NewPart.Info = DXContainerYAML::PSVInfo(P); + break; + } case dxbc::PartType::Unknown: break; } -- 2.7.4