Parallel preparation and command recording #35

Open
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:15:58 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

With thousands of render items, preparation and recording dominate the frame on one thread.

Decided

  • Render items collected in jobs (per surface and per 1,024 items) under shared content locks (std::shared_mutex).
  • More than 512 items are recorded in jobs: Vulkan into secondary command buffers with command pools per thread and frame; D3D12 into command lists per job.
  • PRIMAL_VULKAN_PARALLEL_RECORDING=0 / PRIMAL_D3D12_PARALLEL_RECORDING=0 turn it off.
  • The fork's numbers (RADV): 6,400 items 3.3 ms to 0.60 ms; four windows 1.92 ms to 0.84 ms.

Read first

Steps

  • 1. Add a stress option (extra spheres) and record the single-thread numbers.
  • 2. Collect render items in jobs.
  • 3. Record in jobs on both backends.
  • 4. Measure again and write the numbers here.

Done when

  • Numbers before and after are in this issue; TSan clean; validation clean; 0 warnings; tidy 0.

Claude can help with

  • Running the benchmarks and TSan.

Learn

  • Why secondary command buffers exist and what they cost.
## Why With thousands of render items, preparation and recording dominate the frame on one thread. ## Decided - Render items collected in jobs (per surface and per 1,024 items) under shared content locks (`std::shared_mutex`). - More than 512 items are recorded in jobs: Vulkan into secondary command buffers with command pools per thread and frame; D3D12 into command lists per job. - `PRIMAL_VULKAN_PARALLEL_RECORDING=0` / `PRIMAL_D3D12_PARALLEL_RECORDING=0` turn it off. - The fork's numbers (RADV): 6,400 items 3.3 ms to 0.60 ms; four windows 1.92 ms to 0.84 ms. ## Read first - [Renderer](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Renderer), section 12; [Multithreading](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Multithreading) section 9 step 7. ## Steps - [ ] 1. Add a stress option (extra spheres) and record the single-thread numbers. - [ ] 2. Collect render items in jobs. - [ ] 3. Record in jobs on both backends. - [ ] 4. Measure again and write the numbers here. ## Done when - [ ] Numbers before and after are in this issue; TSan clean; validation clean; 0 warnings; tidy 0. ## Claude can help with - Running the benchmarks and TSan. ## Learn - Why secondary command buffers exist and what they cost.
Sign in to join this conversation.
No assignees
No project
No milestone
Blocks
#18 Job system: spin before sleeping (measured)
UnflavoredMeson/Primal_Plus_Plus
Depends on
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
UnflavoredMeson/Primal_Plus_Plus#35
No description provided.