[spirv-writer] Generate load for var initializer, if needed

Change-Id: I609860bb05fae3e6e5eb21a471f869030f384ad0
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/20721
Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
David Neto 2020-05-01 19:09:08 +00:00 committed by dan sinclair
parent de4259ef80
commit c8c10e83df
2 changed files with 10 additions and 0 deletions

View File

@ -416,6 +416,7 @@ bool Builder::GenerateFunctionVariable(ast::Variable* var) {
push_function_var(
{Operand::Int(type_id), result, Operand::Int(ConvertStorageClass(sc))});
if (var->has_constructor()) {
init_id = GenerateLoadIfNeeded(var->constructor()->result_type(), init_id);
GenerateStore(var_id, init_id);
}

View File

@ -158,6 +158,15 @@ OpStore %7 %6
)");
}
TEST_F(BuilderTest,
DISABLED_FunctionVar_WithNonConstantConstructorLoadedFromVar) {
// fn main() -> void {
// var v : f32 = 1.0;
// var v2 : f32 = v; // Should generate the load automatically.
// }
FAIL();
}
TEST_F(BuilderTest, FunctionVar_Const) {
ast::type::F32Type f32;
ast::type::VectorType vec(&f32, 3);