Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2919,6 +2919,9 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv
without host-transfer usage before it is bound, and takes the staging path. `d3d12_vulkan_device_test` and
`d3d12_subresource_copy_test` force this branch on any GPU with `VulkanDeviceInfo::force_host_transfer_retry`
(their third CPU-copy path; the second compares it with the host runtime).
- Setting `LEONIDA_HOST_IMAGE_COPY=0` (or `off`) disables `VK_EXT_host_image_copy` and routes all CPU texture
copies through the staging submit path. This provides an immediate diagnostic bypass for driver-side host image
transfer write faults (e.g. `WRITE_INVALID` stops during world-start loading on NVIDIA GPUs).
- 96-bit textures (`R32G32B32_FLOAT`/`_UINT`/`_SINT`/`_TYPELESS`, D3D-62) are `R32G32B32A32` images
(`ResourceBinding::rgb96`), on every GPU. Most GPUs have no optimal-tiling RGB32 image (an RX 9070 XT reports
no optimal features for `R32G32B32_SFLOAT`), and one that has would not avoid the repack: D3D12 places
Expand Down
12 changes: 11 additions & 1 deletion runtime/shims/d3d12_vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17952,11 +17952,21 @@ HRESULT create_vulkan_device_standalone(REFIID riid, void** out, QueueTestSettin
}
const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME;
info.host_image_copy = has_host_image_copy && host_copy.hostImageCopy;
char host_copy_env[8]{};
DWORD host_copy_len = 0;
if (getenv_s(&host_copy_len, host_copy_env, "LEONIDA_HOST_IMAGE_COPY") == 0 && host_copy_len > 1) {
if (host_copy_env[0] == '0' || std::strcmp(host_copy_env, "off") == 0) {
info.host_image_copy = false;
}
}
if (info.host_image_copy) {
host_copy.pNext = *v13.next(); // after the conditional rendering features, if any
*v13.next() = &host_copy;
} else {
std::fprintf(stderr, "[rt] d3d12: no VK_EXT_host_image_copy; CPU texture copies use a staging submit\n");
std::fprintf(stderr, "[rt] d3d12: %s; CPU texture copies use a staging submit\n",
(host_copy_len > 1 && (host_copy_env[0] == '0' || std::strcmp(host_copy_env, "off") == 0))
? "LEONIDA_HOST_IMAGE_COPY=0"
: "no VK_EXT_host_image_copy");
}

const auto has_device_extension = [&](const char* name) {
Expand Down
14 changes: 14 additions & 0 deletions runtime/test/d3d12_vulkan_device_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7086,6 +7086,20 @@ int main() {
EXPECT(cpu_copies(device.p, d.bc, path.name) == 0);
}

// LEONIDA_HOST_IMAGE_COPY=0 forces staging copies even on a device with VK_EXT_host_image_copy.
{
_putenv_s("LEONIDA_HOST_IMAGE_COPY", "0");
Ref<ID3D12Device> forced_staging;
EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device_standalone(IID_PPV_ARGS(&forced_staging.p))));
const rt::d3d12::VulkanDeviceInfo* made = rt::d3d12::vulkan_device_info(forced_staging.p);
EXPECT(made != nullptr);
if (made) {
EXPECT(!made->host_image_copy);
}
EXPECT(cpu_copies(forced_staging.p, d.bc, "staging copy with LEONIDA_HOST_IMAGE_COPY=0") == 0);
_putenv_s("LEONIDA_HOST_IMAGE_COPY", "");
}

{
Ref<ID3D12Device> removable;
EXPECT(SUCCEEDED(rt::d3d12::create_vulkan_device_standalone(IID_PPV_ARGS(&removable.p))));
Expand Down
7 changes: 7 additions & 0 deletions runtime/test/vk_test_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,13 @@ class Device {
instance_fn<PFN_vkGetPhysicalDeviceFeatures2>("vkGetPhysicalDeviceFeatures2")(physical, &query);
host_image_copy = host_copy.hostImageCopy == VK_TRUE;
}
char host_copy_env[8]{};
DWORD host_copy_len = 0;
if (getenv_s(&host_copy_len, host_copy_env, "LEONIDA_HOST_IMAGE_COPY") == 0 && host_copy_len > 1) {
if (host_copy_env[0] == '0' || std::strcmp(host_copy_env, "off") == 0) {
host_image_copy = false;
}
}
const char* host_image_copy_name = VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME;
if (host_image_copy) {
host_copy.pNext = *v13_.next(); // after the conditional rendering features, if any
Expand Down
Loading