Added AssertDSLObjectsReleased setting
Change-Id: Ia63f892305c2347e55560141880a0b6a124b84f6 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/429196 Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
b22b41d55a
commit
459777a1a4
@ -74,6 +74,8 @@ struct ProgramSettings {
|
|||||||
bool fDSLMarkVarsDeclared = false;
|
bool fDSLMarkVarsDeclared = false;
|
||||||
// If true, the DSL should install a memory pool when possible.
|
// If true, the DSL should install a memory pool when possible.
|
||||||
bool fDSLUseMemoryPool = true;
|
bool fDSLUseMemoryPool = true;
|
||||||
|
// If true, DSL objects assert that they were used prior to destruction
|
||||||
|
bool fAssertDSLObjectsReleased = true;
|
||||||
// External functions available for use in runtime effects. These values are registered in the
|
// External functions available for use in runtime effects. These values are registered in the
|
||||||
// symbol table of the Program, but ownership is *not* transferred. It is up to the caller to
|
// symbol table of the Program, but ownership is *not* transferred. It is up to the caller to
|
||||||
// keep them alive.
|
// keep them alive.
|
||||||
|
@ -92,8 +92,9 @@ DSLExpression::~DSLExpression() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SkASSERTF(fExpression == nullptr,
|
SkASSERTF(!fExpression || !DSLWriter::Settings().fAssertDSLObjectsReleased,
|
||||||
"Expression destroyed without being incorporated into program");
|
"Expression destroyed without being incorporated into program (see "
|
||||||
|
"ProgramSettings::fAssertDSLObjectsReleased)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSLExpression::swap(DSLExpression& other) {
|
void DSLExpression::swap(DSLExpression& other) {
|
||||||
|
@ -25,7 +25,7 @@ void DSLFunction::init(DSLModifiers modifiers, const DSLType& returnType, skstd:
|
|||||||
modifiers.fModifiers.fFlags |= Modifiers::kHasSideEffects_Flag;
|
modifiers.fModifiers.fFlags |= Modifiers::kHasSideEffects_Flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DSLWriter::Context().fConfig->fSettings.fForceNoInline) {
|
if (DSLWriter::Settings().fForceNoInline) {
|
||||||
// Apply the `noinline` modifier to every function. This allows us to test Runtime
|
// Apply the `noinline` modifier to every function. This allows us to test Runtime
|
||||||
// Effects without any inlining, even when the code is later added to a paint.
|
// Effects without any inlining, even when the code is later added to a paint.
|
||||||
modifiers.fModifiers.fFlags &= ~Modifiers::kInline_Flag;
|
modifiers.fModifiers.fFlags &= ~Modifiers::kInline_Flag;
|
||||||
|
@ -64,7 +64,9 @@ DSLStatement::~DSLStatement() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SkASSERTF(!fStatement, "Statement destroyed without being incorporated into program");
|
SkASSERTF(!fStatement || !DSLWriter::Settings().fAssertDSLObjectsReleased,
|
||||||
|
"Statement destroyed without being incorporated into program (see "
|
||||||
|
"ProgramSettings::fAssertDSLObjectsReleased)");
|
||||||
}
|
}
|
||||||
|
|
||||||
DSLPossibleStatement::DSLPossibleStatement(std::unique_ptr<SkSL::Statement> statement)
|
DSLPossibleStatement::DSLPossibleStatement(std::unique_ptr<SkSL::Statement> statement)
|
||||||
|
@ -79,7 +79,11 @@ SkSL::IRGenerator& DSLWriter::IRGenerator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SkSL::Context& DSLWriter::Context() {
|
const SkSL::Context& DSLWriter::Context() {
|
||||||
return IRGenerator().fContext;
|
return Compiler().context();
|
||||||
|
}
|
||||||
|
|
||||||
|
SkSL::ProgramSettings& DSLWriter::Settings() {
|
||||||
|
return Context().fConfig->fSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::shared_ptr<SkSL::SymbolTable>& DSLWriter::SymbolTable() {
|
const std::shared_ptr<SkSL::SymbolTable>& DSLWriter::SymbolTable() {
|
||||||
|
@ -70,6 +70,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
static const SkSL::Context& Context();
|
static const SkSL::Context& Context();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Settings used by DSL operations in the current thread.
|
||||||
|
*/
|
||||||
|
static SkSL::ProgramSettings& Settings();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the collection to which DSL program elements in this thread should be appended.
|
* Returns the collection to which DSL program elements in this thread should be appended.
|
||||||
*/
|
*/
|
||||||
|
@ -1986,3 +1986,12 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLInlining, r, ctxInfo) {
|
|||||||
"}");
|
"}");
|
||||||
REPORTER_ASSERT(r, *program->fSource == source);
|
REPORTER_ASSERT(r, *program->fSource == source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEF_GPUTEST_FOR_MOCK_CONTEXT(DSLReleaseUnused, r, ctxInfo) {
|
||||||
|
SkSL::ProgramSettings settings = default_settings();
|
||||||
|
settings.fAssertDSLObjectsReleased = false;
|
||||||
|
AutoDSLContext context(ctxInfo.directContext()->priv().getGpu(), settings);
|
||||||
|
If(Sqrt(1) > 0, Discard());
|
||||||
|
// Ensure that we can safely destroy statements and expressions despite being unused while
|
||||||
|
// settings.fAssertDSLObjectsReleased is disabled.
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user