-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[HLSL][RootSignature] Metadata generation of RootFlags, RootConstants, RootDescriptors #142010
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
Changes from 5 commits
34733d6
2ee3b10
33b5b05
5875d8d
e163ede
5501e5e
079c6a6
2640b02
ec94a3c
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 |
---|---|---|
|
@@ -171,6 +171,12 @@ void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements) { | |
MDNode *MetadataBuilder::BuildRootSignature() { | ||
for (const RootElement &Element : Elements) { | ||
MDNode *ElementMD = nullptr; | ||
if (const auto &Flags = std::get_if<RootFlags>(&Element)) | ||
ElementMD = BuildRootFlags(*Flags); | ||
if (const auto &Constants = std::get_if<RootConstants>(&Element)) | ||
ElementMD = BuildRootConstants(*Constants); | ||
if (const auto &Descriptor = std::get_if<RootDescriptor>(&Element)) | ||
ElementMD = BuildRootDescriptor(*Descriptor); | ||
if (const auto &Clause = std::get_if<DescriptorTableClause>(&Element)) | ||
ElementMD = BuildDescriptorTableClause(*Clause); | ||
if (const auto &Table = std::get_if<DescriptorTable>(&Element)) | ||
inbelic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -187,6 +193,46 @@ MDNode *MetadataBuilder::BuildRootSignature() { | |
return MDNode::get(Ctx, GeneratedMetadata); | ||
} | ||
|
||
MDNode *MetadataBuilder::BuildRootFlags(const RootFlags &Flags) { | ||
IRBuilder<> Builder(Ctx); | ||
return MDNode::get(Ctx, { | ||
MDString::get(Ctx, "RootFlags"), | ||
ConstantAsMetadata::get( | ||
Builder.getInt32(llvm::to_underlying(Flags))), | ||
}); | ||
inbelic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
MDNode *MetadataBuilder::BuildRootConstants(const RootConstants &Constants) { | ||
IRBuilder<> Builder(Ctx); | ||
return MDNode::get( | ||
Ctx, { | ||
MDString::get(Ctx, "RootConstants"), | ||
ConstantAsMetadata::get( | ||
Builder.getInt32(llvm::to_underlying(Constants.Visibility))), | ||
ConstantAsMetadata::get(Builder.getInt32(Constants.Reg.Number)), | ||
ConstantAsMetadata::get(Builder.getInt32(Constants.Space)), | ||
ConstantAsMetadata::get( | ||
Builder.getInt32(Constants.Num32BitConstants)), | ||
}); | ||
} | ||
|
||
MDNode *MetadataBuilder::BuildRootDescriptor(const RootDescriptor &Descriptor) { | ||
IRBuilder<> Builder(Ctx); | ||
std::string Name; | ||
llvm::raw_string_ostream OS(Name); | ||
OS << "Root" << ClauseType(llvm::to_underlying(Descriptor.Type)); | ||
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. It'll be slightly more efficient to use Note also that this does actually point out a bit of an inefficiency with how we've implemented only 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. Sounds good. I have a note for a clean-up to do define the stringifying functions for the enums. Further, the pattern used here was propagated from descriptor tables, so I will update the other uses accordingly. |
||
return MDNode::get( | ||
Ctx, { | ||
MDString::get(Ctx, OS.str()), | ||
ConstantAsMetadata::get(Builder.getInt32( | ||
llvm::to_underlying(Descriptor.Visibility))), | ||
ConstantAsMetadata::get(Builder.getInt32(Descriptor.Reg.Number)), | ||
ConstantAsMetadata::get(Builder.getInt32(Descriptor.Space)), | ||
ConstantAsMetadata::get( | ||
Builder.getInt32(llvm::to_underlying(Descriptor.Flags))), | ||
}); | ||
} | ||
|
||
MDNode *MetadataBuilder::BuildDescriptorTable(const DescriptorTable &Table) { | ||
IRBuilder<> Builder(Ctx); | ||
SmallVector<Metadata *> TableOperands; | ||
|
Uh oh!
There was an error while loading. Please reload this page.