Revert "Split apart flushing and submitting in the GrGpu classes and GrDrawingManager."
This reverts commit 6341d92280
.
Reason for revert: metal tests failing
Original change's description:
> Split apart flushing and submitting in the GrGpu classes and GrDrawingManager.
>
> Bug: skia:10118
> Change-Id: I53e3b9f1bd28a00276a3d35b5160aa0cfec30cfd
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282417
> Reviewed-by: Jim Van Verth <jvanverth@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,jvanverth@google.com,bsalomon@google.com,senorblanco@chromium.org
Change-Id: I2cb98b470e3a066c09012b686e9942edb5a3979b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:10118
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/282852
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
bb776c11a6
commit
2faa33772b
@ -319,17 +319,8 @@ GrSemaphoresSubmitted GrContext::flush(const GrFlushInfo& info,
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
bool submitted = false;
|
||||
if (this->drawingManager()->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
info, externalRequests)) {
|
||||
bool forceSync = SkToBool(info.fFlags & kSyncCpu_GrFlushFlag);
|
||||
submitted = this->drawingManager()->submitToGpu(forceSync);
|
||||
}
|
||||
|
||||
if (!submitted || (!this->priv().caps()->semaphoreSupport() && info.fNumSemaphores)) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
return GrSemaphoresSubmitted::kYes;
|
||||
return this->drawingManager()->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
info, externalRequests);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -221,7 +221,7 @@ void GrDrawingManager::freeGpuResources() {
|
||||
}
|
||||
|
||||
// MDB TODO: make use of the 'proxy' parameter.
|
||||
bool GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
|
||||
GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
|
||||
SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info,
|
||||
const GrPrepareForExternalIORequests& externalRequests) {
|
||||
SkASSERT(numProxies >= 0);
|
||||
@ -232,7 +232,7 @@ bool GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
return false;
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
SkDEBUGCODE(this->validate());
|
||||
@ -244,7 +244,7 @@ bool GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
|
||||
canSkip = !fDAG.isUsed(proxies[i]) && !this->isDDLTarget(proxies[i]);
|
||||
}
|
||||
if (canSkip) {
|
||||
return false;
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ bool GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
return false; // Can't flush while DDL recording
|
||||
return GrSemaphoresSubmitted::kNo; // Can't flush while DDL recording
|
||||
}
|
||||
direct->priv().clientMappedBufferManager()->process();
|
||||
|
||||
@ -262,7 +262,7 @@ bool GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
return false; // Can't flush while DDL recording
|
||||
return GrSemaphoresSubmitted::kNo; // Can't flush while DDL recording
|
||||
}
|
||||
|
||||
fFlushing = true;
|
||||
@ -394,7 +394,8 @@ bool GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
|
||||
opMemoryPool->isEmpty();
|
||||
#endif
|
||||
|
||||
gpu->executeFlushInfo(proxies, numProxies, access, info, externalRequests);
|
||||
GrSemaphoresSubmitted result = gpu->finishFlush(proxies, numProxies, access, info,
|
||||
externalRequests);
|
||||
|
||||
// Give the cache a chance to purge resources that become purgeable due to flushing.
|
||||
if (flushed) {
|
||||
@ -412,20 +413,7 @@ bool GrDrawingManager::flush(GrSurfaceProxy* proxies[], int numProxies,
|
||||
fFlushingRenderTaskIDs.reset();
|
||||
fFlushing = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GrDrawingManager::submitToGpu(bool syncToCpu) {
|
||||
if (fFlushing || this->wasAbandoned()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto direct = fContext->priv().asDirectContext();
|
||||
if (!direct) {
|
||||
return false; // Can't submit while DDL recording
|
||||
}
|
||||
GrGpu* gpu = direct->priv().getGpu();
|
||||
return gpu->submitToGpu(syncToCpu);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GrDrawingManager::executeRenderTasks(int startIndex, int stopIndex, GrOpFlushState* flushState,
|
||||
@ -474,7 +462,8 @@ bool GrDrawingManager::executeRenderTasks(int startIndex, int stopIndex, GrOpFlu
|
||||
onFlushRenderTask = nullptr;
|
||||
(*numRenderTasksExecuted)++;
|
||||
if (*numRenderTasksExecuted >= kMaxRenderTasksBeforeFlush) {
|
||||
flushState->gpu()->submitToGpu(false);
|
||||
flushState->gpu()->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
GrFlushInfo(), GrPrepareForExternalIORequests());
|
||||
*numRenderTasksExecuted = 0;
|
||||
}
|
||||
}
|
||||
@ -492,7 +481,8 @@ bool GrDrawingManager::executeRenderTasks(int startIndex, int stopIndex, GrOpFlu
|
||||
}
|
||||
(*numRenderTasksExecuted)++;
|
||||
if (*numRenderTasksExecuted >= kMaxRenderTasksBeforeFlush) {
|
||||
flushState->gpu()->submitToGpu(false);
|
||||
flushState->gpu()->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess,
|
||||
GrFlushInfo(), GrPrepareForExternalIORequests());
|
||||
*numRenderTasksExecuted = 0;
|
||||
}
|
||||
}
|
||||
@ -533,12 +523,12 @@ GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(GrSurfaceProxy* proxies[],
|
||||
// TODO: It is important to upgrade the drawingmanager to just flushing the
|
||||
// portion of the DAG required by 'proxies' in order to restore some of the
|
||||
// semantics of this method.
|
||||
bool didFlush = this->flush(proxies, numProxies, access, info,
|
||||
GrPrepareForExternalIORequests());
|
||||
GrSemaphoresSubmitted result = this->flush(proxies, numProxies, access, info,
|
||||
GrPrepareForExternalIORequests());
|
||||
for (int i = 0; i < numProxies; ++i) {
|
||||
GrSurfaceProxy* proxy = proxies[i];
|
||||
if (!proxy->isInstantiated()) {
|
||||
continue;
|
||||
return result;
|
||||
}
|
||||
// In the flushSurfaces case, we need to resolve MSAA immediately after flush. This is
|
||||
// because the client will call through to this method when drawing into a target created by
|
||||
@ -568,16 +558,7 @@ GrSemaphoresSubmitted GrDrawingManager::flushSurfaces(GrSurfaceProxy* proxies[],
|
||||
}
|
||||
|
||||
SkDEBUGCODE(this->validate());
|
||||
|
||||
bool submitted = false;
|
||||
if (didFlush) {
|
||||
submitted = this->submitToGpu(SkToBool(info.fFlags & kSyncCpu_GrFlushFlag));
|
||||
}
|
||||
|
||||
if (!submitted || (!direct->priv().caps()->semaphoreSupport() && info.fNumSemaphores)) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
return GrSemaphoresSubmitted::kYes;
|
||||
return result;
|
||||
}
|
||||
|
||||
void GrDrawingManager::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBObject) {
|
||||
@ -929,10 +910,8 @@ void GrDrawingManager::flushIfNecessary() {
|
||||
|
||||
auto resourceCache = direct->priv().getResourceCache();
|
||||
if (resourceCache && resourceCache->requestsFlush()) {
|
||||
if (this->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(),
|
||||
GrPrepareForExternalIORequests())) {
|
||||
this->submitToGpu(false);
|
||||
}
|
||||
this->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(),
|
||||
GrPrepareForExternalIORequests());
|
||||
resourceCache->purgeAsNeeded();
|
||||
}
|
||||
}
|
||||
|
@ -182,13 +182,11 @@ private:
|
||||
bool executeRenderTasks(int startIndex, int stopIndex, GrOpFlushState*,
|
||||
int* numRenderTasksExecuted);
|
||||
|
||||
bool flush(GrSurfaceProxy* proxies[],
|
||||
int numProxies,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&,
|
||||
const GrPrepareForExternalIORequests&);
|
||||
|
||||
bool submitToGpu(bool syncToCpu);
|
||||
GrSemaphoresSubmitted flush(GrSurfaceProxy* proxies[],
|
||||
int numProxies,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&,
|
||||
const GrPrepareForExternalIORequests&);
|
||||
|
||||
SkDEBUGCODE(void validate() const);
|
||||
|
||||
|
@ -646,13 +646,16 @@ void GrGpu::validateStagingBuffers() const {
|
||||
}
|
||||
#endif
|
||||
|
||||
void GrGpu::executeFlushInfo(GrSurfaceProxy* proxies[],
|
||||
int numProxies,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info,
|
||||
const GrPrepareForExternalIORequests& externalRequests) {
|
||||
GrSemaphoresSubmitted GrGpu::finishFlush(GrSurfaceProxy* proxies[],
|
||||
int n,
|
||||
SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info,
|
||||
const GrPrepareForExternalIORequests& externalRequests) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
this->validateStagingBuffers();
|
||||
#endif
|
||||
this->stats()->incNumFinishFlushes();
|
||||
GrResourceProvider* resourceProvider = fContext->priv().resourceProvider();
|
||||
|
||||
std::unique_ptr<std::unique_ptr<GrSemaphore>[]> semaphores(
|
||||
@ -675,30 +678,21 @@ void GrGpu::executeFlushInfo(GrSurfaceProxy* proxies[],
|
||||
}
|
||||
}
|
||||
|
||||
if (info.fFinishedProc) {
|
||||
this->addFinishedProc(info.fFinishedProc, info.fFinishedContext);
|
||||
}
|
||||
this->prepareSurfacesForBackendAccessAndExternalIO(proxies, numProxies, access,
|
||||
externalRequests);
|
||||
}
|
||||
|
||||
bool GrGpu::submitToGpu(bool syncCpu) {
|
||||
this->stats()->incNumSubmitToGpus();
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
this->validateStagingBuffers();
|
||||
#endif
|
||||
this->unmapStagingBuffers();
|
||||
|
||||
bool submitted = this->onSubmitToGpu(syncCpu);
|
||||
if (!this->onFinishFlush(proxies, n, access, info, externalRequests)) {
|
||||
return GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
|
||||
// Move all active staging buffers to the busy list.
|
||||
// TODO: this should probably be handled inside of the onSubmitToGpu by the backends.
|
||||
while (GrStagingBuffer* buffer = fActiveStagingBuffers.head()) {
|
||||
fActiveStagingBuffers.remove(buffer);
|
||||
fBusyStagingBuffers.addToTail(buffer);
|
||||
}
|
||||
return submitted;
|
||||
|
||||
return this->caps()->semaphoreSupport() ? GrSemaphoresSubmitted::kYes
|
||||
: GrSemaphoresSubmitted::kNo;
|
||||
}
|
||||
|
||||
#ifdef SK_ENABLE_DUMP_GPU
|
||||
|
@ -360,11 +360,9 @@ public:
|
||||
// Provides a hook for post-flush actions (e.g. Vulkan command buffer submits). This will also
|
||||
// insert any numSemaphore semaphores on the gpu and set the backendSemaphores to match the
|
||||
// inserted semaphores.
|
||||
void executeFlushInfo(GrSurfaceProxy*[], int numProxies,
|
||||
SkSurface::BackendSurfaceAccess access, const GrFlushInfo&,
|
||||
const GrPrepareForExternalIORequests&);
|
||||
|
||||
bool submitToGpu(bool syncCpu);
|
||||
GrSemaphoresSubmitted finishFlush(GrSurfaceProxy*[], int n,
|
||||
SkSurface::BackendSurfaceAccess access, const GrFlushInfo&,
|
||||
const GrPrepareForExternalIORequests&);
|
||||
|
||||
virtual void submit(GrOpsRenderPass*) = 0;
|
||||
|
||||
@ -435,8 +433,8 @@ public:
|
||||
int numFailedDraws() const { return fNumFailedDraws; }
|
||||
void incNumFailedDraws() { ++fNumFailedDraws; }
|
||||
|
||||
int numSubmitToGpus() const { return fNumSubmitToGpus; }
|
||||
void incNumSubmitToGpus() { ++fNumSubmitToGpus; }
|
||||
int numFinishFlushes() const { return fNumFinishFlushes; }
|
||||
void incNumFinishFlushes() { ++fNumFinishFlushes; }
|
||||
|
||||
int numScratchTexturesReused() const { return fNumScratchTexturesReused; }
|
||||
void incNumScratchTexturesReused() { ++fNumScratchTexturesReused; }
|
||||
@ -484,7 +482,7 @@ public:
|
||||
int fStencilAttachmentCreates = 0;
|
||||
int fNumDraws = 0;
|
||||
int fNumFailedDraws = 0;
|
||||
int fNumSubmitToGpus = 0;
|
||||
int fNumFinishFlushes = 0;
|
||||
int fNumScratchTexturesReused = 0;
|
||||
|
||||
int fNumInlineCompilationFailures = 0;
|
||||
@ -511,7 +509,7 @@ public:
|
||||
void incStencilAttachmentCreates() {}
|
||||
void incNumDraws() {}
|
||||
void incNumFailedDraws() {}
|
||||
void incNumSubmitToGpus() {}
|
||||
void incNumFinishFlushes() {}
|
||||
void incNumInlineCompilationFailures() {}
|
||||
void incNumInlineProgramCacheResult(ProgramCacheResult stat) {}
|
||||
void incNumPreCompilationFailures() {}
|
||||
@ -807,14 +805,8 @@ private:
|
||||
virtual bool onCopySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
|
||||
const SkIPoint& dstPoint) = 0;
|
||||
|
||||
virtual void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) = 0;
|
||||
|
||||
virtual void prepareSurfacesForBackendAccessAndExternalIO(
|
||||
GrSurfaceProxy* proxies[], int numProxies, SkSurface::BackendSurfaceAccess access,
|
||||
const GrPrepareForExternalIORequests& externalRequests) {}
|
||||
|
||||
virtual bool onSubmitToGpu(bool syncCpu) = 0;
|
||||
virtual bool onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&, const GrPrepareForExternalIORequests&) = 0;
|
||||
|
||||
#ifdef SK_ENABLE_DUMP_GPU
|
||||
virtual void onDumpJSON(SkJSONWriter*) const {}
|
||||
|
@ -160,14 +160,11 @@ private:
|
||||
|
||||
void onResolveRenderTarget(GrRenderTarget* target, const SkIRect&, ForExternalIO) override {}
|
||||
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override {
|
||||
// TODO: have this actually wait before calling the proc
|
||||
SkASSERT(finishedProc);
|
||||
finishedProc(finishedContext);
|
||||
}
|
||||
|
||||
bool onSubmitToGpu(bool syncCpu) override {
|
||||
bool onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info, const GrPrepareForExternalIORequests&) override {
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -442,12 +442,8 @@ void GrDawnGpu::flush() {
|
||||
fDevice.Tick();
|
||||
}
|
||||
|
||||
void GrDawnGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
bool GrDawnGpu::onSubmitToGpu(bool syncCpu) {
|
||||
bool GrDawnGpu::onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info, const GrPrepareForExternalIORequests&) {
|
||||
this->flush();
|
||||
return true;
|
||||
}
|
||||
@ -520,7 +516,7 @@ bool GrDawnGpu::onReadPixels(GrSurface* surface, int left, int top, int width, i
|
||||
|
||||
wgpu::Extent3D copySize = {(uint32_t) width, (uint32_t) height, 1};
|
||||
this->getCopyEncoder().CopyTextureToBuffer(&srcTexture, &dstBuffer, ©Size);
|
||||
this->flush();
|
||||
flush();
|
||||
|
||||
const void *readPixelsPtr = nullptr;
|
||||
buf.MapReadAsync(callback, &readPixelsPtr);
|
||||
|
@ -172,10 +172,8 @@ private:
|
||||
bool onCopySurface(GrSurface* dst, GrSurface* src,
|
||||
const SkIRect& srcRect, const SkIPoint& dstPoint) override;
|
||||
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override;
|
||||
|
||||
bool onSubmitToGpu(bool syncCpu) override;
|
||||
bool onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info, const GrPrepareForExternalIORequests&) override;
|
||||
|
||||
void mapStagingBuffers();
|
||||
|
||||
|
@ -3784,35 +3784,37 @@ GrGLAttribArrayState* GrGLGpu::HWVertexArrayState::bindInternalVertexArray(GrGLG
|
||||
return attribState;
|
||||
}
|
||||
|
||||
void GrGLGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
SkASSERT(finishedProc);
|
||||
FinishCallback callback;
|
||||
callback.fCallback = finishedProc;
|
||||
callback.fContext = finishedContext;
|
||||
if (this->caps()->fenceSyncSupport()) {
|
||||
callback.fSync = (GrGLsync)this->insertFence();
|
||||
} else {
|
||||
callback.fSync = 0;
|
||||
}
|
||||
fFinishCallbacks.push_back(callback);
|
||||
}
|
||||
|
||||
bool GrGLGpu::onSubmitToGpu(bool syncCpu) {
|
||||
if (syncCpu || (!fFinishCallbacks.empty() && !this->caps()->fenceSyncSupport())) {
|
||||
bool GrGLGpu::onFinishFlush(GrSurfaceProxy*[], int, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info, const GrPrepareForExternalIORequests&) {
|
||||
// If we inserted semaphores during the flush, we need to call GLFlush.
|
||||
bool insertedSemaphore = info.fNumSemaphores > 0 && this->caps()->semaphoreSupport();
|
||||
// We call finish if the client told us to sync or if we have a finished proc but don't support
|
||||
// GLsync objects.
|
||||
bool finish = (info.fFlags & kSyncCpu_GrFlushFlag) ||
|
||||
(info.fFinishedProc && !this->caps()->fenceSyncSupport());
|
||||
if (finish) {
|
||||
GL_CALL(Finish());
|
||||
// After a finish everything previously sent to GL is done.
|
||||
for (const auto& cb : fFinishCallbacks) {
|
||||
cb.fCallback(cb.fContext);
|
||||
if (cb.fSync) {
|
||||
this->deleteSync(cb.fSync);
|
||||
} else {
|
||||
SkASSERT(!this->caps()->fenceSyncSupport());
|
||||
}
|
||||
this->deleteSync(cb.fSync);
|
||||
}
|
||||
fFinishCallbacks.clear();
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
} else {
|
||||
GL_CALL(Flush());
|
||||
if (info.fFinishedProc) {
|
||||
FinishCallback callback;
|
||||
callback.fCallback = info.fFinishedProc;
|
||||
callback.fContext = info.fFinishedContext;
|
||||
callback.fSync = (GrGLsync)this->insertFence();
|
||||
fFinishCallbacks.push_back(callback);
|
||||
GL_CALL(Flush());
|
||||
} else if (insertedSemaphore) {
|
||||
// Must call flush after semaphores in case they are waited on another GL context.
|
||||
GL_CALL(Flush());
|
||||
}
|
||||
// See if any previously inserted finish procs are good to go.
|
||||
this->checkFinishProcs();
|
||||
}
|
||||
|
@ -306,10 +306,8 @@ private:
|
||||
|
||||
void flushBlendAndColorWrite(const GrXferProcessor::BlendInfo& blendInfo, const GrSwizzle&);
|
||||
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override;
|
||||
|
||||
bool onSubmitToGpu(bool syncCpu) override;
|
||||
bool onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&, const GrPrepareForExternalIORequests&) override;
|
||||
|
||||
bool waitSync(GrGLsync, uint64_t timeout, bool flush);
|
||||
|
||||
|
@ -131,13 +131,11 @@ private:
|
||||
|
||||
void onResolveRenderTarget(GrRenderTarget* target, const SkIRect&, ForExternalIO) override {}
|
||||
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override {
|
||||
SkASSERT(finishedProc);
|
||||
finishedProc(finishedContext);
|
||||
}
|
||||
|
||||
bool onSubmitToGpu(bool syncCpu) override {
|
||||
bool onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info, const GrPrepareForExternalIORequests&) override {
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -199,10 +199,8 @@ private:
|
||||
|
||||
void resolveTexture(id<MTLTexture> colorTexture, id<MTLTexture> resolveTexture);
|
||||
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override;
|
||||
|
||||
bool onSubmitToGpu(bool syncCpu) override;
|
||||
bool onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo& info, const GrPrepareForExternalIORequests&) override;
|
||||
|
||||
// Function that uploads data onto textures with private storage mode (GPU access only).
|
||||
bool uploadToTexture(GrMtlTexture* tex, int left, int top, int width, int height,
|
||||
|
@ -187,26 +187,30 @@ void GrMtlGpu::submitCommandBuffer(SyncQueue sync) {
|
||||
}
|
||||
}
|
||||
|
||||
void GrMtlGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
SkASSERT(finishedProc);
|
||||
SkASSERT(this->caps()->fenceSyncSupport());
|
||||
FinishCallback callback;
|
||||
callback.fCallback = finishedProc;
|
||||
callback.fContext = finishedContext;
|
||||
callback.fFence = this->insertFence();
|
||||
fFinishCallbacks.push_back(callback);
|
||||
}
|
||||
|
||||
bool GrMtlGpu::onSubmitToGpu(bool syncCpu) {
|
||||
if (syncCpu) {
|
||||
bool GrMtlGpu::onFinishFlush(GrSurfaceProxy*[], int, SkSurface::BackendSurfaceAccess,
|
||||
const GrFlushInfo& info, const GrPrepareForExternalIORequests&) {
|
||||
bool forceSync = SkToBool(info.fFlags & kSyncCpu_GrFlushFlag) ||
|
||||
(info.fFinishedProc && !this->mtlCaps().fenceSyncSupport());
|
||||
// TODO: do we care about info.fSemaphore?
|
||||
if (forceSync) {
|
||||
this->submitCommandBuffer(kForce_SyncQueue);
|
||||
// After a forced sync everything previously sent to the GPU is done.
|
||||
for (const auto& cb : fFinishCallbacks) {
|
||||
cb.fCallback(cb.fContext);
|
||||
this->deleteFence(cb.fFence);
|
||||
}
|
||||
fFinishCallbacks.clear();
|
||||
if (info.fFinishedProc) {
|
||||
info.fFinishedProc(info.fFinishedContext);
|
||||
}
|
||||
} else {
|
||||
if (info.fFinishedProc) {
|
||||
FinishCallback callback;
|
||||
callback.fCallback = info.fFinishedProc;
|
||||
callback.fContext = info.fFinishedContext;
|
||||
callback.fFence = this->insertFence();
|
||||
fFinishCallbacks.push_back(callback);
|
||||
}
|
||||
this->submitCommandBuffer(kSkip_SyncQueue);
|
||||
}
|
||||
return true;
|
||||
|
@ -642,7 +642,7 @@ void GrVkPrimaryCommandBuffer::onReleaseResources() {
|
||||
for (int i = 0; i < fSecondaryCommandBuffers.count(); ++i) {
|
||||
fSecondaryCommandBuffers[i]->releaseResources();
|
||||
}
|
||||
this->callFinishedProcs();
|
||||
fFinishedProcs.reset();
|
||||
}
|
||||
|
||||
void GrVkPrimaryCommandBuffer::recycleSecondaryCommandBuffers(GrVkCommandPool* cmdPool) {
|
||||
|
@ -299,10 +299,6 @@ public:
|
||||
|
||||
void addFinishedProc(sk_sp<GrRefCntedCallback> finishedProc);
|
||||
|
||||
void callFinishedProcs() {
|
||||
fFinishedProcs.reset();
|
||||
}
|
||||
|
||||
void recycleSecondaryCommandBuffers(GrVkCommandPool* cmdPool);
|
||||
|
||||
private:
|
||||
|
@ -312,20 +312,19 @@ GrOpsRenderPass* GrVkGpu::getOpsRenderPass(
|
||||
return fCachedOpsRenderPass.get();
|
||||
}
|
||||
|
||||
bool GrVkGpu::submitCommandBuffer(SyncQueue sync) {
|
||||
bool GrVkGpu::submitCommandBuffer(SyncQueue sync, GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
TRACE_EVENT0("skia.gpu", TRACE_FUNC);
|
||||
SkASSERT(fCurrentCmdBuffer);
|
||||
SkASSERT(!fCachedOpsRenderPass || !fCachedOpsRenderPass->isActive());
|
||||
|
||||
if (!fCurrentCmdBuffer->hasWork() && kForce_SyncQueue != sync &&
|
||||
!fSemaphoresToSignal.count() && !fSemaphoresToWaitOn.count()) {
|
||||
// We may have added finished procs during the flush call. Since there is no actual work
|
||||
// we are not submitting the command buffer and may never come back around to submit it.
|
||||
// Thus we call all current finished procs manually, since the work has technically
|
||||
// finished.
|
||||
fCurrentCmdBuffer->callFinishedProcs();
|
||||
SkASSERT(fDrawables.empty());
|
||||
fResourceProvider.checkCommandBuffers();
|
||||
if (finishedProc) {
|
||||
fResourceProvider.addFinishedProcToActiveCommandBuffers(finishedProc, finishedContext);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -339,6 +338,11 @@ bool GrVkGpu::submitCommandBuffer(SyncQueue sync) {
|
||||
fCurrentCmdBuffer->forceSync(this);
|
||||
}
|
||||
|
||||
if (finishedProc) {
|
||||
// Make sure this is called after closing the current command pool
|
||||
fResourceProvider.addFinishedProcToActiveCommandBuffers(finishedProc, finishedContext);
|
||||
}
|
||||
|
||||
// We must delete any drawables that had to wait until submit to destroy.
|
||||
fDrawables.reset();
|
||||
|
||||
@ -2095,16 +2099,16 @@ void GrVkGpu::addImageMemoryBarrier(const GrManagedResource* resource,
|
||||
barrier);
|
||||
}
|
||||
|
||||
void GrVkGpu::prepareSurfacesForBackendAccessAndExternalIO(
|
||||
GrSurfaceProxy* proxies[], int numProxies, SkSurface::BackendSurfaceAccess access,
|
||||
const GrPrepareForExternalIORequests& externalRequests) {
|
||||
SkASSERT(numProxies >= 0);
|
||||
SkASSERT(!numProxies || proxies);
|
||||
bool GrVkGpu::onFinishFlush(GrSurfaceProxy* proxies[], int n,
|
||||
SkSurface::BackendSurfaceAccess access, const GrFlushInfo& info,
|
||||
const GrPrepareForExternalIORequests& externalRequests) {
|
||||
SkASSERT(n >= 0);
|
||||
SkASSERT(!n || proxies);
|
||||
// Submit the current command buffer to the Queue. Whether we inserted semaphores or not does
|
||||
// not effect what we do here.
|
||||
if (numProxies && access == SkSurface::BackendSurfaceAccess::kPresent) {
|
||||
if (n && access == SkSurface::BackendSurfaceAccess::kPresent) {
|
||||
GrVkImage* image;
|
||||
for (int i = 0; i < numProxies; ++i) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
SkASSERT(proxies[i]->isInstantiated());
|
||||
if (GrTexture* tex = proxies[i]->peekTexture()) {
|
||||
image = static_cast<GrVkTexture*>(tex);
|
||||
@ -2166,19 +2170,13 @@ void GrVkGpu::prepareSurfacesForBackendAccessAndExternalIO(
|
||||
vkRT->prepareForExternal(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GrVkGpu::addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) {
|
||||
SkASSERT(finishedProc);
|
||||
fResourceProvider.addFinishedProcToActiveCommandBuffers(finishedProc, finishedContext);
|
||||
}
|
||||
|
||||
bool GrVkGpu::onSubmitToGpu(bool syncCpu) {
|
||||
if (syncCpu) {
|
||||
return this->submitCommandBuffer(kForce_SyncQueue);
|
||||
if (info.fFlags & kSyncCpu_GrFlushFlag) {
|
||||
return this->submitCommandBuffer(kForce_SyncQueue, info.fFinishedProc,
|
||||
info.fFinishedContext);
|
||||
} else {
|
||||
return this->submitCommandBuffer(kSkip_SyncQueue);
|
||||
return this->submitCommandBuffer(kSkip_SyncQueue, info.fFinishedProc,
|
||||
info.fFinishedContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,14 +243,8 @@ private:
|
||||
bool onCopySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRect,
|
||||
const SkIPoint& dstPoint) override;
|
||||
|
||||
void addFinishedProc(GrGpuFinishedProc finishedProc,
|
||||
GrGpuFinishedContext finishedContext) override;
|
||||
|
||||
void prepareSurfacesForBackendAccessAndExternalIO(
|
||||
GrSurfaceProxy* proxies[], int numProxies, SkSurface::BackendSurfaceAccess access,
|
||||
const GrPrepareForExternalIORequests& externalRequests) override;
|
||||
|
||||
bool onSubmitToGpu(bool syncCpu) override;
|
||||
bool onFinishFlush(GrSurfaceProxy*[], int, SkSurface::BackendSurfaceAccess access,
|
||||
const GrFlushInfo&, const GrPrepareForExternalIORequests&) 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
|
||||
@ -258,7 +252,8 @@ private:
|
||||
// fSemaphoreToSignal, we will add those signal semaphores to the submission of this command
|
||||
// buffer. If this GrVkGpu object has any semaphores in fSemaphoresToWaitOn, we will add those
|
||||
// wait semaphores to the submission of this command buffer.
|
||||
bool submitCommandBuffer(SyncQueue sync);
|
||||
bool submitCommandBuffer(SyncQueue sync, GrGpuFinishedProc finishedProc = nullptr,
|
||||
GrGpuFinishedContext finishedContext = nullptr);
|
||||
|
||||
void copySurfaceAsCopyImage(GrSurface* dst, GrSurface* src, GrVkImage* dstImage,
|
||||
GrVkImage* srcImage, const SkIRect& srcRect,
|
||||
|
@ -347,8 +347,10 @@ void GrVkResourceProvider::addFinishedProcToActiveCommandBuffers(
|
||||
sk_sp<GrRefCntedCallback> procRef(new GrRefCntedCallback(finishedProc, finishedContext));
|
||||
for (int i = 0; i < fActiveCommandPools.count(); ++i) {
|
||||
GrVkCommandPool* pool = fActiveCommandPools[i];
|
||||
GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer();
|
||||
buffer->addFinishedProc(procRef);
|
||||
if (!pool->isOpen()) {
|
||||
GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer();
|
||||
buffer->addFinishedProc(procRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrOpsTaskFlushCount, reporter, ctxInfo) {
|
||||
// In total we make 2000 oplists. Our current limit on max oplists between flushes is 100, so we
|
||||
// should do 20 flushes while executing oplists. Additionaly we always do 1 flush at the end of
|
||||
// executing all oplists. So in total we should see 21 flushes here.
|
||||
REPORTER_ASSERT(reporter, gpu->stats()->numSubmitToGpus() == 21);
|
||||
REPORTER_ASSERT(reporter, gpu->stats()->numFinishFlushes() == 21);
|
||||
|
||||
SkBitmap readbackBitmap;
|
||||
readbackBitmap.allocN32Pixels(1000, 1);
|
||||
|
@ -1380,8 +1380,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
|
||||
// Flush all the setup work we did above and then make little lambda that reports the flush
|
||||
// count delta since the last time it was called.
|
||||
c->flush();
|
||||
auto numFlushes = [c, flushCnt = c->priv().getGpu()->stats()->numSubmitToGpus()]() mutable {
|
||||
int curr = c->priv().getGpu()->stats()->numSubmitToGpus();
|
||||
auto numFlushes = [c, flushCnt = c->priv().getGpu()->stats()->numFinishFlushes()]() mutable {
|
||||
int curr = c->priv().getGpu()->stats()->numFinishFlushes();
|
||||
int n = curr - flushCnt;
|
||||
flushCnt = curr;
|
||||
return n;
|
||||
|
@ -1707,7 +1707,7 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(OverbudgetFlush, reporter, ctxInfo) {
|
||||
// Helper that checks whether a flush has occurred between calls.
|
||||
int baseFlushCount = 0;
|
||||
auto getFlushCountDelta = [context, &baseFlushCount]() {
|
||||
int cur = context->priv().getGpu()->stats()->numSubmitToGpus();
|
||||
int cur = context->priv().getGpu()->stats()->numFinishFlushes();
|
||||
int delta = cur - baseFlushCount;
|
||||
baseFlushCount = cur;
|
||||
return delta;
|
||||
|
@ -330,8 +330,11 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C
|
||||
}
|
||||
++expectedTransferCnt;
|
||||
|
||||
GrFlushInfo flushInfo;
|
||||
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
|
||||
if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
|
||||
gpu->submitToGpu(true);
|
||||
gpu->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo,
|
||||
GrPrepareForExternalIORequests());
|
||||
}
|
||||
|
||||
// Copy the transfer buffer contents to a temporary so we can manipulate it.
|
||||
@ -371,7 +374,8 @@ void basic_transfer_from_test(skiatest::Reporter* reporter, const sk_gpu_test::C
|
||||
++expectedTransferCnt;
|
||||
|
||||
if (context->priv().caps()->mapBufferFlags() & GrCaps::kAsyncRead_MapFlag) {
|
||||
gpu->submitToGpu(true);
|
||||
gpu->finishFlush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo,
|
||||
GrPrepareForExternalIORequests());
|
||||
}
|
||||
|
||||
map = reinterpret_cast<const char*>(buffer->map());
|
||||
|
Loading…
Reference in New Issue
Block a user