Don't execute onFlush op lists until after GPU data is uploaded

Bug: skia:
Change-Id: I2ea15f67466761ebd24b9d4a8eb51cd2d452be3c
Reviewed-on: https://skia-review.googlesource.com/54942
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2017-10-04 12:48:04 -05:00 committed by Skia Commit-Bot
parent 448324218a
commit 374a4e49e4

View File

@ -137,6 +137,8 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*,
GrOnFlushResourceProvider onFlushProvider(this);
// Prepare any onFlush op lists (e.g. atlases).
SkSTArray<8, sk_sp<GrOpList>> onFlushOpLists;
if (!fOnFlushCBObjects.empty()) {
// MDB TODO: pre-MDB '1' is the correct pre-allocated size. Post-MDB it will need
// to be larger.
@ -144,27 +146,19 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*,
for (int i = 0; i < fOpLists.count(); ++i) {
opListIds[i] = fOpLists[i]->uniqueID();
}
SkSTArray<1, sk_sp<GrRenderTargetContext>> renderTargetContexts;
SkSTArray<4, sk_sp<GrRenderTargetContext>> renderTargetContexts;
for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
onFlushCBObject->preFlush(&onFlushProvider,
opListIds.get(), opListIds.count(),
&renderTargetContexts);
if (!renderTargetContexts.count()) {
continue; // This is fine. No atlases of this type are required for this flush
}
for (int j = 0; j < renderTargetContexts.count(); ++j) {
GrOpList* opList = renderTargetContexts[j]->getOpList();
if (!opList) {
for (const sk_sp<GrRenderTargetContext>& rtc : renderTargetContexts) {
sk_sp<GrOpList> onFlushOpList = sk_ref_sp(rtc->getOpList());
if (!onFlushOpList) {
continue; // Odd - but not a big deal
}
SkASSERT(opList->unique());
opList->makeClosed(*fContext->caps());
opList->prepare(&fFlushState);
if (!opList->execute(&fFlushState)) {
continue; // This is bad
}
onFlushOpList->makeClosed(*fContext->caps());
onFlushOpList->prepare(&fFlushState);
onFlushOpLists.push_back(std::move(onFlushOpList));
}
renderTargetContexts.reset();
}
@ -201,6 +195,17 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*,
// Upload all data to the GPU
fFlushState.preIssueDraws();
// Execute the onFlush op lists first, if any.
for (sk_sp<GrOpList>& onFlushOpList : onFlushOpLists) {
if (!onFlushOpList->execute(&fFlushState)) {
SkDebugf("WARNING: onFlushOpList failed to execute.\n");
}
SkASSERT(onFlushOpList->unique());
onFlushOpList = nullptr;
}
onFlushOpLists.reset();
// Execute the normal op lists.
for (int i = 0; i < fOpLists.count(); ++i) {
if (!fOpLists[i]) {
continue;
@ -227,6 +232,7 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*,
// https://bugs.chromium.org/p/skia/issues/detail?id=7111
fOpLists[i]->endFlush();
}
fOpLists[i] = nullptr;
}
fOpLists.reset();