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

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

Issue 1896013003: Revert of Refactor how we store and use samplers in Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrGLSLUniformHandler.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"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (i < argCnt - 1) { 56 if (i < argCnt - 1) {
57 this->functions().append(", "); 57 this->functions().append(", ");
58 } 58 }
59 } 59 }
60 this->functions().append(") {\n"); 60 this->functions().append(") {\n");
61 this->functions().append(body); 61 this->functions().append(body);
62 this->functions().append("}\n\n"); 62 this->functions().append("}\n\n");
63 } 63 }
64 64
65 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out, 65 void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
66 SamplerHandle samplerHandle, 66 const GrGLSLSampler& sampler,
67 const char* coordName, 67 const char* coordName,
68 GrSLType varyingType) const { 68 GrSLType varyingType) const {
69 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps(); 69 const GrGLSLCaps* glslCaps = fProgramBuilder->glslCaps();
70 const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle); 70 GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler();
71 GrSLType samplerType = sampler.type(); 71 GrSLType samplerType = uniformHandler->getUniformVariable(sampler.fSamplerUn iform).getType();
72 if (samplerType == kSampler2DRect_GrSLType) { 72 if (samplerType == kSampler2DRect_GrSLType) {
73 if (varyingType == kVec2f_GrSLType) { 73 if (varyingType == kVec2f_GrSLType) {
74 out->appendf("%s(%s, textureSize(%s) * %s)", 74 out->appendf("%s(%s, textureSize(%s) * %s)",
75 GrGLSLTexture2DFunctionName(varyingType, samplerType, 75 GrGLSLTexture2DFunctionName(varyingType, samplerType,
76 glslCaps->generation()), 76 glslCaps->generation()),
77 sampler.getSamplerNameForTexture2D(), 77 uniformHandler->getUniformCStr(sampler.fSamplerUniform) ,
78 sampler.getSamplerNameForTexture2D(), 78 uniformHandler->getUniformCStr(sampler.fSamplerUniform) ,
79 coordName); 79 coordName);
80 } else { 80 } else {
81 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))", 81 out->appendf("%s(%s, vec3(textureSize(%s) * %s.xy, %s.z))",
82 GrGLSLTexture2DFunctionName(varyingType, samplerType, 82 GrGLSLTexture2DFunctionName(varyingType, samplerType,
83 glslCaps->generation()), 83 glslCaps->generation()),
84 sampler.getSamplerNameForTexture2D(), 84 uniformHandler->getUniformCStr(sampler.fSamplerUniform) ,
85 sampler.getSamplerNameForTexture2D(), 85 uniformHandler->getUniformCStr(sampler.fSamplerUniform) ,
86 coordName, 86 coordName,
87 coordName); 87 coordName);
88 } 88 }
89 } else { 89 } else {
90 out->appendf("%s(%s, %s)", 90 out->appendf("%s(%s, %s)",
91 GrGLSLTexture2DFunctionName(varyingType, samplerType, glslC aps->generation()), 91 GrGLSLTexture2DFunctionName(varyingType, samplerType, glslC aps->generation()),
92 sampler.getSamplerNameForTexture2D(), 92 uniformHandler->getUniformCStr(sampler.fSamplerUniform),
93 coordName); 93 coordName);
94 } 94 }
95 95
96 this->appendTextureSwizzle(out, sampler.config()); 96 this->appendTextureSwizzle(out, sampler.config());
97 } 97 }
98 98
99 void GrGLSLShaderBuilder::appendTextureLookup(SamplerHandle samplerHandle, 99 void GrGLSLShaderBuilder::appendTextureLookup(const GrGLSLSampler& sampler,
100 const char* coordName, 100 const char* coordName,
101 GrSLType varyingType) { 101 GrSLType varyingType) {
102 this->appendTextureLookup(&this->code(), samplerHandle, coordName, varyingTy pe); 102 this->appendTextureLookup(&this->code(), sampler, coordName, varyingType);
103 } 103 }
104 104
105 void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation, 105 void GrGLSLShaderBuilder::appendTextureLookupAndModulate(const char* modulation,
106 SamplerHandle samplerHa ndle, 106 const GrGLSLSampler& sa mpler,
107 const char* coordName, 107 const char* coordName,
108 GrSLType varyingType) { 108 GrSLType varyingType) {
109 SkString lookup; 109 SkString lookup;
110 this->appendTextureLookup(&lookup, samplerHandle, coordName, varyingType); 110 this->appendTextureLookup(&lookup, sampler, coordName, varyingType);
111 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str()); 111 this->codeAppend((GrGLSLExpr4(modulation) * GrGLSLExpr4(lookup)).c_str());
112 } 112 }
113 113
114 void GrGLSLShaderBuilder::appendTexelFetch(SkString* out, 114 void GrGLSLShaderBuilder::appendTexelFetch(SkString* out,
115 SamplerHandle samplerHandle, 115 const GrGLSLSampler& sampler,
116 const char* coordExpr) const { 116 const char* coordExpr) const {
117 const GrGLSLSampler& sampler = fProgramBuilder->getSampler(samplerHandle); 117 const GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler ();
118 SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport()); 118 SkASSERT(fProgramBuilder->glslCaps()->texelFetchSupport());
119 SkASSERT(GrSLTypeIsSamplerType(sampler.type())); 119 SkASSERT(GrSLTypeIsSamplerType(
120 uniformHandler->getUniformVariable(sampler.fSamplerUniform).getType ()));
120 121
121 out->appendf("texelFetch(%s, %s)", sampler.getSamplerNameForTexelFetch(), co ordExpr); 122 out->appendf("texelFetch(%s, %s)",
123 uniformHandler->getUniformCStr(sampler.fSamplerUniform),
124 coordExpr);
122 125
123 this->appendTextureSwizzle(out, sampler.config()); 126 this->appendTextureSwizzle(out, sampler.config());
124 } 127 }
125 128
126 void GrGLSLShaderBuilder::appendTexelFetch(SamplerHandle samplerHandle, const ch ar* coordExpr) { 129 void GrGLSLShaderBuilder::appendTexelFetch(const GrGLSLSampler& sampler, const c har* coordExpr) {
127 this->appendTexelFetch(&this->code(), samplerHandle, coordExpr); 130 this->appendTexelFetch(&this->code(), sampler, coordExpr);
128 } 131 }
129 132
130 void GrGLSLShaderBuilder::appendTextureSwizzle(SkString* out, GrPixelConfig conf ig) const { 133 void GrGLSLShaderBuilder::appendTextureSwizzle(SkString* out, GrPixelConfig conf ig) const {
131 const GrSwizzle& configSwizzle = fProgramBuilder->glslCaps()->configTextureS wizzle(config); 134 const GrSwizzle& configSwizzle = fProgramBuilder->glslCaps()->configTextureS wizzle(config);
132 135
133 if (configSwizzle != GrSwizzle::RGBA()) { 136 if (configSwizzle != GrSwizzle::RGBA()) {
134 out->appendf(".%s", configSwizzle.c_str()); 137 out->appendf(".%s", configSwizzle.c_str());
135 } 138 }
136 } 139 }
137 140
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // append the 'footer' to code 193 // append the 'footer' to code
191 this->code().append("}"); 194 this->code().append("}");
192 195
193 for (int i = 0; i <= fCodeIndex; i++) { 196 for (int i = 0; i <= fCodeIndex; i++) {
194 fCompilerStrings[i] = fShaderStrings[i].c_str(); 197 fCompilerStrings[i] = fShaderStrings[i].c_str();
195 fCompilerStringLengths[i] = (int)fShaderStrings[i].size(); 198 fCompilerStringLengths[i] = (int)fShaderStrings[i].size();
196 } 199 }
197 200
198 fFinalized = true; 201 fFinalized = true;
199 } 202 }
OLDNEW
« no previous file with comments | « src/gpu/glsl/GrGLSLShaderBuilder.h ('k') | src/gpu/glsl/GrGLSLUniformHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698