-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DXIL] Adding support to RootSignatureFlags in obj2yaml #122396
base: main
Are you sure you want to change the base?
Changes from all commits
8adb678
ba78f21
0a54559
557075f
e0d3dcd
80587dd
be3764d
7582ca6
6aaa0a5
916b2f1
d9bce0a
e7676ed
a0cee57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//===- llvm/MC/DXContainerRootSignature.h - DXContainer RootSignature -*- C++ | ||
//-------*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include <cstdint> | ||
#include <limits> | ||
|
||
namespace llvm { | ||
|
||
class raw_ostream; | ||
|
||
namespace mcdxbc { | ||
struct RootSignatureHeader { | ||
uint32_t Version; | ||
uint32_t Flags; | ||
|
||
void swapBytes(); | ||
void write(raw_ostream &OS, | ||
uint32_t Version = std::numeric_limits<uint32_t>::max()); | ||
}; | ||
} // namespace mcdxbc | ||
} // namespace llvm |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//===- llvm/MC/DXContainerRootSignature.cpp - DXContainer RootSignature -*- C++ | ||
//-------*-===// | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like clang format wrapped your header. |
||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/MC/DXContainerRootSignature.h" | ||
#include "llvm/Support/EndianStream.h" | ||
#include "llvm/Support/SwapByteOrder.h" | ||
#include <iterator> | ||
|
||
using namespace llvm; | ||
using namespace llvm::mcdxbc; | ||
|
||
void RootSignatureHeader::write(raw_ostream &OS, uint32_t Version) { | ||
|
||
uint32_t SizeInfo = sizeof(this); | ||
// support::endian::write(OS, SizeInfo, llvm::endianness::little); | ||
|
||
if (sys::IsBigEndianHost) { | ||
sys::swapByteOrder(Version); | ||
sys::swapByteOrder(Flags); | ||
} | ||
|
||
OS.write(reinterpret_cast<const char *>(this), SizeInfo); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're writing the size without byte-swapping, and byte swapping the fields (in place) without writing them. This seems wrong. Wouldn't it be better to just write:
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,9 @@ | |
#include "llvm/ObjectYAML/DXContainerYAML.h" | ||
#include "llvm/ADT/ScopeExit.h" | ||
#include "llvm/BinaryFormat/DXContainer.h" | ||
#include "llvm/Object/DXContainer.h" | ||
#include "llvm/Support/ScopedPrinter.h" | ||
#include <cstdint> | ||
|
||
namespace llvm { | ||
|
||
|
@@ -29,6 +31,24 @@ DXContainerYAML::ShaderFeatureFlags::ShaderFeatureFlags(uint64_t FlagData) { | |
#include "llvm/BinaryFormat/DXContainerConstants.def" | ||
} | ||
|
||
DXContainerYAML::RootSignatureDesc::RootSignatureDesc( | ||
const object::DirectX::RootSignature &Data) | ||
: Version(Data.getVersion()) { | ||
uint32_t Flags = Data.getFlags(); | ||
#define ROOT_ELEMENT_FLAG(Num, Val, Str) \ | ||
Val = (Flags & (uint32_t)dxbc::RootElementFlag::Val) > 0; | ||
#include "llvm/BinaryFormat/DXContainerConstants.def" | ||
} | ||
|
||
uint32_t DXContainerYAML::RootSignatureDesc::getEncodedFlags() { | ||
uint64_t Flag = 0; | ||
#define ROOT_ELEMENT_FLAG(Num, Val, Str) \ | ||
if (Val) \ | ||
Flag |= (uint32_t)dxbc::RootElementFlag::Val; | ||
#include "llvm/BinaryFormat/DXContainerConstants.def" | ||
return Flag; | ||
} | ||
|
||
uint64_t DXContainerYAML::ShaderFeatureFlags::getEncodedFlags() { | ||
uint64_t Flag = 0; | ||
#define SHADER_FEATURE_FLAG(Num, DxilModuleNum, Val, Str) \ | ||
|
@@ -188,6 +208,13 @@ void MappingTraits<DXContainerYAML::Signature>::mapping( | |
IO.mapRequired("Parameters", S.Parameters); | ||
} | ||
|
||
void MappingTraits<DXContainerYAML::RootSignatureDesc>::mapping( | ||
IO &IO, DXContainerYAML::RootSignatureDesc &S) { | ||
IO.mapRequired("Version", S.Version); | ||
#define ROOT_ELEMENT_FLAG(Num, Val, Str) IO.mapRequired(#Val, S.Val); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could instead consider doing this as a |
||
#include "llvm/BinaryFormat/DXContainerConstants.def" | ||
} | ||
|
||
void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO, | ||
DXContainerYAML::Part &P) { | ||
IO.mapRequired("Name", P.Name); | ||
|
@@ -197,6 +224,7 @@ void MappingTraits<DXContainerYAML::Part>::mapping(IO &IO, | |
IO.mapOptional("Hash", P.Hash); | ||
IO.mapOptional("PSVInfo", P.Info); | ||
IO.mapOptional("Signature", P.Signature); | ||
IO.mapOptional("RootSignature", P.RootSignature); | ||
} | ||
|
||
void MappingTraits<DXContainerYAML::Object>::mapping( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could add a similar description as we have in the other enums