libs/vkd3d: Fix d3d12_device_GetCopyableFootprints() for 3D textures.

This commit is contained in:
Józef Kucia 2017-08-09 19:38:06 +02:00
parent 624699f5e6
commit e01cc64d82
2 changed files with 8 additions and 3 deletions

View File

@ -1124,7 +1124,7 @@ 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, depth;
unsigned int array_size, base_depth, depth;
const struct vkd3d_format *format;
UINT64 offset, size, total;
@ -1184,7 +1184,7 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i
}
array_size = desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc->DepthOrArraySize;
depth = desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc->DepthOrArraySize;
base_depth = desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? 1 : desc->DepthOrArraySize;
if (first_sub_resource >= desc->MipLevels * array_size
|| sub_resource_count > desc->MipLevels * array_size - first_sub_resource)
@ -1211,7 +1211,7 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *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, depth >> miplevel_idx);
depth = max(1, base_depth >> 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);

View File

@ -8119,6 +8119,7 @@ static void test_get_copyable_footprints(void)
{D3D12_RESOURCE_DIMENSION_TEXTURE3D, 4, 4, 1, 1, true},
{D3D12_RESOURCE_DIMENSION_TEXTURE3D, 4, 4, 2, 1, true},
{D3D12_RESOURCE_DIMENSION_TEXTURE3D, 4, 4, 2, 2, true},
{D3D12_RESOURCE_DIMENSION_TEXTURE3D, 8, 8, 8, 4, true},
{D3D12_RESOURCE_DIMENSION_TEXTURE3D, 3, 2, 2, 2, false},
};
static const struct
@ -8177,6 +8178,10 @@ static void test_get_copyable_footprints(void)
{D3D12_RESOURCE_DIMENSION_TEXTURE2D, 0, 3, 1, 1, 1, DXGI_FORMAT_BC7_UNORM,
{1, 0}, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_NONE}, 0, 1,
},
{
{D3D12_RESOURCE_DIMENSION_TEXTURE3D, 3, 2, 2, 2, 2, DXGI_FORMAT_BC1_UNORM,
{1, 0}, D3D12_TEXTURE_LAYOUT_UNKNOWN, D3D12_RESOURCE_FLAG_NONE}, 0, 1,
},
};
if (!(device = create_device()))