• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2021 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 // MonomorphizeUnsupportedFunctions: Monomorphize functions that are called with
7 // parameters that are incompatible with both Vulkan GLSL and Metal:
8 //
9 // - Samplers in structs
10 // - Structs that have samplers
11 // - Partially subscripted array of array of samplers
12 // - Partially subscripted array of array of images
13 // - Atomic counters
14 // - samplerCube variables when emulating ES2's cube map sampling
15 // - image* variables with r32f formats (to emulate imageAtomicExchange)
16 //
17 // This transformation basically duplicates such functions, removes the
18 // sampler/image/atomic_counter parameters and uses the opaque uniforms used by the caller.
19 
20 #ifndef COMPILER_TRANSLATOR_TREEOPS_MONOMORPHIZEUNSUPPORTEDFUNCTIONS_H_
21 #define COMPILER_TRANSLATOR_TREEOPS_MONOMORPHIZEUNSUPPORTEDFUNCTIONS_H_
22 
23 #include "common/angleutils.h"
24 #include "compiler/translator/Compiler.h"
25 
26 namespace sh
27 {
28 class TIntermBlock;
29 class TSymbolTable;
30 
31 // Types of function prameters that should trigger monomorphization.
32 enum class UnsupportedFunctionArgs
33 {
34     StructContainingSamplers     = 0,
35     ArrayOfArrayOfSamplerOrImage = 1,
36     AtomicCounter                = 2,
37     SamplerCubeEmulation         = 3,
38     Image                        = 4,
39     PixelLocalStorage            = 5,
40 
41     InvalidEnum = 6,
42     EnumCount   = 6,
43 };
44 
45 using UnsupportedFunctionArgsBitSet = angle::PackedEnumBitSet<UnsupportedFunctionArgs>;
46 
47 [[nodiscard]] bool MonomorphizeUnsupportedFunctions(TCompiler *compiler,
48                                                     TIntermBlock *root,
49                                                     TSymbolTable *symbolTable,
50                                                     const ShCompileOptions &compileOptions,
51                                                     UnsupportedFunctionArgsBitSet);
52 }  // namespace sh
53 
54 #endif  // COMPILER_TRANSLATOR_TREEOPS_MONOMORPHIZEUNSUPPORTEDFUNCTIONS_H_
55