[PATCH 1/4] d3d11/tests: Add more SwapDeviceContextState tests.

Henri Verbeet hverbeet at gmail.com
Fri Jan 29 10:23:00 CST 2021


On Wed, 27 Jan 2021 at 20:50, Rémi Bernon <rbernon at codeweavers.com> wrote:
> +    /* context states may be used with other devices instances too */
> +    d3d11_device2 = create_device(NULL);
> +    ok(!!d3d11_device2, "Failed to create device.\n");
> +    hr = ID3D11Device_QueryInterface(d3d11_device2, &IID_ID3D11Device1, (void **)&device2);
> +    ok(SUCCEEDED(hr), "Failed to query device interface, hr %#x.\n", hr);
> +    ID3D11Device_Release(d3d11_device2);
> +    ID3D11Device1_GetImmediateContext1(device2, &context2);
> +    ok(!!context2, "Failed to get immediate context.\n");
> +
> +    ID3D11DeviceContext1_SwapDeviceContextState(context2, context_state, &tmp_context_state);
> +    ok(!!tmp_context_state, "Failed to get context state.\n");
> +    tmp_vs = (ID3D11VertexShader *)0xdeadbeef;
> +    ID3D11DeviceContext1_VSGetShader(context, &tmp_vs, NULL, NULL);
> +    todo_wine ok(tmp_vs == vs2, "Got shader %p, expected %p.\n", tmp_vs, vs2);

This (only) tests the vertex shader set on the original device
context, is that intentional? It may be at least as interesting to
test which vertex shader is set on the new device context. This also
raises the question whether updates to context2 would be (immediately)
visible to the first context. E.g., consider the following sequence:

    ID3D11Device1_CreateDeviceContextState(device1, ..., &state);
    ...
    ID3D11DeviceContext1_VSSetShader(context1, vs1, NULL, 0);
    ID3D11DeviceContext1_VSSetShader(context2, vs2, NULL, 0);
    /* context1: vs1, context2: vs2 */
    ID3D11DeviceContext1_SwapDeviceContextState(context1, state, NULL);
    ID3D11DeviceContext1_VSSetShader(context1, vs3, NULL, 0);
    /* context1: vs3, context2: vs2 */
    ID3D11DeviceContext1_SwapDeviceContextState(context2, state, NULL);
    /* context1: vs3, does context2 also have vs3 set now? */
    ID3D11DeviceContext1_VSSetShader(context2, vs1, NULL, 0);
    /* context2: vs1, does context1 also have vs1 set now? */

In particular, since the current tests never change or test the state
of context2, it would be possible to make them pass by only
capturing/applying state on context state swaps when the device
matches the device used to create the context state, or even by always
applying state to the context corresponding to the device used to
create the device context state, regardless of what context
ID3D11DeviceContext1_SwapDeviceContextState() was called on.



More information about the wine-devel mailing list