aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-07-07 11:58:35 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-07 11:58:35 -0700
commit27bb28473912181cf9a838e9282e86cb62e2d44b (patch)
tree9bc0a4f062cb2a6f09e678b72aa3f1af999108b8 /src/gpu/vk
parentdb37909347d034943bd6b0922710a94c6c6ea572 (diff)
Check granularity in render pass bounds
Diffstat (limited to 'src/gpu/vk')
-rw-r--r--src/gpu/vk/GrVkGpu.cpp45
-rw-r--r--src/gpu/vk/GrVkRenderPass.cpp5
-rw-r--r--src/gpu/vk/GrVkRenderPass.h3
3 files changed, 53 insertions, 0 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index fcbe6eeb58..b995ed91aa 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1497,6 +1497,40 @@ bool GrVkGpu::onReadPixels(GrSurface* surface,
return true;
}
+// The RenderArea bounds we pass into BeginRenderPass must have a start x value that is a multiple
+// of the granularity. The width must also be a multiple of the granularity or eaqual to the width
+// the the entire attachment. Similar requirements for the y and height components.
+void adjust_bounds_to_granularity(SkIRect* dstBounds, const SkIRect& srcBounds,
+ const VkExtent2D& granularity, int maxWidth, int maxHeight) {
+ // Adjust Width
+ // Start with the right side of rect so we know if we end up going pass the maxWidth.
+ int rightAdj = srcBounds.fRight % granularity.width;
+ if (rightAdj != 0) {
+ rightAdj = granularity.width - rightAdj;
+ }
+ dstBounds->fRight = srcBounds.fRight + rightAdj;
+ if (dstBounds->fRight > maxWidth) {
+ dstBounds->fRight = maxWidth;
+ dstBounds->fLeft = 0;
+ } else {
+ dstBounds->fLeft = srcBounds.fLeft - srcBounds.fLeft % granularity.width;
+ }
+
+ // Adjust height
+ // Start with the bottom side of rect so we know if we end up going pass the maxHeight.
+ int bottomAdj = srcBounds.fBottom % granularity.height;
+ if (bottomAdj != 0) {
+ bottomAdj = granularity.height - bottomAdj;
+ }
+ dstBounds->fBottom = srcBounds.fBottom + bottomAdj;
+ if (dstBounds->fBottom > maxHeight) {
+ dstBounds->fBottom = maxHeight;
+ dstBounds->fTop = 0;
+ } else {
+ dstBounds->fTop = srcBounds.fTop - srcBounds.fTop % granularity.height;
+ }
+}
+
void GrVkGpu::submitSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer,
const GrVkRenderPass* renderPass,
const VkClearValue* colorClear,
@@ -1511,6 +1545,17 @@ void GrVkGpu::submitSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer,
pBounds = &flippedBounds;
}
+ // The bounds we use for the render pass should be of the granularity supported
+ // by the device.
+ const VkExtent2D& granularity = renderPass->granularity();
+ SkIRect adjustedBounds;
+ if ((0 != granularity.width && 1 != granularity.width) ||
+ (0 != granularity.height && 1 != granularity.height)) {
+ adjust_bounds_to_granularity(&adjustedBounds, *pBounds, granularity,
+ target->width(), target->height());
+ pBounds = &adjustedBounds;
+ }
+
// Currently it is fine for us to always pass in 1 for the clear count even if no attachment
// uses it. In the current state, we also only use the LOAD_OP_CLEAR for the color attachment
// which is always at the first attachment.
diff --git a/src/gpu/vk/GrVkRenderPass.cpp b/src/gpu/vk/GrVkRenderPass.cpp
index a49393800f..ba325ef5a6 100644
--- a/src/gpu/vk/GrVkRenderPass.cpp
+++ b/src/gpu/vk/GrVkRenderPass.cpp
@@ -145,6 +145,11 @@ void GrVkRenderPass::init(const GrVkGpu* gpu,
&createInfo,
nullptr,
&fRenderPass));
+
+ // Get granularity for this render pass
+ GR_VK_CALL(gpu->vkInterface(), GetRenderAreaGranularity(gpu->device(),
+ fRenderPass,
+ &fGranularity));
}
void GrVkRenderPass::init(const GrVkGpu* gpu,
diff --git a/src/gpu/vk/GrVkRenderPass.h b/src/gpu/vk/GrVkRenderPass.h
index 5438a10dfc..21146ab129 100644
--- a/src/gpu/vk/GrVkRenderPass.h
+++ b/src/gpu/vk/GrVkRenderPass.h
@@ -118,6 +118,8 @@ public:
VkRenderPass vkRenderPass() const { return fRenderPass; }
+ const VkExtent2D& granularity() const { return fGranularity; }
+
void genKey(GrProcessorKeyBuilder* b) const;
#ifdef SK_TRACE_VK_RESOURCES
@@ -141,6 +143,7 @@ private:
VkRenderPass fRenderPass;
AttachmentFlags fAttachmentFlags;
AttachmentsDescriptor fAttachmentsDescriptor;
+ VkExtent2D fGranularity;
typedef GrVkResource INHERITED;
};