[Fix, Test] (MG_State, MG_Backend, MG_Impl, MG_Test): review wave - hand the mapping back instead of renewing it, retire an immutable ES store on respecify, and tag glTexStorage2D levels too

This commit is contained in:
2026-08-12 10:32:39 -04:00
parent 7ccb762936
commit 1b05a84928
9 changed files with 474 additions and 62 deletions
@@ -379,23 +379,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
BumpSliceEpoch(*resource);
// Any cached streaming slice refers to the previous contents.
resource->transientFrameSerial = 0;
if (resource->persistentMapped) {
if (bufferObject.IsBackendPersistentMapped()) {
// The frontend renewed its adoption of this storage for the redefined
// store before writing a byte of it (BufferObject::RedefineStorage), so
// the new contents are already HERE and there is no second copy to
// update. Swapping the storage is what must not happen: the mapping the
// frontend holds, and every read that resolves through it, would keep
// addressing the storage being released - which is how a transform
// feedback capture came to be written to one buffer and read back out
// of another.
return;
}
// The renewal did not happen (a zero-sized store, or the storage could not
// be created): the frontend is back on its CPU shadow, so this is an
// ordinary resident buffer again and the handling below applies.
resource->persistentMapped = false;
}
// Redefining the store hands any adopted mapping back to the CPU shadow
// (BufferObject::RedefineStorage), so a buffer that reaches here persistent-mapped
// is an ordinary resident one again: it needs the busy-tracking and conditional
// orphan below, and the next AcquirePersistentMap has to mint storage for the new
// store rather than hand back a mapping of the old one.
resource->persistentMapped = false;
if (!resource->buffer.IsValid()) {
return; // streaming-only resource: shadow + serial are enough
}