tests: Add test for vCoverage shader register.

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:
Józef Kucia 2019-01-24 15:09:25 +01:00 committed by Alexandre Julliard
parent 639693de86
commit abe857d2de

View File

@ -23145,6 +23145,165 @@ static void test_sample_mask(void)
destroy_test_context(&context);
}
static void test_coverage(void)
{
static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc;
ID3D12GraphicsCommandList *command_list;
D3D12_CPU_DESCRIPTOR_HANDLE ms_rtv;
ID3D12Resource *ms_render_target;
ID3D12PipelineState *pso_resolve;
struct test_context_desc desc;
struct test_context context;
ID3D12DescriptorHeap *heap;
ID3D12CommandQueue *queue;
unsigned int i;
HRESULT hr;
static const DWORD ps_code[] =
{
#if 0
uint4 main(uint coverage : SV_Coverage) : SV_Target
{
return coverage;
}
#endif
0x43425844, 0x0d652986, 0x6144c247, 0x743bacfa, 0x95068994, 0x00000001, 0x000000ac, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000034, 0x00000050, 0x0000000d,
0x0100086a, 0x0200005f, 0x00023001, 0x03000065, 0x001020f2, 0x00000000, 0x04000036, 0x001020f2,
0x00000000, 0x00023006, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)};
static const DWORD ps_resolve_code[] =
{
#if 0
Texture2DMS<uint> t;
uint4 main(float4 position : SV_Position) : SV_Target
{
return t.Load((int2)position.xy, 0);
}
#endif
0x43425844, 0x280a495f, 0x88543834, 0x1fd0597d, 0xe7ed74ac, 0x00000001, 0x00000154, 0x00000003,
0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000030f, 0x505f5653, 0x7469736f, 0x006e6f69,
0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000001,
0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000b8, 0x00000050,
0x0000002e, 0x0100086a, 0x04002058, 0x00107000, 0x00000000, 0x00004444, 0x04002064, 0x00101032,
0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0500001b,
0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x08000036, 0x001000c2, 0x00000000, 0x00004002,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x8b00002e, 0x80000102, 0x00111103, 0x00100012,
0x00000000, 0x00100e46, 0x00000000, 0x00107e46, 0x00000000, 0x00004001, 0x00000000, 0x05000036,
0x001020f2, 0x00000000, 0x00100006, 0x00000000, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps_resolve = {ps_resolve_code, sizeof(ps_resolve_code)};
static const struct
{
unsigned int sample_mask;
unsigned int expected_result;
}
tests[] =
{
{0x01, 0x1},
{0x03, 0x3},
{0x07, 0x7},
{0x09, 0x9},
{0x0d, 0xd},
{0x0f, 0xf},
{0xff, 0xf},
{ ~0u, 0xf},
};
if (use_warp_device)
{
skip("Sample shading tests fail on WARP.\n");
return;
}
memset(&desc, 0, sizeof(desc));
desc.rt_width = desc.rt_height = 32;
desc.rt_format = DXGI_FORMAT_R32_UINT;
desc.rt_descriptor_count = 2;
desc.no_root_signature = true;
if (!init_test_context(&context, &desc))
return;
command_list = context.list;
queue = context.queue;
context.root_signature = create_texture_root_signature(context.device,
D3D12_SHADER_VISIBILITY_PIXEL, 1, 0);
ms_rtv = get_cpu_rtv_handle(&context, context.rtv_heap, 1);
desc.sample_desc.Count = 4;
create_render_target(&context, &desc, &ms_render_target, &ms_rtv);
heap = create_gpu_descriptor_heap(context.device, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 1);
ID3D12Device_CreateShaderResourceView(context.device, ms_render_target, NULL,
get_cpu_descriptor_handle(&context, heap, 0));
pso_resolve = create_pipeline_state(context.device,
context.root_signature, context.render_target_desc.Format, NULL, &ps_resolve, NULL);
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
vkd3d_test_set_context("sample mask %#x", tests[i].sample_mask);
if (context.pipeline_state)
ID3D12PipelineState_Release(context.pipeline_state);
init_pipeline_state_desc(&pso_desc, context.root_signature,
context.render_target_desc.Format, NULL, &ps, NULL);
pso_desc.SampleMask = tests[i].sample_mask;
pso_desc.SampleDesc.Count = 4;
hr = ID3D12Device_CreateGraphicsPipelineState(context.device, &pso_desc,
&IID_ID3D12PipelineState, (void **)&context.pipeline_state);
ok(hr == S_OK, "Failed to create pipeline, hr %#x.\n", hr);
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL);
ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, ms_rtv, white, 0, NULL);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &ms_rtv, FALSE, NULL);
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
transition_resource_state(command_list, ms_render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, FALSE, NULL);
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
ID3D12GraphicsCommandList_SetPipelineState(command_list, pso_resolve);
ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
ID3D12GraphicsCommandList_SetDescriptorHeaps(command_list, 1, &heap);
ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(command_list, 0,
get_gpu_descriptor_handle(&context, heap, 0));
ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
transition_resource_state(command_list, ms_render_target,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
check_sub_resource_uint(context.render_target, 0, queue, command_list, tests[i].expected_result, 0);
reset_command_list(command_list, context.allocator);
transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET);
}
vkd3d_test_set_context(NULL);
ID3D12DescriptorHeap_Release(heap);
ID3D12PipelineState_Release(pso_resolve);
ID3D12Resource_Release(ms_render_target);
destroy_test_context(&context);
}
static void test_primitive_restart(void)
{
static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
@ -23546,6 +23705,7 @@ START_TEST(d3d12)
run_test(test_dual_source_blending);
run_test(test_multisample_rendering);
run_test(test_sample_mask);
run_test(test_coverage);
run_test(test_primitive_restart);
run_test(test_vertex_shader_stream_output);
}