runtime: flush COMPUTE_SHADER_BIT to HOST on XDXR postbuild readbacks (VK-XDXR-POSTBUILD-READBACK-STAGE) #615
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!615
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/615/head"
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?
@tahffo68hk-hash on GitHub · 2026-11-24 09:58 UTC · original
tahffo68hk-hash:fix/vk-xdxr-postbuild-readback-stage→main· +247 −1 · 4 files · 1 commits · merged 2026-11-24 22:31 UTCSummary
In \prepare()\ (
untime/src/vulkan_replay.h), the KHR \AccelerationStructurePostbuild\ path marks \out.wrote_readback = true\ and \out.readback_src_stages |= VK_PIPELINE_STAGE_2_TRANSFER_BIT\ so \VulkanQueue::execute_now()\ emits a host-visibility barrier when \dest_va\ targets a host-readable readback buffer.
However, the XDXR \AccelerationStructurePostbuild\ path — where \XdxrBuilder::record_postbuild()\ dispatches a compute shader writing compacted/current acceleration-structure sizes to \dest_va\ — omitted setting \out.wrote_readback = true\ and \out.readback_src_stages |= VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT. As a result, a submission ending with XDXR \EmitRaytracingAccelerationStructurePostbuildInfo\ into a \READBACK\ buffer emitted no \COMPUTE_SHADER_BIT -> HOST_BIT\ flush barrier.
Fix
untime/src/vulkan_replay.h\ (\prepare()), set \out.wrote_readback = true\ and \out.readback_src_stages |= VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT\ on the XDXR \AccelerationStructurePostbuild\ path when !info->sources.empty().
Verification
eplay_readback_stages_test):
eplay_readback_stages: depth24, rgb96, copy, UAV-clear and XDXR postbuild readback stages exact)
Claimed on #14. (AI-assisted)
中文翻译
摘要
在
untime/src/vulkan_replay.h\ 的 \prepare()\ 中,KHR \AccelerationStructurePostbuild\ 路径会设置 \out.wrote_readback = true\ 和 \out.readback_src_stages |= VK_PIPELINE_STAGE_2_TRANSFER_BIT\,使 \VulkanQueue::execute_now()\ 在 \dest_va\ 指向主机可读回读缓冲区时发出主机可见性屏障。
但 XDXR \AccelerationStructurePostbuild\ 路径(通过计算着色器将压缩/当前加速结构大小写入 \dest_va\)漏掉了 \out.wrote_readback = true\ 和 \out.readback_src_stages |= VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT\,导致仅含 XDXR postbuild 写入 \READBACK\ 缓冲区的提交缺失 \COMPUTE_SHADER_BIT -> HOST_BIT\ 刷新屏障。
修复
untime/src/vulkan_replay.h\ 的 XDXR \AccelerationStructurePostbuild\ 路径中(!info->sources.empty()\ 时),设置 \out.wrote_readback = true\ 与 \out.readback_src_stages |= VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT\。
验证
eplay_readback_stages_test\):修复前失败,修复后通过。
已在 #14 认领。(AI 辅助)
@kawaii-shakal on GitHub · 2026-11-24 11:39 UTC · original
Independent run on Windows: passes, with and without validation.
Head
dfadf4ce5built as it is (cmake --build runtime/build --config RelWithDebInfo, MSVC 19.50.35721.0),ctest -R "readback_stages|xdxr":LEONIDA_VK_VALIDATION1(Khronos validation with synchronization validation, Vulkan SDK 1.4.363.0)xdxr_build_checkscene reports 0 validation errors and 0/1000 (or 0/300, 0/200) rays differing;d3d12_xdxr_rt0 errorsI read the diff too: the COMPUTE_SHADER → HOST flush on XDXR postbuild readbacks matches what the KHR path already does for its query results.
One thing for whoever lands second: #626 (mine, RT-XDXR-SERIALIZE) adds XDXR copy mode 19 (
SERIALIZE), which also writes the destination from the build compute shader by VA and is typically read back by the title. If both merge, that mode should take the same readback stage path this PR adds. I'll rebase #626 onto this if it merges first.GPU: NVIDIA GeForce RTX 5070 Ti, driver 617.42, Vulkan 1.4.351, Windows 11 Pro 26300.
AI-assisted.
@QemmHD on GitHub · 2026-11-24 22:31 UTC · original
Merging.
Why merged: VK-XDXR-POSTBUILD-READBACK-STAGE: in vulkan_replay prepare(), an XDXR postbuild that has sources now sets wrote_readback and adds the COMPUTE_SHADER stage to the readback flush, so its results are visible to the CPU read. kawaii-shakal independently ran it 8/8 both plain and under validation.
Why it's good: vk_xdxr_postbuild_readback, replay_readback_stages, xdxr_* and d3d12_xdxr_rt*: 9/9 plain and 9/9 under validation. The new vk_xdxr_postbuild_readback is the extra test in the cumulative count.
Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main
4a50cafc7, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main540d5111f: the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 316/317 with the usual 11 skips; the only failure is main's pre-existing d3d12_depth_resolve. All d3d12_* tests under validation: 119/120 with 0 VUIDs. The full semantic suite has the same single environment-only failure as main. git merge-tree against current main51a6074d2: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).