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

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

Issue 661603009: Revert of Support GLSL es 3.00 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/GrGLShaderVar.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 bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) { 12 bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
13 SkASSERT(generation); 13 SkASSERT(generation);
14 GrGLSLVersion ver = GrGLGetGLSLVersion(gl); 14 GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
15 if (GR_GLSL_INVALID_VER == ver) { 15 if (GR_GLSL_INVALID_VER == ver) {
16 return false; 16 return false;
17 } 17 }
18 switch (gl->fStandard) { 18 switch (gl->fStandard) {
19 case kGL_GrGLStandard: 19 case kGL_GrGLStandard:
20 SkASSERT(ver >= GR_GLSL_VER(1,10)); 20 SkASSERT(ver >= GR_GLSL_VER(1,10));
21 if (ver >= GR_GLSL_VER(3,30)) { 21 if (ver >= GR_GLSL_VER(1,50)) {
22 *generation = k330_GrGLSLGeneration;
23 } else if (ver >= GR_GLSL_VER(1,50)) {
24 *generation = k150_GrGLSLGeneration; 22 *generation = k150_GrGLSLGeneration;
25 } else if (ver >= GR_GLSL_VER(1,40)) { 23 } else if (ver >= GR_GLSL_VER(1,40)) {
26 *generation = k140_GrGLSLGeneration; 24 *generation = k140_GrGLSLGeneration;
27 } else if (ver >= GR_GLSL_VER(1,30)) { 25 } else if (ver >= GR_GLSL_VER(1,30)) {
28 *generation = k130_GrGLSLGeneration; 26 *generation = k130_GrGLSLGeneration;
29 } else { 27 } else {
30 *generation = k110_GrGLSLGeneration; 28 *generation = k110_GrGLSLGeneration;
31 } 29 }
32 return true; 30 return true;
33 case kGLES_GrGLStandard: 31 case kGLES_GrGLStandard:
32 // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL
34 SkASSERT(ver >= GR_GL_VER(1,00)); 33 SkASSERT(ver >= GR_GL_VER(1,00));
35 if (ver >= GR_GLSL_VER(3,1)) { 34 *generation = k110_GrGLSLGeneration;
36 *generation = k310es_GrGLSLGeneration;
37 }
38 else if (ver >= GR_GLSL_VER(3,0)) {
39 *generation = k330_GrGLSLGeneration;
40 } else {
41 *generation = k110_GrGLSLGeneration;
42 }
43 return true; 35 return true;
44 default: 36 default:
45 SkFAIL("Unknown GL Standard"); 37 SkFAIL("Unknown GL Standard");
46 return false; 38 return false;
47 } 39 }
48 } 40 }
49 41
50 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) { 42 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) {
51 switch (info.glslGeneration()) { 43 switch (info.glslGeneration()) {
52 case k110_GrGLSLGeneration: 44 case k110_GrGLSLGeneration:
(...skipping 11 matching lines...) Expand all
64 case k140_GrGLSLGeneration: 56 case k140_GrGLSLGeneration:
65 SkASSERT(kGL_GrGLStandard == info.standard()); 57 SkASSERT(kGL_GrGLStandard == info.standard());
66 return "#version 140\n"; 58 return "#version 140\n";
67 case k150_GrGLSLGeneration: 59 case k150_GrGLSLGeneration:
68 SkASSERT(kGL_GrGLStandard == info.standard()); 60 SkASSERT(kGL_GrGLStandard == info.standard());
69 if (info.caps()->isCoreProfile()) { 61 if (info.caps()->isCoreProfile()) {
70 return "#version 150\n"; 62 return "#version 150\n";
71 } else { 63 } else {
72 return "#version 150 compatibility\n"; 64 return "#version 150 compatibility\n";
73 } 65 }
74 case k330_GrGLSLGeneration:
75 if (kGLES_GrGLStandard == info.standard()) {
76 return "#version 300 es\n";
77 } else {
78 SkASSERT(kGL_GrGLStandard == info.standard());
79 return "#version 330 compatibility\n";
80 }
81 case k310es_GrGLSLGeneration:
82 SkASSERT(kGLES_GrGLStandard == info.standard());
83 return "#version 310 es\n";
84 default: 66 default:
85 SkFAIL("Unknown GL version."); 67 SkFAIL("Unknown GL version.");
86 return ""; // suppress warning 68 return ""; // suppress warning
87 } 69 }
88 } 70 }
89 71
90 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL Expr4& mulFactor) { 72 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL Expr4& mulFactor) {
91 if (mulFactor.isOnes()) { 73 if (mulFactor.isOnes()) {
92 *outAppend = SkString(); 74 *outAppend = SkString();
93 } 75 }
94 76
95 if (mulFactor.isZeros()) { 77 if (mulFactor.isZeros()) {
96 outAppend->appendf("%s = vec4(0);", vec4VarName); 78 outAppend->appendf("%s = vec4(0);", vec4VarName);
97 } else { 79 } else {
98 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); 80 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str());
99 } 81 }
100 } 82 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLSL.h ('k') | src/gpu/gl/GrGLShaderVar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698