[PR #1810] [CLOSED] d3d12: support LEONIDA_HOST_IMAGE_COPY=0 to force staging texture copies (RT-HOST-IMAGE-COPY-ENV) #1823

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1810
Author: @abnalstlll-byte
Created: 11/25/2026
Status: ❌ Closed

Base: main ← Head: feat/rt-host-image-copy-env


📝 Commits (1)

  • b7980d3 d3d12: support LEONIDA_HOST_IMAGE_COPY=0 to force staging texture copies (RT-HOST-IMAGE-COPY-ENV)

📊 Changes

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

View changed files

📝 docs/d3d12_vulkan.md (+3 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+11 -1)
📝 runtime/test/d3d12_vulkan_device_test.cpp (+14 -0)
📝 runtime/test/vk_test_device.h (+7 -0)

📄 Description

Description

This PR implements the LEONIDA_HOST_IMAGE_COPY=0 (or off) environment variable switch, enabling community testers and CI to disable VK_EXT_host_image_copy and route all CPU texture transfers through the existing staging submit path.

Context & Finding

  • Hardware measurements reported by @QemmHD on RTX 4070 SUPER (#1608, comment 7162097442) revealed that VK_EXT_host_image_copy is the direct trigger for the fatal WRITE_INVALID device loss during the transition to the first world frame (crashing at ~6,570 commands).
  • Disabling host image copies allows the title to run past 29,726 commands, 49,019 draws, and 7,431 PresentX frames with zero device loss.
  • Prior to this PR, testers had to manually modify C++ source and recompile to test this path.

Changes

  1. runtime/shims/d3d12_vulkan_device.cpp:
    • Check LEONIDA_HOST_IMAGE_COPY via getenv_s. If set to "0" or "off", set info.host_image_copy = false and log [rt] d3d12: LEONIDA_HOST_IMAGE_COPY=0; CPU texture copies use a staging submit.
    • Naturally omits host_copy from the Vulkan 1.3 pNext chain, omits VK_EXT_host_image_copy from device_extensions, and skips entry point loading.
  2. runtime/test/vk_test_device.h:
    • Also respect LEONIDA_HOST_IMAGE_COPY=0 in TestDevice for consistent test harness behavior.
  3. runtime/test/d3d12_vulkan_device_test.cpp:
    • Added test case verifying that _putenv_s("LEONIDA_HOST_IMAGE_COPY", "0") disables made->host_image_copy on standalone device creation and successfully executes CPU texture copies through the staging path.
  4. docs/d3d12_vulkan.md:
    • Documented LEONIDA_HOST_IMAGE_COPY=0 under subresource copy options.

Verification

  • python -I scripts/check_no_game_data.py: Clean-room confirmed, 0 violations.
  • python -I tests/test_text_write_line_endings.py: 3/3 tests passed.

Claimed in #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162191969).

AI-assisted (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/1810 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/rt-host-image-copy-env` --- ### 📝 Commits (1) - [`b7980d3`](https://github.com/ubiquitarianism/leonida/commit/b7980d3efe51d09f74e589e67f8e38890f926afc) d3d12: support LEONIDA_HOST_IMAGE_COPY=0 to force staging texture copies (RT-HOST-IMAGE-COPY-ENV) ### 📊 Changes **4 files changed** (+35 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+3 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+11 -1) 📝 `runtime/test/d3d12_vulkan_device_test.cpp` (+14 -0) 📝 `runtime/test/vk_test_device.h` (+7 -0) </details> ### 📄 Description ### Description This PR implements the `LEONIDA_HOST_IMAGE_COPY=0` (or `off`) environment variable switch, enabling community testers and CI to disable `VK_EXT_host_image_copy` and route all CPU texture transfers through the existing staging submit path. ### Context & Finding - Hardware measurements reported by @QemmHD on RTX 4070 SUPER (#1608, [comment 7162097442](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162097442)) revealed that `VK_EXT_host_image_copy` is the direct trigger for the fatal `WRITE_INVALID` device loss during the transition to the first world frame (crashing at ~6,570 commands). - Disabling host image copies allows the title to run past 29,726 commands, 49,019 draws, and 7,431 PresentX frames with zero device loss. - Prior to this PR, testers had to manually modify C++ source and recompile to test this path. ### Changes 1. **`runtime/shims/d3d12_vulkan_device.cpp`**: - Check `LEONIDA_HOST_IMAGE_COPY` via `getenv_s`. If set to `"0"` or `"off"`, set `info.host_image_copy = false` and log `[rt] d3d12: LEONIDA_HOST_IMAGE_COPY=0; CPU texture copies use a staging submit`. - Naturally omits `host_copy` from the Vulkan 1.3 `pNext` chain, omits `VK_EXT_host_image_copy` from `device_extensions`, and skips entry point loading. 2. **`runtime/test/vk_test_device.h`**: - Also respect `LEONIDA_HOST_IMAGE_COPY=0` in `TestDevice` for consistent test harness behavior. 3. **`runtime/test/d3d12_vulkan_device_test.cpp`**: - Added test case verifying that `_putenv_s("LEONIDA_HOST_IMAGE_COPY", "0")` disables `made->host_image_copy` on standalone device creation and successfully executes CPU texture copies through the staging path. 4. **`docs/d3d12_vulkan.md`**: - Documented `LEONIDA_HOST_IMAGE_COPY=0` under subresource copy options. ### Verification - `python -I scripts/check_no_game_data.py`: Clean-room confirmed, 0 violations. - `python -I tests/test_text_write_line_endings.py`: 3/3 tests passed. Claimed in #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162191969). AI-assisted (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:05 +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#1823
No description provided.