Line data Source code
1 : //
2 : // Copyright (c) 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 : // ExtensionGLSL.cpp: Implements the TExtensionGLSL class that tracks GLSL extension requirements
7 : // of shaders.
8 :
9 : #include "compiler/translator/ExtensionGLSL.h"
10 :
11 : #include "compiler/translator/VersionGLSL.h"
12 :
13 : namespace sh
14 : {
15 :
16 0 : TExtensionGLSL::TExtensionGLSL(ShShaderOutput output)
17 0 : : TIntermTraverser(true, false, false), mTargetVersion(ShaderOutputTypeToGLSLVersion(output))
18 : {
19 0 : }
20 :
21 0 : const std::set<std::string> &TExtensionGLSL::getEnabledExtensions() const
22 : {
23 0 : return mEnabledExtensions;
24 : }
25 :
26 0 : const std::set<std::string> &TExtensionGLSL::getRequiredExtensions() const
27 : {
28 0 : return mRequiredExtensions;
29 : }
30 :
31 0 : bool TExtensionGLSL::visitUnary(Visit, TIntermUnary *node)
32 : {
33 0 : checkOperator(node);
34 :
35 0 : return true;
36 : }
37 :
38 0 : bool TExtensionGLSL::visitAggregate(Visit, TIntermAggregate *node)
39 : {
40 0 : checkOperator(node);
41 :
42 0 : return true;
43 : }
44 :
45 0 : void TExtensionGLSL::checkOperator(TIntermOperator *node)
46 : {
47 0 : if (mTargetVersion < GLSL_VERSION_130)
48 : {
49 0 : return;
50 : }
51 :
52 0 : switch (node->getOp())
53 : {
54 : case EOpAbs:
55 0 : break;
56 :
57 : case EOpSign:
58 0 : break;
59 :
60 : case EOpMix:
61 0 : break;
62 :
63 : case EOpFloatBitsToInt:
64 : case EOpFloatBitsToUint:
65 : case EOpIntBitsToFloat:
66 : case EOpUintBitsToFloat:
67 0 : if (mTargetVersion < GLSL_VERSION_330)
68 : {
69 : // Bit conversion functions cannot be emulated.
70 0 : mRequiredExtensions.insert("GL_ARB_shader_bit_encoding");
71 : }
72 0 : break;
73 :
74 : case EOpPackSnorm2x16:
75 : case EOpPackHalf2x16:
76 : case EOpUnpackSnorm2x16:
77 : case EOpUnpackHalf2x16:
78 0 : if (mTargetVersion < GLSL_VERSION_420)
79 : {
80 0 : mEnabledExtensions.insert("GL_ARB_shading_language_packing");
81 :
82 0 : if (mTargetVersion < GLSL_VERSION_330)
83 : {
84 : // floatBitsToUint and uintBitsToFloat are needed to emulate
85 : // packHalf2x16 and unpackHalf2x16 respectively and cannot be
86 : // emulated themselves.
87 0 : mRequiredExtensions.insert("GL_ARB_shader_bit_encoding");
88 : }
89 : }
90 0 : break;
91 :
92 : case EOpPackUnorm2x16:
93 : case EOpUnpackUnorm2x16:
94 0 : if (mTargetVersion < GLSL_VERSION_410)
95 : {
96 0 : mEnabledExtensions.insert("GL_ARB_shading_language_packing");
97 : }
98 0 : break;
99 :
100 : default:
101 0 : break;
102 : }
103 : }
104 :
105 : } // namespace sh
|