Skip to content

Commit a693491

Browse files
author
joaosaffran
committed
updating test
1 parent b02e7fe commit a693491

File tree

6 files changed

+94
-64
lines changed

6 files changed

+94
-64
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 44 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "llvm/Support/SwapByteOrder.h"
1818
#include "llvm/TargetParser/Triple.h"
1919

20-
#include <cstdint>
2120
#include <stdint.h>
2221

2322
namespace llvm {
@@ -64,19 +63,55 @@ struct ShaderHash {
6463
void swapBytes() { sys::swapByteOrder(Flags); }
6564
};
6665

67-
<<<<<<< HEAD
68-
struct RootSignatureDesc {
69-
uint32_t Size;
70-
uint32_t Flags;
66+
#define ROOT_PARAMETER(Val, Enum) Enum = Val,
67+
enum class RootParameterType : uint8_t {
68+
#include "DXContainerConstants.def"
69+
};
70+
71+
ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
72+
73+
74+
#define SHADER_VISIBILITY(Val, Enum) Enum = Val,
75+
enum class ShaderVisibilityFlag : uint8_t {
76+
#include "DXContainerConstants.def"
77+
};
78+
79+
ArrayRef<EnumEntry<ShaderVisibilityFlag>> getShaderVisibilityFlags();
80+
81+
struct RootConstants {
82+
uint32_t ShaderRegister;
83+
uint32_t RegisterSpace;
84+
uint32_t Num32BitValues;
7185

7286
void swapBytes() {
73-
sys::swapByteOrder(Size);
74-
sys::swapByteOrder(Flags);
87+
sys::swapByteOrder(ShaderRegister);
88+
sys::swapByteOrder(RegisterSpace);
89+
sys::swapByteOrder(Num32BitValues);
90+
}
91+
};
92+
93+
struct RootParameter {
94+
RootParameterType ParameterType;
95+
union {
96+
RootConstants Constants;
97+
};
98+
ShaderVisibilityFlag ShaderVisibility;
99+
100+
void swapBytes() {
101+
switch (ParameterType) {
102+
103+
case RootParameterType::Constants32Bit:
104+
Constants.swapBytes();
105+
break;
106+
case RootParameterType::DescriptorTable:
107+
case RootParameterType::CBV:
108+
case RootParameterType::SRV:
109+
case RootParameterType::UAV:
110+
break;
111+
}
75112
}
76113
};
77114

78-
=======
79-
>>>>>>> b1b967db8d32 (adding support for root constants in dxcontainer for ob2jyaml and yaml2obj tools)
80115
struct ContainerVersion {
81116
uint16_t Major;
82117
uint16_t Minor;
@@ -171,50 +206,6 @@ enum class RootElementFlag : uint32_t {
171206
#include "DXContainerConstants.def"
172207
};
173208

174-
#define ROOT_PARAMETER(Val, Enum) Enum = Val,
175-
enum class RootParameterType : uint8_t {
176-
#include "DXContainerConstants.def"
177-
};
178-
179-
#define SHADER_VISIBILITY(Val, Enum) Enum = Val,
180-
enum class ShaderVisibilityFlag : uint8_t {
181-
#include "DXContainerConstants.def"
182-
};
183-
184-
struct RootConstants {
185-
uint32_t ShaderRegister;
186-
uint32_t RegisterSpace;
187-
uint32_t Num32BitValues;
188-
189-
void swapBytes() {
190-
sys::swapByteOrder(ShaderRegister);
191-
sys::swapByteOrder(RegisterSpace);
192-
sys::swapByteOrder(Num32BitValues);
193-
}
194-
};
195-
196-
struct RootParameter {
197-
RootParameterType ParameterType;
198-
union {
199-
RootConstants Constants;
200-
};
201-
ShaderVisibilityFlag ShaderVisibility;
202-
203-
void swapBytes() {
204-
switch (ParameterType) {
205-
206-
case RootParameterType::Constants32Bit:
207-
Constants.swapBytes();
208-
break;
209-
case RootParameterType::DescriptorTable:
210-
case RootParameterType::CBV:
211-
case RootParameterType::SRV:
212-
case RootParameterType::UAV:
213-
break;
214-
}
215-
}
216-
};
217-
218209
PartType parsePartType(StringRef S);
219210

220211
struct VertexPSVInfo {
@@ -556,8 +547,6 @@ enum class SigComponentType : uint32_t {
556547
};
557548

558549
ArrayRef<EnumEntry<SigComponentType>> getSigComponentTypes();
559-
ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
560-
ArrayRef<EnumEntry<ShaderVisibilityFlag>> getShaderVisibilityFlags();
561550

562551
struct ProgramSignatureHeader {
563552
uint32_t ParamCount;

llvm/include/llvm/Object/DXContainer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "llvm/Support/MemoryBufferRef.h"
2323
#include "llvm/TargetParser/Triple.h"
2424
#include <array>
25-
#include <cstdint>
2625
#include <variant>
2726

2827
namespace llvm {

llvm/include/llvm/ObjectYAML/DXContainerYAML.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ struct RootSignatureDesc {
8080

8181
uint32_t getEncodedFlags();
8282
uint32_t Size;
83+
uint32_t NumParameters;
84+
SmallVector<dxbc::RootParameter> Parameters;
8385

8486
#include "llvm/BinaryFormat/DXContainerConstants.def"
8587
};

llvm/lib/MC/DXContainerRootSignature.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "llvm/MC/DXContainerRootSignature.h"
1010
#include "llvm/BinaryFormat/DXContainer.h"
1111
#include "llvm/Support/EndianStream.h"
12-
#include <cstdint>
1312

1413
using namespace llvm;
1514
using namespace llvm::mcdxbc;

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ DXContainerYAML::ShaderFeatureFlags::ShaderFeatureFlags(uint64_t FlagData) {
3232

3333
DXContainerYAML::RootSignatureDesc::RootSignatureDesc(
3434
const object::DirectX::RootSignature &Data)
35-
: Size(Data.getSize()) {
36-
: Size(Data.getSize()), Version(Data.getVersion()),
37-
NumParameters(Data.getNParameters()) {
35+
: Size(Data.getSize()), NumParameters(Data.getNParameters()) {
3836
uint32_t Flags = Data.getFlags();
37+
for (const auto &Param : Data.getParameters())
38+
Parameters.push_back(Param);
39+
3940
#define ROOT_ELEMENT_FLAG(Num, Val, Str) \
4041
Val = (Flags & (uint32_t)dxbc::RootElementFlag::Val) > 0;
4142
#include "llvm/BinaryFormat/DXContainerConstants.def"
@@ -209,10 +210,48 @@ void MappingTraits<DXContainerYAML::Signature>::mapping(
209210
IO.mapRequired("Parameters", S.Parameters);
210211
}
211212

213+
void MappingTraits<dxbc::RootParameter>::mapping(IO &IO,
214+
dxbc::RootParameter &S) {
215+
216+
IO.mapRequired("Type", S.ParameterType);
217+
IO.mapRequired("ShaderVisibility", S.ShaderVisibility);
218+
219+
switch (S.ParameterType) {
220+
221+
case dxbc::RootParameterType::Constants32Bit:
222+
IO.mapRequired("Constants", S.Constants);
223+
break;
224+
case dxbc::RootParameterType::DescriptorTable:
225+
case dxbc::RootParameterType::CBV:
226+
case dxbc::RootParameterType::SRV:
227+
case dxbc::RootParameterType::UAV:
228+
break;
229+
}
230+
}
231+
232+
void ScalarEnumerationTraits<dxbc::RootParameterType>::enumeration(
233+
IO &IO, dxbc::RootParameterType &Value) {
234+
for (const auto &E : dxbc::getRootParameterTypes())
235+
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
236+
}
237+
238+
void ScalarEnumerationTraits<dxbc::ShaderVisibilityFlag>::enumeration(
239+
IO &IO, dxbc::ShaderVisibilityFlag &Value) {
240+
for (const auto &E : dxbc::getShaderVisibilityFlags())
241+
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
242+
}
243+
244+
void MappingTraits<dxbc::RootConstants>::mapping(IO &IO,
245+
dxbc::RootConstants &S) {
246+
247+
IO.mapRequired("Num32BitValues", S.Num32BitValues);
248+
IO.mapRequired("ShaderRegister", S.ShaderRegister);
249+
IO.mapRequired("RegisterSpace", S.RegisterSpace);
250+
}
251+
212252
void MappingTraits<DXContainerYAML::RootSignatureDesc>::mapping(
213253
IO &IO, DXContainerYAML::RootSignatureDesc &S) {
214254
IO.mapRequired("Size", S.Size);
215-
IO.mapRequired("Version", S.Version);
216255
IO.mapRequired("NumParameters", S.NumParameters);
217256
IO.mapRequired("Parameters", S.Parameters);
218257
#define ROOT_ELEMENT_FLAG(Num, Val, Str) IO.mapOptional(#Val, S.Val, false);

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
target triple = "dxil-unknown-shadermodel6.0-compute"
55

6-
; CHECK: @dx.rts0 = private constant [8 x i8] c"{{.*}}", section "RTS0", align 4
6+
; CHECK: @dx.rts0 = private constant [12 x i8] c"{{.*}}", section "RTS0", align 4
77

88

99
define void @main() #0 {
@@ -24,7 +24,9 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
2424

2525

2626
; DXC: - Name: RTS0
27-
; DXC-NEXT: Size: 8
27+
; DXC-NEXT: Size: 12
2828
; DXC-NEXT: RootSignature:
29-
; DXC-NEXT: Size: 8
29+
; DXC-NEXT: Size: 64
30+
; DXC-NEXT: NumParameters: 0
31+
; DXC-NEXT: Parameters: []
3032
; DXC-NEXT: AllowInputAssemblerInputLayout: true

0 commit comments

Comments
 (0)