upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorQemmHD <stephenlethco2@gmail.com>2026-11-24 19:02:14 -0500
committerGitHub <noreply@github.com>2026-11-24 19:02:14 -0500
commitfec45f0a13df1c742e559db14828fe2623e3e400 (patch)
treeafc603e70635800b39f220da9ac5164f2405f4b4 /runtime/src
parent3943b04d53dfb66f1424a833f4eef6120f7d3112 (diff)
parentddcffa634e606ce959c1276b26eb63fb8c8297d5 (diff)
Merge pull request #1099 from Moriz82/split/rt-stream-transfer-barrier
Merging. **Why merged:** RT-STREAM-TRANSFER-BARRIER: a transfer-write → transfer-read/write barrier goes before every vkCmdCopyBuffer, so back-to-back streamed copies are ordered. moffington measured SyncVal at 10 errors on the base and 0 on the head. Plaaasma (4070 Ti), iFeyz (RX 9070 XT) and whoalin1 (gfx1035) passed it. LEONIDA_ORDER_BUFFER_COPIES=0 turns it off (documented in docs/d3d12_vulkan.md). **Why it's good:** replay_*, vk_bc_zero_init, vk_queue* and d3d12_close_parity: 16/16 both plain and under validation. A negative control on the cumulative build checked that the test really catches a missing barrier: with the barrier on, `--expect-unordered` fails; with the env var at 0, the ordered check fails and `--expect-unordered` passes. It also passes on top of #1055's vulkan_replay.h change. It adds one barrier per buffer copy, a small sync-policy cost with an opt-out. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 0f98d193c, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative with the rest of this batch on main 507029d1e: the repo-consistency set gives 578 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 317/318 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 semantic suite has only the known environment-only failure. git merge-tree against current main 9c5e70661: 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).
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/vulkan_replay.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/src/vulkan_replay.h b/runtime/src/vulkan_replay.h
index 16a850d9e..8d5b95388 100644
--- a/runtime/src/vulkan_replay.h
+++ b/runtime/src/vulkan_replay.h
@@ -43,6 +43,7 @@
43#include <array> 43#include <array>
44#include <cmath> 44#include <cmath>
45#include <cstdint> 45#include <cstdint>
46#include <cstdlib>
46#include <functional> 47#include <functional>
47#include <limits> 48#include <limits>
48#include <map> 49#include <map>
@@ -3500,6 +3501,20 @@ inline void close_labels(VkCommandBuffer command_buffer, const ReplayFunctions&
3500// `open_labels` counts the debug labels begun and not yet ended in this command buffer: an EndEvent with none open 3501// `open_labels` counts the debug labels begun and not yet ended in this command buffer: an EndEvent with none open
3501// is dropped (Vulkan requires a matching begin), and the caller ends what is still open before it ends the buffer 3502// is dropped (Vulkan requires a matching begin), and the caller ends what is still open before it ends the buffer
3502// (close_labels). Without it, the list's own events are balanced at its end. 3503// (close_labels). Without it, the list's own events are balanced at its end.
3504inline bool order_buffer_copies() {
3505 static const bool enabled = [] {
3506#ifdef _WIN32
3507 char value[2]{};
3508 std::size_t length = 0;
3509 return getenv_s(&length, value, sizeof value, "LEONIDA_ORDER_BUFFER_COPIES") != 0 || length != 2 || value[0] != '0';
3510#else
3511 const char* value = std::getenv("LEONIDA_ORDER_BUFFER_COPIES");
3512 return !value || value[0] != '0' || value[1];
3513#endif
3514 }();
3515 return enabled;
3516}
3517
3503inline void emit(const PreparedList& prepared, VkCommandBuffer command_buffer, const ReplayFunctions& vk, 3518inline void emit(const PreparedList& prepared, VkCommandBuffer command_buffer, const ReplayFunctions& vk,
3504 LayoutTracker* tracker = nullptr, std::uint32_t* open_labels = nullptr) { 3519 LayoutTracker* tracker = nullptr, std::uint32_t* open_labels = nullptr) {
3505 std::uint32_t own_labels = 0; 3520 std::uint32_t own_labels = 0;
@@ -3813,6 +3828,14 @@ inline void emit(const PreparedList& prepared, VkCommandBuffer command_buffer, c
3813 vk.emit_predicated_copy(command_buffer, p.predicated_copy); 3828 vk.emit_predicated_copy(command_buffer, p.predicated_copy);
3814 begin_statistics(); 3829 begin_statistics();
3815 } else if (!p.buffer_copies.empty()) { 3830 } else if (!p.buffer_copies.empty()) {
3831 // Transfer dependency from natterman12, ubiquitarianism/leonida PR #354 (GPL-3.0).
3832 // D3D12 orders buffer copies even across lists on one queue. A previous transfer write can
3833 // overlap this copy's source or destination without an application barrier.
3834 if (vk.pipeline_barrier && order_buffer_copies()) {
3835 detail::memory_barrier(vk, command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
3836 VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
3837 VK_PIPELINE_STAGE_TRANSFER_BIT);
3838 }
3816 vk.copy_buffer(command_buffer, p.source.buffer, p.binding.buffer, std::uint32_t(p.buffer_copies.size()), 3839 vk.copy_buffer(command_buffer, p.source.buffer, p.binding.buffer, std::uint32_t(p.buffer_copies.size()),
3817 p.buffer_copies.data()); 3840 p.buffer_copies.data());
3818 } else if (p.staged) { 3841 } else if (p.staged) {