MethanePowered / MethaneKit

🎲 Modern 3D graphics made simple with C++17 cross-platform framework and rendering abstraction API on top of DirectX 12, Metal & Vulkan
Apache License 2.0
846 stars 51 forks source link

Vulkan RHI: High overhead of ICommandList::SetProgramBindings in multi-threaded rendering scenario #130

Closed egorodet closed 9 months ago

egorodet commented 9 months ago

Describe the bug "Asteroids" sample and "Parallel Rendering" tutorial built for Vulkan API has significantly lower FPS than for DirectX API in multi-threaded rendering scenario.

Steps To Reproduce Steps to reproduce the behavior:

  1. Run "Parallel Rendering" tutorial built for DirectX, set grid size to 25 or higher => get ~400 FPS MethaneParallelRendering_DirectX
  2. Run "Parallel Rendering" tutorial built for Vulkan, set grid size to 25 or higher => get ~150 FPS MethaneParallelRendering_Vulkan
  3. Run "Asteroids" sample built for DirectX, set scene complexity to 8 (35000 asteroids) => get ~294 FPS
  4. Run "Asteroids" sample built for Vulkan, set scene complexity to 8 (35000 asteroids) => get ~77 FPS

MethaneAsteroids_ParallelRender_FPS

Expected behavior Comparable FPS is expected for DirectX and Vulkan version for the same application with equal parameters.

Desktop (please complete the following information):

egorodet commented 9 months ago

Rootcause Multi-threaded rendering performance became limited by std::mutex lock in Vulkan::Program::GetNativePipelineLayout called from Vulkan::ProgramBindings::Apply, as seen in Tracy: MethaneAsteroids_ParallelRender_Tracy

egorodet commented 9 months ago

Fixed in commit f57fcc84847a557de063e69698cbd2810130867f