diff --git a/third_party/angle/src/libANGLE/renderer/metal/mtl_state_cache.mm b/third_party/angle/src/libANGLE/renderer/metal/mtl_state_cache.mm --- a/third_party/angle/src/libANGLE/renderer/metal/mtl_state_cache.mm +++ b/third_party/angle/src/libANGLE/renderer/metal/mtl_state_cache.mm @@ -867,12 +867,21 @@ void RenderPassDesc::convertToMetalDesc(MTLRenderPassDescriptor *objCDesc, ToObjC(depthAttachment, objCDesc.depthAttachment); ToObjC(stencilAttachment, objCDesc.stencilAttachment); + // objCDesc is the long-lived mCachedRenderPassDescObjC owned by the + // RenderCommandEncoder (allocated once in its constructor, reused for the + // lifetime of the ContextMtl). These properties must be reset on every + // call, otherwise a value latched by a previous no-attachment render pass + // persists into a later pass that has a small attachment, violating the + // Metal requirement that renderTargetWidth <= smallest attachment width. if ((defaultWidth | defaultHeight) != 0) { objCDesc.renderTargetWidth = defaultWidth; objCDesc.renderTargetHeight = defaultHeight; objCDesc.defaultRasterSampleCount = 1; } + else + { + objCDesc.renderTargetWidth = 0; + objCDesc.renderTargetHeight = 0; + objCDesc.defaultRasterSampleCount = 0; + } } diff --git a/third_party/angle/src/libANGLE/renderer/metal/FrameBufferMtl.mm b/third_party/angle/src/libANGLE/renderer/metal/FrameBufferMtl.mm --- a/third_party/angle/src/libANGLE/renderer/metal/FrameBufferMtl.mm +++ b/third_party/angle/src/libANGLE/renderer/metal/FrameBufferMtl.mm @@ -1068,8 +1068,12 @@ angle::Result FramebufferMtl::prepareRenderPass(const gl::Context *context, mRenderPassFirstColorAttachmentFormat = nullptr; mRenderPassAttachmentsSameColorType = true; uint32_t maxColorAttachments = static_cast(mState.getColorAttachments().size()); + // mRenderPassDesc is a persistent member of FramebufferMtl. defaultWidth/ + // defaultHeight must be reset alongside numColorAttachments and + // rasterSampleCount, otherwise a no-attachment pass leaves them set and a + // subsequent pass on the same FBO with a small attachment inherits them. desc.numColorAttachments = 0; desc.rasterSampleCount = 1; + desc.defaultWidth = 0; + desc.defaultHeight = 0; for (uint32_t colorIndexGL = 0; colorIndexGL < maxColorAttachments; ++colorIndexGL) {