1 //
2 // Copyright 2017 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 // Regardless of the shader type, the following AST transformations are applied:
7 // - Add declaration of View_ID_OVR.
8 // - Replace every occurrence of gl_ViewID_OVR with ViewID_OVR, mark ViewID_OVR as internal and
9 // declare it as a flat varying.
10 //
11 // If the shader type is a vertex shader, the following AST transformations are applied:
12 // - Replace every occurrence of gl_InstanceID with InstanceID, mark InstanceID as internal and set
13 // its qualifier to EvqTemporary.
14 // - Add initializers of ViewID_OVR and InstanceID to the beginning of the body of main. The pass
15 // should be executed before any variables get collected so that usage of gl_InstanceID is recorded.
16 // - If the output is ESSL or GLSL and the SH_SELECT_VIEW_IN_NV_GLSL_VERTEX_SHADER option is
17 // enabled, the expression
18 // "if (multiviewBaseViewLayerIndex < 0) {
19 //      gl_ViewportIndex = int(ViewID_OVR);
20 //  } else {
21 //      gl_Layer = int(ViewID_OVR) + multiviewBaseViewLayerIndex;
22 //  }"
23 // is added after ViewID and InstanceID are initialized. Also, MultiviewRenderPath is added as a
24 // uniform.
25 //
26 
27 #ifndef COMPILER_TRANSLATOR_TREEOPS_DECLAREANDINITBUILTINSFORINSTANCEDMULTIVIEW_H_
28 #define COMPILER_TRANSLATOR_TREEOPS_DECLAREANDINITBUILTINSFORINSTANCEDMULTIVIEW_H_
29 
30 #include "GLSLANG/ShaderLang.h"
31 #include "angle_gl.h"
32 #include "common/angleutils.h"
33 
34 namespace sh
35 {
36 
37 class TCompiler;
38 class TIntermBlock;
39 class TSymbolTable;
40 
41 ANGLE_NO_DISCARD bool DeclareAndInitBuiltinsForInstancedMultiview(TCompiler *compiler,
42                                                                   TIntermBlock *root,
43                                                                   unsigned numberOfViews,
44                                                                   GLenum shaderType,
45                                                                   ShCompileOptions compileOptions,
46                                                                   ShShaderOutput shaderOutput,
47                                                                   TSymbolTable *symbolTable);
48 
49 }  // namespace sh
50 
51 #endif  // COMPILER_TRANSLATOR_TREEOPS_DECLAREANDINITBUILTINSFORINSTANCEDMULTIVIEW_H_
52