mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-16 22:43:24 +09:00
[MG_Backend] (P7): the descriptor memos fold in a wire-store destroy epoch, so a VkBuffer handle the mid-frame reclaim freed and the next mint handed back cannot revive a set baked to the dead store
- M2's defer path destroys a wire store MID-FRAME (the serial-0 park, the sweep's prefix walk, the watermark); before it a wire store only died at the boundary that also clears UniformManager's memos (BeginFrame from Present or a drain). Those memos are keyed on the VkBuffer HANDLE - m_descriptorReuseMemo hashes the VkDescriptorBufferInfo words, FastRebindMemo compares uboBuffer - and on the wire arm the direct-bind UBO and the SSBO descriptor name the store's own handle. A store destroyed at a park, its handle value re-minted by the next Create (a heap pointer under lavapipe, LIFO out of glibc's tcache), and a draw resolving the same (handle, range) reused a set whose descriptor still pointed at the dead store's memory: silent wrong bytes, no Fatal (ID-P7-43, the fable review's must-fix).
- VkBufferManager gains m_wireStoreDestroyEpoch, bumped on every path that destroys a wire store's VkBuffer (DeferWireRelease's immediate destroy, SweepDeferredWireReleases once per sweep that freed anything, DestroyAllDeferredWireReleases, Shutdown's record teardown) and never reset, with GetWireStoreDestroyEpoch(). UniformManager mixes it into the descriptor-reuse signature and records it in FastRebindMemo, refusing the fast rebind when it moved; all under MOBILEGL_BUILD_DISAGGREGATED. Deliberately not m_sliceEpochCounter, which every WriteWireBuffer bumps and would defeat the memo on every glBufferSubData. On the wire arm only the signature is reached (SetupWireDraw passes no sampler hint), the FastRebindMemo field is the defensive half.
- Two comments from the same review: SweepDeferredWireReleases no longer claims GetSyncPointSubmitIndex() never decreases - it steps back by one across an abandoned recording (RecreateSwapchain, the minimized Present), and the prefix walk is conservative across that, not wrong; and the header's "floor is not a proof" keeps its decision on its first reason alone, the second was a stale citation of a fix that is on the integration tree.
- Section 9 partition exception for UniformManager.{h,cpp} granted by the integrator for this fix.
This commit is contained in:
@@ -3027,6 +3027,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
(samplerBindingOverrides == nullptr || samplerBindingOverrides->empty());
|
||||
if (cacheable && samplerDescriptorsUnchangedHint && m_fastRebindMemo.valid &&
|
||||
m_fastRebindMemo.frameIndex == frameIndex &&
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// A wire store destroyed since the memo was taken may have handed its handle
|
||||
// value to a later mint (see FastRebindMemo): "same VkBuffer" then names a
|
||||
// different store, so the memo is refused and the full walk re-records it.
|
||||
m_fastRebindMemo.wireStoreDestroyEpoch == m_bufferManager->GetWireStoreDestroyEpoch() &&
|
||||
#endif
|
||||
m_fastRebindMemo.programLifetimeId == program.GetLifetimeId() &&
|
||||
m_fastRebindMemo.programHash == programObj.hash) {
|
||||
VkBuffer uboBuffer = VK_NULL_HANDLE;
|
||||
@@ -3323,6 +3329,16 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
}
|
||||
};
|
||||
mixWords(&programObj.descriptorSetLayout, sizeof(programObj.descriptorSetLayout));
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
// P7 M2 round 2 (ID-P7-43): the buffer infos below name WIRE stores by VkBuffer
|
||||
// handle, and a wire store can be destroyed mid-frame (VkBufferManager::
|
||||
// DeferredWireRelease) with its handle value re-minted before this frame's memo
|
||||
// is cleared. Folding the destroy epoch in makes every entry taken before such a
|
||||
// destroy miss, so a byte-identical info can never revive a set baked to a dead
|
||||
// store. NOT the slice epoch: that moves on every glBufferSubData and would make
|
||||
// the memo miss on every draw.
|
||||
mix64(m_bufferManager->GetWireStoreDestroyEpoch());
|
||||
#endif
|
||||
for (const auto& write : writes) {
|
||||
mix64((static_cast<Uint64>(write.dstBinding) << 40) ^
|
||||
(static_cast<Uint64>(write.descriptorType) << 8) ^
|
||||
@@ -3377,7 +3393,11 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
m_fastRebindMemo = FastRebindMemo{
|
||||
/*valid=*/true, frameIndex, program.GetLifetimeId(), programObj.hash,
|
||||
fastRebindUboBinding, bufferInfos[0].buffer,
|
||||
bufferInfos[0].range, descriptorSet};
|
||||
bufferInfos[0].range, descriptorSet,
|
||||
#if MOBILEGL_BUILD_DISAGGREGATED
|
||||
m_bufferManager->GetWireStoreDestroyEpoch(),
|
||||
#endif
|
||||
};
|
||||
} else {
|
||||
m_fastRebindMemo.valid = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user