From 858ea17eba47e17c7a2e4acb5a5678320d7b1290 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 15 Apr 2021 13:29:42 +0200 Subject: [PATCH] Backends: DirectX10, DirectX11: fixed a crash when backing/restoring state if nothing is bound when entering the rendering function. (#4045) --- backends/imgui_impl_dx10.cpp | 2 +- backends/imgui_impl_dx11.cpp | 2 +- docs/CHANGELOG.txt | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backends/imgui_impl_dx10.cpp b/backends/imgui_impl_dx10.cpp index 288427553..33be9389a 100644 --- a/backends/imgui_impl_dx10.cpp +++ b/backends/imgui_impl_dx10.cpp @@ -190,7 +190,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data) DXGI_FORMAT IndexBufferFormat; ID3D10InputLayout* InputLayout; }; - BACKUP_DX10_STATE old; + BACKUP_DX10_STATE old = {}; old.ScissorRectsCount = old.ViewportsCount = D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ctx->RSGetScissorRects(&old.ScissorRectsCount, old.ScissorRects); ctx->RSGetViewports(&old.ViewportsCount, old.Viewports); diff --git a/backends/imgui_impl_dx11.cpp b/backends/imgui_impl_dx11.cpp index f114cdc15..0690b97bf 100644 --- a/backends/imgui_impl_dx11.cpp +++ b/backends/imgui_impl_dx11.cpp @@ -198,7 +198,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data) DXGI_FORMAT IndexBufferFormat; ID3D11InputLayout* InputLayout; }; - BACKUP_DX11_STATE old; + BACKUP_DX11_STATE old = {}; old.ScissorRectsCount = old.ViewportsCount = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; ctx->RSGetScissorRects(&old.ScissorRectsCount, old.ScissorRects); ctx->RSGetViewports(&old.ViewportsCount, old.Viewports); diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 564c8a353..bcfa40f98 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -60,6 +60,8 @@ Other Changes: [@1025798851] - Backends: DirectX9: calling IDirect3DStateBlock9::Capture() after CreateStateBlock() which appears to workaround/fix state restoring issues. Unknown exactly why so, but bit of a cargo-cult fix. (#3857) +- Backends: DirectX10, DirectX11: fixed a crash when backing/restoring state if nothing is bound when + entering the rendering function. (#4045) [@Nemirtingas] - Backends: Vulkan: Fix mapped memory Vulkan validation error when buffer sizes are not multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize. (#3957) [@AgentX1994] - Backends: OpenGL3: Don't try to read GL_CLIP_ORIGIN unless we're OpenGL 4.5. (#3998, #2366, #2186) [@s7jones]