diff --git a/src/gpu/ganesh/ops/OpsTask.cpp b/src/gpu/ganesh/ops/OpsTask.cpp --- a/src/gpu/ganesh/ops/OpsTask.cpp +++ b/src/gpu/ganesh/ops/OpsTask.cpp @@ -644,8 +644,15 @@ bool OpsTask::onExecute(GrOpFlushState* flushState) { if (!renderPass) { return false; } - if (markStencilCleared) { - stencil->markHasPerformedInitialClear(); + if (markStencilCleared && + fClippedContentBounds.contains(SkIRect::MakeSize(stencil->dimensions()))) { + // VK_ATTACHMENT_LOAD_OP_CLEAR is renderArea-scoped (Vulkan spec + // §8.1). fClippedContentBounds is the union of op bounds, NOT the full + // attachment, so a sub-rect kClear must not latch the attachment- + // global flag — otherwise a later same-dim render target falls through + // to kLoad over never-initialised stencil VRAM and the Redbook cover + // pass exposes it to getImageData() (CWE-908). + stencil->markHasPerformedInitialClear(); } flushState->setOpsRenderPass(renderPass); renderPass->begin();