https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/139963

>From bc246e6523f726f9a9a6c2563a58eec39888aadc Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saff...@microsoft.com>
Date: Wed, 7 May 2025 00:13:27 +0000
Subject: [PATCH 1/6] adding static samplers

---
 llvm/include/llvm/BinaryFormat/DXContainer.h  | 51 +++++++++++++
 .../BinaryFormat/DXContainerConstants.def     | 73 +++++++++++++++++++
 .../llvm/MC/DXContainerRootSignature.h        |  1 +
 llvm/include/llvm/Object/DXContainer.h        |  5 ++
 .../include/llvm/ObjectYAML/DXContainerYAML.h | 26 +++++++
 llvm/lib/MC/DXContainerRootSignature.cpp      | 20 ++++-
 llvm/lib/Object/DXContainer.cpp               |  4 +
 llvm/lib/ObjectYAML/DXContainerYAML.cpp       | 37 ++++++++++
 8 files changed, 216 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h 
b/llvm/include/llvm/BinaryFormat/DXContainer.h
index 98e30b1b6a8af..c2b55c2c820aa 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -18,6 +18,7 @@
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/TargetParser/Triple.h"
 
+#include <cstdint>
 #include <stdint.h>
 
 namespace llvm {
@@ -600,6 +601,25 @@ inline bool isValidShaderVisibility(uint32_t V) {
   return false;
 }
 
+#define STATIC_SAMPLER_FILTER(Val, Enum) Enum = Val,
+enum class StaticSamplerFilter : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+#define TEXTURE_ADDRESS_MODE(Val, Enum) Enum = Val,
+enum class TextureAddressMode : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+#define COMPARISON_FUNCTION(Val, Enum) Enum = Val,
+enum class ComparisonFunction : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+#define STATIC_BORDER_COLOR(Val, Enum) Enum = Val,
+enum class StaticBorderColor : uint32_t {
+#include "DXContainerConstants.def"
+};
 namespace v0 {
 
 struct RootSignatureHeader {
@@ -667,6 +687,37 @@ struct DescriptorRange {
     sys::swapByteOrder(OffsetInDescriptorsFromTableStart);
   }
 };
+
+struct StaticSampler {
+  StaticSamplerFilter Filter;
+  TextureAddressMode AddressU;
+  TextureAddressMode AddressV;
+  TextureAddressMode AddressW;
+  float MipLODBias;
+  uint32_t MaxAnisotropy;
+  ComparisonFunction ComparisonFunc;
+  StaticBorderColor BorderColor;
+  float MinLOD;
+  float MaxLOD;
+  uint32_t ShaderRegister;
+  uint32_t RegisterSpace;
+  ShaderVisibility ShaderVisibility;
+  void swapBytes() {
+    sys::swapByteOrder(Filter);
+    sys::swapByteOrder(AddressU);
+    sys::swapByteOrder(AddressV);
+    sys::swapByteOrder(AddressW);
+    sys::swapByteOrder(MipLODBias);
+    sys::swapByteOrder(MaxAnisotropy);
+    sys::swapByteOrder(ComparisonFunc);
+    sys::swapByteOrder(BorderColor);
+    sys::swapByteOrder(MinLOD);
+    sys::swapByteOrder(MaxLOD);
+    sys::swapByteOrder(ShaderRegister);
+    sys::swapByteOrder(RegisterSpace);
+    sys::swapByteOrder(ShaderVisibility);
+  };
+};
 } // namespace v0
 
 namespace v1 {
diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def 
b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
index 5fe7e7c321a33..f25c464d5f9cc 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
+++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
@@ -129,6 +129,79 @@ SHADER_VISIBILITY(7, Mesh)
 #undef SHADER_VISIBILITY
 #endif // SHADER_VISIBILITY
 
+#ifdef STATIC_SAMPLER_FILTER
+
+STATIC_SAMPLER_FILTER(0, MIN_MAG_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x1, MIN_MAG_POINT_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x4, MIN_POINT_MAG_LINEAR_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x5, MIN_POINT_MAG_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x10, MIN_LINEAR_MAG_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x11, MIN_LINEAR_MAG_POINT_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x14, MIN_MAG_LINEAR_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x15, MIN_MAG_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x55, ANISOTROPIC)
+STATIC_SAMPLER_FILTER(0x80, COMPARISON_MIN_MAG_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x81, COMPARISON_MIN_MAG_POINT_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x84, COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x85, COMPARISON_MIN_POINT_MAG_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x90, COMPARISON_MIN_LINEAR_MAG_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x91, COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x94, COMPARISON_MIN_MAG_LINEAR_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x95, COMPARISON_MIN_MAG_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0xd5, COMPARISON_ANISOTROPIC)
+STATIC_SAMPLER_FILTER(0x100, MINIMUM_MIN_MAG_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x101, MINIMUM_MIN_MAG_POINT_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x104, MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x105, MINIMUM_MIN_POINT_MAG_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x110, MINIMUM_MIN_LINEAR_MAG_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x111, MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x114, MINIMUM_MIN_MAG_LINEAR_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x115, MINIMUM_MIN_MAG_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x155, MINIMUM_ANISOTROPIC)
+STATIC_SAMPLER_FILTER(0x180, MAXIMUM_MIN_MAG_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x181, MAXIMUM_MIN_MAG_POINT_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x184, MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x185, MAXIMUM_MIN_POINT_MAG_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x190, MAXIMUM_MIN_LINEAR_MAG_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x191, MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x194, MAXIMUM_MIN_MAG_LINEAR_MIP_POINT)
+STATIC_SAMPLER_FILTER(0x195, MAXIMUM_MIN_MAG_MIP_LINEAR)
+STATIC_SAMPLER_FILTER(0x1d5, MAXIMUM_ANISOTROPIC)
+#undef STATIC_SAMPLER_FILTER
+#endif // STATIC_SAMPLER_FILTER
+
+#ifdef TEXTURE_ADDRESS_MODE
+
+TEXTURE_ADDRESS_MODE( 1,  Wrap)
+TEXTURE_ADDRESS_MODE( 2,  Mirror)
+TEXTURE_ADDRESS_MODE( 3,  Clamp)
+TEXTURE_ADDRESS_MODE( 4,  Border)
+TEXTURE_ADDRESS_MODE( 5,  MirrorOnce)
+#undef TEXTURE_ADDRESS_MODE
+#endif // TEXTURE_ADDRESS_MODE
+
+#ifdef COMPARISON_FUNCTION
+
+COMPARISON_FUNCTION( 1,  Never)
+COMPARISON_FUNCTION( 2,  Less)
+COMPARISON_FUNCTION( 3,  Equal)
+COMPARISON_FUNCTION( 4,  LessEqual)
+COMPARISON_FUNCTION( 5,  Greater)
+COMPARISON_FUNCTION( 6,  NotEqual)
+COMPARISON_FUNCTION( 7,  GreaterEqual)
+COMPARISON_FUNCTION( 8,  Always)
+#undef COMPARISON_FUNCTION
+#endif // COMPARISON_FUNCTION
+
+#ifdef STATIC_BORDER_COLOR
+STATIC_BORDER_COLOR( 0,  TransparentBlack)
+STATIC_BORDER_COLOR( 1,  OpaqueBlack)
+STATIC_BORDER_COLOR( 2,  OpaqueWhite)
+STATIC_BORDER_COLOR( 3,  OpaqueBlackUint)
+STATIC_BORDER_COLOR( 4,  OpaqueWhiteUint)
+#undef STATIC_BORDER_COLOR
+#endif // STATIC_BORDER_COLOR
+
 #ifdef DXIL_MODULE_FLAG
 
 // Only save DXIL module flags which not map to feature flags here.
diff --git a/llvm/include/llvm/MC/DXContainerRootSignature.h 
b/llvm/include/llvm/MC/DXContainerRootSignature.h
index 84f6421d8ad9d..45ffafd4df325 100644
--- a/llvm/include/llvm/MC/DXContainerRootSignature.h
+++ b/llvm/include/llvm/MC/DXContainerRootSignature.h
@@ -120,6 +120,7 @@ struct RootSignatureDesc {
   uint32_t StaticSamplersOffset = 0u;
   uint32_t NumStaticSamplers = 0u;
   mcdxbc::RootParametersContainer ParametersContainer;
+  SmallVector<dxbc::RTS0::v0::StaticSampler> StaticSamplers;
 
   void write(raw_ostream &OS) const;
 
diff --git a/llvm/include/llvm/Object/DXContainer.h 
b/llvm/include/llvm/Object/DXContainer.h
index 3e32870c5fb8f..d05d7fa5605bc 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -238,9 +238,11 @@ class RootSignature {
   uint32_t Flags;
   ViewArray<dxbc::RTS0::v0::RootParameterHeader> ParametersHeaders;
   StringRef PartData;
+  ViewArray<dxbc::RTS0::v0::StaticSampler> StaticSamplers;
 
   using param_header_iterator =
       ViewArray<dxbc::RTS0::v0::RootParameterHeader>::iterator;
+  using samplers_iterator = ViewArray<dxbc::RTS0::v0::StaticSampler>::iterator;
 
 public:
   RootSignature(StringRef PD) : PartData(PD) {}
@@ -255,6 +257,9 @@ class RootSignature {
   llvm::iterator_range<param_header_iterator> param_headers() const {
     return llvm::make_range(ParametersHeaders.begin(), 
ParametersHeaders.end());
   }
+  llvm::iterator_range<samplers_iterator> samplers() const {
+    return llvm::make_range(StaticSamplers.begin(), StaticSamplers.end());
+  }
   uint32_t getFlags() const { return Flags; }
 
   llvm::Expected<RootParameterView>
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h 
b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index 549cf0b791e28..b4baeb491b3b7 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -126,6 +126,22 @@ struct RootParameterYamlDesc {
   RootParameterYamlDesc(uint32_t T) : Type(T) {}
 };
 
+struct StaticSamplerYamlDesc {
+  dxbc::RTS0::StaticSamplerFilter Filter;
+  dxbc::RTS0::TextureAddressMode AddressU;
+  dxbc::RTS0::TextureAddressMode AddressV;
+  dxbc::RTS0::TextureAddressMode AddressW;
+  float MipLODBias;
+  uint32_t MaxAnisotropy;
+  dxbc::RTS0::ComparisonFunction ComparisonFunc;
+  dxbc::RTS0::StaticBorderColor BorderColor;
+  float MinLOD;
+  float MaxLOD;
+  uint32_t ShaderRegister;
+  uint32_t RegisterSpace;
+  dxbc::RTS0::ShaderVisibility ShaderVisibility;
+};
+
 struct RootSignatureYamlDesc {
   RootSignatureYamlDesc() = default;
 
@@ -136,6 +152,7 @@ struct RootSignatureYamlDesc {
   uint32_t StaticSamplersOffset;
 
   SmallVector<RootParameterYamlDesc> Parameters;
+  SmallVector<StaticSamplerYamlDesc> StaticSamplers;
 
   uint32_t getEncodedFlags();
 
@@ -143,6 +160,10 @@ struct RootSignatureYamlDesc {
     return make_range(Parameters.begin(), Parameters.end());
   }
 
+  iterator_range<StaticSamplerYamlDesc *> samplers() {
+    return make_range(StaticSamplers.begin(), StaticSamplers.end());
+  }
+
   static llvm::Expected<DXContainerYAML::RootSignatureYamlDesc>
   create(const object::DirectX::RootSignature &Data);
 
@@ -255,6 +276,7 @@ 
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::PSVInfo::MaskVector)
 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::SignatureParameter)
 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::RootParameterYamlDesc)
 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::DescriptorRangeYaml)
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DXContainerYAML::StaticSamplerYamlDesc)
 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)
@@ -347,6 +369,10 @@ template <> struct 
MappingTraits<llvm::DXContainerYAML::DescriptorRangeYaml> {
   static void mapping(IO &IO, llvm::DXContainerYAML::DescriptorRangeYaml &D);
 };
 
+template <> struct MappingTraits<llvm::DXContainerYAML::StaticSamplerYamlDesc> 
{
+  static void mapping(IO &IO, llvm::DXContainerYAML::StaticSamplerYamlDesc &S);
+};
+
 } // namespace yaml
 
 } // namespace llvm
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp 
b/llvm/lib/MC/DXContainerRootSignature.cpp
index 352a8d3a9c603..3415f8e1b101a 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -8,8 +8,10 @@
 
 #include "llvm/MC/DXContainerRootSignature.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/bit.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Support/EndianStream.h"
