1 //
2 // Copyright 2015 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 // CompilerGL:
7 // Implementation of the GL compiler methods.
8 //
9
10 #include "libANGLE/renderer/gl/CompilerGL.h"
11
12 #include "libANGLE/renderer/gl/FunctionsGL.h"
13
14 namespace rx
15 {
16
17 namespace
18 {
19
GetShaderOutputType(const FunctionsGL * functions)20 ShShaderOutput GetShaderOutputType(const FunctionsGL *functions)
21 {
22 ASSERT(functions);
23
24 if (functions->standard == STANDARD_GL_DESKTOP)
25 {
26 // GLSL outputs
27 if (functions->isAtLeastGL(gl::Version(4, 5)))
28 {
29 return SH_GLSL_450_CORE_OUTPUT;
30 }
31 else if (functions->isAtLeastGL(gl::Version(4, 4)))
32 {
33 return SH_GLSL_440_CORE_OUTPUT;
34 }
35 else if (functions->isAtLeastGL(gl::Version(4, 3)))
36 {
37 return SH_GLSL_430_CORE_OUTPUT;
38 }
39 else if (functions->isAtLeastGL(gl::Version(4, 2)))
40 {
41 return SH_GLSL_420_CORE_OUTPUT;
42 }
43 else if (functions->isAtLeastGL(gl::Version(4, 1)))
44 {
45 return SH_GLSL_410_CORE_OUTPUT;
46 }
47 else if (functions->isAtLeastGL(gl::Version(4, 0)))
48 {
49 return SH_GLSL_400_CORE_OUTPUT;
50 }
51 else if (functions->isAtLeastGL(gl::Version(3, 3)))
52 {
53 return SH_GLSL_330_CORE_OUTPUT;
54 }
55 else if (functions->isAtLeastGL(gl::Version(3, 2)))
56 {
57 return SH_GLSL_150_CORE_OUTPUT;
58 }
59 else if (functions->isAtLeastGL(gl::Version(3, 1)))
60 {
61 return SH_GLSL_140_OUTPUT;
62 }
63 else if (functions->isAtLeastGL(gl::Version(3, 0)))
64 {
65 return SH_GLSL_130_OUTPUT;
66 }
67 else
68 {
69 return SH_GLSL_COMPATIBILITY_OUTPUT;
70 }
71 }
72 else if (functions->standard == STANDARD_GL_ES)
73 {
74 // ESSL outputs
75 return SH_ESSL_OUTPUT;
76 }
77 else
78 {
79 UNREACHABLE();
80 return ShShaderOutput(0);
81 }
82 }
83
84 } // anonymous namespace
85
CompilerGL(const FunctionsGL * functions)86 CompilerGL::CompilerGL(const FunctionsGL *functions)
87 : mTranslatorOutputType(GetShaderOutputType(functions))
88 {}
89
getTranslatorOutputType() const90 ShShaderOutput CompilerGL::getTranslatorOutputType() const
91 {
92 return mTranslatorOutputType;
93 }
94
95 } // namespace rx
96