diff options
author | bsalomon <bsalomon@google.com> | 2016-05-11 11:55:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-11 11:55:36 -0700 |
commit | c8699321b924c1f284df93cb29b86000c1d73c0a (patch) | |
tree | 79a78db44c72f95769d35c25d0f06739b90f2cfe | |
parent | cf05dcd64b47dcf5e6ff02132d2b57d3b40d0bf1 (diff) |
Nanobench running on Vulkan
This lets nanobench run but the timings are inaccurate because of missing
implementations of synchronization functions in VkTestContext.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1965273004
Review-Url: https://codereview.chromium.org/1965273004
-rw-r--r-- | bench/nanobench.cpp | 45 | ||||
-rw-r--r-- | tools/gpu/TestContext.cpp | 1 | ||||
-rw-r--r-- | tools/gpu/TestContext.h | 8 | ||||
-rw-r--r-- | tools/gpu/gl/GLTestContext.cpp | 12 | ||||
-rw-r--r-- | tools/gpu/gl/GLTestContext.h | 6 | ||||
-rw-r--r-- | tools/gpu/vk/VkTestContext.cpp | 5 |
6 files changed, 55 insertions, 22 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index 30eab5c3d8..69f1c4f988 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -58,7 +58,7 @@ #include "GrContextFactory.h" #include "gl/GrGLUtil.h" using sk_gpu_test::GrContextFactory; - using sk_gpu_test::GLTestContext; + using sk_gpu_test::TestContext; SkAutoTDelete<GrContextFactory> gGrFactory; #endif @@ -157,26 +157,25 @@ bool Target::capturePixels(SkBitmap* bmp) { #if SK_SUPPORT_GPU struct GPUTarget : public Target { - explicit GPUTarget(const Config& c) : Target(c), gl(nullptr) { } - GLTestContext* gl; + explicit GPUTarget(const Config& c) : Target(c), context(nullptr) { } + TestContext* context; void setup() override { - this->gl->makeCurrent(); + this->context->makeCurrent(); // Make sure we're done with whatever came before. - GR_GL_CALL(this->gl->gl(), Finish()); + this->context->finish(); } void endTiming() override { - if (this->gl) { - GR_GL_CALL(this->gl->gl(), Flush()); - this->gl->waitOnSyncOrSwap(); + if (this->context) { + this->context->waitOnSyncOrSwap(); } } void fence() override { - GR_GL_CALL(this->gl->gl(), Finish()); + this->context->finish(); } bool needsFrameTiming(int* maxFrameLag) const override { - if (!this->gl->getMaxGpuFrameLag(maxFrameLag)) { + if (!this->context->getMaxGpuFrameLag(maxFrameLag)) { // Frame lag is unknown. *maxFrameLag = FLAGS_gpuFrameLag; } @@ -190,12 +189,12 @@ struct GPUTarget : public Target { this->config.ctxOptions), SkBudgeted::kNo, info, this->config.samples, &props); - this->gl = gGrFactory->getContextInfo(this->config.ctxType, - this->config.ctxOptions).glContext(); + this->context = gGrFactory->getContextInfo(this->config.ctxType, + this->config.ctxOptions).testContext(); if (!this->surface.get()) { return false; } - if (!this->gl->fenceSyncSupport()) { + if (!this->context->fenceSyncSupport()) { SkDebugf("WARNING: GL context for config \"%s\" does not support fence sync. " "Timings might not be accurate.\n", this->config.name.c_str()); } @@ -203,17 +202,21 @@ struct GPUTarget : public Target { } void fillOptions(ResultsWriter* log) override { const GrGLubyte* version; - GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_VERSION)); - log->configOption("GL_VERSION", (const char*)(version)); + if (this->context->backend() == kOpenGL_GrBackend) { + const GrGLInterface* gl = + reinterpret_cast<const GrGLInterface*>(this->context->backendContext()); + GR_GL_CALL_RET(gl, version, GetString(GR_GL_VERSION)); + log->configOption("GL_VERSION", (const char*)(version)); - GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_RENDERER)); - log->configOption("GL_RENDERER", (const char*) version); + GR_GL_CALL_RET(gl, version, GetString(GR_GL_RENDERER)); + log->configOption("GL_RENDERER", (const char*) version); - GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_VENDOR)); - log->configOption("GL_VENDOR", (const char*) version); + GR_GL_CALL_RET(gl, version, GetString(GR_GL_VENDOR)); + log->configOption("GL_VENDOR", (const char*) version); - GR_GL_CALL_RET(this->gl->gl(), version, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); - log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version); + GR_GL_CALL_RET(gl, version, GetString(GR_GL_SHADING_LANGUAGE_VERSION)); + log->configOption("GL_SHADING_LANGUAGE_VERSION", (const char*) version); + } } }; diff --git a/tools/gpu/TestContext.cpp b/tools/gpu/TestContext.cpp index 09174cd984..c6900fe41d 100644 --- a/tools/gpu/TestContext.cpp +++ b/tools/gpu/TestContext.cpp @@ -34,6 +34,7 @@ void TestContext::waitOnSyncOrSwap() { return; } + this->submit(); if (fFrameFences[fCurrentFenceIdx]) { if (!fFenceSync->waitFence(fFrameFences[fCurrentFenceIdx], true)) { SkDebugf("WARNING: Wait failed for fence sync. Timings might not be accurate.\n"); diff --git a/tools/gpu/TestContext.h b/tools/gpu/TestContext.h index 5143b8a6fa..ffa8cae8f9 100644 --- a/tools/gpu/TestContext.h +++ b/tools/gpu/TestContext.h @@ -54,6 +54,8 @@ public: * Otherwise it will call the platform SwapBuffers method. This may or may * not perform some sort of synchronization, depending on whether the * drawing surface provided by the platform is double buffered. + * + * Implicitly performs a submit(). */ void waitOnSyncOrSwap(); @@ -65,6 +67,12 @@ public: */ virtual void testAbandon(); + /** Ensures all work is submitted to the GPU for execution. */ + virtual void submit() = 0; + + /** Wait until all GPU work is finished. */ + virtual void finish() = 0; + /** * returns the fencesync object owned by this GLTestContext */ diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp index 3bd814762e..87cf724139 100644 --- a/tools/gpu/gl/GLTestContext.cpp +++ b/tools/gpu/gl/GLTestContext.cpp @@ -61,6 +61,18 @@ void GLTestContext::testAbandon() { } } +void GLTestContext::submit() { + if (fGL) { + GR_GL_CALL(fGL.get(), Flush()); + } +} + +void GLTestContext::finish() { + if (fGL) { + GR_GL_CALL(fGL.get(), Finish()); + } +} + GLTestContext::GLFenceSync* GLTestContext::GLFenceSync::CreateIfSupported(const GLTestContext* ctx) { SkAutoTDelete<GLFenceSync> ret(new GLFenceSync); diff --git a/tools/gpu/gl/GLTestContext.h b/tools/gpu/gl/GLTestContext.h index a940f8dce7..efe9d8f100 100644 --- a/tools/gpu/gl/GLTestContext.h +++ b/tools/gpu/gl/GLTestContext.h @@ -47,6 +47,12 @@ public: void testAbandon() override; + /** Ensures all work is submitted to the GPU for execution. */ + void submit() override; + + /** Wait until all GPU work is finished. */ + void finish() override; + /** * Creates a new GL context of the same type and makes the returned context current * (if not null). diff --git a/tools/gpu/vk/VkTestContext.cpp b/tools/gpu/vk/VkTestContext.cpp index 44be9fd242..f6849e4484 100644 --- a/tools/gpu/vk/VkTestContext.cpp +++ b/tools/gpu/vk/VkTestContext.cpp @@ -10,7 +10,7 @@ #ifdef SK_VULKAN namespace { -// TODO: Implement fence syncs and swap buffers +// TODO: Implement fence syncs, swap buffers, submit, and flush class VkTestContextImpl : public sk_gpu_test::VkTestContext { public: VkTestContextImpl() @@ -20,6 +20,9 @@ public: void testAbandon() override {} + void submit() override {} + void finish() override {} + protected: void teardown() override { fVk.reset(nullptr); } |