Repository navigation
runtime: flush COMPUTE_SHADER_BIT to HOST on XDXR postbuild readbacks (VK-XDXR-POSTBUILD-READBACK-STAGE) - #615
Conversation
… (VK-XDXR-POSTBUILD-READBACK-STAGE)
|
Independent run on Windows: passes, with and without validation. Head dfadf4c built as it is (
I 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 ( GPU: NVIDIA GeForce RTX 5070 Ti, driver 617.42, Vulkan 1.4.351, Windows 11 Pro 26300. AI-assisted. |
|
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 4a50caf, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main 540d511: 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 main 51a6074: 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). |
Summary
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 辅助)