+#include <cstddef>
 #include <cstdint>
 #include <variant>
 
@@ -65,7 +67,8 @@ static void rewriteOffsetToCurrentByte(raw_svector_ostream 
&Stream,
 size_t RootSignatureDesc::getSize() const {
   size_t Size =
       sizeof(dxbc::RTS0::v0::RootSignatureHeader) +
-      ParametersContainer.size() * sizeof(dxbc::RTS0::v0::RootParameterHeader);
+      ParametersContainer.size() * sizeof(dxbc::RTS0::v0::RootParameterHeader) 
+
+      StaticSamplers.size() * sizeof(dxbc::RTS0::v0::StaticSampler);
 
   for (const auto &I : ParametersContainer) {
     std::optional<ParametersView> P = ParametersContainer.getParameter(&I);
@@ -177,6 +180,21 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
       }
     }
   }
+  for (const auto &S : StaticSamplers) {
+    support::endian::write(BOS, S.Filter, llvm::endianness::little);
+    support::endian::write(BOS, S.AddressU, llvm::endianness::little);
+    support::endian::write(BOS, S.AddressV, llvm::endianness::little);
+    support::endian::write(BOS, S.AddressW, llvm::endianness::little);
+    support::endian::write(BOS, S.MipLODBias, llvm::endianness::little);
+    support::endian::write(BOS, S.MaxAnisotropy, llvm::endianness::little);
+    support::endian::write(BOS, S.ComparisonFunc, llvm::endianness::little);
+    support::endian::write(BOS, S.BorderColor, llvm::endianness::little);
+    support::endian::write(BOS, S.MinLOD, llvm::endianness::little);
+    support::endian::write(BOS, S.MaxLOD, llvm::endianness::little);
+    support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little);
+    support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little);
+    support::endian::write(BOS, S.ShaderVisibility, llvm::endianness::little);
+  }
   assert(Storage.size() == getSize());
   OS.write(Storage.data(), Storage.size());
 }
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index f4617bd87e0f7..8c62510f1936d 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -276,6 +276,10 @@ Error DirectX::RootSignature::parse() {
       RootParametersOffset,
       NumParameters * sizeof(dxbc::RTS0::v0::RootParameterHeader));
 
