upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_bindless.h
AgeCommit message (Collapse)Author
9 daysbindless: size every sampled dimension alike and name a full array as its ↵Jan Trencansky
own refusal (RT-BINDLESS-DIMENSION-LIMITS) World runs fill one bindless image array a few minutes in: `a bindless image array is full; dimension 3: 4096 indices, 4092 T#s of 4090 textures`. Dimension 3 is 1D (ImageDimension: 2D, 2D array, 3D, 1D). From then on every new 1D T# reads the fallback's zeros, and the console heaps count it as "no view for the T#'s format or range", which went from 2-28 a window to over 4000. Nothing leaks: the 4096 indices are the fallback, 4092 entries of image_entries and 3 replaced views, every one held by a texture the runtime still has registered, and a texture's indices go back when it goes (forget_image, the deferred bindless_slot release, remove_image). The cause is the size: size_bindings grew 2D images to 65536 but 3D and 1D only to 4096 and 2D arrays to 16384, constants that guessed how many textures of each dimension a title keeps, whatever the device holds (RADV allows 8388606 sampled images, llvmpipe 1015808). - vulkan_bindless.h: one maximum (max_images, 65536) for the sampled array of every single-sample dimension, in place of max_2d_images, max_2d_array_images, max_3d_images and max_1d_images. The 2D-array, 3D and 1D arrays grow together after 2D and the storage arrays, so on a device whose limits stop growth earlier none of them is favoured. The bound is memory (each generation's pool holds every element): 325729 descriptors on an RTX 5070, 10-20 MiB at 32-64 bytes a descriptor. The shaders declare runtime arrays, so no shader changes; the set layout changes, so compute pipelines get new journal names (hash_bindless_layout) and the pipeline cache is rebuilt. - BindlessSet::image_refusal says why add_image returned 0: no array for the dimension, the array is full, or only its shorter storage range is. - d3d12_vulkan_device.cpp: bind_image_locked and bind_image_views_locked report that reason; bind_title_image counts it ("the bindless array of the T#'s dimension is full", or "the bindless storage arrays of the T#'s dimension are full") instead of "no view for the T#'s format or range". The once-per-dimension line names the dimension, the storage range and how many of the textures holding indices are still registered at their address. - docs/d3d12_vulkan.md: the sizes, and the new reason. Tests: bindless_sizing_test checks RADV's and llvmpipe's limits (every sampled dimension at 65536; on main 1D and 3D stop at 4096) and that the three dimensions share a short budget alike. vk_bindless_dimensions_test (new, GLSL shader) sizes a set from the device, gives 5000 live 1D, 2D-array and 3D images an index each and reads every one through its index, then fills the rest of the array: the next is refused as full, and removed indices come back at once or, after an erased key, at the next flush. On main it fails at "1D: 4096 indices in the set". vk_bindless_test's index-space case filled 1D expecting the first index to be 1, which held only while the 1D array was as short as its storage arrays; it now checks every index once and that indices above the storage arrays go first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 daysImprove post-load GPU memory and pipeline handling (RT-POST-LOAD-GPU-MEMORY)Moriz82
Fall back to a dedicated buffer allocation when the shared arena fills. Update console descriptors and resource backing, preserve pipeline cache entries, and replay mesh records using bounded indirect arguments. Keep scripted input available until read and cover the runtime and translator paths with synthetic tests. Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
10 daysIntegrate post-story-load memory, queue and Vulkan runtime changesMoriz82
Preserve physical window aliases across remaps, order console list values, and replay bounded indirect graphics with captured draw state. Coordinate pipeline lifetime, texture refresh and queue teardown. Add synthetic CPU and GPU coverage for the integrated paths. Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com>
10 daysMerge the #984 result (main + RT-PROTON-STORY-LOAD) into #939Jan Trencansky
The base is 8a242efeb, the merge of main and #984. 68 files conflicted; they were resolved in seven groups by one rule: the same change in two forms keeps the base's form, everything only #939 has is kept, and where the two solve one problem in two ways the base's is the frame and #939's plugs into it. A, the Xbox proxy (d3d12_xs_device.cpp/.h, d3d12_xs.cpp, d3d12_xs_pso_stream.cpp/.h, d3d12_xs_alloc_size.h, d3d12_xs_desc_clean.h, device_proxy_test.cpp, queue_proxy_test.cpp): the base's files with #939's additions ported in. Device slot 57 asks #939's NativeGraphicsFactory first and falls back to the base's proxy_create_graphics_pipeline_from_native_code on E_NOTIMPL. Kept from #939: the providers (texture lease, raw texture view, resource by address, constant view, descriptor mapping, depth-stencil UAV, texture pages), the title-backed descriptor mirror, slot 13's feature answers, GPU labels on list slots 71/72. Dropped: #939's duplicates of the boot ladder routes, its fallback window, its slot 133 stand-in. A2 (xs_proxy_mock_test.cpp): the base's test with #939's slot 70 raw-buffer case; presentation cases follow #939's rule that a device which ever had a handler has no queue fallback. B1, the Vulkan device (d3d12_vulkan_device.cpp, d3d12_com.cpp/.h, shader_library.h, queue_families.h, pipeline_cache_file.h, startup_trace.h): one lazy-pipeline mechanism, the base's; #939's pending_base_compile and first_use_backend_pipelines dropped, prepare_on_bind and cold_graphics_compile kept. create_texture keeps the base's signature; #939's deferred backing is folded into the base's placed-memory binder. #939's quad lists as triangle indices. B2, the D3D12 tests (d3d12_existing_heap, a8_dimensions, pipeline_cache_seed, title_va, rect_list, shader_library, loader_tls_index0, draw, compute, xmem_placed, shader_library_corpus): the base's tests where both carry the same case, #939's cases added (rebound tables, linear texture map, large vertex batch, executable shaders, default A8 views). C, the backend (vulkan_replay.h, vulkan_backend.h, vulkan_bindless.h, vulkan_scratch.h, vulkan_present.h, rect_list_geometry.h, vk_test_device.h, vk_pipeline_check.cpp, vk_store_test.cpp, bindless_sizing_test.cpp, replay_texture_barrier_test.cpp): the base's prepare_draw and lazy compute, its #1055 release rule and its rectangle generator; #939's rectangle variants, GPU quad index expansion, 1D/3D and depth-stencil UAVs, the label fence on the base's submit. D, memory, services, presentation (xmem.cpp/.h, xg_xs.cpp, xg_xs_test.cpp, title_va_alias.h and its test, main.cpp, frame_pacer.h, xbox_present.cpp/.h; xgameruntime_offline.cpp for one comment): the base's xmem with #939's label hooks, file-backed sections and pin_mapped_data; both texture computers in xg_xs.cpp, the base's answering first; --first-run-ui kept without host speech in its profile. E, build, tools, docs (runtime/CMakeLists.txt, make_game.py, tools/rdna2spirv.py, tools/shader_disasm.py, scripts, tests, docs; docs/README.md and tests/test_exe_shaders_stage.py beyond the conflicts): the base's v_dot4 decode, #281's disassembler form and tests/semantic/test_fspx_dot4_op_sel_disasm.py dropped; the base's executable-shader step with #939's cache fix; 366 registered tests. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
11 days[integration] Linux/Proton and native Windows: boot through the story load ↵Moriz82
(RT-PROTON-STORY-LOAD) One squashed commit of a fork that was developed on a Linux/Proton machine and tested on two native Windows machines. On all of them the retail 1.0.2.1 package now launches, shows its launch movie, first-run pages and landing prompt, runs the story load to its end with the loading slideshow drawing its artwork, and enters the world phase. A first world frame is not verified yet. docs/linux_proton.md has the setup, a healthy boot's timeline, the machines and where it stops. Runtime: frames in the title's own window; DirectStorage pinned reads, page-list scatter/gather, BCPack and unshuffle with a locally generated predictor file; pooled, device-local and deferred image backing for streamed and placed textures; enhanced barriers into LAYOUT_UNDEFINED; a bindless table that degrades instead of refusing a submission; a descriptor hash finalizer (off until a library carries it); directly indexed heap offsets for compute dispatches and VS/PS/GS draws; title buffer windows outside a fragmented arena; opt-in device-local copies of streamed buffer views; write-fault retries under the tracker lock, shared trackers and write-watched title memory for native Windows; device-loss, compute-input and memory probes. Translator: loop bounds at structured exits, the eight FidelityFX programs that use a packed-dot form the disassembler skips, buffer bounds modes per view kind, a compaction option, the hash finalizer option. Tools and scripts: Linux boot scripts (Wine/Proton, no network), a Windows boot script, the paired compute translation script. No game data. AI-assisted (Claude Code and Codex agents), reviewed and booted by people on the machines named in docs/linux_proton.md. Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
11 daysruntime: connect native pipelines and title resources to the offline ↵Rain156
first-run UI Build on the public frame-loop integration in #321. Carry the texture-view and depth work from #213 and #261, the layout provider from #461, the responsive window from #526, and the rectangle generator from #682. Integrate the Xbox constant-buffer row addressing measured in #513 and the draw-time rectangle selection in #722. Keep all fixtures synthetic. The Windows GPU path resolves title-owned shader objects, retires geometry uploads per submission, materializes texture views on use, maps linear surfaces, and delivers completed GPU label writes. A first-run UI launch selects the tested settings for these paths.
13 daysOrder the bindless table upload across queues, bound retired generations, ↵AlxcBTW
keep the in-use set on failure (review of #2740) Other queues' next submission waits on the timeline value of the submission that carries a new generation's table upload; the submit result is committed under tracker_mutex_; at most 8 retired generations are kept before the flush waits for the oldest one's ticket (queue timelines, not the device); a failed new generation leaves the in-use set and the pending writes alone. The churn test gains an async-compute case (no D3D12 fence from compute to the direct queue), a check that a retired generation is pending right after its submit, and a --validated ctest. Docs: only public sources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 daysMerge remote-tracking branch 'origin/main' into bindless-per-queue-retireAlxcBTW
# Conflicts: # runtime/test/d3d12_descriptor_test.cpp
13 daysRetire bindless table generations by timeline instead of waiting for the ↵AlxcBTW
device (D3D-314) A flush that grows the table or changes live keys now makes a new generation (table buffers, descriptor set, descriptors rewritten from a CPU shadow) that replay binds, and frees the old one once every submission up to its ticket has completed. No vkDeviceWaitIdle. Adds d3d12_bindless_churn_test and the LEONIDA_BINDLESS_IDLE_WAIT=1 comparison knob. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 daysd3d12_descriptor_test: the bindless capacity check follows the set's roomJolymmiles
On MoltenVK (1.4.2, 1.4.3) the check sampled zeros: vkGetDescriptorSetLayoutSupport there accepts only layouts of fewer than maxPerSetDescriptors (1212) descriptors, so size_bindings keeps the default 4096 2D images and 1024 samplers, and the test's 5001st view and 2100th sampler were refused as the arrays filled. MoltenVK does create and sample a 65536-image, 4096-sampler set correctly (a native reproduction, and the whole test passes under Wine with growth forced), so that is MoltenVK's to fix; the runtime keeps following the driver's answer. The test now asks the set how much room it has (rt::d3d12::bindless_room, from BindlessSet::free_images and free_samplers). Where the set holds the full counts nothing changes. Where it holds fewer, the test fills each short array to its last index, checks the last view through the last sampler gives the texture, and that one more view and sampler are refused and read as the fallbacks. The device logs at startup when its set holds fewer samplers than a full shader-visible sampler heap. bindless_sizing_test gets MoltenVK's limits; vk_bindless_test checks the free counts.
13 daysMerge pull request #1863 from jsthopeItsNotRexed
13 daysruntime: erasing a bindless descriptor key no longer idles the GPUjsthope
DescriptorTable::erase backward-shifted the key's probe cluster, which moved other live entries, so BindlessSet::erase_key flagged the next flush as needing idle and every texture release ended in vkDeviceWaitIdle on the next submit. The shift is not needed: every lookup, on the CPU and in the translated shaders (rdna2spirv.py desc_probe), compares all eight probe slots and never stops at an empty one. Erase now empties only the key's own slot, and inserts reuse the hole. An erase uploads like an add (one slot, no idle). Replacing a live key's index, a relocating insert and table growth still require idle. Tests: descriptor_table_test checks that an erase in the middle of a cluster leaves every other slot byte-identical and marks one changed slot (it fails on the old erase); vk_bindless_test now expects no idle after an erase.
13 daysRuntime: exact minimum-LOD views and full bindless set on Intel Xe-LP (D3D-219)CowDeV
d3d12_descriptor failed every run on an Intel UHD 770 (101.7092) for two reasons, both from the driver taking an option the Vulkan spec allows: - VK_EXT_image_view_min_lod: the driver selects levels with minLodInteger = floor(minLod), the spec's "alternative", so a 0.75 or 1.75 ResourceMinLODClamp read one mip too detailed. On Intel integrated GPUs bind_image now passes the clamp rounded to the nearest level, which point mip filtering selects exactly. LEONIDA_MIN_LOD_INTEGER=1/0 forces it either way. - The bindless set stayed at its default counts (4096 2D images, 1024 samplers) because the driver reports maxPerSetDescriptors = 6159 with every other limit at 1048576. size_bindings now takes an optional layout_supported callback, and past maxPerSetDescriptors the device asks vkGetDescriptorSetLayoutSupport about the grown layout. bindless::SetLayout describes set 0 once for create_layout and that query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 daysperf(vulkan): zero-copy DescriptorTable staging upload and uint32 wrap guard ↵totonii
in read_slots
13 daysRuntime: size the bindless set's arrays from the device's descriptor limitsquackottu
Set 0's 2D, sampler and storage arrays were constexpr (4096 2D images, 1024 samplers, 256 per storage array): one full D3D12 sampler heap (2048) did not fit and bind_image/bind_sampler fell back. They are now sized once, when the device creates the set, from the update-after-bind or plain limits: today's sizes as the floor, then samplers up to min(4096, maxSamplerAllocationCount - 64), 2D images up to 65536, storage up to 4096. Sizing at creation keeps the set layout fixed for the pipelines built on it.
13 daysRuntime: bind multisampled 2D and array shader-resource viewscemalyakla
13 daysRuntime: the descriptor table lives in device-local memory (D3D-76)SuarezPM
AI-assisted. Set 0 binding 2 is the table every T#/S# lookup probes. BindlessSet allocated it HOST_VISIBLE | HOST_COHERENT and flush() memcpy'd into the mapping, so a divergent lookup read it over PCIe: 19.5x slower for T#+S# pairs and 46.2x for a divergent miss at 100k entries on an RTX 2060 SUPER (vk_descriptor_bench, #639; 58-796x on the 5080). The table now lives in DEVICE_LOCAL (HOST_VISIBLE kept as a fallback for a device without it). flush() takes the command buffer that will use the set and uploads only what changed: the whole table from a mapped staging buffer when the buffers were just created (first use or growth), and the changed slots with vkCmdUpdateBuffer otherwise, which copies the data into the command buffer while recording so no staging bytes are read at execution. A TRANSFER_WRITE -> SHADER_READ barrier follows, before the draws. DescriptorTable tracks the slots that insert, replace, erase, clear and grow touched, including both slots of a relocation, so a flush no longer rebuilds an 80 MiB table for one descriptor. A command buffer whose vkQueueSubmit is rejected never runs the upload, so the set keeps the obligation: VulkanQueue::execute reports the submit result through a commit callback, and the set rebuilds the table on the next flush, which also reports flush_needs_idle() and makes the device wait before it. The same wait now honours the pre-existing contract for replaced/erased entries and for growth (the device ignored flush_needs_idle() before), and frees the retired buffers once the queue is idle instead of at teardown. Verified on an NVIDIA RTX 2060 SUPER, Linux 620.73.04, Vulkan 1.4.357: - ctest 10/10, including descriptor_table cases for the change list, relocation marking and consume-once reads. - vk_bindless_test with LEONIDA_VK_VALIDATION=1: 14 draws (probe depth, erase, relocation, growth 64 -> 512 slots, rebind, failed-submit retry, other view, removal) read back exact, table in device-local memory in both descriptor-indexing configurations. With the retry disabled the test is red. - GPU suite 64/91 with the same 27 64-wide skips as main, 0 failures; 91/91 with LEONIDA_W64_EMULATE=1. No game data; synthetic fixtures only.
13 daysAvoid descriptor table growth with a bounded slot relocationTal Swicegood
14 daysruntime: require idle for bindless key replacementsCodex
14 daysRuntime: bindless set 0 (M2)Jan Trencansky
Set 0 as the translator declares it (docs/design.md, docs/d3d12_vulkan.md section 5), in runtime/src/vulkan_bindless.h: the twenty bindings with the array sizes vk_pipeline_check uses, and DescriptorTable (descriptor_table.h) behind binding 2. - An image has one index in its dimension (2D, 2D array, 3D, 1D), the same in every binding of that dimension. The storage arrays hold 256, so an image with a storage view gets an index below 256 and a read-only one goes above while there is room. - Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest clamping sampler), because a miss in the table is index 0. - Changes are queued and written by flush(), one write a slot: a view removed before the next flush is never written, so it may be destroyed at once. - insert_key / erase_key change the table; flush() copies it to the buffer, into a new and larger one when it has grown. Erasing compacts a probe cluster, which moves other keys' entries, and a new buffer rewrites binding 2: flush_needs_idle() says when a flush would do either, so the owner can make sure no command buffer that uses the set is still running. - With update after bind the set may be flushed between submissions; with partially bound only index 0 is written at creation. Test: vk_bindless_test, run by runtime/test/shaders/check.py and scripts/run_gpu_tests.py. ps_tex.asm, a hand-written RDNA2 pixel shader built by build.py, loads a T# and an S# from a descriptor table and samples: the translator's own lookup against the table and the set. It draws the gradient with the T# at the fourth slot probed, the fallback after the key is erased, the gradient after the table has grown into a new buffer, another view at the same index and the fallback after removal, with and without the descriptor-indexing flags; and it adds, removes and destroys a view before its first flush, which the validation layer reports if the write is still made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>