From d263d752ac356f610e59dc453f5607fbd887fbfa Mon Sep 17 00:00:00 2001 From: Li Hao Date: Fri, 15 Mar 2019 01:37:21 +0000 Subject: [PATCH] Fix scissor rect larger than render pass width/height in Metal backend BUG=dawn:116 TEST=dawn_end2end_tests Change-Id: I3e36e19d20b271ba58652bcaea973f3999e9e7ac Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/5560 Reviewed-by: Kai Ninomiya Reviewed-by: Corentin Wallez Commit-Queue: Hao Li --- src/dawn_native/metal/CommandBufferMTL.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm index bb76ca24a6..a15adcbcf3 100644 --- a/src/dawn_native/metal/CommandBufferMTL.mm +++ b/src/dawn_native/metal/CommandBufferMTL.mm @@ -667,6 +667,15 @@ namespace dawn_native { namespace metal { rect.width = cmd->width; rect.height = cmd->height; + // The scissor rect x + width must be <= render pass width + if ((rect.x + rect.width) > renderPassCmd->width) { + rect.width = renderPassCmd->width - rect.x; + } + // The scissor rect y + height must be <= render pass height + if ((rect.y + rect.height > renderPassCmd->height)) { + rect.height = renderPassCmd->height - rect.y; + } + [encoder setScissorRect:rect]; } break;