Skip to content

fix(runtime): synchronize bindless uploads across Vulkan queues - #4517

Open
Persudes wants to merge 3 commits into
ItsNotRexed:mainfrom
Persudes:runtime/bindless-cross-queue-sync
Open

Persudes wants to merge 3 commits into
ItsNotRexed:mainfrom
Persudes:runtime/bindless-cross-queue-sync

Conversation

@Persudes

Copy link
Copy Markdown
Contributor

Summary

Addresses @shdann's runtime audit item 7 (cross-queue synchronization of BindlessSet uploads and fallback image initialization).

Changes

  • runtime/src/vulkan_bindless.h:
    • Added BindlessFeatures::queue_families and BindlessSet::share() so table/staging buffers and fallback images use VK_SHARING_MODE_CONCURRENT when 2+ unique queue families access the bindless set.
    • Tracked in-flight fallback image initialization (fallbacks_in_flight_) alongside upload_in_flight_, rolling back fallbacks_ready_ as well as table_dirty_ / force_full_upload_ when vkQueueSubmit fails.
    • Added BindlessSet::has_recorded_upload() and expanded record_table_barrier() dstAccessMask to VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT.
  • runtime/src/vulkan_backend.h:
    • Added a device-wide bindless_timeline_ VK_SEMAPHORE_TYPE_TIMELINE semaphore, upload sequence counter (bindless_upload_value_), cached completed value (bindless_completed_value_), and last uploader queue handle (bindless_upload_owner_) in VulkanContext (guarded by tracker_mutex_).
    • Updated VulkanContext::set_bindless_prepare to report whether GPU bindless commands were recorded (keeping a backward-compatible 1-arg overload) and wired VulkanQueue::prepare_bindless_sync() / VulkanQueue::submit() so any non-transfer-only queue waits on pending cross-queue uploads without mutating waits_ and advances bindless_timeline_ when recording new uploads.
  • runtime/shims/d3d12_vulkan_device.cpp:
    • Passed state_.families into BindlessFeatures::queue_families and reported state_.bindless->has_recorded_upload() from bindless_prepare_.
  • runtime/test/vk_bindless_queue_sync_test.cpp & runtime/CMakeLists.txt:
    • Added a synthetic multi-queue Vulkan regression covering: (1) first upload (record_fallback_init + vkCmdCopyBuffer) on queue A gating queue B's compute lookup, (2) zero redundant waits after upload completion, (3) incremental vkCmdUpdateBuffer gating across queues, (4) safe queue B execution after queue A teardown, and (5) failed vkQueueSubmit rollback + retry.

Verification

Tested on Windows 11 x64, MSVC 19.52.37029, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.1, AMD Radeon RX 6900 XT (AMD proprietary driver 26.11.2, Vulkan 1.4.315, distinct direct family 0 and async compute family 1 queues).

  • Negative control on main (03b09a08): vk_bindless_queue_sync_test.exe failed on subtest 1 with waits=0 blocked=0 mask=0 found=0 (queue B ran ahead of the gated queue A upload and read zeros).
  • .\runtime\build\vk_bindless_queue_sync_test.exe: passed (all 5 subtests).
  • LEONIDA_VK_VALIDATION=1 .\runtime\build\vk_bindless_queue_sync_test.exe (5 consecutive runs): 5/5 passed, 0 validation errors.
  • LEONIDA_VK_VALIDATION=1 .\runtime\build\vk_queue_test.exe: passed, 0 validation errors.
  • LEONIDA_VK_VALIDATION=1 .\runtime\build\d3d12_descriptor_test.exe: passed.
  • ctest --test-dir runtime/build --output-on-failure: 100% tests passed, 0 tests failed out of 156 (8 expected skips without retail files / sync validation layers, 1 disabled gameinput).
  • python -I tests/test_ctest_registration.py: 4/4 passed.

AI-assisted. No game files were used.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and ran vk_bindless_queue_sync_test at 11d905f7 on Windows 11, RTX 5070 Ti: vk_bindless_queue_sync_test: ok, exit 0.

