[llvm] [DXIL] Add support for root signature flag element in DXContainer (PR #123147)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 16:39:03 PST 2025
https://github.com/joaosaffran created https://github.com/llvm/llvm-project/pull/123147
None
>From 8adb678cbb5effc1a578a41a9490fdbc9e22cd0a Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Mon, 13 Jan 2025 21:57:03 +0000
Subject: [PATCH 01/10] adding rootsignature to obj2yaml
---
llvm/include/llvm/BinaryFormat/DXContainer.h | 9 +++++++
.../BinaryFormat/DXContainerConstants.def | 1 +
llvm/include/llvm/Object/DXContainer.h | 7 +++++
.../include/llvm/ObjectYAML/DXContainerYAML.h | 16 +++++++++++
llvm/lib/Object/DXContainer.cpp | 14 ++++++++++
llvm/lib/ObjectYAML/DXContainerEmitter.cpp | 8 ++++++
llvm/lib/ObjectYAML/DXContainerYAML.cpp | 11 ++++++++
.../RootSignatures/FlagsElement.ll | 27 +++++++++++++++++++
llvm/tools/obj2yaml/dxcontainer2yaml.cpp | 8 ++++++
9 files changed, 101 insertions(+)
create mode 100644 llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll
diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h
index 21e28d546286ee..3907d88df43b07 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -63,6 +63,15 @@ struct ShaderHash {
void swapBytes() { sys::swapByteOrder(Flags); }
};
+struct RootSignatureDesc {
+ uint32_t Version;
+ uint32_t Flags;
+ void swapBytes() {
+ sys::swapByteOrder(Version);
+ sys::swapByteOrder(Flags);
+ }
+};
+
struct ContainerVersion {
uint16_t Major;
uint16_t Minor;
diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
index 1aacbb2f65b27f..38b69228cd3975 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
+++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
@@ -4,6 +4,7 @@ CONTAINER_PART(DXIL)
CONTAINER_PART(SFI0)
CONTAINER_PART(HASH)
CONTAINER_PART(PSV0)
+CONTAINER_PART(RTS0)
CONTAINER_PART(ISG1)
CONTAINER_PART(OSG1)
CONTAINER_PART(PSG1)
diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h
index 19c83ba6c6e85d..9159b9083b6185 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -287,6 +287,7 @@ class DXContainer {
std::optional<uint64_t> ShaderFeatureFlags;
std::optional<dxbc::ShaderHash> Hash;
std::optional<DirectX::PSVRuntimeInfo> PSVInfo;
+ std::optional<dxbc::RootSignatureDesc> RootSignature;
DirectX::Signature InputSignature;
DirectX::Signature OutputSignature;
DirectX::Signature PatchConstantSignature;
@@ -296,6 +297,7 @@ class DXContainer {
Error parseDXILHeader(StringRef Part);
Error parseShaderFeatureFlags(StringRef Part);
Error parseHash(StringRef Part);
+ Error parseRootSignature(StringRef Part);
Error parsePSVInfo(StringRef Part);
Error parseSignature(StringRef Part, DirectX::Signature &Array);
friend class PartIterator;
@@ -382,6 +384,11 @@ class DXContainer {
std::optional<dxbc::ShaderHash> getShaderHash() const { return Hash; }
+ std::optional<dxbc::RootSignatureDesc>
+ getRootSignature() const {
+ return RootSignature;
+ }
+
const std::optional<DirectX::PSVRuntimeInfo> &getPSVInfo() const {
return PSVInfo;
};
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index 66ad057ab0e30f..c4bf6bc4920cf7 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -72,6 +72,16 @@ struct ShaderHash {
std::vector<llvm::yaml::Hex8> Digest;
};
+
+
+struct RootSignatureDesc {
+ RootSignatureDesc() = default;
+ RootSignatureDesc(const dxbc::RootSignatureDesc &Data);
+
+ uint32_t Version;
+ uint32_t Flags;
+};
+
using ResourceFlags = dxbc::PSV::ResourceFlags;
using ResourceBindInfo = dxbc::PSV::v2::ResourceBindInfo;
@@ -159,6 +169,7 @@ struct Part {
std::optional<ShaderHash> Hash;
std::optional<PSVInfo> Info;
std::optional<DXContainerYAML::Signature> Signature;
+ std::optional<DXContainerYAML::RootSignatureDesc> RootSignature;
};
struct Object {
@@ -241,6 +252,11 @@ template <> struct MappingTraits<DXContainerYAML::Signature> {
static void mapping(IO &IO, llvm::DXContainerYAML::Signature &El);
};
+template <> struct MappingTraits<DXContainerYAML::RootSignatureDesc> {
+ static void mapping(IO &IO,
+ DXContainerYAML::RootSignatureDesc &RootSignature);
+};
+
} // namespace yaml
} // namespace llvm
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index 3b1a6203a1f8fc..e6577192a92c74 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -10,6 +10,7 @@
#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Object/Error.h"
#include "llvm/Support/Alignment.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
using namespace llvm;
@@ -92,6 +93,14 @@ Error DXContainer::parseHash(StringRef Part) {
return Error::success();
}
+Error DXContainer::parseRootSignature(StringRef Part) {
+ dxbc::RootSignatureDesc Desc;
+ if (Error Err = readStruct(Part, Part.begin(), Desc))
+ return Err;
+ RootSignature = Desc;
+ return Error::success();
+}
+
Error DXContainer::parsePSVInfo(StringRef Part) {
if (PSVInfo)
return parseFailed("More than one PSV0 part is present in the file");
@@ -192,6 +201,11 @@ Error DXContainer::parsePartOffsets() {
return Err;
break;
case dxbc::PartType::Unknown:
+ break;
+ case dxbc::PartType::RTS0:
+ if (Error Err = parseRootSignature(PartData))
+ return Err;
+
break;
}
}
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index 175f1a12f93145..22ac2b223ea53c 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -261,6 +261,14 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
}
case dxbc::PartType::Unknown:
break; // Skip any handling for unrecognized parts.
+ case dxbc::PartType::RTS0:
+ if (!P.RootSignature.has_value())
+ continue;
+ dxbc::RootSignatureDesc RS = {P.RootSignature->Version, P.RootSignature->Flags};
+ if (sys::IsBigEndianHost)
+ RS.swapBytes();
+ OS.write(reinterpret_cast<char *>(&RS), sizeof(dxbc::RootSignatureDesc));
+ break;
}
uint64_t BytesWritten = OS.tell() - DataStart;
RollingOffset += BytesWritten;
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 5dee1221b27c01..7bfd77acaecfbe 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -45,6 +45,10 @@ DXContainerYAML::ShaderHash::ShaderHash(const dxbc::ShaderHash &Data)
memcpy(Digest.data(), &Data.Digest[0], 16);
}
+DXContainerYAML::RootSignatureDesc::RootSignatureDesc(const dxbc::RootSignatureDesc &Data)
+ : Version(Data.Version), Flags(Data.Flags) {
+}
+
DXContainerYAML::PSVInfo::PSVInfo() : Version(0) {
memset(&Info, 0, sizeof(Info));
}
@@ -188,6 +192,12 @@ void MappingTraits<DXContainerYAML::Signature>::mapping(
IO.mapRequired("Parameters", S.Parameters);
}
+void MappingTraits<DXContainerYAML::RootSignatureDesc>::mapping(
+ IO &IO, DXContainerYAML::RootSignatureDesc &S) {
+ IO.mapRequired("Version", S.Version);
+ IO.mapRequired("Flags", S.Flags);
+}
+
void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
DXContainerYAML::Part &P) {
IO.mapRequired("Name", P.Name);
@@ -197,6 +207,7 @@ void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
IO.mapOptional("Hash", P.Hash);
IO.mapOptional("PSVInfo", P.Info);
IO.mapOptional("Signature", P.Signature);
+ IO.mapOptional("RootSignature", P.RootSignature);
}
void MappingTraits<DXContainerYAML::Object>::mapping(
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll
new file mode 100644
index 00000000000000..402f03a4dd589b
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll
@@ -0,0 +1,27 @@
+; RUN: opt %s -dxil-embed -dxil-globals -S -o - | FileCheck %s
+; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
+
+target triple = "dxil-unknown-shadermodel6.0-compute"
+
+; CHECK: @dx.rts0 = private constant [8 x i8] c"{{.*}}", section "RTS0", align 4
+
+
+define void @main() #0 {
+entry:
+ ret void
+}
+
+attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
+
+
+!dx.rootsignatures = !{!2} ; list of function/root signature pairs
+!2 = !{ ptr @main, !3 } ; function, root signature
+!3 = !{ !4 } ; list of root signature elements
+!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
+
+
+; DXC: - Name: RTS0
+; DXC-NEXT: Size: 8
+; DXC-NEXT: RootSignature:
+; DXC-NEXT: Version: 1.0
+; DXC-NEXT: Flags: AllowInputAssemblerInputLayout
diff --git a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp
index 06966b1883586c..90ee47cd469949 100644
--- a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp
+++ b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp
@@ -7,9 +7,11 @@
//===----------------------------------------------------------------------===//
#include "obj2yaml.h"
+#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Object/DXContainer.h"
#include "llvm/ObjectYAML/DXContainerYAML.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
@@ -153,6 +155,12 @@ dumpDXContainer(MemoryBufferRef Source) {
break;
case dxbc::PartType::Unknown:
break;
+ case dxbc::PartType::RTS0:
+ std::optional<dxbc::RootSignatureDesc> RS = Container.getRootSignature();
+ if (RS && RS.has_value())
+ NewPart.RootSignature = DXContainerYAML::RootSignatureDesc(*RS);
+ break;
+ break;
}
}
>From ba78f21112999d704bef4e0605a51de8f2add813 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Mon, 13 Jan 2025 22:31:14 +0000
Subject: [PATCH 02/10] adding test
---
.../RootSignature-FlagsRootElement.yaml | 242 ++++++++++++++++++
1 file changed, 242 insertions(+)
create mode 100644 llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
new file mode 100644
index 00000000000000..5435c432a073ec
--- /dev/null
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
@@ -0,0 +1,242 @@
+# 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
+ FileSize: 1672
+ PartCount: 7
+ PartOffsets: [ 60, 1496, 1512, 1540, 1556, 1572, 1588 ]
+Parts:
+ - Name: DXIL
+ Size: 1428
+ Program:
+ MajorVersion: 6
+ MinorVersion: 0
+ ShaderK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C5, 0x96, 0x78, 0x49, 0x89, 0x5C, 0x6B ]
+ - Name: ISG1
+ Size: 8
+ Signature:
+ Parameters: []
+ - Name: OSG1
+ Size: 8
+ Signature:
+ Parameters: []
+ - Name: RTS0
+ Size: 8
+ RootSignature:
+ Version: 1
+ Flags: 8
+ - Name: PSV0
+ Size: 76
+ PSVInfo:
+ Version: 3
+ ShaderStage: 5
+ MinimumWaveLaneCount: 0
+ MaximumWaveLaneCount: 4294967295
+ UsesViewID: 0
+ SigInputVectors: 0
+ SigOutputVectors: [ 0, 0, 0, 0 ]
+ NumThreadsX: 1
+ NumThreadsY: 1
+ NumThreadsZ: 1
+ EntryName: main
+ ResourceStride: 24
+ Resources: []
+ SigInputElements: []
+ SigOutputElements: []
+ SigPatchOrPrimElements: []
+ InputOutputMap:
+ - [ ]
+ - [ ]
+ - [ ]
+ - [ ]
+
+# CHECK: - Name: RTS0
+# CHECK-NEXT: Size: 8
+# CHECK-NEXT: RootSignature:
+# CHECK-NEXT: Version: 1
+# CHECK-NEXT: Flags: 8
>From 0a54559969f272f574ca1be557157c8c9f5f1c06 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Mon, 13 Jan 2025 22:35:01 +0000
Subject: [PATCH 03/10] removing old test
---
.../RootSignatures/FlagsElement.ll | 27 -------------------
1 file changed, 27 deletions(-)
delete mode 100644 llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll
deleted file mode 100644
index 402f03a4dd589b..00000000000000
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignatures/FlagsElement.ll
+++ /dev/null
@@ -1,27 +0,0 @@
-; RUN: opt %s -dxil-embed -dxil-globals -S -o - | FileCheck %s
-; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
-
-target triple = "dxil-unknown-shadermodel6.0-compute"
-
-; CHECK: @dx.rts0 = private constant [8 x i8] c"{{.*}}", section "RTS0", align 4
-
-
-define void @main() #0 {
-entry:
- ret void
-}
-
-attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
-
-
-!dx.rootsignatures = !{!2} ; list of function/root signature pairs
-!2 = !{ ptr @main, !3 } ; function, root signature
-!3 = !{ !4 } ; list of root signature elements
-!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
-
-
-; DXC: - Name: RTS0
-; DXC-NEXT: Size: 8
-; DXC-NEXT: RootSignature:
-; DXC-NEXT: Version: 1.0
-; DXC-NEXT: Flags: AllowInputAssemblerInputLayout
>From 557075fd17edfd8bfb40266bd70299cb27ee9632 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Mon, 13 Jan 2025 22:43:27 +0000
Subject: [PATCH 04/10] remove useless includes
---
llvm/lib/Object/DXContainer.cpp | 1 -
llvm/tools/obj2yaml/dxcontainer2yaml.cpp | 2 --
2 files changed, 3 deletions(-)
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index e6577192a92c74..4ffa00f70bdb75 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -10,7 +10,6 @@
#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Object/Error.h"
#include "llvm/Support/Alignment.h"
-#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
using namespace llvm;
diff --git a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp
index 90ee47cd469949..6ae0a0859b48e1 100644
--- a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp
+++ b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp
@@ -7,11 +7,9 @@
//===----------------------------------------------------------------------===//
#include "obj2yaml.h"
-#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Object/DXContainer.h"
#include "llvm/ObjectYAML/DXContainerYAML.h"
#include "llvm/Support/Error.h"
-#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
>From e0d3dcd9d60a9955bb1cb0fd23dbd78bf0deddd3 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Tue, 14 Jan 2025 23:42:24 +0000
Subject: [PATCH 05/10] addressing comments
---
llvm/include/llvm/BinaryFormat/DXContainer.h | 5 +
.../BinaryFormat/DXContainerConstants.def | 19 ++
.../include/llvm/ObjectYAML/DXContainerYAML.h | 5 +-
llvm/lib/Object/DXContainer.cpp | 3 +
llvm/lib/ObjectYAML/DXContainerEmitter.cpp | 5 +-
llvm/lib/ObjectYAML/DXContainerYAML.cpp | 26 +-
.../RootSignature-FlagsRootElement.yaml | 259 ++----------------
7 files changed, 85 insertions(+), 237 deletions(-)
diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h
index 3907d88df43b07..0ada2125119378 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -161,6 +161,11 @@ enum class FeatureFlags : uint64_t {
static_assert((uint64_t)FeatureFlags::NextUnusedBit <= 1ull << 63,
"Shader flag bits exceed enum size.");
+#define ROOT_ELEMENT_FLAG(Num, Val) Val = 1ull << Num,
+enum class RootElementFlag : uint32_t {
+#include "DXContainerConstants.def"
+};
+
PartType parsePartType(StringRef S);
struct VertexPSVInfo {
diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
index 38b69228cd3975..b351b9a01773c8 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
+++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
@@ -53,6 +53,25 @@ SHADER_FEATURE_FLAG(31, 36, NextUnusedBit, "Next reserved shader flag bit (not a
#undef SHADER_FEATURE_FLAG
#endif // SHADER_FEATURE_FLAG
+#ifdef ROOT_ELEMENT_FLAG
+
+
+ROOT_ELEMENT_FLAG(0, AllowInputAssemblerInputLayout)
+ROOT_ELEMENT_FLAG(1, DenyVertexShaderRootAccess)
+ROOT_ELEMENT_FLAG(2, DenyHullShaderRootAccess)
+ROOT_ELEMENT_FLAG(3, DenyDomainShaderRootAccess)
+ROOT_ELEMENT_FLAG(4, DenyGeometryShaderRootAccess)
+ROOT_ELEMENT_FLAG(5, DenyPixelShaderRootAccess)
+ROOT_ELEMENT_FLAG(6, AllowStreamOutput)
+ROOT_ELEMENT_FLAG(7, LocalRootSignature)
+ROOT_ELEMENT_FLAG(8, DenyAmplificationShaderRootAccess)
+ROOT_ELEMENT_FLAG(9, DenyMeshShaderRootAccess)
+ROOT_ELEMENT_FLAG(10, CBVSRVUAVHeapDirectlyIndexed)
+ROOT_ELEMENT_FLAG(11, SamplerHeapDirectlyIndexed)
+#undef ROOT_ELEMENT_FLAG
+#endif // ROOT_ELEMENT_FLAG
+
+
#ifdef DXIL_MODULE_FLAG
// Only save DXIL module flags which not map to feature flags here.
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index c4bf6bc4920cf7..9b25c5c33e7ef8 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -73,13 +73,14 @@ struct ShaderHash {
};
-
+#define ROOT_ELEMENT_FLAG(Num, Val) bool Val = false;
struct RootSignatureDesc {
RootSignatureDesc() = default;
RootSignatureDesc(const dxbc::RootSignatureDesc &Data);
+ uint32_t getEncodedFlags();
uint32_t Version;
- uint32_t Flags;
+#include "llvm/BinaryFormat/DXContainerConstants.def"
};
using ResourceFlags = dxbc::PSV::ResourceFlags;
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index 4ffa00f70bdb75..92956c580f9b23 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -8,6 +8,7 @@
#include "llvm/Object/DXContainer.h"
#include "llvm/BinaryFormat/DXContainer.h"
+#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Object/Error.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/FormatVariadic.h"
@@ -93,6 +94,8 @@ Error DXContainer::parseHash(StringRef Part) {
}
Error DXContainer::parseRootSignature(StringRef Part) {
+ if (RootSignature)
+ return parseFailed("More than one RTS0 part is present in the file");
dxbc::RootSignatureDesc Desc;
if (Error Err = readStruct(Part, Part.begin(), Desc))
return Err;
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index 22ac2b223ea53c..e5561fe44375d7 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -264,7 +264,10 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
case dxbc::PartType::RTS0:
if (!P.RootSignature.has_value())
continue;
- dxbc::RootSignatureDesc RS = {P.RootSignature->Version, P.RootSignature->Flags};
+ uint32_t Flags = P.RootSignature->getEncodedFlags();
+ if (sys::IsBigEndianHost)
+ sys::swapByteOrder(Flags);
+ dxbc::RootSignatureDesc RS = {P.RootSignature->Version, Flags};
if (sys::IsBigEndianHost)
RS.swapBytes();
OS.write(reinterpret_cast<char *>(&RS), sizeof(dxbc::RootSignatureDesc));
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 7bfd77acaecfbe..d226a5b2e5942b 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -15,6 +15,7 @@
#include "llvm/ADT/ScopeExit.h"
#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Support/ScopedPrinter.h"
+#include <cstdint>
namespace llvm {
@@ -29,6 +30,23 @@ DXContainerYAML::ShaderFeatureFlags::ShaderFeatureFlags(uint64_t FlagData) {
#include "llvm/BinaryFormat/DXContainerConstants.def"
}
+
+DXContainerYAML::RootSignatureDesc::RootSignatureDesc(const dxbc::RootSignatureDesc &Data): Version(Data.Version) {
+#define ROOT_ELEMENT_FLAG(Num, Val) \
+ Val = (Data.Flags & (uint32_t)dxbc::RootElementFlag::Val) > 0;
+#include "llvm/BinaryFormat/DXContainerConstants.def"
+}
+
+
+uint32_t DXContainerYAML::RootSignatureDesc::getEncodedFlags() {
+ uint64_t Flag = 0;
+#define ROOT_ELEMENT_FLAG(Num, Val) \
+ if (Val) \
+ Flag |= (uint32_t)dxbc::RootElementFlag::Val;
+#include "llvm/BinaryFormat/DXContainerConstants.def"
+ return Flag;
+}
+
uint64_t DXContainerYAML::ShaderFeatureFlags::getEncodedFlags() {
uint64_t Flag = 0;
#define SHADER_FEATURE_FLAG(Num, DxilModuleNum, Val, Str) \
@@ -45,10 +63,6 @@ DXContainerYAML::ShaderHash::ShaderHash(const dxbc::ShaderHash &Data)
memcpy(Digest.data(), &Data.Digest[0], 16);
}
-DXContainerYAML::RootSignatureDesc::RootSignatureDesc(const dxbc::RootSignatureDesc &Data)
- : Version(Data.Version), Flags(Data.Flags) {
-}
-
DXContainerYAML::PSVInfo::PSVInfo() : Version(0) {
memset(&Info, 0, sizeof(Info));
}
@@ -195,7 +209,9 @@ void MappingTraits<DXContainerYAML::Signature>::mapping(
void MappingTraits<DXContainerYAML::RootSignatureDesc>::mapping(
IO &IO, DXContainerYAML::RootSignatureDesc &S) {
IO.mapRequired("Version", S.Version);
- IO.mapRequired("Flags", S.Flags);
+ #define ROOT_ELEMENT_FLAG(Num, Val) \
+ IO.mapRequired(#Val, S.Val);
+ #include "llvm/BinaryFormat/DXContainerConstants.def"
}
void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
index 5435c432a073ec..2ed71091cacd45 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
@@ -6,237 +6,38 @@ Header:
Version:
Major: 1
Minor: 0
- FileSize: 1672
- PartCount: 7
- PartOffsets: [ 60, 1496, 1512, 1540, 1556, 1572, 1588 ]
+ PartCount: 1
+ PartOffsets: [ 60 ]
Parts:
- - Name: DXIL
- Size: 1428
- Program:
- MajorVersion: 6
- MinorVersion: 0
- ShaderKind: 5
- Size: 357
- DXILMajorVersion: 1
- DXILMinorVersion: 0
- DXILSize: 1404
- DXIL: [ 0x42, 0x43, 0xC0, 0xDE, 0x21, 0xC, 0x0, 0x0, 0x5C,
- 0x1, 0x0, 0x0, 0xB, 0x82, 0x20, 0x0, 0x2, 0x0,
- 0x0, 0x0, 0x13, 0x0, 0x0, 0x0, 0x7, 0x81, 0x23,
- 0x91, 0x41, 0xC8, 0x4, 0x49, 0x6, 0x10, 0x32,
- 0x39, 0x92, 0x1, 0x84, 0xC, 0x25, 0x5, 0x8, 0x19,
- 0x1E, 0x4, 0x8B, 0x62, 0x80, 0x10, 0x45, 0x2,
- 0x42, 0x92, 0xB, 0x42, 0x84, 0x10, 0x32, 0x14,
- 0x38, 0x8, 0x18, 0x4B, 0xA, 0x32, 0x42, 0x88,
- 0x48, 0x90, 0x14, 0x20, 0x43, 0x46, 0x88, 0xA5,
- 0x0, 0x19, 0x32, 0x42, 0xE4, 0x48, 0xE, 0x90,
- 0x11, 0x22, 0xC4, 0x50, 0x41, 0x51, 0x81, 0x8C,
- 0xE1, 0x83, 0xE5, 0x8A, 0x4, 0x21, 0x46, 0x6,
- 0x89, 0x20, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x32,
- 0x22, 0x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x50, 0x10, 0xCD, 0x14, 0x61, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
- - Name: SFI0
- Size: 8
- - Name: HASH
- Size: 20
- Hash:
- IncludesSource: false
- Digest: [ 0xCE, 0xA, 0x5B, 0x9C, 0xBF, 0x9A, 0xBB, 0x5,
- 0x19, 0xC5, 0x96, 0x78, 0x49, 0x89, 0x5C, 0x6B ]
- - Name: ISG1
- Size: 8
- Signature:
- Parameters: []
- - Name: OSG1
- Size: 8
- Signature:
- Parameters: []
- Name: RTS0
Size: 8
RootSignature:
Version: 1
- Flags: 8
- - Name: PSV0
- Size: 76
- PSVInfo:
- Version: 3
- ShaderStage: 5
- MinimumWaveLaneCount: 0
- MaximumWaveLaneCount: 4294967295
- UsesViewID: 0
- SigInputVectors: 0
- SigOutputVectors: [ 0, 0, 0, 0 ]
- NumThreadsX: 1
- NumThreadsY: 1
- NumThreadsZ: 1
- EntryName: main
- ResourceStride: 24
- Resources: []
- SigInputElements: []
- SigOutputElements: []
- SigPatchOrPrimElements: []
- InputOutputMap:
- - [ ]
- - [ ]
- - [ ]
- - [ ]
-
-# CHECK: - Name: RTS0
-# CHECK-NEXT: Size: 8
-# CHECK-NEXT: RootSignature:
-# CHECK-NEXT: Version: 1
-# CHECK-NEXT: Flags: 8
+ AllowInputAssemblerInputLayout: true
+ DenyVertexShaderRootAccess: false
+ DenyHullShaderRootAccess: false
+ DenyDomainShaderRootAccess: false
+ DenyGeometryShaderRootAccess: false
+ DenyPixelShaderRootAccess: false
+ AllowStreamOutput: false
+ LocalRootSignature: false
+ DenyAmplificationShaderRootAccess: false
+ DenyMeshShaderRootAccess: false
+ CBVSRVUAVHeapDirectlyIndexed: false
+ SamplerHeapDirectlyIndexed: false
+#CHECK: - Name: RTS0
+#CHECK-NEXT: Size: 8
+#CHECK-NEXT: RootSignature:
+#CHECK-NEXT: Version: 1
+#CHECK-NEXT: AllowInputAssemblerInputLayout: true
+#CHECK-NEXT: DenyVertexShaderRootAccess: false
+#CHECK-NEXT: DenyHullShaderRootAccess: false
+#CHECK-NEXT: DenyDomainShaderRootAccess: false
+#CHECK-NEXT: DenyGeometryShaderRootAccess: false
+#CHECK-NEXT: DenyPixelShaderRootAccess: false
+#CHECK-NEXT: AllowStreamOutput: false
+#CHECK-NEXT: LocalRootSignature: false
+#CHECK-NEXT: DenyAmplificationShaderRootAccess: false
+#CHECK-NEXT: DenyMeshShaderRootAccess: false
+#CHECK-NEXT: CBVSRVUAVHeapDirectlyIndexed: false
+#CHECK-NEXT: SamplerHeapDirectlyIndexed: false
>From 80587ddd3736472bfd3e089db35880762a2035b7 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Tue, 14 Jan 2025 23:47:46 +0000
Subject: [PATCH 06/10] updating test
---
.../ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
index 2ed71091cacd45..8ce18d8e1aa4cb 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-FlagsRootElement.yaml
@@ -25,6 +25,7 @@ Parts:
DenyMeshShaderRootAccess: false
CBVSRVUAVHeapDirectlyIndexed: false
SamplerHeapDirectlyIndexed: false
+
#CHECK: - Name: RTS0
#CHECK-NEXT: Size: 8
#CHECK-NEXT: RootSignature:
>From be3764d8748cf55c781cd3b98a5f616c9a09e5f0 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Wed, 15 Jan 2025 00:42:39 +0000
Subject: [PATCH 07/10] removing useless header
---
llvm/lib/Object/DXContainer.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index 92956c580f9b23..b7eff25ed7b33b 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -8,7 +8,6 @@
#include "llvm/Object/DXContainer.h"
#include "llvm/BinaryFormat/DXContainer.h"
-#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Object/Error.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/FormatVariadic.h"
>From 2b7284179f6e4aef5a5104752e6e8de3fca732c5 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Wed, 15 Jan 2025 17:30:00 +0000
Subject: [PATCH 08/10] adding metadata extraction
---
.../llvm/Analysis/DXILMetadataAnalysis.h | 3 +
llvm/include/llvm/BinaryFormat/DXContainer.h | 4 +-
.../llvm/MC/DXContainerRootSignature.h | 74 +++++++++++++++
llvm/include/llvm/Object/DXContainer.h | 3 +-
.../include/llvm/ObjectYAML/DXContainerYAML.h | 1 -
llvm/lib/Analysis/DXILMetadataAnalysis.cpp | 89 +++++++++++++++++++
llvm/lib/MC/CMakeLists.txt | 1 +
llvm/lib/MC/DXContainerRootSignature.cpp | 36 ++++++++
llvm/lib/ObjectYAML/DXContainerEmitter.cpp | 2 +-
llvm/lib/ObjectYAML/DXContainerYAML.cpp | 15 ++--
.../lib/Target/DirectX/DXContainerGlobals.cpp | 24 +++++
11 files changed, 238 insertions(+), 14 deletions(-)
create mode 100644 llvm/include/llvm/MC/DXContainerRootSignature.h
create mode 100644 llvm/lib/MC/DXContainerRootSignature.cpp
diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index cb535ac14f1c61..f420244ba111a4 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -11,9 +11,11 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Pass.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/TargetParser/Triple.h"
+#include <optional>
namespace llvm {
@@ -37,6 +39,7 @@ struct ModuleMetadataInfo {
Triple::EnvironmentType ShaderProfile{Triple::UnknownEnvironment};
VersionTuple ValidatorVersion{};
SmallVector<EntryProperties> EntryPropertyVec{};
+ std::optional<mcdxbc::RootSignatureDesc> RootSignatureDesc;
void print(raw_ostream &OS) const;
};
diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h
index 0ada2125119378..74003387a249ef 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -66,9 +66,9 @@ struct ShaderHash {
struct RootSignatureDesc {
uint32_t Version;
uint32_t Flags;
- void swapBytes() {
+ void swapBytes() {
sys::swapByteOrder(Version);
- sys::swapByteOrder(Flags);
+ sys::swapByteOrder(Flags);
}
};
diff --git a/llvm/include/llvm/MC/DXContainerRootSignature.h b/llvm/include/llvm/MC/DXContainerRootSignature.h
new file mode 100644
index 00000000000000..e5abbf3009464e
--- /dev/null
+++ b/llvm/include/llvm/MC/DXContainerRootSignature.h
@@ -0,0 +1,74 @@
+//===- DXILRootSignature.h - DXIL Root Signature helper objects -----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file contains helper objects for working with DXIL Root
+/// Signatures.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DIRECTX_HLSLROOTSIGNATURE_H
+#define LLVM_DIRECTX_HLSLROOTSIGNATURE_H
+
+#include "llvm/IR/Metadata.h"
+#include <memory>
+
+namespace llvm {
+namespace mcdxbc {
+
+enum class RootSignatureElementKind {
+ None = 0,
+ RootFlags = 1,
+ RootConstants = 2,
+ RootDescriptor = 3,
+ DescriptorTable = 4,
+ StaticSampler = 5
+};
+
+enum RootSignatureFlags : uint32_t {
+ None = 0,
+ AllowInputAssemblerInputLayout = 0x1,
+ DenyVertexShaderRootAccess = 0x2,
+ DenyHullShaderRootAccess = 0x4,
+ DenyDomainShaderRootAccess = 0x8,
+ DenyGeometryShaderRootAccess = 0x10,
+ DenyPixelShaderRootAccess = 0x20,
+ AllowStreamOutput = 0x40,
+ LocalRootSignature = 0x80,
+ DenyAmplificationShaderRootAccess = 0x100,
+ DenyMeshShaderRootAccess = 0x200,
+ CBVSRVUAVHeapDirectlyIndexed = 0x400,
+ SamplerHeapDirectlyIndexed = 0x800,
+ AllowLowTierReservedHwCbLimit = 0x80000000,
+ ValidFlags = 0x80000fff
+};
+
+struct RootSignatureDesc {
+ uint32_t Version;
+ RootSignatureFlags Flags;
+
+ void swapBytes() {
+ sys::swapByteOrder(Version);
+ sys::swapByteOrder(Flags);
+ }
+};
+
+class RootSignatureDescWriter {
+private:
+ RootSignatureDesc *Desc;
+
+public:
+ RootSignatureDescWriter(RootSignatureDesc *Desc) : Desc(Desc) {}
+
+ void write(raw_ostream &OS,
+ uint32_t Version = std::numeric_limits<uint32_t>::max());
+};
+
+} // namespace mcdxbc
+} // namespace llvm
+
+#endif // LLVM_DIRECTX_HLSLROOTSIGNATURE_H
diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h
index 9159b9083b6185..8574a04027ce46 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -384,8 +384,7 @@ class DXContainer {
std::optional<dxbc::ShaderHash> getShaderHash() const { return Hash; }
- std::optional<dxbc::RootSignatureDesc>
- getRootSignature() const {
+ std::optional<dxbc::RootSignatureDesc> getRootSignature() const {
return RootSignature;
}
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index 9b25c5c33e7ef8..bb232543cd3b07 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -72,7 +72,6 @@ struct ShaderHash {
std::vector<llvm::yaml::Hex8> Digest;
};
-
#define ROOT_ELEMENT_FLAG(Num, Val) bool Val = false;
struct RootSignatureDesc {
RootSignatureDesc() = default;
diff --git a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
index a7f666a3f8b48f..388e3853008eae 100644
--- a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
+++ b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
@@ -15,12 +15,91 @@
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
+#include "llvm/MC/DXContainerRootSignature.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
+#include <memory>
#define DEBUG_TYPE "dxil-metadata-analysis"
using namespace llvm;
using namespace dxil;
+using namespace llvm::mcdxbc;
+
+static bool parseRootFlags(MDNode *RootFlagNode, RootSignatureDesc *Desc) {
+
+ assert(RootFlagNode->getNumOperands() == 2 &&
+ "Invalid format for RootFlag Element");
+ auto *Flag = mdconst::extract<ConstantInt>(RootFlagNode->getOperand(1));
+ auto Value = (RootSignatureFlags)Flag->getZExtValue();
+
+ if ((Value & ~RootSignatureFlags::ValidFlags) != RootSignatureFlags::None)
+ return true;
+
+ Desc->Flags = Value;
+ return false;
+}
+
+static bool parseRootSignatureElement(MDNode *Element,
+ RootSignatureDesc *Desc) {
+ MDString *ElementText = cast<MDString>(Element->getOperand(0));
+
+ assert(ElementText != nullptr && "First preoperty of element is not ");
+
+ RootSignatureElementKind ElementKind =
+ StringSwitch<RootSignatureElementKind>(ElementText->getString())
+ .Case("RootFlags", RootSignatureElementKind::RootFlags)
+ .Case("RootConstants", RootSignatureElementKind::RootConstants)
+ .Case("RootCBV", RootSignatureElementKind::RootDescriptor)
+ .Case("RootSRV", RootSignatureElementKind::RootDescriptor)
+ .Case("RootUAV", RootSignatureElementKind::RootDescriptor)
+ .Case("Sampler", RootSignatureElementKind::RootDescriptor)
+ .Case("DescriptorTable", RootSignatureElementKind::DescriptorTable)
+ .Case("StaticSampler", RootSignatureElementKind::StaticSampler)
+ .Default(RootSignatureElementKind::None);
+
+ switch (ElementKind) {
+
+ case RootSignatureElementKind::RootFlags: {
+ return parseRootFlags(Element, Desc);
+ break;
+ }
+
+ case RootSignatureElementKind::RootConstants:
+ case RootSignatureElementKind::RootDescriptor:
+ case RootSignatureElementKind::DescriptorTable:
+ case RootSignatureElementKind::StaticSampler:
+ case RootSignatureElementKind::None:
+ llvm_unreachable("Not Implemented yet");
+ break;
+ }
+
+ return true;
+}
+
+bool parseRootSignature(RootSignatureDesc *Desc, int32_t Version,
+ NamedMDNode *Root) {
+ Desc->Version = Version;
+ bool HasError = false;
+
+ for (unsigned int Sid = 0; Sid < Root->getNumOperands(); Sid++) {
+ // This should be an if, for error handling
+ MDNode *Node = cast<MDNode>(Root->getOperand(Sid));
+
+ // Not sure what use this for...
+ Metadata *Func = Node->getOperand(0).get();
+
+ // This should be an if, for error handling
+ MDNode *Elements = cast<MDNode>(Node->getOperand(1).get());
+
+ for (unsigned int Eid = 0; Eid < Elements->getNumOperands(); Eid++) {
+ MDNode *Element = cast<MDNode>(Elements->getOperand(Eid));
+
+ HasError = HasError || parseRootSignatureElement(Element, Desc);
+ }
+ }
+ return HasError;
+}
static ModuleMetadataInfo collectMetadataInfo(Module &M) {
ModuleMetadataInfo MMDAI;
@@ -28,6 +107,7 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
MMDAI.DXILVersion = TT.getDXILVersion();
MMDAI.ShaderModelVersion = TT.getOSVersion();
MMDAI.ShaderProfile = TT.getEnvironment();
+
NamedMDNode *ValidatorVerNode = M.getNamedMetadata("dx.valver");
if (ValidatorVerNode) {
auto *ValVerMD = cast<MDNode>(ValidatorVerNode->getOperand(0));
@@ -37,6 +117,15 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
VersionTuple(MajorMD->getZExtValue(), MinorMD->getZExtValue());
}
+ NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
+ if (RootSignatureNode) {
+ mcdxbc::RootSignatureDesc Desc;
+
+ parseRootSignature(&Desc, 1, RootSignatureNode);
+
+ MMDAI.RootSignatureDesc = Desc;
+ }
+
// For all HLSL Shader functions
for (auto &F : M.functions()) {
if (!F.hasFnAttribute("hlsl.shader"))
diff --git a/llvm/lib/MC/CMakeLists.txt b/llvm/lib/MC/CMakeLists.txt
index e1d19196c8766a..f49f14c848b902 100644
--- a/llvm/lib/MC/CMakeLists.txt
+++ b/llvm/lib/MC/CMakeLists.txt
@@ -1,6 +1,7 @@
add_llvm_component_library(LLVMMC
ConstantPools.cpp
DXContainerPSVInfo.cpp
+ DXContainerRootSignature.cpp
ELFObjectWriter.cpp
GOFFObjectWriter.cpp
MCAsmBackend.cpp
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp b/llvm/lib/MC/DXContainerRootSignature.cpp
new file mode 100644
index 00000000000000..120f0f63c196f6
--- /dev/null
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -0,0 +1,36 @@
+//===- DXContainerRootSignature.cpp - DXIL Root Signature helper objects
+//-----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file contains the parsing logic to extract root signature data
+/// from LLVM IR metadata.
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/MC/DXContainerRootSignature.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/BinaryFormat/DXContainer.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Metadata.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/SwapByteOrder.h"
+#include <cassert>
+#include <cstdint>
+
+using namespace llvm;
+using namespace llvm::mcdxbc;
+
+void RootSignatureDescWriter::write(raw_ostream &OS, uint32_t Version) {
+ dxbc::RootSignatureDesc Out{Desc->Version, Desc->Flags};
+
+ if (sys::IsBigEndianHost) {
+ Out.swapBytes();
+ }
+
+ OS.write(reinterpret_cast<const char *>(&Out), sizeof(RootSignatureDesc));
+}
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index e5561fe44375d7..3ac539c8e0853c 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -267,7 +267,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
uint32_t Flags = P.RootSignature->getEncodedFlags();
if (sys::IsBigEndianHost)
sys::swapByteOrder(Flags);
- dxbc::RootSignatureDesc RS = {P.RootSignature->Version, Flags};
+ dxbc::RootSignatureDesc RS = {P.RootSignature->Version, Flags};
if (sys::IsBigEndianHost)
RS.swapBytes();
OS.write(reinterpret_cast<char *>(&RS), sizeof(dxbc::RootSignatureDesc));
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index d226a5b2e5942b..80f4587a06ff5e 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -30,17 +30,17 @@ DXContainerYAML::ShaderFeatureFlags::ShaderFeatureFlags(uint64_t FlagData) {
#include "llvm/BinaryFormat/DXContainerConstants.def"
}
-
-DXContainerYAML::RootSignatureDesc::RootSignatureDesc(const dxbc::RootSignatureDesc &Data): Version(Data.Version) {
-#define ROOT_ELEMENT_FLAG(Num, Val) \
+DXContainerYAML::RootSignatureDesc::RootSignatureDesc(
+ const dxbc::RootSignatureDesc &Data)
+ : Version(Data.Version) {
+#define ROOT_ELEMENT_FLAG(Num, Val) \
Val = (Data.Flags & (uint32_t)dxbc::RootElementFlag::Val) > 0;
#include "llvm/BinaryFormat/DXContainerConstants.def"
}
-
uint32_t DXContainerYAML::RootSignatureDesc::getEncodedFlags() {
uint64_t Flag = 0;
-#define ROOT_ELEMENT_FLAG(Num, Val) \
+#define ROOT_ELEMENT_FLAG(Num, Val) \
if (Val) \
Flag |= (uint32_t)dxbc::RootElementFlag::Val;
#include "llvm/BinaryFormat/DXContainerConstants.def"
@@ -209,9 +209,8 @@ void MappingTraits<DXContainerYAML::Signature>::mapping(
void MappingTraits<DXContainerYAML::RootSignatureDesc>::mapping(
IO &IO, DXContainerYAML::RootSignatureDesc &S) {
IO.mapRequired("Version", S.Version);
- #define ROOT_ELEMENT_FLAG(Num, Val) \
- IO.mapRequired(#Val, S.Val);
- #include "llvm/BinaryFormat/DXContainerConstants.def"
+#define ROOT_ELEMENT_FLAG(Num, Val) IO.mapRequired(#Val, S.Val);
+#include "llvm/BinaryFormat/DXContainerConstants.def"
}
void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO,
diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index 7a0bd6a7c88692..7ab11ce757e436 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
@@ -23,9 +23,11 @@
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/MC/DXContainerPSVInfo.h"
+#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Pass.h"
#include "llvm/Support/MD5.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
+#include <optional>
using namespace llvm;
using namespace llvm::dxil;
@@ -41,6 +43,7 @@ class DXContainerGlobals : public llvm::ModulePass {
GlobalVariable *buildSignature(Module &M, Signature &Sig, StringRef Name,
StringRef SectionName);
void addSignature(Module &M, SmallVector<GlobalValue *> &Globals);
+ void addRootSignature(Module &M, SmallVector<GlobalValue *> &Globals);
void addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV);
void addPipelineStateValidationInfo(Module &M,
SmallVector<GlobalValue *> &Globals);
@@ -73,6 +76,7 @@ bool DXContainerGlobals::runOnModule(Module &M) {
Globals.push_back(getFeatureFlags(M));
Globals.push_back(computeShaderHash(M));
addSignature(M, Globals);
+ addRootSignature(M, Globals);
addPipelineStateValidationInfo(M, Globals);
appendToCompilerUsed(M, Globals);
return true;
@@ -144,6 +148,26 @@ void DXContainerGlobals::addSignature(Module &M,
Globals.emplace_back(buildSignature(M, OutputSig, "dx.osg1", "OSG1"));
}
+void DXContainerGlobals::addRootSignature(Module &M,
+ SmallVector<GlobalValue *> &Globals) {
+
+ std::optional<RootSignatureDesc> Desc =
+ getAnalysis<DXILMetadataAnalysisWrapperPass>()
+ .getModuleMetadata()
+ .RootSignatureDesc;
+ if (!Desc.has_value())
+ return;
+
+ SmallString<256> Data;
+ raw_svector_ostream OS(Data);
+ RootSignatureDescWriter writer(&Desc.value());
+ writer.write(OS);
+
+ Constant *Constant =
+ ConstantDataArray::getString(M.getContext(), Data, /*AddNull*/ false);
+ Globals.emplace_back(buildContainerGlobal(M, Constant, "dx.rts0", "RTS0"));
+}
+
void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
const DXILBindingMap &DBM =
getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
>From 5360947ee4f504fa89b128aac2a280517fc75c87 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Thu, 16 Jan 2025 00:36:11 +0000
Subject: [PATCH 09/10] moving root signature to it's own pass
---
.../llvm/Analysis/DXILMetadataAnalysis.h | 2 -
.../llvm/MC/DXContainerRootSignature.h | 74 ---------
llvm/lib/Analysis/DXILMetadataAnalysis.cpp | 84 ----------
llvm/lib/MC/CMakeLists.txt | 1 -
llvm/lib/MC/DXContainerRootSignature.cpp | 36 -----
llvm/lib/Target/DirectX/CMakeLists.txt | 2 +-
.../lib/Target/DirectX/DXContainerGlobals.cpp | 15 +-
llvm/lib/Target/DirectX/DXILRootSignature.cpp | 146 ++++++++++++++++++
llvm/lib/Target/DirectX/DXILRootSignature.h | 75 +++++++++
llvm/lib/Target/DirectX/DirectX.h | 3 +
.../Target/DirectX/DirectXTargetMachine.cpp | 1 +
.../ContainerData/RootSignature-Flags.ll | 38 +++++
12 files changed, 271 insertions(+), 206 deletions(-)
delete mode 100644 llvm/include/llvm/MC/DXContainerRootSignature.h
delete mode 100644 llvm/lib/MC/DXContainerRootSignature.cpp
create mode 100644 llvm/lib/Target/DirectX/DXILRootSignature.cpp
create mode 100644 llvm/lib/Target/DirectX/DXILRootSignature.h
create mode 100644 llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll
diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index f420244ba111a4..dcc3237f57802f 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -11,7 +11,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/PassManager.h"
-#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Pass.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/TargetParser/Triple.h"
@@ -39,7 +38,6 @@ struct ModuleMetadataInfo {
Triple::EnvironmentType ShaderProfile{Triple::UnknownEnvironment};
VersionTuple ValidatorVersion{};
SmallVector<EntryProperties> EntryPropertyVec{};
- std::optional<mcdxbc::RootSignatureDesc> RootSignatureDesc;
void print(raw_ostream &OS) const;
};
diff --git a/llvm/include/llvm/MC/DXContainerRootSignature.h b/llvm/include/llvm/MC/DXContainerRootSignature.h
deleted file mode 100644
index e5abbf3009464e..00000000000000
--- a/llvm/include/llvm/MC/DXContainerRootSignature.h
+++ /dev/null
@@ -1,74 +0,0 @@
-//===- DXILRootSignature.h - DXIL Root Signature helper objects -----------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file This file contains helper objects for working with DXIL Root
-/// Signatures.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DIRECTX_HLSLROOTSIGNATURE_H
-#define LLVM_DIRECTX_HLSLROOTSIGNATURE_H
-
-#include "llvm/IR/Metadata.h"
-#include <memory>
-
-namespace llvm {
-namespace mcdxbc {
-
-enum class RootSignatureElementKind {
- None = 0,
- RootFlags = 1,
- RootConstants = 2,
- RootDescriptor = 3,
- DescriptorTable = 4,
- StaticSampler = 5
-};
-
-enum RootSignatureFlags : uint32_t {
- None = 0,
- AllowInputAssemblerInputLayout = 0x1,
- DenyVertexShaderRootAccess = 0x2,
- DenyHullShaderRootAccess = 0x4,
- DenyDomainShaderRootAccess = 0x8,
- DenyGeometryShaderRootAccess = 0x10,
- DenyPixelShaderRootAccess = 0x20,
- AllowStreamOutput = 0x40,
- LocalRootSignature = 0x80,
- DenyAmplificationShaderRootAccess = 0x100,
- DenyMeshShaderRootAccess = 0x200,
- CBVSRVUAVHeapDirectlyIndexed = 0x400,
- SamplerHeapDirectlyIndexed = 0x800,
- AllowLowTierReservedHwCbLimit = 0x80000000,
- ValidFlags = 0x80000fff
-};
-
-struct RootSignatureDesc {
- uint32_t Version;
- RootSignatureFlags Flags;
-
- void swapBytes() {
- sys::swapByteOrder(Version);
- sys::swapByteOrder(Flags);
- }
-};
-
-class RootSignatureDescWriter {
-private:
- RootSignatureDesc *Desc;
-
-public:
- RootSignatureDescWriter(RootSignatureDesc *Desc) : Desc(Desc) {}
-
- void write(raw_ostream &OS,
- uint32_t Version = std::numeric_limits<uint32_t>::max());
-};
-
-} // namespace mcdxbc
-} // namespace llvm
-
-#endif // LLVM_DIRECTX_HLSLROOTSIGNATURE_H
diff --git a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
index 388e3853008eae..15e72bf17515b1 100644
--- a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
+++ b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
@@ -15,7 +15,6 @@
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
-#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include <memory>
@@ -24,82 +23,8 @@
using namespace llvm;
using namespace dxil;
-using namespace llvm::mcdxbc;
-static bool parseRootFlags(MDNode *RootFlagNode, RootSignatureDesc *Desc) {
- assert(RootFlagNode->getNumOperands() == 2 &&
- "Invalid format for RootFlag Element");
- auto *Flag = mdconst::extract<ConstantInt>(RootFlagNode->getOperand(1));
- auto Value = (RootSignatureFlags)Flag->getZExtValue();
-
- if ((Value & ~RootSignatureFlags::ValidFlags) != RootSignatureFlags::None)
- return true;
-
- Desc->Flags = Value;
- return false;
-}
-
-static bool parseRootSignatureElement(MDNode *Element,
- RootSignatureDesc *Desc) {
- MDString *ElementText = cast<MDString>(Element->getOperand(0));
-
- assert(ElementText != nullptr && "First preoperty of element is not ");
-
- RootSignatureElementKind ElementKind =
- StringSwitch<RootSignatureElementKind>(ElementText->getString())
- .Case("RootFlags", RootSignatureElementKind::RootFlags)
- .Case("RootConstants", RootSignatureElementKind::RootConstants)
- .Case("RootCBV", RootSignatureElementKind::RootDescriptor)
- .Case("RootSRV", RootSignatureElementKind::RootDescriptor)
- .Case("RootUAV", RootSignatureElementKind::RootDescriptor)
- .Case("Sampler", RootSignatureElementKind::RootDescriptor)
- .Case("DescriptorTable", RootSignatureElementKind::DescriptorTable)
- .Case("StaticSampler", RootSignatureElementKind::StaticSampler)
- .Default(RootSignatureElementKind::None);
-
- switch (ElementKind) {
-
- case RootSignatureElementKind::RootFlags: {
- return parseRootFlags(Element, Desc);
- break;
- }
-
- case RootSignatureElementKind::RootConstants:
- case RootSignatureElementKind::RootDescriptor:
- case RootSignatureElementKind::DescriptorTable:
- case RootSignatureElementKind::StaticSampler:
- case RootSignatureElementKind::None:
- llvm_unreachable("Not Implemented yet");
- break;
- }
-
- return true;
-}
-
-bool parseRootSignature(RootSignatureDesc *Desc, int32_t Version,
- NamedMDNode *Root) {
- Desc->Version = Version;
- bool HasError = false;
-
- for (unsigned int Sid = 0; Sid < Root->getNumOperands(); Sid++) {
- // This should be an if, for error handling
- MDNode *Node = cast<MDNode>(Root->getOperand(Sid));
-
- // Not sure what use this for...
- Metadata *Func = Node->getOperand(0).get();
-
- // This should be an if, for error handling
- MDNode *Elements = cast<MDNode>(Node->getOperand(1).get());
-
- for (unsigned int Eid = 0; Eid < Elements->getNumOperands(); Eid++) {
- MDNode *Element = cast<MDNode>(Elements->getOperand(Eid));
-
- HasError = HasError || parseRootSignatureElement(Element, Desc);
- }
- }
- return HasError;
-}
static ModuleMetadataInfo collectMetadataInfo(Module &M) {
ModuleMetadataInfo MMDAI;
@@ -117,15 +42,6 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) {
VersionTuple(MajorMD->getZExtValue(), MinorMD->getZExtValue());
}
- NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
- if (RootSignatureNode) {
- mcdxbc::RootSignatureDesc Desc;
-
- parseRootSignature(&Desc, 1, RootSignatureNode);
-
- MMDAI.RootSignatureDesc = Desc;
- }
-
// For all HLSL Shader functions
for (auto &F : M.functions()) {
if (!F.hasFnAttribute("hlsl.shader"))
diff --git a/llvm/lib/MC/CMakeLists.txt b/llvm/lib/MC/CMakeLists.txt
index f49f14c848b902..e1d19196c8766a 100644
--- a/llvm/lib/MC/CMakeLists.txt
+++ b/llvm/lib/MC/CMakeLists.txt
@@ -1,7 +1,6 @@
add_llvm_component_library(LLVMMC
ConstantPools.cpp
DXContainerPSVInfo.cpp
- DXContainerRootSignature.cpp
ELFObjectWriter.cpp
GOFFObjectWriter.cpp
MCAsmBackend.cpp
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp b/llvm/lib/MC/DXContainerRootSignature.cpp
deleted file mode 100644
index 120f0f63c196f6..00000000000000
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-//===- DXContainerRootSignature.cpp - DXIL Root Signature helper objects
-//-----------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file This file contains the parsing logic to extract root signature data
-/// from LLVM IR metadata.
-///
-//===----------------------------------------------------------------------===//
-
-#include "llvm/MC/DXContainerRootSignature.h"
-#include "llvm/ADT/StringSwitch.h"
-#include "llvm/BinaryFormat/DXContainer.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/IR/Metadata.h"
-#include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/SwapByteOrder.h"
-#include <cassert>
-#include <cstdint>
-
-using namespace llvm;
-using namespace llvm::mcdxbc;
-
-void RootSignatureDescWriter::write(raw_ostream &OS, uint32_t Version) {
- dxbc::RootSignatureDesc Out{Desc->Version, Desc->Flags};
-
- if (sys::IsBigEndianHost) {
- Out.swapBytes();
- }
-
- OS.write(reinterpret_cast<const char *>(&Out), sizeof(RootSignatureDesc));
-}
diff --git a/llvm/lib/Target/DirectX/CMakeLists.txt b/llvm/lib/Target/DirectX/CMakeLists.txt
index 26315db891b577..89fe494dea71cc 100644
--- a/llvm/lib/Target/DirectX/CMakeLists.txt
+++ b/llvm/lib/Target/DirectX/CMakeLists.txt
@@ -33,7 +33,7 @@ add_llvm_target(DirectXCodeGen
DXILResourceAccess.cpp
DXILShaderFlags.cpp
DXILTranslateMetadata.cpp
-
+ DXILRootSignature.cpp
LINK_COMPONENTS
Analysis
AsmPrinter
diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index 7ab11ce757e436..833a22a9b3e81e 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "DXILShaderFlags.h"
+#include "DXILRootSignature.h"
#include "DirectX.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -23,7 +24,6 @@
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/MC/DXContainerPSVInfo.h"
-#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Pass.h"
#include "llvm/Support/MD5.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -63,6 +63,7 @@ class DXContainerGlobals : public llvm::ModulePass {
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
AU.addRequired<ShaderFlagsAnalysisWrapper>();
+ AU.addRequired<RootSignatureAnalysisWrapper>();
AU.addRequired<DXILMetadataAnalysisWrapperPass>();
AU.addRequired<DXILResourceTypeWrapperPass>();
AU.addRequired<DXILResourceBindingWrapperPass>();
@@ -151,17 +152,15 @@ void DXContainerGlobals::addSignature(Module &M,
void DXContainerGlobals::addRootSignature(Module &M,
SmallVector<GlobalValue *> &Globals) {
- std::optional<RootSignatureDesc> Desc =
- getAnalysis<DXILMetadataAnalysisWrapperPass>()
- .getModuleMetadata()
- .RootSignatureDesc;
- if (!Desc.has_value())
+ std::optional<ModuleRootSignature> MRS =
+ getAnalysis<RootSignatureAnalysisWrapper>()
+ .getRootSignature();
+ if (!MRS.has_value())
return;
SmallString<256> Data;
raw_svector_ostream OS(Data);
- RootSignatureDescWriter writer(&Desc.value());
- writer.write(OS);
+ MRS->write(OS);
Constant *Constant =
ConstantDataArray::getString(M.getContext(), Data, /*AddNull*/ false);
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
new file mode 100644
index 00000000000000..4a51198d97ac34
--- /dev/null
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -0,0 +1,146 @@
+//===- DXILRootSignature.cpp - DXIL Root Signature helper objects ---------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file contains helper objects and APIs for working with DXIL
+/// Root Signatures.
+///
+//===----------------------------------------------------------------------===//
+#include "DXILRootSignature.h"
+#include "DirectX.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/BinaryFormat/DXContainer.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Metadata.h"
+#include "llvm/IR/Module.h"
+
+using namespace llvm;
+using namespace llvm::dxil;
+
+static bool parseRootFlags(ModuleRootSignature *MRS, MDNode *RootFlagNode) {
+
+ assert(RootFlagNode->getNumOperands() == 2 &&
+ "Invalid format for RootFlag Element");
+ auto *Flag = mdconst::extract<ConstantInt>(RootFlagNode->getOperand(1));
+ auto Value = Flag->getZExtValue();
+
+ // Root Element validation, as specified: https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#validations-during-dxil-generation
+ if ((Value & ~0x80000fff) != 0)
+ return true;
+
+ MRS->Flags = Value;
+ return false;
+}
+
+static bool parseRootSignatureElement(ModuleRootSignature *MRS, MDNode *Element) {
+ MDString *ElementText = cast<MDString>(Element->getOperand(0));
+
+ assert(ElementText != nullptr && "First preoperty of element is not ");
+
+ RootSignatureElementKind ElementKind =
+ StringSwitch<RootSignatureElementKind>(ElementText->getString())
+ .Case("RootFlags", RootSignatureElementKind::RootFlags)
+ .Case("RootConstants", RootSignatureElementKind::RootConstants)
+ .Case("RootCBV", RootSignatureElementKind::RootDescriptor)
+ .Case("RootSRV", RootSignatureElementKind::RootDescriptor)
+ .Case("RootUAV", RootSignatureElementKind::RootDescriptor)
+ .Case("Sampler", RootSignatureElementKind::RootDescriptor)
+ .Case("DescriptorTable", RootSignatureElementKind::DescriptorTable)
+ .Case("StaticSampler", RootSignatureElementKind::StaticSampler)
+ .Default(RootSignatureElementKind::None);
+
+ switch (ElementKind) {
+
+ case RootSignatureElementKind::RootFlags: {
+ return parseRootFlags(MRS, Element);
+ break;
+ }
+
+ case RootSignatureElementKind::RootConstants:
+ case RootSignatureElementKind::RootDescriptor:
+ case RootSignatureElementKind::DescriptorTable:
+ case RootSignatureElementKind::StaticSampler:
+ case RootSignatureElementKind::None:
+ llvm_unreachable("Not Implemented yet");
+ break;
+ }
+
+ return true;
+}
+
+bool ModuleRootSignature::parse( int32_t Version,
+ NamedMDNode *Root) {
+ this->Version = Version;
+ bool HasError = false;
+
+ for (unsigned int Sid = 0; Sid < Root->getNumOperands(); Sid++) {
+ // This should be an if, for error handling
+ MDNode *Node = cast<MDNode>(Root->getOperand(Sid));
+
+ // Not sure what use this for...
+ Metadata *Func = Node->getOperand(0).get();
+
+ // This should be an if, for error handling
+ MDNode *Elements = cast<MDNode>(Node->getOperand(1).get());
+
+ for (unsigned int Eid = 0; Eid < Elements->getNumOperands(); Eid++) {
+ MDNode *Element = cast<MDNode>(Elements->getOperand(Eid));
+
+ HasError = HasError || parseRootSignatureElement(this, Element);
+ }
+ }
+ return HasError;
+}
+
+void ModuleRootSignature::write(raw_ostream &OS) {
+ dxbc::RootSignatureDesc Out{this->Version, this->Flags};
+
+ if (sys::IsBigEndianHost) {
+ Out.swapBytes();
+ }
+
+ OS.write(reinterpret_cast<const char *>(&Out), sizeof(dxbc::RootSignatureDesc));
+}
+
+AnalysisKey RootSignatureAnalysis::Key;
+
+ModuleRootSignature RootSignatureAnalysis::run(Module &M,
+ ModuleAnalysisManager &AM) {
+ ModuleRootSignature MRSI;
+
+ NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
+ if (RootSignatureNode) {
+ MRSI.parse(1, RootSignatureNode);
+ }
+
+ return MRSI;
+
+}
+
+
+//===----------------------------------------------------------------------===//
+bool RootSignatureAnalysisWrapper::runOnModule(Module &M) {
+ ModuleRootSignature MRS;
+
+ NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
+ if (RootSignatureNode) {
+ MRS.parse(1, RootSignatureNode);
+ this->MRS = MRS;
+ }
+
+
+ return false;
+}
+
+void RootSignatureAnalysisWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+}
+
+char RootSignatureAnalysisWrapper::ID = 0;
+
+INITIALIZE_PASS(RootSignatureAnalysisWrapper, "dx-root-signature-analysis",
+ "DXIL Root Signature Analysis", true, true)
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.h b/llvm/lib/Target/DirectX/DXILRootSignature.h
new file mode 100644
index 00000000000000..fdfd6c41c0af37
--- /dev/null
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.h
@@ -0,0 +1,75 @@
+//===- DXILRootSignature.h - DXIL Root Signature helper objects ---------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file This file contains helper objects and APIs for working with DXIL
+/// Root Signatures.
+///
+//===----------------------------------------------------------------------===//
+
+
+#include "llvm/IR/Metadata.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/Pass.h"
+#include <optional>
+
+namespace llvm {
+namespace dxil {
+
+
+ enum class RootSignatureElementKind {
+ None = 0,
+ RootFlags = 1,
+ RootConstants = 2,
+ RootDescriptor = 3,
+ DescriptorTable = 4,
+ StaticSampler = 5
+ };
+
+ struct ModuleRootSignature {
+ uint32_t Version;
+ uint32_t Flags;
+
+ ModuleRootSignature() = default;
+
+ bool parse( int32_t Version, NamedMDNode *Root);
+ void write(raw_ostream &OS);
+ };
+
+ class RootSignatureAnalysis : public AnalysisInfoMixin<RootSignatureAnalysis> {
+ friend AnalysisInfoMixin<RootSignatureAnalysis>;
+ static AnalysisKey Key;
+
+ public:
+ RootSignatureAnalysis() = default;
+
+ using Result = ModuleRootSignature;
+
+ ModuleRootSignature run(Module &M, ModuleAnalysisManager &AM);
+ };
+
+ /// Wrapper pass for the legacy pass manager.
+ ///
+ /// This is required because the passes that will depend on this are codegen
+ /// passes which run through the legacy pass manager.
+ class RootSignatureAnalysisWrapper : public ModulePass {
+ std::optional<ModuleRootSignature> MRS;
+
+ public:
+ static char ID;
+
+ RootSignatureAnalysisWrapper() : ModulePass(ID) {}
+
+ const std::optional<ModuleRootSignature> &getRootSignature() { return MRS; }
+
+ bool runOnModule(Module &M) override;
+
+ void getAnalysisUsage(AnalysisUsage &AU) const override;
+ };
+
+} // namespace dxil
+} // namespace llvm
diff --git a/llvm/lib/Target/DirectX/DirectX.h b/llvm/lib/Target/DirectX/DirectX.h
index add23587de7d58..953ac3eb820987 100644
--- a/llvm/lib/Target/DirectX/DirectX.h
+++ b/llvm/lib/Target/DirectX/DirectX.h
@@ -77,6 +77,9 @@ void initializeDXILPrettyPrinterLegacyPass(PassRegistry &);
/// Initializer for dxil::ShaderFlagsAnalysisWrapper pass.
void initializeShaderFlagsAnalysisWrapperPass(PassRegistry &);
+/// Initializer for dxil::RootSignatureAnalysisWrapper pass.
+void initializeRootSignatureAnalysisWrapperPass(PassRegistry &);
+
/// Initializer for DXContainerGlobals pass.
void initializeDXContainerGlobalsPass(PassRegistry &);
diff --git a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
index ecb1bf775f8578..93745d7a5cb0d2 100644
--- a/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
+++ b/llvm/lib/Target/DirectX/DirectXTargetMachine.cpp
@@ -61,6 +61,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeDirectXTarget() {
initializeDXILTranslateMetadataLegacyPass(*PR);
initializeDXILResourceMDWrapperPass(*PR);
initializeShaderFlagsAnalysisWrapperPass(*PR);
+ initializeRootSignatureAnalysisWrapperPass(*PR);
initializeDXILFinalizeLinkageLegacyPass(*PR);
}
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll
new file mode 100644
index 00000000000000..ffbf5e9ffd1d32
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll
@@ -0,0 +1,38 @@
+; RUN: opt %s -dxil-embed -dxil-globals -S -o - | FileCheck %s
+; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
+
+target triple = "dxil-unknown-shadermodel6.0-compute"
+
+; CHECK: @dx.rts0 = private constant [8 x i8] c"{{.*}}", section "RTS0", align 4
+
+
+define void @main() #0 {
+entry:
+ ret void
+}
+
+attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
+
+
+!dx.rootsignatures = !{!2} ; list of function/root signature pairs
+!2 = !{ ptr @main, !3 } ; function, root signature
+!3 = !{ !4 } ; list of root signature elements
+!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
+
+
+; DXC: - Name: RTS0
+; DXC-NEXT: Size: 8
+; DXC-NEXT: RootSignature:
+; DXC-NEXT: Version: 1
+; DXC-NEXT: AllowInputAssemblerInputLayout: true
+; DXC-NEXT: DenyVertexShaderRootAccess: false
+; DXC-NEXT: DenyHullShaderRootAccess: false
+; DXC-NEXT: DenyDomainShaderRootAccess: false
+; DXC-NEXT: DenyGeometryShaderRootAccess: false
+; DXC-NEXT: DenyPixelShaderRootAccess: false
+; DXC-NEXT: AllowStreamOutput: false
+; DXC-NEXT: LocalRootSignature: false
+; DXC-NEXT: DenyAmplificationShaderRootAccess: false
+; DXC-NEXT: DenyMeshShaderRootAccess: false
+; DXC-NEXT: CBVSRVUAVHeapDirectlyIndexed: false
+; DXC-NEXT: SamplerHeapDirectlyIndexed: false
>From 3edcce542e14450057bf1899c5b81650f4fac332 Mon Sep 17 00:00:00 2001
From: joaosaffran <joao.saffran at microsoft.com>
Date: Thu, 16 Jan 2025 00:37:14 +0000
Subject: [PATCH 10/10] formating
---
llvm/lib/Analysis/DXILMetadataAnalysis.cpp | 2 -
.../lib/Target/DirectX/DXContainerGlobals.cpp | 5 +-
llvm/lib/Target/DirectX/DXILRootSignature.cpp | 48 ++++++------
llvm/lib/Target/DirectX/DXILRootSignature.h | 77 +++++++++----------
4 files changed, 64 insertions(+), 68 deletions(-)
diff --git a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
index 15e72bf17515b1..197b7e422092c6 100644
--- a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
+++ b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
@@ -24,8 +24,6 @@
using namespace llvm;
using namespace dxil;
-
-
static ModuleMetadataInfo collectMetadataInfo(Module &M) {
ModuleMetadataInfo MMDAI;
Triple TT(Triple(M.getTargetTriple()));
diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index 833a22a9b3e81e..ac70bd3771dadf 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
@@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//
-#include "DXILShaderFlags.h"
#include "DXILRootSignature.h"
+#include "DXILShaderFlags.h"
#include "DirectX.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -153,8 +153,7 @@ void DXContainerGlobals::addRootSignature(Module &M,
SmallVector<GlobalValue *> &Globals) {
std::optional<ModuleRootSignature> MRS =
- getAnalysis<RootSignatureAnalysisWrapper>()
- .getRootSignature();
+ getAnalysis<RootSignatureAnalysisWrapper>().getRootSignature();
if (!MRS.has_value())
return;
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index 4a51198d97ac34..89621868a93368 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -1,4 +1,5 @@
-//===- DXILRootSignature.cpp - DXIL Root Signature helper objects ---------------===//
+//===- DXILRootSignature.cpp - DXIL Root Signature helper objects
+//---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,7 +29,8 @@ static bool parseRootFlags(ModuleRootSignature *MRS, MDNode *RootFlagNode) {
auto *Flag = mdconst::extract<ConstantInt>(RootFlagNode->getOperand(1));
auto Value = Flag->getZExtValue();
- // Root Element validation, as specified: https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#validations-during-dxil-generation
+ // Root Element validation, as specified:
+ // https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#validations-during-dxil-generation
if ((Value & ~0x80000fff) != 0)
return true;
@@ -36,7 +38,8 @@ static bool parseRootFlags(ModuleRootSignature *MRS, MDNode *RootFlagNode) {
return false;
}
-static bool parseRootSignatureElement(ModuleRootSignature *MRS, MDNode *Element) {
+static bool parseRootSignatureElement(ModuleRootSignature *MRS,
+ MDNode *Element) {
MDString *ElementText = cast<MDString>(Element->getOperand(0));
assert(ElementText != nullptr && "First preoperty of element is not ");
@@ -72,8 +75,7 @@ static bool parseRootSignatureElement(ModuleRootSignature *MRS, MDNode *Element)
return true;
}
-bool ModuleRootSignature::parse( int32_t Version,
- NamedMDNode *Root) {
+bool ModuleRootSignature::parse(int32_t Version, NamedMDNode *Root) {
this->Version = Version;
bool HasError = false;
@@ -103,37 +105,35 @@ void ModuleRootSignature::write(raw_ostream &OS) {
Out.swapBytes();
}
- OS.write(reinterpret_cast<const char *>(&Out), sizeof(dxbc::RootSignatureDesc));
+ OS.write(reinterpret_cast<const char *>(&Out),
+ sizeof(dxbc::RootSignatureDesc));
}
AnalysisKey RootSignatureAnalysis::Key;
ModuleRootSignature RootSignatureAnalysis::run(Module &M,
- ModuleAnalysisManager &AM) {
- ModuleRootSignature MRSI;
+ ModuleAnalysisManager &AM) {
+ ModuleRootSignature MRSI;
- NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
- if (RootSignatureNode) {
- MRSI.parse(1, RootSignatureNode);
- }
-
- return MRSI;
+ NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
+ if (RootSignatureNode) {
+ MRSI.parse(1, RootSignatureNode);
+ }
+ return MRSI;
}
-
//===----------------------------------------------------------------------===//
bool RootSignatureAnalysisWrapper::runOnModule(Module &M) {
ModuleRootSignature MRS;
- NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
- if (RootSignatureNode) {
- MRS.parse(1, RootSignatureNode);
- this->MRS = MRS;
- }
-
+ NamedMDNode *RootSignatureNode = M.getNamedMetadata("dx.rootsignatures");
+ if (RootSignatureNode) {
+ MRS.parse(1, RootSignatureNode);
+ this->MRS = MRS;
+ }
- return false;
+ return false;
}
void RootSignatureAnalysisWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
@@ -142,5 +142,5 @@ void RootSignatureAnalysisWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
char RootSignatureAnalysisWrapper::ID = 0;
-INITIALIZE_PASS(RootSignatureAnalysisWrapper, "dx-root-signature-analysis",
- "DXIL Root Signature Analysis", true, true)
+INITIALIZE_PASS(RootSignatureAnalysisWrapper, "dx-root-signature-analysis",
+ "DXIL Root Signature Analysis", true, true)
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.h b/llvm/lib/Target/DirectX/DXILRootSignature.h
index fdfd6c41c0af37..de82afcdc8c467 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.h
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.h
@@ -1,4 +1,5 @@
-//===- DXILRootSignature.h - DXIL Root Signature helper objects ---------------===//
+//===- DXILRootSignature.h - DXIL Root Signature helper objects
+//---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +12,6 @@
///
//===----------------------------------------------------------------------===//
-
#include "llvm/IR/Metadata.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
@@ -20,56 +20,55 @@
namespace llvm {
namespace dxil {
+enum class RootSignatureElementKind {
+ None = 0,
+ RootFlags = 1,
+ RootConstants = 2,
+ RootDescriptor = 3,
+ DescriptorTable = 4,
+ StaticSampler = 5
+};
- enum class RootSignatureElementKind {
- None = 0,
- RootFlags = 1,
- RootConstants = 2,
- RootDescriptor = 3,
- DescriptorTable = 4,
- StaticSampler = 5
- };
-
- struct ModuleRootSignature {
- uint32_t Version;
- uint32_t Flags;
+struct ModuleRootSignature {
+ uint32_t Version;
+ uint32_t Flags;
- ModuleRootSignature() = default;
+ ModuleRootSignature() = default;
- bool parse( int32_t Version, NamedMDNode *Root);
- void write(raw_ostream &OS);
- };
+ bool parse(int32_t Version, NamedMDNode *Root);
+ void write(raw_ostream &OS);
+};
- class RootSignatureAnalysis : public AnalysisInfoMixin<RootSignatureAnalysis> {
- friend AnalysisInfoMixin<RootSignatureAnalysis>;
- static AnalysisKey Key;
+class RootSignatureAnalysis : public AnalysisInfoMixin<RootSignatureAnalysis> {
+ friend AnalysisInfoMixin<RootSignatureAnalysis>;
+ static AnalysisKey Key;
- public:
- RootSignatureAnalysis() = default;
+public:
+ RootSignatureAnalysis() = default;
- using Result = ModuleRootSignature;
+ using Result = ModuleRootSignature;
- ModuleRootSignature run(Module &M, ModuleAnalysisManager &AM);
- };
+ ModuleRootSignature run(Module &M, ModuleAnalysisManager &AM);
+};
- /// Wrapper pass for the legacy pass manager.
- ///
- /// This is required because the passes that will depend on this are codegen
- /// passes which run through the legacy pass manager.
- class RootSignatureAnalysisWrapper : public ModulePass {
- std::optional<ModuleRootSignature> MRS;
+/// Wrapper pass for the legacy pass manager.
+///
+/// This is required because the passes that will depend on this are codegen
+/// passes which run through the legacy pass manager.
+class RootSignatureAnalysisWrapper : public ModulePass {
+ std::optional<ModuleRootSignature> MRS;
- public:
- static char ID;
+public:
+ static char ID;
- RootSignatureAnalysisWrapper() : ModulePass(ID) {}
+ RootSignatureAnalysisWrapper() : ModulePass(ID) {}
- const std::optional<ModuleRootSignature> &getRootSignature() { return MRS; }
+ const std::optional<ModuleRootSignature> &getRootSignature() { return MRS; }
- bool runOnModule(Module &M) override;
+ bool runOnModule(Module &M) override;
- void getAnalysisUsage(AnalysisUsage &AU) const override;
- };
+ void getAnalysisUsage(AnalysisUsage &AU) const override;
+};
} // namespace dxil
} // namespace llvm
More information about the llvm-commits
mailing list