diff options
author | 2017-08-08 08:36:22 -0400 | |
---|---|---|
committer | 2017-08-08 13:23:20 +0000 | |
commit | 65a88fadab72abd104fdf4cc4a97488b2e901c60 (patch) | |
tree | f18907298553a9a72faa01361950a9c633398895 | |
parent | bdc3afa577718c657da6eaffba6ae90ec1c26ca2 (diff) |
Add GrDebugMarkerOp
Change-Id: I948838dea13d2f36194ca1043ab37e72759794e0
Reviewed-on: https://skia-review.googlesource.com/31740
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
-rw-r--r-- | gn/gpu.gni | 1 | ||||
-rw-r--r-- | src/gpu/GrGpuCommandBuffer.h | 2 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 2 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpuCommandBuffer.h | 10 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpuCommandBuffer.h | 1 | ||||
-rw-r--r-- | src/gpu/ops/GrDebugMarkerOp.h | 58 | ||||
-rw-r--r-- | src/gpu/ops/GrDiscardOp.h | 3 | ||||
-rw-r--r-- | src/gpu/ops/GrOp.h | 5 | ||||
-rw-r--r-- | src/gpu/ops/GrSemaphoreOp.h | 3 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpuCommandBuffer.cpp | 4 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpuCommandBuffer.h | 1 |
14 files changed, 99 insertions, 4 deletions
diff --git a/gn/gpu.gni b/gn/gpu.gni index e9b33ed58c..6cea1d6360 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -248,6 +248,7 @@ skia_gpu_sources = [ "$_src/gpu/ops/GrDefaultPathRenderer.cpp", "$_src/gpu/ops/GrDefaultPathRenderer.h", "$_src/gpu/ops/GrDiscardOp.h", + "$_src/gpu/ops/GrDebugMarkerOp.h", "$_src/gpu/ops/GrDrawAtlasOp.cpp", "$_src/gpu/ops/GrDrawAtlasOp.h", "$_src/gpu/ops/GrDrawOp.h", diff --git a/src/gpu/GrGpuCommandBuffer.h b/src/gpu/GrGpuCommandBuffer.h index 3fb12bfc07..a50901ac58 100644 --- a/src/gpu/GrGpuCommandBuffer.h +++ b/src/gpu/GrGpuCommandBuffer.h @@ -92,6 +92,8 @@ public: // TODO: This should be removed in the future to favor using the load and store ops for discard virtual void discard(GrRenderTargetProxy*) = 0; + virtual void insertEventMarker(GrRenderTargetProxy*, const char*) = 0; + private: virtual GrGpu* gpu() = 0; virtual GrRenderTarget* renderTarget() = 0; diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index cc82408b8b..dfea8f9637 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -30,6 +30,7 @@ #include "instanced/InstancedRendering.h" #include "ops/GrClearOp.h" #include "ops/GrClearStencilClipOp.h" +#include "ops/GrDebugMarkerOp.h" #include "ops/GrDiscardOp.h" #include "ops/GrDrawAtlasOp.h" #include "ops/GrDrawOp.h" @@ -1446,6 +1447,12 @@ bool GrRenderTargetContext::waitOnSemaphores(int numSemaphores, return true; } +void GrRenderTargetContext::insertEventMarker(const SkString& str) { + std::unique_ptr<GrOp> op(GrDebugMarkerOp::Make(fRenderTargetProxy.get(), str)); + this->getRTOpList()->addOp(std::move(op), *this->caps()); +} + + // Can 'path' be drawn as a pair of filled nested rectangles? static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path, SkRect rects[2]) { diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index d7d2b9b60c..f012ebb2cf 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -313,6 +313,8 @@ public: */ bool waitOnSemaphores(int numSemaphores, const GrBackendSemaphore* waitSemaphores); + void insertEventMarker(const SkString&); + GrFSAAType fsaaType() const { return fRenderTargetProxy->fsaaType(); } const GrCaps* caps() const { return fContext->caps(); } int width() const { return fRenderTargetProxy->width(); } diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index a126e1a082..bfa8ee48ee 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4395,6 +4395,10 @@ void GrGLGpu::deleteSync(GrGLsync sync) const { GL_CALL(DeleteSync(sync)); } +void GrGLGpu::insertEventMarker(const char* msg) { + GL_CALL(InsertEventMarker(strlen(msg), msg)); +} + sk_sp<GrSemaphore> GrGLGpu::prepareTextureForCrossContextUsage(GrTexture* texture) { // Set up a semaphore to be signaled once the data is ready, and flush GL sk_sp<GrSemaphore> semaphore = this->makeSemaphore(true); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index f8f4a6e4cf..1d362fa9eb 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -178,6 +178,8 @@ public: void deleteSync(GrGLsync) const; + void insertEventMarker(const char*); + private: GrGLGpu(GrGLContext* ctx, GrContext* context); diff --git a/src/gpu/gl/GrGLGpuCommandBuffer.h b/src/gpu/gl/GrGLGpuCommandBuffer.h index a430494e91..531251b03d 100644 --- a/src/gpu/gl/GrGLGpuCommandBuffer.h +++ b/src/gpu/gl/GrGLGpuCommandBuffer.h @@ -38,6 +38,16 @@ public: SkASSERT(target == fRenderTarget); } + void insertEventMarker(GrRenderTargetProxy* proxy, const char* msg) override { + GrGLRenderTarget* target = static_cast<GrGLRenderTarget*>(proxy->priv().peekRenderTarget()); + if (!fRenderTarget) { + fRenderTarget = target; + } + SkASSERT(target == fRenderTarget); + + fGpu->insertEventMarker(msg); + } + void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload, GrRenderTargetProxy*) override { state->doUpload(upload); diff --git a/src/gpu/mock/GrMockGpuCommandBuffer.h b/src/gpu/mock/GrMockGpuCommandBuffer.h index d923903cc1..0213cb9c14 100644 --- a/src/gpu/mock/GrMockGpuCommandBuffer.h +++ b/src/gpu/mock/GrMockGpuCommandBuffer.h @@ -19,6 +19,7 @@ public: void inlineUpload(GrOpFlushState*, GrDrawOp::DeferredUploadFn&, GrRenderTargetProxy*) override {} void discard(GrRenderTargetProxy*) override {} + void insertEventMarker(GrRenderTargetProxy*, const char*) override {} void end() override {} int numDraws() const { return fNumDraws; } diff --git a/src/gpu/ops/GrDebugMarkerOp.h b/src/gpu/ops/GrDebugMarkerOp.h new file mode 100644 index 0000000000..326aa75bdd --- /dev/null +++ b/src/gpu/ops/GrDebugMarkerOp.h @@ -0,0 +1,58 @@ +/* + * 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 GrDebugMarkerOp_DEFINED +#define GrDebugMarkerOp_DEFINED + +#include "GrGpuCommandBuffer.h" +#include "GrOp.h" +#include "GrOpFlushState.h" +#include "GrRenderTargetProxy.h" + +class GrDebugMarkerOp final : public GrOp { +public: + DEFINE_OP_CLASS_ID + + static std::unique_ptr<GrOp> Make(GrRenderTargetProxy* proxy, const SkString& str) { + return std::unique_ptr<GrOp>(new GrDebugMarkerOp(proxy, str)); + } + + const char* name() const override { return "DebugMarker"; } + + SkString dumpInfo() const override { + SkString string; + string.append(INHERITED::dumpInfo()); + return string; + } + +private: + GrDebugMarkerOp(GrRenderTargetProxy* proxy, const SkString& str) + : INHERITED(ClassID()) + , fStr(str) { + // Make this cover the whole screen so it can't be reordered around + this->makeFullScreen(proxy); + } + + bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; } + + void onPrepare(GrOpFlushState*) override {} + + void onExecute(GrOpFlushState* state) override { + SkASSERT(state->drawOpArgs().renderTarget()); + + //SkDebugf("%s\n", fStr.c_str()); + if (state->caps().gpuTracingSupport()) { + state->commandBuffer()->insertEventMarker(state->drawOpArgs().fProxy, fStr.c_str()); + } + } + + SkString fStr; + + typedef GrOp INHERITED; +}; + +#endif diff --git a/src/gpu/ops/GrDiscardOp.h b/src/gpu/ops/GrDiscardOp.h index 6f8ff5e89e..4fb481ca74 100644 --- a/src/gpu/ops/GrDiscardOp.h +++ b/src/gpu/ops/GrDiscardOp.h @@ -31,8 +31,7 @@ public: private: GrDiscardOp(GrRenderTargetProxy* proxy) : INHERITED(ClassID()) { - this->setBounds(SkRect::MakeIWH(proxy->width(), proxy->height()), - HasAABloat::kNo, IsZeroArea::kNo); + this->makeFullScreen(proxy); } bool onCombineIfPossible(GrOp* that, const GrCaps& caps) override { return false; } diff --git a/src/gpu/ops/GrOp.h b/src/gpu/ops/GrOp.h index 953a9147aa..254fc44237 100644 --- a/src/gpu/ops/GrOp.h +++ b/src/gpu/ops/GrOp.h @@ -172,6 +172,7 @@ protected: kYes, kNo }; + void setBounds(const SkRect& newBounds, HasAABloat aabloat, IsZeroArea zeroArea) { fBounds = newBounds; this->setBoundsFlags(aabloat, zeroArea); @@ -181,6 +182,10 @@ protected: m.mapRect(&fBounds, srcBounds); this->setBoundsFlags(aabloat, zeroArea); } + void makeFullScreen(GrSurfaceProxy* proxy) { + this->setBounds(SkRect::MakeIWH(proxy->width(), proxy->height()), + HasAABloat::kNo, IsZeroArea::kNo); + } void joinBounds(const GrOp& that) { if (that.hasAABloat()) { diff --git a/src/gpu/ops/GrSemaphoreOp.h b/src/gpu/ops/GrSemaphoreOp.h index 4df09e8fbd..1acc6a7825 100644 --- a/src/gpu/ops/GrSemaphoreOp.h +++ b/src/gpu/ops/GrSemaphoreOp.h @@ -26,8 +26,7 @@ public: protected: GrSemaphoreOp(uint32_t classId, sk_sp<GrSemaphore> semaphore, GrRenderTargetProxy* proxy) : INHERITED(classId), fSemaphore(std::move(semaphore)) { - this->setBounds(SkRect::MakeIWH(proxy->width(), proxy->height()), - HasAABloat::kNo, IsZeroArea::kNo); + this->makeFullScreen(proxy); } sk_sp<GrSemaphore> fSemaphore; diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp index 4c1ad8e787..6a01d3f18d 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp +++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp @@ -219,6 +219,10 @@ void GrVkGpuCommandBuffer::discard(GrRenderTargetProxy* proxy) { } } +void GrVkGpuCommandBuffer::insertEventMarker(GrRenderTargetProxy* proxy, const char* msg) { + // TODO: does Vulkan have a correlate? +} + void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTargetProxy* proxy, const GrFixedClip& clip, bool insideStencilMask) { SkASSERT(!clip.hasWindowRectangles()); diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.h b/src/gpu/vk/GrVkGpuCommandBuffer.h index 06fb953150..6031788711 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.h +++ b/src/gpu/vk/GrVkGpuCommandBuffer.h @@ -32,6 +32,7 @@ public: void end() override; void discard(GrRenderTargetProxy*) override; + void insertEventMarker(GrRenderTargetProxy*, const char*) override; void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload, GrRenderTargetProxy*) override; |