+  StaticSamplers.Data = PartData.substr(
+      (StaticSamplersOffset,
+       NumStaticSamplers * sizeof(dxbc::RTS0::v0::StaticSampler)));
+
   return Error::success();
 }
 
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp 
b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index f61ef9dc3e2ef..1aeda2f847fee 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -157,6 +157,25 @@ DXContainerYAML::RootSignatureYamlDesc::create(
 
     RootSigDesc.Parameters.push_back(NewP);
   }
+
+  for (const auto &S : Data.samplers()) {
+    StaticSamplerYamlDesc NewS;
+    NewS.Filter = S.Filter;
+    NewS.AddressU = S.AddressU;
+    NewS.AddressV = S.AddressV;
+    NewS.AddressW = S.AddressW;
+    NewS.MipLODBias = S.MipLODBias;
+    NewS.MaxAnisotropy = S.MaxAnisotropy;
+    NewS.ComparisonFunc = S.ComparisonFunc;
+    NewS.BorderColor = S.BorderColor;
+    NewS.MinLOD = S.MinLOD;
+    NewS.MaxLOD = S.MaxLOD;
+    NewS.ShaderRegister = S.ShaderRegister;
+    NewS.RegisterSpace = S.RegisterSpace;
+    NewS.ShaderVisibility = S.ShaderVisibility;
+
+    RootSigDesc.StaticSamplers.push_back(NewS);
+  }
 #define ROOT_ELEMENT_FLAG(Num, Val)                                            
