vkd3d/tests: Add tests for D3D12_HEAP_TYPE_CUSTOM.

Signed-off-by: Conor McCarthy <cmccarthy@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Conor McCarthy 2019-10-25 11:13:22 +10:00 committed by Alexandre Julliard
parent 87cc75b7e6
commit a38ee68f93

View File

@ -697,6 +697,22 @@ static bool is_standard_swizzle_64kb_supported(ID3D12Device *device)
return options.StandardSwizzle64KBSupported;
}
static bool is_memory_pool_L1_supported(ID3D12Device *device)
{
D3D12_FEATURE_DATA_ARCHITECTURE architecture;
HRESULT hr;
memset(&architecture, 0, sizeof(architecture));
if (FAILED(hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_ARCHITECTURE,
&architecture, sizeof(architecture))))
{
trace("Failed to check feature support, hr %#x.\n", hr);
return false;
}
return !architecture.UMA;
}
#define create_cb_root_signature(a, b, c, e) create_cb_root_signature_(__LINE__, a, b, c, e)
static ID3D12RootSignature *create_cb_root_signature_(unsigned int line,
ID3D12Device *device, unsigned int reg_idx, D3D12_SHADER_VISIBILITY shader_visibility,
@ -1962,10 +1978,11 @@ static void test_create_heap(void)
D3D12_FEATURE_DATA_D3D12_OPTIONS options;
D3D12_HEAP_DESC desc, result_desc;
ID3D12Device *device, *tmp_device;
bool is_pool_L1_supported;
HRESULT hr, expected_hr;
unsigned int i, j;
ID3D12Heap *heap;
ULONG refcount;
HRESULT hr;
static const struct
{
@ -1991,6 +2008,27 @@ static void test_create_heap(void)
{D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES, "textures"},
{D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES, "rt_ds_textures"},
};
static const struct
{
D3D12_CPU_PAGE_PROPERTY page_property;
D3D12_MEMORY_POOL pool_preference;
HRESULT expected_hr;
}
custom_tests[] =
{
{D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, E_INVALIDARG},
{D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE, D3D12_MEMORY_POOL_UNKNOWN, E_INVALIDARG},
{D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE, D3D12_MEMORY_POOL_UNKNOWN, E_INVALIDARG},
{D3D12_CPU_PAGE_PROPERTY_WRITE_BACK, D3D12_MEMORY_POOL_UNKNOWN, E_INVALIDARG},
{D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_L0, E_INVALIDARG},
{D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE, D3D12_MEMORY_POOL_L0, S_OK},
{D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE, D3D12_MEMORY_POOL_L0, S_OK},
{D3D12_CPU_PAGE_PROPERTY_WRITE_BACK, D3D12_MEMORY_POOL_L0, S_OK},
{D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_L1, E_INVALIDARG},
{D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE, D3D12_MEMORY_POOL_L1, S_OK},
{D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE, D3D12_MEMORY_POOL_L1, E_INVALIDARG},
{D3D12_CPU_PAGE_PROPERTY_WRITE_BACK, D3D12_MEMORY_POOL_L1, E_INVALIDARG},
};
if (!(device = create_device()))
{
@ -2083,6 +2121,31 @@ static void test_create_heap(void)
refcount = ID3D12Heap_Release(heap);
ok(!refcount, "ID3D12Heap has %u references left.\n", (unsigned int)refcount);
is_pool_L1_supported = is_memory_pool_L1_supported(device);
desc.Properties.Type = D3D12_HEAP_TYPE_CUSTOM;
desc.Properties.CreationNodeMask = 1;
desc.Properties.VisibleNodeMask = 1;
for (i = 0; i < ARRAY_SIZE(custom_tests); ++i)
{
vkd3d_test_set_context("Test %u", i);
desc.Properties.CPUPageProperty = custom_tests[i].page_property;
desc.Properties.MemoryPoolPreference = custom_tests[i].pool_preference;
hr = ID3D12Device_CreateHeap(device, &desc, &IID_ID3D12Heap, (void **)&heap);
expected_hr = (custom_tests[i].pool_preference != D3D12_MEMORY_POOL_L1 || is_pool_L1_supported) ? custom_tests[i].expected_hr : E_INVALIDARG;
ok(hr == expected_hr, "Test %u, page_property %u, pool_preference %u: Got hr %#x, expected %#x.\n",
i, custom_tests[i].page_property, custom_tests[i].pool_preference, hr, expected_hr);
if (FAILED(hr))
continue;
result_desc = ID3D12Heap_GetDesc(heap);
check_heap_desc(&result_desc, &desc);
refcount = ID3D12Heap_Release(heap);
ok(!refcount, "ID3D12Heap has %u references left.\n", (unsigned int)refcount);
}
vkd3d_test_set_context(NULL);
done:
refcount = ID3D12Device_Release(device);
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);