From dbd11ec106e3726b09bf5d240c9fcbf6a671a570 Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Tue, 21 Mar 2017 16:56:31 -0400 Subject: [PATCH] Init Command buffer on inlineUploads in Vulkan When the first thing we do in a GrGpuCommandBuffer is do an inlineUpload, we need to make sure we've initialized the command buffer in Vulkan. BUG=skia: Change-Id: Iabee770864a61697c55fb1df18b31862d8df3cdc Reviewed-on: https://skia-review.googlesource.com/9970 Reviewed-by: Jim Van Verth Commit-Queue: Greg Daniel --- src/gpu/GrGpuCommandBuffer.h | 3 ++- src/gpu/gl/GrGLGpuCommandBuffer.h | 3 ++- src/gpu/ops/GrMeshDrawOp.cpp | 3 ++- src/gpu/vk/GrVkGpuCommandBuffer.cpp | 7 ++++++- src/gpu/vk/GrVkGpuCommandBuffer.h | 3 ++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gpu/GrGpuCommandBuffer.h b/src/gpu/GrGpuCommandBuffer.h index 332b0e5..23a300c 100644 --- a/src/gpu/GrGpuCommandBuffer.h +++ b/src/gpu/GrGpuCommandBuffer.h @@ -73,7 +73,8 @@ public: const SkRect& bounds); // Performs an upload of vertex data in the middle of a set of a set of draws - virtual void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) = 0; + virtual void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload, + GrRenderTarget* rt) = 0; /** * Clear the passed in render target. Ignores the draw state and clip. diff --git a/src/gpu/gl/GrGLGpuCommandBuffer.h b/src/gpu/gl/GrGLGpuCommandBuffer.h index 73deba3..c7c76a4 100644 --- a/src/gpu/gl/GrGLGpuCommandBuffer.h +++ b/src/gpu/gl/GrGLGpuCommandBuffer.h @@ -36,7 +36,8 @@ public: SkASSERT(target == fRenderTarget); } - void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) override { + void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload, + GrRenderTarget*) override { state->doUpload(upload); } diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp index 59335d4..c3a191d 100644 --- a/src/gpu/ops/GrMeshDrawOp.cpp +++ b/src/gpu/ops/GrMeshDrawOp.cpp @@ -72,7 +72,8 @@ void GrMeshDrawOp::onExecute(GrOpFlushState* state) { GrDrawOpUploadToken drawToken = state->nextTokenToFlush(); while (currUploadIdx < fInlineUploads.count() && fInlineUploads[currUploadIdx].fUploadBeforeToken == drawToken) { - state->commandBuffer()->inlineUpload(state, fInlineUploads[currUploadIdx++].fUpload); + state->commandBuffer()->inlineUpload(state, fInlineUploads[currUploadIdx++].fUpload, + this->pipeline()->getRenderTarget()); } const QueuedDraw& draw = fQueuedDraws[currDrawIdx]; state->commandBuffer()->draw(*this->pipeline(), *draw.fGeometryProcessor.get(), diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp index d2d5ee8..c4a8dae 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp +++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp @@ -400,7 +400,12 @@ void GrVkGpuCommandBuffer::addAdditionalCommandBuffer() { cbInfo.fCommandBuffer->begin(fGpu, fRenderTarget->framebuffer(), cbInfo.fRenderPass); } -void GrVkGpuCommandBuffer::inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) { +void GrVkGpuCommandBuffer::inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload, + GrRenderTarget* rt) { + GrVkRenderTarget* target = static_cast(rt); + if (!fRenderTarget) { + this->init(target); + } if (!fCommandBufferInfos[fCurrentCmdBuffer].fIsEmpty) { this->addAdditionalCommandBuffer(); } diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.h b/src/gpu/vk/GrVkGpuCommandBuffer.h index 93370fe..f5f6677 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.h +++ b/src/gpu/vk/GrVkGpuCommandBuffer.h @@ -33,7 +33,8 @@ public: void discard(GrRenderTarget*) override; - void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) override; + void inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload, + GrRenderTarget*) override; private: // Performs lazy initialization on the first operation seen by the command buffer. -- 2.7.4