From d7bca8124079c986a013b7a5bdeb35ec453b2ead Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 9 Sep 2024 17:27:10 +1000 Subject: [PATCH] D3D12Device: Fix crash when using media capture --- src/util/d3d12_device.cpp | 1 + src/util/d3d12_texture.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/util/d3d12_device.cpp b/src/util/d3d12_device.cpp index fca2bea40..fb72a2ef0 100644 --- a/src/util/d3d12_device.cpp +++ b/src/util/d3d12_device.cpp @@ -556,6 +556,7 @@ ID3D12GraphicsCommandList4* D3D12Device::GetInitCommandList() void D3D12Device::SubmitCommandList(bool wait_for_completion) { + DebugAssert(!InRenderPass()); if (m_device_was_lost) [[unlikely]] return; diff --git a/src/util/d3d12_texture.cpp b/src/util/d3d12_texture.cpp index 44e468c6d..2f2844621 100644 --- a/src/util/d3d12_texture.cpp +++ b/src/util/d3d12_texture.cpp @@ -996,9 +996,15 @@ void D3D12DownloadTexture::Flush() // Need to execute command buffer. if (dev.GetCurrentFenceValue() == m_copy_fence_value) + { + if (dev.InRenderPass()) + dev.EndRenderPass(); dev.SubmitCommandList(true); + } else + { dev.WaitForFence(m_copy_fence_value); + } } void D3D12DownloadTexture::SetDebugName(std::string_view name)