d3d11/tests: Add test for forced early depth stencil.

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 2017-07-24 00:15:56 +02:00 committed by Alexandre Julliard
parent a6d26527c6
commit 48d5ace688

View File

@ -20666,6 +20666,127 @@ static void test_fractional_viewports(void)
release_test_context(&test_context);
}
static void test_early_depth_stencil(void)
{
ID3D11DepthStencilState *depth_stencil_state;
D3D11_DEPTH_STENCIL_DESC depth_stencil_desc;
ID3D11Texture2D *texture, *depth_texture;
struct d3d11_test_context test_context;
D3D11_TEXTURE2D_DESC texture_desc;
ID3D11UnorderedAccessView *uav;
ID3D11DeviceContext *context;
ID3D11DepthStencilView *dsv;
ID3D11PixelShader *ps;
ID3D11Device *device;
D3D11_VIEWPORT vp;
HRESULT hr;
static const DWORD ps_code[] =
{
#if 0
RWTexture2D<int> u;
[earlydepthstencil]
float4 main() : SV_Target
{
InterlockedAdd(u[uint2(0, 0)], 1);
return float4(1.0f, 1.0f, 1.0f, 1.0f);
}
#endif
0x43425844, 0xda4325ad, 0xc01d3815, 0xfd610cc9, 0x8ed1e351, 0x00000001, 0x000000ec, 0x00000003,
0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x00000074, 0x00000050, 0x0000001d,
0x0100286a, 0x0400189c, 0x0011e000, 0x00000001, 0x00003333, 0x03000065, 0x001020f2, 0x00000000,
0x0a0000ad, 0x0011e000, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00004001, 0x00000001, 0x08000036, 0x001020f2, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000,
0x3f800000, 0x3f800000, 0x0100003e,
};
static const D3D_FEATURE_LEVEL feature_level = D3D_FEATURE_LEVEL_11_0;
static const UINT values[4] = {0};
if (!init_test_context(&test_context, &feature_level))
return;
device = test_context.device;
context = test_context.immediate_context;
depth_stencil_desc.DepthEnable = TRUE;
depth_stencil_desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
depth_stencil_desc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
depth_stencil_desc.StencilEnable = FALSE;
hr = ID3D11Device_CreateDepthStencilState(device, &depth_stencil_desc, &depth_stencil_state);
ok(SUCCEEDED(hr), "Failed to create depth stencil state, hr %#x.\n", hr);
texture_desc.Width = 1;
texture_desc.Height = 1;
texture_desc.MipLevels = 1;
texture_desc.ArraySize = 1;
texture_desc.Format = DXGI_FORMAT_R32_SINT;
texture_desc.SampleDesc.Count = 1;
texture_desc.SampleDesc.Quality = 0;
texture_desc.Usage = D3D11_USAGE_DEFAULT;
texture_desc.BindFlags = D3D11_BIND_UNORDERED_ACCESS;
texture_desc.CPUAccessFlags = 0;
texture_desc.MiscFlags = 0;
hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = ID3D11Device_CreateUnorderedAccessView(device, (ID3D11Resource *)texture, NULL, &uav);
ok(SUCCEEDED(hr), "Failed to create unordered access view, hr %#x.\n", hr);
ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
texture_desc.Format = DXGI_FORMAT_D32_FLOAT;
texture_desc.Usage = D3D11_USAGE_DEFAULT;
texture_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &depth_texture);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = ID3D11Device_CreateDepthStencilView(device, (ID3D11Resource *)depth_texture, NULL, &dsv);
ok(SUCCEEDED(hr), "Failed to create depth stencil view, hr %#x.\n", hr);
hr = ID3D11Device_CreatePixelShader(device, ps_code, sizeof(ps_code), NULL, &ps);
ok(SUCCEEDED(hr), "Failed to create pixel shader, hr %#x.\n", hr);
ID3D11DeviceContext_PSSetShader(context, ps, NULL, 0);
memset(&vp, 0, sizeof(vp));
vp.Width = 1.0f;
vp.Height = 100.0f;
vp.MinDepth = 0.5f;
vp.MaxDepth = 0.5f;
ID3D11DeviceContext_RSSetViewports(context, 1, &vp);
ID3D11DeviceContext_OMSetDepthStencilState(context, depth_stencil_state, 0);
ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context,
1, &test_context.backbuffer_rtv, dsv, 1, 1, &uav, NULL);
ID3D11DeviceContext_ClearUnorderedAccessViewUint(context, uav, values);
ID3D11DeviceContext_ClearDepthStencilView(context, dsv, D3D11_CLEAR_DEPTH, 0.6f, 0);
draw_quad(&test_context);
check_texture_color(texture, 100, 1);
draw_quad(&test_context);
check_texture_color(texture, 200, 1);
check_texture_float(depth_texture, 0.6f, 1);
ID3D11DeviceContext_ClearDepthStencilView(context, dsv, D3D11_CLEAR_DEPTH, 0.3f, 0);
draw_quad(&test_context);
draw_quad(&test_context);
ID3D11DeviceContext_ClearDepthStencilView(context, dsv, D3D11_CLEAR_DEPTH, 0.55f, 0);
draw_quad(&test_context);
check_texture_color(texture, 300, 1);
ID3D11DeviceContext_ClearDepthStencilView(context, dsv, D3D11_CLEAR_DEPTH, 0.5f, 0);
draw_quad(&test_context);
check_texture_color(texture, 400, 1);
check_texture_float(depth_texture, 0.5f, 1);
ID3D11Texture2D_Release(depth_texture);
ID3D11DepthStencilView_Release(dsv);
ID3D11DepthStencilState_Release(depth_stencil_state);
ID3D11PixelShader_Release(ps);
ID3D11Texture2D_Release(texture);
ID3D11UnorderedAccessView_Release(uav);
release_test_context(&test_context);
}
START_TEST(d3d11)
{
test_create_device();
@ -20763,4 +20884,5 @@ START_TEST(d3d11)
test_gather();
test_gather_c();
test_fractional_viewports();
test_early_depth_stencil();
}