Skip to content

BUILD-1655: per-operation Vulkan DRED breadcrumbs (LEONIDA_DRED=2) - #5314

Closed
AimLogin wants to merge 13 commits into
ProjectLeonida:mainfrom
AimLogin:claim/BUILD-1655-dred-per-op
Closed

AimLogin wants to merge 13 commits into
ProjectLeonida:mainfrom
AimLogin:claim/BUILD-1655-dred-per-op

Conversation

@AimLogin

@AimLogin AimLogin commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

BUILD-1655 (claim), a follow-up to D3D-264.

Depends on: #3293. This branch (head a7b1f6d4) is built on #3293's head accf0263, which has main 8575d36e merged in. Until #3293 is merged, the diff below includes it; the BUILD-1655 part alone is accf0263...a7b1f6d4.

Why

#3293 tells which command lists the GPU started and finished. Its *pLastBreadcrumbValue is always 0, because it doesn't know how far a started list got. With a list of thousands of draws, "list X was running" is a weak lead. This PR records progress per D3D12 operation, so a node says how many of the list's operations the GPU finished.

What

Three levels (LEONIDA_DRED, read once):

Level Records GPU cost
unset / anything else nothing; one null check per command in replay none
1 (#3293) a breadcrumb per command list: begin word at TOP_OF_PIPE, end word at BOTTOM_OF_PIPE ≈ none
2 (this PR) level 1, plus a progress marker after every D3D12 operation ≈ 0.4 µs per operation on an RTX 4060 Ti

Level 2 is its own level, not part of =1, because it roughly doubles GPU time for small operations (table below). =1 stays cheap enough to leave on.

How the progress is recorded (vulkan_breadcrumbs.h, vulkan_replay.h emit(), vulkan_backend.h):

  • Op numbers. mark() notes each D3D12 operation of a list together with the index of the IR command it stands for, and gives the list a range of 32-bit op numbers under the ring's lock. Numbers are never 0, and a range never spans 0.
  • Markers. emit() writes first + k into the list's slot word at BOTTOM_OF_PIPE once operation k's command is recorded. The marker goes in at the top of the next loop step, or after the loop, where no rendering scope is open: every draw and clear opens and ends its own.
  • Reading the word. BOTTOM_OF_PIPE writes only after every earlier command of the queue has finished, so the word counts operations finished in order. Only a word in the list's own range counts (word - first < count, unsigned). The initial 0, an older range, or one across the 32-bit wrap reads as "none finished", never as more.
  • Slot reuse. At level 2 a ring slot is taken over only once its previous owner is seen finished, i.e. its end word holds its tag. A finished list writes nothing more, so no older list's marker can land in the new owner's word, however many op numbers were handed out in between. The range check alone wouldn't rule that out: a list stuck on another queue could write after 2^32 op numbers.
  • All slots busy. If all 1024 slots hold lists the GPU hasn't been seen to finish, the new list gets its list markers only, and its progress is reported as unknown. A failed submission frees its slot at once, since it never runs.
  • Memory. The command positions are dropped at submission, so the history keeps one uint32 per operation, as at level 1. The ring is 1024 slots × 16 bytes.

D3D12 outputs (d3d12_dred.h):

  • BreadcrumbCount: the list's operations.
  • pCommandHistory: their D3D12_AUTO_BREADCRUMB_OPs, in order.
  • *pLastBreadcrumbValue: the number the GPU finished, at level 2.
  • NODE and NODE1 share the same arrays.
  • At level 1, or when progress is unknown, *pLastBreadcrumbValue stays 0. D3D12 has no "unknown", so 0 is a lower bound, never a guess.

Report (stderr): a started list reads one of:

  • "K of N operations completed", when observed;
  • "progress inside the list not recorded", at level 1;
  • "GPU progress UNKNOWN", without VK_AMD_buffer_marker.

Docs: docs/d3d12_vulkan.md §4.11.

Tests

Observed on the GPU, with validation and synchronization validation:

  • vk_breadcrumbs:
    • every operation of a finished list reads finished: 3 + 1 operations in one submission, a list reset and recorded again, a held batch, two queues on two threads (800 lists), and a 1026-list ring wrap;
    • op numbers across the 32-bit wrap, starting at 0xfffffffd;
    • with list markers only, no per-op progress is claimed.
  • d3d12_dred_off, d3d12_dred_on and the new d3d12_dred_ops (LEONIDA_DRED=2).

Mocks, with markers counted and not written, and a controlled loss (vk_device_lost):

  • after a loss no list claims an operation finished;
  • the marker count is exactly 2 per list plus 1 per operation;
  • with all 1024 slots held by unfinished lists, the next list gets no per-op marker and its progress is unknown.

Synthetic, not observed on a GPU:

  • the range check: never written, a previous owner, a later owner, the 32-bit wrap, an empty list;
  • a list stopped partway: 2 of 4, 0 of 2, and unknown;
  • BreadcrumbCount, pCommandHistory order and *pLastBreadcrumbValue, node by node in NODE and NODE1;
  • the three report forms.

A list can't be held on the GPU between two of its own operations without risking a hang, so partial progress is only tested this way.

Full ctest, RelWithDebInfo (MSVC), LEONIDA_VK_VALIDATION=1 plus synchronization validation, implicit layers off. RTX 4060 Ti, driver 621.01, Windows 11 26200. These are the original measurements, on main 3faac557:

Tree LEONIDA_DRED unset =1 =2 VUIDs
#3293 abd80129 173/173 173/173 — 0
this PR 174/174 174/174 174/174 0

The only new test is d3d12_dred_ops, and the validation output matches abd80129's. The same 8 tests skip (no game package, corpus, LEONIDA_FIRST_LIGHT_DIR or RGB9E5 RTVs), and gameinput is disabled by default.

Current head a7b1f6d4 (on main 8575d36e, same machine and settings). Its tree is byte-identical to the tree that was tested.

  • Full ctest, LEONIDA_DRED=2: 270/274. The 4 failures also fail on unchanged main 8575d36e (264/269 there): vk_queue (sync-validation hazards), d3d12_vulkan_device, d3d12_indirect_dispatch_count and d3d12_mesh.
  • VUIDs: none new. The only VUIDs are the 6× VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 from main's mesh statistics, which main shows too.
  • DRED tests with LEONIDA_DRED unset and =1: 13/15 each, with the same two main failures. These are vk_breadcrumbs, vk_device_lost, d3d12_dred_off/on/ops, d3d12_queue_share, vk_queue, d3d12_mesh and vk_sync_validation.
  • What passes at every level: the A/B/C slot-ownership case, the 32-bit op wrap, the 1026-list ring wrap, two queues on two threads, and the marker buffer CONCURRENT across queue families.
  • Nothing is tested against a real device loss.

Cost

Lists of N operations, each a 16-byte copy and a copy → copy barrier, best of 7, three runs. These are tiny operations, so the cost per operation dominates. Record is execute() on the CPU; wait is the GPU finishing after it. NVIDIA only so far: other drivers may implement buffer markers differently.

N record: off / level 1 / level 2 (ms) wait: off / level 1 / level 2 (ms)
100 0.04–0.05 / 0.04 / 0.05–0.07 0.08–0.10 / 0.08–0.09 / 0.12–0.14
1,000 0.24–0.26 / 0.25–0.27 / 0.31–0.33 0.43–0.45 / 0.44–0.45 / 0.84–0.89
2,000 0.47–0.49 / 0.49–0.51 / 0.58–0.60 0.82–0.84 / 0.82–0.84 / 1.63–1.71
10,000 2.3–2.6 / 2.4–2.6 / 2.9–3.3 3.9–4.3 / 3.9–4.2 / 8.1–8.7

Limits

  • Bundles. ExecuteBundle copies the bundle's commands into the calling list, so the history lists the bundle's own operations. The host runtime lists one EXECUTEBUNDLE instead. The progress is right, but finer than on the host. Recording the bundle boundary is a possible follow-up.
  • ExecuteIndirect. One operation, whatever its argument buffer holds.
  • Predication. An operation the predicate skipped, or one the layer records as a no-op, counts as finished, as on the host.
  • Marker reuse. The slot guard assumes that a list's earlier marker writes are visible before its end word. Both are written by the same queue, in order, but the Vulkan spec doesn't guarantee the order in which the host sees two marker writes. A late write can only lower the progress shown, never raise it.
  • No real GPU device loss was tested. What a driver leaves in the words after a hang or fault isn't covered. No AMD or Intel results yet.

No game files.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

AimLogin and others added 4 commits November 22, 2026 21:00
With LEONIDA_DRED=1 the Vulkan layer records per-command-list breadcrumbs
(VK_AMD_buffer_marker; CPU-only with UNKNOWN progress without it), reads
VK_EXT_device_fault on a loss, prints one report, and answers
ID3D12DeviceRemovedExtendedData/1/2 as the host runtime does. Off by
default; the Xbox-ABI device proxy is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts in runtime/src/vulkan_backend.h: main's event functions and
the two optional DRED functions both stay in the device function list;
after submit(), main's wait clean-up runs first, then the breadcrumbs
keep the marks only if the submission succeeded.

main's SetName now keeps the name apart from the private data
(Object::debug_name()), so ExecuteCommandLists takes the DRED names
from there; the GetPrivateData-based dred_debug_name() is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Preserve the optional Vulkan DRED hooks alongside main's new device
functions and adapt deferred command-list batches to keep their
original diagnostic names.

Fix stale queue-name reuse and protect DRED snapshots under their
own mutex. Add regression coverage for deferred batches and
reused object addresses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_DRED=2 adds a progress marker after every D3D12 operation, on
top of ItsNotRexed#3293's per-list breadcrumbs (LEONIDA_DRED=1), so a device-lost
report and D3D12's *pLastBreadcrumbValue say how many of a started
list's operations the GPU finished.

- Ring: four words per slot (begin, end, progress, padding). mark()
  gives each list a range of 32-bit op numbers (never 0, never spanning
  0) and notes each operation's IR command index; emit() writes
  first + k at BOTTOM_OF_PIPE after operation k, between commands where
  no rendering scope is open. Only a word inside the list's own range
  counts, so anything foreign reads as "none finished", never as more.
- Slot reuse: at level 2 a slot is taken over only once its previous
  owner wrote its end word, so no older list can still write into it
  whatever the op count in between. With every slot held by unfinished
  lists, the new list gets list markers only and its progress is
  unknown. A failed submission frees its slot.
- Unknown is said as such: at level 1, or without a safe slot, a
  started list's progress is "not recorded", not 0 completed;
  *pLastBreadcrumbValue stays 0 there as a lower bound. NODE and NODE1
  share the count, history and value.
- The per-op command positions are dropped at submission; the history
  keeps one uint32 per operation, as before.
- Cost on an RTX 4060 Ti: level 1 about free, level 2 about 0.4 us of
  GPU time per operation (twice the GPU time for 10,000 small copies),
  hence its own level.
- Tests: vk_breadcrumbs (GPU: several operations, reset and reuse,
  held batches, two queues, 1026-list wrap, op numbers across 2^32,
  list markers only; cost table), vk_device_lost (no progress claimed
  after a loss, marker counts, every slot busy), d3d12_dred_test
  (synthetic partial progress, node-by-node NODE/NODE1), and the new
  d3d12_dred_ops (LEONIDA_DRED=2).
- Docs: docs/d3d12_vulkan.md section 4.11.

Depends on ItsNotRexed#3293.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@DoubleD17 DoubleD17 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.

The all-slots-busy fallback can make a later list's per-operation progress unreliable across queues.

At 160a72d66486cf82078ebb6ed60f0818512cd959, BreadcrumbRing::mark() leaves progress_safe false when all slots are busy, but still replaces owner_[m.slot]. The fallback list still writes its end tag via record_end().

Consider a full ring where an earlier list A still holds a slot on queue 1. An overflow list B takes it on queue 2 and writes its end tag. A subsequent list C now sees B's end tag match owner_ and gets progress_safe = true, although A can still write into the slot. When A resumes, its older operation tag can overwrite C's progress word. C's range check then reports zero completed operations even if its first marker was already visible. This needs no sequence wrap.

Can the overflow lists use CPU-only history, leaving the GPU slot owner in place until its actual writer finishes? The regression case needs an overflow list that finishes before the old owner, followed by another reservation. I traced the pinned source and verified the ordering with an independent CPU model of the marker words. I did not build or execute the PR or test this ordering on a GPU.

No game files. AI-assisted.

@AimLogin

Copy link
Copy Markdown
Contributor Author

Thanks @DoubleD17, the trace holds. At 160a72d6, the all-slots-busy branch of BreadcrumbRing::mark() sets progress_safe = false but then still runs owner_[m.slot] = m.tag (line 359). record_begin()/record_end() still write the overflow list's tags, so its end word can make the slot look free while A, the actual writer, is still pending.

The same overwrite also drops A's own entry from snapshot(), because owner_ no longer holds A's tag. An unfinished list can then disappear from the device-lost report.

I'm fixing it along the lines you suggest. An overflow list keeps CPU-only history: it gets no begin, end or per-op markers, owner_ stays with the slot's real owner, and its GPU progress reads as unknown. There will be a deterministic regression test for your A/B/C order. I'll report the test results here once they've run; until then this is a plan, not a fix.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Head 160a72d66. git diff --check clean. Delta reviewed: abd80129..160a72d6 (BUILD-1655, 10 files, +444/-46); the rest of the diff vs main is #3293.

  • Configured with vcvars64 + Ninja and the stated Vulkan 1.4.363 options; built d3d12_dred_test, vk_breadcrumbs_test, vk_device_lost_test.
  • LEONIDA_VK_DEVICE='RTX 5070 Ti' ctest -R "vk_breadcrumbs|vk_device_lost|d3d12_dred" --output-on-failure -> 5/5 passed.
  • Output includes breadcrumbs: per-operation progress over 3 + 1 operations and a reset list ok, ... across the 32-bit wrap of op numbers ok, breadcrumbs: 1026 lists across a ring wrap ok, breadcrumbs: 0 validation errors; d3d12_dred_off/on/ops all passed.
  • python -I tests/test_docs_*.py and test_boot_trace.py OK.

Verdict: approve the BUILD-1655 delta; blocked on #3293, which is open. This branch is #3293's abd80129 + one commit, so it cannot merge on its own without carrying #3293's ~2.1k-line diff. Partial progress inside a list is synthetic only (a real list cannot be held on the GPU between its own ops), as the PR says.

Review of ProjectLeonida#5314 (DoubleD17): with every slot held by an unfinished list,
mark() left progress_safe false but still overwrote owner_[slot], and
the overflow list still recorded its begin and end markers. Its end tag
made the slot look free while the slot's real owner, possibly on another
queue, could still write into it. A later list then took the slot and
read too little progress, and the unfinished owner dropped out of the
device-lost report.

- A list that finds no slot whose owner is seen finished takes none
  (kNoSlot). It records no GPU marker at all, changes no owner_ and no
  next_slot_, and is kept as CPU history with its GPU progress unknown:
  no D3D12 node, and "every breadcrumb slot was busy" in the report,
  counted apart from the lists that did not complete. A slot is used
  again as soon as its owner's end word shows.
- A failed submission frees only a slot it really took.
- History: the oldest list that no longer holds a slot is dropped first.
  A list that still holds its slot, finished or not, stays; up to 64
  others are kept besides.
- The begin marker of a list with per-op markers clears the progress
  word, so the previous owner's last op number does not sit there.
- Tests: vk_breadcrumbs slot_ownership() runs the A/B/C order on a ring
  whose GPU writes are the test's own (it fails at 160a72d), plus failed
  submissions, history and CPU only. Also the marker counts in
  vk_device_lost, and the no-slot entry (no node) and a 0-op node in
  d3d12_dred_test.
- Docs, section 4.11: the fallback, and what the Vulkan spec guarantees
  about marker order (per queue, execution only toward the host).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AimLogin

Copy link
Copy Markdown
Contributor Author

@DoubleD17, fixed in fa0c0f17, and reproduced first: your A/B/C order fails at 160a72d6.

  • Fix. A list that finds no slot whose owner is seen finished now takes no slot (kNoSlot). It records no GPU marker at all (no begin, end or per-op one), leaves owner_ and next_slot_ alone, and stays in the history as CPU knowledge with its GPU progress unknown. That means no D3D12 node, and "every breadcrumb slot was busy" in the report, counted apart from the lists that did not complete. A slot is used again once its real owner's end word shows.
  • Same mechanism, two more paths:
    • A failed submission used to free a busy slot it had taken; it now frees only a slot it really took.
    • The history used to push out an unfinished owner after 1024 later lists; it now drops lists that no longer hold a slot first.
    • The begin marker also clears the progress word, so a previous owner's last op number doesn't sit there.
  • Test. vk_breadcrumbs slot_ownership() runs your order deterministically on a ring whose "GPU" writes are the test's own. The checks: B and C change no slot word, A stays in the snapshot, a freed slot is reused by exactly the next list, failed submissions behave, and CPU-only mode never claims progress. It fails at 160a72d6 (B's marker lands in A's slot) and passes now.
  • Results. Full ctest passes 174/174 without LEONIDA_DRED, with =1 and with =2, with 0 VUIDs, under validation and synchronization validation (RTX 4060 Ti, 621.01). The validation output matches D3D-264: opt-in DRED device-loss diagnostics for Vulkan #3293's.
  • Still best effort. The Vulkan spec orders marker writes per queue, as an execution dependency. It doesn't promise that the host sees them in that order without a fence wait, or anything after a device loss. The slot guard therefore relies on the host seeing a list's op markers no later than its end marker. That holds on AMD and NVIDIA in practice, and §4.11 now says so. A late write can only lower the progress shown, never raise it. No real device loss was tested.

Thanks for the careful trace.

@AimLogin

Copy link
Copy Markdown
Contributor Author

Status of this PR. The branch is unchanged on GitHub: the head is still fa0c0f17, which includes the overflow fix. Everything below is local. No new commits have been made and nothing has been pushed yet. This PR still depends on #3293 (status there), so it stays a draft until #3293 is merged.

The overflow fix (fa0c0f17) was checked again.

  • @DoubleD17's A/B/C order is still deterministic in vk_breadcrumbs slot_ownership(). It fails at 160a72d6 and passes at fa0c0f17.
  • An independent CPU model of the ring (a separate review, not the test) ran 30 trials of 20,000 steps. It used two queues, held batches, 5% failed submissions and a stalled queue that fills every slot. In those trials no list that was in flight or held lost its slot, the history never grew past kSlots + kNoSlotKept, and at most 1024 lists held a slot at once.
  • The behaviour that stays:
    • A list that finds no slot whose owner is seen finished gets kNoSlot. It writes no GPU marker, leaves owner_ and next_slot_ alone, and is kept as CPU-only history with UNKNOWN progress and no D3D12 node.
    • A failed submission frees only a slot it really took.
    • Eviction drops lists that no longer hold a slot first.
    • The CPU-only ring (no VK_AMD_buffer_marker) never claims progress.
  • Levels: LEONIDA_DRED=0 (off), =1 (per list) and =2 (per operation, with 32-bit op ranges and their wrap) all work as before.

Stacked on the updated #3293.

  • The local tree is D3D-264: opt-in DRED device-loss diagnostics for Vulkan #3293 merged with main 1cc6e3c1, plus all of abd80129..fa0c0f17. BUILD-1655's diff against that base is identical, line for line, to what it was against the earlier base.
  • Both PRs add a parameter to BreadcrumbRing::initialize() / configure_breadcrumbs(), so they are combined as (…, bool per_op = true, std::span<const std::uint32_t> queue_families = {}).
  • The buffer size stays kSlots * kWords (four words per slot). Keeping D3D-264: opt-in DRED device-loss diagnostics for Vulkan #3293's two-word size would have put the progress word outside the buffer.
  • The device passes dred_level() >= 2, state_.families. So D3D-264: opt-in DRED device-loss diagnostics for Vulkan #3293's VK_SHARING_MODE_CONCURRENT fix covers the per-op markers too.
  • The per-op markers stay outside any rendering scope after main's render-pass change (D3D-417): every draw and clear opens and closes its own scope.

Doc and comment corrections (local).

  • The history bound. The old text said that besides the slot holders, at most 64 lists without a slot are kept. That was wrong: only the total is bounded, at kSlots + kNoSlotKept = 1088. At least the newest 64 slotless lists stay, and more while fewer than 1024 lists hold a slot. The code was already right; the comment and §4.11 now say this.
  • Marker semantics. As in D3D-264: opt-in DRED device-loss diagnostics for Vulkan #3293, started from a begin word is a lower bound. At level 2, a progress word in the list's range is real evidence that an operation finished. "Queue" means the VkQueue.

Tests. RTX 4060 Ti (621.01, Windows 11, MSVC), LEONIDA_VK_VALIDATION=1, synchronization validation. Hazards are counted as well as VUID- messages.

Tree ctest
main 1cc6e3c1 258/260: vk_queue (10 sync hazards, main's own) and d3d12_indirect_dispatch_count; 0 VUIDs
this PR on 1cc6e3c1, DRED off / =1 / =2 pending: the build and the three runs are queued behind #3293's
earlier run, this PR on 561b65a8, DRED off / =1 / =2 251/252 each; 0 VUIDs; the one failure is main's d3d12_indirect_dispatch_count
after the doc changes, targeted breadcrumbs|device_lost|dred 6/6 at each level on 561b65a8, 0 VUIDs

Limits.

  • A real device loss is untested. The device-loss paths use mocks. After a real loss, the marker words are best effort.
  • Performance. At level 2 on this GPU, 10,000 small operations take about 8.4–8.7 ms against about 4.1 ms at level 0/1. That is an earlier measurement; it is not repeated here, and AMD and Intel are unmeasured.
  • A known slow path, not fixed here. When every slot is busy (a stuck GPU), each mark() scans all 1024 slots under the ring's lock. That is a possible follow-up.

Next. After #3293's head is updated, I'll merge it into this branch on top of fa0c0f17 (no rebase, no force-push), add the doc commit, and post the numbers. @DoubleD17 and @Kam471, a re-review of the stacked delta then would be very welcome. The parts worth checking are slot_ownership() and the combined initialize() signature. I'll mention you here when it's up.

AI-assisted (Claude Code). No game files.

AimLogin and others added 5 commits November 23, 2026 17:05
Conflicts in runtime/CMakeLists.txt, runtime/shims/d3d12_com.cpp and
runtime/src/vulkan_backend.h. Each is resolved by keeping both sides:
- Held batches keep DRED's origins and names and main's pins.
  run(Deferred) passes the origins and names and sets main's
  held_failure_.
- execute_now() keeps main's wait_for_room() and KHR instance staging,
  and adds the DRED identity and held-name parameters.
- The marker loop runs over lists.size(), because main keeps prepared_
  larger than the batch.
- ExecuteCommandLists labels for DRED, then calls main's
  execute(recorded, pin_lists).
- The device-function list keeps main's render-pass entries; the two
  optional DRED functions follow them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The direct, compute and copy queues (and the staging queue, on the
graphics family) all record breadcrumb markers into the ring's buffer,
from up to three queue families. There is no queue-family ownership
transfer, so an EXCLUSIVE buffer's contents become undefined on such a
device.

BreadcrumbRing::initialize() now takes the device's queue families. It
gets state_.families, which is deduplicated, skips UINT32_MAX and is
complete before configure_breadcrumbs() runs. With two or more families
the buffer is CONCURRENT among them; with one, or none given, it stays
EXCLUSIVE, as DeviceState::share does for the device's own resources.
vk_breadcrumbs reads the create info to check both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A begin marker at TOP_OF_PIPE is ordered after the earlier commands of
the queue, not before the list's own commands. So "started" says where
the GPU got in the queue, and "submitted" can lag a list that is
already running: both are lower bounds. "Completed" means execution
finished, not that the list's memory writes are visible. "Queue" here
is the VkQueue, so D3D12 queues that share one are ordered together.

This changes docs/d3d12_vulkan.md section 4.11 and the header comment
only. The code and the report strings are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in ItsNotRexed#3293's current head: main 1cc6e3c, the marker buffer
shared CONCURRENT across queue families, and the stated
started/submitted/completed guarantees.

Both sides add a trailing parameter to BreadcrumbRing::initialize()
and configure_breadcrumbs(), so they are combined as
(..., bool per_op = true, std::span<const std::uint32_t>
queue_families = {}). The device passes dred_level() >= 2 and
state_.families. The buffer keeps BUILD-1655's kSlots * kWords size,
because ItsNotRexed#3293's two-word size would put the progress word outside
the buffer.

vk_breadcrumbs runs both marker_buffer_sharing() and slot_ownership().
In section 4.11, the per-list and per-operation texts are combined,
and the begin-word guarantee now includes level 2's progress word.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment and section 4.11 said that, besides the slot holders, at
most 64 lists without a slot are kept. Only the total is bounded:
kSlots + kNoSlotKept = 1088 lists. Lists without a slot fill what the
slot holders leave, so at least the newest 64 of them stay, and more
while fewer than kSlots lists hold a slot. The code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AimLogin

Copy link
Copy Markdown
Contributor Author

Updated: the head is now 08be4be5, a fast-forward from fa0c0f17 with no force-push or rebase. It is still a draft, because it depends on #3293 (now at 6d6b2286, details).

Commit What
1677c265 Merge of #3293's published head 6d6b2286 (which carries main 1cc6e3c1). Both sides add a trailing parameter, combined as initialize(…, bool per_op = true, std::span<const std::uint32_t> queue_families = {}). The device passes dred_level() >= 2, state_.families. The buffer keeps kSlots * kWords. vk_breadcrumbs runs both marker_buffer_sharing() and slot_ownership().
08be4be5 The history bound is stated as it is: the total is at most kSlots + kNoSlotKept (1088), and at least the newest 64 slotless lists stay. Comment and §4.11 only.
  • The pushed tree is byte-identical to the tree I tested.
  • It contains fa0c0f17 (the overflow fix), all of abd80129..fa0c0f17, and 6d6b2286.
  • The overflow behaviour is unchanged: kNoSlot with no GPU markers, owner_ and next_slot_ untouched, CPU-only history with UNKNOWN progress, failed submissions freeing only their own slot, and eviction of slotless lists first.

Test results. These were run on that tree before the commit. RTX 4060 Ti (621.01, Windows 11, MSVC), LEONIDA_VK_VALIDATION=1, synchronization validation:

ctest VUIDs sync hazards
main 1cc6e3c1 258/260 0 10 in vk_queue (main's own) + 1 expected self-test
this PR, DRED off 262/265 (+1 flaky, see below) 0 the same as main
this PR, LEONIDA_DRED=1 263/265 0 the same as main
this PR, LEONIDA_DRED=2 263/265 0 the same as main
  • The two failures in each run are main's: vk_queue and d3d12_indirect_dispatch_count.
  • In the DRED-off run, vk_pipeline_check_cli also timed out once. Its --count usage check hit the script's 10-second limit on the first start of the freshly built tool. It then passed 5/5 reruns on the same build in about 0.45 s each, and this PR touches nothing in vk_pipeline_check.
  • vk_breadcrumbs (including the A/B/C slot-ownership case and the 32-bit op wrap), vk_device_lost and d3d12_dred_off/on/ops pass.

Limits.

  • A real GPU device loss is not validated.
  • The level-2 cost (about 2x GPU time on 10k tiny operations) was measured only on this GPU, earlier.
  • The full-ring mark() scan under the lock is a known slow path when a GPU is stuck.

Remaining conflict and CI. Against main 8575d36e the only conflict is the one #3293 has, the device-extension list in d3d12_vulkan_device.cpp. While it conflicts, GitHub runs no checks.

@DoubleD17 and @Kam471, could you re-review the stacked delta on the new head? The parts that changed since fa0c0f17 are 1677c265 (the combined initialize() signature and buffer size) and 08be4be5 (wording only). The slot-ownership logic you reviewed is unchanged.

AI-assisted (Claude Code). No game files.

AimLogin and others added 3 commits November 23, 2026 20:04
One conflict, in the device-extension list of
runtime/shims/d3d12_vulkan_device.cpp: main's VK_EXT_mesh_shader
(ItsNotRexed#2359, D3D-291) and DRED's optional VK_AMD_buffer_marker /
VK_EXT_device_fault both stay, main's first.

ItsNotRexed#2359's pipeline-statistics segments in execute_now() run before the
DRED marker loop and leave it unchanged. The loop is still over
lists.size(), begin and end markers are still paired, and
submitted() is still reached on every path after mark().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main records DispatchMesh as a Draw with `mesh` set (ItsNotRexed#2359). The
breadcrumb op table named it DrawInstanced. It is now
D3D12_AUTO_BREADCRUMB_OP_DISPATCHMESH (42, from d3d12.h), and the
report prints "DispatchMesh". There is still one op per draw, so op
counts, and BUILD-1655's per-operation positions, are unchanged.

vk_breadcrumbs checks that a mesh Draw maps to 42, an indexed one to
DrawIndexedInstanced and a plain one to DrawInstanced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in ItsNotRexed#3293's current head: main 8575d36, and DispatchMesh
reported as D3D12_AUTO_BREADCRUMB_OP_DISPATCHMESH (42). The merge is
clean. BUILD-1655 needs no change of its own: a DispatchMesh is still
one D3D12 operation, so its per-operation positions and op numbers are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AimLogin

Copy link
Copy Markdown
Contributor Author

@DoubleD17 @Kam471, #5314 has a new head, a7b1f6d4. It is a fast-forward with no force-push or rebase, and it is still a draft. Could you take another look at the BUILD-1655 delta?

What changed since you last reviewed (160a72d6):

  • Overflow race fixed (fa0c0f17, @DoubleD17's A/B/C case). A list that finds every slot busy gets kNoSlot: no GPU markers, owner_ and next_slot_ untouched, CPU-only history with UNKNOWN progress. The behaviour is unchanged since then.
  • New base. D3D-264: opt-in DRED device-loss diagnostics for Vulkan #3293 is now at accf0263, which carries main 8575d36e. a7b1f6d4 is a clean merge of it into 08be4be5, with no change of its own.
  • Queue families, from the base. The marker buffer is VK_SHARING_MODE_CONCURRENT across the device's distinct queue families, EXCLUSIVE with one. That also covers the per-op markers.
  • DispatchMesh, from the base. It is reported as D3D12_AUTO_BREADCRUMB_OP_DISPATCHMESH (42) and stays one operation, so op counts and positions are unchanged.
  • Signature. initialize() / configure_breadcrumbs() take (…, bool per_op = true, std::span<const std::uint32_t> queue_families = {}). The buffer stays kSlots * kWords.

The BUILD-1655 part alone: accf0263...a7b1f6d4.

Tests. The pushed tree is byte-identical to the one I tested: RTX 4060 Ti, 621.01, validation plus sync validation. Not everything passes; the failures are main's own:

  • Full ctest, LEONIDA_DRED=2: 270/274. The same 4 fail on unchanged main 8575d36e (264/269 there): vk_queue (sync hazards), d3d12_vulkan_device, d3d12_indirect_dispatch_count and d3d12_mesh.
  • VUIDs: none new. There are only the 6× VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 that main shows too.
  • DRED tests with LEONIDA_DRED unset and =1: 13/15 each, with the same two main failures.
  • What passes at every level: the A/B/C slot-ownership case, the 32-bit op wrap, the 1026-list ring wrap, two queues on two threads, and the CONCURRENT check.
  • Not tested: a real device loss.

GitHub now reports the PR as MERGEABLE; its checks are still queued.

AI-assisted (Claude Code). No game files.

@AimLogin
AimLogin marked this pull request as ready for review November 23, 2026 19:30
@YordiLorenzo

Copy link
Copy Markdown

Tested a7b1f6d on RTX 4070 SUPER, NVIDIA 621.01, Windows 11 Pro: pass

  • Build RelWithDebInfo, MSVC + Ninja, Vulkan SDK: ok
  • ctest -R "vk_breadcrumbs|vk_device_lost|d3d12_dred" with LEONIDA_VK_VALIDATION=1: 5 passed, 0 validation errors
  • d3d12_dred_ops ran with LEONIDA_DRED=2, per-operation progress cases ok
  • Per-op markers at 10000 ops: record 27.6 ms vs 21.1 ms with list markers only

@melesnaker-glitch

Copy link
Copy Markdown

Tested a7b1f6d47, squashed onto main 867d922f0 (it merges clean, with #3293's part included). Setup: NVIDIA GeForce RTX 3060, driver 610.88, Windows 11 (22631), MSVC 14.44 RelWithDebInfo, Ninja, Vulkan SDK 1.4.363.0, LEONIDA_VK_VALIDATION=1. Result: pass, no regressions.

  • Full ctest -j 2 with LEONIDA_DRED=2: 263/270 passed.
  • Unchanged main on the same machine and settings: 258/265.
  • The 7 failures are the same tests on both trees, so none comes from this PR:
Failing test (both trees) Covered by
vk_queue #5997
d3d12_mesh #7112
d3d12_indirect_rt #6010
d3d12_vulkan_device #7125
d3d12_depth_resolve #7905 / #7930
d3d12_execute_indirect_validation #7393 (this host is 22631)
d3d12_pso_validation #8540 (DYNAMIC_DEPTH_BIAS vs this host)

The 5 tests this PR adds pass at each level, with LEONIDA_DRED unset, =1 and =2: vk_breadcrumbs, vk_device_lost, d3d12_dred_off, d3d12_dred_on and d3d12_dred_ops.

This is a check of the current head on a second NVIDIA generation (Ampere), after the description's RTX 4060 Ti. I did not re-time the per-operation cost.

AI-assisted (Claude Code, Claude Opus 5.5).

@optinium51-bot

Copy link
Copy Markdown

Tested a7b1f6d47 merged onto main 5d74c2723 (clean merge) on NVIDIA GeForce RTX 3060 (driver 616.92), Windows 11 26200, MSVC 14.52 (VS 2026), RelWithDebInfo + Ninja: pass.

No game files. AI-assisted (Claude Code).

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.

7 participants