Skip to content

Commit 2bdbbc6

Browse files
committed
implement support for dumping descriptor table struct
1 parent 51483dd commit 2bdbbc6

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct Register {
6161
struct DescriptorTable {
6262
ShaderVisibility Visibility = ShaderVisibility::All;
6363
uint32_t NumClauses = 0; // The number of clauses in the table
64+
65+
void dump(raw_ostream &OS) const;
6466
};
6567

6668
static const uint32_t NumDescriptorsUnbounded = 0xffffffff;

llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,42 @@ void Register::dump(raw_ostream &OS) const {
3939
OS << Number;
4040
}
4141

42+
static void dumpVisibility(raw_ostream &OS, ShaderVisibility Visibility) {
43+
switch (Visibility) {
44+
case ShaderVisibility::All:
45+
OS << "All";
46+
break;
47+
case ShaderVisibility::Vertex:
48+
OS << "Vertex";
49+
break;
50+
case ShaderVisibility::Hull:
51+
OS << "Hull";
52+
break;
53+
case ShaderVisibility::Domain:
54+
OS << "Domain";
55+
break;
56+
case ShaderVisibility::Geometry:
57+
OS << "Geometry";
58+
break;
59+
case ShaderVisibility::Pixel:
60+
OS << "Pixel";
61+
break;
62+
case ShaderVisibility::Amplification:
63+
OS << "Amplification";
64+
break;
65+
case ShaderVisibility::Mesh:
66+
OS << "Mesh";
67+
break;
68+
}
69+
}
70+
71+
void DescriptorTable::dump(raw_ostream &OS) const {
72+
OS << "DescriptorTable(numClauses = " << NumClauses;
73+
OS << ", visibility = ";
74+
dumpVisibility(OS, Visibility);
75+
OS << ")";
76+
}
77+
4278
static void dumpClauseType(raw_ostream& OS, ClauseType Type) {
4379
switch (Type) {
4480
case ClauseType::CBuffer:

llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,19 @@ TEST(HLSLRootSignatureTest, DescriptorSamplerClauseDump) {
9595
EXPECT_EQ(Out, Expected);
9696
}
9797

98+
TEST(HLSLRootSignatureTest, DescriptorTableDump) {
99+
DescriptorTable Table;
100+
Table.NumClauses = 4;
101+
Table.Visibility = ShaderVisibility::Geometry;
102+
103+
std::string Out;
104+
llvm::raw_string_ostream OS(Out);
105+
Table.dump(OS);
106+
OS.flush();
107+
108+
std::string Expected =
109+
"DescriptorTable(numClauses = 4, visibility = Geometry)";
110+
EXPECT_EQ(Out, Expected);
111+
}
112+
98113
} // namespace

0 commit comments

Comments
 (0)