From 1e896001e6b95f586bf3aee55a8fa46b01e96d3e Mon Sep 17 00:00:00 2001 From: Stephen White Date: Thu, 21 Oct 2021 20:43:15 +0000 Subject: [PATCH] GLSL: Don't use a typedef for array returns. Covered by GlslGeneratorImplTest_Function.Emit_Function_WithArrayReturn Bug: tint:1258 Change-Id: I181641ebe170ec359d9833e9022e6e70747fde9a Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67240 Reviewed-by: Ben Clayton Kokoro: Kokoro Commit-Queue: Stephen White --- src/writer/glsl/generator_impl.cc | 20 +++---------------- .../glsl/generator_impl_function_test.cc | 3 +-- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc index e9f23195dc..10be79e72b 100644 --- a/src/writer/glsl/generator_impl.cc +++ b/src/writer/glsl/generator_impl.cc @@ -1465,23 +1465,9 @@ bool GeneratorImpl::EmitFunction(const ast::Function* func) { { auto out = line(); auto name = builder_.Symbols().NameFor(func->symbol); - // If the function returns an array, then we need to declare a typedef for - // this. - if (sem->ReturnType()->Is()) { - auto typedef_name = UniqueIdentifier(name + "_ret"); - auto pre = line(); - pre << "typedef "; - if (!EmitTypeAndName(pre, sem->ReturnType(), ast::StorageClass::kNone, - ast::Access::kReadWrite, typedef_name)) { - return false; - } - pre << ";"; - out << typedef_name; - } else { - if (!EmitType(out, sem->ReturnType(), ast::StorageClass::kNone, - ast::Access::kReadWrite, "")) { - return false; - } + if (!EmitType(out, sem->ReturnType(), ast::StorageClass::kNone, + ast::Access::kReadWrite, "")) { + return false; } out << " " << name << "("; diff --git a/src/writer/glsl/generator_impl_function_test.cc b/src/writer/glsl/generator_impl_function_test.cc index 6f36da43e9..f0a4406c48 100644 --- a/src/writer/glsl/generator_impl_function_test.cc +++ b/src/writer/glsl/generator_impl_function_test.cc @@ -999,8 +999,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Function_WithArrayReturn) { EXPECT_EQ(gen.result(), R"(#version 310 es precision mediump float; -typedef float my_func_ret[5]; -my_func_ret my_func() { +float[5] my_func() { return float[5](0.0f, 0.0f, 0.0f, 0.0f, 0.0f); } )");