OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrGLSL.h" | 8 #include "GrGLSL.h" |
9 #include "GrGLShaderVar.h" | 9 #include "GrGLShaderVar.h" |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 case kES_GrGLBinding: | 26 case kES_GrGLBinding: |
27 // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL | 27 // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL |
28 SkASSERT(ver >= GR_GL_VER(1,00)); | 28 SkASSERT(ver >= GR_GL_VER(1,00)); |
29 return k110_GrGLSLGeneration; | 29 return k110_GrGLSLGeneration; |
30 default: | 30 default: |
31 GrCrash("Unknown GL Binding"); | 31 GrCrash("Unknown GL Binding"); |
32 return k110_GrGLSLGeneration; // suppress warning | 32 return k110_GrGLSLGeneration; // suppress warning |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 const char* GrGetGLSLVersionDecl(GrGLBinding binding, GrGLSLGeneration gen) { | 36 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) { |
37 switch (gen) { | 37 switch (info.glslGeneration()) { |
38 case k110_GrGLSLGeneration: | 38 case k110_GrGLSLGeneration: |
39 if (kES_GrGLBinding == binding) { | 39 if (kES_GrGLBinding == info.binding()) { |
40 // ES2s shader language is based on version 1.20 but is version | 40 // ES2s shader language is based on version 1.20 but is version |
41 // 1.00 of the ES language. | 41 // 1.00 of the ES language. |
42 return "#version 100\n"; | 42 return "#version 100\n"; |
43 } else { | 43 } else { |
44 SkASSERT(kDesktop_GrGLBinding == binding); | 44 SkASSERT(kDesktop_GrGLBinding == info.binding()); |
45 return "#version 110\n"; | 45 return "#version 110\n"; |
46 } | 46 } |
47 case k130_GrGLSLGeneration: | 47 case k130_GrGLSLGeneration: |
48 SkASSERT(kDesktop_GrGLBinding == binding); | 48 SkASSERT(kDesktop_GrGLBinding == info.binding()); |
49 return "#version 130\n"; | 49 return "#version 130\n"; |
50 case k140_GrGLSLGeneration: | 50 case k140_GrGLSLGeneration: |
51 SkASSERT(kDesktop_GrGLBinding == binding); | 51 SkASSERT(kDesktop_GrGLBinding == info.binding()); |
52 return "#version 140\n"; | 52 return "#version 140\n"; |
53 case k150_GrGLSLGeneration: | 53 case k150_GrGLSLGeneration: |
54 SkASSERT(kDesktop_GrGLBinding == binding); | 54 SkASSERT(kDesktop_GrGLBinding == info.binding()); |
55 return "#version 150\n"; | 55 if (info.caps()->isCoreProfile()) { |
| 56 return "#version 150\n"; |
| 57 } else { |
| 58 return "#version 150 compatibility\n"; |
| 59 } |
56 default: | 60 default: |
57 GrCrash("Unknown GL version."); | 61 GrCrash("Unknown GL version."); |
58 return ""; // suppress warning | 62 return ""; // suppress warning |
59 } | 63 } |
60 } | 64 } |
61 | 65 |
62 bool GrGLSLSetupFSColorOuput(GrGLSLGeneration gen, const char* nameIfDeclared, G
rGLShaderVar* var) { | 66 bool GrGLSLSetupFSColorOuput(GrGLSLGeneration gen, const char* nameIfDeclared, G
rGLShaderVar* var) { |
63 bool declaredOutput = k110_GrGLSLGeneration != gen; | 67 bool declaredOutput = k110_GrGLSLGeneration != gen; |
64 var->set(kVec4f_GrSLType, | 68 var->set(kVec4f_GrSLType, |
65 GrGLShaderVar::kOut_TypeModifier, | 69 GrGLShaderVar::kOut_TypeModifier, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 SkASSERT(kZeros_GrSLConstantVec == defaultExpr); | 142 SkASSERT(kZeros_GrSLConstantVec == defaultExpr); |
139 outAppend->append("0.0"); | 143 outAppend->append("0.0"); |
140 } | 144 } |
141 } | 145 } |
142 return defaultExpr; | 146 return defaultExpr; |
143 } else { | 147 } else { |
144 outAppend->appendf("(%s).%c", expr, GrColorComponentFlagToChar(component
)); | 148 outAppend->appendf("(%s).%c", expr, GrColorComponentFlagToChar(component
)); |
145 return kNone_GrSLConstantVec; | 149 return kNone_GrSLConstantVec; |
146 } | 150 } |
147 } | 151 } |
OLD | NEW |