Hash :
18fa02be
Author :
Date :
2024-03-12T10:23:55
Rewrite exprs using separated decl variables
Rewrite expressions that use the rewritten struct declaration variables.
Declaration that specfies a struct and defines multiple variables will
get its variable declarations separated. The type of the variable
changes when a struct specifier is removed for the second and rest of
the variable declarations. The type of the variable changes also when a
anonymous struct is named.
The expressions that used the separated variables used the old struct as
their types.
Fix by using TIntermRebuild. Upon creating a new symbol node referencing
the new type, the rebuilder will instantiate also all the needed
intermediate nodes, which then get the correct struct type.
For consistency, fix the case of anonymous struct -> named struct
transform naming the variables similar to named struct separation.
Consider base case:
struct S { .. } a, b; -> struct S { .. } a; S b;
Compare against case:
struct { .. } a, b;
Before, inconsistency:
struct s1 { .. }; s1 a; s1 b;
After, fixed:
struct s1 { .. } a; s1 b;
Bug: angleproject:8590
Change-Id: Iffb0ef4441d6021e076b04485b808b26a7fa4dcb
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5365201
Auto-Submit: Kimmo Kinnunen <kkinnunen@apple.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef COMPILER_TRANSLATOR_TREEOPS_MSL_REDUCEINTERFACEBLOCKS_H_
#define COMPILER_TRANSLATOR_TREEOPS_MSL_REDUCEINTERFACEBLOCKS_H_
#include "common/angleutils.h"
#include "compiler/translator/Compiler.h"
namespace sh
{
class TSymbolTable;
// This rewrites interface block declarations only.
//
// Access of interface blocks is not rewritten (e.g. TOperator::EOpIndexDirectInterfaceBlock). //
// XXX: ^ Still true?
//
// Example:
// uniform Foo { int x; };
// Becomes:
// uniform int x;
//
// Example:
// uniform Foo { int x; } foo;
// Becomes:
// struct Foo { int x; }; uniform Foo x;
//
[[nodiscard]] bool ReduceInterfaceBlocks(TCompiler &compiler, TIntermBlock &root, IdGen &idGen);
} // namespace sh
#endif // COMPILER_TRANSLATOR_TREEOPS_MSL_REDUCEINTERFACEBLOCKS_H_