Skip to content

Commit 751cbdc

Browse files
author
joaosaffran
committed
addressing comments
1 parent 25e3f37 commit 751cbdc

File tree

7 files changed

+36
-52
lines changed

7 files changed

+36
-52
lines changed

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ enum class FeatureFlags : uint64_t {
162162
static_assert((uint64_t)FeatureFlags::NextUnusedBit <= 1ull << 63,
163163
"Shader flag bits exceed enum size.");
164164

165-
#define ROOT_ELEMENT_FLAG(Num, Val, Str) Val = 1ull << Num,
165+
#define ROOT_ELEMENT_FLAG(Num, Val) Val = 1ull << Num,
166166
enum class RootElementFlag : uint32_t {
167167
#include "DXContainerConstants.def"
168168
};

llvm/include/llvm/BinaryFormat/DXContainerConstants.def

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,20 @@ SHADER_FEATURE_FLAG(31, 36, NextUnusedBit, "Next reserved shader flag bit (not a
5353
#undef SHADER_FEATURE_FLAG
5454
#endif // SHADER_FEATURE_FLAG
5555

56-
#ifdef ROOT_PARAMETER
57-
58-
ROOT_PARAMETER(DescriptorTable)
59-
ROOT_PARAMETER(Constants32Bit)
60-
ROOT_PARAMETER(CBV)
61-
ROOT_PARAMETER(SRV)
62-
ROOT_PARAMETER(UAV)
63-
#undef ROOT_PARAMETER
64-
#endif // ROOT_PARAMETER
65-
66-
67-
#ifdef SHADER_VISIBILITY
68-
69-
SHADER_VISIBILITY(All)
70-
SHADER_VISIBILITY(Vertex)
71-
SHADER_VISIBILITY(Hull)
72-
SHADER_VISIBILITY(Domain)
73-
SHADER_VISIBILITY(Geometry)
74-
SHADER_VISIBILITY(Pixel)
75-
SHADER_VISIBILITY(Amplification)
76-
SHADER_VISIBILITY(Mesh)
77-
#undef SHADER_VISIBILITY
78-
#endif // SHADER_VISIBILITY
79-
8056
#ifdef ROOT_ELEMENT_FLAG
8157

82-
ROOT_ELEMENT_FLAG(0, AllowInputAssemblerInputLayout, "The app is opting in to using the Input Assembler")
83-
ROOT_ELEMENT_FLAG(1, DenyVertexShaderRootAccess, "Denies the vertex shader access to the root signature.")
84-
ROOT_ELEMENT_FLAG(2, DenyHullShaderRootAccess, "Denies the hull shader access to the root signature.")
85-
ROOT_ELEMENT_FLAG(3, DenyDomainShaderRootAccess, "Denies the domain shader access to the root signature.")
86-
ROOT_ELEMENT_FLAG(4, DenyGeometryShaderRootAccess, "Denies the geometry shader access to the root signature.")
87-
ROOT_ELEMENT_FLAG(5, DenyPixelShaderRootAccess, "Denies the pixel shader access to the root signature.")
88-
ROOT_ELEMENT_FLAG(6, AllowStreamOutput, "The app is opting in to using Stream Output.")
89-
ROOT_ELEMENT_FLAG(7, LocalRootSignature, "The root signature is to be used with raytracing shaders to define resource bindings sourced from shader records in shader tables.")
90-
ROOT_ELEMENT_FLAG(8, DenyAmplificationShaderRootAccess, "Denies the amplification shader access to the root signature.")
91-
ROOT_ELEMENT_FLAG(9, DenyMeshShaderRootAccess, "Denies the mesh shader access to the root signature.")
92-
ROOT_ELEMENT_FLAG(10, CBVSRVUAVHeapDirectlyIndexed, "The shaders are allowed to index the CBV/SRV/UAV descriptor heap directly, using the ResourceDescriptorHeap built-in variable.")
93-
ROOT_ELEMENT_FLAG(11, SamplerHeapDirectlyIndexed, "The shaders are allowed to index the sampler descriptor heap directly, using the SamplerDescriptorHeap built-in variable.")
58+
ROOT_ELEMENT_FLAG(0, AllowInputAssemblerInputLayout)
59+
ROOT_ELEMENT_FLAG(1, DenyVertexShaderRootAccess)
60+
ROOT_ELEMENT_FLAG(2, DenyHullShaderRootAccess)
61+
ROOT_ELEMENT_FLAG(3, DenyDomainShaderRootAccess)
62+
ROOT_ELEMENT_FLAG(4, DenyGeometryShaderRootAccess)
63+
ROOT_ELEMENT_FLAG(5, DenyPixelShaderRootAccess)
64+
ROOT_ELEMENT_FLAG(6, AllowStreamOutput)
65+
ROOT_ELEMENT_FLAG(7, LocalRootSignature)
66+
ROOT_ELEMENT_FLAG(8, DenyAmplificationShaderRootAccess)
67+
ROOT_ELEMENT_FLAG(9, DenyMeshShaderRootAccess)
68+
ROOT_ELEMENT_FLAG(10, CBVSRVUAVHeapDirectlyIndexed)
69+
ROOT_ELEMENT_FLAG(11, SamplerHeapDirectlyIndexed)
9470
#undef ROOT_ELEMENT_FLAG
9571
#endif // ROOT_ELEMENT_FLAG
9672

llvm/include/llvm/ObjectYAML/DXContainerYAML.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,19 @@ struct ShaderHash {
7373
std::vector<llvm::yaml::Hex8> Digest;
7474
};
7575

76-
#define ROOT_ELEMENT_FLAG(Num, Val, Str) bool Val = false;
76+
#define ROOT_ELEMENT_FLAG(Num, Val) bool Val = false;
7777
struct RootSignatureDesc {
7878
RootSignatureDesc() = default;
7979
RootSignatureDesc(const object::DirectX::RootSignature &Data);
8080

81-
uint32_t getEncodedFlags();
8281
uint32_t Version;
8382
uint32_t NumParameters;
8483
uint32_t RootParametersOffset;
8584
uint32_t NumStaticSamplers;
8685
uint32_t StaticSamplersOffset;
8786

87+
uint32_t getEncodedFlags();
88+
8889
#include "llvm/BinaryFormat/DXContainerConstants.def"
8990
};
9091

llvm/lib/ObjectYAML/DXContainerEmitter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
268268

269269
mcdxbc::RootSignatureHeader Header;
270270
Header.Flags = P.RootSignature->getEncodedFlags();
271+
Header.Version = P.RootSignature->Version;
272+
Header.NumParameters = P.RootSignature->NumParameters;
273+
Header.RootParametersOffset = P.RootSignature->RootParametersOffset;
274+
Header.NumStaticSamplers = P.RootSignature->NumStaticSamplers;
275+
Header.StaticSamplersOffset = P.RootSignature->StaticSamplersOffset;
271276

272277
Header.write(OS);
273278
break;

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ DXContainerYAML::RootSignatureDesc::RootSignatureDesc(
3737
NumStaticSamplers(Data.getNumStaticSamplers()),
3838
StaticSamplersOffset(Data.getStaticSamplersOffset()) {
3939
uint32_t Flags = Data.getFlags();
40-
#define ROOT_ELEMENT_FLAG(Num, Val, Str) \
40+
#define ROOT_ELEMENT_FLAG(Num, Val) \
4141
Val = (Flags & (uint32_t)dxbc::RootElementFlag::Val) > 0;
4242
#include "llvm/BinaryFormat/DXContainerConstants.def"
4343
}
4444

4545
uint32_t DXContainerYAML::RootSignatureDesc::getEncodedFlags() {
4646
uint64_t Flag = 0;
47-
#define ROOT_ELEMENT_FLAG(Num, Val, Str) \
47+
#define ROOT_ELEMENT_FLAG(Num, Val) \
4848
if (Val) \
4949
Flag |= (uint32_t)dxbc::RootElementFlag::Val;
5050
#include "llvm/BinaryFormat/DXContainerConstants.def"
@@ -217,7 +217,7 @@ void MappingTraits<DXContainerYAML::RootSignatureDesc>::mapping(
217217
IO.mapRequired("RootParametersOffset", S.RootParametersOffset);
218218
IO.mapRequired("NumStaticSamplers", S.NumStaticSamplers);
219219
IO.mapRequired("StaticSamplersOffset", S.StaticSamplersOffset);
220-
#define ROOT_ELEMENT_FLAG(Num, Val, Str) IO.mapOptional(#Val, S.Val, false);
220+
#define ROOT_ELEMENT_FLAG(Num, Val) IO.mapOptional(#Val, S.Val, false);
221221
#include "llvm/BinaryFormat/DXContainerConstants.def"
222222
}
223223

llvm/test/ObjectYAML/DXContainer/RootSignature-Flags.yaml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ Parts:
1414
Size: 24
1515
RootSignature:
1616
Version: 2
17-
NumParameters: 0
18-
RootParametersOffset: 0
19-
NumStaticSamplers: 0
20-
StaticSamplersOffset: 0
17+
NumParameters: 1
18+
RootParametersOffset: 3
19+
NumStaticSamplers: 4
20+
StaticSamplersOffset: 5
2121
AllowInputAssemblerInputLayout: true
22+
DenyGeometryShaderRootAccess: true
2223

2324
# CHECK: - Name: RTS0
2425
# CHECK-NEXT: Size: 24
2526
# CHECK-NEXT: RootSignature:
2627
# CHECK-NEXT: Version: 2
27-
# CHECK-NEXT: NumParameters: 0
28-
# CHECK-NEXT: RootParametersOffset: 0
29-
# CHECK-NEXT: NumStaticSamplers: 0
30-
# CHECK-NEXT: StaticSamplersOffset: 0
28+
# CHECK-NEXT: NumParameters: 1
29+
# CHECK-NEXT: RootParametersOffset: 3
30+
# CHECK-NEXT: NumStaticSamplers: 4
31+
# CHECK-NEXT: StaticSamplersOffset: 5
3132
# CHECK-NEXT: AllowInputAssemblerInputLayout: true
33+
# CHECK-NEXT: DenyGeometryShaderRootAccess: true

llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ TEST(RootSignature, ParseRootFlags) {
128128
RootSignature:
129129
Version: 2
130130
NumParameters: 0
131-
RootParametersOffset: 24
131+
RootParametersOffset: 0
132132
NumStaticSamplers: 0
133-
StaticSamplersOffset: 24
133+
StaticSamplersOffset: 0
134134
AllowInputAssemblerInputLayout: true
135135
)"));
136136

0 commit comments

Comments
 (0)