diff --git a/bench/SkSLBench.cpp b/bench/SkSLBench.cpp index fcf8b148fe..cfc2eb8e02 100644 --- a/bench/SkSLBench.cpp +++ b/bench/SkSLBench.cpp @@ -70,7 +70,6 @@ public: , fCompiler(fCaps.shaderCaps()) , fOutput(output) { fSettings.fOptimize = optimize; - fSettings.fDSLMangling = false; // The test programs we compile don't follow Vulkan rules and thus produce invalid // SPIR-V. This is harmless, so long as we don't try to validate them. fSettings.fValidateSPIRV = false; diff --git a/include/sksl/DSLVar.h b/include/sksl/DSLVar.h index 4e49583d4f..ee6e99e2e1 100644 --- a/include/sksl/DSLVar.h +++ b/include/sksl/DSLVar.h @@ -137,7 +137,6 @@ protected: std::unique_ptr fDeclaration; const SkSL::Variable* fVar = nullptr; Position fNamePosition; - std::string_view fRawName; // for error reporting std::string_view fName; DSLExpression fInitialValue; // true if we have attempted to create the SkSL var diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp index 4114b8004e..d50ec2997c 100644 --- a/src/sksl/SkSLCompiler.cpp +++ b/src/sksl/SkSLCompiler.cpp @@ -510,7 +510,6 @@ std::unique_ptr Compiler::convertProgram(ProgramKind kind, this->resetErrors(); fInliner.reset(); - settings.fDSLMangling = false; return DSLParser(this, settings, kind, std::move(text)).program(); } diff --git a/src/sksl/SkSLDSLParser.cpp b/src/sksl/SkSLDSLParser.cpp index 3d4458c58d..b720d80f4e 100644 --- a/src/sksl/SkSLDSLParser.cpp +++ b/src/sksl/SkSLDSLParser.cpp @@ -112,8 +112,6 @@ DSLParser::DSLParser(Compiler* compiler, const ProgramSettings& settings, Progra // We don't want to have to worry about manually releasing all of the objects in the event that // an error occurs fSettings.fAssertDSLObjectsReleased = false; - // We manage our symbol tables manually, so no need for name mangling - fSettings.fDSLMangling = false; fLexer.start(*fText); } diff --git a/src/sksl/SkSLProgramSettings.h b/src/sksl/SkSLProgramSettings.h index afdf1d88f1..4dc02f9d4d 100644 --- a/src/sksl/SkSLProgramSettings.h +++ b/src/sksl/SkSLProgramSettings.h @@ -75,8 +75,6 @@ struct ProgramSettings { // every temporary value, even ones that would otherwise be optimized away entirely. The other // debug opcodes are much less invasive on the generated code. bool fAllowTraceVarInSkVMDebugTrace = true; - // If true, the DSL should automatically mangle symbol names. - bool fDSLMangling = true; // If true, the DSL should automatically mark variables declared upon creation. bool fDSLMarkVarsDeclared = false; // If true, the DSL should install a memory pool when possible. diff --git a/src/sksl/dsl/BUILD.bazel b/src/sksl/dsl/BUILD.bazel index 1f74e0d434..2ee24d56ee 100644 --- a/src/sksl/dsl/BUILD.bazel +++ b/src/sksl/dsl/BUILD.bazel @@ -223,7 +223,6 @@ generated_cc_atom( "//src/sksl/ir:SkSLFieldAccess_hdr", "//src/sksl/ir:SkSLFunctionCall_hdr", "//src/sksl/ir:SkSLSymbolTable_hdr", - "//src/sksl/ir:SkSLType_hdr", "//src/sksl/ir:SkSLVariable_hdr", ], ) diff --git a/src/sksl/dsl/DSLFunction.cpp b/src/sksl/dsl/DSLFunction.cpp index 4022a7c5fe..7327d7f2f3 100644 --- a/src/sksl/dsl/DSLFunction.cpp +++ b/src/sksl/dsl/DSLFunction.cpp @@ -70,7 +70,7 @@ void DSLFunction::init(DSLModifiers modifiers, const DSLType& returnType, std::s pos, modifiers.fPosition, ThreadContext::Modifiers(modifiers.fModifiers), - name == "main" ? name : DSLWriter::Name(name), + name, std::move(paramVars), returnType.fPosition, &returnType.skslType()); ThreadContext::ReportErrors(pos); diff --git a/src/sksl/dsl/DSLVar.cpp b/src/sksl/dsl/DSLVar.cpp index 0e3e4b8efa..a26490c3b5 100644 --- a/src/sksl/dsl/DSLVar.cpp +++ b/src/sksl/dsl/DSLVar.cpp @@ -22,7 +22,6 @@ #include "src/sksl/ir/SkSLFieldAccess.h" #include "src/sksl/ir/SkSLFunctionCall.h" #include "src/sksl/ir/SkSLSymbolTable.h" -#include "src/sksl/ir/SkSLType.h" #include "src/sksl/ir/SkSLVariable.h" #include @@ -47,8 +46,7 @@ DSLVarBase::DSLVarBase(const DSLModifiers& modifiers, DSLType type, std::string_ : fModifiers(std::move(modifiers)) , fType(std::move(type)) , fNamePosition(namePos) - , fRawName(name) - , fName(fType.skslType().isOpaque() ? name : DSLWriter::Name(name)) + , fName(name) , fInitialValue(std::move(initialValue)) , fDeclared(DSLWriter::MarkVarsDeclared()) , fPosition(pos) {} @@ -57,8 +55,8 @@ DSLVarBase::~DSLVarBase() { if (fDeclaration && !fDeclared) { ThreadContext::ReportError(String::printf("variable '%.*s' was destroyed without being " "declared", - (int)fRawName.length(), - fRawName.data()).c_str()); + (int)fName.length(), + fName.data()).c_str()); } } @@ -70,7 +68,6 @@ void DSLVarBase::swap(DSLVarBase& other) { std::swap(fDeclaration, other.fDeclaration); std::swap(fVar, other.fVar); std::swap(fNamePosition, other.fNamePosition); - std::swap(fRawName, other.fRawName); std::swap(fName, other.fName); std::swap(fInitialValue.fExpression, other.fInitialValue.fExpression); std::swap(fDeclared, other.fDeclared); diff --git a/src/sksl/dsl/priv/BUILD.bazel b/src/sksl/dsl/priv/BUILD.bazel index 481a0a44b2..857dcef539 100644 --- a/src/sksl/dsl/priv/BUILD.bazel +++ b/src/sksl/dsl/priv/BUILD.bazel @@ -34,7 +34,6 @@ generated_cc_atom( "//include/sksl:DSLType_hdr", "//include/sksl:DSLVar_hdr", "//include/sksl:SkSLPosition_hdr", - "//src/sksl:SkSLMangler_hdr", "//src/sksl:SkSLModifiersPool_hdr", "//src/sksl:SkSLProgramSettings_hdr", "//src/sksl:SkSLThreadContext_hdr", diff --git a/src/sksl/dsl/priv/DSLWriter.cpp b/src/sksl/dsl/priv/DSLWriter.cpp index f7672ec9ca..f97e4f342f 100644 --- a/src/sksl/dsl/priv/DSLWriter.cpp +++ b/src/sksl/dsl/priv/DSLWriter.cpp @@ -19,7 +19,6 @@ #include "include/sksl/DSLType.h" #include "include/sksl/DSLVar.h" #include "include/sksl/SkSLPosition.h" -#include "src/sksl/SkSLMangler.h" #include "src/sksl/SkSLModifiersPool.h" #include "src/sksl/SkSLProgramSettings.h" #include "src/sksl/SkSLThreadContext.h" @@ -30,8 +29,6 @@ #include "src/sksl/ir/SkSLVarDeclarations.h" #include "src/sksl/ir/SkSLVariable.h" -#include -#include #include #include @@ -39,20 +36,6 @@ namespace SkSL { namespace dsl { -bool DSLWriter::ManglingEnabled() { - return ThreadContext::Instance().fSettings.fDSLMangling; -} - -std::string_view DSLWriter::Name(std::string_view name) { - if (ManglingEnabled()) { - const std::string* s = ThreadContext::SymbolTable()->takeOwnershipOfString( - ThreadContext::Instance().fMangler.uniqueName(name, - ThreadContext::SymbolTable().get())); - return s->c_str(); - } - return name; -} - const SkSL::Variable* DSLWriter::Var(DSLVarBase& var) { // fInitialized is true if we have attempted to create a var, whether or not we actually // succeeded. If it's true, we don't want to try again, to avoid reporting the same error diff --git a/src/sksl/dsl/priv/DSLWriter.h b/src/sksl/dsl/priv/DSLWriter.h index 98087a2b66..07e7416ba9 100644 --- a/src/sksl/dsl/priv/DSLWriter.h +++ b/src/sksl/dsl/priv/DSLWriter.h @@ -15,7 +15,6 @@ #endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU #include -#include namespace SkSL { @@ -35,28 +34,6 @@ class DSLVar; */ class DSLWriter { public: - /** - * Returns whether name mangling is enabled. Mangling is important for the DSL because its - * variables normally all go into the same symbol table; for instance if you were to translate - * this legal (albeit silly) GLSL code: - * int x; - * { - * int x; - * } - * - * into DSL, you'd end up with: - * DSLVar x1(kInt_Type, "x"); - * DSLVar x2(kInt_Type, "x"); - * Declare(x1); - * Block(Declare(x2)); - * - * with x1 and x2 ending up in the same symbol table. This is fine as long as their effective - * names are different, so mangling prevents this situation from causing problems. - */ - static bool ManglingEnabled(); - - static std::string_view Name(std::string_view name); - /** * Returns the SkSL variable corresponding to a DSL var. */ diff --git a/tests/SkSLDSLTest.cpp b/tests/SkSLDSLTest.cpp index 0f763fae5d..d7fea0f635 100644 --- a/tests/SkSLDSLTest.cpp +++ b/tests/SkSLDSLTest.cpp @@ -55,7 +55,6 @@ using namespace SkSL::dsl; SkSL::ProgramSettings default_settings() { SkSL::ProgramSettings result; result.fDSLMarkVarsDeclared = true; - result.fDSLMangling = false; return result; } @@ -66,11 +65,10 @@ SkSL::ProgramSettings no_mark_vars_declared() { } /** - * In addition to issuing an automatic Start() and End(), disables mangling and optionally - * auto-declares variables during its lifetime. Variable auto-declaration simplifies testing so we - * don't have to sprinkle all the tests with a bunch of Declare(foo).release() calls just to avoid - * errors, especially given that some of the variables have options that make them an error to - * actually declare. + * Issues an automatic Start() and End(), and optionally auto-declares variables during its + * lifetime. Variable auto-declaration simplifies testing so we don't have to sprinkle all the tests + * with a bunch of Declare(foo).release() calls just to avoid errors, especially given that some of + * the variables have options that make them an error to actually declare. */ class AutoDSLContext { public: @@ -203,12 +201,6 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLFlags, r, ctxInfo) { Var y(kFloat_Type, "y"); EXPECT_EQUAL(x = y, "(x = half(y))"); } - - { - AutoDSLContext context(ctxInfo.directContext()->priv().getGpu(), SkSL::ProgramSettings()); - Var x(kInt_Type, "x"); - EXPECT_EQUAL(Declare(x), "int _0_x;"); - } } DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLFloat, r, ctxInfo) {