\
   RootSigDesc.Val =                                                            
\
       (Flags & llvm::to_underlying(dxbc::RTS0::RootElementFlag::Val)) > 0;
@@ -428,6 +447,24 @@ void 
MappingTraits<llvm::DXContainerYAML::RootParameterYamlDesc>::mapping(
   }
 }
 
+void MappingTraits<llvm::DXContainerYAML::StaticSamplerYamlDesc>::mapping(
+    IO &IO, llvm::DXContainerYAML::StaticSamplerYamlDesc &S) {
+
+  IO.mapRequired("Filter", S.Filter);
+  IO.mapRequired("AddressU", S.AddressU);
+  IO.mapRequired("AddressV", S.AddressV);
+  IO.mapRequired("AddressW", S.AddressW);
+  IO.mapRequired("MipLODBias", S.MipLODBias);
+  IO.mapRequired("MaxAnisotropy", S.MaxAnisotropy);
+  IO.mapRequired("ComparisonFunc", S.ComparisonFunc);
+  IO.mapRequired("BorderColor", S.BorderColor);
+  IO.mapRequired("MinLOD", S.MinLOD);
+  IO.mapRequired("MaxLOD", S.MaxLOD);
+  IO.mapRequired("ShaderRegister", S.ShaderRegister);
+  IO.mapRequired("RegisterSpace", S.RegisterSpace);
+  IO.mapRequired("ShaderVisibility", S.ShaderVisibility);
+}
+
 void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
                                                    DXContainerYAML::Part &P) {
   IO.mapRequired("Name", P.Name);

>From f23c0543d980456dc925405bf2f700227be855ae Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saff...@microsoft.com>
Date: Wed, 7 May 2025 18:08:48 +0000
Subject: [PATCH 2/6] fixing bugs

---
 llvm/include/llvm/BinaryFormat/DXContainer.h  | 14 +++---
 .../include/llvm/ObjectYAML/DXContainerYAML.h | 14 +++---
 llvm/lib/Object/DXContainer.cpp               |  5 +-
 llvm/lib/ObjectYAML/DXContainerEmitter.cpp    | 19 +++++++
 llvm/lib/ObjectYAML/DXContainerYAML.cpp       |  1 +
 .../RootSignature-StaticSamplers.yaml         | 49 +++++++++++++++++++
 6 files changed, 86 insertions(+), 16 deletions(-)
 create mode 100644 
llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml

diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h 
b/llvm/include/llvm/BinaryFormat/DXContainer.h
index c2b55c2c820aa..c9d54e29be54d 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -689,19 +689,19 @@ struct DescriptorRange {
 };
 
 struct StaticSampler {
-  StaticSamplerFilter Filter;
-  TextureAddressMode AddressU;
-  TextureAddressMode AddressV;
-  TextureAddressMode AddressW;
+  uint32_t Filter;
+  uint32_t AddressU;
+  uint32_t AddressV;
+  uint32_t AddressW;
   float MipLODBias;
   uint32_t MaxAnisotropy;
-  ComparisonFunction ComparisonFunc;
-  StaticBorderColor BorderColor;
+  uint32_t ComparisonFunc;
+  uint32_t BorderColor;
   float MinLOD;
   float MaxLOD;
   uint32_t ShaderRegister;
   uint32_t RegisterSpace;
-  ShaderVisibility ShaderVisibility;
+  uint32_t ShaderVisibility;
   void swapBytes() {
     sys::swapByteOrder(Filter);
     sys::swapByteOrder(AddressU);
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h 
b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index b4baeb491b3b7..72a79b017c498 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -127,19 +127,19 @@ struct RootParameterYamlDesc {
 };
 
 struct StaticSamplerYamlDesc {
-  dxbc::RTS0::StaticSamplerFilter Filter;
-  dxbc::RTS0::TextureAddressMode AddressU;
-  dxbc::RTS0::TextureAddressMode AddressV;
-  dxbc::RTS0::TextureAddressMode AddressW;
+  uint32_t Filter;
+  uint32_t AddressU;
+  uint32_t AddressV;
+  uint32_t AddressW;
   float MipLODBias;
   uint32_t MaxAnisotropy;
-  dxbc::RTS0::ComparisonFunction ComparisonFunc;
-  dxbc::RTS0::StaticBorderColor BorderColor;
+  uint32_t ComparisonFunc;
+  uint32_t BorderColor;
   float MinLOD;
   float MaxLOD;
   uint32_t ShaderRegister;
   uint32_t RegisterSpace;
-  dxbc::RTS0::ShaderVisibility ShaderVisibility;
+  uint32_t ShaderVisibility;
 };
 
 struct RootSignatureYamlDesc {
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index 8c62510f1936d..3b6f4a8c7dedf 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -276,9 +276,10 @@ Error DirectX::RootSignature::parse() {
       RootParametersOffset,
       NumParameters * sizeof(dxbc::RTS0::v0::RootParameterHeader));
 
+  StaticSamplers.Stride = sizeof(dxbc::RTS0::v0::StaticSampler);
   StaticSamplers.Data = PartData.substr(
-      (StaticSamplersOffset,
-       NumStaticSamplers * sizeof(dxbc::RTS0::v0::StaticSampler)));
+      StaticSamplersOffset,
+      NumStaticSamplers * sizeof(dxbc::RTS0::v0::StaticSampler));
 
   return Error::success();
 }
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp 
b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index e24d5cb528389..f8f280469b4ca 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -342,6 +342,25 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
         }
       }
 
