aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Brian Osman <brianosman@google.com>2017-08-30 10:02:10 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-30 15:27:42 +0000
commitf9810666bd40db8fb1650e6c727c1a83b8090136 (patch)
tree0d346bbb44d61c7da4c53655620e890f60758ffc /tools
parente750391c349ff1fa1c179fbf2f5af27fb4405cef (diff)
Threaded generation of software paths
Re-land of: https://skia-review.googlesource.com/36560 All information needed by the thread is captured by the prepare callback object, the lambda captures a pointer to that, and does the mask render. Once it's done, it signals the semaphore (also owned by the callback). The callback defers the semaphore wait even longer (into the ASAP upload), so the odds of waiting for the thread are REALLY low. Also did a bunch of cleanup along the way, and put in some trace markers so we can monitor how well this is working. Traces of a GM that includes GPU and SW path rendering (path-reverse): Original: https://screenshot.googleplex.com/f5BG3901tQg.png Threaded, with wait in the callback (notice pre flush callback blocking): https://screenshot.googleplex.com/htOSZFE2s04.png Current version, with wait deferred to ASAP upload function: https://screenshot.googleplex.com/GHjD0U3C34q.png Bug: skia: Change-Id: Idb92f385590749f41328a9aec65b2a93f4775079 Reviewed-on: https://skia-review.googlesource.com/40775 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/flags/SkCommonFlags.cpp11
-rw-r--r--tools/flags/SkCommonFlagsConfig.cpp16
-rw-r--r--tools/flags/SkCommonFlagsConfig.h5
-rw-r--r--tools/flags/SkCommonFlagsGpuThreads.h15
-rw-r--r--tools/viewer/Viewer.cpp2
5 files changed, 45 insertions, 4 deletions
diff --git a/tools/flags/SkCommonFlags.cpp b/tools/flags/SkCommonFlags.cpp
index facbd3139b..0986d2b57c 100644
--- a/tools/flags/SkCommonFlags.cpp
+++ b/tools/flags/SkCommonFlags.cpp
@@ -6,6 +6,8 @@
*/
#include "SkCommonFlags.h"
+#include "SkExecutor.h"
+#include "SkOnce.h"
#include "SkOSFile.h"
#include "SkOSPath.h"
@@ -54,6 +56,9 @@ DEFINE_string(svgs, "", "Directory to read SVGs from, or a single SVG file.");
DEFINE_int32_2(threads, j, -1, "Run threadsafe tests on a threadpool with this many extra threads, "
"defaulting to one extra thread per core.");
+DEFINE_int32(gpuThreads, 0, "Create this many extra threads to assist with GPU work, "
+ "including software path rendering.");
+
DEFINE_bool2(verbose, v, false, "enable verbose output from the test driver.");
DEFINE_bool2(veryVerbose, V, false, "tell individual tests to be verbose.");
@@ -123,3 +128,9 @@ bool CollectImages(SkCommandLineFlags::StringArray images, SkTArray<SkString>* o
}
return true;
}
+
+SkExecutor* GpuExecutorForTools() {
+ static std::unique_ptr<SkExecutor> gGpuExecutor = (0 != FLAGS_gpuThreads)
+ ? SkExecutor::MakeThreadPool(FLAGS_gpuThreads) : nullptr;
+ return gGpuExecutor.get();
+}
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 03b3b96822..16fe914f77 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -72,6 +72,7 @@ static const struct {
{ "glesnarrow", "gpu", "api=gles,color=f16_narrow" },
{ "gldft", "gpu", "api=gl,dit=true" },
{ "glesdft", "gpu", "api=gles,dit=true" },
+ { "gltestthreading", "gpu", "api=gl,testThreading=true" },
{ "debuggl", "gpu", "api=debuggl" },
{ "nullgl", "gpu", "api=nullgl" },
{ "angle_d3d11_es2", "gpu", "api=angle_d3d11_es2" },
@@ -170,6 +171,8 @@ static const char configExtendedHelp[] =
"\t Use multisampling with N samples.\n"
"\tstencils\ttype: bool\tdefault: true.\n"
"\t Allow the use of stencil buffers.\n"
+ "\ttestThreading\ttype: bool\tdefault: false.\n"
+ "\t Run config with and without worker threads, check that results match.\n"
"\n"
"Predefined configs:\n\n"
// Help text for pre-defined configs is auto-generated from gPredefinedConfigs
@@ -200,7 +203,7 @@ SkCommandLineConfig::~SkCommandLineConfig() {
SkCommandLineConfigGpu::SkCommandLineConfigGpu(
const SkString& tag, const SkTArray<SkString>& viaParts, ContextType contextType, bool useNVPR,
bool useInstanced, bool useDIText, int samples, SkColorType colorType, SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace, bool useStencilBuffers)
+ sk_sp<SkColorSpace> colorSpace, bool useStencilBuffers, bool testThreading)
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
, fContextType(contextType)
, fContextOverrides(ContextOverrides::kNone)
@@ -208,7 +211,8 @@ SkCommandLineConfigGpu::SkCommandLineConfigGpu(
, fSamples(samples)
, fColorType(colorType)
, fAlphaType(alphaType)
- , fColorSpace(std::move(colorSpace)) {
+ , fColorSpace(std::move(colorSpace))
+ , fTestThreading(testThreading) {
if (useNVPR) {
fContextOverrides |= ContextOverrides::kRequireNVPRSupport;
} else if (!useInstanced) {
@@ -419,6 +423,8 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
sk_sp<SkColorSpace> colorSpace = nullptr;
bool seenUseStencils = false;
bool useStencils = true;
+ bool seenTestThreading = false;
+ bool testThreading = false;
SkTArray<SkString> optionParts;
SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
@@ -452,6 +458,9 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
} else if (key.equals("stencils") && !seenUseStencils) {
valueOk = parse_option_bool(value, &useStencils);
seenUseStencils = true;
+ } else if (key.equals("testThreading") && !seenTestThreading) {
+ valueOk = parse_option_bool(value, &testThreading);
+ seenTestThreading = true;
}
if (!valueOk) {
return nullptr;
@@ -461,7 +470,8 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
return nullptr;
}
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useInstanced, useDIText,
- samples, colorType, alphaType, colorSpace, useStencils);
+ samples, colorType, alphaType, colorSpace, useStencils,
+ testThreading);
}
#endif
diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h
index 77f31c32c2..18b138c468 100644
--- a/tools/flags/SkCommonFlagsConfig.h
+++ b/tools/flags/SkCommonFlagsConfig.h
@@ -56,7 +56,8 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useInstanced, bool useDIText,
int samples, SkColorType colorType, SkAlphaType alphaType,
- sk_sp<SkColorSpace> colorSpace, bool useStencilBuffers);
+ sk_sp<SkColorSpace> colorSpace, bool useStencilBuffers,
+ bool testThreading);
const SkCommandLineConfigGpu* asConfigGpu() const override { return this; }
ContextType getContextType() const { return fContextType; }
ContextOverrides getContextOverrides() const { return fContextOverrides; }
@@ -71,6 +72,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
SkColorType getColorType() const { return fColorType; }
SkAlphaType getAlphaType() const { return fAlphaType; }
SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
+ bool getTestThreading() const { return fTestThreading; }
private:
ContextType fContextType;
@@ -80,6 +82,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
SkColorType fColorType;
SkAlphaType fAlphaType;
sk_sp<SkColorSpace> fColorSpace;
+ bool fTestThreading;
};
#endif
diff --git a/tools/flags/SkCommonFlagsGpuThreads.h b/tools/flags/SkCommonFlagsGpuThreads.h
new file mode 100644
index 0000000000..a6042fa821
--- /dev/null
+++ b/tools/flags/SkCommonFlagsGpuThreads.h
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SK_COMMON_FLAGS_GPU_THREADS
+#define SK_COMMON_FLAGS_GPU_THREADS
+
+class SkExecutor;
+
+SkExecutor* GpuExecutorForTools();
+
+#endif
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 9bfdc4b60a..4e6684310f 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -19,6 +19,7 @@
#include "SkColorSpace_Base.h"
#include "SkColorSpaceXformCanvas.h"
#include "SkCommandLineFlags.h"
+#include "SkCommonFlagsGpuThreads.h"
#include "SkCommonFlagsPathRenderer.h"
#include "SkDashPathEffect.h"
#include "SkEventTracingPriv.h"
@@ -304,6 +305,7 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
displayParams.fMSAASampleCount = FLAGS_msaa;
displayParams.fGrContextOptions.fEnableInstancedRendering = FLAGS_instancedRendering;
displayParams.fGrContextOptions.fGpuPathRenderers = CollectGpuPathRenderersFromFlags();
+ displayParams.fGrContextOptions.fExecutor = GpuExecutorForTools();
fWindow->setRequestedDisplayParams(displayParams);
// register callbacks