From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- tests/d3d12.c | 61 ++++++++++++++++++++++++++++++++++++++++ tests/d3d12_test_utils.h | 1 + 2 files changed, 62 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index bccface6de51..06543e9152f0 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -22025,6 +22025,7 @@ static void test_resource_allocation_info(void) ID3D12Device *device; unsigned int i, j; ULONG refcount; + UINT64 size;
static const unsigned int alignments[] = { @@ -22046,6 +22047,22 @@ static void test_resource_allocation_info(void) D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT, D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT + 1, }; + static const struct + { + unsigned int width; + unsigned int height; + unsigned int array_size; + DXGI_FORMAT format; + } + texture_tests[] = + { + { 4, 4, 1, DXGI_FORMAT_R8_UINT}, + { 8, 8, 1, DXGI_FORMAT_R8G8B8A8_UNORM}, + {16, 16, 1, DXGI_FORMAT_R8G8B8A8_UNORM}, + {16, 16, 6, DXGI_FORMAT_R8G8B8A8_UNORM}, + + {1024, 1024, 1, DXGI_FORMAT_R8G8B8A8_UNORM}, + };
if (!(device = create_device())) { @@ -22086,6 +22103,50 @@ static void test_resource_allocation_info(void) } }
+ desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + desc.MipLevels = 1; + desc.SampleDesc.Count = 1; + desc.SampleDesc.Quality = 0; + desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; + desc.Flags = 0; + + for (i = 0; i < ARRAY_SIZE(texture_tests); ++i) + { + desc.Width = texture_tests[i].width; + desc.Height = texture_tests[i].height; + desc.DepthOrArraySize = texture_tests[i].array_size; + desc.Format = texture_tests[i].format; + + desc.Alignment = 0; + info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &desc); + ok(info.Alignment >= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT, + "Got unexpected alignment %"PRIu64".\n", info.Alignment); + check_alignment(info.SizeInBytes, info.Alignment); + + desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; + info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &desc); + ok(info.Alignment >= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT, + "Got unexpected alignment %"PRIu64".\n", info.Alignment); + check_alignment(info.SizeInBytes, info.Alignment); + + desc.Alignment = D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT; + info = ID3D12Device_GetResourceAllocationInfo(device, 0, 1, &desc); + ok(info.Alignment >= D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT, + "Got unexpected alignment %"PRIu64".\n", info.Alignment); + size = desc.Width * desc.Height * desc.DepthOrArraySize * format_size(desc.Format); + if (size <= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT) + { + check_alignment(info.SizeInBytes, info.Alignment); + } + else + { + ok(info.SizeInBytes == ~(UINT64)0, + "Got unexpected size %"PRIu64".\n", info.SizeInBytes); + ok(info.Alignment >= D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT, + "Got unexpected alignment %"PRIu64".\n", info.Alignment); + } + } + refcount = ID3D12Device_Release(device); ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount); } diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index d4265fc893c8..6ccbc64981b9 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -227,6 +227,7 @@ static unsigned int format_size(DXGI_FORMAT format) { case DXGI_FORMAT_UNKNOWN: case DXGI_FORMAT_A8_UNORM: + case DXGI_FORMAT_R8_UINT: return 1; case DXGI_FORMAT_R32G32B32A32_FLOAT: case DXGI_FORMAT_R32G32B32A32_UINT: