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

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

Issue 12330181: Checkpoint towards core profile support. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Checkpoint towards core profile support. Created 7 years, 9 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/GrGLCaps.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('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 2012 Google Inc. 2 * Copyright 2012 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 "gl/GrGLShaderBuilder.h" 8 #include "gl/GrGLShaderBuilder.h"
9 #include "gl/GrGLProgram.h" 9 #include "gl/GrGLProgram.h"
10 #include "gl/GrGLUniformHandle.h" 10 #include "gl/GrGLUniformHandle.h"
11 #include "GrTexture.h" 11 #include "GrTexture.h"
12 12
13 // number of each input/output type in a single allocation block 13 // number of each input/output type in a single allocation block
14 static const int kVarsPerBlock = 8; 14 static const int kVarsPerBlock = 8;
15 15
16 // except FS outputs where we expect 2 at most. 16 // except FS outputs where we expect 2 at most.
17 static const int kMaxFSOutputs = 2; 17 static const int kMaxFSOutputs = 2;
18 18
19 // ES2 FS only guarantees mediump and lowp support 19 // ES2 FS only guarantees mediump and lowp support
20 static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar: :kMedium_Precision; 20 static const GrGLShaderVar::Precision kDefaultFragmentPrecision = GrGLShaderVar: :kMedium_Precision;
21 21
22 typedef GrGLUniformManager::UniformHandle UniformHandle; 22 typedef GrGLUniformManager::UniformHandle UniformHandle;
23 /////////////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////////////
24 24
25 namespace { 25 namespace {
26 26
27 inline const char* sample_function_name(GrSLType type) { 27 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen) {
28 if (kVec2f_GrSLType == type) { 28 if (kVec2f_GrSLType == type) {
29 return "texture2D"; 29 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D";
30 } else { 30 } else {
31 GrAssert(kVec3f_GrSLType == type); 31 GrAssert(kVec3f_GrSLType == type);
32 return "texture2DProj"; 32 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj ";
33 } 33 }
34 } 34 }
35 35
36 /** 36 /**
37 * Do we need to either map r,g,b->a or a->r. 37 * Do we need to either map r,g,b->a or a->r.
38 */ 38 */
39 inline bool swizzle_requires_alpha_remapping(const GrGLCaps& caps, 39 inline bool swizzle_requires_alpha_remapping(const GrGLCaps& caps,
40 const GrTextureAccess& access) { 40 const GrTextureAccess& access) {
41 if (GrPixelConfigIsAlphaOnly(access.getTexture()->config())) { 41 if (GrPixelConfigIsAlphaOnly(access.getTexture()->config())) {
42 if (caps.textureRedSupport() && (GrTextureAccess::kA_SwizzleFlag & acces s.swizzleMask())) { 42 if (caps.textureRedSupport() && (GrTextureAccess::kA_SwizzleFlag & acces s.swizzleMask())) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 void GrGLShaderBuilder::appendTextureLookup(SkString* out, 104 void GrGLShaderBuilder::appendTextureLookup(SkString* out,
105 const GrGLShaderBuilder::TextureSamp ler& sampler, 105 const GrGLShaderBuilder::TextureSamp ler& sampler,
106 const char* coordName, 106 const char* coordName,
107 GrSLType varyingType) const { 107 GrSLType varyingType) const {
108 GrAssert(NULL != sampler.textureAccess()); 108 GrAssert(NULL != sampler.textureAccess());
109 GrAssert(NULL != coordName); 109 GrAssert(NULL != coordName);
110 110
111 out->appendf("%s(%s, %s)", 111 out->appendf("%s(%s, %s)",
112 sample_function_name(varyingType), 112 sample_function_name(varyingType, fCtxInfo.glslGeneration()),
113 this->getUniformCStr(sampler.fSamplerUniform), 113 this->getUniformCStr(sampler.fSamplerUniform),
114 coordName); 114 coordName);
115 append_swizzle(out, *sampler.textureAccess(), fCtxInfo.caps()); 115 append_swizzle(out, *sampler.textureAccess(), fCtxInfo.caps());
116 } 116 }
117 117
118 void GrGLShaderBuilder::appendTextureLookupAndModulate( 118 void GrGLShaderBuilder::appendTextureLookupAndModulate(
119 SkString* out, 119 SkString* out,
120 const char* modulation, 120 const char* modulation,
121 const GrGLShaderBuilder::TextureSamp ler& sampler, 121 const GrGLShaderBuilder::TextureSamp ler& sampler,
122 const char* coordName, 122 const char* coordName,
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 key, 455 key,
456 vsInCoord, 456 vsInCoord,
457 fsOutColor, 457 fsOutColor,
458 fsInColor, 458 fsInColor,
459 textureSamplers); 459 textureSamplers);
460 this->fVSCode.appendf("\t}\n"); 460 this->fVSCode.appendf("\t}\n");
461 this->fFSCode.appendf("\t}\n"); 461 this->fFSCode.appendf("\t}\n");
462 462
463 return glEffect; 463 return glEffect;
464 } 464 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | src/gpu/gl/GrGpuGL.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698