Skip to content

Commit 76a2b07

Browse files
author
joaosaffran
committed
clean up
1 parent 28be2f8 commit 76a2b07

File tree

7 files changed

+81
-80
lines changed

7 files changed

+81
-80
lines changed

llvm/include/llvm/MC/DXContainerRootSignature.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "llvm/ADT/STLForwardCompat.h"
109
#include "llvm/ADT/SmallVector.h"
1110
#include "llvm/BinaryFormat/DXContainer.h"
1211
#include <cstdint>
1312
#include <limits>
14-
#include <variant>
1513

1614
namespace llvm {
1715

@@ -87,6 +85,7 @@ struct RootParametersContainer {
8785
const dxbc::RTS0::v2::RootDescriptor &getRootDescriptor(size_t Index) const {
8886
return Descriptors[Index];
8987
}
88+
9089
const DescriptorTable &getDescriptorTable(size_t Index) const {
9190
return Tables[Index];
9291
}

llvm/include/llvm/Object/DXContainer.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
#include "llvm/ADT/Twine.h"
2121
#include "llvm/BinaryFormat/DXContainer.h"
2222
#include "llvm/Object/Error.h"
23-
#include "llvm/Support/Casting.h"
2423
#include "llvm/Support/Endian.h"
2524
#include "llvm/Support/Error.h"
2625
#include "llvm/Support/MemoryBufferRef.h"
2726
#include "llvm/TargetParser/Triple.h"
27+
#include <array>
28+
#include <cstddef>
2829
#include <cstdint>
2930
#include <variant>
3031

@@ -41,7 +42,6 @@ template <typename T>
4142
std::enable_if_t<std::is_class<T>::value, void> swapBytes(T &value) {
4243
value.swapBytes();
4344
}
44-
4545
} // namespace detail
4646

4747
// This class provides a view into the underlying resource array. The Resource
@@ -278,11 +278,13 @@ class RootSignature {
278278
support::endian::read<uint32_t, llvm::endianness::little>(
279279
PartData.begin() + Header.ParameterOffset);
280280
if (Version == 1)
281-
DataSize = sizeof(dxbc::RTS0::v1::DescriptorRange) * NumRanges +
282-
2 * sizeof(uint32_t);
281+
DataSize = sizeof(dxbc::RTS0::v1::DescriptorRange) * NumRanges;
283282
else
284-
DataSize = sizeof(dxbc::RTS0::v2::DescriptorRange) * NumRanges +
285-
2 * sizeof(uint32_t);
283+
DataSize = sizeof(dxbc::RTS0::v2::DescriptorRange) * NumRanges;
284+
285+
// 4 bits for the number of ranges in table and
286+
// 4 bits for the ranges offset
287+
DataSize += 2 * sizeof(uint32_t);
286288
break;
287289
}
288290
size_t EndOfSectionByte = getNumStaticSamplers() == 0

llvm/include/llvm/ObjectYAML/DXContainerYAML.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#ifndef LLVM_OBJECTYAML_DXCONTAINERYAML_H
1616
#define LLVM_OBJECTYAML_DXCONTAINERYAML_H
1717

18-
#include "llvm/ADT/STLForwardCompat.h"
19-
#include "llvm/ADT/SmallVector.h"
2018
#include "llvm/ADT/StringRef.h"
2119
#include "llvm/BinaryFormat/DXContainer.h"
2220
#include "llvm/Object/DXContainer.h"

llvm/lib/MC/DXContainerRootSignature.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/MC/DXContainerRootSignature.h"
10-
#include "llvm/ADT/STLForwardCompat.h"
1110
#include "llvm/ADT/SmallString.h"
12-
#include "llvm/BinaryFormat/DXContainer.h"
1311
#include "llvm/Support/EndianStream.h"
12+
#include <cstdint>
1413

1514
using namespace llvm;
1615
using namespace llvm::mcdxbc;
@@ -51,12 +50,14 @@ size_t RootSignatureDesc::getSize() const {
5150
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
5251
const DescriptorTable &Table =
5352
ParametersContainer.getDescriptorTable(I.Location);
53+
54+
// 4 bits for the number of ranges in table and
55+
// 4 bits for the ranges offset
56+
Size += 2 * sizeof(uint32_t);
5457
if (Version == 1)
55-
Size +=
56-
sizeof(dxbc::RTS0::v1::DescriptorRange) * Table.Ranges.size() + 8;
58+
Size += sizeof(dxbc::RTS0::v1::DescriptorRange) * Table.Ranges.size();
5759
else
58-
Size +=
59-
sizeof(dxbc::RTS0::v2::DescriptorRange) * Table.Ranges.size() + 8;
60+
Size += sizeof(dxbc::RTS0::v2::DescriptorRange) * Table.Ranges.size();
6061
break;
6162
}
6263
}
@@ -101,7 +102,8 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
101102
llvm::endianness::little);
102103
support::endian::write(BOS, Constants.Num32BitValues,
103104
llvm::endianness::little);
104-
} break;
105+
break;
106+
}
105107
case llvm::to_underlying(dxbc::RootParameterType::CBV):
106108
case llvm::to_underlying(dxbc::RootParameterType::SRV):
107109
case llvm::to_underlying(dxbc::RootParameterType::UAV): {
@@ -114,7 +116,8 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
114116
llvm::endianness::little);
115117
if (Version > 1)
116118
support::endian::write(BOS, Descriptor.Flags, llvm::endianness::little);
117-
} break;
119+
break;
120+
}
118121
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): {
119122
const DescriptorTable &Table =
120123
ParametersContainer.getDescriptorTable(Loc);
@@ -134,7 +137,8 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
134137
if (Version > 1)
135138
support::endian::write(BOS, Range.Flags, llvm::endianness::little);
136139
}
137-
} break;
140+
break;
141+
}
138142
}
139143
}
140144
assert(Storage.size() == getSize());

llvm/lib/ObjectYAML/DXContainerEmitter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
///
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "llvm/ADT/STLForwardCompat.h"
1514
#include "llvm/BinaryFormat/DXContainer.h"
1615
#include "llvm/MC/DXContainerPSVInfo.h"
1716
#include "llvm/MC/DXContainerRootSignature.h"

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ void MappingTraits<llvm::DXContainerYAML::RootParameterYamlDesc>::mapping(
382382
case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
383383
IO.mapRequired("Table", P.Table);
384384
break;
385-
break;
386385
}
387386
}
388387

llvm/unittests/Object/DXContainerTest.cpp

Lines changed: 59 additions & 59 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,21 +560,21 @@ 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,
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,
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,
578578
};
579579
DXContainer C =
580580
llvm::cantFail(DXContainer::create(getMemoryBuffer<180>(Buffer)));
@@ -602,7 +602,7 @@ TEST(DXCFile, PSVResourceIteratorsStride) {
602602
EXPECT_EQ(Binding.Type, dxbc::PSV::ResourceType::SRVStructured);
603603
EXPECT_EQ(Binding.Space, 6u);
604604
EXPECT_EQ(Binding.LowerBound, 7u);
605-
EXPECT_EQ(Binding.UpperBound, 8u);
605+
EXPECT_EQ(Binding.UpperBound, 8u);;
606606

607607
--It;
608608
Binding = *It;

0 commit comments

Comments
 (0)