diff --git a/runtime/Core/Debugging.h b/runtime/Core/Debugging.h index b928c9e35..06d89273e 100644 --- a/runtime/Core/Debugging.h +++ b/runtime/Core/Debugging.h @@ -46,11 +46,11 @@ namespace Spartan private: inline static bool m_validation_layer_enabled = false; // enables vulkan validation, high cpu overhead per draw inline static bool m_gpu_assisted_validation_enabled = false; // gpu-based validation, significant cpu and gpu cost - inline static bool m_breadcrumbs_enabled = false; // breadcrumbs: tracks gpu crashes and writes info into breadcrumbs.txt, minimal overhead - will be ignored for non-amd gpus + inline static bool m_breadcrumbs_enabled = false; // tracks gpu crashes and writes info into breadcrumbs.txt, minimal overhead - will be ignored for non-amd gpus inline static bool m_logging_to_file_enabled = false; // logs to file, high cpu cost due to disk i/o inline static bool m_renderdoc_enabled = false; // integrates renderdoc, high cpu overhead from api wrapping - inline static bool m_gpu_marking_enabled = true; // gpu markers for debugging, no performance impact - inline static bool m_gpu_timing_enabled = true; // measures gpu timings, negligible cost - inline static bool m_shader_optimization_enabled = true; // enables shader optimizations, high cost when off + inline static bool m_gpu_marking_enabled = true; // negligible cost + inline static bool m_gpu_timing_enabled = true; // negligible cost + inline static bool m_shader_optimization_enabled = true; // high cost when off }; } diff --git a/runtime/RHI/Vulkan/Vulkan_Device.cpp b/runtime/RHI/Vulkan/Vulkan_Device.cpp index 3e1461926..42548aa92 100644 --- a/runtime/RHI/Vulkan/Vulkan_Device.cpp +++ b/runtime/RHI/Vulkan/Vulkan_Device.cpp @@ -1596,15 +1596,41 @@ namespace Spartan deletion_queue.clear(); } - bool RHI_Device::DeletionQueueNeedsToParse() + bool RHI_Device::DeletionQueueNeedsToParse() { - uint32_t objects_to_delete = 0; + const uint32_t frames_selflife = 10; + static uint32_t frames_equilibrium = 0; + static uint32_t previous_objects_to_delete = 0; + + // count deletions in the queue + uint32_t current_objects_to_delete = 0; for (uint32_t i = 0; i < static_cast(RHI_Resource_Type::Max); i++) { - objects_to_delete += static_cast(deletion_queue[static_cast(i)].size()); + current_objects_to_delete += static_cast(deletion_queue[static_cast(i)].size()); } + + // check if the number of objects to delete has remained unchanged + if (current_objects_to_delete > 0 && current_objects_to_delete == previous_objects_to_delete) + { + frames_equilibrium++; - return objects_to_delete > 0; + // if it’s been stable for frame_selflife frames, reset counter and delete + if (frames_equilibrium >= frames_selflife) + { + frames_equilibrium = 0; + return true; + } + } + else + { + // reset counter if the count changed or if nothing is in the queue + frames_equilibrium = 0; + } + + // update the previous object count to the current count + previous_objects_to_delete = current_objects_to_delete; + + return false; } // descriptors