[MG_Backend, MG_IntegrationTest] (P7): the default draw framebuffer is asked the multisample depth/stencil shape question before any aspect runs, so a scaled COLOR|DEPTH resolve onto the window writes nothing

- BlitWireFramebuffers' round-2 pre-pass left a default DRAW framebuffer to the per-aspect lambdas on the belief that a default draw behind a multisample read was ResolveWireDepthStencil's region Fatal whatever the shape. It is not: that arm calls DeclineWireDepthStencilResolveShape BEFORE its destination.isDefault region check, so a scaled (or X-mirrored) COLOR|DEPTH blit out of a multisample framebuffer onto the window ran the colour lambda first (BlitWireColorToDefault wrote the swapchain image) and then recorded INVALID_OPERATION on its depth - the partial effect magma-b2.md §2.9 item 3 declared closed.
- The guard drops !draw->IsDefault, and the pre-pass resolves both sides as READS (isWriteTarget=false): only their format and samples are consulted, and DefaultFramebufferReadIndex is const, so nothing re-points the default framebuffer at the acquired image before a write.
- The flipped-resolve case gains a leg: the window is primed blue at depth 0.5, the multisample source (red below, green above) is blown up over the whole of it with COLOR|DEPTH, the call must be INVALID_OPERATION, and three probes (corner, centre, far corner) must read the priming on both aspects through glReadPixels - the only way the harness's pbuffer default framebuffer can be looked at.
- Red-once (split + spawn, restored): the round-2 guard (&& !draw->IsDefault) put back -> DirectVulkan.{Split,Spawn}.MsFlip. fail "the declined COLOR|DEPTH scale onto the window must not have written its colour at (1, 1)" reading {255,0,0,255} (the source's bottom band), and {0,255,0,255} at (64, 48) and (126, 94), for {0,0,255,255}; the INVALID_OPERATION assertion still held, which is the partial effect exactly.
- Verified: the 107 multisample blit/resolve and depth/stencil readback entries on the three wire arms (MsFlip/MsFlip1/MsBlit/MsResolve0/1, Full x3 for both readback scenarios) and the monolith DirectVulkan.DepthStencilReadback* entries pass, pre-existing skips unchanged.
This commit is contained in:
2026-09-22 21:36:08 -04:00
parent 6f1c6d26ee
commit 24da1e0f6d
2 changed files with 66 additions and 6 deletions
@@ -819,16 +819,23 @@
// images, so it is asked here, before any aspect runs, for every depth/stencil aspect
// the mask names that would take the multisample resolve arm.
//
// A default READ framebuffer is never multisampled here, and a default DRAW one behind a
// multisample read is ResolveWireDepthStencil's region Fatal whatever the shape - and
// resolving the default draw image early would move its write index - so both are left
// to the lambda.
if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) && !read->IsDefault && !draw->IsDefault) {
// A default READ framebuffer is never multisampled here, so it is left to the lambda. A
// default DRAW framebuffer is asked like any other (review round 3): round 2 left it out
// on the belief that a default draw behind a multisample read was ResolveWireDepthStencil's
// region Fatal whatever the shape, but that arm asks DeclineWireDepthStencilResolveShape
// BEFORE its region check - so a scaled (or X-mirrored) COLOR|DEPTH blit out of a
// multisample framebuffer onto the window scaled and wrote its colour through
// BlitWireColorToDefault and then recorded INVALID_OPERATION on its depth, the very
// partial effect this block exists to close. Both sides are resolved as READS
// (isWriteTarget=false): only their format and samples are consulted here, and a write
// resolve of the default framebuffer would re-point it at the acquired swapchain image
// before anything had been written to it.
if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) && !read->IsDefault) {
const auto declines = [&](const MG_Pipe::MGPSurface& src, const MG_Pipe::MGPSurface& dst,
VkImageAspectFlags aspect) -> Bool {
const WireImage source = ResolveWireImage(*read, src, aspect, /*isWriteTarget=*/false);
if (!source.image || source.samples == VK_SAMPLE_COUNT_1_BIT) return false;
const WireImage destination = ResolveWireImage(*draw, dst, aspect, /*isWriteTarget=*/true);
const WireImage destination = ResolveWireImage(*draw, dst, aspect, /*isWriteTarget=*/false);
if (!destination.image || destination.samples != VK_SAMPLE_COUNT_1_BIT) return false;
return DeclineWireDepthStencilResolveShape(source, destination, sx0, sy0, sx1, sy1,
dx0, dy0, dx1, dy1);