[Refactor] (P13 W5 S7): Magma's wire-object collection, wire-store teardown, depth-resolve entry point and the fast-rebind destroy epoch follow the record-arm guard.

This commit is contained in:
2026-10-06 13:57:26 -04:00
parent e9a353c324
commit 1cd35d3922
4 changed files with 21 additions and 8 deletions
@@ -3244,7 +3244,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
(samplerBindingOverrides == nullptr || samplerBindingOverrides->empty());
if (cacheable && samplerDescriptorsUnchangedHint && m_fastRebindMemo.valid &&
m_fastRebindMemo.frameIndex == frameIndex &&
#if MOBILEGL_BUILD_DISAGGREGATED
#if MOBILEGL_BUILD_RECORD_ARM
// 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.
@@ -3546,7 +3546,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
}
};
mixWords(&programObj.descriptorSetLayout, sizeof(programObj.descriptorSetLayout));
#if MOBILEGL_BUILD_DISAGGREGATED
#if MOBILEGL_BUILD_RECORD_ARM
// 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
@@ -3611,7 +3611,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
/*valid=*/true, frameIndex, program.GetLifetimeId(), programObj.hash,
fastRebindUboBinding, bufferInfos[0].buffer,
bufferInfos[0].range, descriptorSet,
#if MOBILEGL_BUILD_DISAGGREGATED
#if MOBILEGL_BUILD_RECORD_ARM
m_bufferManager->GetWireStoreDestroyEpoch(),
#endif
};
@@ -1236,7 +1236,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
void VkBufferManager::Shutdown() {
if (g_activeBufferManager.Get() == this) {
g_activeBufferManager.Get() = nullptr;
#if MOBILEGL_BUILD_DISAGGREGATED
#if MOBILEGL_BUILD_RECORD_ARM
// Under a transport the table is the PROCESS's and serves every session: it dispatches
// to the calling session's own manager (WireManager), so one session's renderer going
// away must not take it from the others - their buffer creates would be dropped from
@@ -1255,7 +1255,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
m_unboundTexelBuffer.Destroy();
DestroyAllDeferredReleases();
ReleaseAllLiveResources();
#if MOBILEGL_BUILD_DISAGGREGATED
#if MOBILEGL_BUILD_RECORD_ARM
// DestroyAllDeferredReleases above emptied the parked list; this destroys the stores the
// records still hold, so nothing this arm minted outlives the count.
if (!m_wireBuffers.empty()) ++m_wireStoreDestroyEpoch;
@@ -3506,7 +3506,7 @@ void main() {
// Parked surface targets (ActivateSurfaceTarget) go before the device and instance.
for (auto& [_, target] : m_parkedTargets) DestroyParkedTarget(target);
m_parkedTargets.clear();
#if MOBILEGL_BUILD_DISAGGREGATED
#if MOBILEGL_BUILD_RECORD_ARM
// P7 wave 2 package B3: the session's decline tally. Silent when nothing declined, so a
// green lane stays quiet and a lane that dropped a draw cannot (rule I's observable).
WireDeclineTally::Dump("shutdown");
@@ -3518,11 +3518,15 @@ void main() {
CollectWireObjects(m_submitCounter, true);
ClearAllWireDrawPassCaches();
DestroyWireColorBlitResources();
#if MOBILEGL_BUILD_DISAGGREGATED
DestroyWireYuvResources();
#endif
DestroyWireDepthMipmapResources();
DestroyWireMultisampleResolveResources();
#if MOBILEGL_BUILD_DISAGGREGATED
DestroySharedImagePresentTargets(false);
DestroySharedImageSync();
#endif
#endif
OnSubmitsCompletedUpTo(m_submitCounter);
DestroySubmitFencePool();
@@ -13843,8 +13847,10 @@ void main() {
// Mid-frame-flushed command buffers whose submission just completed can
// be freed now; present-less flush loops have no other reclaim point.
m_frameContext.FreeRetiredCommandBuffersCompletedUpTo(m_completedSubmitCounter);
#if MOBILEGL_BUILD_DISAGGREGATED
#if MOBILEGL_BUILD_RECORD_ARM
CollectWireObjects(m_completedSubmitCounter);
#endif
#if MOBILEGL_BUILD_DISAGGREGATED
RecycleSharedImageSemaphores(m_completedSubmitCounter);
#endif
}
@@ -16030,11 +16036,13 @@ void main() {
m_shaderDrawParametersFeatureEnabled ? "true" : "false");
VK_VERIFY(vkCreateDevice(m_physicalDevice.handle, &deviceCreateInfo, nullptr, &m_device), "vkCreateDevice");
#if MOBILEGL_BUILD_DISAGGREGATED
#if MOBILEGL_BUILD_RECORD_ARM
if (wireDepthResolveEnabled) {
m_wireCreateRenderPass2 = reinterpret_cast<PFN_vkCreateRenderPass2>(
vkGetDeviceProcAddr(m_device, wireDepthResolveCore ? "vkCreateRenderPass2" : "vkCreateRenderPass2KHR"));
}
#endif
#if MOBILEGL_BUILD_DISAGGREGATED
if (m_wireAhbImport) {
m_wireGetAhbProperties =
reinterpret_cast<void*>(vkGetDeviceProcAddr(m_device, "vkGetAndroidHardwareBufferPropertiesANDROID"));