Reland "Fix vulkan async transfer from call to not submit command buffer to early."

This reverts commit bd986b1044.

Reason for revert: didn't mean to revert

Original change's description:
> Revert "Fix vulkan async transfer from call to not submit command buffer to early."
> 
> This reverts commit 10e259e958.
> 
> Reason for revert: breaks nexus 7 and android one
> 
> Original change's description:
> > Fix vulkan async transfer from call to not submit command buffer to early.
> > 
> > Change-Id: I657758070261a6365975d9c7d61489b1ccb0e437
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219201
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> 
> TBR=egdaniel@google.com,bsalomon@google.com
> 
> Change-Id: Ie3685c84be77e5bfbfbe83278c1341bed5dc20d9
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218958
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,bsalomon@google.com

Change-Id: Iba7975bb7ff0202299c995e71e911b7836e85953
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219383
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2019-06-06 17:23:35 +00:00 committed by Skia Commit-Bot
parent bd986b1044
commit b0c7ad1e89
3 changed files with 48 additions and 4 deletions

View File

@ -335,6 +335,8 @@ GrGpuTextureCommandBuffer* GrVkGpu::getCommandBuffer(GrTexture* texture, GrSurfa
void GrVkGpu::submitCommandBuffer(SyncQueue sync, GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) {
SkASSERT(fCurrentCmdBuffer);
SkASSERT(!fCachedRTCommandBuffer || !fCachedRTCommandBuffer->isActive());
SkASSERT(!fCachedTexCommandBuffer || !fCachedTexCommandBuffer->isActive());
if (!fCurrentCmdBuffer->hasWork() && kForce_SyncQueue != sync &&
!fSemaphoresToSignal.count() && !fSemaphoresToWaitOn.count()) {
@ -569,10 +571,6 @@ bool GrVkGpu::onTransferPixelsFrom(GrSurface* surface, int left, int top, int wi
VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_PIPELINE_STAGE_HOST_BIT,
false);
// The caller is responsible for syncing.
this->submitCommandBuffer(kSkip_SyncQueue);
return true;
}

View File

@ -327,6 +327,10 @@ void GrVkGpuRTCommandBuffer::set(GrRenderTarget* rt, GrSurfaceOrigin origin,
SkASSERT(fGpu == rt->getContext()->priv().getGpu());
SkASSERT(!fLastPipelineState);
#ifdef SK_DEBUG
fIsActive = true;
#endif
this->INHERITED::set(rt, origin);
if (this->wrapsSecondaryCommandBuffer()) {
@ -360,6 +364,10 @@ void GrVkGpuRTCommandBuffer::reset() {
fLastPipelineState = nullptr;
fRenderTarget = nullptr;
#ifdef SK_DEBUG
fIsActive = false;
#endif
}
bool GrVkGpuRTCommandBuffer::wrapsSecondaryCommandBuffer() const {

View File

@ -54,14 +54,38 @@ public:
void reset() {
fTasks.reset();
fTexture = nullptr;
#ifdef SK_DEBUG
fIsActive = false;
#endif
}
void setVk(GrTexture* tex, GrSurfaceOrigin origin) {
#ifdef SK_DEBUG
fIsActive = true;
#endif
this->INHERITED::set(tex, origin);
}
#ifdef SK_DEBUG
bool isActive() const { return fIsActive; }
#endif
void submit();
private:
GrVkGpu* fGpu;
GrTRecorder<GrVkPrimaryCommandBufferTask> fTasks{1024};
#ifdef SK_DEBUG
// When we are actively recording into the GrVkGpuCommandBuffer we set this flag to true. This
// then allows us to assert that we never submit a primary command buffer to the queue while in
// a recording state. This is needed since when we submit to the queue we change command pools
// and may trigger the old one to be reset, but a recording GrVkGpuCommandBuffer may still have
// a outstanding secondary command buffer allocated from that pool that we'll try to access
// after the pool as been reset.
bool fIsActive = false;
#endif
typedef GrGpuTextureCommandBuffer INHERITED;
};
@ -92,6 +116,10 @@ public:
void submit();
#ifdef SK_DEBUG
bool isActive() const { return fIsActive; }
#endif
private:
void init();
@ -193,6 +221,16 @@ private:
VkAttachmentStoreOp fVkStencilStoreOp;
int fCurrentCmdInfo = -1;
#ifdef SK_DEBUG
// When we are actively recording into the GrVkGpuCommandBuffer we set this flag to true. This
// then allows us to assert that we never submit a primary command buffer to the queue while in
// a recording state. This is needed since when we submit to the queue we change command pools
// and may trigger the old one to be reset, but a recording GrVkGpuCommandBuffer may still have
// a outstanding secondary command buffer allocated from that pool that we'll try to access
// after the pool as been reset.
bool fIsActive = false;
#endif
typedef GrGpuRTCommandBuffer INHERITED;
};