[PR #1893] [CLOSED] replay: copies between depth formats that differ go through transfer scratch (RT-DEPTH-FORMAT-COPY-STAGED) #1904

Closed
opened 2026-11-26 21:19:21 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1893
Author: @OreoFR
Created: 11/25/2026
Status: ❌ Closed

Base: main ← Head: rt-depth-format-copy-staged


📝 Commits (1)

  • daf31b8 replay: copies between depth formats that differ go through transfer scratch (RT-DEPTH-FORMAT-COPY-STAGED)

📊 Changes

3 files changed (+103 additions, -2 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+7 -0)
📝 runtime/src/vulkan_replay.h (+23 -1)
📝 runtime/test/replay_copy_offset_test.cpp (+73 -1)

📄 Description

Claimed in the coordination issue as: RT-DEPTH-FORMAT-COPY-STAGED (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7165740106)

What and why

A CopyTextureRegion of the depth plane from a D32_SFLOAT_S8_UINT image into a D32_SFLOAT one (D3D12: D32_FLOAT_S8X24 and D32_FLOAT) was replayed as vkCmdCopyImage. Vulkan requires depth/stencil formats to match exactly (VUID-vkCmdCopyImage-srcImage-01548). The NVIDIA driver runs the copy anyway and writes past the end of the D32 image.

That is the world-start WRITE_INVALID device loss ("crash A"):

depth_format_pair (new, runtime/src/vulkan_replay.h): two depth formats with the same depth encoding but not the same VkFormat (D32_SFLOAT / D32_SFLOAT_S8_UINT, D16_UNORM / D16_UNORM_S8_UINT, X8_D24_UNORM_PACK32 / D24_UNORM_S8_UINT) now take the image → transfer scratch → image path that depth ↔ colour and the two A8 backings already use. In a buffer the depth aspect has the same texel layout on both sides (4 bytes for D32). A whole-resource copy between such a pair was already refused before this point (the aspects differ), so only the depth-plane CopyTextureRegion changes.

Tested

  • replay_copy_offset_test (no GPU, fake Vulkan callbacks), new case: D32S8 → D32 and D32 → D32S8 depth-plane copies are staged (no vkCmdCopyImage, depth aspect on both halves, 4 bytes a texel), and D32 → D32 keeps vkCmdCopyImage. It fails without the change (6 checks) and passes with it. Built with MSVC 19.44.
  • scripts/check_no_game_data.py on the changed files, and tests/test_text_write_line_endings.py: OK.
  • Retail 1.0.2.1 boots, native Windows 11, RTX 4070 Laptop 8 GB, NVIDIA 621.40, LEONIDA_ASYNC_PIPELINES=1, LEONIDA_DEVICE_FAULT=1, counts only:
    • before the change: 6 of 6 runs lost the device with crash A, between 236 and 323 s (~4,800 to 5,300 ExecuteCommandLists), with host image copies off plus #1827, #1849 and #1698;
    • with the change and that same set: 2 runs without crash A (stopped by me at 6,493 and 6,398 ExecuteCommandLists); one of them under validation, which no longer reported the copy;
    • with the change on main alone (host image copies on, the default): no crash A; that run stopped at ~266 s with the other known stop ("crash B", lib_cs_01144 in flight, a type-4-only fault report), which #1849 addresses;
    • with the change and #1849, host image copies on: no device loss up to the time of writing (6,200+ ExecuteCommandLists).

Not shown yet: these are few runs on one machine. Whether host image copies can stay on by default on NVIDIA (#1810, #1851) needs more runs with them on; I'm doing those and will report in #1608. After crash A, the next stop here is a list-values gate stall (gates time out, frames drop to 0), which this change doesn't address.

Depends on: none.

AI-assisted (Claude Code).

🤖 Generated with Claude Code


🔄 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/1893 **Author:** [@OreoFR](https://github.com/OreoFR) **Created:** 11/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `rt-depth-format-copy-staged` --- ### 📝 Commits (1) - [`daf31b8`](https://github.com/ubiquitarianism/leonida/commit/daf31b820b5b9fe5d7d119836657bff1f8fd1ea0) replay: copies between depth formats that differ go through transfer scratch (RT-DEPTH-FORMAT-COPY-STAGED) ### 📊 Changes **3 files changed** (+103 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+7 -0) 📝 `runtime/src/vulkan_replay.h` (+23 -1) 📝 `runtime/test/replay_copy_offset_test.cpp` (+73 -1) </details> ### 📄 Description Claimed in the coordination issue as: RT-DEPTH-FORMAT-COPY-STAGED (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7165740106) ### What and why A `CopyTextureRegion` of the depth plane from a `D32_SFLOAT_S8_UINT` image into a `D32_SFLOAT` one (D3D12: `D32_FLOAT_S8X24` and `D32_FLOAT`) was replayed as `vkCmdCopyImage`. Vulkan requires depth/stencil formats to match exactly (`VUID-vkCmdCopyImage-srcImage-01548`). The NVIDIA driver runs the copy anyway and writes past the end of the D32 image. That is the world-start `WRITE_INVALID` device loss ("crash A"): - with `VK_EXT_device_address_binding_report`, the fault address is **the first byte after a 2560x1440 `D32_SFLOAT` image** (bound size `0xF00000`); the next binding starts 64 KiB later (finding: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164893397); - with `LEONIDA_VK_VALIDATION=1`, this VUID for exactly that pair is reported just before the loss. `depth_format_pair` (new, `runtime/src/vulkan_replay.h`): two depth formats with the same depth encoding but not the same `VkFormat` (`D32_SFLOAT` / `D32_SFLOAT_S8_UINT`, `D16_UNORM` / `D16_UNORM_S8_UINT`, `X8_D24_UNORM_PACK32` / `D24_UNORM_S8_UINT`) now take the image → transfer scratch → image path that depth ↔ colour and the two A8 backings already use. In a buffer the depth aspect has the same texel layout on both sides (4 bytes for D32). A whole-resource copy between such a pair was already refused before this point (the aspects differ), so only the depth-plane `CopyTextureRegion` changes. ### Tested - `replay_copy_offset_test` (no GPU, fake Vulkan callbacks), new case: D32S8 → D32 and D32 → D32S8 depth-plane copies are staged (no `vkCmdCopyImage`, depth aspect on both halves, 4 bytes a texel), and D32 → D32 keeps `vkCmdCopyImage`. It fails without the change (6 checks) and passes with it. Built with MSVC 19.44. - `scripts/check_no_game_data.py` on the changed files, and `tests/test_text_write_line_endings.py`: OK. - **Retail 1.0.2.1 boots**, native Windows 11, RTX 4070 Laptop 8 GB, NVIDIA 621.40, `LEONIDA_ASYNC_PIPELINES=1`, `LEONIDA_DEVICE_FAULT=1`, counts only: - before the change: 6 of 6 runs lost the device with crash A, between 236 and 323 s (~4,800 to 5,300 `ExecuteCommandLists`), with host image copies off plus #1827, #1849 and #1698; - with the change and that same set: 2 runs without crash A (stopped by me at 6,493 and 6,398 `ExecuteCommandLists`); one of them under validation, which no longer reported the copy; - with the change on `main` alone (host image copies on, the default): no crash A; that run stopped at ~266 s with the other known stop ("crash B", `lib_cs_01144` in flight, a type-4-only fault report), which #1849 addresses; - with the change and #1849, host image copies on: no device loss up to the time of writing (6,200+ `ExecuteCommandLists`). **Not shown yet:** these are few runs on one machine. Whether host image copies can stay on by default on NVIDIA (#1810, #1851) needs more runs with them on; I'm doing those and will report in #1608. After crash A, the next stop here is a list-values gate stall (gates time out, frames drop to 0), which this change doesn't address. Depends on: none. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:19:21 +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#1904
No description provided.