mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
libs/vkd3d: Fix texture region copying for miplevels other than 0.
This commit is contained in:
parent
0dca9909d9
commit
d8847aa462
@ -1841,9 +1841,10 @@ static void vk_image_copy_from_d3d12(VkImageCopy *image_copy,
|
||||
}
|
||||
else
|
||||
{
|
||||
image_copy->extent.width = src_desc->Width;
|
||||
image_copy->extent.height = src_desc->Height;
|
||||
image_copy->extent.depth = d3d12_resource_desc_get_depth(src_desc);
|
||||
unsigned int miplevel = image_copy->srcSubresource.mipLevel;
|
||||
image_copy->extent.width = d3d12_resource_desc_get_width(src_desc, miplevel);
|
||||
image_copy->extent.height = d3d12_resource_desc_get_height(src_desc, miplevel);
|
||||
image_copy->extent.depth = d3d12_resource_desc_get_depth(src_desc, miplevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1368,8 +1368,8 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i
|
||||
{
|
||||
static const struct vkd3d_format vkd3d_format_unknown = {DXGI_FORMAT_UNKNOWN, VK_FORMAT_UNDEFINED, 1, 1, 1, 1, 0};
|
||||
|
||||
unsigned int i, sub_resource_idx, miplevel_idx, width, height, row_count, row_size, row_pitch;
|
||||
unsigned int array_size, base_depth, depth;
|
||||
unsigned int i, sub_resource_idx, miplevel_idx, row_count, row_size, row_pitch;
|
||||
unsigned int width, height, depth, array_size;
|
||||
const struct vkd3d_format *format;
|
||||
UINT64 offset, size, total;
|
||||
|
||||
@ -1429,7 +1429,6 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i
|
||||
}
|
||||
|
||||
array_size = desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc->DepthOrArraySize;
|
||||
base_depth = d3d12_resource_desc_get_depth(desc);
|
||||
|
||||
if (first_sub_resource >= desc->MipLevels * array_size
|
||||
|| sub_resource_count > desc->MipLevels * array_size - first_sub_resource)
|
||||
@ -1454,9 +1453,9 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i
|
||||
{
|
||||
sub_resource_idx = first_sub_resource + i;
|
||||
miplevel_idx = sub_resource_idx % desc->MipLevels;
|
||||
width = align(max(1, desc->Width >> miplevel_idx), format->block_width);
|
||||
height = align(max(1, desc->Height >> miplevel_idx), format->block_height);
|
||||
depth = max(1, base_depth >> miplevel_idx);
|
||||
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);
|
||||
depth = d3d12_resource_desc_get_depth(desc, miplevel_idx);
|
||||
row_count = height / format->block_height;
|
||||
row_size = (width / format->block_width) * format->byte_count * format->block_byte_count;
|
||||
row_pitch = align(row_size, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
|
||||
|
@ -579,9 +579,23 @@ static inline const struct vkd3d_format *vkd3d_format_from_d3d12_resource_desc(
|
||||
desc->Flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_depth(const D3D12_RESOURCE_DESC *desc)
|
||||
static inline unsigned int d3d12_resource_desc_get_width(const D3D12_RESOURCE_DESC *desc,
|
||||
unsigned int miplevel_idx)
|
||||
{
|
||||
return desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc->DepthOrArraySize;
|
||||
return max(1, desc->Width >> miplevel_idx);
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_height(const D3D12_RESOURCE_DESC *desc,
|
||||
unsigned int miplevel_idx)
|
||||
{
|
||||
return max(1, desc->Height >> miplevel_idx);
|
||||
}
|
||||
|
||||
static inline unsigned int d3d12_resource_desc_get_depth(const D3D12_RESOURCE_DESC *desc,
|
||||
unsigned int miplevel_idx)
|
||||
{
|
||||
unsigned int d = desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc->DepthOrArraySize;
|
||||
return max(1, d >> miplevel_idx);
|
||||
}
|
||||
|
||||
enum VkCompareOp vk_compare_op_from_d3d12(D3D12_COMPARISON_FUNC op) DECLSPEC_HIDDEN;
|
||||
|
Loading…
x
Reference in New Issue
Block a user