mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests: Add test for creating committed resource.
This commit is contained in:
parent
4175bec471
commit
768dffe9d6
@ -457,6 +457,96 @@ static void test_create_command_queue(void)
|
||||
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
|
||||
}
|
||||
|
||||
static void test_create_committed_resource(void)
|
||||
{
|
||||
D3D12_HEAP_PROPERTIES heap_properties;
|
||||
D3D12_RESOURCE_DESC resource_desc;
|
||||
ID3D12Device *device, *tmp_device;
|
||||
D3D12_CLEAR_VALUE clear_value;
|
||||
ID3D12Resource *resource;
|
||||
ULONG refcount;
|
||||
HRESULT hr;
|
||||
|
||||
if (!(device = create_device()))
|
||||
{
|
||||
skip("Failed to create device.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&heap_properties, 0, sizeof(heap_properties));
|
||||
heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
|
||||
resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
resource_desc.Alignment = 0;
|
||||
resource_desc.Width = 32;
|
||||
resource_desc.Height = 32;
|
||||
resource_desc.DepthOrArraySize = 1;
|
||||
resource_desc.MipLevels = 1;
|
||||
resource_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
resource_desc.SampleDesc.Count = 1;
|
||||
resource_desc.SampleDesc.Quality = 0;
|
||||
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
|
||||
resource_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
|
||||
|
||||
clear_value.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
clear_value.Color[0] = 1.0f;
|
||||
clear_value.Color[1] = 0.0f;
|
||||
clear_value.Color[2] = 0.0f;
|
||||
clear_value.Color[3] = 1.0f;
|
||||
|
||||
hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
|
||||
&resource_desc, D3D12_RESOURCE_STATE_RENDER_TARGET, &clear_value,
|
||||
&IID_ID3D12Resource, (void **)&resource);
|
||||
ok(SUCCEEDED(hr), "CreateCommittedResource failed, hr %#x.\n", hr);
|
||||
|
||||
refcount = get_refcount(device);
|
||||
ok(refcount == 2, "Got unexpected refcount %u.\n", (unsigned int)refcount);
|
||||
hr = ID3D12Resource_GetDevice(resource, &IID_ID3D12Device, (void **)&tmp_device);
|
||||
ok(SUCCEEDED(hr), "GetDevice failed, hr %#x.\n", hr);
|
||||
refcount = get_refcount(device);
|
||||
ok(refcount == 3, "Got unexpected refcount %u.\n", (unsigned int)refcount);
|
||||
refcount = ID3D12Device_Release(tmp_device);
|
||||
ok(refcount == 2, "Got unexpected refcount %u.\n", (unsigned int)refcount);
|
||||
|
||||
check_interface(resource, &IID_ID3D12Object, TRUE);
|
||||
check_interface(resource, &IID_ID3D12DeviceChild, TRUE);
|
||||
check_interface(resource, &IID_ID3D12Pageable, TRUE);
|
||||
check_interface(resource, &IID_ID3D12Resource, TRUE);
|
||||
|
||||
refcount = ID3D12Resource_Release(resource);
|
||||
ok(!refcount, "ID3D12Resource has %u references left.\n", (unsigned int)refcount);
|
||||
|
||||
heap_properties.Type = D3D12_HEAP_TYPE_UPLOAD;
|
||||
|
||||
resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
resource_desc.Alignment = 0;
|
||||
resource_desc.Width = 32;
|
||||
resource_desc.Height = 1;
|
||||
resource_desc.DepthOrArraySize = 1;
|
||||
resource_desc.MipLevels = 1;
|
||||
resource_desc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
resource_desc.SampleDesc.Count = 1;
|
||||
resource_desc.SampleDesc.Quality = 0;
|
||||
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||
|
||||
hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
|
||||
&resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL,
|
||||
&IID_ID3D12Resource, (void **)&resource);
|
||||
ok(SUCCEEDED(hr), "CreateCommittedResource failed, hr %#x.\n", hr);
|
||||
|
||||
check_interface(resource, &IID_ID3D12Object, TRUE);
|
||||
check_interface(resource, &IID_ID3D12DeviceChild, TRUE);
|
||||
check_interface(resource, &IID_ID3D12Pageable, TRUE);
|
||||
check_interface(resource, &IID_ID3D12Resource, TRUE);
|
||||
|
||||
refcount = ID3D12Resource_Release(resource);
|
||||
ok(!refcount, "ID3D12Resource has %u references left.\n", (unsigned int)refcount);
|
||||
|
||||
refcount = ID3D12Device_Release(device);
|
||||
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
|
||||
}
|
||||
|
||||
START_TEST(d3d12)
|
||||
{
|
||||
ID3D12Debug *debug;
|
||||
@ -473,4 +563,5 @@ START_TEST(d3d12)
|
||||
test_create_command_allocator();
|
||||
test_create_command_list();
|
||||
test_create_command_queue();
|
||||
test_create_committed_resource();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user