From 7cd0262c50f10cbb2f67a4c48b353e2ac7039fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 23 Nov 2016 14:36:11 +0100 Subject: [PATCH] d3d11/tests: Add test for 2D texture UAV in pixel shader. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3d11/tests/d3d11.c | 85 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c index 6640db08264..496b7151412 100644 --- a/dlls/d3d11/tests/d3d11.c +++ b/dlls/d3d11/tests/d3d11.c @@ -8350,6 +8350,90 @@ static void test_draw_depth_only(void) release_test_context(&test_context); } +static void test_draw_uav_only(void) +{ + struct d3d11_test_context test_context; + D3D11_TEXTURE2D_DESC texture_desc; + ID3D11UnorderedAccessView *uav; + ID3D11DeviceContext *context; + ID3D11Texture2D *texture; + ID3D11PixelShader *ps; + ID3D11Device *device; + D3D11_VIEWPORT vp; + HRESULT hr; + + static const DWORD ps_code[] = + { +#if 0 + RWTexture2D u; + + void main() + { + InterlockedAdd(u[uint2(0, 0)], 1); + } +#endif + 0x43425844, 0x237a8398, 0xe7b34c17, 0xa28c91a4, 0xb3614d73, 0x00000001, 0x0000009c, 0x00000003, + 0x0000002c, 0x0000003c, 0x0000004c, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f, + 0x00000008, 0x00000000, 0x00000008, 0x58454853, 0x00000048, 0x00000050, 0x00000012, 0x0100086a, + 0x0400189c, 0x0011e000, 0x00000000, 0x00003333, 0x0a0000ad, 0x0011e000, 0x00000000, 0x00004002, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00004001, 0x00000001, 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; + + 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); + + 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); + /* FIXME: Set the render targets to NULL when no attachment draw calls are supported in wined3d. */ + ID3D11DeviceContext_OMSetRenderTargetsAndUnorderedAccessViews(context, 1, &test_context.backbuffer_rtv, NULL, + 0, 1, &uav, NULL); + + ID3D11DeviceContext_ClearUnorderedAccessViewUint(context, uav, values); + memset(&vp, 0, sizeof(vp)); + vp.Width = 1.0f; + vp.Height = 100.0f; + ID3D11DeviceContext_RSSetViewports(context, 1, &vp); + ID3D11DeviceContext_ClearUnorderedAccessViewUint(context, uav, values); + draw_quad(&test_context); + check_texture_color(texture, 100, 1); + + draw_quad(&test_context); + draw_quad(&test_context); + draw_quad(&test_context); + draw_quad(&test_context); + check_texture_color(texture, 500, 1); + + ID3D11PixelShader_Release(ps); + ID3D11Texture2D_Release(texture); + ID3D11UnorderedAccessView_Release(uav); + release_test_context(&test_context); +} + static void test_cb_relative_addressing(void) { struct d3d11_test_context test_context; @@ -11114,6 +11198,7 @@ START_TEST(d3d11) test_clear_render_target_view(); test_clear_depth_stencil_view(); test_draw_depth_only(); + test_draw_uav_only(); test_cb_relative_addressing(); test_getdc(); test_shader_stage_input_output_matching();