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

Side by Side Diff: src/gpu/glsl/GrGLSLShaderBuilder.cpp

Issue 1862373003: Rename EmitArgs::fSamplers to fTexSamplers (Closed) Base URL: https://skia.googlesource.com/skia.git@upload3_infer
Patch Set: rebase Created 4 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
« no previous file with comments | « src/gpu/glsl/GrGLSLShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLTextureSampler.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 2014 Google Inc. 2 * Copyright 2014 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 "GrSwizzle.h" 8 #include "GrSwizzle.h"
9 #include "glsl/GrGLSLShaderBuilder.h" 9 #include "glsl/GrGLSLShaderBuilder.h"
10 #include "glsl/GrGLSLCaps.h" 10 #include "glsl/GrGLSLCaps.h"
11 #include "glsl/GrGLSLShaderVar.h" 11 #include "glsl/GrGLSLShaderVar.h"
12 #include "glsl/GrGLSLTextureSampler.h" 12 #include "glsl/GrGLSLSampler.h"
13 #include "glsl/GrGLSLProgramBuilder.h" 13 #include "glsl/GrGLSLProgramBuilder.h"
14 14
15 GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program) 15 GrGLSLShaderBuilder::GrGLSLShaderBuilder(GrGLSLProgramBuilder* program)
16 : fProgramBuilder(program) 16 : fProgramBuilder(program)
17 , fInputs(GrGLSLProgramBuilder::kVarsPerBlock) 17 , fInputs(GrGLSLProgramBuilder::kVarsPerBlock)
18 , fOutputs(GrGLSLProgramBuilder::kVarsPerBlock) 18 , fOutputs(GrGLSLProgramBuilder::kVarsPerBlock)
19 , fFeaturesAddedMask(0) 19 , fFeaturesAddedMask(0)
20 , fCodeIndex(kCode) 20 , fCodeIndex(kCode)
21 , fFinalized(false) { 21 , fFinalized(false) {
22 // We push back some dummy pointers which will later become our header 22 // We push back some dummy pointers which will later become our header
(...skipping 27 matching lines...) Expand all
50 if (i < argCnt - 1) { 50 if (i < argCnt - 1) {
51 this->functions().append(", "); 51 this->functions().append(", ");
52 } 52 }
53 } 53 }
54 this->functions().append(") {\n"); 54 this->functions().append(") {\n");
55 this->functions().append(body); 55 this->functions().append(body);
56 this->functions().append("}\n\n"); 56 this->functions().append("}\n\n");
57 } 57 }
58 58
59 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, 59 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
60 const GrGLSLTextureSampler& sample r, 60 const GrGLSLSampler& sampler,
61 const char* coordName, 61 const char* coordName,
62 GrSLType varyingType) const { 62 GrSLType varyingType) const {
63 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); 63 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
64 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler(); 64 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler();
65 GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUn iform).getType(); 65 GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUn iform).getType();
66 if (samplerType == kSampler2DRect_GrSLType) { 66 if (samplerType == kSampler2DRect_GrSLType) {
67 if (varyingType == kVec2f_GrSLType) { 67 if (varyingType == kVec2f_GrSLType) {
68 out->appendf("%s(%s, textureSize(%s) * %s)", 68 out->appendf("%s(%s, textureSize(%s) * %s)",
69 GrGLSLTexture2DFunctionName(varyingType, samplerType, 69 GrGLSLTexture2DFunctionName(varyingType, samplerType,
70 glslCaps->generation()), 70 glslCaps->generation()),
(...skipping 19 matching lines...) Expand all
90 // This refers to any swizzling we may need to get from some backend interna l format to the 90 // This refers to any swizzling we may need to get from some backend interna l format to the
91 // format used in GrPixelConfig. If this is implemented by the GrGpu object, then swizzle will 91 // format used in GrPixelConfig. If this is implemented by the GrGpu object, then swizzle will
92 // be rgba. For shader prettiness we omit the swizzle rather than appending ".rgba". 92 // be rgba. For shader prettiness we omit the swizzle rather than appending ".rgba".
93 const GrSwizzle& configSwizzle = glslCaps->configTextureSwizzle(sampler.conf ig()); 93 const GrSwizzle& configSwizzle = glslCaps->configTextureSwizzle(sampler.conf ig());
94 94
95 if (configSwizzle != GrSwizzle::RGBA()) { 95 if (configSwizzle != GrSwizzle::RGBA()) {
96 out->appendf(".%s", configSwizzle.c_str()); 96 out->appendf(".%s", configSwizzle.c_str());
97 } 97 }
98 } 98 }
99 99
100 void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLTextureSampler& sample r, 100 void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLSampler& sampler,
101 const char* coordName, 101 const char* coordName,
102 GrSLType varyingType) { 102 GrSLType varyingType) {
103 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType); 103 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType);
104 } 104 }
105 105
106 void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation, 106 void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation,
107 const GrGLSLTextureSamp ler& sampler, 107 const GrGLSLSampler& sa mpler,
108 const char* coordName, 108 const char* coordName,
109 GrSLType varyingType) { 109 GrSLType varyingType) {
110 SkString lookup; 110 SkString lookup;
111 this->appendTextureLookup(&lookup, sampler, coordName, varyingType); 111 this->appendTextureLookup(&lookup, sampler, coordName, varyingType);
112 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); 112 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
113 } 113 }
114 114
115 bool GrGLSLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionN ame) { 115 bool GrGLSLShaderBuilder::addFeature(uint32_t featureBit, const char* extensionN ame) {
116 if (featureBit & fFeaturesAddedMask) { 116 if (featureBit & fFeaturesAddedMask) {
117 return false; 117 return false;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // append the 'footer' to code 167 // append the 'footer' to code
168 this->code().append("}"); 168 this->code().append("}");
169 169
170 for (int i = 0; i <= fCodeIndex; i++) { 170 for (int i = 0; i <= fCodeIndex; i++) {
171 fCompilerStrings[i] = fShaderStrings[i].c_str(); 171 fCompilerStrings[i] = fShaderStrings[i].c_str();
172 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); 172 fCompilerStringLengths[i] = (int)fShaderStrings[i].size();
173 } 173 }
174 174
175 fFinalized = true; 175 fFinalized = true;
176 } 176 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLTextureSampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698