libs/vkd3d: Implement d3d12_command_list_ClearDepthStencilView().

This commit is contained in:
Henri Verbeet
2016-11-02 20:57:23 +01:00
parent f252d6cd31
commit 2213e126cf
4 changed files with 209 additions and 46 deletions

View File

@@ -323,6 +323,7 @@ static unsigned int format_size(DXGI_FORMAT format)
{
switch (format)
{
case DXGI_FORMAT_D32_FLOAT:
case DXGI_FORMAT_R8G8B8A8_UNORM:
case DXGI_FORMAT_B8G8R8A8_UNORM:
return 4;
@@ -2290,6 +2291,118 @@ static void test_multithread_fence_wait(void)
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
}
static void test_clear_depth_stencil_view(void)
{
D3D12_COMMAND_QUEUE_DESC command_queue_desc;
ID3D12CommandAllocator *command_allocator;
D3D12_DESCRIPTOR_HEAP_DESC dsv_heap_desc;
ID3D12GraphicsCommandList *command_list;
D3D12_CPU_DESCRIPTOR_HANDLE dsv_handle;
D3D12_HEAP_PROPERTIES heap_properties;
D3D12_RESOURCE_DESC resource_desc;
unsigned int dsv_increment_size;
ID3D12DescriptorHeap *dsv_heap;
D3D12_CLEAR_VALUE clear_value;
struct resource_readback rb;
ID3D12CommandQueue *queue;
ID3D12Resource *resource;
ID3D12Device *device;
unsigned int x, y;
ULONG refcount;
HRESULT hr;
if (!(device = create_device()))
{
skip("Failed to create device.\n");
return;
}
command_queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
command_queue_desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
command_queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
command_queue_desc.NodeMask = 0;
hr = ID3D12Device_CreateCommandQueue(device, &command_queue_desc,
&IID_ID3D12CommandQueue, (void **)&queue);
ok(SUCCEEDED(hr), "CreateCommandQueue failed, hr %#x.\n", hr);
hr = ID3D12Device_CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_DIRECT,
&IID_ID3D12CommandAllocator, (void **)&command_allocator);
ok(SUCCEEDED(hr), "CreateCommandAllocator failed, hr %#x.\n", hr);
hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list);
ok(SUCCEEDED(hr), "CreateCommandList failed, hr %#x.\n", hr);
dsv_heap_desc.NumDescriptors = 1;
dsv_heap_desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV;
dsv_heap_desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE;
dsv_heap_desc.NodeMask = 0;
hr = ID3D12Device_CreateDescriptorHeap(device, &dsv_heap_desc,
&IID_ID3D12DescriptorHeap, (void **)&dsv_heap);
ok(SUCCEEDED(hr), "CreateDescriptorHeap failed, hr %#x.\n", hr);
dsv_increment_size = ID3D12Device_GetDescriptorHandleIncrementSize(device,
D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
trace("DSV descriptor handle increment size: %u.\n", dsv_increment_size);
ok(dsv_increment_size, "Got unexpectd increment size %#x.\n", dsv_increment_size);
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_D32_FLOAT;
resource_desc.SampleDesc.Count = 1;
resource_desc.SampleDesc.Quality = 0;
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
resource_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
clear_value.Format = DXGI_FORMAT_D32_FLOAT;
clear_value.DepthStencil.Depth = 0.5f;
clear_value.DepthStencil.Stencil = 0x3;
hr = ID3D12Device_CreateCommittedResource(device, &heap_properties, D3D12_HEAP_FLAG_NONE, &resource_desc,
D3D12_RESOURCE_STATE_DEPTH_WRITE, &clear_value, &IID_ID3D12Resource, (void **)&resource);
ok(SUCCEEDED(hr), "CreateCommittedResource failed, hr %#x.\n", hr);
dsv_handle = ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(dsv_heap);
ID3D12Device_CreateDepthStencilView(device, resource, NULL, dsv_handle);
ID3D12GraphicsCommandList_ClearDepthStencilView(command_list, dsv_handle,
D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, 0.75f, 0x7, 0, NULL);
transition_resource_state(command_list, resource,
D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_COPY_SOURCE);
hr = ID3D12GraphicsCommandList_Close(command_list);
ok(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr);
exec_command_list(queue, command_list);
wait_queue_idle(device, queue);
hr = ID3D12CommandAllocator_Reset(command_allocator);
ok(SUCCEEDED(hr), "Command allocator reset failed, hr %#x.\n", hr);
hr = ID3D12GraphicsCommandList_Reset(command_list, command_allocator, NULL);
ok(SUCCEEDED(hr), "Command list reset failed, hr %#x.\n", hr);
get_texture_readback_with_command_list(resource, 0, &rb, queue, command_list);
for (y = 0; y < resource_desc.Height; ++y)
{
for (x = 0; x < resource_desc.Width; ++x)
{
unsigned int v = get_readback_uint(&rb, x, y);
ok(v == 0x3f400000, "Got unexpected value 0x%08x at (%u, %u).\n", v, x, y);
}
}
release_resource_readback(&rb);
ID3D12GraphicsCommandList_Release(command_list);
ID3D12CommandAllocator_Release(command_allocator);
ID3D12Resource_Release(resource);
ID3D12CommandQueue_Release(queue);
ID3D12DescriptorHeap_Release(dsv_heap);
refcount = ID3D12Device_Release(device);
ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount);
}
static void test_clear_render_target_view(void)
{
static const float green[] = { 0.0f, 1.0f, 0.0f, 1.0f };
@@ -3138,6 +3251,7 @@ START_TEST(d3d12)
run_test(test_cpu_signal_fence);
run_test(test_gpu_signal_fence);
run_test(test_multithread_fence_wait);
run_test(test_clear_depth_stencil_view);
run_test(test_clear_render_target_view);
run_test(test_draw_instanced);
run_test(test_texture_resource_barriers);