vkback: track dirty descriptor bindings per slot for null_slot #15
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!15
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-15"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@olafix52 on GitHub · 2026-11-30 17:46 UTC · original
olafix52:perf/null-slot-dirty-mask→main· +238 −27 · 4 files · 2 commits · merged 2026-11-30 22:35 UTCSummary
Tracks which of the 9
dbuf0descriptor bindings (0..=6atindex, plus4/5atindex + RAW_TWIN) have been written non-null per slot, sowrite_null_slot/Job::Nullwrites null descriptors only to dirty bindings instead of writing all 9 unconditionally.Changes & Invalidation (
AGENTS.mdrules 17, 18)descjob.rs: addSlotMasks(u16bitmask per slot for0..RAW_TWIN, falling back toALL_BINDINGS = 0x1ffpastRAW_TWIN),Job::Null { index, mask }, andBufJob::write_mask().null_fill(lib.rs) initializes every slot across all 9 bindings tonull_blobs[b], anduse_direct_descriptorscopiesdbuf0byte-for-byte, so initial mask0matchesdbuf0.dbuf0ORs its binding bits viaqueue_desc->aside_mark_desc, and viaBufJob::write_mask()inrun_job.write_null_slot(slotwrite.rs) queuesJob::Null { index, mask }for all dirty bits, or when a synchronousBufJobfails (Located::Uncommitted/Located::Short) and nullsj.null_mask.index >= RAW_TWINreturnsALL_BINDINGS(0x1ff).slotwrite.rs,bufview.rs,lib.rs: emitdirty_null_job(index)inwrite_null_slotand keepSlotMasksin sync viaaside_mark_desc/aside_take_dirty.AGENTS.mdrule 24): cuts descriptor-helper BAR write traffic cleanly during heavy slot-nulling windows.0..140world s runs passed with zero rendering differences or artifacts.Measurements
experimental-11.0-20261123b).0..140world s, warm shader store,VKTORY_LOCK=1 MEASURE=1,VKB_LAT+greenfield/tools/frec/frames.py 0 140 --no-perf), interleavedA B B A(measured pre-rebase86e1068vsmain7403bee; rebased cleanly onto8a3cb80with identical code diff):aside: descriptor bytes(ms/f)main(7403bee)null-slot-masknull-slot-maskmain(7403bee)aside: descriptor bytes) separates cleanly: 8.59 -> 6.27 ms/f (-2.32 ms/f, -27.0%). Overall FPS improves slightly (+0.20 fps, 23.94 -> 24.14) whilep50/p90stay within noise since the descriptor helper runs asynchronously from the renderer critical path.Verification (rebased
6ac2478on8a3cb80)cargo test -p vkback --lib -j 6: 146 passed, 0 failed, 3 ignored.cargo test -p vkback --test policy -j 6: 6 passed, 0 failed.cargo xtask policy:asset policy: 533 files ok.Skip redundant BAR descriptor writes when nulling a slot by tracking which of the 9 `dbuf0` descriptor bindings (`0..=6` at `index`, plus `4`/`5` at `index + RAW_TWIN`) have actually been written non-null for that slot. Changes & invalidation (`AGENTS.md` rule 17): - `descjob.rs`: add `SlotMasks` (`u16` bitmask per slot for `0..RAW_TWIN`, falling back to `ALL_BINDINGS = 0x1ff` past `RAW_TWIN`) and `Job::Null` with a per-slot binding mask; add `BufJob::write_mask()` and unit tests. - Startup matches `null_fill` / `use_direct_descriptors` (initial mask `0`). - Marked on every non-null `dbuf0` write (`queue_desc` -> `aside_mark_desc`, and `run_job` via `BufJob::write_mask()`). - Cleared when `write_null_slot` queues `Job::Null { index, mask }` or a synchronous `BufJob` fails (`Uncommitted`/`Short`) and nulls `write_mask`. - `slotwrite.rs`, `bufview.rs`, `lib.rs`: pass `dirty_null_job(index)` in `write_null_slot` and pass `aside_mark_desc` / `aside_take_dirty`. - Kept (`AGENTS.md` rule 24): reduces helper thread BAR write bandwidth (~72k-90k misses/frame) cleanly in scenes with heavy descriptor churn. Measured (prison cell, steady state, 0..140 world s, A/B/B/A vs `main`7403bee, AMD Ryzen 9 7900X + RX 9070 XT RADV Mesa 26.3.1, `VKB_LAT` + `frames.py 0 140 --no-perf`): - `aside: descriptor bytes`: 8.53 / 8.65 ms/f (A mean 8.59) -> 6.37 / 6.17 ms/f (B mean 6.27, -2.32 ms/f, -27.0%), cleanly separated. - Whole-frame FPS: 23.88 / 23.99 (A mean 23.94, mean 41.80 ms) -> 24.01 / 24.27 (B mean 24.14, mean 41.45 ms). - Verified locally with zero visual artifacts across the full 0..140 s run. Verification: - `cargo test -p vkback --lib -j 6` + `cargo test -p vkback --test policy -j 6` + `cargo xtask policy`: all pass.6ac2478c57to7447bc1867@olafix52 on GitHub · 2026-11-30 21:09 UTC · original
Rebased onto
main(74587c3, after #13), preservingslot_flagsgating inslotwrite.rs::write_null_slotand updatingdescjob.rs/slotwrite.rscomments. New commit:7447bc1.Re-verification
cargo test -p vkback --lib -j 6:148 passed; 0 failed; 3 ignoredcargo test -p vkback --test policy -j 6:6 passed; 0 failedcargo xtask policy:533 files okVulkan validation run (AGENTS.md rule 30)
Run under
VK_LAYER_KHRONOS_validation(1.4.363,VK_KHRONOS_VALIDATION_REPORT_FLAGS=error,VK_KHRONOS_VALIDATION_DUPLICATE_MESSAGE_LIMIT=3) on the available world save (78.0 sstartup +66.0 sin the world):docs/ROADMAP.md(Vulkan validation errors).VUID-RuntimeSpirv-None-06288VUID-VkBufferCreateInfo-size-06409VUID-VkComputePipelineCreateInfo-layout-01687VUID-VkDescriptorAddressInfoEXT-nullDescriptor-08938VUID-VkDescriptorAddressInfoEXT-range-08940VUID-VkDescriptorGetInfoEXT-type-12222VUID-VkDescriptorGetInfoEXT-type-12223VUID-VkExportMemoryAllocateInfo-handleTypes-09860VUID-VkGraphicsPipelineCreateInfo-layout-01688VUID-VkPipelineLayoutCreateInfo-descriptorType-03018VUID-VkPipelineLayoutCreateInfo-descriptorType-03024VUID-VkPipelineLayoutCreateInfo-descriptorType-03031VUID-VkPipelineLayoutCreateInfo-pSetLayouts-03039VUID-VkQueryPoolCreateInfo-meshShaderQueries-07069VUID-VkRayTracingPipelineCreateInfoKHR-layout-03428VUID-VkRenderingInfo-None-08994VUID-VkShaderModuleCreateInfo-pCode-08740VUID-VkShaderModuleCreateInfo-pCode-08742VUID-vkBindImageMemory-memory-02728VUID-vkCmdClearColorImage-image-00007VUID-vkCmdCopyBuffer-srcBuffer-00118VUID-vkCmdCopyBufferToImage-dstImage-00177VUID-vkCmdCopyImage-srcImage-01548VUID-vkCmdFillBuffer-dstBuffer-00029VUID-vkCmdPushConstants-size-arraylength@vktory6 on GitHub · 2026-11-30 22:34 UTC · original
Thanks: skipping null writes into bindings that still hold null is the right fix, and the startup state, the twin bits and the failure reset all line up. I rebased it onto current main and pushed one commit on top (989a01e), then squash-merge:
queue_write(now indescjob.rs) reports a write to the resource descriptor buffer as an invariant break; those writes go throughqueue_descor a descriptor job, which keep the marks (both usequeue_write_raw). A future writer that would bypass the marks shows up loudly instead of leaving a stale descriptor behind.SlotMasksdocs: they go stale; names only.Checks: vkback unit and policy tests pass, asset policy OK, validation run (rule 30) on current main: no new errors, and the new invariant never fired. Kept under rule 24 although fps did not move (the helper thread is not the bottleneck today).