Skip to content

Commit 28be2f8

Browse files
author
joaosaffran
committed
format
1 parent a9b87c2 commit 28be2f8

File tree

6 files changed

+112
-112
lines changed

6 files changed

+112
-112
lines changed

llvm/include/llvm/MC/DXContainerRootSignature.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ struct RootParameterInfo {
2828
: Header(Header), Location(Location) {}
2929
};
3030

31-
3231
struct DescriptorTable {
3332
SmallVector<dxbc::RTS0::v2::DescriptorRange> Ranges;
34-
3533
SmallVector<dxbc::RTS0::v2::DescriptorRange>::const_iterator begin() const {
3634
return Ranges.begin();
3735
}
@@ -40,8 +38,6 @@ struct DescriptorTable {
4038
}
4139
};
4240

43-
44-
4541
struct RootParametersContainer {
4642
SmallVector<RootParameterInfo> ParametersInfo;
4743
SmallVector<dxbc::RootConstants> Constants;
@@ -91,7 +87,7 @@ struct RootParametersContainer {
9187
const dxbc::RTS0::v2::RootDescriptor &getRootDescriptor(size_t Index) const {
9288
return Descriptors[Index];
9389
}
94-
const DescriptorTable &getDescriptorTable(size_t Index) const {
90+
const DescriptorTable &getDescriptorTable(size_t Index) const {
9591
return Tables[Index];
9692
}
9793

llvm/include/llvm/Object/DXContainer.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,13 @@ struct DescriptorTable {
183183
uint32_t RangesOffset;
184184
ViewArray<dxbc::RTS0::v2::DescriptorRange> Ranges;
185185

186-
typename ViewArray<dxbc::RTS0::v2::DescriptorRange>::iterator begin() const { return Ranges.begin(); }
186+
typename ViewArray<dxbc::RTS0::v2::DescriptorRange>::iterator begin() const {
187+
return Ranges.begin();
188+
}
187189

188-
typename ViewArray<dxbc::RTS0::v2::DescriptorRange>::iterator end() const { return Ranges.end(); }
190+
typename ViewArray<dxbc::RTS0::v2::DescriptorRange>::iterator end() const {
191+
return Ranges.end();
192+
}
189193
};
190194

191195
struct DescriptorTableView : RootParameterView {
@@ -208,7 +212,7 @@ struct DescriptorTableView : RootParameterView {
208212
Current += sizeof(uint32_t);
209213

210214
size_t RangeSize = sizeof(dxbc::RTS0::v1::DescriptorRange);
211-
if(Version > 1)
215+
if (Version > 1)
212216
RangeSize = sizeof(dxbc::RTS0::v2::DescriptorRange);
213217

214218
Table.Ranges.Stride = RangeSize;

llvm/lib/MC/DXContainerRootSignature.cpp

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ size_t RootSignatureDesc::getSize() const {
4848
Size += sizeof(dxbc::RTS0::v2::RootDescriptor);
4949

5050
break;
51-
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
52-
const DescriptorTable &Table = ParametersContainer.getDescriptorTable(I.Location);
53-
if (Version == 1)
54-
Size +=
55-
sizeof(dxbc::RTS0::v1::DescriptorRange) * Table.Ranges.size() + 8;
56-
else
57-
Size +=
58-
sizeof(dxbc::RTS0::v2::DescriptorRange) * Table.Ranges.size() + 8;
59-
break;
51+
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
52+
const DescriptorTable &Table =
53+
ParametersContainer.getDescriptorTable(I.Location);
54+
if (Version == 1)
55+
Size +=
56+
sizeof(dxbc::RTS0::v1::DescriptorRange) * Table.Ranges.size() + 8;
57+
else
58+
Size +=
59+
sizeof(dxbc::RTS0::v2::DescriptorRange) * Table.Ranges.size() + 8;
60+
break;
6061
}
6162
}
6263
return Size;
@@ -100,8 +101,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
100101
llvm::endianness::little);
101102
support::endian::write(BOS, Constants.Num32BitValues,
102103
llvm::endianness::little);
103-
}
104-
break;
104+
} break;
105105
case llvm::to_underlying(dxbc::RootParameterType::CBV):
106106
case llvm::to_underlying(dxbc::RootParameterType::SRV):
107107
case llvm::to_underlying(dxbc::RootParameterType::UAV): {
@@ -114,29 +114,26 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
114114
llvm::endianness::little);
115115
if (Version > 1)
116116
support::endian::write(BOS, Descriptor.Flags, llvm::endianness::little);
117-
}
118-
break;
119-
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):{
117+
} break;
118+
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): {
120119
const DescriptorTable &Table =
121120
ParametersContainer.getDescriptorTable(Loc);
122121
support::endian::write(BOS, (uint32_t)Table.Ranges.size(),
123122
llvm::endianness::little);
124123
rewriteOffsetToCurrentByte(BOS, writePlaceholder(BOS));
125124
for (const auto &Range : Table) {
126-
support::endian::write(BOS, Range.RangeType,
127-
llvm::endianness::little);
128-
support::endian::write(BOS, Range.NumDescriptors,
129-
llvm::endianness::little);
130-
support::endian::write(BOS, Range.BaseShaderRegister,
131-
llvm::endianness::little);
132-
support::endian::write(BOS, Range.RegisterSpace,
133-
llvm::endianness::little);
134-
support::endian::write(BOS, Range.OffsetInDescriptorsFromTableStart,
135-
llvm::endianness::little);
136-
if(Version > 1)
137-
support::endian::write(BOS, Range.Flags,
138-
llvm::endianness::little);
139-
}
125+
support::endian::write(BOS, Range.RangeType, llvm::endianness::little);
126+
support::endian::write(BOS, Range.NumDescriptors,
127+
llvm::endianness::little);
128+
support::endian::write(BOS, Range.BaseShaderRegister,
129+
llvm::endianness::little);
130+
support::endian::write(BOS, Range.RegisterSpace,
131+
llvm::endianness::little);
132+
support::endian::write(BOS, Range.OffsetInDescriptorsFromTableStart,
133+
llvm::endianness::little);
134+
if (Version > 1)
135+
support::endian::write(BOS, Range.Flags, llvm::endianness::little);
136+
}
140137
} break;
141138
}
142139
}

