diff --git a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp index 3229dc507..1e65a621e 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp @@ -27,6 +27,8 @@ #include "d3d12_command_list.h" #include "d3d12_resources.h" +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_SingleSubmitFlushing); + template bool WrappedID3D12CommandQueue::Serialise_UpdateTileMappings( SerialiserType &ser, ID3D12Resource *pResource, UINT NumResourceRegions, @@ -489,9 +491,8 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(SerialiserType &se { ID3D12CommandList *list = Unwrap(ppCommandLists[i]); real->ExecuteCommandLists(1, &list); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDevice->GPUSyncAllQueues(); -#endif + if(D3D12_Debug_SingleSubmitFlushing()) + m_pDevice->GPUSyncAllQueues(); } else { @@ -523,9 +524,8 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(SerialiserType &se return false; } -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDevice->GPUSyncAllQueues(); -#endif + if(D3D12_Debug_SingleSubmitFlushing()) + m_pDevice->GPUSyncAllQueues(); } } @@ -709,15 +709,18 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(SerialiserType &se } } -#if ENABLED(SINGLE_FLUSH_VALIDATE) - for(size_t i = 0; i < rerecordedCmds.size(); i++) + if(D3D12_Debug_SingleSubmitFlushing()) { - real->ExecuteCommandLists(1, &rerecordedCmds[i]); - m_pDevice->GPUSyncAllQueues(); + for(size_t i = 0; i < rerecordedCmds.size(); i++) + { + real->ExecuteCommandLists(1, &rerecordedCmds[i]); + m_pDevice->GPUSyncAllQueues(); + } + } + else + { + real->ExecuteCommandLists((UINT)rerecordedCmds.size(), &rerecordedCmds[0]); } -#else - real->ExecuteCommandLists((UINT)rerecordedCmds.size(), &rerecordedCmds[0]); -#endif } } } diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index a37154440..0aa8e892a 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -137,11 +137,6 @@ StencilOperation MakeStencilOp(D3D12_STENCIL_OP op); } \ } -// uncomment this to cause every internal ExecuteCommandLists to immediately call -// FlushLists(), and to only submit one command list at once to narrow -// down the cause of device lost errors -#define SINGLE_FLUSH_VALIDATE OPTION_OFF - // uncomment this to get verbose debugging about when/where/why partial command // buffer replay is happening #define VERBOSE_PARTIAL_REPLAY OPTION_OFF diff --git a/renderdoc/driver/d3d12/d3d12_counters.cpp b/renderdoc/driver/d3d12/d3d12_counters.cpp index 0562c8e7a..c8ca0b302 100644 --- a/renderdoc/driver/d3d12/d3d12_counters.cpp +++ b/renderdoc/driver/d3d12/d3d12_counters.cpp @@ -24,6 +24,7 @@ #include #include +#include "core/settings.h" #include "driver/ihv/amd/amd_counters.h" #include "driver/ihv/nv/nv_d3d12_counters.h" #include "d3d12_command_list.h" @@ -32,6 +33,8 @@ #include "d3d12_device.h" #include "d3d12_replay.h" +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_SingleSubmitFlushing); + rdcarray D3D12Replay::EnumerateCounters() { rdcarray ret; @@ -634,10 +637,11 @@ rdcarray D3D12Replay::FetchCounters(const rdcarray &c // replay the events to perform all the queries m_pDevice->ReplayLog(0, maxEID, eReplay_Full); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDevice->ExecuteLists(); - m_pDevice->FlushLists(true); -#endif + if(D3D12_Debug_SingleSubmitFlushing()) + { + m_pDevice->ExecuteLists(); + m_pDevice->FlushLists(true); + } // Only supported with developer mode drivers!!! m_pDevice->SetStablePowerState(FALSE); diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 989aa0d09..efde16b15 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -25,6 +25,7 @@ #include "d3d12_device.h" #include #include "core/core.h" +#include "core/settings.h" #include "driver/dxgi/dxgi_common.h" #include "driver/dxgi/dxgi_wrapped.h" #include "driver/ihv/amd/amd_rgp.h" @@ -40,6 +41,10 @@ #include "d3d12_resources.h" #include "d3d12_shader_cache.h" +RDOC_DEBUG_CONFIG(bool, D3D12_Debug_SingleSubmitFlushing, false, + "Every command buffer is submitted and fully flushed to the GPU, to narrow down " + "the source of problems."); + WRAPPED_POOL_INST(WrappedID3D12Device); Threading::CriticalSection WrappedID3D12Device::m_DeviceWrappersLock; @@ -4513,12 +4518,13 @@ void WrappedID3D12Device::ReplayLog(uint32_t startEventID, uint32_t endEventID, cmd.m_RenderState = cmd.m_BakedCmdListInfo[cmd.m_Partial[D3D12CommandData::Primary].partialParent].state; -#if ENABLED(SINGLE_FLUSH_VALIDATE) - FlushLists(true); + if(D3D12_Debug_SingleSubmitFlushing()) + { + FlushLists(true); - if(HasFatalError()) - return; -#endif + if(HasFatalError()) + return; + } } D3D12MarkerRegion::Set(GetQueue(), "!!!!RenderDoc Internal: Done replay"); diff --git a/renderdoc/driver/d3d12/d3d12_initstate.cpp b/renderdoc/driver/d3d12/d3d12_initstate.cpp index 069a9fbd1..78e2b2439 100644 --- a/renderdoc/driver/d3d12/d3d12_initstate.cpp +++ b/renderdoc/driver/d3d12/d3d12_initstate.cpp @@ -31,6 +31,8 @@ #include "d3d12_manager.h" #include "d3d12_resources.h" +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_SingleSubmitFlushing); + bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) { ResourceId id = GetResID(res); @@ -167,13 +169,11 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) m_Device->GetReal()->Evict(1, &unwrappedPageable); } - else + else if(D3D12_Debug_SingleSubmitFlushing()) { -#if ENABLED(SINGLE_FLUSH_VALIDATE) m_Device->CloseInitialStateList(); m_Device->ExecuteLists(NULL, true); m_Device->FlushLists(true); -#endif } initContents = D3D12InitialContents(copyDst); @@ -386,13 +386,11 @@ bool D3D12ResourceManager::Prepare_InitialState(ID3D12DeviceChild *res) if(nonresident) m_Device->GetReal()->Evict(1, &unwrappedPageable); } - else + else if(D3D12_Debug_SingleSubmitFlushing()) { -#if ENABLED(SINGLE_FLUSH_VALIDATE) m_Device->CloseInitialStateList(); m_Device->ExecuteLists(NULL, true); m_Device->FlushLists(true); -#endif } SAFE_RELEASE(arrayTexture); @@ -1353,11 +1351,12 @@ void D3D12ResourceManager::Apply_InitialState(ID3D12DeviceChild *live, if(!barriers.empty()) list->ResourceBarrier((UINT)barriers.size(), &barriers[0]); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_Device->CloseInitialStateList(); - m_Device->ExecuteLists(NULL, true); - m_Device->FlushLists(true); -#endif + if(D3D12_Debug_SingleSubmitFlushing()) + { + m_Device->CloseInitialStateList(); + m_Device->ExecuteLists(NULL, true); + m_Device->FlushLists(true); + } } } else diff --git a/renderdoc/driver/d3d12/d3d12_overlay.cpp b/renderdoc/driver/d3d12/d3d12_overlay.cpp index fa84ae9ca..15fca182f 100644 --- a/renderdoc/driver/d3d12/d3d12_overlay.cpp +++ b/renderdoc/driver/d3d12/d3d12_overlay.cpp @@ -48,6 +48,8 @@ RDOC_CONFIG(rdcstr, D3D12_Debug_OverlayDumpDirPath, "", "Path to dump quad overdraw patched DXIL files."); +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_SingleSubmitFlushing); + struct D3D12QuadOverdrawCallback : public D3D12ActionCallback { D3D12QuadOverdrawCallback(WrappedID3D12Device *dev, const rdcarray &events, @@ -2004,10 +2006,11 @@ ResourceId D3D12Replay::RenderOverlay(ResourceId texid, FloatVector clearCol, De list->Close(); list = NULL; -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDevice->ExecuteLists(); - m_pDevice->FlushLists(); -#endif + if(D3D12_Debug_SingleSubmitFlushing()) + { + m_pDevice->ExecuteLists(); + m_pDevice->FlushLists(); + } m_pDevice->ReplayLog(0, events[0], eReplay_WithoutDraw); diff --git a/renderdoc/driver/d3d12/d3d12_rendermesh.cpp b/renderdoc/driver/d3d12/d3d12_rendermesh.cpp index 83a8a1fb0..fef3178d1 100644 --- a/renderdoc/driver/d3d12/d3d12_rendermesh.cpp +++ b/renderdoc/driver/d3d12/d3d12_rendermesh.cpp @@ -22,6 +22,7 @@ * THE SOFTWARE. ******************************************************************************/ +#include "core/settings.h" #include "driver/dxgi/dxgi_common.h" #include "maths/camera.h" #include "maths/formatpacking.h" @@ -35,6 +36,8 @@ #include "data/hlsl/hlsl_cbuffers.h" +RDOC_EXTERN_CONFIG(bool, D3D12_Debug_SingleSubmitFlushing); + MeshDisplayPipelines D3D12DebugManager::CacheMeshDisplayPipelines(const MeshFormat &primary, const MeshFormat &secondary) { @@ -849,8 +852,9 @@ void D3D12Replay::RenderMesh(uint32_t eventId, const rdcarray &secon list->Close(); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDevice->ExecuteLists(); - m_pDevice->FlushLists(); -#endif + if(D3D12_Debug_SingleSubmitFlushing()) + { + m_pDevice->ExecuteLists(); + m_pDevice->FlushLists(); + } } diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index 5e9e4b169..f3f9f82bc 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -78,10 +78,6 @@ typedef VkBufferDeviceAddressInfo VkBufferDeviceAddressInfoEXT; typedef VkPhysicalDeviceBufferDeviceAddressFeatures VkPhysicalDeviceBufferDeviceAddressFeaturesKHR; -// enable this to cause every internal QueueSubmit to immediately call DeviceWaitIdle(), and to only -// submit one command buffer at once to narrow down the cause of device lost errors -#define SINGLE_FLUSH_VALIDATE OPTION_OFF - // enable this to get verbose debugging about when/where/why partial command buffer replay is // happening #define VERBOSE_PARTIAL_REPLAY OPTION_OFF diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 448638ed4..336e6f3e0 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -39,6 +39,10 @@ RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_VerboseCommandRecording); +RDOC_DEBUG_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing, false, + "Every command buffer is submitted and fully flushed to the GPU, to narrow down " + "the source of problems."); + uint64_t VkInitParams::GetSerialiseSize() { // misc bytes and fixed integer members @@ -351,9 +355,8 @@ void WrappedVulkan::SubmitCmds(VkSemaphore *unwrappedWaitSemaphores, m_InternalCmds.submittedcmds.append(m_InternalCmds.pendingcmds); m_InternalCmds.pendingcmds.clear(); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - FlushQ(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + FlushQ(); } VkSemaphore WrappedVulkan::GetNextSemaphore() @@ -413,14 +416,12 @@ void WrappedVulkan::FlushQ() CheckVkResult(vkr); } -#if ENABLED(SINGLE_FLUSH_VALIDATE) - if(m_Device != VK_NULL_HANDLE) + if(Vulkan_Debug_SingleSubmitFlushing() && m_Device != VK_NULL_HANDLE) { ObjDisp(m_Device)->DeviceWaitIdle(Unwrap(m_Device)); VkResult vkr = ObjDisp(m_Device)->DeviceWaitIdle(Unwrap(m_Device)); CheckVkResult(vkr); } -#endif for(std::function cleanup : m_PendingCleanups) cleanup(); @@ -528,48 +529,52 @@ void WrappedVulkan::SubmitAndFlushImageStateBarriers(ImageBarrierSequence &barri NULL, // signal semaphores }; -#if ENABLED(SINGLE_FLUSH_VALIDATE) - for(auto it = batch.begin(); it != batch.end(); ++it) + if(Vulkan_Debug_SingleSubmitFlushing()) + { + for(auto it = batch.begin(); it != batch.end(); ++it) + { + vkr = ObjDisp(cmd)->BeginCommandBuffer(Unwrap(cmd), &beginInfo); + CheckVkResult(vkr); + + DoPipelineBarrier(cmd, 1, it); + vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); + CheckVkResult(vkr); + + vkr = ObjDisp(queue)->QueueSubmit(Unwrap(queue), 1, &submitInfo, VK_NULL_HANDLE); + CheckVkResult(vkr); + + vkr = ObjDisp(queue)->QueueWaitIdle(Unwrap(queue)); + CheckVkResult(vkr); + } + } + else { vkr = ObjDisp(cmd)->BeginCommandBuffer(Unwrap(cmd), &beginInfo); CheckVkResult(vkr); - DoPipelineBarrier(cmd, 1, it); + DoPipelineBarrier(cmd, (uint32_t)batch.size(), batch.data()); + vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); - vkr = ObjDisp(queue)->QueueSubmit(Unwrap(queue), 1, &submitInfo, VK_NULL_HANDLE); - CheckVkResult(vkr); - - vkr = ObjDisp(queue)->QueueWaitIdle(Unwrap(queue)); - CheckVkResult(vkr); - } -#else - vkr = ObjDisp(cmd)->BeginCommandBuffer(Unwrap(cmd), &beginInfo); - CheckVkResult(vkr); - - DoPipelineBarrier(cmd, (uint32_t)batch.size(), batch.data()); - - vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); - CheckVkResult(vkr); - - queueFamilyFences.resize_for_index(queueFamilyIndex); - VkFence &fence = queueFamilyFences[queueFamilyIndex]; - if(fence == VK_NULL_HANDLE) - { - VkFenceCreateInfo fenceInfo = { - /* sType = */ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, - /* pNext = */ NULL, - /* flags = */ 0, - }; - vkr = ObjDisp(m_Device)->CreateFence(Unwrap(m_Device), &fenceInfo, NULL, &fence); + queueFamilyFences.resize_for_index(queueFamilyIndex); + VkFence &fence = queueFamilyFences[queueFamilyIndex]; + if(fence == VK_NULL_HANDLE) + { + VkFenceCreateInfo fenceInfo = { + /* sType = */ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, + /* pNext = */ NULL, + /* flags = */ 0, + }; + vkr = ObjDisp(m_Device)->CreateFence(Unwrap(m_Device), &fenceInfo, NULL, &fence); + CheckVkResult(vkr); + } + + vkr = ObjDisp(queue)->QueueSubmit(Unwrap(queue), 1, &submitInfo, fence); CheckVkResult(vkr); + submittedFences.push_back(fence); } - vkr = ObjDisp(queue)->QueueSubmit(Unwrap(queue), 1, &submitInfo, fence); - CheckVkResult(vkr); - submittedFences.push_back(fence); -#endif batch.clear(); } if(!submittedFences.empty()) @@ -3987,12 +3992,13 @@ void WrappedVulkan::ReplayLog(uint32_t startEventID, uint32_t endEventID, Replay m_OutsideCmdBuffer = VK_NULL_HANDLE; } -#if ENABLED(SINGLE_FLUSH_VALIDATE) - SubmitAndFlushImageStateBarriers(m_setupImageBarriers); - SubmitCmds(); - FlushQ(); - SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + { + SubmitAndFlushImageStateBarriers(m_setupImageBarriers); + SubmitCmds(); + FlushQ(); + SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); + } } if(!IsStructuredExporting(m_State)) diff --git a/renderdoc/driver/vulkan/vk_counters.cpp b/renderdoc/driver/vulkan/vk_counters.cpp index 663a2b0d9..1ec048a07 100644 --- a/renderdoc/driver/vulkan/vk_counters.cpp +++ b/renderdoc/driver/vulkan/vk_counters.cpp @@ -26,6 +26,7 @@ #include #include +#include "core/settings.h" #include "vk_core.h" #include "vk_replay.h" #include "vk_resources.h" @@ -36,6 +37,8 @@ #include "driver/ihv/nv/nv_vk_counters.h" +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); + static uint32_t FromKHRCounter(GPUCounter counterID) { return (uint32_t)counterID - (uint32_t)GPUCounter::FirstVulkanExtended; @@ -994,9 +997,8 @@ rdcarray VulkanReplay::FetchCounters(const rdcarray & vkr = ObjDisp(dev)->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); VulkanGPUTimerCallback cb(m_pDriver, this, timeStampPool, occlusionPool, pipeStatsPool, compPipeStatsPool); diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index 126e99bc7..249ccea16 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -42,6 +42,8 @@ #define VULKAN 1 #include "data/glsl/glsl_ubos_cpp.h" +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); + RDOC_CONFIG(bool, Vulkan_HardwareCounters, true, "Enable support for IHV-specific hardware counters on Vulkan."); @@ -969,9 +971,8 @@ void VulkanDebugManager::CreateCustomShaderTex(uint32_t width, uint32_t height, vkr = ObjDisp(dev)->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); CREATE_OBJECT(m_Custom.TexRP, imInfo.format, imInfo.samples); @@ -1562,9 +1563,8 @@ uint32_t VulkanReplay::PickVertex(uint32_t eventId, int32_t width, int32_t heigh VkResult vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); m_pDriver->SubmitCmds(); m_pDriver->FlushQ(); @@ -1879,9 +1879,8 @@ void VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_ vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); while(sizeRemaining > 0) { diff --git a/renderdoc/driver/vulkan/vk_initstate.cpp b/renderdoc/driver/vulkan/vk_initstate.cpp index 1312015f8..d0cdf691c 100644 --- a/renderdoc/driver/vulkan/vk_initstate.cpp +++ b/renderdoc/driver/vulkan/vk_initstate.cpp @@ -26,6 +26,8 @@ #include "vk_core.h" #include "vk_debug.h" +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); + // VKTODOLOW there's a lot of duplicated code in this file for creating a buffer to do // a memory copy and saving to disk. @@ -1749,13 +1751,14 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten VkMarkerRegion::End(cmd); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - CloseInitStateCmd(); - SubmitAndFlushImageStateBarriers(m_setupImageBarriers); - SubmitCmds(); - FlushQ(); - SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + { + CloseInitStateCmd(); + SubmitAndFlushImageStateBarriers(m_setupImageBarriers); + SubmitCmds(); + FlushQ(); + SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); + } } else if(initial.tag == VkInitialContents::ClearDepthStencilImage) { @@ -1781,13 +1784,14 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten VkMarkerRegion::End(cmd); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - CloseInitStateCmd(); - SubmitAndFlushImageStateBarriers(m_setupImageBarriers); - SubmitCmds(); - FlushQ(); - SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + { + CloseInitStateCmd(); + SubmitAndFlushImageStateBarriers(m_setupImageBarriers); + SubmitCmds(); + FlushQ(); + SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); + } } else { @@ -1822,13 +1826,14 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten GetDebugManager()->CopyBufferToTex2DMS(cmd, ToUnwrappedHandle(live), Unwrap(buf), c.extent, c.arrayLayers, (uint32_t)c.samples, fmt); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - CloseInitStateCmd(); - SubmitAndFlushImageStateBarriers(m_setupImageBarriers); - SubmitCmds(); - FlushQ(); - SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + { + CloseInitStateCmd(); + SubmitAndFlushImageStateBarriers(m_setupImageBarriers); + SubmitCmds(); + FlushQ(); + SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); + } return; } @@ -2055,13 +2060,14 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten VkMarkerRegion::End(cmd); } -#if ENABLED(SINGLE_FLUSH_VALIDATE) - CloseInitStateCmd(); - SubmitAndFlushImageStateBarriers(m_setupImageBarriers); - SubmitCmds(); - FlushQ(); - SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + { + CloseInitStateCmd(); + SubmitAndFlushImageStateBarriers(m_setupImageBarriers); + SubmitCmds(); + FlushQ(); + SubmitAndFlushImageStateBarriers(m_cleanupImageBarriers); + } } else if(type == eResDeviceMemory) { @@ -2162,11 +2168,12 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, const VkInitialConten VkMarkerRegion::End(cmd); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - CloseInitStateCmd(); - SubmitCmds(); - FlushQ(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + { + CloseInitStateCmd(); + SubmitCmds(); + FlushQ(); + } } else { diff --git a/renderdoc/driver/vulkan/vk_outputwindow.cpp b/renderdoc/driver/vulkan/vk_outputwindow.cpp index e646f0363..7495476b5 100644 --- a/renderdoc/driver/vulkan/vk_outputwindow.cpp +++ b/renderdoc/driver/vulkan/vk_outputwindow.cpp @@ -22,9 +22,12 @@ * THE SOFTWARE. ******************************************************************************/ +#include "core/settings.h" #include "vk_core.h" #include "vk_replay.h" +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); + VulkanReplay::OutputWindow::OutputWindow() : m_WindowSystem(WindowingSystem::Unknown), width(0), height(0) { @@ -1044,9 +1047,8 @@ void VulkanReplay::BindOutputWindow(uint64_t id, bool depth) vt->EndCommandBuffer(Unwrap(cmd)); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); } void VulkanReplay::ClearOutputWindowColor(uint64_t id, FloatVector col) @@ -1101,9 +1103,8 @@ void VulkanReplay::ClearOutputWindowColor(uint64_t id, FloatVector col) vt->EndCommandBuffer(Unwrap(cmd)); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); } void VulkanReplay::ClearOutputWindowDepth(uint64_t id, float depth, uint8_t stencil) @@ -1157,9 +1158,8 @@ void VulkanReplay::ClearOutputWindowDepth(uint64_t id, float depth, uint8_t sten vt->EndCommandBuffer(Unwrap(cmd)); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); } void VulkanReplay::FlipOutputWindow(uint64_t id) diff --git a/renderdoc/driver/vulkan/vk_overlay.cpp b/renderdoc/driver/vulkan/vk_overlay.cpp index 625e3c1a2..63545d338 100644 --- a/renderdoc/driver/vulkan/vk_overlay.cpp +++ b/renderdoc/driver/vulkan/vk_overlay.cpp @@ -25,6 +25,7 @@ #include #include #include +#include "core/settings.h" #include "data/glsl_shaders.h" #include "driver/shaders/spirv/spirv_common.h" #include "driver/shaders/spirv/spirv_gen.h" @@ -39,6 +40,8 @@ #define VULKAN 1 #include "data/glsl/glsl_ubos_cpp.h" +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); + struct VulkanQuadOverdrawCallback : public VulkanActionCallback { VulkanQuadOverdrawCallback(WrappedVulkan *vk, VkDescriptorSetLayout descSetLayout, @@ -1928,9 +1931,8 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, FloatVector clearCol, D vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); size_t startEvent = 0; @@ -2216,9 +2218,8 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, FloatVector clearCol, D vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); m_pDriver->ReplayLog(0, events[0], eReplay_WithoutDraw); @@ -2346,9 +2347,8 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, FloatVector clearCol, D vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); rdcarray events = passEvents; @@ -2904,9 +2904,8 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, FloatVector clearCol, D vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); return GetResID(m_Overlay.Image); } diff --git a/renderdoc/driver/vulkan/vk_rendermesh.cpp b/renderdoc/driver/vulkan/vk_rendermesh.cpp index cdf1e0862..b9208dbd4 100644 --- a/renderdoc/driver/vulkan/vk_rendermesh.cpp +++ b/renderdoc/driver/vulkan/vk_rendermesh.cpp @@ -23,6 +23,7 @@ ******************************************************************************/ #include +#include "core/settings.h" #include "maths/camera.h" #include "maths/formatpacking.h" #include "maths/matrix.h" @@ -34,6 +35,8 @@ #define VULKAN 1 #include "data/glsl/glsl_ubos_cpp.h" +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); + VKMeshDisplayPipelines VulkanDebugManager::CacheMeshDisplayPipelines(VkPipelineLayout pipeLayout, const MeshFormat &primary, const MeshFormat &secondary) @@ -977,9 +980,8 @@ void VulkanReplay::RenderMesh(uint32_t eventId, const rdcarray &seco vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); } m_HighlightCache.CacheHighlightingData(eventId, cfg); @@ -1226,7 +1228,6 @@ void VulkanReplay::RenderMesh(uint32_t eventId, const rdcarray &seco vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); } diff --git a/renderdoc/driver/vulkan/vk_rendertexture.cpp b/renderdoc/driver/vulkan/vk_rendertexture.cpp index 2548e045d..64ee823de 100644 --- a/renderdoc/driver/vulkan/vk_rendertexture.cpp +++ b/renderdoc/driver/vulkan/vk_rendertexture.cpp @@ -22,6 +22,7 @@ * THE SOFTWARE. ******************************************************************************/ +#include "core/settings.h" #include "maths/formatpacking.h" #include "maths/matrix.h" #include "vk_core.h" @@ -31,6 +32,8 @@ #define VULKAN 1 #include "data/glsl/glsl_ubos_cpp.h" +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); + void VulkanReplay::CreateTexImageView(VkImage liveIm, const VulkanCreationInfo::Image &iminfo, CompType typeCast, TextureDisplayViews &views) { @@ -597,12 +600,10 @@ bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, const ImageState &i m_pDriver->FlushQ(); m_pDriver->SubmitAndFlushImageStateBarriers(cleanupBarriers); } -#if ENABLED(SINGLE_FLUSH_VALIDATE) - else + else if(Vulkan_Debug_SingleSubmitFlushing()) { m_pDriver->SubmitCmds(); } -#endif return true; } diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index bce509648..c52198837 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -44,6 +44,8 @@ #define VULKAN 1 #include "data/glsl/glsl_ubos_cpp.h" +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); + static const char *SPIRVDisassemblyTarget = "SPIR-V (RenderDoc)"; static const char *AMDShaderInfoTarget = "AMD_shader_info"; static const char *KHRExecutablePropertiesTarget = "KHR_pipeline_executable_properties"; @@ -843,9 +845,8 @@ void VulkanReplay::RenderCheckerboard(FloatVector dark, FloatVector light) vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); } void VulkanReplay::RenderHighlightBox(float w, float h, float scale) @@ -946,9 +947,8 @@ void VulkanReplay::RenderHighlightBox(float w, float h, float scale) vkr = vt->EndCommandBuffer(Unwrap(cmd)); CheckVkResult(vkr); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); } void VulkanReplay::GetBufferData(ResourceId buff, uint64_t offset, uint64_t len, bytebuf &retData) @@ -3446,9 +3446,8 @@ void VulkanReplay::GetTextureData(ResourceId tex, const Subresource &sub, // ordering vt->EndCommandBuffer(Unwrap(cmd)); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - m_pDriver->SubmitCmds(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + m_pDriver->SubmitCmds(); // create framebuffer/render pass to render to VkAttachmentDescription attDesc = {0, diff --git a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp index 68ccc122e..352e21989 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp @@ -28,6 +28,7 @@ #include "core/settings.h" RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_VerboseCommandRecording); +RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing); template bool WrappedVulkan::Serialise_vkGetDeviceQueue(SerialiserType &ser, VkDevice device, @@ -470,26 +471,28 @@ void WrappedVulkan::ReplayQueueSubmit(VkQueue queue, VkSubmitInfo2 submitInfo, r submitInfo.pCommandBufferInfos = rerecordedCmds.data(); -#if ENABLED(SINGLE_FLUSH_VALIDATE) - submitInfo.commandBufferInfoCount = 1; - for(size_t i = 0; i < rerecordedCmds.size(); i++) + if(Vulkan_Debug_SingleSubmitFlushing()) { - DoSubmit(queue, submitInfo); - submitInfo.pCommandBufferInfos++; + submitInfo.commandBufferInfoCount = 1; + for(size_t i = 0; i < rerecordedCmds.size(); i++) + { + DoSubmit(queue, submitInfo); + submitInfo.pCommandBufferInfos++; - FlushQ(); + FlushQ(); + } } -#else - submitInfo.commandBufferInfoCount = (uint32_t)rerecordedCmds.size(); + else + { + submitInfo.commandBufferInfoCount = (uint32_t)rerecordedCmds.size(); - DoSubmit(queue, submitInfo); -#endif + DoSubmit(queue, submitInfo); + } } } -#if ENABLED(SINGLE_FLUSH_VALIDATE) - FlushQ(); -#endif + if(Vulkan_Debug_SingleSubmitFlushing()) + FlushQ(); } bool WrappedVulkan::PatchIndirectDraw(size_t drawIndex, uint32_t paramStride,