Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: src/gpu/gl/GrGLSL.cpp

Issue 12668019: Make GrGLShaderBuilder responsible for enabling GLSL extensions (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: sync to TOT Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 11
12 GrGLSLGeneration GrGetGLSLGeneration(GrGLBinding binding, 12 GrGLSLGeneration GrGetGLSLGeneration(GrGLBinding binding, const GrGLInterface* g l) {
13 const GrGLInterface* gl) {
14 GrGLSLVersion ver = GrGLGetGLSLVersion(gl); 13 GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
15 switch (binding) { 14 switch (binding) {
16 case kDesktop_GrGLBinding: 15 case kDesktop_GrGLBinding:
17 GrAssert(ver >= GR_GLSL_VER(1,10)); 16 GrAssert(ver >= GR_GLSL_VER(1,10));
18 if (ver >= GR_GLSL_VER(1,50)) { 17 if (ver >= GR_GLSL_VER(1,50)) {
19 return k150_GrGLSLGeneration; 18 return k150_GrGLSLGeneration;
20 } else if (ver >= GR_GLSL_VER(1,40)) { 19 } else if (ver >= GR_GLSL_VER(1,40)) {
21 return k140_GrGLSLGeneration; 20 return k140_GrGLSLGeneration;
22 } else if (ver >= GR_GLSL_VER(1,30)) { 21 } else if (ver >= GR_GLSL_VER(1,30)) {
23 return k130_GrGLSLGeneration; 22 return k130_GrGLSLGeneration;
24 } else { 23 } else {
25 return k110_GrGLSLGeneration; 24 return k110_GrGLSLGeneration;
26 } 25 }
27 case kES2_GrGLBinding: 26 case kES2_GrGLBinding:
28 // 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
29 GrAssert(ver >= GR_GL_VER(1,00)); 28 GrAssert(ver >= GR_GL_VER(1,00));
30 return k110_GrGLSLGeneration; 29 return k110_GrGLSLGeneration;
31 default: 30 default:
32 GrCrash("Unknown GL Binding"); 31 GrCrash("Unknown GL Binding");
33 return k110_GrGLSLGeneration; // suppress warning 32 return k110_GrGLSLGeneration; // suppress warning
34 } 33 }
35 } 34 }
36 35
37 const char* GrGetGLSLVersionDecl(GrGLBinding binding, 36 const char* GrGetGLSLVersionDecl(GrGLBinding binding, GrGLSLGeneration gen) {
38 GrGLSLGeneration gen) {
39 switch (gen) { 37 switch (gen) {
40 case k110_GrGLSLGeneration: 38 case k110_GrGLSLGeneration:
41 if (kES2_GrGLBinding == binding) { 39 if (kES2_GrGLBinding == binding) {
42 // 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
43 // 1.00 of the ES language. 41 // 1.00 of the ES language.
44 return "#version 100\n"; 42 return "#version 100\n";
45 } else { 43 } else {
46 GrAssert(kDesktop_GrGLBinding == binding); 44 GrAssert(kDesktop_GrGLBinding == binding);
47 return "#version 110\n"; 45 return "#version 110\n";
48 } 46 }
49 case k130_GrGLSLGeneration: 47 case k130_GrGLSLGeneration:
50 GrAssert(kDesktop_GrGLBinding == binding); 48 GrAssert(kDesktop_GrGLBinding == binding);
51 return "#version 130\n"; 49 return "#version 130\n";
52 case k140_GrGLSLGeneration: 50 case k140_GrGLSLGeneration:
53 GrAssert(kDesktop_GrGLBinding == binding); 51 GrAssert(kDesktop_GrGLBinding == binding);
54 return "#version 140\n"; 52 return "#version 140\n";
55 case k150_GrGLSLGeneration: 53 case k150_GrGLSLGeneration:
56 GrAssert(kDesktop_GrGLBinding == binding); 54 GrAssert(kDesktop_GrGLBinding == binding);
57 return "#version 150\n"; 55 return "#version 150\n";
58 default: 56 default:
59 GrCrash("Unknown GL version."); 57 GrCrash("Unknown GL version.");
60 return ""; // suppress warning 58 return ""; // suppress warning
61 } 59 }
62 } 60 }
63 61
64 bool GrGLSLSetupFSColorOuput(GrGLSLGeneration gen, 62 bool GrGLSLSetupFSColorOuput(GrGLSLGeneration gen, const char* nameIfDeclared, G rGLShaderVar* var) {
65 const char* nameIfDeclared,
66 GrGLShaderVar* var) {
67 bool declaredOutput = k110_GrGLSLGeneration != gen; 63 bool declaredOutput = k110_GrGLSLGeneration != gen;
68 var->set(kVec4f_GrSLType, 64 var->set(kVec4f_GrSLType,
69 GrGLShaderVar::kOut_TypeModifier, 65 GrGLShaderVar::kOut_TypeModifier,
70 declaredOutput ? nameIfDeclared : "gl_FragColor"); 66 declaredOutput ? nameIfDeclared : "gl_FragColor");
71 return declaredOutput; 67 return declaredOutput;
72 } 68 }
73 69
74 GrSLType GrSLFloatVectorType (int count) { 70 GrSLType GrSLFloatVectorType (int count) {
75 GR_STATIC_ASSERT(kFloat_GrSLType == 1); 71 GR_STATIC_ASSERT(kFloat_GrSLType == 1);
76 GR_STATIC_ASSERT(kVec2f_GrSLType == 2); 72 GR_STATIC_ASSERT(kVec2f_GrSLType == 2);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return kNone_GrSLConstantVec; 202 return kNone_GrSLConstantVec;
207 } else if (!has1) { 203 } else if (!has1) {
208 GrAssert(kZeros_GrSLConstantVec == default1); 204 GrAssert(kZeros_GrSLConstantVec == default1);
209 outAppend->appendf("vec4(%s)", in0); 205 outAppend->appendf("vec4(%s)", in0);
210 return kNone_GrSLConstantVec; 206 return kNone_GrSLConstantVec;
211 } else { 207 } else {
212 outAppend->appendf("(vec4(%s) + vec4(%s))", in0, in1); 208 outAppend->appendf("(vec4(%s) + vec4(%s))", in0, in1);
213 return kNone_GrSLConstantVec; 209 return kNone_GrSLConstantVec;
214 } 210 }
215 } 211 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLProgram.cpp ('k') | src/gpu/gl/GrGLShaderBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698