+      for (const auto &Param : P.RootSignature->samplers()) {
+        dxbc::RTS0::v0::StaticSampler NewSampler;
+        NewSampler.Filter = Param.Filter;
+        NewSampler.AddressU = Param.AddressU;
+        NewSampler.AddressV = Param.AddressV;
+        NewSampler.AddressW = Param.AddressW;
+        NewSampler.MipLODBias = Param.MipLODBias;
+        NewSampler.MaxAnisotropy = Param.MaxAnisotropy;
+        NewSampler.ComparisonFunc = Param.ComparisonFunc;
+        NewSampler.BorderColor = Param.BorderColor;
+        NewSampler.MinLOD = Param.MinLOD;
+        NewSampler.MaxLOD = Param.MaxLOD;
+        NewSampler.ShaderRegister = Param.ShaderRegister;
+        NewSampler.RegisterSpace = Param.RegisterSpace;
+        NewSampler.ShaderVisibility = Param.ShaderVisibility;
+
+        RS.StaticSamplers.push_back(NewSampler);
+      }
+
       RS.write(OS);
       break;
     }
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp 
b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 1aeda2f847fee..84af8de3f115d 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -377,6 +377,7 @@ void 
MappingTraits<DXContainerYAML::RootSignatureYamlDesc>::mapping(
   IO.mapRequired("NumStaticSamplers", S.NumStaticSamplers);
   IO.mapRequired("StaticSamplersOffset", S.StaticSamplersOffset);
   IO.mapRequired("Parameters", S.Parameters);
+  IO.mapRequired("Samplers", S.StaticSamplers);
 #define ROOT_ELEMENT_FLAG(Num, Val) IO.mapOptional(#Val, S.Val, false);
 #include "llvm/BinaryFormat/DXContainerConstants.def"
 }
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml 
b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml
new file mode 100644
index 0000000000000..dfc74af31e9b7
--- /dev/null
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.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:       1
+  PartOffsets:     [ 60 ]
+Parts:
+  - Name:            RTS0
+    Size:            76
+    RootSignature:
+      Version: 2
+      NumRootParameters: 0
+      RootParametersOffset: 0
+      NumStaticSamplers: 1
+      StaticSamplersOffset: 24
+      Parameters: []
+      Samplers: 
+        - Filter: 10 
+          AddressU: 1
+          AddressV: 2
+          AddressW: 5
+          MipLODBias: 1.23
+          MaxAnisotropy: 20
+          ComparisonFunc: 4
+          BorderColor: 0
+          MinLOD: 4.56
+          MaxLOD: 8.90
+          ShaderRegister: 31 
+          RegisterSpace: 32
+          ShaderVisibility:  7
+      AllowInputAssemblerInputLayout: true
+      DenyGeometryShaderRootAccess: true
+
+# CHECK:  - Name:            RTS0
+# CHECK-NEXT:    Size:            24
+# CHECK-NEXT:    RootSignature:
+# CHECK-NEXT:      Version: 2
+# CHECK-NEXT:      NumRootParameters: 0
+# CHECK-NEXT:      RootParametersOffset: 24
+# CHECK-NEXT:      NumStaticSamplers: 0
+# CHECK-NEXT:      StaticSamplersOffset: 60
+# CHECK-NEXT:      Parameters: []
+# CHECK-NEXT:      AllowInputAssemblerInputLayout: true
+# CHECK-NEXT:      DenyGeometryShaderRootAccess: true

>From 76ca401b68024b824d70a7085ab261df93abd3df Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saff...@microsoft.com>
Date: Wed, 7 May 2025 21:15:51 +0000
Subject: [PATCH 3/6] adding tests

---
 llvm/lib/ObjectYAML/DXContainerYAML.cpp       |  2 +-
 .../RootSignature-StaticSamplers.yaml         | 36 +++++++----
 llvm/unittests/Object/DXContainerTest.cpp     | 46 +++++++++++++++
 .../ObjectYAML/DXContainerYAMLTest.cpp        | 59 +++++++++++++++++++
 4 files changed, 131 insertions(+), 12 deletions(-)

diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp 
b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 84af8de3f115d..ff2b2024562e5 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -377,7 +377,7 @@ void 
MappingTraits<DXContainerYAML::RootSignatureYamlDesc>::mapping(
   IO.mapRequired("NumStaticSamplers", S.NumStaticSamplers);
   IO.mapRequired("StaticSamplersOffset", S.StaticSamplersOffset);
   IO.mapRequired("Parameters", S.Parameters);
-  IO.mapRequired("Samplers", S.StaticSamplers);
+  IO.mapOptional("Samplers", S.StaticSamplers);
 #define ROOT_ELEMENT_FLAG(Num, Val) IO.mapOptional(#Val, S.Val, false);
 #include "llvm/BinaryFormat/DXContainerConstants.def"
 }
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml 
b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml
index dfc74af31e9b7..8f8083e091253 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml
@@ -36,14 +36,28 @@ Parts:
       AllowInputAssemblerInputLayout: true
       DenyGeometryShaderRootAccess: true
 