It reports five checks: first upload gated queue B (mask=63 found=42), no redundant wait after completion, incremental vkCmdUpdateBuffer gated (found=77), queue B works after queue A is destroyed (found=99), and a failed submit rolls back fallbacks_ready and retries cleanly. No blocking issue.

@Parakeet-Wheat

Copy link
Copy Markdown
Contributor

Tested 11d905f on Windows 11 26300, MSVC (VS 2022), Windows SDK 10.0.26100, RTX 3070 (610.88), with the validation layer: pass. Full ctest is 155/155 with 0 build warnings. vk_bindless_queue_sync_test runs on distinct queues here too (A family=0, B family=2), and all 5 subtests pass. With synchronization validation (VK_KHRONOS_VALIDATION_VALIDATE_SYNC=true) it passed 20 of 20 runs with 0 messages.

Two controls on this head, each one line changed and nothing else:

  • Only the new wait removed (wait_sem = context_.bindless_timeline_; in prepare_bindless_sync commented out): subtest 1 fails with waits=0 blocked=0 mask=0 found=0, the same as your main run. So on NVIDIA as well as AMD, the test pins the timeline wait itself, not just the change as a whole.
  • Only the CONCURRENT sharing removed (BindlessSet::share() returns at once, so the table buffers and fallback images are EXCLUSIVE): exit 0, all subtests pass, 0 validation messages. So that half of the change isn't checked by the test or by the layer on this card. It does match DeviceState::share, which uses the same family list (graphics, compute, copy) for the layer's other resources, and the spec needs it, because an EXCLUSIVE resource used on a second family without an ownership transfer has undefined contents. If you have the 6900 XT handy, the same one-line control there would show whether AMD's driver notices. Otherwise a small check of sharingMode on the created table buffer would at least keep it from being dropped later.

Locking: prepare_bindless_sync runs with tracker_mutex_ held from before it until after bindless_upload_value_ is updated (both submit paths), so two queues can't pick the same signal value. A failed submit leaves the value alone, so the next one reuses pending + 1, which was never signalled.

AI-assisted (Claude Code).

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Keep a queue wait for the first consumer after a host query

vkGetSemaphoreCounterValue only observes the timeline counter. If queue A completes the upload before queue B's first shader use, this code records the completed value and leaves wait_sem null, so B is submitted without the signal-to-batch memory dependency. Vulkan defines the queue semaphore wait as establishing that memory dependency: https://docs.vulkan.org/spec/latest/chapters/synchronization.html#semaphore-waiting. Please retain a timeline wait for a consumer even when the value is already reached; the satisfied wait still establishes the dependency.

[P2] Avoid blocking submissions that do not consume bindless data

prepare_bindless_sync is called for every non-transfer submission. When another queue has a pending upload, a copy-only or empty direct/compute submission can receive the wait even though it has no dispatch, draw, or ExecuteIndirect that reads the bindless set. This serializes unrelated work behind the upload. Gate the consumer wait on actual shader use while keeping any ordering needed for upload submissions.

[P2] Propagate timeline semaphore creation failure

When vkCreateSemaphore fails, the constructor sets bindless_timeline_ to VK_NULL_HANDLE and leaves the context loaded; prepare_bindless_sync then returns without synchronization. Bindless resources can still be used across queues without the guarantee this change adds. Fail context/bindless initialization or use a safe serialized fallback instead of silently disabling the sync.

@JavierBlanco23

Copy link
Copy Markdown
Contributor

Tested 11d905f7 on NVIDIA GeForce RTX 5080 (driver 616.56, Vulkan SDK 1.4.363.0), Windows 11, MSVC 19.44 (RelWithDebInfo): pass.

  • ctest -R "^(vk_bindless_queue_sync|d3d12_descriptor|d3d12_compute|d3d12_vulkan_device)$": 4/4 passed (9.69 s).
  • LEONIDA_VK_VALIDATION=1 on vk_bindless_queue_sync: 1/1 passed (0.38 s), 0 validation errors; exercised distinct queues (A family=0, B family=2), all 5 subtests (bindless queue sync 1..5) ok.

Synthetic inputs only, no game files. AI-assisted.

@Zombins2

Copy link
Copy Markdown

