diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni index a62f633b0e..b15e0ba552 100644 --- a/gn/sksl_tests.gni +++ b/gn/sksl_tests.gni @@ -17,8 +17,6 @@ sksl_fp_error_tests = [ sksl_fp_tests = [ "/sksl/fp/GrChildProcessorAndGlobal.fp", - "/sksl/fp/GrChildProcessorFieldAccess.fp", - "/sksl/fp/GrChildProcessorInlineFieldAccess.fp", "/sksl/fp/GrChildProcessorSampleCoords.fp", "/sksl/fp/GrChildProcessorSampleMatrixAndCoords.fp", "/sksl/fp/GrChildProcessorSampleMatrixConstant.fp", diff --git a/resources/sksl/fp/GrChildProcessorFieldAccess.fp b/resources/sksl/fp/GrChildProcessorFieldAccess.fp deleted file mode 100644 index 5ad93ff662..0000000000 --- a/resources/sksl/fp/GrChildProcessorFieldAccess.fp +++ /dev/null @@ -1,10 +0,0 @@ -in fragmentProcessor child; -bool opaque = child.preservesOpaqueInput; - -half4 main() { - if (opaque) { - return sample(child); - } else { - return half4(0.5); - } -} diff --git a/resources/sksl/fp/GrChildProcessorInlineFieldAccess.fp b/resources/sksl/fp/GrChildProcessorInlineFieldAccess.fp deleted file mode 100644 index df1f8f28a3..0000000000 --- a/resources/sksl/fp/GrChildProcessorInlineFieldAccess.fp +++ /dev/null @@ -1,9 +0,0 @@ -in fragmentProcessor child; - -half4 main() { - if (child.preservesOpaqueInput) { - return sample(child); - } else { - return half4(1); - } -} diff --git a/src/sksl/SkSLBuiltinTypes.cpp b/src/sksl/SkSLBuiltinTypes.cpp index d369bd1dd9..42826cb536 100644 --- a/src/sksl/SkSLBuiltinTypes.cpp +++ b/src/sksl/SkSLBuiltinTypes.cpp @@ -14,20 +14,6 @@ namespace SkSL { -/** - * Returns the struct fields for FragmentProcessors; these are intended to parallel the C++ API for - * GrFragmentProcessor. - */ -static std::vector make_fp_fields(const Type* intType, const Type* boolType) { - Modifiers mods{Layout(), Modifiers::kConst_Flag}; - return {Type::Field(mods, "numTextureSamplers", intType), - Type::Field(mods, "numChildProcessors", intType), - Type::Field(mods, "usesLocalCoords", boolType), - Type::Field(mods, "compatibleWithCoverageAsAlpha", boolType), - Type::Field(mods, "preservesOpaqueInput", boolType), - Type::Field(mods, "hasConstantOutputForConstantInput", boolType)}; -} - /** Create a scalar type. */ std::unique_ptr BuiltinTypes::MakeScalarType(const char* name, Type::NumberKind numberKind, @@ -96,12 +82,6 @@ std::unique_ptr BuiltinTypes::MakeOtherType(const char* name) { return std::unique_ptr(new Type(name)); } -/** Create an "other" (special) type that supports field access. */ -std::unique_ptr BuiltinTypes::MakeOtherStruct(const char* name, - std::vector fields) { - return std::unique_ptr(new Type(name, std::move(fields))); -} - /** * Initializes the core SkSL types. */ @@ -272,7 +252,6 @@ BuiltinTypes::BuiltinTypes() , fBVec(MakeGenericType("$bvec", {fInvalid.get(), fBool2.get(), fBool3.get(), fBool4.get()})) , fSkCaps(MakeOtherType("$sk_Caps")) - , fFragmentProcessor( - MakeOtherStruct("fragmentProcessor", make_fp_fields(fInt.get(), fBool.get()))) {} + , fFragmentProcessor(MakeOtherType("fragmentProcessor")) {} } // namespace SkSL diff --git a/src/sksl/SkSLBuiltinTypes.h b/src/sksl/SkSLBuiltinTypes.h index 9c9bb2fb2b..e8088bbefd 100644 --- a/src/sksl/SkSLBuiltinTypes.h +++ b/src/sksl/SkSLBuiltinTypes.h @@ -154,7 +154,6 @@ private: static std::unique_ptr MakeSamplerType(const char* name, const Type& textureType); static std::unique_ptr MakeSeparateSamplerType(const char* name); static std::unique_ptr MakeOtherType(const char* name); - static std::unique_ptr MakeOtherStruct(const char* name, std::vector fields); }; } // namespace SkSL diff --git a/src/sksl/SkSLCPPCodeGenerator.cpp b/src/sksl/SkSLCPPCodeGenerator.cpp index ccf2e04072..487bf652a6 100644 --- a/src/sksl/SkSLCPPCodeGenerator.cpp +++ b/src/sksl/SkSLCPPCodeGenerator.cpp @@ -344,32 +344,6 @@ void CPPCodeGenerator::writeSwitchStatement(const SwitchStatement& s) { INHERITED::writeSwitchStatement(s); } -void CPPCodeGenerator::writeFieldAccess(const FieldAccess& access) { - if (access.base()->type().name() == "fragmentProcessor") { - // Special field access on fragment processors are converted into function calls on - // GrFragmentProcessor's getters. - if (!access.base()->is()) { - fErrors.error(access.base()->fOffset, "fragmentProcessor must be a reference\n"); - return; - } - - const Type::Field& field = - fContext.fTypes.fFragmentProcessor->fields()[access.fieldIndex()]; - const Variable& var = *access.base()->as().variable(); - String cppAccess = String::printf("_outer.childProcessor(%d)->%s()", - this->getChildFPIndex(var), - String(field.fName).c_str()); - - if (fCPPMode) { - this->write(cppAccess.c_str()); - } else { - writeRuntimeValue(*field.fType, Layout(), cppAccess); - } - return; - } - INHERITED::writeFieldAccess(access); -} - int CPPCodeGenerator::getChildFPIndex(const Variable& var) const { int index = 0; for (const ProgramElement* p : fProgram.elements()) { diff --git a/src/sksl/SkSLCPPCodeGenerator.h b/src/sksl/SkSLCPPCodeGenerator.h index 252f5b7e7f..15a8bc9701 100644 --- a/src/sksl/SkSLCPPCodeGenerator.h +++ b/src/sksl/SkSLCPPCodeGenerator.h @@ -45,8 +45,6 @@ private: void writeSwizzle(const Swizzle& swizzle) override; - void writeFieldAccess(const FieldAccess& access) override; - void writeVariableReference(const VariableReference& ref) override; String getSamplerHandle(const Variable& var); diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp index c6fc6ad45a..4c5b1a756a 100644 --- a/src/sksl/SkSLIRGenerator.cpp +++ b/src/sksl/SkSLIRGenerator.cpp @@ -2604,7 +2604,6 @@ std::unique_ptr IRGenerator::convertFieldExpression(const ASTNode& f return std::make_unique(fieldNode.fOffset, field, type); } switch (baseType.typeKind()) { - case Type::TypeKind::kOther: case Type::TypeKind::kStruct: return this->convertField(std::move(base), field); default: diff --git a/src/sksl/ir/SkSLType.h b/src/sksl/ir/SkSLType.h index d43f2ea678..c863d9830b 100644 --- a/src/sksl/ir/SkSLType.h +++ b/src/sksl/ir/SkSLType.h @@ -282,7 +282,7 @@ public: } const std::vector& fields() const { - SkASSERT(this->isStruct() || fTypeKind == TypeKind::kOther); + SkASSERT(this->isStruct()); return fFields; } @@ -382,13 +382,6 @@ private: , fTypeKind(TypeKind::kOther) , fNumberKind(NumberKind::kNonnumeric) {} - // Constructor for MakeOtherStruct. - Type(const char* name, std::vector fields) - : INHERITED(-1, kSymbolKind, name) - , fTypeKind(TypeKind::kOther) - , fNumberKind(NumberKind::kNonnumeric) - , fFields(std::move(fields)) {} - // Constructor for MakeEnumType and MakeSeparateSamplerType. Type(String name, TypeKind kind) : INHERITED(-1, kSymbolKind, "") diff --git a/tests/sksl/fp/GrChildProcessorFieldAccess.cpp b/tests/sksl/fp/GrChildProcessorFieldAccess.cpp deleted file mode 100644 index b3029841d9..0000000000 --- a/tests/sksl/fp/GrChildProcessorFieldAccess.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -/************************************************************************************************** - *** This file was autogenerated from GrChildProcessorFieldAccess.fp; do not modify. - **************************************************************************************************/ -#include "GrChildProcessorFieldAccess.h" - -#include "src/core/SkUtils.h" -#include "src/gpu/GrTexture.h" -#include "src/gpu/glsl/GrGLSLFragmentProcessor.h" -#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" -#include "src/gpu/glsl/GrGLSLProgramBuilder.h" -#include "src/sksl/SkSLCPP.h" -#include "src/sksl/SkSLUtil.h" -class GrGLSLChildProcessorFieldAccess : public GrGLSLFragmentProcessor { -public: - GrGLSLChildProcessorFieldAccess() {} - void emitCode(EmitArgs& args) override { - GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; - const GrChildProcessorFieldAccess& _outer = args.fFp.cast(); - (void) _outer; -opaque = _outer.childProcessor(0)->preservesOpaqueInput(); - fragBuilder->codeAppendf( -R"SkSL(bool opaque = %s; -if (opaque) {)SkSL" -, (opaque ? "true" : "false")); - SkString _sample0 = this->invokeChild(0, args); - fragBuilder->codeAppendf( -R"SkSL( - return %s; -} else { - return half4(0.5); -} -)SkSL" -, _sample0.c_str()); - } -private: - void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override { - } -bool opaque = false; -}; -std::unique_ptr GrChildProcessorFieldAccess::onMakeProgramImpl() const { - return std::make_unique(); -} -void GrChildProcessorFieldAccess::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { -} -bool GrChildProcessorFieldAccess::onIsEqual(const GrFragmentProcessor& other) const { - const GrChildProcessorFieldAccess& that = other.cast(); - (void) that; - return true; -} -GrChildProcessorFieldAccess::GrChildProcessorFieldAccess(const GrChildProcessorFieldAccess& src) -: INHERITED(kGrChildProcessorFieldAccess_ClassID, src.optimizationFlags()) { - this->cloneAndRegisterAllChildProcessors(src); -} -std::unique_ptr GrChildProcessorFieldAccess::clone() const { - return std::make_unique(*this); -} -#if GR_TEST_UTILS -SkString GrChildProcessorFieldAccess::onDumpInfo() const { - return SkString(); -} -#endif diff --git a/tests/sksl/fp/GrChildProcessorFieldAccess.h b/tests/sksl/fp/GrChildProcessorFieldAccess.h deleted file mode 100644 index dbbfed8a2f..0000000000 --- a/tests/sksl/fp/GrChildProcessorFieldAccess.h +++ /dev/null @@ -1,36 +0,0 @@ - - -/************************************************************************************************** - *** This file was autogenerated from GrChildProcessorFieldAccess.fp; do not modify. - **************************************************************************************************/ -#ifndef GrChildProcessorFieldAccess_DEFINED -#define GrChildProcessorFieldAccess_DEFINED - -#include "include/core/SkM44.h" -#include "include/core/SkTypes.h" - - -#include "src/gpu/GrFragmentProcessor.h" - -class GrChildProcessorFieldAccess : public GrFragmentProcessor { -public: - static std::unique_ptr Make(std::unique_ptr child) { - return std::unique_ptr(new GrChildProcessorFieldAccess(std::move(child))); - } - GrChildProcessorFieldAccess(const GrChildProcessorFieldAccess& src); - std::unique_ptr clone() const override; - const char* name() const override { return "ChildProcessorFieldAccess"; } -private: - GrChildProcessorFieldAccess(std::unique_ptr child) - : INHERITED(kGrChildProcessorFieldAccess_ClassID, kNone_OptimizationFlags) { - this->registerChild(std::move(child), SkSL::SampleUsage::PassThrough()); } - std::unique_ptr onMakeProgramImpl() const override; - void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; - bool onIsEqual(const GrFragmentProcessor&) const override; -#if GR_TEST_UTILS - SkString onDumpInfo() const override; -#endif - GR_DECLARE_FRAGMENT_PROCESSOR_TEST - using INHERITED = GrFragmentProcessor; -}; -#endif diff --git a/tests/sksl/fp/GrChildProcessorInlineFieldAccess.cpp b/tests/sksl/fp/GrChildProcessorInlineFieldAccess.cpp deleted file mode 100644 index 50d805ba2b..0000000000 --- a/tests/sksl/fp/GrChildProcessorInlineFieldAccess.cpp +++ /dev/null @@ -1,60 +0,0 @@ - - -/************************************************************************************************** - *** This file was autogenerated from GrChildProcessorInlineFieldAccess.fp; do not modify. - **************************************************************************************************/ -#include "GrChildProcessorInlineFieldAccess.h" - -#include "src/core/SkUtils.h" -#include "src/gpu/GrTexture.h" -#include "src/gpu/glsl/GrGLSLFragmentProcessor.h" -#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h" -#include "src/gpu/glsl/GrGLSLProgramBuilder.h" -#include "src/sksl/SkSLCPP.h" -#include "src/sksl/SkSLUtil.h" -class GrGLSLChildProcessorInlineFieldAccess : public GrGLSLFragmentProcessor { -public: - GrGLSLChildProcessorInlineFieldAccess() {} - void emitCode(EmitArgs& args) override { - GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; - const GrChildProcessorInlineFieldAccess& _outer = args.fFp.cast(); - (void) _outer; - fragBuilder->codeAppendf( -R"SkSL(if (%s) {)SkSL" -, (_outer.childProcessor(0)->preservesOpaqueInput() ? "true" : "false")); - SkString _sample0 = this->invokeChild(0, args); - fragBuilder->codeAppendf( -R"SkSL( - return %s; -} else { - return half4(1.0); -} -)SkSL" -, _sample0.c_str()); - } -private: - void onSetData(const GrGLSLProgramDataManager& pdman, const GrFragmentProcessor& _proc) override { - } -}; -std::unique_ptr GrChildProcessorInlineFieldAccess::onMakeProgramImpl() const { - return std::make_unique(); -} -void GrChildProcessorInlineFieldAccess::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { -} -bool GrChildProcessorInlineFieldAccess::onIsEqual(const GrFragmentProcessor& other) const { - const GrChildProcessorInlineFieldAccess& that = other.cast(); - (void) that; - return true; -} -GrChildProcessorInlineFieldAccess::GrChildProcessorInlineFieldAccess(const GrChildProcessorInlineFieldAccess& src) -: INHERITED(kGrChildProcessorInlineFieldAccess_ClassID, src.optimizationFlags()) { - this->cloneAndRegisterAllChildProcessors(src); -} -std::unique_ptr GrChildProcessorInlineFieldAccess::clone() const { - return std::make_unique(*this); -} -#if GR_TEST_UTILS -SkString GrChildProcessorInlineFieldAccess::onDumpInfo() const { - return SkString(); -} -#endif diff --git a/tests/sksl/fp/GrChildProcessorInlineFieldAccess.h b/tests/sksl/fp/GrChildProcessorInlineFieldAccess.h deleted file mode 100644 index 79571f934d..0000000000 --- a/tests/sksl/fp/GrChildProcessorInlineFieldAccess.h +++ /dev/null @@ -1,36 +0,0 @@ - - -/************************************************************************************************** - *** This file was autogenerated from GrChildProcessorInlineFieldAccess.fp; do not modify. - **************************************************************************************************/ -#ifndef GrChildProcessorInlineFieldAccess_DEFINED -#define GrChildProcessorInlineFieldAccess_DEFINED - -#include "include/core/SkM44.h" -#include "include/core/SkTypes.h" - - -#include "src/gpu/GrFragmentProcessor.h" - -class GrChildProcessorInlineFieldAccess : public GrFragmentProcessor { -public: - static std::unique_ptr Make(std::unique_ptr child) { - return std::unique_ptr(new GrChildProcessorInlineFieldAccess(std::move(child))); - } - GrChildProcessorInlineFieldAccess(const GrChildProcessorInlineFieldAccess& src); - std::unique_ptr clone() const override; - const char* name() const override { return "ChildProcessorInlineFieldAccess"; } -private: - GrChildProcessorInlineFieldAccess(std::unique_ptr child) - : INHERITED(kGrChildProcessorInlineFieldAccess_ClassID, kNone_OptimizationFlags) { - this->registerChild(std::move(child), SkSL::SampleUsage::PassThrough()); } - std::unique_ptr onMakeProgramImpl() const override; - void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; - bool onIsEqual(const GrFragmentProcessor&) const override; -#if GR_TEST_UTILS - SkString onDumpInfo() const override; -#endif - GR_DECLARE_FRAGMENT_PROCESSOR_TEST - using INHERITED = GrFragmentProcessor; -}; -#endif