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

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

Issue 659443007: Support GLSL es 3.00 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: nvpr fix 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(1,50)) { 21 if (ver >= GR_GLSL_VER(3,30)) {
22 *generation = k330_GrGLSLGeneration;
23 } else if (ver >= GR_GLSL_VER(1,50)) {
22 *generation = k150_GrGLSLGeneration; 24 *generation = k150_GrGLSLGeneration;
23 } else if (ver >= GR_GLSL_VER(1,40)) { 25 } else if (ver >= GR_GLSL_VER(1,40)) {
24 *generation = k140_GrGLSLGeneration; 26 *generation = k140_GrGLSLGeneration;
25 } else if (ver >= GR_GLSL_VER(1,30)) { 27 } else if (ver >= GR_GLSL_VER(1,30)) {
26 *generation = k130_GrGLSLGeneration; 28 *generation = k130_GrGLSLGeneration;
27 } else { 29 } else {
28 *generation = k110_GrGLSLGeneration; 30 *generation = k110_GrGLSLGeneration;
29 } 31 }
30 return true; 32 return true;
31 case kGLES_GrGLStandard: 33 case kGLES_GrGLStandard:
32 // version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL
33 SkASSERT(ver >= GR_GL_VER(1,00)); 34 SkASSERT(ver >= GR_GL_VER(1,00));
34 *generation = k110_GrGLSLGeneration; 35 if (ver >= GR_GLSL_VER(3,1)) {
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 }
35 return true; 43 return true;
36 default: 44 default:
37 SkFAIL("Unknown GL Standard"); 45 SkFAIL("Unknown GL Standard");
38 return false; 46 return false;
39 } 47 }
40 } 48 }
41 49
42 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) { 50 const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) {
43 switch (info.glslGeneration()) { 51 switch (info.glslGeneration()) {
44 case k110_GrGLSLGeneration: 52 case k110_GrGLSLGeneration:
(...skipping 11 matching lines...) Expand all
56 case k140_GrGLSLGeneration: 64 case k140_GrGLSLGeneration:
57 SkASSERT(kGL_GrGLStandard == info.standard()); 65 SkASSERT(kGL_GrGLStandard == info.standard());
58 return "#version 140\n"; 66 return "#version 140\n";
59 case k150_GrGLSLGeneration: 67 case k150_GrGLSLGeneration:
60 SkASSERT(kGL_GrGLStandard == info.standard()); 68 SkASSERT(kGL_GrGLStandard == info.standard());
61 if (info.caps()->isCoreProfile()) { 69 if (info.caps()->isCoreProfile()) {
62 return "#version 150\n"; 70 return "#version 150\n";
63 } else { 71 } else {
64 return "#version 150 compatibility\n"; 72 return "#version 150 compatibility\n";
65 } 73 }
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";
66 default: 84 default:
67 SkFAIL("Unknown GL version."); 85 SkFAIL("Unknown GL version.");
68 return ""; // suppress warning 86 return ""; // suppress warning
69 } 87 }
70 } 88 }
71 89
72 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL Expr4& mulFactor) { 90 void GrGLSLMulVarBy4f(SkString* outAppend, const char* vec4VarName, const GrGLSL Expr4& mulFactor) {
73 if (mulFactor.isOnes()) { 91 if (mulFactor.isOnes()) {
74 *outAppend = SkString(); 92 *outAppend = SkString();
75 } 93 }
76 94
77 if (mulFactor.isZeros()) { 95 if (mulFactor.isZeros()) {
78 outAppend->appendf("%s = vec4(0);", vec4VarName); 96 outAppend->appendf("%s = vec4(0);", vec4VarName);
79 } else { 97 } else {
80 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str()); 98 outAppend->appendf("%s *= %s;", vec4VarName, mulFactor.c_str());
81 } 99 }
82 } 100 }
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