mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-14 19:31:25 +00:00
[spirv-reader] Store to module-scope variables
Bug: tint:3 Change-Id: Ib4dbb976268999529c2a1c55531aa8293e565b9c Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/19222 Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
parent
b39dabd0cd
commit
2a3e79cf8c
@ -209,6 +209,10 @@ std::unique_ptr<ast::Expression> FunctionEmitter::MakeExpression(uint32_t id) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
switch (inst->opcode()) {
|
switch (inst->opcode()) {
|
||||||
|
case SpvOpVariable:
|
||||||
|
// This occurs for module-scope variables.
|
||||||
|
return std::make_unique<ast::IdentifierExpression>(
|
||||||
|
namer_.Name(inst->result_id()));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -257,6 +257,28 @@ Assignment{
|
|||||||
)"));
|
)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) {
|
||||||
|
auto p = parser(test::Assemble(R"(
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%voidfn = OpTypeFunction %void
|
||||||
|
%ty = OpTypeInt 32 0
|
||||||
|
%val = OpConstant %ty 42
|
||||||
|
%ptr_ty = OpTypePointer Workgroup %ty
|
||||||
|
%1 = OpVariable %ptr_ty Workgroup
|
||||||
|
%100 = OpFunction %void None %voidfn
|
||||||
|
%entry = OpLabel
|
||||||
|
OpStore %1 %val
|
||||||
|
OpReturn
|
||||||
|
)"));
|
||||||
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
|
EXPECT_TRUE(fe.EmitBody());
|
||||||
|
EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{
|
||||||
|
Identifier{x_1}
|
||||||
|
ScalarConstructor{42}
|
||||||
|
})"));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
} // namespace reader
|
} // namespace reader
|
||||||
|
Loading…
x
Reference in New Issue
Block a user