-# CHECK:  - Name:            RTS0
-# CHECK-NEXT:    Size:            24
-# CHECK-NEXT:    RootSignature:
-# CHECK-NEXT:      Version: 2
-# CHECK-NEXT:      NumRootParameters: 0
-# CHECK-NEXT:      RootParametersOffset: 24
-# CHECK-NEXT:      NumStaticSamplers: 0
-# CHECK-NEXT:      StaticSamplersOffset: 60
-# CHECK-NEXT:      Parameters: []
-# CHECK-NEXT:      AllowInputAssemblerInputLayout: true
-# CHECK-NEXT:      DenyGeometryShaderRootAccess: true
+#CHECK:  - Name:            RTS0
+#CHECK-NEXT:    Size:            76
+#CHECK-NEXT:    RootSignature:
+#CHECK-NEXT:      Version:         2
+#CHECK-NEXT:      NumRootParameters: 0
+#CHECK-NEXT:      RootParametersOffset: 0
+#CHECK-NEXT:      NumStaticSamplers: 1
+#CHECK-NEXT:      StaticSamplersOffset: 24
+#CHECK-NEXT:      Parameters:      []
+#CHECK-NEXT:      Samplers:
+#CHECK-NEXT:        - Filter:          10
+#CHECK-NEXT:          AddressU:        1
+#CHECK-NEXT:          AddressV:        2
+#CHECK-NEXT:          AddressW:        5
+#CHECK-NEXT:          MipLODBias:      1.23
+#CHECK-NEXT:          MaxAnisotropy:   20
+#CHECK-NEXT:          ComparisonFunc:  4
+#CHECK-NEXT:          BorderColor:     0
+#CHECK-NEXT:          MinLOD:          4.56
+#CHECK-NEXT:          MaxLOD:          8.9
+#CHECK-NEXT:          ShaderRegister:  31
+#CHECK-NEXT:          RegisterSpace:   32
+#CHECK-NEXT:          ShaderVisibility: 7
+#CHECK-NEXT:      AllowInputAssemblerInputLayout: true
+#CHECK-NEXT:      DenyGeometryShaderRootAccess: true
diff --git a/llvm/unittests/Object/DXContainerTest.cpp 
b/llvm/unittests/Object/DXContainerTest.cpp
index 602aae875a283..01fa31e60310a 100644
--- a/llvm/unittests/Object/DXContainerTest.cpp
+++ b/llvm/unittests/Object/DXContainerTest.cpp
@@ -1157,3 +1157,49 @@ TEST(RootSignature, ParseDescriptorTable) {
     ASSERT_EQ(Range.OffsetInDescriptorsFromTableStart, -1);
   }
 }
+
+TEST(RootSignature, ParseStaticSamplers) {
+  {
+    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,
+        0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, 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,
+        0x52, 0x54, 0x53, 0x30, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+        0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
+        0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+        0xa4, 0x70, 0x9d, 0x3f, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x85, 0xeb, 0x91, 0x40, 0x66, 0x66, 0x0e, 0x41,
+        0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 
0x00};
+    DXContainer C =
+        llvm::cantFail(DXContainer::create(getMemoryBuffer<133>(Buffer)));
+
+    auto MaybeRS = C.getRootSignature();
+    ASSERT_TRUE(MaybeRS.has_value());
+    const auto &RS = MaybeRS.value();
+    ASSERT_EQ(RS.getVersion(), 2u);
+    ASSERT_EQ(RS.getNumParameters(), 0u);
+    ASSERT_EQ(RS.getRootParametersOffset(), 0u);
+    ASSERT_EQ(RS.getNumStaticSamplers(), 1u);
+    ASSERT_EQ(RS.getStaticSamplersOffset(), 24u);
+    ASSERT_EQ(RS.getFlags(), 17u);
+
+    auto Sampler = *RS.samplers().begin();
+
+    ASSERT_EQ(Sampler.Filter, 10u);
+    ASSERT_EQ(Sampler.AddressU, 1u);
+    ASSERT_EQ(Sampler.AddressV, 2u);
+    ASSERT_EQ(Sampler.AddressW, 5u);
+    EXPECT_FLOAT_EQ(Sampler.MipLODBias, 1.23);
+    ASSERT_EQ(Sampler.MaxAnisotropy, 20);
+    ASSERT_EQ(Sampler.ComparisonFunc, 4);
+    ASSERT_EQ(Sampler.BorderColor, 0);
+    EXPECT_FLOAT_EQ(Sampler.MinLOD, 4.56);
+    EXPECT_FLOAT_EQ(Sampler.MaxLOD, 8.9);
+    ASSERT_EQ(Sampler.ShaderRegister, 31);
+    ASSERT_EQ(Sampler.RegisterSpace, 32);
+    ASSERT_EQ(Sampler.ShaderVisibility, 7);
+  }
+}
diff --git a/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp 
b/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp
index fa3af7045a4fd..04fe2d4c9f460 100644
--- a/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp
+++ b/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp
@@ -467,3 +467,62 @@ TEST(RootSignature, ParseDescriptorTableV11) {
   EXPECT_EQ(Storage.size(), 133u);
   EXPECT_TRUE(memcmp(Buffer, Storage.data(), 133u) == 0);
 }
