aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkGpuCommandBuffer.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2017-08-09 09:30:51 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-08-09 14:30:54 +0000
commit19e51dcd1eb0bcdc70f29620ce4ca30ddbfc2042 (patch)
tree19639614fa3494f150b97c4dd9bf9b07b69474fa /src/gpu/vk/GrVkGpuCommandBuffer.cpp
parent69fd008199989c5a5a96f992dcaa4089b63f490f (diff)
Store GrRenderTarget in GrGpuCommandBuffer
Change-Id: I545d53ffb5f9d450b87a360516b03bdd47232a70 Reviewed-on: https://skia-review.googlesource.com/32460 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/vk/GrVkGpuCommandBuffer.cpp')
-rw-r--r--src/gpu/vk/GrVkGpuCommandBuffer.cpp100
1 files changed, 39 insertions, 61 deletions
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index 2528fce38f..65445264c5 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -57,11 +57,10 @@ GrVkGpuCommandBuffer::GrVkGpuCommandBuffer(GrVkGpu* gpu,
GrRenderTarget* rt, GrSurfaceOrigin origin,
const LoadAndStoreInfo& colorInfo,
const StencilLoadAndStoreInfo& stencilInfo)
- : fGpu(gpu)
- , fRenderTarget(nullptr)
- , fOrigin(kTopLeft_GrSurfaceOrigin)
- , fClearColor(GrColor4f::FromGrColor(colorInfo.fClearColor))
- , fLastPipelineState(nullptr) {
+ : INHERITED(rt, origin)
+ , fGpu(gpu)
+ , fClearColor(GrColor4f::FromGrColor(colorInfo.fClearColor))
+ , fLastPipelineState(nullptr) {
get_vk_load_store_ops(colorInfo.fLoadOp, colorInfo.fStoreOp,
&fVkColorLoadOp, &fVkColorStoreOp);
@@ -69,14 +68,10 @@ GrVkGpuCommandBuffer::GrVkGpuCommandBuffer(GrVkGpu* gpu,
&fVkStencilLoadOp, &fVkStencilStoreOp);
fCurrentCmdInfo = -1;
- this->init(static_cast<GrVkRenderTarget*>(rt), origin);
+ this->init();
}
-void GrVkGpuCommandBuffer::init(GrVkRenderTarget* target, GrSurfaceOrigin origin) {
- SkASSERT(!fRenderTarget);
- fRenderTarget = target;
- fOrigin = origin;
-
+void GrVkGpuCommandBuffer::init() {
GrVkRenderPass::LoadStoreOps vkColorOps(fVkColorLoadOp, fVkColorStoreOp);
GrVkRenderPass::LoadStoreOps vkStencilOps(fVkStencilLoadOp, fVkStencilStoreOp);
@@ -84,13 +79,14 @@ void GrVkGpuCommandBuffer::init(GrVkRenderTarget* target, GrSurfaceOrigin origin
SkASSERT(fCommandBufferInfos.count() == 1);
fCurrentCmdInfo = 0;
- const GrVkResourceProvider::CompatibleRPHandle& rpHandle = target->compatibleRenderPassHandle();
+ GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
+ const GrVkResourceProvider::CompatibleRPHandle& rpHandle = vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
- cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*target,
+ cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
@@ -108,7 +104,7 @@ void GrVkGpuCommandBuffer::init(GrVkRenderTarget* target, GrSurfaceOrigin origin
cbInfo.fStartsWithClear = false;
cbInfo.fCommandBuffers.push_back(fGpu->resourceProvider().findOrCreateSecondaryCommandBuffer());
- cbInfo.currentCmdBuf()->begin(fGpu, target->framebuffer(), cbInfo.fRenderPass);
+ cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
}
@@ -123,7 +119,6 @@ GrVkGpuCommandBuffer::~GrVkGpuCommandBuffer() {
}
GrGpu* GrVkGpuCommandBuffer::gpu() { return fGpu; }
-GrRenderTarget* GrVkGpuCommandBuffer::renderTarget() { return fRenderTarget; }
void GrVkGpuCommandBuffer::begin() {
// TODO: remove this - see skbug.com/6936
@@ -142,10 +137,12 @@ void GrVkGpuCommandBuffer::onSubmit() {
if (!fRenderTarget) {
return;
}
+
+ GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
+
// Change layout of our render target so it can be used as the color attachment. Currently
// we don't attach the resolve to the framebuffer so no need to change its layout.
- GrVkImage* targetImage = fRenderTarget->msaaImage() ? fRenderTarget->msaaImage()
- : fRenderTarget;
+ GrVkImage* targetImage = vkRT->msaaImage() ? vkRT->msaaImage() : vkRT;
// Change layout of our render target so it can be used as the color attachment
targetImage->setImageLayout(fGpu,
@@ -194,17 +191,13 @@ void GrVkGpuCommandBuffer::onSubmit() {
fGpu->submitSecondaryCommandBuffer(cbInfo.fCommandBuffers, cbInfo.fRenderPass,
&cbInfo.fColorClearValue,
&cbInfo.fStencilClearValue,
- fRenderTarget, iBounds);
+ vkRT, iBounds);
}
}
}
-void GrVkGpuCommandBuffer::discard(GrRenderTargetProxy* proxy) {
- GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(proxy->priv().peekRenderTarget());
- if (!fRenderTarget) {
- this->init(target, proxy->origin());
- }
- SkASSERT(target == fRenderTarget);
+void GrVkGpuCommandBuffer::discard() {
+ GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
if (cbInfo.fIsEmpty) {
@@ -217,13 +210,13 @@ void GrVkGpuCommandBuffer::discard(GrRenderTargetProxy* proxy) {
const GrVkRenderPass* oldRP = cbInfo.fRenderPass;
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
- fRenderTarget->compatibleRenderPassHandle();
+ vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
- cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*fRenderTarget,
+ cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
@@ -235,20 +228,13 @@ void GrVkGpuCommandBuffer::discard(GrRenderTargetProxy* proxy) {
}
}
-void GrVkGpuCommandBuffer::insertEventMarker(GrRenderTargetProxy* proxy, const char* msg) {
+void GrVkGpuCommandBuffer::insertEventMarker(const char* msg) {
// TODO: does Vulkan have a correlate?
}
-void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTargetProxy* proxy, const GrFixedClip& clip,
- bool insideStencilMask) {
+void GrVkGpuCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
SkASSERT(!clip.hasWindowRectangles());
- GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(proxy->priv().peekRenderTarget());
- if (!fRenderTarget) {
- this->init(target, proxy->origin());
- }
- SkASSERT(target == fRenderTarget);
-
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
GrStencilAttachment* sb = fRenderTarget->renderTargetPriv().getStencilAttachment();
@@ -306,17 +292,12 @@ void GrVkGpuCommandBuffer::onClearStencilClip(GrRenderTargetProxy* proxy, const
}
}
-void GrVkGpuCommandBuffer::onClear(GrRenderTargetProxy* proxy, const GrFixedClip& clip,
- GrColor color) {
+void GrVkGpuCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) {
+ GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
+
// parent class should never let us get here with no RT
SkASSERT(!clip.hasWindowRectangles());
- GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(proxy->priv().peekRenderTarget());
- if (!fRenderTarget) {
- this->init(target, proxy->origin());
- }
- SkASSERT(target == fRenderTarget);
-
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
VkClearColorValue vkColor;
@@ -332,13 +313,13 @@ void GrVkGpuCommandBuffer::onClear(GrRenderTargetProxy* proxy, const GrFixedClip
const GrVkRenderPass* oldRP = cbInfo.fRenderPass;
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
- fRenderTarget->compatibleRenderPassHandle();
+ vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
- cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*fRenderTarget,
+ cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
@@ -393,13 +374,17 @@ void GrVkGpuCommandBuffer::onClear(GrRenderTargetProxy* proxy, const GrFixedClip
}
void GrVkGpuCommandBuffer::addAdditionalCommandBuffer() {
+ GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
+
CommandBufferInfo& cbInfo = fCommandBufferInfos[fCurrentCmdInfo];
cbInfo.currentCmdBuf()->end(fGpu);
cbInfo.fCommandBuffers.push_back(fGpu->resourceProvider().findOrCreateSecondaryCommandBuffer());
- cbInfo.currentCmdBuf()->begin(fGpu, fRenderTarget->framebuffer(), cbInfo.fRenderPass);
+ cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
}
void GrVkGpuCommandBuffer::addAdditionalRenderPass() {
+ GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(fRenderTarget);
+
fCommandBufferInfos[fCurrentCmdInfo].currentCmdBuf()->end(fGpu);
CommandBufferInfo& cbInfo = fCommandBufferInfos.push_back();
@@ -411,13 +396,13 @@ void GrVkGpuCommandBuffer::addAdditionalRenderPass() {
VK_ATTACHMENT_STORE_OP_STORE);
const GrVkResourceProvider::CompatibleRPHandle& rpHandle =
- fRenderTarget->compatibleRenderPassHandle();
+ vkRT->compatibleRenderPassHandle();
if (rpHandle.isValid()) {
cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(rpHandle,
vkColorOps,
vkStencilOps);
} else {
- cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*fRenderTarget,
+ cbInfo.fRenderPass = fGpu->resourceProvider().findRenderPass(*vkRT,
vkColorOps,
vkStencilOps);
}
@@ -431,15 +416,11 @@ void GrVkGpuCommandBuffer::addAdditionalRenderPass() {
cbInfo.fIsEmpty = true;
cbInfo.fStartsWithClear = false;
- cbInfo.currentCmdBuf()->begin(fGpu, fRenderTarget->framebuffer(), cbInfo.fRenderPass);
+ cbInfo.currentCmdBuf()->begin(fGpu, vkRT->framebuffer(), cbInfo.fRenderPass);
}
-void GrVkGpuCommandBuffer::inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload,
- GrRenderTargetProxy* proxy) {
- GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(proxy->priv().peekRenderTarget());
- if (!fRenderTarget) {
- this->init(target, proxy->origin());
- }
+void GrVkGpuCommandBuffer::inlineUpload(GrOpFlushState* state, GrDrawOp::DeferredUploadFn& upload) {
+
if (!fCommandBufferInfos[fCurrentCmdInfo].fIsEmpty) {
this->addAdditionalRenderPass();
}
@@ -573,11 +554,7 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline,
const GrPipeline::DynamicState dynamicStates[],
int meshCount,
const SkRect& bounds) {
- GrVkRenderTarget* target = static_cast<GrVkRenderTarget*>(pipeline.renderTarget());
- if (!fRenderTarget) {
- this->init(target, pipeline.proxy()->origin());
- }
- SkASSERT(target == fRenderTarget);
+ SkASSERT(pipeline.renderTarget() == fRenderTarget);
if (!meshCount) {
return;
@@ -623,7 +600,8 @@ void GrVkGpuCommandBuffer::onDraw(const GrPipeline& pipeline,
if (dynamicStates) {
if (pipeline.getScissorState().enabled()) {
GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(),
- target, dynamicStates[i].fScissorRect);
+ fRenderTarget,
+ dynamicStates[i].fScissorRect);
}
}