Rémi Bernon : d3d11/tests: Add more tests for ID3D11DeviceContext1_SwapDeviceContextState.

Alexandre Julliard julliard at winehq.org
Wed Feb 3 15:39:28 CST 2021


Module: wine
Branch: master
Commit: ccffc06c6df30aa8b4ea487b868c419b9c7f5a9a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ccffc06c6df30aa8b4ea487b868c419b9c7f5a9a

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Tue Feb  2 16:41:00 2021 +0100

d3d11/tests: Add more tests for ID3D11DeviceContext1_SwapDeviceContextState.

Better checking multiple context swap side effects.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3d11/tests/d3d11.c | 47 +++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index c5c2e16e716..7935dab1332 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -7057,14 +7057,21 @@ static void test_device_context_state(void)
     ID3D11Device1_GetImmediateContext1(device2, &context2);
     ok(!!context2, "Failed to get immediate context.\n");
 
+    /* but they track a distinct state on each context */
     ID3D11DeviceContext1_SwapDeviceContextState(context2, context_state, &tmp_context_state);
     ok(!!tmp_context_state, "Failed to get context state.\n");
     tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
+    ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL);
+    ok(!tmp_vs, "Got unexpected shader %p.\n", tmp_vs);
+
+    /* updating context2 vertex shader doesn't update other contexts using the same state */
+    ID3D11DeviceContext1_VSSetShader(context2, vs, NULL, 0);
     ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL);
     todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);
     if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
     else refcount = 0;
     todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+
     ID3D11DeviceContext1_SwapDeviceContextState(context2, tmp_context_state, &context_state2);
     refcount = ID3DDeviceContextState_Release(tmp_context_state);
     ok(refcount == 0, "Got refcount %u, expected 1.\n", refcount);
@@ -7072,14 +7079,46 @@ static void test_device_context_state(void)
     todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
     todo_wine ok(context_state2 == context_state, "Got unexpected state pointer.\n");
 
-    refcount = ID3D11DeviceContext1_Release(context2);
-    ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount);
-    refcount = ID3D11Device1_Release(device2);
-    ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount);
+    /* swapping the default state on context2 effectively clears the vertex shader */
+    tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
+    ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL);
+    ok(!tmp_vs, "Got unexpected shader %p.\n", tmp_vs);
+
+    ID3D11DeviceContext1_SwapDeviceContextState(context2, context_state, &tmp_context_state);
+    ok(!!tmp_context_state, "Failed to get context state.\n");
+    refcount = ID3DDeviceContextState_Release(tmp_context_state);
+    ok(refcount == 0, "Got refcount %u, expected 1.\n", refcount);
 
+    /* clearing the vertex shader on context doesn't have side effect on context2 */
     ID3D11DeviceContext1_VSSetShader(context, NULL, NULL, 0);
     refcount = ID3D11VertexShader_Release(vs2);
     ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount);
+    tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
+    ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL);
+    todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
+    if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
+    else refcount = 0;
+    todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+
+    /* even after swapping it again */
+    ID3D11DeviceContext1_SwapDeviceContextState(context2, context_state, NULL);
+    tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
+    ID3D11DeviceContext1_VSGetShader(context2, &tmp_vs, NULL, NULL);
+    todo_wine ok(tmp_vs == vs, "Got shader %p, expected %p.\n", tmp_vs, vs);
+    if (tmp_vs) refcount = ID3D11VertexShader_Release(tmp_vs);
+    else refcount = 0;
+    todo_wine ok(refcount == 1, "Got refcount %u, expected 1.\n", refcount);
+
+    /* swapping the initial state on context2 doesn't have side effect on context either */
+    ID3D11DeviceContext1_SwapDeviceContextState(context2, previous_context_state, NULL);
+    tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
+    ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL);
+    ok(!tmp_vs, "Got unexpected shader %p.\n", tmp_vs);
+
+    refcount = ID3D11DeviceContext1_Release(context2);
+    ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount);
+    refcount = ID3D11Device1_Release(device2);
+    ok(refcount == 0, "Got refcount %u, expected 0.\n", refcount);
 
     ID3D11DeviceContext1_SwapDeviceContextState(context, previous_context_state, &tmp_context_state);
     refcount = ID3DDeviceContextState_Release(previous_context_state);




More information about the wine-cvs mailing list