+
+TEST(RootSignature, ParseStaticSamplers) {
+  SmallString<128> Storage;
+
+  // First read a fully explicit yaml with all sizes and offsets provided
+  ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer
+Header:
+  Hash:            [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
+                     0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
+  Version:
+    Major:           1
+    Minor:           0
+  PartCount:       1
+  PartOffsets:     [ 60 ]
+Parts:
+  - Name:            RTS0
+    Size:            76
+    RootSignature:
+      Version: 2
+      NumRootParameters: 0
+      RootParametersOffset: 0
+      NumStaticSamplers: 1
+      StaticSamplersOffset: 24
+      Parameters: []
+      Samplers: 
+        - Filter: 10 
+          AddressU: 1
+          AddressV: 2
+          AddressW: 5
+          MipLODBias: 1.23
+          MaxAnisotropy: 20
+          ComparisonFunc: 4
+          BorderColor: 0
+          MinLOD: 4.56
+          MaxLOD: 8.90
+          ShaderRegister: 31 
+          RegisterSpace: 32
+          ShaderVisibility:  7
+      AllowInputAssemblerInputLayout: true
+      DenyGeometryShaderRootAccess: true
+    )"));
+
+  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,
+      0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, 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,
+      0x52, 0x54, 0x53, 0x30, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+      0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
+      0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+      0xa4, 0x70, 0x9d, 0x3f, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+      0x00, 0x00, 0x00, 0x00, 0x85, 0xeb, 0x91, 0x40, 0x66, 0x66, 0x0e, 0x41,
+      0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00};
+
+  EXPECT_EQ(Storage.size(), 144u);
+  EXPECT_TRUE(memcmp(Buffer, Storage.data(), 144u) == 0);
+}

>From f992117f37632fc8d8c7005ce3510ac23a7bb410 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saff...@microsoft.com>
Date: Thu, 29 May 2025 19:16:48 +0000
Subject: [PATCH 4/6] make static samplers value as default in yaml

---
 llvm/include/llvm/BinaryFormat/DXContainer.h  | 20 +++++++
 .../include/llvm/ObjectYAML/DXContainerYAML.h | 23 ++++----
 llvm/lib/ObjectYAML/DXContainerYAML.cpp       | 20 +++----
 ...RootSignature-StaticSamplers-Defaults.yaml | 53 +++++++++++++++++++
 4 files changed, 96 insertions(+), 20 deletions(-)
 create mode 100644 
llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers-Defaults.yaml

diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h 
b/llvm/include/llvm/BinaryFormat/DXContainer.h
index 6d1efb29ce642..d1306c85719aa 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -209,6 +209,26 @@ inline bool isValidShaderVisibility(uint32_t V) {
   return false;
 }
 