AI-assisted. No game files used.

Following @Parakeet-Wheat's NVIDIA controls: AMD iGPU mutation/coverage results for 11d905f, plus two additional mutants. Ryzen 5 7600X (RDNA2 gfx1036, AMD 26.10.1), Windows 11 build 26200, MSVC 19.50 / Ninja Release. No validation layer enabled here; this is not the author's 6900 XT.

vk_bindless_queue_sync_test used distinct queues, A family 0 / B family 1. Five builds, 50 runs each; each mutant is a single-line replacement:

build / replacement observed outcome in all 50 runs
unmodified PR all five subtests pass
wait omitted subtest 1 fails: waits=0 blocked=0 mask=0 found=0
completed-value condition replaced with if(true) subtest 2 fails: last_wait_count == 0 assertion
failed-submit fallback-ready rollback omitted subtest 5 fails: !fresh_bindless.fallbacks_ready(); 1-4 pass
share() returns immediately all five subtests pass

Thus this AMD run also fails to distinguish the no-CONCURRENT-sharing mutant from the PR. Correct returned values in that mutant do not establish valid queue-family ownership or safe EXCLUSIVE sharing. This is observed test coverage on this driver, without validation, not a driver-conformance conclusion.

The additional mutants pin the existing assertions for B's later dispatch and failed-submit rollback. Subtest 2 comes after B has already waited for its first upload. It does NOT address the first-consumer-after-host-query scenario in Flyander's review; passing this test does not resolve that synchronization concern or endorse every wait-elision policy.

Two further coverage observations from source:

  • The new test constructs BindlessSet and its prepare lambda directly. It does not execute the two changed d3d12_vulkan_device.cpp statements that supply state_.families and propagate has_recorded_upload() through recorded. Those production wiring changes remain outside this test's coverage.
  • For the suggested sharingMode assertion, BindlessSet obtains vkCreateBuffer/vkCreateImage through the supplied getter. The test already intercepts vkQueueSubmit through driver::get_device, so analogous wrappers could capture create-info for the intended shared BindlessSet table/staging buffers and fallback images and verify CONCURRENT plus both distinct families. Scope that check to those resources, not every buffer/image created by the test. This hook suggestion is unimplemented here.

Existing vk_queue_test, vk_queue_query_sync_test, descriptor_table_test and d3d12_descriptor_test each passed three times on PR and parent 03b09a0 (24 executions). The descriptor test's sampling shader was unavailable (no glslangValidator). vk_bindless_test was not successfully exercised: no-argument invocations returned usage and are not counted.

Scope: targeted mutation/coverage feedback, not a synchronization-correctness or merge verdict. No NVIDIA, validation-layer, full-CTest or same-family-path check here; dropping the signal, semaphore-creation failure and the access-mask change were not independently tested.

@shdann

shdann commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 11d905f7 on Windows 11, MSVC 14.51, Ninja, RelWithDebInfo, on two GPUs: NVIDIA GeForce RTX 4090 (driver 32.0.16.2101) and AMD Radeon(TM) Graphics (integrated, driver 32.0.21043.5001). Result: pass. An AI tool helped me to do these tests. No game files. The validation layer is not installed on this computer.

