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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 fHasCustomColorOutput = true; | 174 fHasCustomColorOutput = true; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) { | 178 bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) { |
179 switch (feature) { | 179 switch (feature) { |
180 case kStandardDerivatives_GLSLFeature: | 180 case kStandardDerivatives_GLSLFeature: |
181 if (!fGpu->glCaps().shaderDerivativeSupport()) { | 181 if (!fGpu->glCaps().shaderDerivativeSupport()) { |
182 return false; | 182 return false; |
183 } | 183 } |
184 if (kES_GrGLBinding == fGpu->glBinding()) { | 184 if (kGLES_GrGLStandard == fGpu->glStandard()) { |
185 this->addFSFeature(1 << kStandardDerivatives_GLSLFeature, | 185 this->addFSFeature(1 << kStandardDerivatives_GLSLFeature, |
186 "GL_OES_standard_derivatives"); | 186 "GL_OES_standard_derivatives"); |
187 } | 187 } |
188 return true; | 188 return true; |
189 default: | 189 default: |
190 GrCrash("Unexpected GLSLFeature requested."); | 190 GrCrash("Unexpected GLSLFeature requested."); |
191 return false; | 191 return false; |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 } | 464 } |
465 } | 465 } |
466 fFSFunctions.append(") {\n"); | 466 fFSFunctions.append(") {\n"); |
467 fFSFunctions.append(body); | 467 fFSFunctions.append(body); |
468 fFSFunctions.append("}\n\n"); | 468 fFSFunctions.append("}\n\n"); |
469 } | 469 } |
470 | 470 |
471 namespace { | 471 namespace { |
472 | 472 |
473 inline void append_default_precision_qualifier(GrGLShaderVar::Precision p, | 473 inline void append_default_precision_qualifier(GrGLShaderVar::Precision p, |
474 GrGLBinding binding, | 474 GrGLStandard standard, |
475 SkString* str) { | 475 SkString* str) { |
476 // Desktop GLSL has added precision qualifiers but they don't do anything. | 476 // Desktop GLSL has added precision qualifiers but they don't do anything. |
477 if (kES_GrGLBinding == binding) { | 477 if (kGLES_GrGLStandard == standard) { |
478 switch (p) { | 478 switch (p) { |
479 case GrGLShaderVar::kHigh_Precision: | 479 case GrGLShaderVar::kHigh_Precision: |
480 str->append("precision highp float;\n"); | 480 str->append("precision highp float;\n"); |
481 break; | 481 break; |
482 case GrGLShaderVar::kMedium_Precision: | 482 case GrGLShaderVar::kMedium_Precision: |
483 str->append("precision mediump float;\n"); | 483 str->append("precision mediump float;\n"); |
484 break; | 484 break; |
485 case GrGLShaderVar::kLow_Precision: | 485 case GrGLShaderVar::kLow_Precision: |
486 str->append("precision lowp float;\n"); | 486 str->append("precision lowp float;\n"); |
487 break; | 487 break; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 | 682 |
683 GR_GL_CALL(gli, AttachShader(programId, shaderId)); | 683 GR_GL_CALL(gli, AttachShader(programId, shaderId)); |
684 GR_GL_CALL(gli, DeleteShader(shaderId)); | 684 GR_GL_CALL(gli, DeleteShader(shaderId)); |
685 return true; | 685 return true; |
686 } | 686 } |
687 | 687 |
688 bool GrGLShaderBuilder::compileAndAttachShaders(GrGLuint programId) const { | 688 bool GrGLShaderBuilder::compileAndAttachShaders(GrGLuint programId) const { |
689 SkString fragShaderSrc(GrGetGLSLVersionDecl(this->ctxInfo())); | 689 SkString fragShaderSrc(GrGetGLSLVersionDecl(this->ctxInfo())); |
690 fragShaderSrc.append(fFSExtensions); | 690 fragShaderSrc.append(fFSExtensions); |
691 append_default_precision_qualifier(kDefaultFragmentPrecision, | 691 append_default_precision_qualifier(kDefaultFragmentPrecision, |
692 fGpu->glBinding(), | 692 fGpu->glStandard(), |
693 &fragShaderSrc); | 693 &fragShaderSrc); |
694 this->appendUniformDecls(kFragment_Visibility, &fragShaderSrc); | 694 this->appendUniformDecls(kFragment_Visibility, &fragShaderSrc); |
695 this->appendDecls(fFSInputs, &fragShaderSrc); | 695 this->appendDecls(fFSInputs, &fragShaderSrc); |
696 // We shouldn't have declared outputs on 1.10 | 696 // We shouldn't have declared outputs on 1.10 |
697 SkASSERT(k110_GrGLSLGeneration != fGpu->glslGeneration() || fFSOutputs.empty
()); | 697 SkASSERT(k110_GrGLSLGeneration != fGpu->glslGeneration() || fFSOutputs.empty
()); |
698 this->appendDecls(fFSOutputs, &fragShaderSrc); | 698 this->appendDecls(fFSOutputs, &fragShaderSrc); |
699 fragShaderSrc.append(fFSFunctions); | 699 fragShaderSrc.append(fFSFunctions); |
700 fragShaderSrc.append("void main() {\n"); | 700 fragShaderSrc.append("void main() {\n"); |
701 fragShaderSrc.append(fFSCode); | 701 fragShaderSrc.append(fFSCode); |
702 fragShaderSrc.append("}\n"); | 702 fragShaderSrc.append("}\n"); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 GrGLSLExpr4* inOutFSColor) { | 977 GrGLSLExpr4* inOutFSColor) { |
978 | 978 |
979 GrGLTexGenProgramEffectsBuilder texGenEffectsBuilder(this, effectCnt); | 979 GrGLTexGenProgramEffectsBuilder texGenEffectsBuilder(this, effectCnt); |
980 this->INHERITED::createAndEmitEffects(&texGenEffectsBuilder, | 980 this->INHERITED::createAndEmitEffects(&texGenEffectsBuilder, |
981 effectStages, | 981 effectStages, |
982 effectKeys, | 982 effectKeys, |
983 effectCnt, | 983 effectCnt, |
984 inOutFSColor); | 984 inOutFSColor); |
985 return texGenEffectsBuilder.finish(); | 985 return texGenEffectsBuilder.finish(); |
986 } | 986 } |
OLD | NEW |