[PATCH v2] d3d11/tests: Add test for depth clip.
Zebediah Figura
z.figura12 at gmail.com
Tue May 15 11:14:31 CDT 2018
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/d3d11/tests/d3d11.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 63f964a..ca6130b 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -26567,6 +26567,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 = D3D10_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;
@@ -26704,4 +26777,5 @@ START_TEST(d3d11)
test_unbound_multisample_texture();
test_multiple_viewports();
test_multisample_resolve();
+ test_depth_clip();
}
--
2.7.4
More information about the wine-devel
mailing list