llvm/lib/ObjectYAML/DXContainerEmitter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,16 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
300300
mcdxbc::DescriptorTable Table;
301301
for (const auto &R : Param.Table.Ranges) {
302302

303-
dxbc::RTS0::v2::DescriptorRange Range;
304-
Range.RangeType = R.RangeType;
305-
Range.NumDescriptors = R.NumDescriptors;
306-
Range.BaseShaderRegister = R.BaseShaderRegister;
307-
Range.RegisterSpace = R.RegisterSpace;
308-
Range.OffsetInDescriptorsFromTableStart =
309-
R.OffsetInDescriptorsFromTableStart;
310-
if (RS.Version > 1)
311-
Range.Flags = R.getEncodedFlags();
312-
Table.Ranges.push_back(Range);
303+
dxbc::RTS0::v2::DescriptorRange Range;
304+
Range.RangeType = R.RangeType;
305+
Range.NumDescriptors = R.NumDescriptors;
306+
Range.BaseShaderRegister = R.BaseShaderRegister;
307+
Range.RegisterSpace = R.RegisterSpace;
308+
Range.OffsetInDescriptorsFromTableStart =
309+
R.OffsetInDescriptorsFromTableStart;
310+
if (RS.Version > 1)
311+
Range.Flags = R.getEncodedFlags();
312+
Table.Ranges.push_back(Range);
313313
}
314314
RS.ParametersContainer.addParameter(Header, Table);
315315
} break;

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ DXContainerYAML::RootSignatureYamlDesc::create(
9595
llvm::to_underlying(dxbc::RootDescriptorFlag::Val)) > 0;
9696
#include "llvm/BinaryFormat/DXContainerConstants.def"
9797
}
98-
} else if (auto *TDV = dyn_cast<object::DirectX::DescriptorTableView>(&ParamView)) {
99-
llvm::Expected<object::DirectX::DescriptorTable>TableOrErr = TDV->read(Version);
98+
} else if (auto *TDV =
99+
dyn_cast<object::DirectX::DescriptorTableView>(&ParamView)) {
100+
llvm::Expected<object::DirectX::DescriptorTable> TableOrErr =
101+
TDV->read(Version);
100102
if (Error E = TableOrErr.takeError())
101103
return std::move(E);
102104
auto Table = *TableOrErr;
@@ -119,8 +121,8 @@ DXContainerYAML::RootSignatureYamlDesc::create(
119121
#include "llvm/BinaryFormat/DXContainerConstants.def"
120122
}
121123
NewP.Table.Ranges.push_back(NewR);
124+
}
122125
}
123-
}
124126

125127
RootSigDesc.Parameters.push_back(NewP);
126128
}

