diff --git a/src/libANGLE/renderer/gl/FramebufferGL.cpp b/src/libANGLE/renderer/gl/FramebufferGL.cpp index 55d1527378..75d314cf15 100644 --- a/src/libANGLE/renderer/gl/FramebufferGL.cpp +++ b/src/libANGLE/renderer/gl/FramebufferGL.cpp @@ -490,6 +490,17 @@ angle::Result FramebufferGL::invalidate(const gl::Context *context, size_t count, const GLenum *attachments) { + // SECURITY: When robust resource initialisation is enabled, the application + // must never observe uninitialised GPU memory. Native glInvalidateFramebuffer + // on TBDR drivers (Mali/Adreno/PowerVR) discards pending tile flushes, and + // the libANGLE frontend does not re-set mResourceNeedsInit after invalidate. + // Treat invalidate as a no-op under robust init (matching the WebGL2 spec + // recommendation). + if (context->isRobustResourceInitEnabled()) + { + return angle::Result::Continue; + } + const GLenum *finalAttachmentsPtr = attachments; std::vector modifiedAttachments; @@ -523,6 +534,11 @@ angle::Result FramebufferGL::invalidateSub(const gl::Context *context, const GLenum *attachments, const gl::Rectangle &area) { + // SECURITY: see invalidate() above. + if (context->isRobustResourceInitEnabled()) + { + return angle::Result::Continue; + } const GLenum *finalAttachmentsPtr = attachments; diff --git a/src/libANGLE/renderer/metal/FrameBufferMtl.mm b/src/libANGLE/renderer/metal/FrameBufferMtl.mm index 7a24908e2b..b67b5a9c0f 100644 --- a/src/libANGLE/renderer/metal/FrameBufferMtl.mm +++ b/src/libANGLE/renderer/metal/FrameBufferMtl.mm @@ -1421,6 +1421,17 @@ angle::Result FramebufferMtl::invalidateImpl(const gl::Context *context, size_t count, const GLenum *attachments) { + // SECURITY: When robust resource initialisation is enabled, the application + // must never observe uninitialised GPU memory. MTLStoreActionDontCare / + // MTLLoadActionDontCare on TBDR hardware leave tile/heap residue in the + // attachment, and the libANGLE frontend does not re-set mResourceNeedsInit + // after invalidate. Until the frontend tracks this, treat invalidate as a + // no-op under robust init (matching the WebGL2 spec recommendation). + if (context->isRobustResourceInitEnabled()) + { + return angle::Result::Continue; + } + ContextMtl *contextMtl = mtl::GetImpl(context); gl::DrawBufferMask invalidateColorBuffers; bool invalidateDepthBuffer = false;