vkd3d: Return the correct depth/stencil plane format from GetCopyableFootprints().

This commit is contained in:
Conor McCarthy 2024-05-31 10:17:31 +10:00 committed by Henri Verbeet
parent 17adde7f73
commit 1a4dedbc8d
Notes: Henri Verbeet 2025-01-20 16:18:31 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/899
2 changed files with 13 additions and 8 deletions

View File

@ -4693,10 +4693,11 @@ static void d3d12_device_get_copyable_footprints(struct d3d12_device *device,
uint64_t base_offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, UINT *row_counts, uint64_t base_offset, D3D12_PLACED_SUBRESOURCE_FOOTPRINT *layouts, UINT *row_counts,
UINT64 *row_sizes, UINT64 *total_bytes) UINT64 *row_sizes, UINT64 *total_bytes)
{ {
unsigned int i, sub_resource_idx, miplevel_idx, row_count, row_size, row_pitch; unsigned int i, sub_resource_idx, plane_idx, miplevel_idx, row_count, row_size, row_pitch;
unsigned int width, height, depth, plane_count, sub_resources_per_plane; unsigned int width, height, depth, plane_count, sub_resources_per_plane;
const struct vkd3d_format *format; const struct vkd3d_format *format;
uint64_t offset, size, total; uint64_t offset, size, total;
DXGI_FORMAT plane_format;
if (layouts) if (layouts)
memset(layouts, 0xff, sizeof(*layouts) * sub_resource_count); memset(layouts, 0xff, sizeof(*layouts) * sub_resource_count);
@ -4719,8 +4720,7 @@ static void d3d12_device_get_copyable_footprints(struct d3d12_device *device,
return; return;
} }
plane_count = ((format->vk_aspect_mask & VK_IMAGE_ASPECT_DEPTH_BIT) plane_count = format->plane_count;
&& (format->vk_aspect_mask & VK_IMAGE_ASPECT_STENCIL_BIT)) ? 2 : 1;
sub_resources_per_plane = d3d12_resource_desc_get_sub_resource_count(desc); sub_resources_per_plane = d3d12_resource_desc_get_sub_resource_count(desc);
if (!vkd3d_bound_range(first_sub_resource, sub_resource_count, sub_resources_per_plane * plane_count)) if (!vkd3d_bound_range(first_sub_resource, sub_resource_count, sub_resources_per_plane * plane_count))
@ -4731,10 +4731,19 @@ static void d3d12_device_get_copyable_footprints(struct d3d12_device *device,
offset = 0; offset = 0;
total = 0; total = 0;
plane_format = desc->Format;
for (i = 0; i < sub_resource_count; ++i) for (i = 0; i < sub_resource_count; ++i)
{ {
sub_resource_idx = (first_sub_resource + i) % sub_resources_per_plane; sub_resource_idx = (first_sub_resource + i) % sub_resources_per_plane;
plane_idx = (first_sub_resource + i) / sub_resources_per_plane;
miplevel_idx = sub_resource_idx % desc->MipLevels; miplevel_idx = sub_resource_idx % desc->MipLevels;
if (plane_count > 1)
{
plane_format = !plane_idx ? DXGI_FORMAT_R32_TYPELESS : DXGI_FORMAT_R8_TYPELESS;
format = vkd3d_get_format(device, plane_format, true);
}
width = align(d3d12_resource_desc_get_width(desc, miplevel_idx), format->block_width); width = align(d3d12_resource_desc_get_width(desc, miplevel_idx), format->block_width);
height = align(d3d12_resource_desc_get_height(desc, miplevel_idx), format->block_height); height = align(d3d12_resource_desc_get_height(desc, miplevel_idx), format->block_height);
depth = d3d12_resource_desc_get_depth(desc, miplevel_idx); depth = d3d12_resource_desc_get_depth(desc, miplevel_idx);
@ -4745,7 +4754,7 @@ static void d3d12_device_get_copyable_footprints(struct d3d12_device *device,
if (layouts) if (layouts)
{ {
layouts[i].Offset = base_offset + offset; layouts[i].Offset = base_offset + offset;
layouts[i].Footprint.Format = desc->Format; layouts[i].Footprint.Format = plane_format;
layouts[i].Footprint.Width = width; layouts[i].Footprint.Width = width;
layouts[i].Footprint.Height = height; layouts[i].Footprint.Height = height;
layouts[i].Footprint.Depth = depth; layouts[i].Footprint.Depth = depth;

View File

@ -20294,7 +20294,6 @@ static void check_copyable_footprints_(const char *file, unsigned int line, cons
todo_if(format_is_ds && l->Offset != base_offset + offset) todo_if(format_is_ds && l->Offset != base_offset + offset)
ok_(file, line)(l->Offset == base_offset + offset, ok_(file, line)(l->Offset == base_offset + offset,
"Got offset %"PRIu64", expected %"PRIu64".\n", l->Offset, base_offset + offset); "Got offset %"PRIu64", expected %"PRIu64".\n", l->Offset, base_offset + offset);
todo_if(format_is_ds)
ok_(file, line)(f->Format == expected_format, "Got format %#x, expected %#x.\n", ok_(file, line)(f->Format == expected_format, "Got format %#x, expected %#x.\n",
f->Format, expected_format); f->Format, expected_format);
ok_(file, line)(f->Width == width, "Got width %u, expected %u.\n", f->Width, width); ok_(file, line)(f->Width == width, "Got width %u, expected %u.\n", f->Width, width);
@ -20308,11 +20307,8 @@ static void check_copyable_footprints_(const char *file, unsigned int line, cons
ok_(file, line)(row_counts[i] == row_count, "Got row count %u, expected %u.\n", row_counts[i], row_count); ok_(file, line)(row_counts[i] == row_count, "Got row count %u, expected %u.\n", row_counts[i], row_count);
if (row_sizes) if (row_sizes)
{
todo_if(format_is_ds && (plane_idx || format_size(desc->Format) > 4))
ok_(file, line)(row_sizes[i] == row_size, "Got row size %"PRIu64", expected %u.\n", ok_(file, line)(row_sizes[i] == row_size, "Got row size %"PRIu64", expected %u.\n",
row_sizes[i], row_size); row_sizes[i], row_size);
}
size = max(0, row_count - 1) * row_pitch + row_size; size = max(0, row_count - 1) * row_pitch + row_size;
size = max(0, depth - 1) * align(size, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT * plane_count) + size; size = max(0, depth - 1) * align(size, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT * plane_count) + size;