[PATCH 02/10] d3dx9/tests: Add test for effect parameter block.

Matteo Bruni matteo.mystral at gmail.com
Tue Nov 12 12:50:38 CST 2019


On Thu, Nov 7, 2019 at 10:18 PM Paul Gofman <gofmanp at gmail.com> wrote:

> +    /* Child parameters and array members are recorded separately (the whole parameter is not
> +     * updated when parameter block is applied).
> +     * Setting the same float value does not affect dirty state, but parameter is still
> +     * recorded to parameter block.
> +     * Setting shared parameter through effect2 is not recorded to effect parameter block. */
> +    hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 92.0f);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 28.0f);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    float_array[0] = -29.0f;
> +    hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array, 1);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);

That reminds me of something maybe worth testing: I couldn't manage to
have SetArrayRange() ever do anything. Maybe it actually does
something with parameter blocks? Not holding my breath for that...

> +    /* Object reference is not increased when object gets to parameter block
> +     * but is also not lost when object is reset in effect parameter.
> +     * Maybe native d3dx is using some copy on write strategy. */
> +    IDirect3DTexture9_AddRef(texture);
> +    refcount = IDirect3DTexture9_Release(texture);
> +    ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);

Or stuff might just break if the texture is released while still in a
parameter block. It should be possible to test it.

> +    hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 0.0f);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    hr = effect->lpVtbl->SetFloat(effect, "arr2[1]", 0.0f);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v1", float_array_zero, 3);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 0.0f);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array_zero, 4);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    memset(&mat, 0, sizeof(mat));
> +    hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &mat);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &mat);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +
> +

The double blank line here seems unnecessary (but I don't mind).

> +    hr = effect->lpVtbl->ApplyParameterBlock(effect, block);
> +    todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr);
> +
> +    IDirect3DTexture9_AddRef(texture);
> +    refcount = IDirect3DTexture9_Release(texture);
> +    todo_wine ok(refcount == 3, "Got unexpected refcount %u.\n", refcount);
> +
> +    hr = effect->lpVtbl->GetFloat(effect, "arr2[0]", &float_value);
> +    todo_wine ok(hr == D3D_OK && float_value == 92.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value);
> +    hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value);
> +    ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value);
> +    hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v1", float_array, 3);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    ok(hr == D3D_OK && !memcmp(float_array, float_array_zero, 3 * sizeof(*float_array)),
> +            "Got unexpected hr %#x, ts1[0].v1 (%g, %g, %g).\n", hr,
> +            float_array[0], float_array[1], float_array[2]);

Here you're checking hr twice.

> +    hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value);
> +    hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);

I guess one was supposed to go after GetFloat().
There are more of those below.

> +    todo_wine ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n");
> +    hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    todo_wine ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n");
> +
> +    todo_wine ok(hr == D3D_OK && float_value == 28.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value);
> +    hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    todo_wine ok(hr == D3D_OK && float_array[0] == -29.0f
> +            && !memcmp(float_array + 1, float_array_zero, 3 * sizeof(*float_array)),
> +            "Got unexpected hr %#x, ts1[0].v2 (%g, %g, %g, %g).\n", hr,
> +            float_array[0], float_array[1], float_array[2], float_array[3]);
> +
> +    hr = effect->lpVtbl->DeleteParameterBlock(effect, block);
> +    todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr);
> +
> +    IDirect3DTexture9_AddRef(texture);
> +
> +    hr = effect->lpVtbl->SetTexture(effect, "tex1", NULL);
> +    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
> +    refcount = IDirect3DTexture9_Release(texture);
> +    ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);
> +    if (refcount)
> +        IDirect3DTexture9_Release(texture);

Here either a todo_wine is missing or the if is unnecessary.



More information about the wine-devel mailing list