OLD | NEW |
---|---|
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" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 if (fCodeStage.inStageCode()) { | 223 if (fCodeStage.inStageCode()) { |
224 if (out->endsWith('_')) { | 224 if (out->endsWith('_')) { |
225 // Names containing "__" are reserved. | 225 // Names containing "__" are reserved. |
226 out->append("x"); | 226 out->append("x"); |
227 } | 227 } |
228 out->appendf("_Stage%d", fCodeStage.stageIndex()); | 228 out->appendf("_Stage%d", fCodeStage.stageIndex()); |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 const char* GrGLShaderBuilder::dstColor() { | 232 const char* GrGLShaderBuilder::dstColor() { |
233 if (fCodeStage.inStageCode()) { | |
234 const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect(); | |
235 if (!effect->willReadDstColor()) { | |
236 GrPrintf("GrGLEffect asked for dst color but its generating GrEffect " | |
Stephen White
2013/05/09 01:33:46
Maybe this should assert instead of printing? It
| |
237 "did not request access."); | |
robertphillips
2013/05/09 13:16:11
Is there something better we could do in this case
| |
238 return NULL; | |
239 } | |
240 } | |
233 static const char kFBFetchColorName[] = "gl_LastFragData[0]"; | 241 static const char kFBFetchColorName[] = "gl_LastFragData[0]"; |
234 GrGLCaps::FBFetchType fetchType = fCtxInfo.caps()->fbFetchType(); | 242 GrGLCaps::FBFetchType fetchType = fCtxInfo.caps()->fbFetchType(); |
235 if (GrGLCaps::kEXT_FBFetchType == fetchType) { | 243 if (GrGLCaps::kEXT_FBFetchType == fetchType) { |
236 SkAssertResult(this->enablePrivateFeature(kEXTShaderFramebufferFetch_GLS LPrivateFeature)); | 244 SkAssertResult(this->enablePrivateFeature(kEXTShaderFramebufferFetch_GLS LPrivateFeature)); |
237 return kFBFetchColorName; | 245 return kFBFetchColorName; |
238 } else if (GrGLCaps::kNV_FBFetchType == fetchType) { | 246 } else if (GrGLCaps::kNV_FBFetchType == fetchType) { |
239 SkAssertResult(this->enablePrivateFeature(kNVShaderFramebufferFetch_GLSL PrivateFeature)); | 247 SkAssertResult(this->enablePrivateFeature(kNVShaderFramebufferFetch_GLSL PrivateFeature)); |
240 return kFBFetchColorName; | 248 return kFBFetchColorName; |
241 } else if (fDstCopySampler.isInitialized()) { | 249 } else if (fDstCopySampler.isInitialized()) { |
242 return kDstCopyColorName; | 250 return kDstCopyColorName; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 fFSInputs.push_back(); | 458 fFSInputs.push_back(); |
451 fFSInputs.back().setType(type); | 459 fFSInputs.back().setType(type); |
452 fFSInputs.back().setTypeModifier(GrGLShaderVar::kVaryingIn_TypeModifier); | 460 fFSInputs.back().setTypeModifier(GrGLShaderVar::kVaryingIn_TypeModifier); |
453 fFSInputs.back().setName(*fsName); | 461 fFSInputs.back().setName(*fsName); |
454 if (fsInName) { | 462 if (fsInName) { |
455 *fsInName = fsName->c_str(); | 463 *fsInName = fsName->c_str(); |
456 } | 464 } |
457 } | 465 } |
458 | 466 |
459 const char* GrGLShaderBuilder::fragmentPosition() { | 467 const char* GrGLShaderBuilder::fragmentPosition() { |
468 if (fCodeStage.inStageCode()) { | |
469 const GrEffectRef& effect = *fCodeStage.effectStage()->getEffect(); | |
470 if (!effect->willReadFragmentPosition()) { | |
471 GrPrintf("GrGLEffect asked for frag position but its generating GrEf fect " | |
Stephen White
2013/05/09 01:33:46
Same here.
| |
472 "did not request access."); | |
473 return NULL; | |
474 } | |
475 } | |
460 #if 1 | 476 #if 1 |
461 if (fCtxInfo.caps()->fragCoordConventionsSupport()) { | 477 if (fCtxInfo.caps()->fragCoordConventionsSupport()) { |
462 if (!fSetupFragPosition) { | 478 if (!fSetupFragPosition) { |
463 SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSL PrivateFeature)); | 479 SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSL PrivateFeature)); |
464 fFSInputs.push_back().set(kVec4f_GrSLType, | 480 fFSInputs.push_back().set(kVec4f_GrSLType, |
465 GrGLShaderVar::kIn_TypeModifier, | 481 GrGLShaderVar::kIn_TypeModifier, |
466 "gl_FragCoord", | 482 "gl_FragCoord", |
467 GrGLShaderVar::kDefault_Precision, | 483 GrGLShaderVar::kDefault_Precision, |
468 GrGLShaderVar::kUpperLeft_Origin); | 484 GrGLShaderVar::kUpperLeft_Origin); |
469 fSetupFragPosition = true; | 485 fSetupFragPosition = true; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 for (const AttributePair* attrib = this->getEffectAttributes().begin(); | 722 for (const AttributePair* attrib = this->getEffectAttributes().begin(); |
707 attrib != attribEnd; | 723 attrib != attribEnd; |
708 ++attrib) { | 724 ++attrib) { |
709 if (attrib->fIndex == attributeIndex) { | 725 if (attrib->fIndex == attributeIndex) { |
710 return &attrib->fName; | 726 return &attrib->fName; |
711 } | 727 } |
712 } | 728 } |
713 | 729 |
714 return NULL; | 730 return NULL; |
715 } | 731 } |
OLD | NEW |