mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests: Add tests for copying block-compressed texture regions of smallest miplevels.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bcd60c21ca
commit
143f25b12e
@ -21177,8 +21177,8 @@ static void test_copy_block_compressed_texture(void)
|
|||||||
}
|
}
|
||||||
ID3D12Resource_Unmap(src_buffer, 0, NULL);
|
ID3D12Resource_Unmap(src_buffer, 0, NULL);
|
||||||
|
|
||||||
texture = create_default_texture(device,
|
texture = create_default_texture2d(device, 8, 8, 1, 4, DXGI_FORMAT_BC2_UNORM,
|
||||||
8, 8, DXGI_FORMAT_BC2_UNORM, 0, D3D12_RESOURCE_STATE_COPY_DEST);
|
D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST);
|
||||||
|
|
||||||
/* copy from buffer to texture */
|
/* copy from buffer to texture */
|
||||||
dst_location.pResource = texture;
|
dst_location.pResource = texture;
|
||||||
@ -21210,6 +21210,16 @@ static void test_copy_block_compressed_texture(void)
|
|||||||
ID3D12GraphicsCommandList_CopyTextureRegion(command_list,
|
ID3D12GraphicsCommandList_CopyTextureRegion(command_list,
|
||||||
&dst_location, 4, 4, 0, &src_location, &box);
|
&dst_location, 4, 4, 0, &src_location, &box);
|
||||||
|
|
||||||
|
/* miplevels smaller than 4x4 */
|
||||||
|
dst_location.SubresourceIndex = 2;
|
||||||
|
set_box(&box, 4, 0, 0, 8, 4, 1);
|
||||||
|
ID3D12GraphicsCommandList_CopyTextureRegion(command_list,
|
||||||
|
&dst_location, 0, 0, 0, &src_location, &box);
|
||||||
|
dst_location.SubresourceIndex = 3;
|
||||||
|
set_box(&box, 8, 0, 0, 12, 4, 1);
|
||||||
|
ID3D12GraphicsCommandList_CopyTextureRegion(command_list,
|
||||||
|
&dst_location, 0, 0, 0, &src_location, &box);
|
||||||
|
|
||||||
transition_resource_state(command_list, texture,
|
transition_resource_state(command_list, texture,
|
||||||
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||||
|
|
||||||
@ -21272,6 +21282,32 @@ static void test_copy_block_compressed_texture(void)
|
|||||||
"Got {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u), expected {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n",
|
"Got {0x%08x, 0x%08x, 0x%08x, 0x%08x} at (%u, %u), expected {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n",
|
||||||
got.x, got.y, got.z, got.w, x, y, expected.x, expected.y, expected.z, expected.w);
|
got.x, got.y, got.z, got.w, x, y, expected.x, expected.y, expected.z, expected.w);
|
||||||
|
|
||||||
|
reset_command_list(command_list, context.allocator);
|
||||||
|
get_texture_readback_with_command_list(texture, 2, &rb, queue, command_list);
|
||||||
|
block_id = 1;
|
||||||
|
expected.x = block_id << 8 | 0;
|
||||||
|
expected.y = block_id << 8 | 1;
|
||||||
|
expected.z = block_id << 8 | 2;
|
||||||
|
expected.w = block_id << 8 | 3;
|
||||||
|
got = *get_readback_uvec4(&rb, 0, 0);
|
||||||
|
release_resource_readback(&rb);
|
||||||
|
ok(compare_uvec4(&got, &expected),
|
||||||
|
"Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n",
|
||||||
|
got.x, got.y, got.z, got.w, expected.x, expected.y, expected.z, expected.w);
|
||||||
|
|
||||||
|
reset_command_list(command_list, context.allocator);
|
||||||
|
get_texture_readback_with_command_list(texture, 3, &rb, queue, command_list);
|
||||||
|
block_id = 2;
|
||||||
|
expected.x = block_id << 8 | 0;
|
||||||
|
expected.y = block_id << 8 | 1;
|
||||||
|
expected.z = block_id << 8 | 2;
|
||||||
|
expected.w = block_id << 8 | 3;
|
||||||
|
got = *get_readback_uvec4(&rb, 0, 0);
|
||||||
|
release_resource_readback(&rb);
|
||||||
|
ok(compare_uvec4(&got, &expected),
|
||||||
|
"Got {0x%08x, 0x%08x, 0x%08x, 0x%08x}, expected {0x%08x, 0x%08x, 0x%08x, 0x%08x}.\n",
|
||||||
|
got.x, got.y, got.z, got.w, expected.x, expected.y, expected.z, expected.w);
|
||||||
|
|
||||||
reset_command_list(command_list, context.allocator);
|
reset_command_list(command_list, context.allocator);
|
||||||
get_buffer_readback_with_command_list(dst_buffer, DXGI_FORMAT_R32_UINT, &rb, queue, command_list);
|
get_buffer_readback_with_command_list(dst_buffer, DXGI_FORMAT_R32_UINT, &rb, queue, command_list);
|
||||||
for (y = 0; y < 24 / format_block_height(DXGI_FORMAT_BC2_UNORM); ++y)
|
for (y = 0; y < 24 / format_block_height(DXGI_FORMAT_BC2_UNORM); ++y)
|
||||||
|
@ -18,6 +18,20 @@
|
|||||||
|
|
||||||
#include "d3d12_crosstest.h"
|
#include "d3d12_crosstest.h"
|
||||||
|
|
||||||
|
#define recreate_command_list(a, b, c) recreate_command_list_(__LINE__, a, b, c)
|
||||||
|
static void recreate_command_list_(unsigned int line, ID3D12Device *device,
|
||||||
|
ID3D12CommandAllocator *allocator, ID3D12GraphicsCommandList **command_list)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
hr = ID3D12CommandAllocator_Reset(allocator);
|
||||||
|
ok_(line)(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
|
||||||
|
ID3D12GraphicsCommandList_Release(*command_list);
|
||||||
|
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||||
|
allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)command_list);
|
||||||
|
ok_(line)(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_invalid_texture_resource_barriers(void)
|
static void test_invalid_texture_resource_barriers(void)
|
||||||
{
|
{
|
||||||
ID3D12Resource *texture, *readback_buffer, *upload_buffer;
|
ID3D12Resource *texture, *readback_buffer, *upload_buffer;
|
||||||
@ -78,12 +92,7 @@ static void test_invalid_texture_resource_barriers(void)
|
|||||||
wait_queue_idle(device, queue);
|
wait_queue_idle(device, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D12GraphicsCommandList_Release(command_list);
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
hr = ID3D12CommandAllocator_Reset(command_allocator);
|
|
||||||
ok(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
|
|
||||||
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
|
||||||
command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
|
|
||||||
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
|
|
||||||
|
|
||||||
/* The before state does not match with the previous state. */
|
/* The before state does not match with the previous state. */
|
||||||
transition_resource_state(command_list, texture,
|
transition_resource_state(command_list, texture,
|
||||||
@ -100,12 +109,7 @@ static void test_invalid_texture_resource_barriers(void)
|
|||||||
wait_queue_idle(device, queue);
|
wait_queue_idle(device, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = ID3D12CommandAllocator_Reset(command_allocator);
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
ok(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
|
|
||||||
ID3D12GraphicsCommandList_Release(command_list);
|
|
||||||
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
|
||||||
command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
|
|
||||||
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
|
|
||||||
|
|
||||||
/* Exactly one write state or a combination of read-only states are allowed. */
|
/* Exactly one write state or a combination of read-only states are allowed. */
|
||||||
transition_resource_state(command_list, texture,
|
transition_resource_state(command_list, texture,
|
||||||
@ -114,12 +118,7 @@ static void test_invalid_texture_resource_barriers(void)
|
|||||||
hr = ID3D12GraphicsCommandList_Close(command_list);
|
hr = ID3D12GraphicsCommandList_Close(command_list);
|
||||||
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = ID3D12CommandAllocator_Reset(command_allocator);
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
ok(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
|
|
||||||
ID3D12GraphicsCommandList_Release(command_list);
|
|
||||||
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
|
||||||
command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
|
|
||||||
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
|
|
||||||
|
|
||||||
/* Readback resources cannot transition from D3D12_RESOURCE_STATE_COPY_DEST. */
|
/* Readback resources cannot transition from D3D12_RESOURCE_STATE_COPY_DEST. */
|
||||||
transition_resource_state(command_list, readback_buffer,
|
transition_resource_state(command_list, readback_buffer,
|
||||||
@ -127,12 +126,7 @@ static void test_invalid_texture_resource_barriers(void)
|
|||||||
hr = ID3D12GraphicsCommandList_Close(command_list);
|
hr = ID3D12GraphicsCommandList_Close(command_list);
|
||||||
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = ID3D12CommandAllocator_Reset(command_allocator);
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
ok(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
|
|
||||||
ID3D12GraphicsCommandList_Release(command_list);
|
|
||||||
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
|
||||||
command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
|
|
||||||
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
|
|
||||||
|
|
||||||
/* Upload resources cannot transition from D3D12_RESOURCE_STATE_GENERIC_READ. */
|
/* Upload resources cannot transition from D3D12_RESOURCE_STATE_GENERIC_READ. */
|
||||||
transition_resource_state(command_list, upload_buffer,
|
transition_resource_state(command_list, upload_buffer,
|
||||||
@ -203,12 +197,7 @@ static void test_invalid_copy_texture_region(void)
|
|||||||
hr = ID3D12GraphicsCommandList_Close(command_list);
|
hr = ID3D12GraphicsCommandList_Close(command_list);
|
||||||
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = ID3D12CommandAllocator_Reset(command_allocator);
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
ok(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
|
|
||||||
ID3D12GraphicsCommandList_Release(command_list);
|
|
||||||
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
|
||||||
command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
|
|
||||||
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
|
|
||||||
|
|
||||||
src_location.PlacedFootprint.Footprint.Width = 4;
|
src_location.PlacedFootprint.Footprint.Width = 4;
|
||||||
src_location.PlacedFootprint.Footprint.Height = 4;
|
src_location.PlacedFootprint.Footprint.Height = 4;
|
||||||
@ -220,12 +209,7 @@ static void test_invalid_copy_texture_region(void)
|
|||||||
hr = ID3D12GraphicsCommandList_Close(command_list);
|
hr = ID3D12GraphicsCommandList_Close(command_list);
|
||||||
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = ID3D12CommandAllocator_Reset(command_allocator);
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
ok(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
|
|
||||||
ID3D12GraphicsCommandList_Release(command_list);
|
|
||||||
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
|
||||||
command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
|
|
||||||
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
|
|
||||||
|
|
||||||
/* row pitch must be multiple of D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT */
|
/* row pitch must be multiple of D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT */
|
||||||
src_location.PlacedFootprint.Footprint.RowPitch
|
src_location.PlacedFootprint.Footprint.RowPitch
|
||||||
@ -237,12 +221,7 @@ static void test_invalid_copy_texture_region(void)
|
|||||||
hr = ID3D12GraphicsCommandList_Close(command_list);
|
hr = ID3D12GraphicsCommandList_Close(command_list);
|
||||||
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
hr = ID3D12CommandAllocator_Reset(command_allocator);
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
ok(hr == S_OK, "Failed to reset command allocator, hr %#x.\n", hr);
|
|
||||||
ID3D12GraphicsCommandList_Release(command_list);
|
|
||||||
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
|
|
||||||
command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
|
|
||||||
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
|
|
||||||
|
|
||||||
dst_location.pResource = dst_buffer;
|
dst_location.pResource = dst_buffer;
|
||||||
dst_location.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
dst_location.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||||
@ -266,12 +245,42 @@ static void test_invalid_copy_texture_region(void)
|
|||||||
hr = ID3D12GraphicsCommandList_Close(command_list);
|
hr = ID3D12GraphicsCommandList_Close(command_list);
|
||||||
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
|
|
||||||
|
ID3D12Resource_Release(src_texture);
|
||||||
|
src_texture = create_default_texture2d(device, 4, 4, 1, 3, DXGI_FORMAT_BC3_UNORM,
|
||||||
|
D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||||
|
|
||||||
|
src_location.pResource = src_texture;
|
||||||
|
src_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||||
|
src_location.SubresourceIndex = 1;
|
||||||
|
|
||||||
|
/* coordinates must be multiple of block size even for smallest miplevels */
|
||||||
|
set_box(&box, 0, 0, 0, 2, 2, 1);
|
||||||
|
ID3D12GraphicsCommandList_CopyTextureRegion(command_list,
|
||||||
|
&dst_location, 0, 0, 0, &src_location, &box);
|
||||||
|
|
||||||
|
hr = ID3D12GraphicsCommandList_Close(command_list);
|
||||||
|
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
|
recreate_command_list(device, command_allocator, &command_list);
|
||||||
|
|
||||||
|
src_location.SubresourceIndex = 2;
|
||||||
|
|
||||||
|
/* coordinates must be multiple of block size even for smallest miplevels */
|
||||||
|
set_box(&box, 0, 0, 0, 1, 1, 1);
|
||||||
|
ID3D12GraphicsCommandList_CopyTextureRegion(command_list,
|
||||||
|
&dst_location, 0, 0, 0, &src_location, &box);
|
||||||
|
|
||||||
|
hr = ID3D12GraphicsCommandList_Close(command_list);
|
||||||
|
todo ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
ID3D12CommandAllocator_Release(command_allocator);
|
ID3D12CommandAllocator_Release(command_allocator);
|
||||||
ID3D12GraphicsCommandList_Release(command_list);
|
ID3D12GraphicsCommandList_Release(command_list);
|
||||||
ID3D12Resource_Release(dst_buffer);
|
ID3D12Resource_Release(dst_buffer);
|
||||||
ID3D12Resource_Release(src_buffer);
|
ID3D12Resource_Release(src_buffer);
|
||||||
ID3D12Resource_Release(dst_texture);
|
|
||||||
ID3D12Resource_Release(src_texture);
|
ID3D12Resource_Release(src_texture);
|
||||||
|
ID3D12Resource_Release(dst_texture);
|
||||||
refcount = ID3D12Device_Release(device);
|
refcount = ID3D12Device_Release(device);
|
||||||
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
|
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
|
||||||
}
|
}
|
||||||
|
@ -348,7 +348,9 @@ static void get_texture_readback_with_command_list(ID3D12Resource *texture, unsi
|
|||||||
|
|
||||||
miplevel = sub_resource % resource_desc.MipLevels;
|
miplevel = sub_resource % resource_desc.MipLevels;
|
||||||
rb->width = max(1, resource_desc.Width >> miplevel);
|
rb->width = max(1, resource_desc.Width >> miplevel);
|
||||||
|
rb->width = align(rb->width, format_block_width(resource_desc.Format));
|
||||||
rb->height = max(1, resource_desc.Height >> miplevel);
|
rb->height = max(1, resource_desc.Height >> miplevel);
|
||||||
|
rb->height = align(rb->height, format_block_height(resource_desc.Format));
|
||||||
rb->depth = resource_desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D
|
rb->depth = resource_desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D
|
||||||
? max(1, resource_desc.DepthOrArraySize >> miplevel) : 1;
|
? max(1, resource_desc.DepthOrArraySize >> miplevel) : 1;
|
||||||
rb->row_pitch = align(rb->width * format_size(resource_desc.Format), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
|
rb->row_pitch = align(rb->width * format_size(resource_desc.Format), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
|
||||||
|
Loading…
Reference in New Issue
Block a user