Skip to content
Merged
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
5 changes: 4 additions & 1 deletion docs/d3d12_vulkan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 11 additions & 4 deletions runtime/shims/d3d12_vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions runtime/test/d3d12_existing_heap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ID3D12Device> 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.
Expand Down
Loading