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;