[PATCH 1/8] d3d11/tests: Add test for unbinding shader resource view.
Józef Kucia
jkucia at codeweavers.com
Thu Mar 9 03:03:03 CST 2017
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d11/tests/d3d11.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 2060ab6..94a5a8f 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -12248,6 +12248,95 @@ static void test_shader_input_registers_limits(void)
release_test_context(&test_context);
}
+static void test_unbind_shader_resource_view(void)
+{
+ struct d3d11_test_context test_context;
+ D3D11_SUBRESOURCE_DATA resource_data;
+ ID3D11ShaderResourceView *srv, *srv2;
+ D3D11_TEXTURE2D_DESC texture_desc;
+ ID3D11DeviceContext *context;
+ ID3D11Texture2D *texture;
+ ID3D11PixelShader *ps;
+ ID3D11Device *device;
+ HRESULT hr;
+
+ static const DWORD ps_code[] =
+ {
+#if 0
+ Texture2D t0;
+ Texture2D t1;
+ SamplerState s;
+
+ float4 main() : SV_Target
+ {
+ return min(t0.Sample(s, float2(0, 0)) + t1.Sample(s, float2(0, 0)), 1.0f);
+ }
+#endif
+ 0x43425844, 0x698dc0cb, 0x0bf322b8, 0xee127418, 0xfe9214ce, 0x00000001, 0x00000168, 0x00000003,
+ 0x0000002c, 0x0000003c, 0x00000070, 0x4e475349, 0x00000008, 0x00000000, 0x00000008, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x000000f0, 0x00000040, 0x0000003c,
+ 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858,
+ 0x00107000, 0x00000001, 0x00005555, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002,
+ 0x0c000045, 0x001000f2, 0x00000000, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x0c000045, 0x001000f2, 0x00000001, 0x00004002,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00107e46, 0x00000001, 0x00106000, 0x00000000,
+ 0x07000000, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, 0x00100e46, 0x00000001, 0x0a000033,
+ 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, 0x00004002, 0x3f800000, 0x3f800000, 0x3f800000,
+ 0x3f800000, 0x0100003e,
+ };
+ static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ static const DWORD texture_data[] = {0xff00ff00};
+
+ if (!init_test_context(&test_context, NULL))
+ return;
+
+ device = test_context.device;
+ context = test_context.immediate_context;
+
+ texture_desc.Width = 1;
+ texture_desc.Height = 1;
+ texture_desc.MipLevels = 0;
+ texture_desc.ArraySize = 1;
+ texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ texture_desc.SampleDesc.Count = 1;
+ texture_desc.SampleDesc.Quality = 0;
+ texture_desc.Usage = D3D11_USAGE_DEFAULT;
+ texture_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+ texture_desc.CPUAccessFlags = 0;
+ texture_desc.MiscFlags = 0;
+
+ resource_data.pSysMem = texture_data;
+ resource_data.SysMemPitch = sizeof(texture_data);
+ resource_data.SysMemSlicePitch = 0;
+
+ hr = ID3D11Device_CreateTexture2D(device, &texture_desc, &resource_data, &texture);
+ ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x.\n", hr);
+ hr = ID3D11Device_CreateShaderResourceView(device, (ID3D11Resource *)texture, NULL, &srv);
+ ok(SUCCEEDED(hr), "Failed to create shader resource 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);
+
+ ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &srv);
+ ID3D11DeviceContext_PSSetShaderResources(context, 1, 1, &srv);
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+ draw_quad(&test_context);
+ check_texture_color(test_context.backbuffer, 0xff00ff00, 1);
+
+ srv2 = NULL;
+ ID3D11DeviceContext_PSSetShaderResources(context, 0, 1, &srv2);
+ ID3D11DeviceContext_PSSetShaderResources(context, 1, 1, &srv2);
+ ID3D11DeviceContext_ClearRenderTargetView(context, test_context.backbuffer_rtv, white);
+ draw_quad(&test_context);
+ todo_wine check_texture_color(test_context.backbuffer, 0x00000000, 1);
+
+ ID3D11PixelShader_Release(ps);
+ ID3D11ShaderResourceView_Release(srv);
+ ID3D11Texture2D_Release(texture);
+ release_test_context(&test_context);
+}
+
static void test_stencil_separate(void)
{
struct d3d11_test_context test_context;
@@ -15734,6 +15823,7 @@ START_TEST(d3d11)
run_for_each_9_x_feature_level(test_fl9_draw);
test_ddy();
test_shader_input_registers_limits();
+ test_unbind_shader_resource_view();
test_stencil_separate();
test_uav_load();
test_cs_uav_store();
--
2.10.2
More information about the wine-patches
mailing list