[PR #615] [MERGED] runtime: flush COMPUTE_SHADER_BIT to HOST on XDXR postbuild readbacks (VK-XDXR-POSTBUILD-READBACK-STAGE) #656

Closed
opened 2026-11-26 20:18:36 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/615
Author: @tahffo68hk-hash
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: fix/vk-xdxr-postbuild-readback-stage


📝 Commits (1)

  • dfadf4c runtime: flush COMPUTE_SHADER_BIT to HOST on XDXR postbuild readbacks (VK-XDXR-POSTBUILD-READBACK-STAGE)

📊 Changes

4 files changed (+247 additions, -1 deletions)

View changed files

📝 runtime/CMakeLists.txt (+10 -0)
📝 runtime/src/vulkan_replay.h (+5 -0)
📝 runtime/test/replay_readback_stages_test.cpp (+55 -1)
➕ runtime/test/vk_xdxr_postbuild_readback_test.cpp (+177 -0)

📄 Description

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

  • In
    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

  • Unit test (
    eplay_readback_stages_test):
    • Before fix: \FAIL: XDXR postbuild compacted size reports COMPUTE_SHADER_BIT, \FAIL: XDXR postbuild current size reports COMPUTE_SHADER_BIT\
    • After fix: \PASS\ (
      eplay_readback_stages: depth24, rgb96, copy, UAV-clear and XDXR postbuild readback stages exact)
  • Real Vulkan GPU test (\ k_xdxr_postbuild_readback_test, builds a real 1-triangle XDXR BLAS on the GPU and executes a standalone XDXR postbuild submission into a host-readable buffer):
    • Before fix on NVIDIA GeForce RTX 5060 Ti: \FAIL line 168: barriers >= 1\ (0 \COMPUTE_SHADER_BIT -> HOST_BIT\ barriers emitted)
    • After fix on NVIDIA GeForce RTX 5060 Ti: \PASS (compute_to_host_barriers=1, reported_size=320, expected=320)\
    • After fix on AMD Radeon(TM) Graphics (GFX1036): \PASS (compute_to_host_barriers=1, reported_size=320, expected=320)\

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\):修复前失败,修复后通过。
  • 真实 Vulkan GPU 测试(\ k_xdxr_postbuild_readback_test\):
    • 修复前(NVIDIA GeForce RTX 5060 Ti):\FAIL line 168: barriers >= 1\
    • 修复后(NVIDIA GeForce RTX 5060 Ti):\PASS (compute_to_host_barriers=1, reported_size=320, expected=320)\
    • 修复后(AMD Radeon(TM) Graphics / GFX1036):\PASS (compute_to_host_barriers=1, reported_size=320, expected=320)\

已在 #14 认领。(AI 辅助)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/615 **Author:** [@tahffo68hk-hash](https://github.com/tahffo68hk-hash) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `fix/vk-xdxr-postbuild-readback-stage` --- ### 📝 Commits (1) - [`dfadf4c`](https://github.com/ubiquitarianism/leonida/commit/dfadf4ce5057de68297f91fdda3bc9dab44651b1) runtime: flush COMPUTE_SHADER_BIT to HOST on XDXR postbuild readbacks (VK-XDXR-POSTBUILD-READBACK-STAGE) ### 📊 Changes **4 files changed** (+247 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+10 -0) 📝 `runtime/src/vulkan_replay.h` (+5 -0) 📝 `runtime/test/replay_readback_stages_test.cpp` (+55 -1) ➕ `runtime/test/vk_xdxr_postbuild_readback_test.cpp` (+177 -0) </details> ### 📄 Description ## 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 - In \ 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 - **Unit test** (\ eplay_readback_stages_test\): - Before fix: \FAIL: XDXR postbuild compacted size reports COMPUTE_SHADER_BIT\, \FAIL: XDXR postbuild current size reports COMPUTE_SHADER_BIT\ - After fix: \PASS\ (\ eplay_readback_stages: depth24, rgb96, copy, UAV-clear and XDXR postbuild readback stages exact\) - **Real Vulkan GPU test** (\ k_xdxr_postbuild_readback_test\, builds a real 1-triangle XDXR BLAS on the GPU and executes a standalone XDXR postbuild submission into a host-readable buffer): - Before fix on **NVIDIA GeForce RTX 5060 Ti**: \FAIL line 168: barriers >= 1\ (0 \COMPUTE_SHADER_BIT -> HOST_BIT\ barriers emitted) - After fix on **NVIDIA GeForce RTX 5060 Ti**: \PASS (compute_to_host_barriers=1, reported_size=320, expected=320)\ - After fix on **AMD Radeon(TM) Graphics (GFX1036)**: \PASS (compute_to_host_barriers=1, reported_size=320, expected=320)\ Claimed on #14. (AI-assisted) <details><summary>中文翻译</summary> ## 摘要 在 \ 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\):修复前失败,修复后通过。 - **真实 Vulkan GPU 测试**(\ k_xdxr_postbuild_readback_test\): - 修复前(NVIDIA GeForce RTX 5060 Ti):\FAIL line 168: barriers >= 1\ - 修复后(NVIDIA GeForce RTX 5060 Ti):\PASS (compute_to_host_barriers=1, reported_size=320, expected=320)\ - 修复后(AMD Radeon(TM) Graphics / GFX1036):\PASS (compute_to_host_barriers=1, reported_size=320, expected=320)\ 已在 #14 认领。(AI 辅助) </details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:36 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#656
No description provided.