+#define STATIC_SAMPLER_FILTER(Val, Enum) Enum = Val,
+enum class StaticSamplerFilter : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+#define TEXTURE_ADDRESS_MODE(Val, Enum) Enum = Val,
+enum class TextureAddressMode : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+#define COMPARISON_FUNCTION(Val, Enum) Enum = Val,
+enum class SamplersComparisonFunction : uint32_t {
+#include "DXContainerConstants.def"
+};
+
+#define STATIC_BORDER_COLOR(Val, Enum) Enum = Val,
+enum class SamplersBorderColor : uint32_t {
+#include "DXContainerConstants.def"
+};
+
 PartType parsePartType(StringRef S);
 
 struct VertexPSVInfo {
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h 
b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index 0f0c4538aba64..a1b50069ad678 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -15,6 +15,7 @@
 #ifndef LLVM_OBJECTYAML_DXCONTAINERYAML_H
 #define LLVM_OBJECTYAML_DXCONTAINERYAML_H
 
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Object/DXContainer.h"
@@ -164,16 +165,18 @@ struct RootParameterYamlDesc {
 };
 
 struct StaticSamplerYamlDesc {
-  uint32_t Filter;
-  uint32_t AddressU;
-  uint32_t AddressV;
-  uint32_t AddressW;
-  float MipLODBias;
-  uint32_t MaxAnisotropy;
-  uint32_t ComparisonFunc;
-  uint32_t BorderColor;
-  float MinLOD;
-  float MaxLOD;
+  uint32_t Filter = 
llvm::to_underlying(dxbc::StaticSamplerFilter::ANISOTROPIC);
+  uint32_t AddressU = llvm::to_underlying(dxbc::TextureAddressMode::Wrap);
+  uint32_t AddressV = llvm::to_underlying(dxbc::TextureAddressMode::Wrap);
+  uint32_t AddressW = llvm::to_underlying(dxbc::TextureAddressMode::Wrap);
+  float MipLODBias = 0.f;
+  uint32_t MaxAnisotropy = 16u;
+  uint32_t ComparisonFunc =
+      llvm::to_underlying(dxbc::SamplersComparisonFunction::LessEqual);
+  uint32_t BorderColor =
+      llvm::to_underlying(dxbc::SamplersBorderColor::OpaqueWhite);
+  float MinLOD = 0.f;
+  float MaxLOD = std::numeric_limits<float>::max();
   uint32_t ShaderRegister;
   uint32_t RegisterSpace;
   uint32_t ShaderVisibility;
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp 
b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index baa73d6e3af0a..3bca25f3fc6c6 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -445,16 +445,16 @@ void 
MappingTraits<llvm::DXContainerYAML::RootDescriptorYaml>::mapping(
 void MappingTraits<llvm::DXContainerYAML::StaticSamplerYamlDesc>::mapping(
     IO &IO, llvm::DXContainerYAML::StaticSamplerYamlDesc &S) {
 
-  IO.mapRequired("Filter", S.Filter);
-  IO.mapRequired("AddressU", S.AddressU);
-  IO.mapRequired("AddressV", S.AddressV);
-  IO.mapRequired("AddressW", S.AddressW);
-  IO.mapRequired("MipLODBias", S.MipLODBias);
-  IO.mapRequired("MaxAnisotropy", S.MaxAnisotropy);
-  IO.mapRequired("ComparisonFunc", S.ComparisonFunc);
-  IO.mapRequired("BorderColor", S.BorderColor);
-  IO.mapRequired("MinLOD", S.MinLOD);
-  IO.mapRequired("MaxLOD", S.MaxLOD);
+  IO.mapOptional("Filter", S.Filter);
+  IO.mapOptional("AddressU", S.AddressU);
+  IO.mapOptional("AddressV", S.AddressV);
+  IO.mapOptional("AddressW", S.AddressW);
+  IO.mapOptional("MipLODBias", S.MipLODBias);
+  IO.mapOptional("MaxAnisotropy", S.MaxAnisotropy);
+  IO.mapOptional("ComparisonFunc", S.ComparisonFunc);
+  IO.mapOptional("BorderColor", S.BorderColor);
+  IO.mapOptional("MinLOD", S.MinLOD);
+  IO.mapOptional("MaxLOD", S.MaxLOD);
   IO.mapRequired("ShaderRegister", S.ShaderRegister);
   IO.mapRequired("RegisterSpace", S.RegisterSpace);
   IO.mapRequired("ShaderVisibility", S.ShaderVisibility);
diff --git 
a/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers-Defaults.yaml 
b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers-Defaults.yaml
new file mode 100644
index 0000000000000..2189753be0b74
--- /dev/null
+++ 
b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers-Defaults.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:       1
+  PartOffsets:     [ 60 ]
+Parts:
+  - Name:            RTS0
+    Size:            76
+    RootSignature:
+      Version: 2
+      NumRootParameters: 0
+      RootParametersOffset: 0
+      NumStaticSamplers: 1
+      StaticSamplersOffset: 24
+      Parameters: []
+      Samplers: 
+        - ShaderRegister: 31 
+          RegisterSpace: 32
+          ShaderVisibility:  7
+      AllowInputAssemblerInputLayout: true
+      DenyGeometryShaderRootAccess: true
+
+#CHECK:  - Name:            RTS0
+#CHECK-NEXT:    Size:            76
+#CHECK-NEXT:    RootSignature:
+#CHECK-NEXT:      Version:         2
+#CHECK-NEXT:      NumRootParameters: 0
+#CHECK-NEXT:      RootParametersOffset: 0
+#CHECK-NEXT:      NumStaticSamplers: 1
+#CHECK-NEXT:      StaticSamplersOffset: 24
+#CHECK-NEXT:      Parameters:      []
+#CHECK-NEXT:      Samplers:
+#CHECK-NEXT:      - Filter:          85
+#CHECK-NEXT:        AddressU:        1
+#CHECK-NEXT:        AddressV:        1
+#CHECK-NEXT:        AddressW:        1
+#CHECK-NEXT:        MipLODBias:      0
+#CHECK-NEXT:        MaxAnisotropy:   16
+#CHECK-NEXT:        ComparisonFunc:  4
+#CHECK-NEXT:        BorderColor:     2
+#CHECK-NEXT:        MinLOD:          0
+#CHECK-NEXT:        MaxLOD:          3.40282e+38
+#CHECK-NEXT:        ShaderRegister:  31
+#CHECK-NEXT:        RegisterSpace:   32
+#CHECK-NEXT:        ShaderVisibility: 7
+#CHECK-NEXT:      AllowInputAssemblerInputLayout: true
+#CHECK-NEXT:      DenyGeometryShaderRootAccess: true

>From 04569bdc3aa59214c14039f28eadf4e5dabdabf6 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saff...@microsoft.com>
Date: Thu, 29 May 2025 19:19:04 +0000
Subject: [PATCH 5/6] clean up

---
 llvm/lib/ObjectYAML/DXContainerYAML.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp 
b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 3bca25f3fc6c6..deb8ece445987 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -12,7 +12,6 @@
 
//===----------------------------------------------------------------------===//
 
 #include "llvm/ObjectYAML/DXContainerYAML.h"
-#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/BinaryFormat/DXContainer.h"
 #include "llvm/Support/Error.h"

>From 774cfd1d8dd4855731a02a4f02d93ab502758b39 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saff...@microsoft.com>
Date: Thu, 29 May 2025 19:20:05 +0000
Subject: [PATCH 6/6] clean up

---
 llvm/lib/MC/DXContainerRootSignature.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp 
b/llvm/lib/MC/DXContainerRootSignature.cpp
index dd1a5416caaa7..6c71823a51f85 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -71,7 +71,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
   BOS.reserveExtraSpace(getSize());
 
   const uint32_t NumParameters = ParametersContainer.size();
-  
+
   support::endian::write(BOS, Version, llvm::endianness::little);
   support::endian::write(BOS, NumParameters, llvm::endianness::little);
   support::endian::write(BOS, RootParameterOffset, llvm::endianness::little);

_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to