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

Side by Side Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp

Issue 665893008: Bug fix for es 3.00 fb fetch (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
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 "GrGLFragmentShaderBuilder.h" 8 #include "GrGLFragmentShaderBuilder.h"
9 #include "GrGLShaderStringBuilder.h" 9 #include "GrGLShaderStringBuilder.h"
10 #include "GrGLProgramBuilder.h" 10 #include "GrGLProgramBuilder.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 } 69 }
70 70
71 GrGLFragmentShaderBuilder::GrGLFragmentShaderBuilder(GrGLProgramBuilder* program , 71 GrGLFragmentShaderBuilder::GrGLFragmentShaderBuilder(GrGLProgramBuilder* program ,
72 const GrGLProgramDesc& desc ) 72 const GrGLProgramDesc& desc )
73 : INHERITED(program) 73 : INHERITED(program)
74 , fHasCustomColorOutput(false) 74 , fHasCustomColorOutput(false)
75 , fHasSecondaryOutput(false) 75 , fHasSecondaryOutput(false)
76 , fSetupFragPosition(false) 76 , fSetupFragPosition(false)
77 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr agPosKey) 77 , fTopLeftFragPosRead(kTopLeftFragPosRead_FragPosKey == desc.getHeader().fFr agPosKey)
78 , fCustomColorOutputIndex(-1)
78 , fHasReadDstColor(false) 79 , fHasReadDstColor(false)
79 , fHasReadFragmentPosition(false) { 80 , fHasReadFragmentPosition(false) {
80 } 81 }
81 82
82 bool GrGLFragmentShaderBuilder::enableFeature(GLSLFeature feature) { 83 bool GrGLFragmentShaderBuilder::enableFeature(GLSLFeature feature) {
83 switch (feature) { 84 switch (feature) {
84 case kStandardDerivatives_GLSLFeature: { 85 case kStandardDerivatives_GLSLFeature: {
85 GrGpuGL* gpu = fProgramBuilder->gpu(); 86 GrGpuGL* gpu = fProgramBuilder->gpu();
86 if (!gpu->glCaps().shaderDerivativeSupport()) { 87 if (!gpu->glCaps().shaderDerivativeSupport()) {
87 return false; 88 return false;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 166 }
166 } 167 }
167 168
168 const char* GrGLFragmentShaderBuilder::dstColor() { 169 const char* GrGLFragmentShaderBuilder::dstColor() {
169 fHasReadDstColor = true; 170 fHasReadDstColor = true;
170 171
171 GrGpuGL* gpu = fProgramBuilder->gpu(); 172 GrGpuGL* gpu = fProgramBuilder->gpu();
172 if (gpu->glCaps().fbFetchSupport()) { 173 if (gpu->glCaps().fbFetchSupport()) {
173 this->addFeature(1 << (GrGLFragmentShaderBuilder::kLastGLSLPrivateFeatur e + 1), 174 this->addFeature(1 << (GrGLFragmentShaderBuilder::kLastGLSLPrivateFeatur e + 1),
174 gpu->glCaps().fbFetchExtensionString()); 175 gpu->glCaps().fbFetchExtensionString());
175 return gpu->glCaps().fbFetchColorName(); 176
177 // On ES 3.0 we have to declare this, and use the custom color output na me
178 const char* fbFetchColorName = gpu->glCaps().fbFetchColorName();
179 if (gpu->glslGeneration() >= k330_GrGLSLGeneration) {
180 if (-1 == fCustomColorOutputIndex) {
egdaniel 2014/10/21 18:22:06 do we need this if? Isn't it true that (-1 == fCus
joshualitt 2014/10/21 18:29:24 Acknowledged.
181 this->enableCustomOutput();
182 }
183 fOutputs[fCustomColorOutputIndex].setTypeModifier(GrShaderVar::kInOu t_TypeModifier);
184 fbFetchColorName = declared_color_output_name();
185 }
186 return fbFetchColorName;
176 } else if (fProgramBuilder->fUniformHandles.fDstCopySamplerUni.isValid()) { 187 } else if (fProgramBuilder->fUniformHandles.fDstCopySamplerUni.isValid()) {
177 return kDstCopyColorName; 188 return kDstCopyColorName;
178 } else { 189 } else {
179 return ""; 190 return "";
180 } 191 }
181 } 192 }
182 193
183 void GrGLFragmentShaderBuilder::emitCodeToReadDstTexture() { 194 void GrGLFragmentShaderBuilder::emitCodeToReadDstTexture() {
184 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & fProgramBuilder->head er().fDstReadKey); 195 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & fProgramBuilder->head er().fDstReadKey);
185 const char* dstCopyTopLeftName; 196 const char* dstCopyTopLeftName;
(...skipping 30 matching lines...) Expand all
216 } 227 }
217 this->codeAppendf("vec4 %s = ", GrGLFragmentShaderBuilder::kDstCopyColorName ); 228 this->codeAppendf("vec4 %s = ", GrGLFragmentShaderBuilder::kDstCopyColorName );
218 this->appendTextureLookup(dstCopySamplerName, 229 this->appendTextureLookup(dstCopySamplerName,
219 "_dstTexCoord", 230 "_dstTexCoord",
220 configMask, 231 configMask,
221 "rgba"); 232 "rgba");
222 this->codeAppend(";"); 233 this->codeAppend(";");
223 } 234 }
224 235
225 void GrGLFragmentShaderBuilder::enableCustomOutput() { 236 void GrGLFragmentShaderBuilder::enableCustomOutput() {
226 SkASSERT(!fHasCustomColorOutput); 237 if (!fHasCustomColorOutput) {
227 fHasCustomColorOutput = true; 238 fHasCustomColorOutput = true;
228 fOutputs.push_back().set(kVec4f_GrSLType, 239 fCustomColorOutputIndex = fOutputs.count();
229 GrGLShaderVar::kOut_TypeModifier, 240 fOutputs.push_back().set(kVec4f_GrSLType,
230 declared_color_output_name()); 241 GrGLShaderVar::kOut_TypeModifier,
242 declared_color_output_name());
243 }
231 } 244 }
232 245
233 void GrGLFragmentShaderBuilder::enableSecondaryOutput() { 246 void GrGLFragmentShaderBuilder::enableSecondaryOutput() {
234 SkASSERT(!fHasSecondaryOutput); 247 SkASSERT(!fHasSecondaryOutput);
235 fHasSecondaryOutput = true; 248 fHasSecondaryOutput = true;
236 fOutputs.push_back().set(kVec4f_GrSLType, GrGLShaderVar::kOut_TypeModifier, 249 fOutputs.push_back().set(kVec4f_GrSLType, GrGLShaderVar::kOut_TypeModifier,
237 dual_source_output_name()); 250 dual_source_output_name());
238 } 251 }
239 252
240 const char* GrGLFragmentShaderBuilder::getPrimaryColorOutputName() const { 253 const char* GrGLFragmentShaderBuilder::getPrimaryColorOutputName() const {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 350
338 void GrGLFragmentShaderBuilder::addVarying(GrSLType type, 351 void GrGLFragmentShaderBuilder::addVarying(GrSLType type,
339 const char* name, 352 const char* name,
340 const char** fsInName, 353 const char** fsInName,
341 GrGLShaderVar::Precision fsPrecision) { 354 GrGLShaderVar::Precision fsPrecision) {
342 fInputs.push_back().set(type, GrGLShaderVar::kVaryingIn_TypeModifier, name, fsPrecision); 355 fInputs.push_back().set(type, GrGLShaderVar::kVaryingIn_TypeModifier, name, fsPrecision);
343 if (fsInName) { 356 if (fsInName) {
344 *fsInName = name; 357 *fsInName = name;
345 } 358 }
346 } 359 }
OLDNEW
« src/gpu/gl/GrGLCaps.h ('K') | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698