[wgsl-writer] Generate decorations on function return types
Bug: tint:576 Change-Id: I60d046fb4db558daf52178600b962eaeb6d3f843 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44602 Commit-Queue: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
feecbe0d83
commit
cc193de025
|
@ -329,6 +329,13 @@ bool GeneratorImpl::EmitFunction(ast::Function* func) {
|
||||||
|
|
||||||
out_ << ") -> ";
|
out_ << ") -> ";
|
||||||
|
|
||||||
|
if (!func->return_type_decorations().empty()) {
|
||||||
|
if (!EmitDecorations(func->return_type_decorations())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
out_ << " ";
|
||||||
|
}
|
||||||
|
|
||||||
if (!EmitType(func->return_type())) {
|
if (!EmitType(func->return_type())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,6 +167,31 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_Parameters) {
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WgslGeneratorImplTest, Emit_Function_EntryPoint_ReturnValue) {
|
||||||
|
auto* func =
|
||||||
|
Func("frag_main", ast::VariableList{}, ty.f32(),
|
||||||
|
ast::StatementList{
|
||||||
|
create<ast::ReturnStatement>(Expr(1.f)),
|
||||||
|
},
|
||||||
|
ast::DecorationList{
|
||||||
|
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||||
|
},
|
||||||
|
ast::DecorationList{
|
||||||
|
create<ast::LocationDecoration>(1u),
|
||||||
|
});
|
||||||
|
|
||||||
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
|
gen.increment_indent();
|
||||||
|
|
||||||
|
ASSERT_TRUE(gen.EmitFunction(func));
|
||||||
|
EXPECT_EQ(gen.result(), R"( [[stage(fragment)]]
|
||||||
|
fn frag_main() -> [[location(1)]] f32 {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
}
|
||||||
|
|
||||||
// https://crbug.com/tint/297
|
// https://crbug.com/tint/297
|
||||||
TEST_F(WgslGeneratorImplTest,
|
TEST_F(WgslGeneratorImplTest,
|
||||||
Emit_Function_Multiple_EntryPoint_With_Same_ModuleVar) {
|
Emit_Function_Multiple_EntryPoint_With_Same_ModuleVar) {
|
||||||
|
|
Loading…
Reference in New Issue