mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-05 04:36:02 +00:00
[spirv-writer] Generate load of conditionals.
This CL adds the missing load of conditional values. Bug: tint:327 Change-Id: I836ecfacb3a237a54886ebc7625c9449ba33fdc7 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32700 Commit-Queue: David Neto <dneto@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
10d5c6a6b6
commit
c7c8f58f17
@ -1998,6 +1998,7 @@ bool Builder::GenerateConditionalBlock(
|
|||||||
if (cond_id == 0) {
|
if (cond_id == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
cond_id = GenerateLoadIfNeeded(cond->result_type(), cond_id);
|
||||||
|
|
||||||
auto merge_block = result_op();
|
auto merge_block = result_op();
|
||||||
auto merge_block_id = merge_block.to_i();
|
auto merge_block_id = merge_block.to_i();
|
||||||
|
@ -627,6 +627,39 @@ OpReturnValue %5
|
|||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(BuilderTest, If_WithLoad_Bug327) {
|
||||||
|
// var a : bool;
|
||||||
|
// if (a) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
ast::type::BoolType bool_type;
|
||||||
|
auto var = std::make_unique<ast::Variable>("a", ast::StorageClass::kFunction,
|
||||||
|
&bool_type);
|
||||||
|
td.RegisterVariableForTesting(var.get());
|
||||||
|
|
||||||
|
ast::IfStatement expr(std::make_unique<ast::IdentifierExpression>("a"),
|
||||||
|
std::make_unique<ast::BlockStatement>());
|
||||||
|
|
||||||
|
ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error();
|
||||||
|
|
||||||
|
b.push_function(Function{});
|
||||||
|
ASSERT_TRUE(b.GenerateGlobalVariable(var.get())) << b.error();
|
||||||
|
|
||||||
|
EXPECT_TRUE(b.GenerateIfStatement(&expr)) << b.error();
|
||||||
|
EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeBool
|
||||||
|
%2 = OpTypePointer Function %3
|
||||||
|
%1 = OpVariable %2 Function
|
||||||
|
)");
|
||||||
|
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
|
||||||
|
R"(%4 = OpLoad %3 %1
|
||||||
|
OpSelectionMerge %5 None
|
||||||
|
OpBranchConditional %4 %6 %5
|
||||||
|
%6 = OpLabel
|
||||||
|
OpBranch %5
|
||||||
|
%5 = OpLabel
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
} // namespace writer
|
} // namespace writer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user