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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 inline const char* dual_source_output_name() { return "dualSourceOut"; } | 42 inline const char* dual_source_output_name() { return "dualSourceOut"; } |
43 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen)
{ | 43 inline const char* sample_function_name(GrSLType type, GrGLSLGeneration glslGen)
{ |
44 if (kVec2f_GrSLType == type) { | 44 if (kVec2f_GrSLType == type) { |
45 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; | 45 return glslGen >= k130_GrGLSLGeneration ? "texture" : "texture2D"; |
46 } else { | 46 } else { |
47 SkASSERT(kVec3f_GrSLType == type); | 47 SkASSERT(kVec3f_GrSLType == type); |
48 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; | 48 return glslGen >= k130_GrGLSLGeneration ? "textureProj" : "texture2DProj
"; |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 /** | 52 void append_texture_lookup(SkString* out, |
53 * Do we need to either map r,g,b->a or a->r. configComponentMask indicates whic
h channels are | 53 GrGpuGL* gpu, |
54 * present in the texture's config. swizzleComponentMask indicates the channels
present in the | 54 const char* samplerName, |
55 * shader swizzle. | 55 const char* coordName, |
56 */ | 56 uint32_t configComponentMask, |
57 inline bool swizzle_requires_alpha_remapping(const GrGLCaps& caps, | 57 const char* swizzle, |
58 uint32_t configComponentMask, | 58 GrSLType varyingType = kVec2f_GrSLType) { |
59 uint32_t swizzleComponentMask) { | 59 SkASSERT(NULL != coordName); |
60 if (caps.textureSwizzleSupport()) { | |
61 // Any remapping is handled using texture swizzling not shader modificat
ions. | |
62 return false; | |
63 } | |
64 // check if the texture is alpha-only | |
65 if (kA_GrColorComponentFlag == configComponentMask) { | |
66 if (caps.textureRedSupport() && (kA_GrColorComponentFlag & swizzleCompon
entMask)) { | |
67 // we must map the swizzle 'a's to 'r'. | |
68 return true; | |
69 } | |
70 if (kRGB_GrColorComponentFlags & swizzleComponentMask) { | |
71 // The 'r', 'g', and/or 'b's must be mapped to 'a' according to our
semantics that | |
72 // alpha-only textures smear alpha across all four channels when rea
d. | |
73 return true; | |
74 } | |
75 } | |
76 return false; | |
77 } | |
78 | 60 |
79 void append_swizzle(SkString* outAppend, | 61 out->appendf("%s(%s, %s)", |
80 const GrGLShaderBuilder::TextureSampler& texSampler, | 62 sample_function_name(varyingType, gpu->glslGeneration()), |
81 const GrGLCaps& caps) { | 63 samplerName, |
82 const char* swizzle = texSampler.swizzle(); | 64 coordName); |
| 65 |
83 char mangledSwizzle[5]; | 66 char mangledSwizzle[5]; |
84 | 67 |
85 // The swizzling occurs using texture params instead of shader-mangling if A
RB_texture_swizzle | 68 // The swizzling occurs using texture params instead of shader-mangling if A
RB_texture_swizzle |
86 // is available. | 69 // is available. |
87 if (!caps.textureSwizzleSupport() && | 70 if (!gpu->glCaps().textureSwizzleSupport() && |
88 (kA_GrColorComponentFlag == texSampler.configComponentMask())) { | 71 (kA_GrColorComponentFlag == configComponentMask)) { |
89 char alphaChar = caps.textureRedSupport() ? 'r' : 'a'; | 72 char alphaChar = gpu->glCaps().textureRedSupport() ? 'r' : 'a'; |
90 int i; | 73 int i; |
91 for (i = 0; '\0' != swizzle[i]; ++i) { | 74 for (i = 0; '\0' != swizzle[i]; ++i) { |
92 mangledSwizzle[i] = alphaChar; | 75 mangledSwizzle[i] = alphaChar; |
93 } | 76 } |
94 mangledSwizzle[i] ='\0'; | 77 mangledSwizzle[i] ='\0'; |
95 swizzle = mangledSwizzle; | 78 swizzle = mangledSwizzle; |
96 } | 79 } |
97 // For shader prettiness we omit the swizzle rather than appending ".rgba". | 80 // For shader prettiness we omit the swizzle rather than appending ".rgba". |
98 if (memcmp(swizzle, "rgba", 4)) { | 81 if (memcmp(swizzle, "rgba", 4)) { |
99 outAppend->appendf(".%s", swizzle); | 82 out->appendf(".%s", swizzle); |
100 } | 83 } |
101 } | 84 } |
102 | 85 |
103 } | 86 } |
104 | 87 |
105 static const char kDstCopyColorName[] = "_dstColor"; | 88 static const char kDstCopyColorName[] = "_dstColor"; |
106 | 89 |
107 /////////////////////////////////////////////////////////////////////////////// | 90 /////////////////////////////////////////////////////////////////////////////// |
108 | 91 |
109 GrGLShaderBuilder::GrGLShaderBuilder(GrGpuGL* gpu, | 92 GrGLShaderBuilder::GrGLShaderBuilder(GrGpuGL* gpu, |
(...skipping 24 matching lines...) Expand all Loading... |
134 GrGLCaps::kNone_FBFetchType == fGpu->glCaps().fbFetchType()) { | 117 GrGLCaps::kNone_FBFetchType == fGpu->glCaps().fbFetchType()) { |
135 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & header.fDstReadKe
y); | 118 bool topDown = SkToBool(kTopLeftOrigin_DstReadKeyBit & header.fDstReadKe
y); |
136 const char* dstCopyTopLeftName; | 119 const char* dstCopyTopLeftName; |
137 const char* dstCopyCoordScaleName; | 120 const char* dstCopyCoordScaleName; |
138 uint32_t configMask; | 121 uint32_t configMask; |
139 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) { | 122 if (SkToBool(kUseAlphaConfig_DstReadKeyBit & header.fDstReadKey)) { |
140 configMask = kA_GrColorComponentFlag; | 123 configMask = kA_GrColorComponentFlag; |
141 } else { | 124 } else { |
142 configMask = kRGBA_GrColorComponentFlags; | 125 configMask = kRGBA_GrColorComponentFlags; |
143 } | 126 } |
144 fDstCopySampler.init(this, configMask, "rgba", 0); | 127 fDstCopySamplerUniform = this->addUniform(kFragment_Visibility, |
145 | 128 kSampler2D_GrSLType, |
| 129 "DstCopySampler"); |
146 fDstCopyTopLeftUniform = this->addUniform(kFragment_Visibility, | 130 fDstCopyTopLeftUniform = this->addUniform(kFragment_Visibility, |
147 kVec2f_GrSLType, | 131 kVec2f_GrSLType, |
148 "DstCopyUpperLeft", | 132 "DstCopyUpperLeft", |
149 &dstCopyTopLeftName); | 133 &dstCopyTopLeftName); |
150 fDstCopyScaleUniform = this->addUniform(kFragment_Visibility, | 134 fDstCopyScaleUniform = this->addUniform(kFragment_Visibility, |
151 kVec2f_GrSLType, | 135 kVec2f_GrSLType, |
152 "DstCopyCoordScale", | 136 "DstCopyCoordScale", |
153 &dstCopyCoordScaleName); | 137 &dstCopyCoordScaleName); |
154 const char* fragPos = this->fragmentPosition(); | 138 const char* fragPos = this->fragmentPosition(); |
155 this->fsCodeAppend("\t// Read color from copy of the destination.\n"); | 139 this->fsCodeAppend("\t// Read color from copy of the destination.\n"); |
156 this->fsCodeAppendf("\tvec2 _dstTexCoord = (%s.xy - %s) * %s;\n", | 140 this->fsCodeAppendf("\tvec2 _dstTexCoord = (%s.xy - %s) * %s;\n", |
157 fragPos, dstCopyTopLeftName, dstCopyCoordScaleName); | 141 fragPos, dstCopyTopLeftName, dstCopyCoordScaleName); |
158 if (!topDown) { | 142 if (!topDown) { |
159 this->fsCodeAppend("\t_dstTexCoord.y = 1.0 - _dstTexCoord.y;\n"); | 143 this->fsCodeAppend("\t_dstTexCoord.y = 1.0 - _dstTexCoord.y;\n"); |
160 } | 144 } |
161 this->fsCodeAppendf("\tvec4 %s = ", kDstCopyColorName); | 145 this->fsCodeAppendf("\tvec4 %s = ", kDstCopyColorName); |
162 this->fsAppendTextureLookup(fDstCopySampler, "_dstTexCoord"); | 146 append_texture_lookup(&fFSCode, |
| 147 fGpu, |
| 148 this->getUniformCStr(fDstCopySamplerUniform), |
| 149 "_dstTexCoord", |
| 150 configMask, |
| 151 "rgba"); |
163 this->fsCodeAppend(";\n\n"); | 152 this->fsCodeAppend(";\n\n"); |
164 } | 153 } |
165 | 154 |
166 switch (header.fColorInput) { | 155 switch (header.fColorInput) { |
167 case GrGLProgramDesc::kAttribute_ColorInput: { | 156 case GrGLProgramDesc::kAttribute_ColorInput: { |
168 SkASSERT(NULL != fVertexBuilder.get()); | 157 SkASSERT(NULL != fVertexBuilder.get()); |
169 fVertexBuilder->addAttribute(kVec4f_GrSLType, color_attribute_name()
); | 158 fVertexBuilder->addAttribute(kVec4f_GrSLType, color_attribute_name()
); |
170 const char *vsName, *fsName; | 159 const char *vsName, *fsName; |
171 fVertexBuilder->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsNam
e); | 160 fVertexBuilder->addVarying(kVec4f_GrSLType, "Color", &vsName, &fsNam
e); |
172 fVertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsName, color_attribut
e_name()); | 161 fVertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsName, color_attribut
e_name()); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 } | 294 } |
306 } | 295 } |
307 static const char kFBFetchColorName[] = "gl_LastFragData[0]"; | 296 static const char kFBFetchColorName[] = "gl_LastFragData[0]"; |
308 GrGLCaps::FBFetchType fetchType = fGpu->glCaps().fbFetchType(); | 297 GrGLCaps::FBFetchType fetchType = fGpu->glCaps().fbFetchType(); |
309 if (GrGLCaps::kEXT_FBFetchType == fetchType) { | 298 if (GrGLCaps::kEXT_FBFetchType == fetchType) { |
310 SkAssertResult(this->enablePrivateFeature(kEXTShaderFramebufferFetch_GLS
LPrivateFeature)); | 299 SkAssertResult(this->enablePrivateFeature(kEXTShaderFramebufferFetch_GLS
LPrivateFeature)); |
311 return kFBFetchColorName; | 300 return kFBFetchColorName; |
312 } else if (GrGLCaps::kNV_FBFetchType == fetchType) { | 301 } else if (GrGLCaps::kNV_FBFetchType == fetchType) { |
313 SkAssertResult(this->enablePrivateFeature(kNVShaderFramebufferFetch_GLSL
PrivateFeature)); | 302 SkAssertResult(this->enablePrivateFeature(kNVShaderFramebufferFetch_GLSL
PrivateFeature)); |
314 return kFBFetchColorName; | 303 return kFBFetchColorName; |
315 } else if (fDstCopySampler.isInitialized()) { | 304 } else if (fDstCopySamplerUniform.isValid()) { |
316 return kDstCopyColorName; | 305 return kDstCopyColorName; |
317 } else { | 306 } else { |
318 return ""; | 307 return ""; |
319 } | 308 } |
320 } | 309 } |
321 | 310 |
322 void GrGLShaderBuilder::appendTextureLookup(SkString* out, | 311 void GrGLShaderBuilder::appendTextureLookup(SkString* out, |
323 const GrGLShaderBuilder::TextureSamp
ler& sampler, | 312 const GrGLShaderBuilder::TextureSamp
ler& sampler, |
324 const char* coordName, | 313 const char* coordName, |
325 GrSLType varyingType) const { | 314 GrSLType varyingType) const { |
326 SkASSERT(NULL != coordName); | 315 append_texture_lookup(out, |
327 | 316 fGpu, |
328 out->appendf("%s(%s, %s)", | 317 this->getUniformCStr(sampler.samplerUniform()), |
329 sample_function_name(varyingType, fGpu->glslGeneration()), | 318 coordName, |
330 this->getUniformCStr(sampler.fSamplerUniform), | 319 sampler.configComponentMask(), |
331 coordName); | 320 sampler.swizzle(), |
332 append_swizzle(out, sampler, fGpu->glCaps()); | 321 varyingType); |
333 } | 322 } |
334 | 323 |
335 void GrGLShaderBuilder::fsAppendTextureLookup(const GrGLShaderBuilder::TextureSa
mpler& sampler, | 324 void GrGLShaderBuilder::fsAppendTextureLookup(const GrGLShaderBuilder::TextureSa
mpler& sampler, |
336 const char* coordName, | 325 const char* coordName, |
337 GrSLType varyingType) { | 326 GrSLType varyingType) { |
338 this->appendTextureLookup(&fFSCode, sampler, coordName, varyingType); | 327 this->appendTextureLookup(&fFSCode, sampler, coordName, varyingType); |
339 } | 328 } |
340 | 329 |
341 void GrGLShaderBuilder::fsAppendTextureLookupAndModulate( | 330 void GrGLShaderBuilder::fsAppendTextureLookupAndModulate( |
342 const char* modulation, | 331 const char* modulation, |
343 const GrGLShaderBuilder::TextureSamp
ler& sampler, | 332 const GrGLShaderBuilder::TextureSamp
ler& sampler, |
344 const char* coordName, | 333 const char* coordName, |
345 GrSLType varyingType) { | 334 GrSLType varyingType) { |
346 SkString lookup; | 335 SkString lookup; |
347 this->appendTextureLookup(&lookup, sampler, coordName, varyingType); | 336 this->appendTextureLookup(&lookup, sampler, coordName, varyingType); |
348 GrGLSLModulatef<4>(&fFSCode, modulation, lookup.c_str()); | 337 GrGLSLModulatef<4>(&fFSCode, modulation, lookup.c_str()); |
349 } | 338 } |
350 | 339 |
351 GrGLShaderBuilder::EffectKey GrGLShaderBuilder::KeyForTextureAccess(const GrText
ureAccess& access, | |
352 const GrGLCa
ps& caps) { | |
353 uint32_t configComponentMask = GrPixelConfigComponentMask(access.getTexture(
)->config()); | |
354 if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.swizz
leMask())) { | |
355 return 1; | |
356 } else { | |
357 return 0; | |
358 } | |
359 } | |
360 | |
361 GrGLShaderBuilder::DstReadKey GrGLShaderBuilder::KeyForDstRead(const GrTexture*
dstCopy, | 340 GrGLShaderBuilder::DstReadKey GrGLShaderBuilder::KeyForDstRead(const GrTexture*
dstCopy, |
362 const GrGLCaps& c
aps) { | 341 const GrGLCaps& c
aps) { |
363 uint32_t key = kYesDstRead_DstReadKeyBit; | 342 uint32_t key = kYesDstRead_DstReadKeyBit; |
364 if (GrGLCaps::kNone_FBFetchType != caps.fbFetchType()) { | 343 if (GrGLCaps::kNone_FBFetchType != caps.fbFetchType()) { |
365 return key; | 344 return key; |
366 } | 345 } |
367 SkASSERT(NULL != dstCopy); | 346 SkASSERT(NULL != dstCopy); |
368 if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstCopy->confi
g())) { | 347 if (!caps.textureSwizzleSupport() && GrPixelConfigIsAlphaOnly(dstCopy->confi
g())) { |
369 // The fact that the config is alpha-only must be considered when genera
ting code. | 348 // The fact that the config is alpha-only must be considered when genera
ting code. |
370 key |= kUseAlphaConfig_DstReadKeyBit; | 349 key |= kUseAlphaConfig_DstReadKeyBit; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 void GrGLShaderBuilder::appendUniformDecls(ShaderVisibility visibility, | 544 void GrGLShaderBuilder::appendUniformDecls(ShaderVisibility visibility, |
566 SkString* out) const { | 545 SkString* out) const { |
567 for (int i = 0; i < fUniforms.count(); ++i) { | 546 for (int i = 0; i < fUniforms.count(); ++i) { |
568 if (fUniforms[i].fVisibility & visibility) { | 547 if (fUniforms[i].fVisibility & visibility) { |
569 fUniforms[i].fVariable.appendDecl(this->ctxInfo(), out); | 548 fUniforms[i].fVariable.appendDecl(this->ctxInfo(), out); |
570 out->append(";\n"); | 549 out->append(";\n"); |
571 } | 550 } |
572 } | 551 } |
573 } | 552 } |
574 | 553 |
575 void GrGLShaderBuilder::emitEffects( | 554 GrGLProgramEffects* GrGLShaderBuilder::createAndEmitEffects( |
576 const GrEffectStage* effectStages[], | 555 const GrEffectStage* effectStages[], |
577 const EffectKey effectKeys[], | 556 const EffectKey effectKeys[], |
578 int effectCnt, | 557 int effectCnt, |
579 SkString* fsInOutColor, | 558 SkString* fsInOutColor, |
580 GrSLConstantVec* fsInOutColorKnownValue, | 559 GrSLConstantVec* fsInOutColorKnownValue) { |
581 SkTArray<GrGLCoordTransform, false>* effectCoordTransfor
mArrays[], | 560 |
582 SkTArray<GrGLUniformManager::UniformHandle, true>* effec
tSamplerHandles[], | 561 GrGLProgramEffectsBuilder programEffectsBuilder(this, effectCnt); |
583 GrGLEffect* glEffects[]) { | |
584 bool effectEmitted = false; | 562 bool effectEmitted = false; |
585 | 563 |
586 SkString inColor = *fsInOutColor; | 564 SkString inColor = *fsInOutColor; |
587 SkString outColor; | 565 SkString outColor; |
588 | 566 |
589 for (int e = 0; e < effectCnt; ++e) { | 567 for (int e = 0; e < effectCnt; ++e) { |
590 SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect()
); | 568 SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect()
); |
591 const GrEffectStage& stage = *effectStages[e]; | 569 const GrEffectStage& stage = *effectStages[e]; |
592 const GrEffectRef& effect = *stage.getEffect(); | |
593 | 570 |
594 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); | 571 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); |
595 | 572 |
596 int numTransforms = effect->numTransforms(); | |
597 SkSTArray<8, GrGLCoordTransform::TransformedCoords> transformedCoords; | |
598 transformedCoords.push_back_n(numTransforms); | |
599 EffectKey transformKey = GrBackendEffectFactory::GetTransformKey(effectK
eys[e]); | |
600 for (int c = 0; c < numTransforms; ++c) { | |
601 GrGLCoordTransform& ct = effectCoordTransformArrays[e]->push_back(); | |
602 EffectKey key = (transformKey >> (c * GrGLCoordTransform::kKeyBits))
& | |
603 (GrGLCoordTransform::kKeyMask); | |
604 ct.emitCode(this, key, &transformedCoords[c], c); | |
605 } | |
606 | |
607 int numTextures = effect->numTextures(); | |
608 SkSTArray<8, GrGLShaderBuilder::TextureSampler> textureSamplers; | |
609 textureSamplers.push_back_n(numTextures); | |
610 for (int t = 0; t < numTextures; ++t) { | |
611 textureSamplers[t].init(this, &effect->textureAccess(t), t); | |
612 effectSamplerHandles[e]->push_back(textureSamplers[t].fSamplerUnifor
m); | |
613 } | |
614 | |
615 GrDrawEffect drawEffect(stage, NULL != fVertexBuilder.get() | |
616 && fVertexBuilder->hasExplicitLocalCoords
()); | |
617 | |
618 int numAttributes = stage.getVertexAttribIndexCount(); | |
619 const int* attributeIndices = stage.getVertexAttribIndices(); | |
620 SkSTArray<GrEffect::kMaxVertexAttribs, SkString> attributeNames; | |
621 for (int a = 0; a < numAttributes; ++a) { | |
622 // TODO: Make addAttribute mangle the name. | |
623 SkASSERT(NULL != fVertexBuilder.get()); | |
624 SkString attributeName("aAttr"); | |
625 attributeName.appendS32(attributeIndices[a]); | |
626 fVertexBuilder->addEffectAttribute(attributeIndices[a], | |
627 effect->vertexAttribType(a), | |
628 attributeName); | |
629 } | |
630 | |
631 glEffects[e] = effect->getFactory().createGLInstance(drawEffect); | |
632 | |
633 if (kZeros_GrSLConstantVec == *fsInOutColorKnownValue) { | 573 if (kZeros_GrSLConstantVec == *fsInOutColorKnownValue) { |
634 // Effects have no way to communicate zeros, they treat an empty str
ing as ones. | 574 // Effects have no way to communicate zeros, they treat an empty str
ing as ones. |
635 this->nameVariable(&inColor, '\0', "input"); | 575 this->nameVariable(&inColor, '\0', "input"); |
636 this->fsCodeAppendf("\tvec4 %s = %s;\n", inColor.c_str(), GrGLSLZero
sVecf(4)); | 576 this->fsCodeAppendf("\tvec4 %s = %s;\n", inColor.c_str(), GrGLSLZero
sVecf(4)); |
637 } | 577 } |
638 | 578 |
639 // create var to hold stage result | 579 // create var to hold stage result |
640 this->nameVariable(&outColor, '\0', "output"); | 580 this->nameVariable(&outColor, '\0', "output"); |
641 this->fsCodeAppendf("\tvec4 %s;\n", outColor.c_str()); | 581 this->fsCodeAppendf("\tvec4 %s;\n", outColor.c_str()); |
642 | 582 |
643 // Enclose custom code in a block to avoid namespace conflicts | 583 programEffectsBuilder.emitEffect(stage, |
644 SkString openBrace; | 584 effectKeys[e], |
645 openBrace.printf("\t{ // Stage %d: %s\n", fCodeStage.stageIndex(), glEff
ects[e]->name()); | 585 outColor.c_str(), |
646 if (NULL != fVertexBuilder.get()) { | 586 inColor.isEmpty() ? NULL : inColor.c_st
r(), |
647 fVertexBuilder->vsCodeAppend(openBrace.c_str()); | 587 fCodeStage.stageIndex()); |
648 } | |
649 this->fsCodeAppend(openBrace.c_str()); | |
650 | |
651 glEffects[e]->emitCode(this, | |
652 drawEffect, | |
653 effectKeys[e], | |
654 outColor.c_str(), | |
655 inColor.isEmpty() ? NULL : inColor.c_str(), | |
656 transformedCoords, | |
657 textureSamplers); | |
658 | |
659 if (NULL != fVertexBuilder.get()) { | |
660 fVertexBuilder->vsCodeAppend("\t}\n"); | |
661 } | |
662 this->fsCodeAppend("\t}\n"); | |
663 | 588 |
664 inColor = outColor; | 589 inColor = outColor; |
665 *fsInOutColorKnownValue = kNone_GrSLConstantVec; | 590 *fsInOutColorKnownValue = kNone_GrSLConstantVec; |
666 effectEmitted = true; | 591 effectEmitted = true; |
667 } | 592 } |
668 | 593 |
669 if (effectEmitted) { | 594 if (effectEmitted) { |
670 *fsInOutColor = outColor; | 595 *fsInOutColor = outColor; |
671 } | 596 } |
| 597 |
| 598 return programEffectsBuilder.finish(); |
672 } | 599 } |
673 | 600 |
674 const char* GrGLShaderBuilder::getColorOutputName() const { | 601 const char* GrGLShaderBuilder::getColorOutputName() const { |
675 return fHasCustomColorOutput ? declared_color_output_name() : "gl_FragColor"
; | 602 return fHasCustomColorOutput ? declared_color_output_name() : "gl_FragColor"
; |
676 } | 603 } |
677 | 604 |
678 const char* GrGLShaderBuilder::enableSecondaryOutput() { | 605 const char* GrGLShaderBuilder::enableSecondaryOutput() { |
679 if (!fHasSecondaryOutput) { | 606 if (!fHasSecondaryOutput) { |
680 fFSOutputs.push_back().set(kVec4f_GrSLType, | 607 fFSOutputs.push_back().set(kVec4f_GrSLType, |
681 GrGLShaderVar::kOut_TypeModifier, | 608 GrGLShaderVar::kOut_TypeModifier, |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 GL_CALL(BindAttribLocation(programId, | 938 GL_CALL(BindAttribLocation(programId, |
1012 header.fCoverageAttributeIndex, | 939 header.fCoverageAttributeIndex, |
1013 coverage_attribute_name())); | 940 coverage_attribute_name())); |
1014 } | 941 } |
1015 | 942 |
1016 const AttributePair* attribEnd = fEffectAttributes.end(); | 943 const AttributePair* attribEnd = fEffectAttributes.end(); |
1017 for (const AttributePair* attrib = fEffectAttributes.begin(); attrib != attr
ibEnd; ++attrib) { | 944 for (const AttributePair* attrib = fEffectAttributes.begin(); attrib != attr
ibEnd; ++attrib) { |
1018 GL_CALL(BindAttribLocation(programId, attrib->fIndex, attrib->fName.c_s
tr())); | 945 GL_CALL(BindAttribLocation(programId, attrib->fIndex, attrib->fName.c_s
tr())); |
1019 } | 946 } |
1020 } | 947 } |
OLD | NEW |