In GrVkGpuCommandBuffer when setting bounds to full RT use proxy bounds instead of surface.
My guess is perf wise this will be a wash/nothing really changes, but it at least lets
Vulkan know exactly what our intention is.
Bug: skia:
Change-Id: I8ddeccc602154c793d8f7d7de087a655a136dc9c
Reviewed-on: https://skia-review.googlesource.com/c/160620
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index ddefb79..717aa7a 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -240,9 +240,10 @@
bool canDiscardOutsideDstRect = false);
// Returns a GrGpuRTCommandBuffer which GrOpLists send draw commands to instead of directly
- // to the Gpu object.
+ // to the Gpu object. The passed in bounds is the content rect of the destination.
virtual GrGpuRTCommandBuffer* getCommandBuffer(
GrRenderTarget*, GrSurfaceOrigin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) = 0;
diff --git a/src/gpu/GrRenderTargetOpList.cpp b/src/gpu/GrRenderTargetOpList.cpp
index 6ca4936..6e465e3 100644
--- a/src/gpu/GrRenderTargetOpList.cpp
+++ b/src/gpu/GrRenderTargetOpList.cpp
@@ -118,6 +118,7 @@
static GrGpuRTCommandBuffer* create_command_buffer(GrGpu* gpu,
GrRenderTarget* rt,
GrSurfaceOrigin origin,
+ const SkRect& bounds,
GrLoadOp colorLoadOp,
GrColor loadClearColor,
GrLoadOp stencilLoadOp) {
@@ -137,7 +138,7 @@
GrStoreOp::kStore,
};
- return gpu->getCommandBuffer(rt, origin, kColorLoadStoreInfo, stencilLoadAndStoreInfo);
+ return gpu->getCommandBuffer(rt, origin, bounds, kColorLoadStoreInfo, stencilLoadAndStoreInfo);
}
// TODO: this is where GrOp::renderTarget is used (which is fine since it
@@ -164,6 +165,7 @@
flushState->gpu(),
fTarget.get()->peekRenderTarget(),
fTarget.get()->origin(),
+ fTarget.get()->getBoundsRect(),
fColorLoadOp,
fLoadClearColor,
fStencilLoadOp);
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 3bc7d3a..4fc91b2 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2175,6 +2175,7 @@
GrGpuRTCommandBuffer* GrGLGpu::getCommandBuffer(
GrRenderTarget* rt, GrSurfaceOrigin origin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
if (!fCachedRTCommandBuffer) {
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 4fa1752..aa11689 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -122,6 +122,7 @@
GrGpuRTCommandBuffer* getCommandBuffer(
GrRenderTarget*, GrSurfaceOrigin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override;
diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp
index ac3e5ca..25084a9 100644
--- a/src/gpu/mock/GrMockGpu.cpp
+++ b/src/gpu/mock/GrMockGpu.cpp
@@ -49,6 +49,7 @@
GrGpuRTCommandBuffer* GrMockGpu::getCommandBuffer(
GrRenderTarget* rt, GrSurfaceOrigin origin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) {
return new GrMockGpuRTCommandBuffer(this, rt, origin);
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index 8155e62..3edec15 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -26,6 +26,7 @@
GrGpuRTCommandBuffer* getCommandBuffer(
GrRenderTarget*, GrSurfaceOrigin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override;
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index 1a58a08..174393d 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -87,6 +87,7 @@
GrGpuRTCommandBuffer* getCommandBuffer(
GrRenderTarget*, GrSurfaceOrigin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override;
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index a2c1f0f..36e834b 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -107,6 +107,7 @@
GrGpuRTCommandBuffer* GrMtlGpu::getCommandBuffer(
GrRenderTarget* renderTarget, GrSurfaceOrigin origin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
return new GrMtlGpuRTCommandBuffer(this, renderTarget, origin, colorInfo, stencilInfo);
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 3aa8286..0981917 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -282,13 +282,14 @@
GrGpuRTCommandBuffer* GrVkGpu::getCommandBuffer(
GrRenderTarget* rt, GrSurfaceOrigin origin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
if (!fCachedRTCommandBuffer) {
fCachedRTCommandBuffer.reset(new GrVkGpuRTCommandBuffer(this));
}
- fCachedRTCommandBuffer->set(rt, origin, colorInfo, stencilInfo);
+ fCachedRTCommandBuffer->set(rt, origin, bounds, colorInfo, stencilInfo);
return fCachedRTCommandBuffer.get();
}
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 80645a3..3be9622 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -93,6 +93,7 @@
GrGpuRTCommandBuffer* getCommandBuffer(
GrRenderTarget*, GrSurfaceOrigin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) override;
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
index 5b484f0..8eb1665 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp
@@ -105,7 +105,7 @@
cbInfo.fColorClearValue.color.float32[3] = fClearColor.fRGBA[3];
if (VK_ATTACHMENT_LOAD_OP_CLEAR == fVkColorLoadOp) {
- cbInfo.fBounds = SkRect::MakeWH(vkRT->width(), vkRT->height());
+ cbInfo.fBounds = fRTBounds;
} else {
cbInfo.fBounds.setEmpty();
}
@@ -176,12 +176,10 @@
// TODO: Once we improve our tracking of discards so that we never end up flushing a discard
// call with no actually ops, remove this.
if (cbInfo.fIsEmpty && cbInfo.fLoadStoreState == LoadStoreState::kStartsWithDiscard) {
- cbInfo.fBounds = SkRect::MakeWH(vkRT->width(), vkRT->height());
+ cbInfo.fBounds = fRTBounds;;
}
- if (cbInfo.fBounds.intersect(0, 0,
- SkIntToScalar(fRenderTarget->width()),
- SkIntToScalar(fRenderTarget->height()))) {
+ if (cbInfo.fBounds.intersect(0, 0, fRTBounds.width(), fRTBounds.height())) {
// Make sure we do the following layout changes after all copies, uploads, or any other
// pre-work is done since we may change the layouts in the pre-work. Also since the
// draws will be submitted in different render passes, we need to guard againts write
@@ -224,6 +222,7 @@
}
void GrVkGpuRTCommandBuffer::set(GrRenderTarget* rt, GrSurfaceOrigin origin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo& colorInfo,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo& stencilInfo) {
SkASSERT(!fRenderTarget);
@@ -234,6 +233,8 @@
this->INHERITED::set(rt, origin);
+ fRTBounds = bounds;
+
fClearColor = GrColor4f::FromGrColor(colorInfo.fClearColor);
get_vk_load_store_ops(colorInfo.fLoadOp, colorInfo.fStoreOp,
@@ -326,7 +327,7 @@
// Flip rect if necessary
SkIRect vkRect;
if (!clip.scissorEnabled()) {
- vkRect.setXYWH(0, 0, fRenderTarget->width(), fRenderTarget->height());
+ vkRect.setXYWH(0, 0, fRTBounds.width(), fRTBounds.height());
} else if (kBottomLeft_GrSurfaceOrigin != fOrigin) {
vkRect = clip.scissorRect();
} else {
@@ -411,7 +412,7 @@
// Flip rect if necessary
SkIRect vkRect;
if (!clip.scissorEnabled()) {
- vkRect.setXYWH(0, 0, fRenderTarget->width(), fRenderTarget->height());
+ vkRect.setXYWH(0, 0, fRTBounds.width(), fRTBounds.height());
} else if (kBottomLeft_GrSurfaceOrigin != fOrigin) {
vkRect = clip.scissorRect();
} else {
@@ -627,7 +628,8 @@
if (!pipeline.isScissorEnabled()) {
GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(),
rt, pipeline.proxy()->origin(),
- SkIRect::MakeWH(rt->width(), rt->height()));
+ SkIRect::MakeWH(fRTBounds.width(),
+ fRTBounds.height()));
} else if (!dynamicStateArrays || !dynamicStateArrays->fScissorRects) {
SkASSERT(fixedDynamicState);
GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(), rt,
diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.h b/src/gpu/vk/GrVkGpuCommandBuffer.h
index c00e4ae..e698845 100644
--- a/src/gpu/vk/GrVkGpuCommandBuffer.h
+++ b/src/gpu/vk/GrVkGpuCommandBuffer.h
@@ -75,6 +75,7 @@
const SkIPoint& dstPoint) override;
void set(GrRenderTarget*, GrSurfaceOrigin,
+ const SkRect& bounds,
const GrGpuRTCommandBuffer::LoadAndStoreInfo&,
const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&);
void reset();
@@ -201,6 +202,9 @@
VkAttachmentStoreOp fVkStencilStoreOp;
GrColor4f fClearColor;
GrVkPipelineState* fLastPipelineState;
+ // We store the bounds of the render target proxy so we can use that for any "full screen"
+ // clears or discards instead of the the GrSurface which may be bigger.
+ SkRect fRTBounds;
typedef GrGpuRTCommandBuffer INHERITED;
};