diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 53d9747968..c66c424b07 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md @@ -2893,7 +2893,10 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv host-visible memory type. The runtime queries the same image with and without host-transfer usage. When only the latter permits plain device-local backing, it detiles the complete image into a reusable staging buffer and transfers all its mips and layers together. Linear slot-133 placements retain host - copies. An allocation failure retries the original host-copyable image. `LEONIDA_TITLE_IMAGE_STAGING=0` + copies. On a device without `VK_EXT_host_image_copy` every colour title image, linear placements too, takes the + staged upload: the refresh before a submission has no other way to fill one, and without it the title's textures + stayed zero (a flat green intro movie). An allocation failure retries the original host-copyable image. + `LEONIDA_TITLE_IMAGE_STAGING=0` restores the original placement policy. With `LEONIDA_MEM_PROBE`, each title image class logs its Vulkan memory type mask, mask without host transfer, and selected type. - `WriteToSubresource`/`ReadFromSubresource` (implemented in `d3d12_vulkan_device.cpp`) complete before they diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index 49743d0c1d..8ff3492980 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp @@ -6217,7 +6217,7 @@ class Resource final const char* value = std::getenv("LEONIDA_TITLE_IMAGE_STAGING"); return !value || std::strcmp(value, "0"); }(); - // Keep placed movie planes with a known linear CPU layout on the host-copy path. + // Keep placed movie planes with a known linear CPU layout on the host-copy path, where there is one. // Map on a staged placement still returns the title's pages and participates in the refresh. std::uint32_t xg_layout = 0; const bool linear_placement = origin == TitleImageOrigin::placed && @@ -6239,17 +6239,24 @@ class Resource final shared_zero_ = device_.zero_sampled_image(desc_, format, footprint.size); } std::uint32_t plain_bits = 0; - if (stage_title && !shared_zero_ && allow_staged_title && origin != TitleImageOrigin::ordinary && !linear_placement && - host_transfer_ && format.aspects == VK_IMAGE_ASPECT_COLOR_BIT && device_.image_requirements) { + // A device without host copies has no other way to fill a title image: a refresh before a submission may not + // use a staged copy through the queue (host_copy_now). Its linear movie planes are staged too. + const bool no_host_copy = !device_.copy_memory_to_image && cpu_visible() && samples == 1 && + !format.d24_as_float && !format.rgb96; + if (stage_title && !shared_zero_ && allow_staged_title && origin != TitleImageOrigin::ordinary && + (no_host_copy || (!linear_placement && host_transfer_)) && format.aspects == VK_IMAGE_ASPECT_COLOR_BIT && + device_.image_requirements) { for (std::uint32_t i = 0; i < device_.memory.memoryTypeCount; ++i) { const auto flags = device_.memory.memoryTypes[i].propertyFlags; if ((flags & (VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) plain_bits |= 1u << i; } + if (no_host_copy) plain_bits = UINT32_MAX; // nothing to compare with: any memory type will do VkMemoryRequirements with{}, without{}; auto staged = info; staged.usage &= ~VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT; - if (plain_bits && device_.memory_requirements(info, with) && !(with.memoryTypeBits & plain_bits) && + if (plain_bits && (no_host_copy || (device_.memory_requirements(info, with) && + !(with.memoryTypeBits & plain_bits))) && device_.memory_requirements(staged, without) && (without.memoryTypeBits & plain_bits)) { staged_title_ = true; host_transfer_ = false; diff --git a/runtime/test/d3d12_existing_heap_test.cpp b/runtime/test/d3d12_existing_heap_test.cpp index d84454fce9..f1ebbe7203 100644 --- a/runtime/test/d3d12_existing_heap_test.cpp +++ b/runtime/test/d3d12_existing_heap_test.cpp @@ -1904,6 +1904,15 @@ int main() { failures += check_mapped_plane(ours.p); failures += check_mapped_bc_array(ours.p); } + { + // Without host image copies a title image is filled through the staged upload, a linear plane too. + auto no_host_copy = info; + no_host_copy.host_image_copy = false; + Ref staged; + if (FAILED(rt::d3d12::create_vulkan_device(no_host_copy, IID_PPV_ARGS(&staged.p)))) return 1; + failures += check_mapped_plane(staged.p); + failures += check_mapped_bc_array(staged.p); + } failures += check_written_pages_all(ours.p); { // A second device over the same Vulkan device: its shadows are trackers of their own.