diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-01 22:20:59 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-04-01 22:20:59 +0000 |
commit | 97055966846f1d3312714d4b811124443aecf681 (patch) | |
tree | cf132d841acbe56154cdd3cc28b27c9627637790 /src/gpu/gl | |
parent | 01f010cffe0b540a1d31d3779edcfcef23e26a45 (diff) |
Reverting r8459 due to shader error on Nexus 10
git-svn-id: http://skia.googlecode.com/svn/trunk@8474 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGLProgram.cpp | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLSL.cpp | 10 | ||||
-rw-r--r-- | src/gpu/gl/GrGLShaderBuilder.cpp | 54 | ||||
-rw-r--r-- | src/gpu/gl/GrGLShaderBuilder.h | 30 |
4 files changed, 16 insertions, 80 deletions
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp index 51cae5c8c8..e1fa3a2613 100644 --- a/src/gpu/gl/GrGLProgram.cpp +++ b/src/gpu/gl/GrGLProgram.cpp @@ -462,6 +462,8 @@ bool GrGLProgram::genProgram(const GrEffectStage* stages[]) { // the dual source output has no canonical var name, have to // declare an output, which is incompatible with gl_FragColor/gl_FragData. bool dualSourceOutputWritten = false; + builder.fHeader.append(GrGetGLSLVersionDecl(fContext.info().binding(), + fContext.info().glslGeneration())); GrGLShaderVar colorOutput; bool isColorDeclared = GrGLSLSetupFSColorOuput(fContext.info().glslGeneration(), diff --git a/src/gpu/gl/GrGLSL.cpp b/src/gpu/gl/GrGLSL.cpp index 3ec7fc45b2..b7946fc07a 100644 --- a/src/gpu/gl/GrGLSL.cpp +++ b/src/gpu/gl/GrGLSL.cpp @@ -9,7 +9,8 @@ #include "GrGLShaderVar.h" #include "SkString.h" -GrGLSLGeneration GrGetGLSLGeneration(GrGLBinding binding, const GrGLInterface* gl) { +GrGLSLGeneration GrGetGLSLGeneration(GrGLBinding binding, + const GrGLInterface* gl) { GrGLSLVersion ver = GrGLGetGLSLVersion(gl); switch (binding) { case kDesktop_GrGLBinding: @@ -33,7 +34,8 @@ GrGLSLGeneration GrGetGLSLGeneration(GrGLBinding binding, const GrGLInterface* g } } -const char* GrGetGLSLVersionDecl(GrGLBinding binding, GrGLSLGeneration gen) { +const char* GrGetGLSLVersionDecl(GrGLBinding binding, + GrGLSLGeneration gen) { switch (gen) { case k110_GrGLSLGeneration: if (kES2_GrGLBinding == binding) { @@ -59,7 +61,9 @@ const char* GrGetGLSLVersionDecl(GrGLBinding binding, GrGLSLGeneration gen) { } } -bool GrGLSLSetupFSColorOuput(GrGLSLGeneration gen, const char* nameIfDeclared, GrGLShaderVar* var) { +bool GrGLSLSetupFSColorOuput(GrGLSLGeneration gen, + const char* nameIfDeclared, + GrGLShaderVar* var) { bool declaredOutput = k110_GrGLSLGeneration != gen; var->set(kVec4f_GrSLType, GrGLShaderVar::kOut_TypeModifier, diff --git a/src/gpu/gl/GrGLShaderBuilder.cpp b/src/gpu/gl/GrGLShaderBuilder.cpp index 1104cd0cb7..0e91df296f 100644 --- a/src/gpu/gl/GrGLShaderBuilder.cpp +++ b/src/gpu/gl/GrGLShaderBuilder.cpp @@ -104,7 +104,6 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, , fCtxInfo(ctxInfo) , fUniformManager(uniformManager) , fCurrentStageIdx(kNonStageIdx) - , fFSFeaturesAddedMask(0) #if GR_GL_EXPERIMENTAL_GS , fUsesGS(desc.fExperimentalGS) #else @@ -158,47 +157,6 @@ GrGLShaderBuilder::GrGLShaderBuilder(const GrGLContextInfo& ctxInfo, } } -bool GrGLShaderBuilder::enableFeature(GLSLFeature feature) { - switch (feature) { - case kStandardDerivatives_GLSLFeature: - if (!fCtxInfo.caps()->shaderDerivativeSupport()) { - return false; - } - if (kES2_GrGLBinding == fCtxInfo.binding()) { - this->addFSFeature(1 << kStandardDerivatives_GLSLFeature, - "GL_OES_standard_derivatives"); - } - return true; - default: - GrCrash("Unexpected GLSLFeature requested."); - return false; - } -} - -bool GrGLShaderBuilder::enablePrivateFeature(GLSLPrivateFeature feature) { - switch (feature) { - case kFragCoordConventions_GLSLPrivateFeature: - if (!fCtxInfo.caps()->fragCoordConventionsSupport()) { - return false; - } - if (fCtxInfo.glslGeneration() < k150_GrGLSLGeneration) { - this->addFSFeature(1 << kFragCoordConventions_GLSLPrivateFeature, - "GL_ARB_fragment_coord_conventions"); - } - return true; - default: - GrCrash("Unexpected GLSLPrivateFeature requested."); - return false; - } -} - -void GrGLShaderBuilder::addFSFeature(uint32_t featureBit, const char* extensionName) { - if (!(featureBit & fFSFeaturesAddedMask)) { - fFSHeader.appendf("#extension %s: require\n", extensionName); - fFSFeaturesAddedMask |= featureBit; - } -} - const char* GrGLShaderBuilder::dstColor() const { if (fDstCopySampler.isInitialized()) { return kDstColorName; @@ -430,7 +388,9 @@ const char* GrGLShaderBuilder::fragmentPosition() { #if 1 if (fCtxInfo.caps()->fragCoordConventionsSupport()) { if (!fSetupFragPosition) { - SkAssertResult(this->enablePrivateFeature(kFragCoordConventions_GLSLPrivateFeature)); + if (fCtxInfo.glslGeneration() < k150_GrGLSLGeneration) { + fFSHeader.append("#extension GL_ARB_fragment_coord_conventions: require\n"); + } fFSInputs.push_back().set(kVec4f_GrSLType, GrGLShaderVar::kIn_TypeModifier, "gl_FragCoord", @@ -547,11 +507,9 @@ void GrGLShaderBuilder::appendUniformDecls(ShaderType stype, SkString* out) cons } void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const { - const char* version = GrGetGLSLVersionDecl(fCtxInfo.binding(), fCtxInfo.glslGeneration()); - switch (type) { case kVertex_ShaderType: - *shaderStr = version; + *shaderStr = fHeader; this->appendUniformDecls(kVertex_ShaderType, shaderStr); this->appendDecls(fVSAttrs, shaderStr); this->appendDecls(fVSOutputs, shaderStr); @@ -561,7 +519,7 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const { break; case kGeometry_ShaderType: if (fUsesGS) { - *shaderStr = version; + *shaderStr = fHeader; shaderStr->append(fGSHeader); this->appendDecls(fGSInputs, shaderStr); this->appendDecls(fGSOutputs, shaderStr); @@ -573,7 +531,7 @@ void GrGLShaderBuilder::getShader(ShaderType type, SkString* shaderStr) const { } break; case kFragment_ShaderType: - *shaderStr = version; + *shaderStr = fHeader; append_default_precision_qualifier(kDefaultFragmentPrecision, fCtxInfo.binding(), shaderStr); diff --git a/src/gpu/gl/GrGLShaderBuilder.h b/src/gpu/gl/GrGLShaderBuilder.h index 8406793671..4e39f91e35 100644 --- a/src/gpu/gl/GrGLShaderBuilder.h +++ b/src/gpu/gl/GrGLShaderBuilder.h @@ -107,22 +107,6 @@ public: GrGLShaderBuilder(const GrGLContextInfo&, GrGLUniformManager&, const GrGLProgramDesc&); /** - * Use of these features may require a GLSL extension to be enabled. Shaders may not compile - * if code is added that uses one of these features without calling enableFeature() - */ - enum GLSLFeature { - kStandardDerivatives_GLSLFeature = 0, - - kLastGLSLFeature = kStandardDerivatives_GLSLFeature - }; - - /** - * If the feature is supported then true is returned and any necessary #extension declarations - * are added to the shaders. If the feature is not supported then false will be returned. - */ - bool enableFeature(GLSLFeature); - - /** * Called by GrGLEffects to add code to one of the shaders. */ void vsCodeAppendf(const char format[], ...) SK_PRINTF_LIKE(2, 3) { @@ -329,6 +313,7 @@ private: // TODO: Everything below here private. public: + SkString fHeader; // VS+FS, GLSL version, etc VarArray fVSAttrs; VarArray fVSOutputs; VarArray fGSInputs; @@ -342,18 +327,6 @@ private: kNonStageIdx = -1, }; - /** - * Features that should only be enabled by GrGLShaderBuilder itself. - */ - enum GLSLPrivateFeature { - kFragCoordConventions_GLSLPrivateFeature = kLastGLSLFeature + 1 - }; - bool enablePrivateFeature(GLSLPrivateFeature); - - // If we ever have VS/GS features we can expand this to take a bitmask of ShaderType and track - // the enables separately for each shader. - void addFSFeature(uint32_t featureBit, const char* extensionName); - // Interpretation of DstReadKey when generating code enum { kNoDstRead_DstReadKey = 0, @@ -365,7 +338,6 @@ private: const GrGLContextInfo& fCtxInfo; GrGLUniformManager& fUniformManager; int fCurrentStageIdx; - uint32_t fFSFeaturesAddedMask; SkString fFSFunctions; SkString fFSHeader; |