xref: /aosp_15_r20/external/angle/src/compiler/translator/wgsl/Utils.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2024 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #ifndef COMPILER_TRANSLATOR_WGSL_UTILS_H_
8 #define COMPILER_TRANSLATOR_WGSL_UTILS_H_
9 
10 #include "compiler/translator/Common.h"
11 #include "compiler/translator/InfoSink.h"
12 #include "compiler/translator/IntermNode.h"
13 #include "compiler/translator/Types.h"
14 
15 namespace sh
16 {
17 
18 // Can be used with TSymbol or TField or TFunc.
19 template <typename StringStreamType, typename Object>
WriteNameOf(StringStreamType & output,const Object & namedObject)20 void WriteNameOf(StringStreamType &output, const Object &namedObject)
21 {
22     WriteNameOf(output, namedObject.symbolType(), namedObject.name());
23 }
24 
25 template <typename StringStreamType>
26 void WriteNameOf(StringStreamType &output, SymbolType symbolType, const ImmutableString &name);
27 template <typename StringStreamType>
28 void WriteWgslBareTypeName(StringStreamType &output, const TType &type);
29 template <typename StringStreamType>
30 void WriteWgslType(StringStreamType &output, const TType &type);
31 
32 using GlobalVars = TMap<ImmutableString, TIntermDeclaration *>;
33 GlobalVars FindGlobalVars(TIntermBlock *root);
34 
35 }  // namespace sh
36 
37 #endif  // COMPILER_TRANSLATOR_WGSL_UTILS_H_
38