From b9990e4492a4e6969f182682d299e28d881dbb0f Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Wed, 10 Apr 2019 16:28:52 -0400 Subject: [PATCH] Add more general flush call to GrContext. This is to match the current features of SkSurface::flush and to prepare for adding additional features to flush. Bug: skia:8802 Change-Id: I5d68272e1277b416af357e6ffaf426841ceda943 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207301 Commit-Queue: Greg Daniel Reviewed-by: Brian Salomon --- include/core/SkSurface.h | 44 ++++++++-------------------- include/gpu/GrContext.h | 10 ++++++- include/gpu/GrTypes.h | 6 ++++ src/gpu/GrContext.cpp | 9 +++--- src/gpu/GrContextPriv.cpp | 4 +-- src/gpu/GrDrawingManager.cpp | 12 ++++---- src/gpu/GrDrawingManager.h | 4 +-- src/gpu/GrGpu.cpp | 2 +- src/gpu/GrGpu.h | 4 +-- src/gpu/GrRenderTargetContext.cpp | 2 +- src/gpu/GrRenderTargetContext.h | 2 +- src/gpu/SkGpuDevice.cpp | 4 +-- src/gpu/SkGpuDevice.h | 2 +- src/gpu/gl/GrGLGpu.cpp | 4 +-- src/gpu/gl/GrGLGpu.h | 2 +- src/gpu/mock/GrMockGpu.h | 2 +- src/gpu/mtl/GrMtlGpu.h | 4 +-- src/gpu/vk/GrVkGpu.cpp | 4 +-- src/gpu/vk/GrVkGpu.h | 4 +-- src/image/SkImage_Gpu.cpp | 2 +- src/image/SkSurface.cpp | 12 ++++++-- src/image/SkSurface_Base.h | 2 +- src/image/SkSurface_Gpu.cpp | 4 +-- src/image/SkSurface_Gpu.h | 3 +- tests/DefaultPathRendererTest.cpp | 2 +- tests/GLProgramsTest.cpp | 4 +-- tests/OnFlushCallbackTest.cpp | 2 +- tests/SurfaceSemaphoreTest.cpp | 2 +- tests/TransferPixelsTest.cpp | 4 +-- tests/VkHardwareBufferTest.cpp | 4 +-- tools/sk_app/VulkanWindowContext.cpp | 2 +- 31 files changed, 84 insertions(+), 84 deletions(-) diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h index 6f4d8857db..48ec1f6342 100644 --- a/include/core/SkSurface.h +++ b/include/core/SkSurface.h @@ -713,12 +713,6 @@ public: kPresent, //!< back-end surface will be used for presenting to screen }; - enum FlushFlags { - kNone_FlushFlags = 0, - // flush will wait till all submitted GPU work is finished before returning. - kSyncCpu_FlushFlag = 0x1, - }; - /** Issues pending SkSurface commands to the GPU-backed API and resolves any SkSurface MSAA. After issuing all commands, signalSemaphores of count numSemaphores are signaled by the GPU. The work that is submitted to the GPU will be dependent on the BackendSurfaceAccess that is @@ -758,35 +752,21 @@ public: @param signalSemaphores array of semaphore containers @return one of: GrSemaphoresSubmitted::kYes, GrSemaphoresSubmitted::kNo */ + GrSemaphoresSubmitted flush(BackendSurfaceAccess access, GrFlushFlags flags, + int numSemaphores, GrBackendSemaphore signalSemaphores[]); + + /** The below enum and flush call are deprected + */ + + enum FlushFlags { + kNone_FlushFlags = 0, + // flush will wait till all submitted GPU work is finished before returning. + kSyncCpu_FlushFlag = 0x1, + }; GrSemaphoresSubmitted flush(BackendSurfaceAccess access, FlushFlags flags, int numSemaphores, GrBackendSemaphore signalSemaphores[]); - /** Issues pending SkSurface commands to the GPU-backed API and resolves any SkSurface MSAA. - After issuing all commands, signalSemaphores of count numSemaphores semaphores - are signaled by the GPU. - - For each GrBackendSemaphore in signalSemaphores: - if GrBackendSemaphore is initialized, the GPU back-end uses the semaphore as is; - otherwise, a new semaphore is created and initializes GrBackendSemaphore. - - The caller must delete the semaphores created and returned in signalSemaphores. - GrBackendSemaphore can be deleted as soon as this function returns. - - If the back-end API is OpenGL only uninitialized backend semaphores are supported. - - If the back-end API is Vulkan semaphores may be initialized or uninitialized. - If uninitialized, created semaphores are valid only with the VkDevice - with which they were created. - - If GrSemaphoresSubmitted::kNo is returned, the GPU back-end did not create or - add any semaphores to signal on the GPU; the caller should not instruct the GPU - to wait on any of the semaphores. - - Pending surface commands are flushed regardless of the return result. - - @param numSemaphores size of signalSemaphores array - @param signalSemaphores array of semaphore containers - @return one of: GrSemaphoresSubmitted::kYes, GrSemaphoresSubmitted::kNo + /** Deprecated. */ GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores, GrBackendSemaphore signalSemaphores[]); diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 72aa9c8ab5..48697467ca 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -268,8 +268,16 @@ public: * added any semaphores to signal on the GPU. Thus the client should not have the GPU wait on * any of the semaphores. However, any pending commands to the context will still be flushed. */ + GrSemaphoresSubmitted flush(GrFlushFlags flags, int numSemaphores, + GrBackendSemaphore signalSemaphores[]); + + /** + * Deprecated. + */ GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores, - GrBackendSemaphore signalSemaphores[]); + GrBackendSemaphore signalSemaphores[]) { + return this->flush(kNone_GrFlushFlags, numSemaphores, signalSemaphores); + } // Provides access to functions that aren't part of the public API. GrContextPriv priv(); diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index 5005d57a4c..1d9ae7c841 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -259,6 +259,12 @@ enum GrGLBackendState { */ static const uint32_t kAll_GrBackendState = 0xffffffff; +enum GrFlushFlags { + kNone_GrFlushFlags = 0, + // flush will wait till all submitted GPU work is finished before returning. + kSyncCpu_GrFlushFlag = 0x1, +}; + /** * Enum used as return value when flush with semaphores so the client knows whether the semaphores * were submitted to GPU or not. diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index c73f9cad48..075ac00e51 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -244,19 +244,18 @@ void GrContext::flush() { RETURN_IF_ABANDONED this->drawingManager()->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); } -GrSemaphoresSubmitted GrContext::flushAndSignalSemaphores(int numSemaphores, - GrBackendSemaphore signalSemaphores[]) { +GrSemaphoresSubmitted GrContext::flush(GrFlushFlags flags, int numSemaphores, + GrBackendSemaphore signalSemaphores[]) { ASSERT_SINGLE_OWNER if (this->abandoned()) { return GrSemaphoresSubmitted::kNo; } return this->drawingManager()->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, numSemaphores, - signalSemaphores); + flags, numSemaphores, signalSemaphores); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp index c8aa4d3722..f545e90764 100644 --- a/src/gpu/GrContextPriv.cpp +++ b/src/gpu/GrContextPriv.cpp @@ -195,7 +195,7 @@ void GrContextPriv::flush(GrSurfaceProxy* proxy) { ASSERT_OWNED_PROXY_PRIV(proxy); fContext->drawingManager()->flush(proxy, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); } void GrContextPriv::prepareSurfaceForExternalIO(GrSurfaceProxy* proxy) { @@ -204,7 +204,7 @@ void GrContextPriv::prepareSurfaceForExternalIO(GrSurfaceProxy* proxy) { SkASSERT(proxy); ASSERT_OWNED_PROXY_PRIV(proxy); fContext->drawingManager()->prepareSurfaceForExternalIO(proxy, - SkSurface::BackendSurfaceAccess::kNoAccess, SkSurface::kNone_FlushFlags, 0, nullptr); + SkSurface::BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr); } static bool valid_premul_color_type(GrColorType ct) { diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp index 897c473f89..7904d7520a 100644 --- a/src/gpu/GrDrawingManager.cpp +++ b/src/gpu/GrDrawingManager.cpp @@ -208,7 +208,7 @@ void GrDrawingManager::freeGpuResources() { // MDB TODO: make use of the 'proxy' parameter. GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, + GrFlushFlags flags, int numSemaphores, GrBackendSemaphore backendSemaphores[]) { GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "flush", fContext); @@ -219,7 +219,7 @@ GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxy, SkDEBUGCODE(this->validate()); - if (SkSurface::kNone_FlushFlags == flags && !numSemaphores && proxy && !fDAG.isUsed(proxy)) { + if (kNone_GrFlushFlags == flags && !numSemaphores && proxy && !fDAG.isUsed(proxy)) { return GrSemaphoresSubmitted::kNo; } @@ -442,7 +442,7 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt (*numOpListsExecuted)++; if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) { flushState->gpu()->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); *numOpListsExecuted = 0; } } @@ -460,7 +460,7 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt (*numOpListsExecuted)++; if (*numOpListsExecuted >= kMaxOpListsBeforeFlush) { flushState->gpu()->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); *numOpListsExecuted = 0; } } @@ -479,7 +479,7 @@ bool GrDrawingManager::executeOpLists(int startIndex, int stopIndex, GrOpFlushSt } GrSemaphoresSubmitted GrDrawingManager::prepareSurfaceForExternalIO( - GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, SkSurface::FlushFlags flags, + GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, GrFlushFlags flags, int numSemaphores, GrBackendSemaphore backendSemaphores[]) { if (this->wasAbandoned()) { return GrSemaphoresSubmitted::kNo; @@ -759,7 +759,7 @@ void GrDrawingManager::flushIfNecessary() { auto resourceCache = direct->priv().getResourceCache(); if (resourceCache && resourceCache->requestsFlush()) { this->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); resourceCache->purgeAsNeeded(); } } diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h index 157a6c6a43..d3b8ac1863 100644 --- a/src/gpu/GrDrawingManager.h +++ b/src/gpu/GrDrawingManager.h @@ -74,7 +74,7 @@ public: GrSemaphoresSubmitted prepareSurfaceForExternalIO(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, + GrFlushFlags flags, int numSemaphores, GrBackendSemaphore backendSemaphores[]); @@ -153,7 +153,7 @@ private: GrSemaphoresSubmitted flush(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, + GrFlushFlags flags, int numSemaphores, GrBackendSemaphore backendSemaphores[]); diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp index 7145f74286..c20b25587a 100644 --- a/src/gpu/GrGpu.cpp +++ b/src/gpu/GrGpu.cpp @@ -420,7 +420,7 @@ int GrGpu::findOrAssignSamplePatternKey(GrRenderTarget* renderTarget, const GrPi GrSemaphoresSubmitted GrGpu::finishFlush(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, int numSemaphores, + GrFlushFlags flags, int numSemaphores, GrBackendSemaphore backendSemaphores[]) { this->stats()->incNumFinishFlushes(); GrResourceProvider* resourceProvider = fContext->priv().resourceProvider(); diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h index 5ffcf382e9..e44e74c1c1 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -303,7 +303,7 @@ public: // insert any numSemaphore semaphores on the gpu and set the backendSemaphores to match the // inserted semaphores. GrSemaphoresSubmitted finishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, int numSemaphores, + GrFlushFlags flags, int numSemaphores, GrBackendSemaphore backendSemaphores[]); virtual void submit(GrGpuCommandBuffer*) = 0; @@ -547,7 +547,7 @@ private: bool canDiscardOutsideDstRect) = 0; virtual void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, bool insertedSemaphores) = 0; + GrFlushFlags flags, bool insertedSemaphores) = 0; #ifdef SK_ENABLE_DUMP_GPU virtual void onDumpJSON(SkJSONWriter*) const {} diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index c4db904985..05241d613d 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -1735,7 +1735,7 @@ void GrRenderTargetContext::drawDrawable(std::unique_ptrpriv().abandoned()) { diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index 6d649f7abd..c4ef529bc9 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -407,7 +407,7 @@ public: * if the surface has MSAA it will be resolved. */ GrSemaphoresSubmitted prepareForExternalIO(SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, int numSemaphores, + GrFlushFlags flags, int numSemaphores, GrBackendSemaphore backendSemaphores[]); /** diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 12af310088..9f05af7bcc 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1628,11 +1628,11 @@ void SkGpuDevice::drawDrawable(SkDrawable* drawable, const SkMatrix* matrix, SkC void SkGpuDevice::flush() { this->flushAndSignalSemaphores(SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); } GrSemaphoresSubmitted SkGpuDevice::flushAndSignalSemaphores(SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, + GrFlushFlags flags, int numSemaphores, GrBackendSemaphore signalSemaphores[]) { ASSERT_SINGLE_OWNER diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h index 21072a6518..e36286b8e7 100644 --- a/src/gpu/SkGpuDevice.h +++ b/src/gpu/SkGpuDevice.h @@ -121,7 +121,7 @@ public: void flush() override; GrSemaphoresSubmitted flushAndSignalSemaphores(SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, + GrFlushFlags flags, int numSemaphores, GrBackendSemaphore signalSemaphores[]); bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores); diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 1d2d7c95a7..506d06aff2 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -4307,12 +4307,12 @@ GrGLAttribArrayState* GrGLGpu::HWVertexArrayState::bindInternalVertexArray(GrGLG } void GrGLGpu::onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, bool insertedSemaphore) { + GrFlushFlags flags, bool insertedSemaphore) { // If we inserted semaphores during the flush, we need to call GLFlush. if (insertedSemaphore) { GL_CALL(Flush()); } - if (flags & SkSurface::kSyncCpu_FlushFlag) { + if (flags & kSyncCpu_GrFlushFlag) { GL_CALL(Finish()); } } diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 8d4da154de..b6d6609b84 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -294,7 +294,7 @@ private: void flushBlend(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle&); void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, bool insertedSemaphores) override; + GrFlushFlags flags, bool insertedSemaphores) override; bool copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin, GrSurface* src, GrSurfaceOrigin srcOrigin, diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h index 317ac6e520..56c40ae371 100644 --- a/src/gpu/mock/GrMockGpu.h +++ b/src/gpu/mock/GrMockGpu.h @@ -111,7 +111,7 @@ private: void onResolveRenderTarget(GrRenderTarget* target) override { return; } void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, bool insertedSemaphores) override {} + GrFlushFlags flags, bool insertedSemaphores) override {} GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*, int width, diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h index ddf93643aa..18736eb8f8 100644 --- a/src/gpu/mtl/GrMtlGpu.h +++ b/src/gpu/mtl/GrMtlGpu.h @@ -182,8 +182,8 @@ private: void onResolveRenderTarget(GrRenderTarget* target) override { return; } void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, bool insertedSemaphores) override { - if (flags & SkSurface::kSyncCpu_FlushFlag) { + GrFlushFlags flags, bool insertedSemaphores) override { + if (flags & kSyncCpu_GrFlushFlag) { this->submitCommandBuffer(kForce_SyncQueue); } else { this->submitCommandBuffer(kSkip_SyncQueue); diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index f12a1a8964..e1032b5e56 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1883,7 +1883,7 @@ void GrVkGpu::addImageMemoryBarrier(const GrVkResource* resource, } void GrVkGpu::onFinishFlush(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, bool insertedSemaphore) { + GrFlushFlags flags, bool insertedSemaphore) { // Submit the current command buffer to the Queue. Whether we inserted semaphores or not does // not effect what we do here. if (proxy && access == SkSurface::BackendSurfaceAccess::kPresent) { @@ -1898,7 +1898,7 @@ void GrVkGpu::onFinishFlush(GrSurfaceProxy* proxy, SkSurface::BackendSurfaceAcce } image->prepareForPresent(this); } - if (flags & SkSurface::kSyncCpu_FlushFlag) { + if (flags & kSyncCpu_GrFlushFlag) { this->submitCommandBuffer(kForce_SyncQueue); } else { this->submitCommandBuffer(kSkip_SyncQueue); diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h index 007ac17a7e..963016ff1d 100644 --- a/src/gpu/vk/GrVkGpu.h +++ b/src/gpu/vk/GrVkGpu.h @@ -220,8 +220,8 @@ private: GrSurfaceOrigin srcOrigin, const SkIRect& srcRect, const SkIPoint& dstPoint, bool canDiscardOutsideDstRect) override; - void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, - SkSurface::FlushFlags flags, bool insertedSemaphores) override; + void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, GrFlushFlags flags, + bool insertedSemaphores) override; // Ends and submits the current command buffer to the queue and then creates a new command // buffer and begins it. If sync is set to kForce_SyncQueue, the function will wait for all diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 1e8d2c062c..1c67013515 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -655,7 +655,7 @@ sk_sp SkImage::MakeFromAHardwareBufferWithData(GrContext* context, texContext->writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), 0, 0); drawingManager->flush(proxy.get(), SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kSyncCpu_FlushFlag, 0, nullptr); + kSyncCpu_GrFlushFlag, 0, nullptr); return image; } diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp index df694a4c66..d7a05eecd1 100644 --- a/src/image/SkSurface.cpp +++ b/src/image/SkSurface.cpp @@ -244,17 +244,23 @@ void SkSurface::prepareForExternalIO() { } void SkSurface::flush() { - asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_FlushFlags, 0, nullptr); + asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, 0, nullptr); } -GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, FlushFlags flags, +GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, GrFlushFlags flags, int numSemaphores, GrBackendSemaphore signalSemaphores[]) { return asSB(this)->onFlush(access, flags, numSemaphores, signalSemaphores); } +GrSemaphoresSubmitted SkSurface::flush(BackendSurfaceAccess access, FlushFlags flags, + int numSemaphores, GrBackendSemaphore signalSemaphores[]) { + GrFlushFlags grFlags = flags == kSyncCpu_FlushFlag ? kSyncCpu_GrFlushFlag : kNone_GrFlushFlags; + return this->flush(access, grFlags, numSemaphores, signalSemaphores); +} + GrSemaphoresSubmitted SkSurface::flushAndSignalSemaphores(int numSemaphores, GrBackendSemaphore signalSemaphores[]) { - return asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_FlushFlags, + return asSB(this)->onFlush(BackendSurfaceAccess::kNoAccess, kNone_GrFlushFlags, numSemaphores, signalSemaphores); } diff --git a/src/image/SkSurface_Base.h b/src/image/SkSurface_Base.h index f1096df6cb..0e3cd955f2 100644 --- a/src/image/SkSurface_Base.h +++ b/src/image/SkSurface_Base.h @@ -80,7 +80,7 @@ public: * Inserts the requested number of semaphores for the gpu to signal when work is complete on the * gpu and inits the array of GrBackendSemaphores with the signaled semaphores. */ - virtual GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, FlushFlags flags, + virtual GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, GrFlushFlags flags, int numSemaphores, GrBackendSemaphore signalSemaphores[]) { return GrSemaphoresSubmitted::kNo; diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 3c72f41746..c0c4042acc 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -51,7 +51,7 @@ static GrRenderTarget* prepare_rt_for_external_access(SkSurface_Gpu* surface, // Grab the render target *after* firing notifications, as it may get switched if CoW kicks in. surface->getDevice()->flushAndSignalSemaphores(SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); GrRenderTargetContext* rtc = surface->getDevice()->accessRenderTargetContext(); return rtc->accessRenderTarget(); } @@ -158,7 +158,7 @@ void SkSurface_Gpu::onDiscard() { fDevice->accessRenderTargetContext()->discard(); } -GrSemaphoresSubmitted SkSurface_Gpu::onFlush(BackendSurfaceAccess access, FlushFlags flags, +GrSemaphoresSubmitted SkSurface_Gpu::onFlush(BackendSurfaceAccess access, GrFlushFlags flags, int numSemaphores, GrBackendSemaphore signalSemaphores[]) { return fDevice->flushAndSignalSemaphores(access, flags, numSemaphores, signalSemaphores); diff --git a/src/image/SkSurface_Gpu.h b/src/image/SkSurface_Gpu.h index 4c2b5f336f..13b79c6ad0 100644 --- a/src/image/SkSurface_Gpu.h +++ b/src/image/SkSurface_Gpu.h @@ -32,7 +32,8 @@ public: void onWritePixels(const SkPixmap&, int x, int y) override; void onCopyOnWrite(ContentChangeMode) override; void onDiscard() override; - GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, FlushFlags flags, int numSemaphores, + GrSemaphoresSubmitted onFlush(BackendSurfaceAccess access, GrFlushFlags flags, + int numSemaphores, GrBackendSemaphore signalSemaphores[]) override; bool onWait(int numSemaphores, const GrBackendSemaphore* waitSemaphores) override; bool onCharacterize(SkSurfaceCharacterization*) const override; diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp index b365dbaa4f..74757295e8 100644 --- a/tests/DefaultPathRendererTest.cpp +++ b/tests/DefaultPathRendererTest.cpp @@ -100,7 +100,7 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) { SkMatrix::I(), invPath, style); rtc->prepareForExternalIO(SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); } { diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 7eb580cd6d..78d3749b6e 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -314,7 +314,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma } // Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes) drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); const GrBackendFormat format = context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); @@ -344,7 +344,7 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma paint.addColorFragmentProcessor(std::move(blockFP)); GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint)); drawingManager->flush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); } } diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp index d1d912d23b..3c97842096 100644 --- a/tests/OnFlushCallbackTest.cpp +++ b/tests/OnFlushCallbackTest.cpp @@ -581,7 +581,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) { } rtc->prepareForExternalIO(SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kNone_FlushFlags, 0, nullptr); + kNone_GrFlushFlags, 0, nullptr); SkBitmap readBack; readBack.allocN32Pixels(kFinalWidth, kFinalHeight); diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp index ccb05ff7b2..fd3b44928e 100644 --- a/tests/SurfaceSemaphoreTest.cpp +++ b/tests/SurfaceSemaphoreTest.cpp @@ -144,7 +144,7 @@ void surface_semaphore_test(skiatest::Reporter* reporter, #endif if (flushContext) { - mainCtx->flushAndSignalSemaphores(2, semaphores.get()); + mainCtx->flush(kNone_GrFlushFlags, 2, semaphores.get()); } else { mainSurface->flushAndSignalSemaphores(2, semaphores.get()); } diff --git a/tests/TransferPixelsTest.cpp b/tests/TransferPixelsTest.cpp index e43af8fc9c..bb0a936156 100644 --- a/tests/TransferPixelsTest.cpp +++ b/tests/TransferPixelsTest.cpp @@ -279,7 +279,7 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C // TODO(bsalomon): caps to know if the map() is synchronous and skip the flush if so. gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kSyncCpu_FlushFlag, 0, nullptr); + kSyncCpu_GrFlushFlag, 0, nullptr); const auto* map = reinterpret_cast(buffer->map()); REPORTER_ASSERT(reporter, map); @@ -308,7 +308,7 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C // TODO(bsalomon): caps to know if the map() is synchronous and skip the flush if so. gpu->finishFlush(nullptr, SkSurface::BackendSurfaceAccess::kNoAccess, - SkSurface::kSyncCpu_FlushFlag, 0, nullptr); + kSyncCpu_GrFlushFlag, 0, nullptr); map = reinterpret_cast(buffer->map()); REPORTER_ASSERT(reporter, map); diff --git a/tests/VkHardwareBufferTest.cpp b/tests/VkHardwareBufferTest.cpp index 4fa4b880e4..920940115f 100644 --- a/tests/VkHardwareBufferTest.cpp +++ b/tests/VkHardwareBufferTest.cpp @@ -821,9 +821,9 @@ bool VulkanTestHelper::flushSurfaceAndSignalSemaphore(skiatest::Reporter* report if (!this->setupSemaphoreForSignaling(reporter, &semaphore)) { return false; } - GrSemaphoresSubmitted submitted = fGrContext->flushAndSignalSemaphores(1, &semaphore); + GrSemaphoresSubmitted submitted = fGrContext->flush(kNone_GrFlushFlags, 1, &semaphore); if (GrSemaphoresSubmitted::kNo == submitted) { - ERRORF(reporter, "Failing call to flushAndSignalSemaphores on SkSurface"); + ERRORF(reporter, "Failing call to flush on GrContext"); return false; } SkASSERT(semaphore.isInitialized()); diff --git a/tools/sk_app/VulkanWindowContext.cpp b/tools/sk_app/VulkanWindowContext.cpp index 7d2b81125f..564f1157c5 100644 --- a/tools/sk_app/VulkanWindowContext.cpp +++ b/tools/sk_app/VulkanWindowContext.cpp @@ -514,7 +514,7 @@ void VulkanWindowContext::swapBuffers() { GrBackendSemaphore beSemaphore; beSemaphore.initVulkan(backbuffer->fRenderSemaphore); - surface->flush(SkSurface::BackendSurfaceAccess::kPresent, SkSurface::kNone_FlushFlags, + surface->flush(SkSurface::BackendSurfaceAccess::kPresent, kNone_GrFlushFlags, 1, &beSemaphore); // Submit present operation to present queue