This pull request is for item 7 of my audit note (#4257 (comment)). That item came from the code only. This is the first test of it on an RTX 40-series GPU.

Full ctest, each GPU, against main (03b09a08)

Build RTX 4090 AMD Radeon
main 134 tests, 2 fail: d3d12_present, xbox_present 134 tests, 1 fails: xbox_present
11d905f7 135 tests, 2 fail: d3d12_present, xbox_present 135 tests, 2 fail: d3d12_present, xbox_present

d3d12_present and xbox_present fail on this computer because of its window manager. d3d12_present passes in some runs and fails in others, on main also. Ignore them. No other test changes its result.

New test

  • vk_bindless_queue_sync: 20 of 20 runs pass on each GPU. The RTX 4090 uses queue families 0 and 2. The AMD GPU uses queue families 0 and 1. Thus the two queues are different VkQueue objects on the two GPUs.
  • Negative control: I changed the first line of prepare_bindless_sync to if (true) return;. Then no submission waits and no submission signals. The test fails in 3 of 3 runs on each GPU. With the line restored, the test passes again. This agrees with the controls from @Parakeet-Wheat and @Zombins2.
  • The test does not compile with the runtime/src and runtime/shims files of main, because it uses the new functions. Thus I have no run of this test on main.

Code read

I looked for a deadlock between the new wait and a D3D12 Wait on a fence. I did not find one. A queue holds a batch on the CPU until the Signal for its Wait is submitted (queue_holds.h). Thus the bindless upload of that batch is recorded only when the batch is released, and the order of the submissions is the order of the dependencies.

I do not repeat the points in the review from @Flyander.

Correction (added later): in the AMD column of the full ctest table, the one test vk_bindless ran on the RTX 4090, not on the AMD GPU. Its program vk_bindless_test ignores LEONIDA_VK_DEVICE (finding: #5781 (comment)). All other tests in that column ran on the AMD GPU. The new test vk_bindless_queue_sync printed the AMD queue families, thus it ran on the AMD GPU.

@Persudes

Copy link
Copy Markdown
Contributor Author

Addressed @Flyander's review points and @Parakeet-Wheat / @Zombins2's CONCURRENT sharingMode coverage feedback in 0a2b0ee1:

  1. [P1] Retain first-consumer timeline wait after host-observed completion (vulkan_backend.h):
    Removed bindless_completed_value_ / bindless_upload_owner_ and host vkGetSemaphoreCounterValue wait elision from prepare_bindless_sync(). Replaced them with per-queue bindless_seen_, so every consumer queue still submits one queue timeline wait for any newer bindless_upload_value_ even if the upload already completed on the GPU — establishing Vulkan's signal-to-batch memory dependency before bindless_seen_ advances on a successful submit (covering subsequent batches on that queue in submission order via VK_PIPELINE_STAGE_ALL_COMMANDS_BIT).
  2. [P2] Do not block non-shader submissions behind bindless uploads (vulkan_backend.h):
    Moved runs_shaders (Dispatch / Draw / ExecuteIndirect) computation before bindless_prepare_ and gated consumer waits on bindless_recorded || runs_shaders (and false on the bindless_prepare_ error path). Empty and copy-only submissions without a newly recorded upload no longer wait on bindless_timeline_ and leave bindless_seen_ untouched.
  3. [P2] Propagate bindless_timeline_ creation failure (vulkan_backend.h):
    VulkanContext now creates bindless_timeline_ before FenceWaitDispatcher and sets loaded_ = false if vkCreateSemaphore fails. VulkanQueue returns early when !context.loaded() (leaving ok_ = false) and guards execute_now(), submit(), and ~VulkanQueue().
  4. Expanded vk_bindless_queue_sync_test.cpp regressions:
    • Check 0: Intercepts vkCreateBuffer / vkCreateImage around BindlessSet construction, confirming all 2 table buffers and 9 fallback images use VK_SHARING_MODE_CONCURRENT with both distinct queue families {0, 1} (or EXCLUSIVE on single-family GPUs).
    • Subtest 1: Verifies empty and CopyBuffer submissions on queue B emit 0 waits and finish while queue A's upload is blocked behind the gate semaphore.
    • Subtest 3: Verifies a fresh consumer queue (queue_c) submitting a shader after queue A completed on the GPU still emits waitSemaphoreCount >= 1, then 0 on its next dispatch.
    • Subtest 6: Verifies a failed consumer vkQueueSubmit does not advance bindless_seen_ before retry.
    • Subtest 7: Injects vkCreateSemaphore failure and verifies !bad_ctx.loaded(), !bad_queue.ok(), and ReplayResult::unsupported.

Verification at 0a2b0ee1 (Windows 11 x64, AMD Radeon RX 6900 XT Adrenalin 26.11.2, Vulkan 1.4.315 / SDK 1.4.363.1)

  • vk_bindless_queue_sync_test.exe (3x standard): 3/3 passed (all 8 checks 0..7 ok, exit 0)
  • vk_bindless_queue_sync_test.exe (5x LEONIDA_VK_VALIDATION=1): 5/5 passed (0 validation errors)
  • vk_bindless_queue_sync_test.exe (5x LEONIDA_VK_VALIDATION=1 + VK_KHRONOS_VALIDATION_VALIDATE_SYNC=true): 5/5 passed (0 validation/sync-validation errors)
  • Related validation runs (LEONIDA_VK_VALIDATION=1): d3d12_descriptor_test.exe, d3d12_compute_test.exe, vk_queue_test.exe, vk_queue_query_sync_test.exe — all passed (0 validation errors)
  • python -I tests/test_ctest_registration.py -v: 4/4 OK; git diff --check clean; CRLF count 0.

AI-assisted (Gemini, Antigravity); no game files.

@Parakeet-Wheat

Copy link
Copy Markdown
Contributor

Tested 0a2b0ee on an RTX 3070 (610.88, Windows 11 26300, MSVC VS 2022, Windows SDK 10.0.26100), with the validation layer: fail, one regression outside the new test. vk_bindless_queue_sync_test passes all 8 checks (0–7) with 0 validation errors, and the queues are distinct here (A family=0, B family=2). Full ctest is 154/155: replay_query_edges fails with FAIL: queue segment allocation and failed submit: mock queue initialized. It passed at 11d905f (155/155 in my earlier run), and the test file is unchanged on current main 7b7d73f8. The PR now conflicts with that main in vulkan_backend.h, so it needs a rebase anyway, and the failure would come along with the guards.

Cause. That test builds VulkanContext on a mocked driver table, so context.loaded() is false there, but before this commit VulkanQueue still came up and replayed. The two new guards stop it: if (!context.loaded()) return; in the VulkanQueue constructor, and !context_.loaded() in execute_now().

  • With only the constructor return removed, the test gets past mock queue initialized and then fails the next check: failed submission frees exact six/five-slot pools.
  • With loaded() returning true, which affects only these two guards (nothing else in the backend calls context.loaded()), replay_query_edges_test exits 0.

To fix it, either give the mock a table that makes loaded() true, or have the guards check only what the timeline change needs, for example bindless_timeline_ creation, rather than loaded() as a whole.

Controls on vk_bindless_queue_sync_test. Each one changes one thing:

Change Result
no consumer wait (if (false) in prepare_bindless_sync) subtest 1 fails: waits=0 blocked=0 mask=0 found=0
host vkGetSemaphoreCounterValue elision put back (skip the wait when the counter already reached pending) subtest 3 fails at line 539 (waits_completed_first >= 1)
VK_SHARING_MODE_EXCLUSIVE instead of CONCURRENT in vulkan_bindless.h check 0 fails at line 360 (check_sharing(rec))
wait on every submit ((bindless_recorded || needs_bindless_read) → (true)) fails at line 464 (last_wait_count == 0)

So the new test now pins @Flyander's P1 (first-consumer wait after host-observed completion), the P2 gating, and the CONCURRENT sharing mode that @Zombins2 and I flagged, on NVIDIA too. The only blocker I see is replay_query_edges.

AI-assisted (Claude Code).

@Persudes

Copy link
Copy Markdown
Contributor Author

Fixed the replay_query_edges mock-queue regression reported by @Parakeet-Wheat in 3fa273a4:

  1. Decouple VulkanQueue initialization from full-device loaded_ (
    untime/src/vulkan_backend.h):
    • replay_query_edges_test constructs VulkanContext on a query-only mock table where vkCreateSemaphore and vkDestroySemaphore succeed, even though other device functions are unpopulated so loaded_ == false.
    • VulkanContext now tracks bindless_sync_failed_ independently of loaded_ and creates bindless_timeline_ whenever vk.vkCreateSemaphore && vk.vkDestroySemaphore are provided, setting both bindless_sync_failed_ = true and loaded_ = false only when vkCreateSemaphore fails (and guarding ~VulkanContext() on vk.vkDestroySemaphore).
    • VulkanQueue constructor, execute_now(), and submit() now check bindless_sync_failed() rather than !loaded(), and idle() guards missing vkQueueWaitIdle.
  2. Align VulkanQueue::submit() with PR fix(runtime): use context-owned timeline semaphore for cross-queue storage init #4561:
    Generalized submit() to take std::span<const TimelineOp> extra_waits, std::span<const TimelineOp> extra_signals.

Verification at 3fa273a4 (Windows 11 x64, AMD Radeon RX 6900 XT Adrenalin 26.11.2, Vulkan 1.4.315 / SDK 1.4.363.1)

  • replay_query_edges_test.exe (standard & LEONIDA_VK_VALIDATION=1): passed (exit 0).
  • vk_bindless_queue_sync_test.exe (checks 0..7 ok, exit 0): 3/3 standard, 5/5 LEONIDA_VK_VALIDATION=1, 5/5 LEONIDA_VK_VALIDATION=1 + VK_KHRONOS_VALIDATION_VALIDATE_SYNC=true.
  • Related validation runs (LEONIDA_VK_VALIDATION=1): vk_queue_test.exe, vk_queue_query_sync_test.exe, d3d12_descriptor_test.exe, d3d12_compute_test.exe — all passed (exit 0).
  • python -I tests/test_ctest_registration.py -v (4/4 OK), python -I scripts/check_no_game_data.py (exit 0), git diff --check -- runtime/src/vulkan_backend.h clean, CRLF=0.

Thank you @Parakeet-Wheat for isolating the exact loaded() cause and running all four negative controls, and @shdann for dual-GPU testing!

(Note: I also tested merging upstream/main locally, which only had a trivial conflict with zero_on_next_submit at the submit() call site in vulkan_backend.h, but GitHub rejects pushing commits that include upstream/main's .github/workflows/{ci,runtime}.yml updates until the fork's OAuth token is refreshed with workflow scope.)

AI-assisted (Gemini, Antigravity); no game files.

@Parakeet-Wheat

Copy link
Copy Markdown
Contributor

Retested 3fa273a on the same RTX 3070 (610.88, Windows 11 26300, MSVC VS 2022), with the validation layer, on its own base (it still conflicts with current main): pass. Full ctest is 155/155, so replay_query_edges passes again. vk_bindless_queue_sync_test passes all 8 checks (0–7) with 0 validation errors. Thanks @Persudes. The one build warning (C4456 in xgameruntime_test.cpp) is in a file this PR doesn't touch.

Control on the new submit() plumbing. With has_extra_waits = true; removed, so a bindless wait in extra_waits never reaches vkQueueSubmit, subtest 1 fails (waits=0 blocked=0 mask=0 found=0). The test therefore covers the TimelineOp span path as well. prepare_bindless_sync() and the sharing-mode code are unchanged since 0a2b0ee, where the four earlier controls all failed as they should.

AI-assisted (Claude Code).

@memorypressure

Copy link
Copy Markdown

FAIL to merge, verified: git merge-tree conflicts exactly in runtime/src/vulkan_backend.h against current main. At the PR head the build_runtime suites pass (1 + 4 with the documented skip); the new vk_bindless_queue_sync_test was not built, but its embedded compute probe passes static spirv-val and the disassembly matches the described GLSL probe. Two suggestions: include the GLSL source alongside the embedded words so provenance and regeneration are checkable, and note #4224 also edits vulkan_backend.h and CMakeLists — the rebase should anticipate it. Main's bb36812 is related submission work, not this bindless-upload protocol, so rebase rather than close. No CI checks reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@editrice

Copy link
Copy Markdown

Rebase integration note for head 3fa273a4 against current main 3faac557: the conflict in runtime/src/vulkan_backend.h includes the newer zero-on-first-submit path. Main’s failed-submit branch checks !storage_images.empty() || !zero_buffers.empty() and reinserts both sets into their pending queues; its successful-submit path also publishes the initialization fence when zero_buffers were filled. This PR’s old-side block checks and restores storage_images only. Taking that block during conflict resolution would lose a zero-buffer obligation after a transient vkQueueSubmit failure, so a retry could use uninitialized buffer contents. Please retain main’s zero_pending_.insert(...) and both conditions while layering the bindless timeline waits/signals. If #4672 lands first, its lock-through-rollback ordering also needs to survive the rebase. AI-assisted static integration review; no game data.

@Zombins2

Copy link
Copy Markdown

AI-assisted. No game files used.

A rebase note for @Persudes: #2740 merged on 2026-11-23 at 11:36Z and includes a8fae90, which adds another bindless-upload wait to main. At main 1cc6e3c1, the shim calls note_bindless_upload() only when flush() reports last_flush_replaced(). After successful submission, the backend publishes the uploading queue's progress semaphore/value and a version checked through each queue's bindless_upload_seen_. This overlaps the PR, but tracks replaced generations rather than every recorded upload.

Setup:

  • Main 1cc6e3c1 plus one local test file and a CMake target registration; runtime source unchanged.
  • That file uses this PR's probe shader and vkQueueSubmit interceptor, copied unchanged from 11d905f.
  • Its prepare callback calls record_fallback_init, then flush(cb, submitted_retire_ticket()), and note_bindless_upload() only on a successful replacing flush. It omits the shim's descriptor lock and retired-generation/legacy-idle bookkeeping; this is a single-threaded component probe.
  • In each case, queue A's submission carries the flush and waits on a gate the host holds; queue B then dispatches the probe, and the host waits 50 ms for B before releasing the gate.
  • Ryzen 5 7600X iGPU (RDNA2 gfx1036, AMD 26.10.1), no validation layer. The main run puts queues A and B in the same family (family 0, two distinct VkQueues). Main's bindless resources are EXCLUSIVE; keeping both queues in family 0 removes the cross-family ownership confound.
  • 50 runs, the same result in every run:
case, on main, A and B both in family 0 waits on B's dispatch submit B's 50 ms wait (gate still held) B read (expected)
first table upload (PR subtest 1's scenario) 0 VK_SUCCESS: B finished first mask=0 found=0 (63 / 42)
new key added in place, no new generation (PR subtest 4's scenario) 0 VK_SUCCESS: B finished first mask=63 found=0 (63 / 77)
existing key's index changed, new generation (control) 1 VK_TIMEOUT mask=63 found=55 (63 / 55)

In both non-replacing cases, B completed while A's upload was still gated and returned the unexpected values shown above. For the replaced generation, B's 50 ms wait timed out; after gate release, B returned the expected values. Generation counts stayed at 0 through the in-place addition and became 1 on replacement, matching the last_flush_replaced() gate. These are observed results with the dependency missing, not guaranteed stale-table contents. A second 50-run set with B on family 1 gave the same rows and values, but its EXCLUSIVE resources span two families, so I'm not relying on its values.

The probe has no pending storage-image initialization or buffer zeroing. In production, either can publish storage_init_semaphore_ from the uploading submission and so make another queue wait incidentally. Explicit application fence waits can also order work. This is not a D3D12-level reproduction or a claim that every first use is unordered. On the same iGPU, the PR's own vk_bindless_queue_sync_test at 3fa273a4 passes all 8 checks (0–7), 50/50. That is a separate test on the PR's existing base, not a rebased comparison.

For the rebase:

  • Taking main's prepare callback unchanged would leave non-replacing uploads unnoted by that mechanism. Please preserve coverage of those uploads when integrating the two protocols, as well as main's retirement-ticket argument, descriptor locking and retired-generation handling. I did not test a merged version.
  • Main's comment that every D3D12 queue uses info.queue_family does not cover all configured paths: CreateCommandQueue can select compute_family / copy_family, and the picker can retain distinct families. Sparse-capability fallback and the graphics-family-only setting can instead collapse them. Cross-family sharing/ownership still needs consideration during the rebase; the PR's share() and check 0 address CONCURRENT sharing. This is source reading, not evidence of which families the D3D12 shim selects on this iGPU.
  • The local merge also conflicts in d3d12_vulkan_device.cpp's prepare callback. @editrice's separate zero_buffers preservation note still applies.

Scope: VulkanContext/VulkanQueue/BindlessSet directly; no NVIDIA, validation-layer or rebased-build coverage here, and no new mutants of 3fa273a4. I can share the test file.

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.

9 participants