[spirv-writer] decorations are annotations
Change-Id: Iaf1c11b2be3fbc2dacda801d1eb32d3e091b76db Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20680 Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
parent
1be8d7f0d1
commit
9684d8101d
|
@ -450,19 +450,19 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) {
|
|||
if (var->IsDecorated()) {
|
||||
for (const auto& deco : var->AsDecorated()->decorations()) {
|
||||
if (deco->IsBuiltin()) {
|
||||
push_debug(spv::Op::OpDecorate,
|
||||
push_annot(spv::Op::OpDecorate,
|
||||
{Operand::Int(var_id), Operand::Int(SpvDecorationBuiltIn),
|
||||
Operand::Int(ConvertBuiltin(deco->AsBuiltin()->value()))});
|
||||
} else if (deco->IsLocation()) {
|
||||
push_debug(spv::Op::OpDecorate,
|
||||
push_annot(spv::Op::OpDecorate,
|
||||
{Operand::Int(var_id), Operand::Int(SpvDecorationLocation),
|
||||
Operand::Int(deco->AsLocation()->value())});
|
||||
} else if (deco->IsBinding()) {
|
||||
push_debug(spv::Op::OpDecorate,
|
||||
push_annot(spv::Op::OpDecorate,
|
||||
{Operand::Int(var_id), Operand::Int(SpvDecorationBinding),
|
||||
Operand::Int(deco->AsBinding()->value())});
|
||||
} else if (deco->IsSet()) {
|
||||
push_debug(
|
||||
push_annot(
|
||||
spv::Op::OpDecorate,
|
||||
{Operand::Int(var_id), Operand::Int(SpvDecorationDescriptorSet),
|
||||
Operand::Int(deco->AsSet()->value())});
|
||||
|
|
|
@ -162,7 +162,8 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) {
|
|||
Builder b(&mod);
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
|
||||
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
|
||||
OpDecorate %1 Location 5
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Location 5
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
|
||||
%2 = OpTypePointer Output %3
|
||||
|
@ -185,7 +186,8 @@ TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) {
|
|||
Builder b(&mod);
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
|
||||
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
|
||||
OpDecorate %1 Binding 2
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 Binding 2
|
||||
OpDecorate %1 DescriptorSet 3
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
|
||||
|
@ -209,7 +211,8 @@ TEST_F(BuilderTest, GlobalVar_WithBuiltin) {
|
|||
Builder b(&mod);
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(&dv)) << b.error();
|
||||
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var"
|
||||
OpDecorate %1 BuiltIn Position
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.annots()), R"(OpDecorate %1 BuiltIn Position
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeFloat 32
|
||||
%2 = OpTypePointer Output %3
|
||||
|
|
Loading…
Reference in New Issue