Chromium Code Reviews| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect() ); | 522 SkASSERT(NULL != effectStages[e] && NULL != effectStages[e]->getEffect() ); |
| 523 const GrEffectStage& stage = *effectStages[e]; | 523 const GrEffectStage& stage = *effectStages[e]; |
| 524 | 524 |
| 525 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); | 525 CodeStage::AutoStageRestore csar(&fCodeStage, &stage); |
| 526 | 526 |
| 527 if (inColor.isZeros()) { | 527 if (inColor.isZeros()) { |
| 528 SkString inColorName; | 528 SkString inColorName; |
| 529 | 529 |
| 530 // Effects have no way to communicate zeros, they treat an empty str ing as ones. | 530 // Effects have no way to communicate zeros, they treat an empty str ing as ones. |
| 531 this->nameVariable(&inColorName, '\0', "input"); | 531 this->nameVariable(&inColorName, '\0', "input"); |
| 532 this->fsCodeAppendf("\tvec4 %s = %s;\n", inColorName.c_str(), inColo r.c_str()); | 532 this->fsCodeAppendf("\tvec4 %s = %s;\n", inColorName.c_str(), inColo r.c_str()); |
|
changjun.yang
2014/06/10 11:41:16
Sorry I am not quite familiar with the shader..
On
bsalomon
2014/06/10 13:22:18
Question: Is this the variable that needs to be hi
changjun.yang
2014/06/11 08:56:56
Yes, it's the var that would make the conversion w
| |
| 533 inColor = inColorName; | 533 inColor = inColorName; |
| 534 } | 534 } |
| 535 | 535 |
| 536 // create var to hold stage result | 536 // create var to hold stage result |
| 537 SkString outColorName; | 537 SkString outColorName; |
| 538 this->nameVariable(&outColorName, '\0', "output"); | 538 this->nameVariable(&outColorName, '\0', "output"); |
| 539 this->fsCodeAppendf("\tvec4 %s;\n", outColorName.c_str()); | 539 this->fsCodeAppendf("\tvec4 %s;\n", outColorName.c_str()); |
| 540 outColor = outColorName; | 540 outColor = outColorName; |
| 541 | 541 |
| 542 | 542 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 // will immediately delete the shader object and free its memory even though it's | 686 // will immediately delete the shader object and free its memory even though it's |
| 687 // attached to a program, which then causes glLinkProgram to fail. | 687 // attached to a program, which then causes glLinkProgram to fail. |
| 688 GR_GL_CALL(gli, AttachShader(programId, shaderId)); | 688 GR_GL_CALL(gli, AttachShader(programId, shaderId)); |
| 689 | 689 |
| 690 return shaderId; | 690 return shaderId; |
| 691 } | 691 } |
| 692 | 692 |
| 693 bool GrGLShaderBuilder::compileAndAttachShaders(GrGLuint programId, SkTDArray<Gr GLuint>* shaderIds) const { | 693 bool GrGLShaderBuilder::compileAndAttachShaders(GrGLuint programId, SkTDArray<Gr GLuint>* shaderIds) const { |
| 694 SkString fragShaderSrc(GrGetGLSLVersionDecl(this->ctxInfo())); | 694 SkString fragShaderSrc(GrGetGLSLVersionDecl(this->ctxInfo())); |
| 695 fragShaderSrc.append(fFSExtensions); | 695 fragShaderSrc.append(fFSExtensions); |
| 696 append_default_precision_qualifier(kDefaultFragmentPrecision, | 696 |
| 697 fGpu->glStandard(), | 697 if (kImagination_GrGLVendor == this->ctxInfo().vendor() && |
| 698 &fragShaderSrc); | 698 kPVRRogueHood_GrGLRenderer == this->ctxInfo().renderer()) |
| 699 append_default_precision_qualifier(GrGLShaderVar::kHigh_Precision, | |
|
bsalomon
2014/06/09 13:56:45
Can you not just apply highp to the vars emitted b
changjun.yang
2014/06/10 11:41:17
Thanks! Pls see my comments above.
| |
| 700 fGpu->glStandard(), | |
| 701 &fragShaderSrc); | |
| 702 else | |
| 703 append_default_precision_qualifier(kDefaultFragmentPrecision, | |
| 704 fGpu->glStandard(), | |
| 705 &fragShaderSrc); | |
| 706 | |
| 699 this->appendUniformDecls(kFragment_Visibility, &fragShaderSrc); | 707 this->appendUniformDecls(kFragment_Visibility, &fragShaderSrc); |
| 700 this->appendDecls(fFSInputs, &fragShaderSrc); | 708 this->appendDecls(fFSInputs, &fragShaderSrc); |
| 701 // We shouldn't have declared outputs on 1.10 | 709 // We shouldn't have declared outputs on 1.10 |
| 702 SkASSERT(k110_GrGLSLGeneration != fGpu->glslGeneration() || fFSOutputs.empty ()); | 710 SkASSERT(k110_GrGLSLGeneration != fGpu->glslGeneration() || fFSOutputs.empty ()); |
| 703 this->appendDecls(fFSOutputs, &fragShaderSrc); | 711 this->appendDecls(fFSOutputs, &fragShaderSrc); |
| 704 fragShaderSrc.append(fFSFunctions); | 712 fragShaderSrc.append(fFSFunctions); |
| 705 fragShaderSrc.append("void main() {\n"); | 713 fragShaderSrc.append("void main() {\n"); |
| 706 fragShaderSrc.append(fFSCode); | 714 fragShaderSrc.append(fFSCode); |
| 707 fragShaderSrc.append("}\n"); | 715 fragShaderSrc.append("}\n"); |
| 708 | 716 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 990 | 998 |
| 991 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, | 999 GrGLPathTexGenProgramEffectsBuilder pathTexGenEffectsBuilder(this, |
| 992 effectCnt); | 1000 effectCnt); |
| 993 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, | 1001 this->INHERITED::createAndEmitEffects(&pathTexGenEffectsBuilder, |
| 994 effectStages, | 1002 effectStages, |
| 995 effectKeys, | 1003 effectKeys, |
| 996 effectCnt, | 1004 effectCnt, |
| 997 inOutFSColor); | 1005 inOutFSColor); |
| 998 return pathTexGenEffectsBuilder.finish(); | 1006 return pathTexGenEffectsBuilder.finish(); |
| 999 } | 1007 } |
| OLD | NEW |