Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions llvm/include/llvm/Object/DXContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,8 @@ struct DescriptorTableView : RootParameterView {
support::endian::read<uint32_t, llvm::endianness::little>(Current);
Current += sizeof(uint32_t);

size_t RangeSize = sizeof(T);

Table.Ranges.Stride = RangeSize;
Table.Ranges.Data =
ParamData.substr(2 * sizeof(uint32_t), Table.NumRanges * RangeSize);
ParamData.substr(2 * sizeof(uint32_t), Table.NumRanges * sizeof(T));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be clearer to use Table.NumRanges * Tabled.Ranges.Stride here?

return Table;
}
};
Expand Down
38 changes: 19 additions & 19 deletions llvm/lib/ObjectYAML/DXContainerYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ DXContainerYAML::ShaderFeatureFlags::ShaderFeatureFlags(uint64_t FlagData) {
}

template <typename T>
static void
addDescriptorRanges(DXContainerYAML::RootParameterHeaderYaml &Header,
DXContainerYAML::RootSignatureYamlDesc &RootSigDesc,
const object::DirectX::DescriptorTable<T> &Table) {
static llvm::Error
readDescriptorRanges(DXContainerYAML::RootParameterHeaderYaml &Header,
DXContainerYAML::RootSignatureYamlDesc &RootSigDesc,
object::DirectX::DescriptorTableView *DTV) {

llvm::Expected<object::DirectX::DescriptorTable<T>> TableOrErr =
DTV->read<T>();
if (Error E = TableOrErr.takeError())
return E;
auto Table = *TableOrErr;

DXContainerYAML::RootParameterLocationYaml Location(Header);
DXContainerYAML::DescriptorTableYaml &TableYaml =
Expand All @@ -64,6 +70,8 @@ addDescriptorRanges(DXContainerYAML::RootParameterHeaderYaml &Header,
}
TableYaml.Ranges.push_back(NewR);
}

return Error::success();
}

llvm::Expected<DXContainerYAML::RootSignatureYamlDesc>
Expand Down Expand Up @@ -140,24 +148,16 @@ DXContainerYAML::RootSignatureYamlDesc::create(
}
} else if (auto *DTV =
dyn_cast<object::DirectX::DescriptorTableView>(&ParamView)) {

if (Version == 1) {
llvm::Expected<
object::DirectX::DescriptorTable<dxbc::RTS0::v1::DescriptorRange>>
TableOrErr = DTV->read<dxbc::RTS0::v1::DescriptorRange>();
if (Error E = TableOrErr.takeError())
if (Error E = readDescriptorRanges<dxbc::RTS0::v1::DescriptorRange>(
Header, RootSigDesc, DTV))
return std::move(E);
auto Table = *TableOrErr;
addDescriptorRanges(Header, RootSigDesc, Table);
} else {
llvm::Expected<
object::DirectX::DescriptorTable<dxbc::RTS0::v2::DescriptorRange>>
TableOrErr = DTV->read<dxbc::RTS0::v2::DescriptorRange>();
if (Error E = TableOrErr.takeError())
} else if (Version == 2) {
if (Error E = readDescriptorRanges<dxbc::RTS0::v2::DescriptorRange>(
Header, RootSigDesc, DTV))
return std::move(E);
auto Table = *TableOrErr;
addDescriptorRanges(Header, RootSigDesc, Table);
}
} else
llvm_unreachable("Unknown version for DescriptorRanges");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a change, but maybe such cases will be a nice reason to use the explicitly defined root signature enum when it is merged in.

}
}

Expand Down
Loading