Repository navigation
Conversation
…PRESENT-CAPTURE-CACHED) make_capture_buffer took the first host-visible, coherent memory type. On NVIDIA that is an uncached type, and a host read of it is many times slower than of cached memory. Since the launch splash (ProjectLeonida#939) every frame the title presents before its first non-black one is scanned on the CPU in finish_startup_frame, with the submit and tracker locks held, so on a large window the scan starves every other submission and the title's hang watchdog ends the boot at the landing screen. The cached type is chosen first, the way probe_read_source already does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
kawaii-shakal
left a comment
There was a problem hiding this comment.
Review (read-only, not run). Correct and minimal. The buffer is only read on the CPU, so host-cached system memory is the right first choice. The two-pass search mirrors probe_read_source. Requiring HOST_COHERENT in both passes means no vkInvalidateMappedMemoryRanges is needed before the reads. On a driver whose only cached type is non-coherent, it falls back to the old choice rather than becoming incorrect.
Nit: the same two-pass search now exists twice in vulkan_present.h. A small pick_host_read_type(requirements) helper would keep them from drifting apart.
AI-assisted review (Claude Code, Claude Opus 5.5).
|
@kawaii-shakal thank you for the review. On the helper: I agree the two searches should not drift apart, and I would do it as a follow-up once this and #1223 are in. #1223 adds its guard directly above the |
|
Tested What the change picks here. In this driver's memory-type list, type 1 is I measured CPU reads from each host-visible type with a small standalone Vulkan program. It maps a 3840x2160x4 buffer (33 MB) and
( So the order is the same as on your RTX 5080 (uncached Tests,
I didn't run a retail boot. |
|
Thanks, that is a useful second vendor: the same memory-type order and a 75 times slower uncached read on the RX 7900 XT. I agree the 114 ms per 4K capture on |
|
Merge test for the #2464 campaign on an 8 GB laptop (profile M), done for the author. Main ec91d69 was merged without conflict, in one tree together with #1705, #1694 and #1284, which touch different code. The numbers were recomputed from the raw logs. AI-assisted (Claude Code, Claude Opus 5.5).
|
Claimed in the coordination issue as: RT-PRESENT-CAPTURE-CACHED (#1608 (comment))
What and why
VulkanPresenter::make_capture_buffertook the first memory type that is host visible and coherent. On NVIDIA the first such type is uncached (flags0x6on this RTX 5080; the cached one,0xe, comes after it), and a host read of uncached memory is many times slower than of cached memory.That did not matter much while the buffer was read once per capture. Since the launch splash (#939),
finish_startup_framereads the whole buffer on the CPU for every frame the title presents before its first non-black one, with the submit and tracker locks held. On a large window that scan takes over the boot:LEONIDA_STACKSdumps 20 s apart:submit_now->present->PresentX);device-stall: could not sample the submit lock for 15 s; submitted ticket 424, last observed retired ticket 328;The change: choose a host-cached, non-device-local type first and fall back to the first host-visible coherent one, exactly as
probe_read_sourcein the same file already does. One function, 11 lines.Measured
Native Windows 11, RTX 5080 16 GB, NVIDIA 621.24, 64 GB, own 1.0.2.1, MSVC RelWithDebInfo with SDL3. Window client area 3824x1841 when the first frame is presented. Every run: keyboard pad with A every 5 s from 30 s,
LEONIDA_SKIP_INT3=1,LEONIDA_PEEK=0x7446510,0x98f828c, an existing save, shaders frommain's translator.d)main3f81d46LEONIDA_TITLE_WINDOWS_MB=4096 LEONIDA_ARENA_MB=4096 LEONIDA_DEVICE_FAULT=1main+ #1558 + #1631LEONIDA_ARENA_MB=2048main+ #1558 + #1631,LEONIDA_WINDOW=960x540(no code change, 14 times fewer texels to scan)LEONIDA_ARENA_MB=2048main+ #1558 + #1631 + this changeLEONIDA_ARENA_MB=2048main+ this change only (this branch)So on this machine the first and last rows differ only by this commit. Before #939 (
main3ff2a2a) the same launcher passed the landing screen every time, which is how I found it.It probably costs time on smaller windows too, in proportion to the texel count: the report on #939 of 182 to 362 PresentX in 51 to 74 s on an RTX 4070 SUPER is a few presents a second. I have not measured another machine.
Tested
runtime/pass on this branch on the same GPU:xbox_present_readback_size,vk_presenter_capture_colour,present_window,xs_present_lazy,vk_present_dump,vk_present_dump_default,vk_present_dump_invalid,vk_presenter_sync,d3d12_present,xbox_present.Not done, not tested
Counters, switch names and addresses of the executable only; no game data. AI-assisted (Claude Code).
🤖 Generated with Claude Code