diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h index f92071e32222e..f202f1bf6dff1 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainer.h +++ b/llvm/include/llvm/BinaryFormat/DXContainer.h @@ -20,7 +20,6 @@ #include namespace llvm { -template struct EnumEntry; // The DXContainer file format is arranged as a header and "parts". Semantically // parts are similar to sections in other object file formats. The File format @@ -274,27 +273,6 @@ static_assert(sizeof(PipelinePSVInfo) == 4 * sizeof(uint32_t), namespace PSV { -#define SEMANTIC_KIND(Val, Enum) Enum = Val, -enum class SemanticKind : uint8_t { -#include "DXContainerConstants.def" -}; - -ArrayRef> getSemanticKinds(); - -#define COMPONENT_TYPE(Val, Enum) Enum = Val, -enum class ComponentType : uint8_t { -#include "DXContainerConstants.def" -}; - -ArrayRef> getComponentTypes(); - -#define INTERPOLATION_MODE(Val, Enum) Enum = Val, -enum class InterpolationMode : uint8_t { -#include "DXContainerConstants.def" -}; - -ArrayRef> getInterpolationModes(); - namespace v0 { struct RuntimeInfo { PipelinePSVInfo StageInfo; @@ -324,34 +302,6 @@ struct ResourceBindInfo { } }; -struct SignatureElement { - uint32_t NameOffset; - uint32_t IndicesOffset; - - uint8_t Rows; - uint8_t StartRow; - uint8_t Cols : 4; - uint8_t StartCol : 2; - uint8_t Allocated : 1; - uint8_t Unused : 1; - SemanticKind Kind; - - ComponentType Type; - InterpolationMode Mode; - uint8_t DynamicMask : 4; - uint8_t Stream : 2; - uint8_t Unused2 : 2; - uint8_t Reserved; - - void swapBytes() { - sys::swapByteOrder(NameOffset); - sys::swapByteOrder(IndicesOffset); - } -}; - -static_assert(sizeof(SignatureElement) == 4 * sizeof(uint32_t), - "PSV Signature elements must fit in 16 bytes."); - } // namespace v0 namespace v1 { @@ -376,7 +326,7 @@ struct RuntimeInfo : public v0::RuntimeInfo { // PSVSignatureElement counts uint8_t SigInputElements; uint8_t SigOutputElements; - uint8_t SigPatchOrPrimElements; + uint8_t SigPatchConstOrPrimElements; // Number of packed vectors per signature uint8_t SigInputVectors; diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def index e2cbad293e162..0073abcd0703a 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def +++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def @@ -46,72 +46,3 @@ SHADER_FLAG(31, NextUnusedBit, "Next reserved shader flag bit (not a flag)") #undef SHADER_FLAG #endif - -#ifdef SEMANTIC_KIND - -SEMANTIC_KIND(0, Arbitrary) -SEMANTIC_KIND(1, VertexID) -SEMANTIC_KIND(2, InstanceID) -SEMANTIC_KIND(3, Position) -SEMANTIC_KIND(4, RenderTargetArrayIndex) -SEMANTIC_KIND(5, ViewPortArrayIndex) -SEMANTIC_KIND(6, ClipDistance) -SEMANTIC_KIND(7, CullDistance) -SEMANTIC_KIND(8, OutputControlPointID) -SEMANTIC_KIND(9, DomainLocation) -SEMANTIC_KIND(10, PrimitiveID) -SEMANTIC_KIND(11, GSInstanceID) -SEMANTIC_KIND(12, SampleIndex) -SEMANTIC_KIND(13, IsFrontFace) -SEMANTIC_KIND(14, Coverage) -SEMANTIC_KIND(15, InnerCoverage) -SEMANTIC_KIND(16, Target) -SEMANTIC_KIND(17, Depth) -SEMANTIC_KIND(18, DepthLessEqual) -SEMANTIC_KIND(19, DepthGreaterEqual) -SEMANTIC_KIND(20, StencilRef) -SEMANTIC_KIND(21, DispatchThreadID) -SEMANTIC_KIND(22, GroupID) -SEMANTIC_KIND(23, GroupIndex) -SEMANTIC_KIND(24, GroupThreadID) -SEMANTIC_KIND(25, TessFactor) -SEMANTIC_KIND(26, InsideTessFactor) -SEMANTIC_KIND(27, ViewID) -SEMANTIC_KIND(28, Barycentrics) -SEMANTIC_KIND(29, ShadingRate) -SEMANTIC_KIND(30, CullPrimitive) -SEMANTIC_KIND(30, Invalid) - -#undef SEMANTIC_KIND -#endif - -#ifdef COMPONENT_TYPE - -COMPONENT_TYPE(0, Unknown) -COMPONENT_TYPE(1, UInt32) -COMPONENT_TYPE(2, SInt32) -COMPONENT_TYPE(3, Float32) -COMPONENT_TYPE(4, UInt16) -COMPONENT_TYPE(5, SInt16) -COMPONENT_TYPE(6, Float16) -COMPONENT_TYPE(7, UInt64) -COMPONENT_TYPE(8, SInt64) -COMPONENT_TYPE(9, Float64) - -#undef COMPONENT_TYPE -#endif - -#ifdef INTERPOLATION_MODE - -INTERPOLATION_MODE(0, Undefined) -INTERPOLATION_MODE(1, Constant) -INTERPOLATION_MODE(2, Linear) -INTERPOLATION_MODE(3, LinearCentroid) -INTERPOLATION_MODE(4, LinearNoperspective) -INTERPOLATION_MODE(5, LinearNoperspectiveCentroid) -INTERPOLATION_MODE(6, LinearSample) -INTERPOLATION_MODE(7, LinearNoperspectiveSample) -INTERPOLATION_MODE(8, Invalid) - -#undef INTERPOLATION_MODE -#endif diff --git a/llvm/include/llvm/MC/DXContainerPSVInfo.h b/llvm/include/llvm/MC/DXContainerPSVInfo.h index dc6bf2fa40d06..e17054365d5cf 100644 --- a/llvm/include/llvm/MC/DXContainerPSVInfo.h +++ b/llvm/include/llvm/MC/DXContainerPSVInfo.h @@ -9,34 +9,18 @@ #ifndef LLVM_MC_DXCONTAINERPSVINFO_H #define LLVM_MC_DXCONTAINERPSVINFO_H -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/DXContainer.h" #include "llvm/TargetParser/Triple.h" #include #include +#include namespace llvm { class raw_ostream; namespace mcdxbc { - -struct PSVSignatureElement { - StringRef Name; - SmallVector Indices; - uint8_t StartRow; - uint8_t Cols; - uint8_t StartCol; - bool Allocated; - dxbc::PSV::SemanticKind Kind; - dxbc::PSV::ComponentType Type; - dxbc::PSV::InterpolationMode Mode; - uint8_t DynamicMask; - uint8_t Stream; -}; - // 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. @@ -44,12 +28,8 @@ struct PSVSignatureElement { // modifiable format, and can be used to serialize the data back into valid PSV // RuntimeInfo. struct PSVRuntimeInfo { - bool IsFinalized = false; dxbc::PSV::v2::RuntimeInfo BaseData; - SmallVector Resources; - SmallVector InputElements; - SmallVector OutputElements; - SmallVector PatchOrPrimElements; + std::vector Resources; // Serialize PSVInfo into the provided raw_ostream. The version field // specifies the data version to encode, the default value specifies encoding @@ -57,14 +37,7 @@ struct PSVRuntimeInfo { void write(raw_ostream &OS, uint32_t Version = std::numeric_limits::max()) const; - void finalize(Triple::EnvironmentType Stage) { - IsFinalized = true; - BaseData.SigInputElements = static_cast(InputElements.size()); - BaseData.SigOutputElements = static_cast(OutputElements.size()); - BaseData.SigPatchOrPrimElements = - static_cast(PatchOrPrimElements.size()); - if (!sys::IsBigEndianHost) - return; + void swapBytes(Triple::EnvironmentType Stage) { BaseData.swapBytes(); BaseData.swapBytes(Stage); for (auto &Res : Resources) diff --git a/llvm/include/llvm/MC/StringTableBuilder.h b/llvm/include/llvm/MC/StringTableBuilder.h index 4ee421e22c171..d0d5aaa037389 100644 --- a/llvm/include/llvm/MC/StringTableBuilder.h +++ b/llvm/include/llvm/MC/StringTableBuilder.h @@ -32,8 +32,7 @@ class StringTableBuilder { MachO64Linked, RAW, DWARF, - XCOFF, - DXContainer + XCOFF }; private: diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h index 2aae0a199f8c1..ece2dfdd8b2d8 100644 --- a/llvm/include/llvm/Object/DXContainer.h +++ b/llvm/include/llvm/Object/DXContainer.h @@ -33,14 +33,14 @@ class PSVRuntimeInfo { // 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. - template struct ViewArray { + struct ResourceArray { StringRef Data; uint32_t Stride; // size of each element in the list. - ViewArray() = default; - ViewArray(StringRef D, size_t S) : Data(D), Stride(S) {} + ResourceArray() = default; + ResourceArray(StringRef D, size_t S) : Data(D), Stride(S) {} - using value_type = T; + using value_type = dxbc::PSV::v2::ResourceBindInfo; static constexpr uint32_t MaxStride() { return static_cast(sizeof(value_type)); } @@ -50,7 +50,7 @@ class PSVRuntimeInfo { uint32_t Stride; // size of each element in the list. const char *Current; - iterator(const ViewArray &A, const char *C) + iterator(const ResourceArray &A, const char *C) : Data(A.Data), Stride(A.Stride), Current(C) {} iterator(const iterator &) = default; @@ -58,8 +58,7 @@ class PSVRuntimeInfo { // 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; - std::memset(&Val, 0, sizeof(value_type)); + value_type Val = {{0, 0, 0, 0}, 0, 0}; if (Current >= Data.end()) return Val; memcpy(static_cast(&Val), Current, @@ -104,9 +103,6 @@ class PSVRuntimeInfo { size_t size() const { return Data.size() / Stride; } }; - using ResourceArray = ViewArray; - using SigElementArray = ViewArray; - StringRef Data; uint32_t Size; using InfoStruct = @@ -114,11 +110,6 @@ class PSVRuntimeInfo { dxbc::PSV::v1::RuntimeInfo, dxbc::PSV::v2::RuntimeInfo>; InfoStruct BasicInfo; ResourceArray Resources; - StringRef StringTable; - SmallVector SemanticIndexTable; - SigElementArray SigInputElements; - SigElementArray SigOutputElements; - SigElementArray SigPatchOrPrimElements; public: PSVRuntimeInfo(StringRef D) : Data(D), Size(0) {} @@ -139,23 +130,6 @@ class PSVRuntimeInfo { uint32_t getResourceStride() const { return Resources.Stride; } const InfoStruct &getInfo() const { return BasicInfo; } - - StringRef getStringTable() const { return StringTable; } - ArrayRef getSemanticIndexTable() const { - return SemanticIndexTable; - } - - uint8_t getSigInputCount() const; - uint8_t getSigOutputCount() const; - uint8_t getSigPatchOrPrimCount() const; - - SigElementArray getSigInputElements() const { return SigInputElements; } - SigElementArray getSigOutputElements() const { return SigOutputElements; } - SigElementArray getSigPatchOrPrimElements() const { - return SigPatchOrPrimElements; - } - - uint32_t getSigElementStride() const { return SigInputElements.Stride; } }; } // namespace DirectX diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h index 1ab979fd0dfea..5dff8b3db9d01 100644 --- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h +++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h @@ -73,33 +73,6 @@ struct ShaderHash { using ResourceBindInfo = dxbc::PSV::v2::ResourceBindInfo; -struct SignatureElement { - SignatureElement() = default; - - SignatureElement(dxbc::PSV::v0::SignatureElement El, StringRef StringTable, - ArrayRef IdxTable) - : Name(StringTable.substr(El.NameOffset, - StringTable.find('\0', El.NameOffset) - - El.NameOffset)), - Indices(IdxTable.slice(El.IndicesOffset, El.Rows)), - StartRow(El.StartRow), Cols(El.Cols), StartCol(El.StartCol), - Allocated(El.Allocated != 0), Kind(El.Kind), Type(El.Type), - Mode(El.Mode), DynamicMask(El.DynamicMask), Stream(El.Stream) {} - StringRef Name; - SmallVector Indices; - - uint8_t StartRow; - uint8_t Cols; - uint8_t StartCol; - bool Allocated; - dxbc::PSV::SemanticKind Kind; - - dxbc::PSV::ComponentType Type; - dxbc::PSV::InterpolationMode Mode; - llvm::yaml::Hex8 DynamicMask; - uint8_t Stream; -}; - 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 @@ -108,10 +81,7 @@ struct PSVInfo { dxbc::PSV::v2::RuntimeInfo Info; uint32_t ResourceStride; - SmallVector Resources; - SmallVector SigInputElements; - SmallVector SigOutputElements; - SmallVector SigPatchOrPrimElements; + std::vector Resources; void mapInfoForVersion(yaml::IO &IO); @@ -142,11 +112,6 @@ struct Object { LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::Part) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::ResourceBindInfo) -LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::SignatureElement) -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) - namespace llvm { class raw_ostream; @@ -189,10 +154,6 @@ template <> struct MappingTraits { static void mapping(IO &IO, DXContainerYAML::ResourceBindInfo &Res); }; -template <> struct MappingTraits { - static void mapping(IO &IO, llvm::DXContainerYAML::SignatureElement &El); -}; - } // namespace yaml } // namespace llvm diff --git a/llvm/lib/BinaryFormat/DXContainer.cpp b/llvm/lib/BinaryFormat/DXContainer.cpp index f6613f16fafef..60a89c66d28c8 100644 --- a/llvm/lib/BinaryFormat/DXContainer.cpp +++ b/llvm/lib/BinaryFormat/DXContainer.cpp @@ -13,7 +13,6 @@ #include "llvm/BinaryFormat/DXContainer.h" #include "llvm/ADT/StringSwitch.h" -#include "llvm/Support/ScopedPrinter.h" using namespace llvm; using namespace llvm::dxbc; @@ -29,33 +28,3 @@ bool ShaderHash::isPopulated() { static uint8_t Zeros[16] = {0}; return Flags > 0 || 0 != memcmp(&Digest, &Zeros, 16); } - -#define SEMANTIC_KIND(Val, Enum) {#Enum, PSV::SemanticKind::Enum}, - -static const EnumEntry SemanticKindNames[] = { -#include "llvm/BinaryFormat/DXContainerConstants.def" -}; - -ArrayRef> PSV::getSemanticKinds() { - return ArrayRef(SemanticKindNames); -} - -#define COMPONENT_TYPE(Val, Enum) {#Enum, PSV::ComponentType::Enum}, - -static const EnumEntry ComponentTypeNames[] = { -#include "llvm/BinaryFormat/DXContainerConstants.def" -}; - -ArrayRef> PSV::getComponentTypes() { - return ArrayRef(ComponentTypeNames); -} - -#define INTERPOLATION_MODE(Val, Enum) {#Enum, PSV::InterpolationMode::Enum}, - -static const EnumEntry InterpolationModeNames[] = { -#include "llvm/BinaryFormat/DXContainerConstants.def" -}; - -ArrayRef> PSV::getInterpolationModes() { - return ArrayRef(InterpolationModeNames); -} diff --git a/llvm/lib/MC/DXContainerPSVInfo.cpp b/llvm/lib/MC/DXContainerPSVInfo.cpp index 36cef31b6354d..efd75370bbf06 100644 --- a/llvm/lib/MC/DXContainerPSVInfo.cpp +++ b/llvm/lib/MC/DXContainerPSVInfo.cpp @@ -8,7 +8,6 @@ #include "llvm/MC/DXContainerPSVInfo.h" #include "llvm/BinaryFormat/DXContainer.h" -#include "llvm/MC/StringTableBuilder.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/raw_ostream.h" @@ -16,59 +15,7 @@ using namespace llvm; using namespace llvm::mcdxbc; using namespace llvm::dxbc::PSV; -static constexpr size_t npos = StringRef::npos; - -static size_t FindSequence(ArrayRef Buffer, - ArrayRef Sequence) { - if (Buffer.size() < Sequence.size()) - return npos; - for (size_t Idx = 0; Idx <= Buffer.size() - Sequence.size(); ++Idx) { - if (0 == memcmp(static_cast(&Buffer[Idx]), - static_cast(Sequence.begin()), - Sequence.size() * sizeof(uint32_t))) - return Idx; - } - return npos; -} - -static void -ProcessElementList(StringTableBuilder &StrTabBuilder, - SmallVectorImpl &IndexBuffer, - SmallVectorImpl &FinalElements, - SmallVectorImpl &SemanticNames, - ArrayRef Elements) { - for (const auto &El : Elements) { - // Put the name in the string table and the name list. - StrTabBuilder.add(El.Name); - SemanticNames.push_back(El.Name); - - v0::SignatureElement FinalElement; - memset(&FinalElement, 0, sizeof(v0::SignatureElement)); - FinalElement.Rows = static_cast(El.Indices.size()); - FinalElement.StartRow = El.StartRow; - FinalElement.Cols = El.Cols; - FinalElement.StartCol = El.StartCol; - FinalElement.Allocated = El.Allocated; - FinalElement.Kind = El.Kind; - FinalElement.Type = El.Type; - FinalElement.Mode = El.Mode; - FinalElement.DynamicMask = El.DynamicMask; - FinalElement.Stream = El.Stream; - - size_t Idx = FindSequence(IndexBuffer, El.Indices); - if (Idx == npos) { - FinalElement.IndicesOffset = static_cast(IndexBuffer.size()); - IndexBuffer.insert(IndexBuffer.end(), El.Indices.begin(), - El.Indices.end()); - } else - FinalElement.IndicesOffset = static_cast(Idx); - FinalElements.push_back(FinalElement); - } -} - void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { - assert(IsFinalized && "finalize must be called before write"); - uint32_t InfoSize; uint32_t BindingSize; switch (Version) { @@ -94,50 +41,8 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { uint32_t ResourceCount = static_cast(Resources.size()); support::endian::write(OS, ResourceCount, support::little); - if (ResourceCount > 0) - support::endian::write(OS, BindingSize, support::little); + support::endian::write(OS, BindingSize, support::little); for (const auto &Res : Resources) OS.write(reinterpret_cast(&Res), BindingSize); - - StringTableBuilder StrTabBuilder((StringTableBuilder::DXContainer)); - SmallVector IndexBuffer; - SmallVector SignatureElements; - SmallVector SemanticNames; - - ProcessElementList(StrTabBuilder, IndexBuffer, SignatureElements, - SemanticNames, InputElements); - ProcessElementList(StrTabBuilder, IndexBuffer, SignatureElements, - SemanticNames, OutputElements); - ProcessElementList(StrTabBuilder, IndexBuffer, SignatureElements, - SemanticNames, PatchOrPrimElements); - - StrTabBuilder.finalize(); - for (auto ElAndName : zip(SignatureElements, SemanticNames)) { - v0::SignatureElement &El = std::get<0>(ElAndName); - StringRef Name = std::get<1>(ElAndName); - El.NameOffset = static_cast(StrTabBuilder.getOffset(Name)); - if (sys::IsBigEndianHost) - El.swapBytes(); - } - - support::endian::write(OS, static_cast(StrTabBuilder.getSize()), - support::little); - - // Write the string table. - StrTabBuilder.write(OS); - - // Write the index table size, then table. - support::endian::write(OS, static_cast(IndexBuffer.size()), - support::little); - for (auto I : IndexBuffer) - support::endian::write(OS, I, support::little); - - // write the size of the signature elements. - support::endian::write( - OS, static_cast(sizeof(v0::SignatureElement)), support::little); - - // write the signature elements. - OS.write(reinterpret_cast(&SignatureElements[0]), - SignatureElements.size() * sizeof(v0::SignatureElement)); } diff --git a/llvm/lib/MC/StringTableBuilder.cpp b/llvm/lib/MC/StringTableBuilder.cpp index 0e4f72e136151..bb948fe3d13bf 100644 --- a/llvm/lib/MC/StringTableBuilder.cpp +++ b/llvm/lib/MC/StringTableBuilder.cpp @@ -41,7 +41,6 @@ void StringTableBuilder::initSize() { case MachO: case MachO64: case ELF: - case DXContainer: // Start the table with a NUL byte. Size = 1; break; @@ -168,7 +167,7 @@ void StringTableBuilder::finalizeStringTable(bool Optimize) { } } - if (K == MachO || K == MachOLinked || K == DXContainer) + if (K == MachO || K == MachOLinked) Size = alignTo(Size, 4); // Pad to multiple of 4. if (K == MachO64 || K == MachO64Linked) Size = alignTo(Size, 8); // Pad to multiple of 8. diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp index df1f98213a995..48932afea84b8 100644 --- a/llvm/lib/Object/DXContainer.cpp +++ b/llvm/lib/Object/DXContainer.cpp @@ -9,7 +9,6 @@ #include "llvm/Object/DXContainer.h" #include "llvm/BinaryFormat/DXContainer.h" #include "llvm/Object/Error.h" -#include "llvm/Support/Alignment.h" #include "llvm/Support/FormatVariadic.h" using namespace llvm; @@ -224,17 +223,14 @@ Error DirectX::PSVRuntimeInfo::parse(uint16_t ShaderKind) { if (sys::IsBigEndianHost) Info.swapBytes(ShaderStage); BasicInfo = Info; - } else if (PSVVersion == 0) { + } else { v0::RuntimeInfo Info; if (Error Err = readStruct(PSVInfoData, Current, Info)) return Err; if (sys::IsBigEndianHost) Info.swapBytes(ShaderStage); BasicInfo = Info; - } else - return parseFailed( - "Cannot read PSV Runtime Info, unsupported PSV version."); - + } Current += Size; uint32_t ResourceCount = 0; @@ -255,95 +251,7 @@ Error DirectX::PSVRuntimeInfo::parse(uint16_t ShaderKind) { "Resource binding data extends beyond the bounds of the part"); Current += BindingDataSize; - } else - Resources.Stride = sizeof(v2::ResourceBindInfo); - - // PSV version 0 ends after the resource bindings. - if (PSVVersion == 0) - return Error::success(); - - // String table starts at a 4-byte offset. - Current = reinterpret_cast( - alignTo<4>(reinterpret_cast(Current))); - - uint32_t StringTableSize = 0; - if (Error Err = readInteger(Data, Current, StringTableSize)) - return Err; - if (StringTableSize % 4 != 0) - return parseFailed("String table misaligned"); - Current += sizeof(uint32_t); - StringTable = StringRef(Current, StringTableSize); - - Current += StringTableSize; - - uint32_t SemanticIndexTableSize = 0; - if (Error Err = readInteger(Data, Current, SemanticIndexTableSize)) - return Err; - Current += sizeof(uint32_t); - - SemanticIndexTable.reserve(SemanticIndexTableSize); - for (uint32_t I = 0; I < SemanticIndexTableSize; ++I) { - uint32_t Index = 0; - if (Error Err = readInteger(Data, Current, Index)) - return Err; - Current += sizeof(uint32_t); - SemanticIndexTable.push_back(Index); - } - - uint8_t InputCount = getSigInputCount(); - uint8_t OutputCount = getSigOutputCount(); - uint8_t PatchOrPrimCount = getSigPatchOrPrimCount(); - - uint32_t ElementCount = InputCount + OutputCount + PatchOrPrimCount; - - if (ElementCount > 0) { - if (Error Err = readInteger(Data, Current, SigInputElements.Stride)) - return Err; - Current += sizeof(uint32_t); - // Assign the stride to all the arrays. - SigOutputElements.Stride = SigPatchOrPrimElements.Stride = - SigInputElements.Stride; - - if (Data.end() - Current < ElementCount * SigInputElements.Stride) - return parseFailed( - "Signature elements extend beyond the size of the part"); - - size_t InputSize = SigInputElements.Stride * InputCount; - SigInputElements.Data = Data.substr(Current - Data.begin(), InputSize); - Current += InputSize; - - size_t OutputSize = SigOutputElements.Stride * OutputCount; - SigOutputElements.Data = Data.substr(Current - Data.begin(), OutputSize); - Current += OutputSize; - - size_t PSize = SigPatchOrPrimElements.Stride * PatchOrPrimCount; - SigPatchOrPrimElements.Data = Data.substr(Current - Data.begin(), PSize); - Current += PSize; } return Error::success(); } - -uint8_t DirectX::PSVRuntimeInfo::getSigInputCount() const { - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigInputElements; - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigInputElements; - return 0; -} - -uint8_t DirectX::PSVRuntimeInfo::getSigOutputCount() const { - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigOutputElements; - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigOutputElements; - return 0; -} - -uint8_t DirectX::PSVRuntimeInfo::getSigPatchOrPrimCount() const { - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigPatchOrPrimElements; - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigPatchOrPrimElements; - return 0; -} diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp index c5d5d6551d401..64b13fc0ccde9 100644 --- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp +++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp @@ -201,26 +201,9 @@ void DXContainerWriter::writeParts(raw_ostream &OS) { memcpy(&PSV.BaseData, &P.Info->Info, sizeof(dxbc::PSV::v2::RuntimeInfo)); PSV.Resources = P.Info->Resources; - for (auto El : P.Info->SigInputElements) - PSV.InputElements.push_back(mcdxbc::PSVSignatureElement{ - El.Name, El.Indices, El.StartRow, El.Cols, El.StartCol, - El.Allocated, El.Kind, El.Type, El.Mode, El.DynamicMask, - El.Stream}); - - for (auto El : P.Info->SigOutputElements) - PSV.OutputElements.push_back(mcdxbc::PSVSignatureElement{ - El.Name, El.Indices, El.StartRow, El.Cols, El.StartCol, - El.Allocated, El.Kind, El.Type, El.Mode, El.DynamicMask, - El.Stream}); - - for (auto El : P.Info->SigPatchOrPrimElements) - PSV.PatchOrPrimElements.push_back(mcdxbc::PSVSignatureElement{ - El.Name, El.Indices, El.StartRow, El.Cols, El.StartCol, - El.Allocated, El.Kind, El.Type, El.Mode, El.DynamicMask, - El.Stream}); - - PSV.finalize(static_cast( - Triple::Pixel + P.Info->Info.ShaderStage)); + if (sys::IsBigEndianHost) + PSV.swapBytes(static_cast( + Triple::Pixel + P.Info->Info.ShaderStage)); PSV.write(OS, P.Info->Version); break; } diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp index 2b03098d7a5d0..ed9f39954111c 100644 --- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp +++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp @@ -12,9 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ObjectYAML/DXContainerYAML.h" -#include "llvm/ADT/ScopeExit.h" #include "llvm/BinaryFormat/DXContainer.h" -#include "llvm/Support/ScopedPrinter.h" namespace llvm { @@ -124,9 +122,6 @@ void MappingTraits::mapping( uint32_t Version = PSV.Version; IO.setContext(&Version); - // Restore the YAML context on function exit. - auto RestoreContext = make_scope_exit([&]() { IO.setContext(OldContext); }); - // 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); @@ -134,11 +129,9 @@ void MappingTraits::mapping( IO.mapRequired("ResourceStride", PSV.ResourceStride); IO.mapRequired("Resources", PSV.Resources); - if (PSV.Version == 0) - return; - IO.mapRequired("SigInputElements", PSV.SigInputElements); - IO.mapRequired("SigOutputElements", PSV.SigOutputElements); - IO.mapRequired("SigPatchOrPrimElements", PSV.SigPatchOrPrimElements); + + // Restore the YAML context. + IO.setContext(OldContext); } void MappingTraits::mapping(IO &IO, @@ -173,39 +166,6 @@ void MappingTraits::mapping( IO.mapRequired("Flags", Res.Flags); } -void MappingTraits::mapping( - IO &IO, DXContainerYAML::SignatureElement &El) { - IO.mapRequired("Name", El.Name); - IO.mapRequired("Indices", El.Indices); - IO.mapRequired("StartRow", El.StartRow); - IO.mapRequired("Cols", El.Cols); - IO.mapRequired("StartCol", El.StartCol); - IO.mapRequired("Allocated", El.Allocated); - IO.mapRequired("Kind", El.Kind); - IO.mapRequired("ComponentType", El.Type); - IO.mapRequired("Interpolation", El.Mode); - IO.mapRequired("DynamicMask", El.DynamicMask); - IO.mapRequired("Stream", El.Stream); -} - -void ScalarEnumerationTraits::enumeration( - IO &IO, dxbc::PSV::SemanticKind &Value) { - for (const auto &E : dxbc::PSV::getSemanticKinds()) - IO.enumCase(Value, E.Name.str().c_str(), E.Value); -} - -void ScalarEnumerationTraits::enumeration( - IO &IO, dxbc::PSV::ComponentType &Value) { - for (const auto &E : dxbc::PSV::getComponentTypes()) - IO.enumCase(Value, E.Name.str().c_str(), E.Value); -} - -void ScalarEnumerationTraits::enumeration( - IO &IO, dxbc::PSV::InterpolationMode &Value) { - for (const auto &E : dxbc::PSV::getInterpolationModes()) - IO.enumCase(Value, E.Name.str().c_str(), E.Value); -} - } // namespace yaml void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) { @@ -282,6 +242,10 @@ void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) { 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); diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml index 29e4b24680785..94c215c1fffc8 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-amplification.yaml @@ -18,6 +18,9 @@ Parts: MinimumWaveLaneCount: 0 MaximumWaveLaneCount: 4294967295 UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] ResourceStride: 16 @@ -30,9 +33,6 @@ Parts: Space: 32768 LowerBound: 8388608 UpperBound: 2147483648 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -53,6 +53,9 @@ Parts: # 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: ResourceStride: 16 @@ -65,7 +68,4 @@ Parts: # CHECK-NEXT: Space: 32768 # CHECK-NEXT: LowerBound: 8388608 # CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml index 8caae8cf868f0..715b28b812c82 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-compute.yaml @@ -17,6 +17,9 @@ Parts: MinimumWaveLaneCount: 0 MaximumWaveLaneCount: 4294967295 UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] ResourceStride: 16 @@ -29,9 +32,6 @@ Parts: Space: 32768 LowerBound: 8388608 UpperBound: 2147483648 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -51,6 +51,9 @@ Parts: # 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: ResourceStride: 16 @@ -63,7 +66,4 @@ Parts: # CHECK-NEXT: Space: 32768 # CHECK-NEXT: LowerBound: 8388608 # CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml index 8c7daa38a7ee8..472b5e0a94779 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-domain.yaml @@ -21,6 +21,9 @@ Parts: MaximumWaveLaneCount: 4294967295 UsesViewID: 128 SigPatchConstOrPrimVectors: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] ResourceStride: 16 @@ -33,9 +36,6 @@ Parts: Space: 32768 LowerBound: 8388608 UpperBound: 2147483648 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -59,6 +59,9 @@ Parts: # 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: ResourceStride: 16 @@ -71,7 +74,4 @@ Parts: # CHECK-NEXT: Space: 32768 # CHECK-NEXT: LowerBound: 8388608 # CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml index 38f2a4cb79a64..0c0a4ed70a1a2 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-geometry.yaml @@ -22,6 +22,9 @@ Parts: MaximumWaveLaneCount: 4294967295 UsesViewID: 128 MaxVertexCount: 4096 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] ResourceStride: 16 @@ -34,9 +37,6 @@ Parts: Space: 32768 LowerBound: 8388608 UpperBound: 2147483648 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -61,6 +61,9 @@ Parts: # 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: ResourceStride: 16 @@ -73,7 +76,4 @@ Parts: # CHECK-NEXT: Space: 32768 # CHECK-NEXT: LowerBound: 8388608 # CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml index 102907d3ed325..330d24ff8597f 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-hull.yaml @@ -22,6 +22,9 @@ Parts: MaximumWaveLaneCount: 4294967295 UsesViewID: 128 SigPatchConstOrPrimVectors: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] ResourceStride: 16 @@ -34,9 +37,6 @@ Parts: Space: 32768 LowerBound: 8388608 UpperBound: 2147483648 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -61,6 +61,9 @@ Parts: # 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: ResourceStride: 16 @@ -73,7 +76,4 @@ Parts: # CHECK-NEXT: Space: 32768 # CHECK-NEXT: LowerBound: 8388608 # CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml index 2bf8a3d54f951..51bd6390df15e 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-mesh.yaml @@ -24,6 +24,9 @@ Parts: UsesViewID: 128 SigPrimVectors: 128 MeshOutputTopology: 16 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] ResourceStride: 16 @@ -36,9 +39,6 @@ Parts: Space: 32768 LowerBound: 8388608 UpperBound: 2147483648 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -65,6 +65,9 @@ Parts: # 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: ResourceStride: 16 @@ -77,7 +80,4 @@ Parts: # CHECK-NEXT: Space: 32768 # CHECK-NEXT: LowerBound: 8388608 # CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml index df4ef44937e97..2e49034f4e3fc 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-pixel.yaml @@ -19,6 +19,9 @@ Parts: MinimumWaveLaneCount: 0 MaximumWaveLaneCount: 4294967295 UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] ResourceStride: 16 @@ -31,9 +34,6 @@ Parts: Space: 32768 LowerBound: 8388608 UpperBound: 2147483648 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -55,6 +55,9 @@ Parts: # 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: ResourceStride: 16 @@ -67,7 +70,4 @@ Parts: # CHECK-NEXT: Space: 32768 # CHECK-NEXT: LowerBound: 8388608 # CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml index 5bd8739cbf442..ad8f08200d507 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv1-vertex.yaml @@ -18,6 +18,9 @@ Parts: MinimumWaveLaneCount: 0 MaximumWaveLaneCount: 4294967295 UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] ResourceStride: 16 @@ -30,9 +33,6 @@ Parts: Space: 32768 LowerBound: 8388608 UpperBound: 2147483648 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -53,6 +53,9 @@ Parts: # 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: ResourceStride: 16 @@ -65,7 +68,4 @@ Parts: # CHECK-NEXT: Space: 32768 # CHECK-NEXT: LowerBound: 8388608 # CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml index 48f5edf1d25f6..d4fee91294099 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-amplification.yaml @@ -18,6 +18,9 @@ Parts: MinimumWaveLaneCount: 0 MaximumWaveLaneCount: 4294967295 UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] NumThreadsX: 512 @@ -37,9 +40,6 @@ Parts: UpperBound: 2147483648 Kind: 65535 Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -60,6 +60,9 @@ Parts: # 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 @@ -79,7 +82,4 @@ Parts: # CHECK-NEXT: UpperBound: 2147483648 # CHECK-NEXT: Kind: 65535 # CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml index 16336f1db79c8..5ee136bf22750 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-compute.yaml @@ -17,6 +17,9 @@ Parts: MinimumWaveLaneCount: 0 MaximumWaveLaneCount: 4294967295 UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] NumThreadsX: 512 @@ -36,9 +39,6 @@ Parts: UpperBound: 2147483648 Kind: 65535 Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -58,6 +58,9 @@ Parts: # 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 @@ -77,7 +80,4 @@ Parts: # CHECK-NEXT: UpperBound: 2147483648 # CHECK-NEXT: Kind: 65535 # CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml index 4aab33ac342d8..4ed9f04e9dc4a 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-domain.yaml @@ -21,6 +21,9 @@ Parts: MaximumWaveLaneCount: 4294967295 UsesViewID: 128 SigPatchConstOrPrimVectors: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] NumThreadsX: 512 @@ -40,9 +43,6 @@ Parts: UpperBound: 2147483648 Kind: 65535 Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -66,6 +66,9 @@ Parts: # 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 @@ -85,7 +88,4 @@ Parts: # CHECK-NEXT: UpperBound: 2147483648 # CHECK-NEXT: Kind: 65535 # CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml index 7fe7b84c1204c..66def9becdef1 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-geometry.yaml @@ -22,6 +22,9 @@ Parts: MaximumWaveLaneCount: 4294967295 UsesViewID: 128 MaxVertexCount: 4096 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] NumThreadsX: 512 @@ -41,9 +44,6 @@ Parts: UpperBound: 2147483648 Kind: 65535 Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -68,6 +68,9 @@ Parts: # 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 @@ -87,7 +90,4 @@ Parts: # CHECK-NEXT: UpperBound: 2147483648 # CHECK-NEXT: Kind: 65535 # CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml index 4eb0dfcbd482b..0a35992c89b80 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-hull.yaml @@ -22,6 +22,9 @@ Parts: MaximumWaveLaneCount: 4294967295 UsesViewID: 128 SigPatchConstOrPrimVectors: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] NumThreadsX: 512 @@ -41,9 +44,6 @@ Parts: UpperBound: 2147483648 Kind: 65535 Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -68,6 +68,9 @@ Parts: # 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 @@ -87,7 +90,4 @@ Parts: # CHECK-NEXT: UpperBound: 2147483648 # CHECK-NEXT: Kind: 65535 # CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml index 873acba05a71e..ec81b60b0d837 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-mesh.yaml @@ -24,6 +24,9 @@ Parts: UsesViewID: 128 SigPrimVectors: 128 MeshOutputTopology: 16 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] NumThreadsX: 512 @@ -43,9 +46,6 @@ Parts: UpperBound: 2147483648 Kind: 65535 Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -72,6 +72,9 @@ Parts: # 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 @@ -91,7 +94,4 @@ Parts: # CHECK-NEXT: UpperBound: 2147483648 # CHECK-NEXT: Kind: 65535 # CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml index 63e2de6eefb08..60e53f8fb7b06 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-pixel.yaml @@ -19,6 +19,9 @@ Parts: MinimumWaveLaneCount: 0 MaximumWaveLaneCount: 4294967295 UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] NumThreadsX: 512 @@ -38,9 +41,6 @@ Parts: UpperBound: 2147483648 Kind: 65535 Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -62,6 +62,9 @@ Parts: # 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 @@ -81,7 +84,4 @@ Parts: # CHECK-NEXT: UpperBound: 2147483648 # CHECK-NEXT: Kind: 65535 # CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml index fb595b51a0fdd..15b227c06fad3 100644 --- a/llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml +++ b/llvm/test/ObjectYAML/DXContainer/PSVv2-vertex.yaml @@ -18,6 +18,9 @@ Parts: MinimumWaveLaneCount: 0 MaximumWaveLaneCount: 4294967295 UsesViewID: 128 + SigInputElements: 8 + SigOutputElements: 16 + SigPatchConstOrPrimElements: 32 SigInputVectors: 64 SigOutputVectors: [ 8, 16, 32, 64 ] NumThreadsX: 512 @@ -37,9 +40,6 @@ Parts: UpperBound: 2147483648 Kind: 65535 Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - Name: DXIL Size: 24 Program: @@ -60,6 +60,9 @@ Parts: # 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 @@ -79,7 +82,4 @@ Parts: # CHECK-NEXT: UpperBound: 2147483648 # CHECK-NEXT: Kind: 65535 # CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] # CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/SigElements.yaml b/llvm/test/ObjectYAML/DXContainer/SigElements.yaml deleted file mode 100644 index 8e2e5aa3e3e26..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/SigElements.yaml +++ /dev/null @@ -1,144 +0,0 @@ -# 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: 250 - PSVInfo: - Version: 1 - ShaderStage: 0 - DepthOutput: 7 - SampleFrequency: 96 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 128 - SigInputVectors: 64 - SigOutputVectors: [ 8, 16, 32, 64 ] - ResourceStride: 16 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - SigInputElements: - - Name: IN - Indices: [ 0, 1 ] - StartRow: 0 - Cols: 2 - StartCol: 0 - Allocated: true - Kind: Arbitrary - ComponentType: SInt32 - Interpolation: Undefined - DynamicMask: 0x0 - Stream: 0 - SigOutputElements: - - Name: OUT - Indices: [ 0, 1 ] - StartRow: 0 - Cols: 2 - StartCol: 0 - Allocated: true - Kind: Arbitrary - ComponentType: Float32 - Interpolation: Linear - DynamicMask: 0x0 - Stream: 1 - SigPatchOrPrimElements: - - Name: Patch - Indices: [ 0 ] - StartRow: 0 - Cols: 1 - StartCol: 0 - Allocated: true - Kind: Arbitrary - ComponentType: Float32 - Interpolation: Linear - DynamicMask: 0x1 - Stream: 2 - - Name: Patch1 - Indices: [ 2 ] - StartRow: 0 - Cols: 1 - StartCol: 0 - Allocated: true - Kind: Arbitrary - ComponentType: Float64 - Interpolation: LinearSample - DynamicMask: 0x2 - Stream: 3 - - 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: SigInputElements: -# CHECK-NEXT: - Name: IN -# CHECK-NEXT: Indices: [ 0, 1 ] -# CHECK-NEXT: StartRow: 0 -# CHECK-NEXT: Cols: 2 -# CHECK-NEXT: StartCol: 0 -# CHECK-NEXT: Allocated: true -# CHECK-NEXT: Kind: Arbitrary -# CHECK-NEXT: ComponentType: SInt32 -# CHECK-NEXT: Interpolation: Undefined -# CHECK-NEXT: DynamicMask: 0x0 -# CHECK-NEXT: Stream: 0 -# CHECK-NEXT: SigOutputElements: -# CHECK-NEXT: - Name: OUT -# CHECK-NEXT: Indices: [ 0, 1 ] -# CHECK-NEXT: StartRow: 0 -# CHECK-NEXT: Cols: 2 -# CHECK-NEXT: StartCol: 0 -# CHECK-NEXT: Allocated: true -# CHECK-NEXT: Kind: Arbitrary -# CHECK-NEXT: ComponentType: Float32 -# CHECK-NEXT: Interpolation: Linear -# CHECK-NEXT: DynamicMask: 0x0 -# CHECK-NEXT: Stream: 1 -# CHECK-NEXT: SigPatchOrPrimElements: -# CHECK-NEXT: - Name: Patch -# CHECK-NEXT: Indices: [ 0 ] -# CHECK-NEXT: StartRow: 0 -# CHECK-NEXT: Cols: 1 -# CHECK-NEXT: StartCol: 0 -# CHECK-NEXT: Allocated: true -# CHECK-NEXT: Kind: Arbitrary -# CHECK-NEXT: ComponentType: Float32 -# CHECK-NEXT: Interpolation: Linear -# CHECK-NEXT: DynamicMask: 0x1 -# CHECK-NEXT: Stream: 2 -# CHECK-NEXT: - Name: Patch1 -# CHECK-NEXT: Indices: [ 2 ] -# CHECK-NEXT: StartRow: 0 -# CHECK-NEXT: Cols: 1 -# CHECK-NEXT: StartCol: 0 -# CHECK-NEXT: Allocated: true -# CHECK-NEXT: Kind: Arbitrary -# CHECK-NEXT: ComponentType: Float64 -# CHECK-NEXT: Interpolation: LinearSample -# CHECK-NEXT: DynamicMask: 0x2 -# CHECK-NEXT: Stream: 3 diff --git a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp index 0b38839a720cb..dd3bea67c75fc 100644 --- a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp +++ b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp @@ -92,22 +92,6 @@ dumpDXContainer(MemoryBufferRef Source) { NewPart.Info->ResourceStride = PSVInfo->getResourceStride(); for (auto Res : PSVInfo->getResources()) NewPart.Info->Resources.push_back(Res); - - for (auto El : PSVInfo->getSigInputElements()) - NewPart.Info->SigInputElements.push_back( - DXContainerYAML::SignatureElement( - El, PSVInfo->getStringTable(), - PSVInfo->getSemanticIndexTable())); - for (auto El : PSVInfo->getSigOutputElements()) - NewPart.Info->SigOutputElements.push_back( - DXContainerYAML::SignatureElement( - El, PSVInfo->getStringTable(), - PSVInfo->getSemanticIndexTable())); - for (auto El : PSVInfo->getSigPatchOrPrimElements()) - NewPart.Info->SigPatchOrPrimElements.push_back( - DXContainerYAML::SignatureElement( - El, PSVInfo->getStringTable(), - PSVInfo->getSemanticIndexTable())); break; } case dxbc::PartType::Unknown: diff --git a/llvm/unittests/Object/DXContainerTest.cpp b/llvm/unittests/Object/DXContainerTest.cpp index 94d8dc40defd4..151fab0ac81c7 100644 --- a/llvm/unittests/Object/DXContainerTest.cpp +++ b/llvm/unittests/Object/DXContainerTest.cpp @@ -593,50 +593,3 @@ TEST(DXCFile, PSVResourceIteratorsStride) { EXPECT_EQ(Binding.Type, 0u); EXPECT_EQ(Binding.Flags, 0u); } - -// This test binary is created using mutations of the yaml in the SigElements -// test found under test/ObjectYAML/DXContainer/SigElements.yaml. - -TEST(DXCFile, MisalignedStringTable) { - uint8_t Buffer[] = { - 0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0xb4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, 0x18, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, - 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x50, 0x53, 0x56, 0x30, 0x68, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0x05, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x08, 0x10, 0x20, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - EXPECT_THAT_EXPECTED(DXContainer::create(getMemoryBuffer<168>(Buffer)), - FailedWithMessage("String table misaligned")); -} - -// This test binary is created using mutations of the yaml in the SigElements -// test found under test/ObjectYAML/DXContainer/SigElements.yaml. -TEST(DXCFile, SigElementsExtendBeyondPart) { - uint8_t Buffer[] = { - 0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0xb4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, 0x18, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4c, - 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x50, 0x53, 0x56, 0x30, 0x54, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, - 0x05, 0x80, 0x00, 0x00, 0x02, 0x00, 0x00, 0x40, 0x08, 0x10, 0x20, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x42, 0x00, 0x02, 0x00, 0x03, 0x00}; - EXPECT_THAT_EXPECTED( - DXContainer::create(getMemoryBuffer<164>(Buffer)), - FailedWithMessage( - "Signature elements extend beyond the size of the part")); -}