Skip to content

[DirectX] Moving Root Signature Metadata Parsing in to Shared Root Signature Metadata lib #149221

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
44 changes: 44 additions & 0 deletions llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#define LLVM_FRONTEND_HLSL_ROOTSIGNATUREMETADATA_H

#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
#include "llvm/IR/Constants.h"
#include "llvm/MC/DXContainerRootSignature.h"

namespace llvm {
class LLVMContext;
Expand Down Expand Up @@ -49,6 +51,48 @@ class MetadataBuilder {
SmallVector<Metadata *> GeneratedMetadata;
};

enum class RootSignatureElementKind {
Error = 0,
RootFlags = 1,
RootConstants = 2,
SRV = 3,
UAV = 4,
CBV = 5,
DescriptorTable = 6,
StaticSamplers = 7
};

class MetadataParser {
public:
MetadataParser(MDNode *Root) : Root(Root) {}

LLVM_ABI bool ParseRootSignature(LLVMContext *Ctx,
mcdxbc::RootSignatureDesc &RSD);

private:
bool parseRootFlags(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
MDNode *RootFlagNode);
bool parseRootConstants(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
MDNode *RootConstantNode);
bool parseRootDescriptors(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
MDNode *RootDescriptorNode,
RootSignatureElementKind ElementKind);
bool parseDescriptorRange(LLVMContext *Ctx, mcdxbc::DescriptorTable &Table,
MDNode *RangeDescriptorNode);
bool parseDescriptorTable(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
MDNode *DescriptorTableNode);
bool parseRootSignatureElement(LLVMContext *Ctx,
mcdxbc::RootSignatureDesc &RSD,
MDNode *Element);
bool parseStaticSampler(LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
MDNode *StaticSamplerNode);

bool validateRootSignature(LLVMContext *Ctx,
const llvm::mcdxbc::RootSignatureDesc &RSD);

MDNode *Root;
};

} // namespace rootsig
} // namespace hlsl
} // namespace llvm
Expand Down
5 changes: 5 additions & 0 deletions llvm/include/llvm/MC/DXContainerRootSignature.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_MC_DXCONTAINERROOTSIGNATURE_H
#define LLVM_MC_DXCONTAINERROOTSIGNATURE_H

#include "llvm/BinaryFormat/DXContainer.h"
#include <cstdint>
#include <limits>
Expand Down Expand Up @@ -116,3 +119,5 @@ struct RootSignatureDesc {
};
} // namespace mcdxbc
} // namespace llvm

#endif // LLVM_MC_DXCONTAINERROOTSIGNATURE_H
Loading
Loading