Skip to content

vulkan: copy descriptor table slots directly into mapped staging - #1196

Open
Kadamitas wants to merge 1 commit into
ProjectLeonida:mainfrom
Kadamitas:perf/descriptor-table-staging
Open

Kadamitas wants to merge 1 commit into
ProjectLeonida:mainfrom
Kadamitas:perf/descriptor-table-staging

Conversation

@Kadamitas

@Kadamitas Kadamitas commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as bulk-copy occupied descriptor staging slots.

What and why

Full bindless table uploads currently write every slot in small fragments, even though the descriptor and value records are already laid out in upload order. Bulk-copy full tables and consecutive slot ranges. Full vector and pointer uploads share the serializer. Removing the occupied marker preserves the descriptor kind, and the layout and tombstone values are preserved.

Tested

  • The existing descriptor_table_test passed on Windows after the Nov 27 rebase, including partial range reads and the kind-preserving marker path.
  • A synthetic byte comparison matched 2,309,432 bytes across aligned and unaligned destinations, with marker clearing enabled and disabled, including insert, erase, clear and rehash.
  • Before the rebase, on a Ryzen 9 7950X with MSVC /O2, a 40 MiB write-combined staging copy took 5.49–5.64 ms before and 1.39–1.44 ms after. Each result is the median of nine groups of four copies, with baseline and patch measured in alternating order. This measures CPU staging time.

GPUs tested: N/A. The benchmark used native Windows write-combined host pages.

AI-assisted: yes.

Checklist

  • Based on current main (43a9d562d).
  • One topic.
  • No game data, keys or decryption.

@Deedlyy

Deedlyy commented Nov 24, 2026

Copy link
Copy Markdown

Recommendation: [MERGE]

Reasoning: Bindless descriptor-table uploads memcpy the occupied slot range directly into staging instead of writing each slot in fragments. New static_asserts pin the trivially-copyable 40-byte layout the copy relies on, the clear_pad path still zeroes the marker word, and both entry points share one serializer. I checked the moved private: label: no member's access changes. Byte-identical output was verified over 2.3 MB of synthetic cases, with a roughly 4x faster CPU staging copy. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 3/10

@Kadamitas
Kadamitas force-pushed the perf/descriptor-table-staging branch from 270aaeb to 2fd49df Compare November 24, 2026 20:17
clquwu added a commit to clquwu/leonida-ultimate that referenced this pull request Nov 25, 2026
…#1904, #1196, #1932, #1957, suballoc 4 MiB)

Self-contained standalone header optimizations & hardening (GPL-3.0, zero RVAs,
zero game data, zero non-trivial thread_local):

1. BufferVaIndex (ubiquitarianism/leonida#1904, IlyassRS3, GPL-3.0):
   Replace std::map + std::multiset with an O(log N) augmented AVL interval
   tree (per-subtree max_end_inc & max_size, O(1) upper-bound miss reject,
   single-node allocation, zero-alloc in-place updates, overflow-safe near
   UINT64_MAX lookups, covers()).
2. DescriptorTable (ubiquitarianism/leonida#1196, Kadamitas, GPL-3.0):
   Static-assert DescriptorEntry layout and use contiguous memcpy in
   write_to_buffer() / build_gpu_buffer() / read_slots() for faster WC staging.
3. VulkanSlabAllocator (runtime/src/vulkan_suballoc.h):
   Raise kDefaultSlabBytes (16 -> 32 MiB) and kDefaultMaxSuballocBytes
   (512 KiB -> 4 MiB) to suballocate 1024x1024 and 2048x2048 BC7 textures, and
   add lock-free per-memory-type empty-slab reclamation capping idle slabs at
   1 per memory type (vkFreeMemory outside pool mutex).
4. GraphicsShaderModules (ubiquitarianism/leonida#1932, IlyassRS3, GPL-3.0):
   Switch to std::shared_mutex read fast path, destroy losing duplicate
   VkShaderModules outside the cache lock, enforce cross-device isolation, add
   null/VK_NULL_HANDLE guards and bucket pruning, and add CTest
   vulkan_graphics_shader_modules.
5. MemoryWaitHolds (ubiquitarianism/leonida#1957, IlyassRS3, GPL-3.0):
   Add work-aware timeout clock (MemoryWaitTimeoutClock, hold_with_budget),
   cycle-safe overwrite/alias-aware producer dependency analysis, and address/
   timestamp/override anti-wrap hardening while preserving all Wave 2/8 behavior.

Verified: Ninja + sccache + /Z7 build of gta6rt + all 5 test targets (0 warnings);
CTest 5/5 passed with LEONIDA_VK_VALIDATION=1; check_no_game_data.py 0 violations.
@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 26, 2026
@Kadamitas
Kadamitas force-pushed the perf/descriptor-table-staging branch from 2fd49df to 72ff4ab Compare November 27, 2026 18:56
@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants