mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
tests: Add test for depth rendering without pixel shader.
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:
parent
a39d2aa3a8
commit
08ff23a0b1
100
tests/d3d12.c
100
tests/d3d12.c
@ -4792,6 +4792,105 @@ static void test_scissor(void)
|
||||
destroy_test_context(&context);
|
||||
}
|
||||
|
||||
static void test_draw_depth_no_ps(void)
|
||||
{
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc;
|
||||
ID3D12GraphicsCommandList *command_list;
|
||||
D3D12_INPUT_LAYOUT_DESC input_layout;
|
||||
struct depth_stencil_resource ds;
|
||||
struct test_context_desc desc;
|
||||
D3D12_VERTEX_BUFFER_VIEW vbv;
|
||||
struct test_context context;
|
||||
ID3D12CommandQueue *queue;
|
||||
ID3D12Resource *vb;
|
||||
HRESULT hr;
|
||||
|
||||
static const D3D12_INPUT_ELEMENT_DESC layout_desc[] =
|
||||
{
|
||||
{"POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0},
|
||||
};
|
||||
static const struct
|
||||
{
|
||||
struct vec4 position;
|
||||
}
|
||||
quad[] =
|
||||
{
|
||||
{{-1.0f, -1.0f, 0.5f, 1.0f}},
|
||||
{{-1.0f, 1.0f, 0.5f, 1.0f}},
|
||||
{{ 1.0f, -1.0f, 0.5f, 1.0f}},
|
||||
{{ 1.0f, 1.0f, 0.5f, 1.0f}},
|
||||
};
|
||||
static const DWORD vs_code[] =
|
||||
{
|
||||
#if 0
|
||||
void main(float4 in_position : POSITION, out float4 out_position : SV_POSITION)
|
||||
{
|
||||
out_position = in_position;
|
||||
}
|
||||
#endif
|
||||
0x43425844, 0xa7a2f22d, 0x83ff2560, 0xe61638bd, 0x87e3ce90, 0x00000001, 0x000000d8, 0x00000003,
|
||||
0x0000002c, 0x00000060, 0x00000094, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
|
||||
0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x49534f50, 0x4e4f4954, 0xababab00,
|
||||
0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000001, 0x00000003,
|
||||
0x00000000, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x52444853, 0x0000003c, 0x00010040,
|
||||
0x0000000f, 0x0300005f, 0x001010f2, 0x00000000, 0x04000067, 0x001020f2, 0x00000000, 0x00000001,
|
||||
0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x0100003e,
|
||||
};
|
||||
static const D3D12_SHADER_BYTECODE vs = {vs_code, sizeof(vs_code)};
|
||||
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.no_render_target = true;
|
||||
if (!init_test_context(&context, &desc))
|
||||
return;
|
||||
command_list = context.list;
|
||||
queue = context.queue;
|
||||
|
||||
vb = create_upload_buffer(context.device, sizeof(quad), quad);
|
||||
|
||||
vbv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(vb);
|
||||
vbv.StrideInBytes = sizeof(*quad);
|
||||
vbv.SizeInBytes = sizeof(quad);
|
||||
|
||||
init_depth_stencil(&ds, context.device, 640, 480, 1, DXGI_FORMAT_D32_FLOAT, 0, NULL);
|
||||
set_viewport(&context.viewport, 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 1.0f);
|
||||
set_rect(&context.scissor_rect, 0, 0, 640, 480);
|
||||
|
||||
context.root_signature = create_empty_root_signature(context.device,
|
||||
D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
|
||||
input_layout.pInputElementDescs = layout_desc;
|
||||
input_layout.NumElements = ARRAY_SIZE(layout_desc);
|
||||
init_pipeline_state_desc(&pso_desc, context.root_signature, 0, &vs, NULL, &input_layout);
|
||||
memset(&pso_desc.PS, 0, sizeof(pso_desc.PS));
|
||||
pso_desc.NumRenderTargets = 0;
|
||||
pso_desc.DSVFormat = DXGI_FORMAT_D32_FLOAT;
|
||||
pso_desc.DepthStencilState.DepthEnable = TRUE;
|
||||
pso_desc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
|
||||
pso_desc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
||||
hr = ID3D12Device_CreateGraphicsPipelineState(context.device, &pso_desc,
|
||||
&IID_ID3D12PipelineState, (void **)&context.pipeline_state);
|
||||
ok(hr == S_OK, "Failed to create graphics pipeline state, hr %#x.\n", hr);
|
||||
|
||||
ID3D12GraphicsCommandList_ClearDepthStencilView(command_list, ds.dsv_handle,
|
||||
D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, NULL);
|
||||
|
||||
ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 0, NULL, FALSE, &ds.dsv_handle);
|
||||
ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature);
|
||||
ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state);
|
||||
ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||
ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport);
|
||||
ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect);
|
||||
ID3D12GraphicsCommandList_IASetVertexBuffers(command_list, 0, 1, &vbv);
|
||||
ID3D12GraphicsCommandList_DrawInstanced(command_list, 4, 1, 0, 0);
|
||||
|
||||
transition_resource_state(command_list, ds.texture,
|
||||
D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_COPY_SOURCE);
|
||||
check_sub_resource_float(ds.texture, 0, queue, command_list, 0.5f, 1);
|
||||
|
||||
destroy_depth_stencil(&ds);
|
||||
ID3D12Resource_Release(vb);
|
||||
destroy_test_context(&context);
|
||||
}
|
||||
|
||||
static void test_draw_depth_only(void)
|
||||
{
|
||||
D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc;
|
||||
@ -21533,6 +21632,7 @@ START_TEST(d3d12)
|
||||
run_test(test_fragment_coords);
|
||||
run_test(test_fractional_viewports);
|
||||
run_test(test_scissor);
|
||||
run_test(test_draw_depth_no_ps);
|
||||
run_test(test_draw_depth_only);
|
||||
run_test(test_draw_uav_only);
|
||||
run_test(test_texture_resource_barriers);
|
||||
|
Loading…
x
Reference in New Issue
Block a user