llvm/unittests/Object/DXContainerTest.cpp

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -248,49 +248,49 @@ generateDXContainer(StringRef Yaml, SmallVectorImpl<char> &BinaryData) {
248248

249249
TEST(DXCFile, PSVResourceIterators) {
250250
const char *Yaml = R"(
251-
--- !dxcontainer
252-
Header:
253-
Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
254-
0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
255-
Version:
256-
Major: 1
257-
Minor: 0
258-
PartCount: 2
259-
Parts:
260-
- Name: PSV0
261-
Size: 144
262-
PSVInfo:
263-
Version: 0
264-
ShaderStage: 14
265-
PayloadSizeInBytes: 4092
266-
MinimumWaveLaneCount: 0
267-
MaximumWaveLaneCount: 4294967295
268-
ResourceStride: 16
269-
Resources:
270-
- Type: Sampler
271-
Space: 1
272-
LowerBound: 1
273-
UpperBound: 1
274-
- Type: CBV
275-
Space: 2
276-
LowerBound: 2
277-
UpperBound: 2
278-
- Type: SRVTyped
279-
Space: 3
280-
LowerBound: 3
281-
UpperBound: 3
282-
- Name: DXIL
283-
Size: 24
284-
Program:
285-
MajorVersion: 6
286-
MinorVersion: 0
287-
ShaderKind: 14
288-
Size: 6
289-
DXILMajorVersion: 1
290-
DXILMinorVersion: 0
291-
DXILSize: 0
292-
...
293-
)";
251+
--- !dxcontainer
252+
Header:
253+
Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
254+
0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
255+
Version:
256+
Major: 1
257+
Minor: 0
258+
PartCount: 2
259+
Parts:
260+
- Name: PSV0
261+
Size: 144
262+
PSVInfo:
263+
Version: 0
264+
ShaderStage: 14
265+
PayloadSizeInBytes: 4092
266+
MinimumWaveLaneCount: 0
267+
MaximumWaveLaneCount: 4294967295
268+
ResourceStride: 16
269+
Resources:
270+
- Type: Sampler
271+
Space: 1
272+
LowerBound: 1
273+
UpperBound: 1
274+
- Type: CBV
275+
Space: 2
276+
LowerBound: 2
277+
UpperBound: 2
278+
- Type: SRVTyped
279+
Space: 3
280+
LowerBound: 3
281+
UpperBound: 3
282+
- Name: DXIL
283+
Size: 24
284+
Program:
285+
MajorVersion: 6
286+
MinorVersion: 0
287+
ShaderKind: 14
288+
Size: 6
289+
DXILMajorVersion: 1
290+
DXILMinorVersion: 0
291+
DXILSize: 0
292+
...
293+
)";
294294

295295
SmallVector<char, 256> BinaryData;
296296
auto C = generateDXContainer(Yaml, BinaryData);
@@ -560,20 +560,23 @@ TEST(DXCFile, MaliciousFiles) {
560560
// ...
561561
TEST(DXCFile, PSVResourceIteratorsStride) {
562562
uint8_t Buffer[] = {
563-
0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
564-
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
565-
0x28, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4C, 0x18, 0x00, 0x00, 0x00,
566-
0x60, 0x00, 0x0E, 0x00, 0x06, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4C, 0x00, 0x01, 0x00, 0x00,
567-
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x53, 0x56, 0x30, 0x64, 0x00, 0x00, 0x00,
568-
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
569-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
570-
0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
571-
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
572-
0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
573-
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
574-
0x00, 0x00, 0x00, 0x00,
575-
};
576-
DXContainer C =
563+
0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
564+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
565+
0xB0, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
566+
0x48, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4C, 0x18, 0x00, 0x00, 0x00,
567+
0x60, 0x00, 0x0E, 0x00, 0x06, 0x00, 0x00, 0x00, 0x44, 0x58, 0x49, 0x4C,
568+
0x00, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
569+
0x50, 0x53, 0x56, 0x30, 0x64, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
570+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
571+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
572+
0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
573+
0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
574+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
575+
0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
576+
0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
577+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
578+
};
579+
DXContainer C =
577580
llvm::cantFail(DXContainer::create(getMemoryBuffer<180>(Buffer)));
578581

579582
const auto &PSVInfo = C.getPSVInfo();
@@ -625,8 +628,8 @@ TEST(DXCFile, PSVResourceIteratorsStride) {
625628
EXPECT_EQ(Binding.Type, dxbc::PSV::ResourceType::SRVStructured);
626629
EXPECT_EQ(Binding.Space, 6u);
627630
EXPECT_EQ(Binding.LowerBound, 7u);
628-
EXPECT_EQ(Binding.UpperBound, 8u);;
629-
631+
EXPECT_EQ(Binding.UpperBound, 8u);
632+
;
630633

631634
EXPECT_FALSE(It == PSVInfo->getResources().end());
632635

@@ -1086,8 +1089,7 @@ TEST(RootSignature, ParseDescriptorTable) {
10861089
ASSERT_THAT_ERROR(ParamView.takeError(), Succeeded());
10871090

10881091
auto *DescriptorTableView =
1089-
dyn_cast<DirectX::DescriptorTableView>(
1090-
&*ParamView);
1092+
dyn_cast<DirectX::DescriptorTableView>(&*ParamView);
10911093
ASSERT_TRUE(DescriptorTableView != nullptr);
10921094
auto Table = DescriptorTableView->read(2);
10931095

@@ -1139,8 +1141,7 @@ TEST(RootSignature, ParseDescriptorTable) {
11391141
ASSERT_THAT_ERROR(ParamView.takeError(), Succeeded());
11401142

11411143
auto *DescriptorTableView =
1142-
dyn_cast<DirectX::DescriptorTableView>(
1143-
&*ParamView);
1144+
dyn_cast<DirectX::DescriptorTableView>(&*ParamView);
11441145
ASSERT_TRUE(DescriptorTableView != nullptr);
11451146
auto Table = DescriptorTableView->read(1);
11461147

0 commit comments

Comments
 (0)