Skip to content

Commit 211f73b

Browse files
committed
add unit tests for setDefaultFlags
1 parent 0eb77b2 commit 211f73b

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,40 @@ TEST(HLSLRootSignatureTest, DescriptorSamplerClauseDump) {
9393
EXPECT_EQ(Out, Expected);
9494
}
9595

96+
TEST(HLSLRootSignatureTest, DescriptorCBVV10ClauseDump) {
97+
DescriptorTableClause Clause;
98+
Clause.Type = ClauseType::CBuffer;
99+
Clause.Reg = {RegisterType::BReg, 0};
100+
Clause.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_0);
101+
102+
std::string Out;
103+
llvm::raw_string_ostream OS(Out);
104+
OS << Clause;
105+
OS.flush();
106+
107+
std::string Expected = "CBV(b0, numDescriptors = 1, space = 0, "
108+
"offset = DescriptorTableOffsetAppend, "
109+
"flags = DescriptorsVolatile | DataVolatile)";
110+
EXPECT_EQ(Out, Expected);
111+
}
112+
113+
TEST(HLSLRootSignatureTest, DescriptorSamplerV10ClauseDump) {
114+
DescriptorTableClause Clause;
115+
Clause.Type = ClauseType::Sampler;
116+
Clause.Reg = {RegisterType::SReg, 0};
117+
Clause.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_0);
118+
119+
std::string Out;
120+
llvm::raw_string_ostream OS(Out);
121+
OS << Clause;
122+
OS.flush();
123+
124+
std::string Expected = "Sampler(s0, numDescriptors = 1, space = 0, offset = "
125+
"DescriptorTableOffsetAppend, "
126+
"flags = DescriptorsVolatile)";
127+
EXPECT_EQ(Out, Expected);
128+
}
129+
96130
TEST(HLSLRootSignatureTest, DescriptorTableDump) {
97131
DescriptorTable Table;
98132
Table.NumClauses = 4;
@@ -125,6 +159,40 @@ TEST(HLSLRootSignatureTest, RootCBVDump) {
125159
EXPECT_EQ(Out, Expected);
126160
}
127161

162+
TEST(HLSLRootSignatureTest, RootSRV10Dump) {
163+
RootDescriptor Descriptor;
164+
Descriptor.Type = DescriptorType::SRV;
165+
Descriptor.Reg = {RegisterType::TReg, 0};
166+
Descriptor.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_0);
167+
168+
std::string Out;
169+
llvm::raw_string_ostream OS(Out);
170+
OS << Descriptor;
171+
OS.flush();
172+
173+
std::string Expected = "RootSRV(t0, space = 0, "
174+
"visibility = All, "
175+
"flags = DataVolatile)";
176+
EXPECT_EQ(Out, Expected);
177+
}
178+
179+
TEST(HLSLRootSignatureTest, RootUAVV10Dump) {
180+
RootDescriptor Descriptor;
181+
Descriptor.Type = DescriptorType::UAV;
182+
Descriptor.Reg = {RegisterType::UReg, 0};
183+
Descriptor.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_0);
184+
185+
std::string Out;
186+
llvm::raw_string_ostream OS(Out);
187+
OS << Descriptor;
188+
OS.flush();
189+
190+
std::string Expected = "RootUAV(u0, space = 0, "
191+
"visibility = All, "
192+
"flags = DataVolatile)";
193+
EXPECT_EQ(Out, Expected);
194+
}
195+
128196
TEST(HLSLRootSignatureTest, RootSRVDump) {
129197
RootDescriptor Descriptor;
130198
Descriptor.Type = DescriptorType::SRV;

0 commit comments

Comments
 (0)