Run SkSL unit tests with optimizations disabled.
We were already running unit tests twice--once with inlining on, and once with inlining off, but always with optimization on. Now, the two passes are instead "inliner + optimizer both on" and "inliner + optimizer both off". (Testing the full 2x2 matrix of possibilities seems like overkill.) Change-Id: I73fb0932877c7b953c1f2e122125e5e7781a8582 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/539396 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
462dab699c
commit
d259c5e4a2
@ -99,13 +99,13 @@ static bool FuzzSkRuntimeEffect_Once(sk_sp<SkData> codeBytes,
|
||||
}
|
||||
|
||||
bool FuzzSkRuntimeEffect(sk_sp<SkData> bytes) {
|
||||
// Test once with the inliner disabled...
|
||||
// Test once with optimization disabled...
|
||||
SkRuntimeEffect::Options options;
|
||||
options.forceNoInline = true;
|
||||
options.forceUnoptimized = true;
|
||||
bool result = FuzzSkRuntimeEffect_Once(bytes, options);
|
||||
|
||||
// ... and then with the inliner enabled.
|
||||
options.forceNoInline = false;
|
||||
// ... and then with optimization enabled.
|
||||
options.forceUnoptimized = false;
|
||||
result = FuzzSkRuntimeEffect_Once(bytes, options) || result;
|
||||
|
||||
return result;
|
||||
|
@ -103,9 +103,10 @@ public:
|
||||
|
||||
class Options {
|
||||
public:
|
||||
// For testing purposes, completely disable the inliner. (Normally, Runtime Effects don't
|
||||
// run the inliner directly, but they still get an inlining pass once they are painted.)
|
||||
bool forceNoInline = false;
|
||||
// For testing purposes, disables optimization and inlining. (Normally, Runtime Effects
|
||||
// don't run the inliner directly, but they still get an inlining pass once they are
|
||||
// painted.)
|
||||
bool forceUnoptimized = false;
|
||||
|
||||
private:
|
||||
friend class SkRuntimeEffect;
|
||||
@ -295,7 +296,7 @@ private:
|
||||
const Options& options,
|
||||
SkSL::ProgramKind kind);
|
||||
|
||||
static SkSL::ProgramSettings MakeSettings(const Options& options, bool optimize);
|
||||
static SkSL::ProgramSettings MakeSettings(const Options& options);
|
||||
|
||||
uint32_t hash() const { return fHash; }
|
||||
bool usesSampleCoords() const { return (fFlags & kUsesSampleCoords_Flag); }
|
||||
|
@ -203,12 +203,12 @@ static std::vector<skvm::Val> make_skvm_uniforms(skvm::Builder* p,
|
||||
return uniform;
|
||||
}
|
||||
|
||||
SkSL::ProgramSettings SkRuntimeEffect::MakeSettings(const Options& options, bool optimize) {
|
||||
SkSL::ProgramSettings SkRuntimeEffect::MakeSettings(const Options& options) {
|
||||
SkSL::ProgramSettings settings;
|
||||
settings.fInlineThreshold = 0;
|
||||
settings.fForceNoInline = options.forceNoInline;
|
||||
settings.fForceNoInline = options.forceUnoptimized;
|
||||
settings.fOptimize = !options.forceUnoptimized;
|
||||
settings.fEnforceES2Restrictions = options.enforceES2Restrictions;
|
||||
settings.fOptimize = optimize;
|
||||
return settings;
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ SkRuntimeEffect::Result SkRuntimeEffect::MakeFromSource(SkString sksl,
|
||||
// calling the Make overload at the end, which creates its own (non-reentrant)
|
||||
// SharedCompiler instance
|
||||
SkSL::SharedCompiler compiler;
|
||||
SkSL::Program::Settings settings = MakeSettings(options, /*optimize=*/true);
|
||||
SkSL::Program::Settings settings = MakeSettings(options);
|
||||
program = compiler->convertProgram(kind, std::string(sksl.c_str(), sksl.size()), settings);
|
||||
|
||||
if (!program) {
|
||||
@ -395,7 +395,7 @@ sk_sp<SkRuntimeEffect> SkRuntimeEffect::makeUnoptimizedClone() {
|
||||
// handled when the original SkRuntimeEffect was made. We don't keep around the Options struct
|
||||
// from when it was initially made so we don't know what was originally requested.
|
||||
Options options;
|
||||
options.forceNoInline = true;
|
||||
options.forceUnoptimized = true;
|
||||
options.enforceES2Restrictions = false;
|
||||
options.usePrivateRTShaderModule = true;
|
||||
|
||||
@ -411,7 +411,7 @@ sk_sp<SkRuntimeEffect> SkRuntimeEffect::makeUnoptimizedClone() {
|
||||
// calling MakeInternal at the end, which creates its own (non-reentrant) SharedCompiler
|
||||
// instance.
|
||||
SkSL::SharedCompiler compiler;
|
||||
SkSL::Program::Settings settings = MakeSettings(options, /*optimize=*/false);
|
||||
SkSL::Program::Settings settings = MakeSettings(options);
|
||||
program = compiler->convertProgram(kind, *fBaseProgram->fSource, settings);
|
||||
|
||||
if (!program) {
|
||||
@ -587,10 +587,12 @@ SkRuntimeEffect::SkRuntimeEffect(std::unique_ptr<SkSL::Program> baseProgram,
|
||||
// be accounted for in `fHash`. If you've added a new field to Options and caused the static-
|
||||
// assert below to trigger, please incorporate your field into `fHash` and update KnownOptions
|
||||
// to match the layout of Options.
|
||||
struct KnownOptions { bool forceNoInline, enforceES2Restrictions, usePrivateRTShaderModule; };
|
||||
struct KnownOptions {
|
||||
bool forceUnoptimized, enforceES2Restrictions, usePrivateRTShaderModule;
|
||||
};
|
||||
static_assert(sizeof(Options) == sizeof(KnownOptions));
|
||||
fHash = SkOpts::hash_fn(&options.forceNoInline,
|
||||
sizeof(options.forceNoInline), fHash);
|
||||
fHash = SkOpts::hash_fn(&options.forceUnoptimized,
|
||||
sizeof(options.forceUnoptimized), fHash);
|
||||
fHash = SkOpts::hash_fn(&options.enforceES2Restrictions,
|
||||
sizeof(options.enforceES2Restrictions), fHash);
|
||||
fHash = SkOpts::hash_fn(&options.usePrivateRTShaderModule,
|
||||
|
@ -205,11 +205,11 @@ static void test_permutations(skiatest::Reporter* r,
|
||||
bool strictES2) {
|
||||
SkRuntimeEffect::Options options =
|
||||
strictES2 ? SkRuntimeEffect::Options{} : SkRuntimeEffectPriv::ES3Options();
|
||||
options.forceNoInline = false;
|
||||
options.forceUnoptimized = false;
|
||||
test_one_permutation(r, surface, testFile, "", options);
|
||||
|
||||
options.forceNoInline = true;
|
||||
test_one_permutation(r, surface, testFile, " (NoInline)", options);
|
||||
options.forceUnoptimized = true;
|
||||
test_one_permutation(r, surface, testFile, " (Unoptimized)", options);
|
||||
}
|
||||
|
||||
static void test_cpu(skiatest::Reporter* r, const char* testFile, int flags) {
|
||||
|
Loading…
Reference in New Issue
Block a user