diff options
-rw-r--r-- | src/gpu/GrOvalRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrAAConvexPathRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrPLSPathRenderer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrBezierEffect.cpp | 12 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 7 | ||||
-rw-r--r-- | src/gpu/gl/builders/GrGLShaderStringBuilder.cpp | 4 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp | 8 | ||||
-rw-r--r-- | src/gpu/glsl/GrGLSLFragmentShaderBuilder.h | 3 | ||||
-rw-r--r-- | src/gpu/instanced/InstanceProcessor.cpp | 1 | ||||
-rw-r--r-- | src/sksl/SkSLCompiler.cpp | 5 | ||||
-rw-r--r-- | src/sksl/SkSLGLSLCodeGenerator.cpp | 18 | ||||
-rw-r--r-- | src/sksl/SkSLGLSLCodeGenerator.h | 36 | ||||
-rw-r--r-- | src/sksl/SkSLMain.cpp | 14 | ||||
-rw-r--r-- | src/sksl/ir/SkSLFunctionDeclaration.h | 2 | ||||
-rw-r--r-- | src/sksl/ir/SkSLSymbolTable.cpp | 18 | ||||
-rw-r--r-- | src/sksl/ir/SkSLSymbolTable.h | 2 | ||||
-rw-r--r-- | tests/SkSLGLSLTest.cpp | 37 |
17 files changed, 80 insertions, 95 deletions
diff --git a/src/gpu/GrOvalRenderer.cpp b/src/gpu/GrOvalRenderer.cpp index d04502ecec..39221a6720 100644 --- a/src/gpu/GrOvalRenderer.cpp +++ b/src/gpu/GrOvalRenderer.cpp @@ -463,6 +463,8 @@ private: diegp.fInPosition->fName, args.fFPCoordTransformHandler); + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); // for outer curve fragBuilder->codeAppendf("vec2 scaledOffset = %s.xy;", offsets0.fsIn()); fragBuilder->codeAppend("float test = dot(scaledOffset, scaledOffset) - 1.0;"); diff --git a/src/gpu/batches/GrAAConvexPathRenderer.cpp b/src/gpu/batches/GrAAConvexPathRenderer.cpp index f02be4c0ec..c71f46de66 100644 --- a/src/gpu/batches/GrAAConvexPathRenderer.cpp +++ b/src/gpu/batches/GrAAConvexPathRenderer.cpp @@ -579,6 +579,8 @@ public: qe.localMatrix(), args.fFPCoordTransformHandler); + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fragBuilder->codeAppendf("float edgeAlpha;"); // keep the derivative instructions outside the conditional diff --git a/src/gpu/batches/GrPLSPathRenderer.cpp b/src/gpu/batches/GrPLSPathRenderer.cpp index f20fb1337e..e8711c09de 100644 --- a/src/gpu/batches/GrPLSPathRenderer.cpp +++ b/src/gpu/batches/GrPLSPathRenderer.cpp @@ -339,6 +339,8 @@ public: GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; SkAssertResult(fsBuilder->enableFeature( GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLFeature)); + SkAssertResult(fsBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fsBuilder->declAppendf(GR_GL_PLS_PATH_DATA_DECL); // Compute four subsamples, each shifted a quarter pixel along x and y from // gl_FragCoord. The oriented box positioning of the subsamples is of course not @@ -520,6 +522,8 @@ public: GrGLSLPPFragmentBuilder* fsBuilder = args.fFragBuilder; SkAssertResult(fsBuilder->enableFeature( GrGLSLFragmentShaderBuilder::kPixelLocalStorage_GLSLFeature)); + SkAssertResult(fsBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); static const int QUAD_ARGS = 2; GrGLSLShaderVar inQuadArgs[QUAD_ARGS] = { GrGLSLShaderVar("dot", kFloat_GrSLType, 0, kHigh_GrSLPrecision), diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp index 7f39b927c9..798695d4ec 100644 --- a/src/gpu/effects/GrBezierEffect.cpp +++ b/src/gpu/effects/GrBezierEffect.cpp @@ -136,6 +136,8 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { switch (fEdgeType) { case kHairlineAA_GrProcessorEdgeType: { + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fragBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), v.fsIn()); fragBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), v.fsIn()); fragBuilder->codeAppendf("%s = 2.0 * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;", @@ -163,6 +165,8 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { break; } case kFillAA_GrProcessorEdgeType: { + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fragBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), v.fsIn()); fragBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), v.fsIn()); fragBuilder->codeAppendf("%s =" @@ -370,6 +374,8 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { switch (fEdgeType) { case kHairlineAA_GrProcessorEdgeType: { + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); fragBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.y," @@ -384,6 +390,8 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { break; } case kFillAA_GrProcessorEdgeType: { + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fragBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); fragBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", v.fsIn()); fragBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.y," @@ -584,6 +592,8 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { switch (fEdgeType) { case kHairlineAA_GrProcessorEdgeType: { + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fragBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), v.fsIn()); fragBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), v.fsIn()); fragBuilder->codeAppendf("%s = 3.0 * %s.x * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;", @@ -610,6 +620,8 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) { break; } case kFillAA_GrProcessorEdgeType: { + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); fragBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), v.fsIn()); fragBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), v.fsIn()); fragBuilder->codeAppendf("%s =" diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 7f9fd85e6b..5404b0c805 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -35,6 +35,8 @@ public: const GrDistanceFieldA8TextGeoProc& dfTexEffect = args.fGP.cast<GrDistanceFieldA8TextGeoProc>(); GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder; + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; @@ -311,6 +313,8 @@ public: const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistanceFieldPathGeoProc>(); GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder; + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder; GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler; @@ -606,6 +610,9 @@ public: // add frag shader code + SkAssertResult(fragBuilder->enableFeature( + GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); + // create LCD offset adjusted by inverse of transform // Use highp to work around aliasing issues fragBuilder->appendPrecisionModifier(kHigh_GrSLPrecision); diff --git a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp index 880e577b36..8e8bb9a0fc 100644 --- a/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp +++ b/src/gpu/gl/builders/GrGLShaderStringBuilder.cpp @@ -85,10 +85,6 @@ SkSL::GLCaps GrGLSkSLCapsForContext(const GrGLContext& context) { result.fIsCoreProfile = caps->isCoreProfile(); result.fUsesPrecisionModifiers = glslCaps->usesPrecisionModifiers(); result.fMustDeclareFragmentShaderOutput = glslCaps->mustDeclareFragmentShaderOutput(); - result.fShaderDerivativeSupport = glslCaps->shaderDerivativeSupport(); - if (glslCaps->shaderDerivativeExtensionString()) { - result.fShaderDerivativeExtensionString = glslCaps->shaderDerivativeExtensionString(); - } result.fCanUseMinAndAbsTogether = glslCaps->canUseMinAndAbsTogether(); result.fMustForceNegatedAtanParamToFloat = glslCaps->mustForceNegatedAtanParamToFloat(); return result; diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp index db420c8439..eb744a9915 100644 --- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp +++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.cpp @@ -96,6 +96,14 @@ GrGLSLFragmentShaderBuilder::GrGLSLFragmentShaderBuilder(GrGLSLProgramBuilder* p bool GrGLSLFragmentShaderBuilder::enableFeature(GLSLFeature feature) { const GrGLSLCaps& glslCaps = *fProgramBuilder->glslCaps(); switch (feature) { + case kStandardDerivatives_GLSLFeature: + if (!glslCaps.shaderDerivativeSupport()) { + return false; + } + if (const char* extension = glslCaps.shaderDerivativeExtensionString()) { + this->addFeature(1 << kStandardDerivatives_GLSLFeature, extension); + } + return true; case kPixelLocalStorage_GLSLFeature: if (glslCaps.pixelLocalStorageSize() <= 0) { return false; diff --git a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h index bf8569c073..6a4a184829 100644 --- a/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h +++ b/src/gpu/glsl/GrGLSLFragmentShaderBuilder.h @@ -29,7 +29,8 @@ public: * if code is added that uses one of these features without calling enableFeature() */ enum GLSLFeature { - kPixelLocalStorage_GLSLFeature = kLastGLSLPrivateFeature + 1, + kStandardDerivatives_GLSLFeature = kLastGLSLPrivateFeature + 1, + kPixelLocalStorage_GLSLFeature, kMultisampleInterpolation_GLSLFeature }; diff --git a/src/gpu/instanced/InstanceProcessor.cpp b/src/gpu/instanced/InstanceProcessor.cpp index 55be89ebb6..82116c4522 100644 --- a/src/gpu/instanced/InstanceProcessor.cpp +++ b/src/gpu/instanced/InstanceProcessor.cpp @@ -1408,6 +1408,7 @@ void GLSLInstanceProcessor::BackendMultisample::onEmitCode(GrGLSLVertexBuilder*, if (arcTest && fBatchInfo.fHasPerspective) { // The non-perspective version accounts for fwidth() in the vertex shader. // We make sure to take the derivative here, before a neighbor pixel may early accept. + f->enableFeature(GrGLSLPPFragmentBuilder::kStandardDerivatives_GLSLFeature); f->appendPrecisionModifier(kHigh_GrSLPrecision); f->codeAppendf("vec2 arcTest = %s - 0.5 * fwidth(%s);", fArcTest.fsIn(), fArcTest.fsIn()); diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp index 5b502dce2f..d4fbc95d39 100644 --- a/src/sksl/SkSLCompiler.cpp +++ b/src/sksl/SkSLCompiler.cpp @@ -19,7 +19,6 @@ #include "ir/SkSLIntLiteral.h" #include "ir/SkSLModifiersDeclaration.h" #include "ir/SkSLSymbolTable.h" -#include "ir/SkSLUnresolvedFunction.h" #include "ir/SkSLVarDeclarations.h" #include "SkMutex.h" @@ -136,7 +135,6 @@ Compiler::Compiler() Modifiers::Flag ignored1; std::vector<std::unique_ptr<ProgramElement>> ignored2; this->internalConvertProgram(SKSL_INCLUDE, &ignored1, &ignored2); - fIRGenerator->fSymbolTable->markAllFunctionsBuiltin(); ASSERT(!fErrorCount); } @@ -395,11 +393,10 @@ std::unique_ptr<Program> Compiler::convertProgram(Program::Kind kind, std::strin this->internalConvertProgram(SKSL_FRAG_INCLUDE, &ignored, &elements); break; } - fIRGenerator->fSymbolTable->markAllFunctionsBuiltin(); Modifiers::Flag defaultPrecision; this->internalConvertProgram(text, &defaultPrecision, &elements); auto result = std::unique_ptr<Program>(new Program(kind, defaultPrecision, std::move(elements), - fIRGenerator->fSymbolTable)); + fIRGenerator->fSymbolTable));; fIRGenerator->popSymbolTable(); this->writeErrorCount(); return result; diff --git a/src/sksl/SkSLGLSLCodeGenerator.cpp b/src/sksl/SkSLGLSLCodeGenerator.cpp index 8a26f6a713..45644e8cd1 100644 --- a/src/sksl/SkSLGLSLCodeGenerator.cpp +++ b/src/sksl/SkSLGLSLCodeGenerator.cpp @@ -150,7 +150,7 @@ void GLSLCodeGenerator::writeMinAbsHack(Expression& absExpr, Expression& otherEx } void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) { - if (!fCaps.fCanUseMinAndAbsTogether && c.fFunction.fName == "min" && c.fFunction.fBuiltin) { + if (!fCaps.fCanUseMinAndAbsTogether && c.fFunction.fName == "min") { ASSERT(c.fArguments.size() == 2); if (is_abs(*c.fArguments[0])) { this->writeMinAbsHack(*c.fArguments[0], *c.fArguments[1]); @@ -164,8 +164,7 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) { } } if (fCaps.fMustForceNegatedAtanParamToFloat && c.fFunction.fName == "atan" && - c.fFunction.fBuiltin && c.fArguments.size() == 2 && - c.fArguments[1]->fKind == Expression::kPrefix_Kind) { + c.fArguments.size() == 2 && c.fArguments[1]->fKind == Expression::kPrefix_Kind) { const PrefixExpression& p = (PrefixExpression&) *c.fArguments[1]; if (p.fOperator == Token::MINUS) { this->write("atan("); @@ -176,12 +175,6 @@ void GLSLCodeGenerator::writeFunctionCall(const FunctionCall& c) { return; } } - if (!fFoundDerivatives && fCaps.fShaderDerivativeExtensionString != "" && - (c.fFunction.fName == "dFdx" || c.fFunction.fName == "dFdy") && c.fFunction.fBuiltin) { - ASSERT(fCaps.fShaderDerivativeSupport); - fHeader << "#extension " << fCaps.fShaderDerivativeExtensionString << " : require\n"; - fFoundDerivatives = true; - } this->write(c.fFunction.fName + "("); const char* separator = ""; for (const auto& arg : c.fArguments) { @@ -585,7 +578,7 @@ void GLSLCodeGenerator::writeReturnStatement(const ReturnStatement& r) { void GLSLCodeGenerator::generateCode(const Program& program, std::ostream& out) { ASSERT(fOut == nullptr); - fOut = &fHeader; + fOut = &out; fProgramKind = program.fKind; this->write("#version " + to_string(fCaps.fVersion)); if (fCaps.fStandard == GLCaps::kGLES_Standard && fCaps.fVersion >= 300) { @@ -599,8 +592,6 @@ void GLSLCodeGenerator::generateCode(const Program& program, std::ostream& out) this->writeExtension((Extension&) *e); } } - std::stringstream body; - fOut = &body; if (fCaps.fStandard == GLCaps::kGLES_Standard) { this->write("precision "); switch (program.fDefaultPrecision) { @@ -658,9 +649,6 @@ void GLSLCodeGenerator::generateCode(const Program& program, std::ostream& out) } } fOut = nullptr; - - out << fHeader.str(); - out << body.str(); } } diff --git a/src/sksl/SkSLGLSLCodeGenerator.h b/src/sksl/SkSLGLSLCodeGenerator.h index 97e6038146..17ac90ea23 100644 --- a/src/sksl/SkSLGLSLCodeGenerator.h +++ b/src/sksl/SkSLGLSLCodeGenerator.h @@ -45,25 +45,20 @@ namespace SkSL { #define kLast_Capability SpvCapabilityMultiViewport struct GLCaps { - GLCaps() {} - - int fVersion = 400; + int fVersion; enum { kGL_Standard, kGLES_Standard - } fStandard = kGL_Standard; - bool fIsCoreProfile = false; - bool fUsesPrecisionModifiers = false; - bool fMustDeclareFragmentShaderOutput = false; - bool fShaderDerivativeSupport = true; - // extension string to enable derivative support, or null if unnecessary - std::string fShaderDerivativeExtensionString; + } fStandard; + bool fIsCoreProfile; + bool fUsesPrecisionModifiers; + bool fMustDeclareFragmentShaderOutput; // The Tegra3 compiler will sometimes never return if we have min(abs(x), y) - bool fCanUseMinAndAbsTogether = true; + bool fCanUseMinAndAbsTogether; // On Intel GPU there is an issue where it misinterprets an atan argument (second argument only, // apparently) of the form "-<expr>" as an int, so we rewrite it as "-1.0 * <expr>" to avoid // this problem - bool fMustForceNegatedAtanParamToFloat = false; + bool fMustForceNegatedAtanParamToFloat; }; /** @@ -94,7 +89,11 @@ public: GLSLCodeGenerator(const Context* context, GLCaps caps) : fContext(*context) - , fCaps(caps) {} + , fCaps(caps) + , fOut(nullptr) + , fVarCount(0) + , fIndentation(0) + , fAtLineStart(true) {} void generateCode(const Program& program, std::ostream& out) override; @@ -177,19 +176,16 @@ private: const Context& fContext; const GLCaps fCaps; - std::ostream* fOut = nullptr; - std::stringstream fHeader; + std::ostream* fOut; std::string fFunctionHeader; Program::Kind fProgramKind; - int fVarCount = 0; - int fIndentation = 0; - bool fAtLineStart = false; + int fVarCount; + int fIndentation; + bool fAtLineStart; // Keeps track of which struct types we have written. Given that we are unlikely to ever write // more than one or two structs per shader, a simple linear search will be faster than anything // fancier. std::vector<const Type*> fWrittenStructs; - // true if we have run into usages of dFdx / dFdy - bool fFoundDerivatives = false; }; } diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp index eb07b4d032..fe925e0c6e 100644 --- a/src/sksl/SkSLMain.cpp +++ b/src/sksl/SkSLMain.cpp @@ -16,6 +16,18 @@ bool endsWith(const std::string& s, const std::string& ending) { return false; } +static SkSL::GLCaps default_caps() { + return { + 400, + SkSL::GLCaps::kGL_Standard, + false, // isCoreProfile + false, // usesPrecisionModifiers; + false, // mustDeclareFragmentShaderOutput + true, // canUseMinAndAbsTogether + false // mustForceNegatedAtanParamToFloat + }; +} + /** * Very simple standalone executable to facilitate testing. */ @@ -57,7 +69,7 @@ int main(int argc, const char** argv) { } else if (endsWith(name, ".glsl")) { std::ofstream out(argv[2], std::ofstream::binary); SkSL::Compiler compiler; - if (!compiler.toGLSL(kind, text, SkSL::GLCaps(), out)) { + if (!compiler.toGLSL(kind, text, default_caps(), out)) { printf("%s", compiler.errorText().c_str()); exit(3); } diff --git a/src/sksl/ir/SkSLFunctionDeclaration.h b/src/sksl/ir/SkSLFunctionDeclaration.h index ffde0c66c1..16a184a6d7 100644 --- a/src/sksl/ir/SkSLFunctionDeclaration.h +++ b/src/sksl/ir/SkSLFunctionDeclaration.h @@ -24,7 +24,6 @@ struct FunctionDeclaration : public Symbol { std::vector<const Variable*> parameters, const Type& returnType) : INHERITED(position, kFunctionDeclaration_Kind, std::move(name)) , fDefined(false) - , fBuiltin(false) , fParameters(std::move(parameters)) , fReturnType(returnType) {} @@ -56,7 +55,6 @@ struct FunctionDeclaration : public Symbol { } mutable bool fDefined; - bool fBuiltin; const std::vector<const Variable*> fParameters; const Type& fReturnType; diff --git a/src/sksl/ir/SkSLSymbolTable.cpp b/src/sksl/ir/SkSLSymbolTable.cpp index 6d8e9a7ea6..9d8c0063c5 100644 --- a/src/sksl/ir/SkSLSymbolTable.cpp +++ b/src/sksl/ir/SkSLSymbolTable.cpp @@ -97,22 +97,4 @@ void SymbolTable::addWithoutOwnership(const std::string& name, const Symbol* sym } } - -void SymbolTable::markAllFunctionsBuiltin() { - for (const auto& pair : fSymbols) { - switch (pair.second->fKind) { - case Symbol::kFunctionDeclaration_Kind: - ((FunctionDeclaration&) *pair.second).fBuiltin = true; - break; - case Symbol::kUnresolvedFunction_Kind: - for (auto& f : ((UnresolvedFunction&) *pair.second).fFunctions) { - ((FunctionDeclaration*) f)->fBuiltin = true; - } - break; - default: - break; - } - } -} - } // namespace diff --git a/src/sksl/ir/SkSLSymbolTable.h b/src/sksl/ir/SkSLSymbolTable.h index be2b49c48d..d732023ff0 100644 --- a/src/sksl/ir/SkSLSymbolTable.h +++ b/src/sksl/ir/SkSLSymbolTable.h @@ -39,8 +39,6 @@ public: Symbol* takeOwnership(Symbol* s); - void markAllFunctionsBuiltin(); - const std::shared_ptr<SymbolTable> fParent; private: diff --git a/tests/SkSLGLSLTest.cpp b/tests/SkSLGLSLTest.cpp index ad1fe0d901..b615f67814 100644 --- a/tests/SkSLGLSLTest.cpp +++ b/tests/SkSLGLSLTest.cpp @@ -27,7 +27,15 @@ static void test(skiatest::Reporter* r, const char* src, SkSL::GLCaps caps, cons } static SkSL::GLCaps default_caps() { - return SkSL::GLCaps(); + return { + 400, + SkSL::GLCaps::kGL_Standard, + false, // isCoreProfile + false, // usesPrecisionModifiers; + false, // mustDeclareFragmentShaderOutput + true, // canUseMinAndAbsTogether + false // mustForceNegatedAtanParamToFloat + }; } DEF_TEST(SkSLHelloWorld, r) { @@ -379,30 +387,3 @@ DEF_TEST(SkSLArrayConstructors, r) { "vec2 test2[] = vec2[](vec2(1.0, 2.0), vec2(3.0, 4.0));\n" "mat4 test3[] = mat4[]();\n"); } - -DEF_TEST(SkSLDerivatives, r) { - test(r, - "void main() { float x = dFdx(1); }", - default_caps(), - "#version 400\n" - "void main() {\n" - " float x = dFdx(1.0);\n" - "}\n"); - SkSL::GLCaps caps = default_caps(); - caps.fShaderDerivativeExtensionString = "GL_OES_standard_derivatives"; - test(r, - "void main() { float x = 1; }", - caps, - "#version 400\n" - "void main() {\n" - " float x = 1.0;\n" - "}\n"); - test(r, - "void main() { float x = dFdx(1); }", - caps, - "#version 400\n" - "#extension GL_OES_standard_derivatives : require\n" - "void main() {\n" - " float x = dFdx(1.0);\n" - "}\n"); -} |