Fixed row length calculation in CopyTextureRegion()

Signed-off-by: Ivan Fedorov <ifedorov@nvidia.com>
This commit is contained in:
ifedorov 2021-10-19 23:05:57 +03:00 committed by Hans-Kristian Arntzen
parent 9a1b7ab002
commit 0abe8a21dd
1 changed files with 17 additions and 8 deletions

View File

@ -5622,21 +5622,22 @@ static void vk_extent_3d_from_d3d12_miplevel(VkExtent3D *extent,
static void vk_buffer_image_copy_from_d3d12(VkBufferImageCopy *copy,
const D3D12_PLACED_SUBRESOURCE_FOOTPRINT *footprint, unsigned int sub_resource_idx,
const D3D12_RESOURCE_DESC *image_desc, const struct vkd3d_format *format,
const D3D12_BOX *src_box, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z)
const D3D12_RESOURCE_DESC *image_desc, const struct vkd3d_format *src_format,
const struct vkd3d_format *dst_format, const D3D12_BOX *src_box, unsigned int dst_x,
unsigned int dst_y, unsigned int dst_z)
{
copy->bufferOffset = footprint->Offset;
if (src_box)
{
VkDeviceSize row_count = footprint->Footprint.Height / format->block_height;
copy->bufferOffset += vkd3d_format_get_data_offset(format, footprint->Footprint.RowPitch,
VkDeviceSize row_count = footprint->Footprint.Height / src_format->block_height;
copy->bufferOffset += vkd3d_format_get_data_offset(src_format, footprint->Footprint.RowPitch,
row_count * footprint->Footprint.RowPitch, src_box->left, src_box->top, src_box->front);
}
copy->bufferRowLength = footprint->Footprint.RowPitch /
(format->byte_count * format->block_byte_count) * format->block_width;
(src_format->byte_count * src_format->block_byte_count) * src_format->block_width;
copy->bufferImageHeight = footprint->Footprint.Height;
vk_image_subresource_layers_from_d3d12(&copy->imageSubresource,
format, sub_resource_idx, image_desc->MipLevels,
dst_format, sub_resource_idx, image_desc->MipLevels,
d3d12_resource_desc_get_layer_count(image_desc));
copy->imageOffset.x = dst_x;
copy->imageOffset.y = dst_y;
@ -6122,15 +6123,23 @@ static void STDMETHODCALLTYPE d3d12_command_list_CopyTextureRegion(d3d12_command
assert(d3d12_resource_is_texture(dst_resource));
assert(d3d12_resource_is_buffer(src_resource));
if (!(src_format = vkd3d_format_from_d3d12_resource_desc(list->device,
if (!(dst_format = vkd3d_format_from_d3d12_resource_desc(list->device,
&dst_resource->desc, DXGI_FORMAT_UNKNOWN)))
{
WARN("Invalid format %#x.\n", dst_resource->desc.Format);
return;
}
if (!(src_format = vkd3d_get_format(list->device, src->PlacedFootprint.Footprint.Format,
true)))
{
WARN("Invalid format %#x.\n", src->PlacedFootprint.Footprint.Format);
return;
}
vk_buffer_image_copy_from_d3d12(&buffer_image_copy, &src->PlacedFootprint,
dst->SubresourceIndex, &dst_resource->desc, src_format, src_box, dst_x, dst_y, dst_z);
dst->SubresourceIndex, &dst_resource->desc, src_format, dst_format, src_box, dst_x,
dst_y, dst_z);
buffer_image_copy.bufferOffset += src_resource->mem.offset;
vk_layout = d3d12_resource_pick_layout(dst_resource, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);