Commit 97bb1c89 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

d3d11/tests: Add test for depth clip.

parent 68d2419a
......@@ -26580,6 +26580,79 @@ static void test_multisample_resolve(void)
release_test_context(&test_context);
}
static void test_depth_clip(void)
{
struct d3d11_test_context test_context;
D3D11_TEXTURE2D_DESC texture_desc;
D3D11_RASTERIZER_DESC rs_desc;
ID3D11DeviceContext *context;
ID3D11DepthStencilView *dsv;
ID3D11RasterizerState *rs;
ID3D11Texture2D *texture;
ID3D11Device *device;
unsigned int count;
D3D11_VIEWPORT vp;
HRESULT hr;
if (!init_test_context(&test_context, NULL))
return;
device = test_context.device;
context = test_context.immediate_context;
ID3D11Texture2D_GetDesc(test_context.backbuffer, &texture_desc);
texture_desc.Format = DXGI_FORMAT_D32_FLOAT;
texture_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
hr = ID3D11Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = ID3D11Device_CreateDepthStencilView(device, (ID3D11Resource *)texture, NULL, &dsv);
ok(SUCCEEDED(hr), "Failed to create depth stencil view, hr %#x.\n", hr);
ID3D11DeviceContext_OMSetRenderTargets(context, 1, &test_context.backbuffer_rtv, dsv);
count = 1;
ID3D11DeviceContext_RSGetViewports(context, &count, &vp);
ID3D11DeviceContext_ClearDepthStencilView(context, dsv, D3D11_CLEAR_DEPTH, 1.0f, 0);
set_viewport(context, vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height, 0.4f, 0.6f);
draw_quad_z(&test_context, 2.0f);
check_texture_float(texture, 1.0f, 1);
draw_quad_z(&test_context, 0.5f);
check_texture_float(texture, 0.5f, 1);
draw_quad_z(&test_context, -1.0f);
check_texture_float(texture, 0.5f, 1);
rs_desc.FillMode = D3D11_FILL_SOLID;
rs_desc.CullMode = D3D11_CULL_BACK;
rs_desc.FrontCounterClockwise = FALSE;
rs_desc.DepthBias = 0;
rs_desc.DepthBiasClamp = 0.0f;
rs_desc.SlopeScaledDepthBias = 0.0f;
rs_desc.DepthClipEnable = FALSE;
rs_desc.ScissorEnable = FALSE;
rs_desc.MultisampleEnable = FALSE;
rs_desc.AntialiasedLineEnable = FALSE;
hr = ID3D11Device_CreateRasterizerState(device, &rs_desc, &rs);
ok(SUCCEEDED(hr), "Failed to create rasterizer state, hr %#x.\n", hr);
ID3D11DeviceContext_RSSetState(context, rs);
ID3D11DeviceContext_ClearDepthStencilView(context, dsv, D3D11_CLEAR_DEPTH, 1.0f, 0);
set_viewport(context, vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height, 0.4f, 0.6f);
draw_quad_z(&test_context, 2.0f);
todo_wine
check_texture_float(texture, 0.6f, 1);
draw_quad_z(&test_context, 0.5f);
check_texture_float(texture, 0.5f, 1);
draw_quad_z(&test_context, -1.0f);
todo_wine
check_texture_float(texture, 0.4f, 1);
ID3D11DepthStencilView_Release(dsv);
ID3D11Texture2D_Release(texture);
ID3D11RasterizerState_Release(rs);
release_test_context(&test_context);
}
START_TEST(d3d11)
{
unsigned int argc, i;
......@@ -26717,4 +26790,5 @@ START_TEST(d3d11)
test_unbound_multisample_texture();
test_multiple_viewports();
test_multisample_resolve();
test_depth_clip();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment