tests: Add test for oMask 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-23 12:46:52 +01:00 committed by Alexandre Julliard
parent 54d9714fcd
commit b59ddfaec3

View File

@ -10991,7 +10991,6 @@ static void test_texture_ld(void)
}
memset(&desc, 0, sizeof(desc));
desc.rt_width = desc.rt_height = 32;
desc.no_root_signature = true;
if (!init_test_context(&context, &desc))
return;
@ -23061,6 +23060,91 @@ static void test_multisample_rendering(void)
destroy_test_context(&context);
}
static void test_sample_mask(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;
struct test_context_desc desc;
struct test_context context;
ID3D12CommandQueue *queue;
uint32_t sample_mask;
HRESULT hr;
static const DWORD ps_code[] =
{
#if 0
uint mask;
float4 main(in float4 pos : SV_Position, out uint sample_mask : SV_Coverage) : SV_Target
{
sample_mask = mask;
return float4(0.0, 1.0, 0.0, 1.0);
}
#endif
0x43425844, 0xfab05c6c, 0xeba1b017, 0xf4493502, 0x72ce5d05, 0x00000001, 0x00000128, 0x00000003,
0x0000002c, 0x00000060, 0x000000b8, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x505f5653, 0x7469736f, 0x006e6f69,
0x4e47534f, 0x00000050, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000000, 0x00000003,
0x00000000, 0x0000000f, 0x00000042, 0x00000000, 0x00000000, 0x00000001, 0xffffffff, 0x00000e01,
0x545f5653, 0x65677261, 0x56530074, 0x766f435f, 0x67617265, 0xabab0065, 0x58454853, 0x00000068,
0x00000050, 0x0000001a, 0x0100086a, 0x04000059, 0x00208e46, 0x00000000, 0x00000001, 0x03000065,
0x001020f2, 0x00000000, 0x02000065, 0x0000f000, 0x08000036, 0x001020f2, 0x00000000, 0x00004002,
0x00000000, 0x3f800000, 0x00000000, 0x3f800000, 0x05000036, 0x0000f001, 0x0020800a, 0x00000000,
0x00000000, 0x0100003e,
};
static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)};
memset(&desc, 0, sizeof(desc));
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_32bit_constants_root_signature(context.device,
0, 1, D3D12_SHADER_VISIBILITY_PIXEL);
init_pipeline_state_desc(&pso_desc, context.root_signature,
context.render_target_desc.Format, NULL, &ps, NULL);
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);
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);
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);
sample_mask = 0xa;
ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(command_list, 0, 1, &sample_mask, 0);
ID3D12GraphicsCommandList_DrawInstanced(command_list, 3, 1, 0, 0);
transition_resource_state(command_list, ms_render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_RESOLVE_SOURCE);
transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_RESOLVE_DEST);
ID3D12GraphicsCommandList_ResolveSubresource(command_list,
context.render_target, 0, ms_render_target, 0, context.render_target_desc.Format);
transition_resource_state(command_list, context.render_target,
D3D12_RESOURCE_STATE_RESOLVE_DEST, D3D12_RESOURCE_STATE_COPY_SOURCE);
check_sub_resource_uint(context.render_target, 0, queue, command_list, 0xff7fff7f, 2);
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};
@ -23461,6 +23545,7 @@ START_TEST(d3d12)
run_test(test_blend_factor);
run_test(test_dual_source_blending);
run_test(test_multisample_rendering);
run_test(test_sample_mask);
run_test(test_primitive_restart);
run_test(test_vertex_shader_stream_output);
}