Textures: allowed backend to destroy texture while inside the NewFrame/EndFrame scope. (#8811)

This commit is contained in:
ocornut
2025-10-01 18:38:27 +02:00
parent fc4105c8a8
commit 8c22b8aef6
2 changed files with 10 additions and 4 deletions

View File

@@ -69,9 +69,13 @@ Other Changes:
- Misc: Debuggers: added type formatters for the LLDB debuggers (e.g. Xcode, - Misc: Debuggers: added type formatters for the LLDB debuggers (e.g. Xcode,
Android Studio & more) to provide nicer display for ImVec2, ImVec4, ImVector etc. Android Studio & more) to provide nicer display for ImVec2, ImVec4, ImVector etc.
See misc/debuggers/ for details. (#8950) [@mentlerd] See misc/debuggers/ for details. (#8950) [@mentlerd]
- Textures: fixed a crash if a texture marked as _WantDestroy by a backend after - Textures: fixed a crash if texture status is set to _WantDestroy by a backend after
it had already been destroyed. This would typically happen when calling backend's it had already been destroyed. This would typically happen when calling backend's
ImGui_ImplXXXX_InvalidateDeviceObjects() helpers twice in a row. (#8977, #8811) ImGui_ImplXXXX_InvalidateDeviceObjects() helpers twice in a row. (#8977, #8811)
- Textures: allowed backend to destroy texture while inside the NewFrame/EndFrame
scope. Basically if a backend decide to destroy a texture that we didn't request
to destroy (for e.g. freeing resources) the texture is immediately set to
a _WantCreate status again. (#8811)
- Textures: fixed an issue preventing multi-contexts sharing a ImFontAtlas from - Textures: fixed an issue preventing multi-contexts sharing a ImFontAtlas from
being possible to destroy in any order. being possible to destroy in any order.
- Textures: fixed not updating ImTextureData's RefCount when destroying a context - Textures: fixed not updating ImTextureData's RefCount when destroying a context
@@ -101,7 +105,7 @@ Other Changes:
CustomShaderVertCreateInfo and CustomShaderFragCreateInfo. (#8585, #8271) [@johan0A] CustomShaderVertCreateInfo and CustomShaderFragCreateInfo. (#8585, #8271) [@johan0A]
- Backends: DX9,DX10,DX11,DX12,Metal,Vulkan,WGPU,SDLRenderer2,SDLRenderer3: - Backends: DX9,DX10,DX11,DX12,Metal,Vulkan,WGPU,SDLRenderer2,SDLRenderer3:
ensure that a texture in _WantDestroy state always turn to _Destroyed even ensure that a texture in _WantDestroy state always turn to _Destroyed even
if your underlying graphics data was already destroyed. if your underlying graphics data was already destroyed. (#8977)
- Examples: SDL2+DirectX11: Try WARP software driver if hardware driver is - Examples: SDL2+DirectX11: Try WARP software driver if hardware driver is
not available. (#5924, #5562) not available. (#5924, #5562)
- Examples: SDL3+DirectX11: Added SDL3+DirectX11 example. (#8956, #8957) [@tomaz82] - Examples: SDL3+DirectX11: Added SDL3+DirectX11 example. (#8956, #8957) [@tomaz82]

View File

@@ -3491,8 +3491,10 @@ struct ImTextureData
ImTextureID GetTexID() const { return TexID; } ImTextureID GetTexID() const { return TexID; }
// Called by Renderer backend // Called by Renderer backend
void SetTexID(ImTextureID tex_id) { TexID = tex_id; } // Call after creating or destroying the texture. Never modify TexID directly! // - Call SetTexID() and SetStatus() after honoring texture requests. Never modify TexID and Status directly!
void SetStatus(ImTextureStatus status) { Status = status; } // Call after honoring a request. Never modify Status directly! // - A backend may decide to destroy a texture that we did not request to destroy, which is fine (e.g. freeing resources), but we immediately set the texture back in _WantCreate mode.
void SetTexID(ImTextureID tex_id) { TexID = tex_id; }
void SetStatus(ImTextureStatus status) { Status = status; if (status == ImTextureStatus_Destroyed && !WantDestroyNextFrame) Status = ImTextureStatus_WantCreate; }
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------