Skip to content

Commit 905d5d3

Browse files
committed
clean up
1 parent 159388d commit 905d5d3

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

llvm/include/llvm/Object/DXContainer.h

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,25 @@ template <typename T> struct ViewArray {
124124

125125
namespace DirectX {
126126

127-
template <typename T> Expected<T> readParameter(StringRef Data) {
128-
T Struct;
129-
if (sizeof(T) != Data.size())
130-
return make_error<GenericBinaryError>(
131-
"Reading structure out of file bounds", object_error::parse_failed);
132-
133-
memcpy(&Struct, Data.data(), sizeof(T));
134-
// DXContainer is always little endian
135-
if (sys::IsBigEndianHost)
136-
Struct.swapBytes();
137-
return Struct;
138-
}
139-
140127
struct RootParameterView {
141128
const dxbc::RTS0::v1::RootParameterHeader &Header;
142129
StringRef ParamData;
143130

144131
RootParameterView(const dxbc::RTS0::v1::RootParameterHeader &H, StringRef P)
145132
: Header(H), ParamData(P) {}
133+
134+
template <typename T> Expected<T> readParameter() {
135+
T Struct;
136+
if (sizeof(T) != ParamData.size())
137+
return make_error<GenericBinaryError>(
138+
"Reading structure out of file bounds", object_error::parse_failed);
139+
140+
memcpy(&Struct, ParamData.data(), sizeof(T));
141+
// DXContainer is always little endian
142+
if (sys::IsBigEndianHost)
143+
Struct.swapBytes();
144+
return Struct;
145+
}
146146
};
147147

148148
struct RootConstantView : RootParameterView {
@@ -152,7 +152,7 @@ struct RootConstantView : RootParameterView {
152152
}
153153

154154
llvm::Expected<dxbc::RTS0::v1::RootConstants> read() {
155-
return readParameter<dxbc::RTS0::v1::RootConstants>(ParamData);
155+
return readParameter<dxbc::RTS0::v1::RootConstants>();
156156
}
157157
};
158158

@@ -168,8 +168,7 @@ struct RootDescriptorView : RootParameterView {
168168

169169
llvm::Expected<dxbc::RTS0::v2::RootDescriptor> read(uint32_t Version) {
170170
if (Version == 1) {
171-
auto Descriptor =
172-
readParameter<dxbc::RTS0::v1::RootDescriptor>(ParamData);
171+
auto Descriptor = readParameter<dxbc::RTS0::v1::RootDescriptor>();
173172
if (Error E = Descriptor.takeError())
174173
return E;
175174
return dxbc::RTS0::v2::RootDescriptor(*Descriptor);
@@ -178,7 +177,7 @@ struct RootDescriptorView : RootParameterView {
178177
return make_error<GenericBinaryError>("Invalid Root Signature version: " +
179178
Twine(Version),
180179
object_error::parse_failed);
181-
return readParameter<dxbc::RTS0::v2::RootDescriptor>(ParamData);
180+
return readParameter<dxbc::RTS0::v2::RootDescriptor>();
182181
}
183182
};
184183

llvm/lib/Object/DXContainer.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include <cstddef>
10-
119
#include "llvm/Object/DXContainer.h"
1210
#include "llvm/BinaryFormat/DXContainer.h"
1311
#include "llvm/Object/Error.h"

llvm/lib/ObjectYAML/DXContainerYAML.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ DXContainerYAML::RootSignatureYamlDesc::create(
164164
}
165165

166166
for (const auto &S : Data.samplers()) {
167-
168167
if (!dxbc::isValidSamplerFilter(S.Filter))
169168
return createStringError(std::errc::invalid_argument,
170169
"Invalid value for static sampler filter");

llvm/unittests/Object/DXContainerTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ TEST(RootSignature, ParseStaticSamplers) {
11721172
0x00, 0x00, 0x00, 0x00, 0x85, 0xeb, 0x91, 0x40, 0x66, 0x66, 0x0e, 0x41,
11731173
0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00};
11741174
DXContainer C =
1175-
llvm::cantFail(DXContainer::create(getMemoryBuffer<144>(Buffer)));
1175+
llvm::cantFail(DXContainer::create(getMemoryBuffer<133>(Buffer)));
11761176

11771177
auto MaybeRS = C.getRootSignature();
11781178
ASSERT_TRUE(MaybeRS.has_value());

0 commit comments

Comments
 (0)