diff options
| author | aslan2142 <jan.trencansky@protonmail.com> | 2026-11-25 15:37:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-11-25 15:37:56 +0100 |
| commit | 24a29f8b4e17e186882d08d2aa0cc71f8eb5c388 (patch) | |
| tree | 07d1226b77b1a2cd0b65d4dc2adef1e92de736e2 /runtime | |
| parent | 71a769d7d85208f86c6e2e50263aca7df1becce9 (diff) | |
| parent | ea6d535ff5831c81bec75505bfc190142296579d (diff) | |
Merge pull request #1827 from DadaCap/title-staged-no-host-copy
d3d12: title images use the staged upload on a device without host image copies (RT-TITLE-STAGED-NO-HOST-COPY)
Diffstat (limited to 'runtime')
| -rw-r--r-- | runtime/shims/d3d12_vulkan_device.cpp | 15 | ||||
| -rw-r--r-- | runtime/test/d3d12_existing_heap_test.cpp | 9 |
2 files changed, 20 insertions, 4 deletions
diff --git a/runtime/shims/d3d12_vulkan_device.cpp b/runtime/shims/d3d12_vulkan_device.cpp index aeecf05b0..0f94dde47 100644 --- a/runtime/shims/d3d12_vulkan_device.cpp +++ b/runtime/shims/d3d12_vulkan_device.cpp | |||
| @@ -6218,7 +6218,7 @@ public: | |||
| 6218 | const char* value = std::getenv("LEONIDA_TITLE_IMAGE_STAGING"); | 6218 | const char* value = std::getenv("LEONIDA_TITLE_IMAGE_STAGING"); |
| 6219 | return !value || std::strcmp(value, "0"); | 6219 | return !value || std::strcmp(value, "0"); |
| 6220 | }(); | 6220 | }(); |
| 6221 | // Keep placed movie planes with a known linear CPU layout on the host-copy path. | 6221 | // Keep placed movie planes with a known linear CPU layout on the host-copy path, where there is one. |
| 6222 | // Map on a staged placement still returns the title's pages and participates in the refresh. | 6222 | // Map on a staged placement still returns the title's pages and participates in the refresh. |
| 6223 | std::uint32_t xg_layout = 0; | 6223 | std::uint32_t xg_layout = 0; |
| 6224 | const bool linear_placement = origin == TitleImageOrigin::placed && | 6224 | const bool linear_placement = origin == TitleImageOrigin::placed && |
| @@ -6240,17 +6240,24 @@ public: | |||
| 6240 | shared_zero_ = device_.zero_sampled_image(desc_, format, footprint.size); | 6240 | shared_zero_ = device_.zero_sampled_image(desc_, format, footprint.size); |
| 6241 | } | 6241 | } |
| 6242 | std::uint32_t plain_bits = 0; | 6242 | std::uint32_t plain_bits = 0; |
| 6243 | if (stage_title && !shared_zero_ && allow_staged_title && origin != TitleImageOrigin::ordinary && !linear_placement && | 6243 | // A device without host copies has no other way to fill a title image: a refresh before a submission may not |
| 6244 | host_transfer_ && format.aspects == VK_IMAGE_ASPECT_COLOR_BIT && device_.image_requirements) { | 6244 | // use a staged copy through the queue (host_copy_now). Its linear movie planes are staged too. |
| 6245 | const bool no_host_copy = !device_.copy_memory_to_image && cpu_visible() && samples == 1 && | ||
| 6246 | !format.d24_as_float && !format.rgb96; | ||
| 6247 | if (stage_title && !shared_zero_ && allow_staged_title && origin != TitleImageOrigin::ordinary && | ||
| 6248 | (no_host_copy || (!linear_placement && host_transfer_)) && format.aspects == VK_IMAGE_ASPECT_COLOR_BIT && | ||
| 6249 | device_.image_requirements) { | ||
| 6245 | for (std::uint32_t i = 0; i < device_.memory.memoryTypeCount; ++i) { | 6250 | for (std::uint32_t i = 0; i < device_.memory.memoryTypeCount; ++i) { |
| 6246 | const auto flags = device_.memory.memoryTypes[i].propertyFlags; | 6251 | const auto flags = device_.memory.memoryTypes[i].propertyFlags; |
| 6247 | if ((flags & (VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) == | 6252 | if ((flags & (VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) == |
| 6248 | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) plain_bits |= 1u << i; | 6253 | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) plain_bits |= 1u << i; |
| 6249 | } | 6254 | } |
| 6255 | if (no_host_copy) plain_bits = UINT32_MAX; // nothing to compare with: any memory type will do | ||
| 6250 | VkMemoryRequirements with{}, without{}; | 6256 | VkMemoryRequirements with{}, without{}; |
| 6251 | auto staged = info; | 6257 | auto staged = info; |
| 6252 | staged.usage &= ~VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT; | 6258 | staged.usage &= ~VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT; |
| 6253 | if (plain_bits && device_.memory_requirements(info, with) && !(with.memoryTypeBits & plain_bits) && | 6259 | if (plain_bits && (no_host_copy || (device_.memory_requirements(info, with) && |
| 6260 | !(with.memoryTypeBits & plain_bits))) && | ||
| 6254 | device_.memory_requirements(staged, without) && (without.memoryTypeBits & plain_bits)) { | 6261 | device_.memory_requirements(staged, without) && (without.memoryTypeBits & plain_bits)) { |
| 6255 | staged_title_ = true; | 6262 | staged_title_ = true; |
| 6256 | host_transfer_ = false; | 6263 | host_transfer_ = false; |
diff --git a/runtime/test/d3d12_existing_heap_test.cpp b/runtime/test/d3d12_existing_heap_test.cpp index d84454fce..f1ebbe720 100644 --- a/runtime/test/d3d12_existing_heap_test.cpp +++ b/runtime/test/d3d12_existing_heap_test.cpp | |||
| @@ -1904,6 +1904,15 @@ int main() { | |||
| 1904 | failures += check_mapped_plane(ours.p); | 1904 | failures += check_mapped_plane(ours.p); |
| 1905 | failures += check_mapped_bc_array(ours.p); | 1905 | failures += check_mapped_bc_array(ours.p); |
| 1906 | } | 1906 | } |
| 1907 | { | ||
| 1908 | // Without host image copies a title image is filled through the staged upload, a linear plane too. | ||
| 1909 | auto no_host_copy = info; | ||
| 1910 | no_host_copy.host_image_copy = false; | ||
| 1911 | Ref<ID3D12Device> staged; | ||
| 1912 | if (FAILED(rt::d3d12::create_vulkan_device(no_host_copy, IID_PPV_ARGS(&staged.p)))) return 1; | ||
| 1913 | failures += check_mapped_plane(staged.p); | ||
| 1914 | failures += check_mapped_bc_array(staged.p); | ||
| 1915 | } | ||
| 1907 | failures += check_written_pages_all(ours.p); | 1916 | failures += check_written_pages_all(ours.p); |
| 1908 | { | 1917 | { |
| 1909 | // A second device over the same Vulkan device: its shadows are trackers of their own. | 1918 | // A second device over the same Vulkan device: its shadows are trackers of their own. |