From 481f2cea17e5862c2f27934c6cb8d4ef1c134191 Mon Sep 17 00:00:00 2001 From: Kian <92978255+MERL10N@users.noreply.github.com> Date: Mon, 6 Jul 2026 18:13:19 -0700 Subject: [PATCH] Backends: Metal4: added ImTextureID tex_id to residency set. (#9461, #9458, #9451) This will resolve runtime errors identified by XCode's Metal Shader Validator. --- backends/imgui_impl_metal4.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backends/imgui_impl_metal4.mm b/backends/imgui_impl_metal4.mm index d2d172a57..2866ed1e2 100644 --- a/backends/imgui_impl_metal4.mm +++ b/backends/imgui_impl_metal4.mm @@ -239,9 +239,6 @@ void ImGui_ImplMetal4_RenderDrawData(ImDrawData* draw_data, idDisplayPos; // (0,0) unless using multi-viewports ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2) - // Before rendering command lists, commit residency set - [bd->SharedMetalContext.residencySet commit]; - // Render command lists size_t vertexBufferOffset = 0; size_t indexBufferOffset = 0; @@ -292,6 +289,7 @@ void ImGui_ImplMetal4_RenderDrawData(ImDrawData* draw_data, id texture = (__bridge id)(void*)(intptr_t)tex_id; + [bd->SharedMetalContext.residencySet addAllocation:texture]; [bd->SharedMetalContext.argumentTable setTexture:texture.gpuResourceID atIndex:0]; } @@ -317,6 +315,9 @@ void ImGui_ImplMetal4_RenderDrawData(ImDrawData* draw_data, idSharedMetalContext.residencySet commit]; bd->RenderCommandEncoder = nil; }