[v2 1/6] d3dx9: add test for basic effect state management.

Paul Gofman gofmanp at gmail.com
Wed Mar 2 10:15:01 CST 2016


Thanks. Is it better to update & resend just one first patch of series
as v3, or wait for your further comments and resend the whole series in
case of any comments there?

Regards,
    Paul.

On 03/02/2016 07:05 PM, Matteo Bruni wrote:
>
> +    hr = D3DXCreateEffect(device, test_effect_states_effect_blob, sizeof(test_effect_states_effect_blob),
> +            NULL, NULL, 0, NULL, &effect, NULL);
> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
> +
> +    /* 1. State affected in passes saved/restored even if no pass
> +       was performed. States not present in passes are not saved &
> +       restored */
> That type of "n." notation isn't found elsewhere and I don't think
> it's particularly useful here either.
>
>> +    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_BLENDOP, 1);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAFUNC, 1);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +
>> +    hr = effect->lpVtbl->Begin(effect, &npasses, 0);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    ok(npasses == 1, "Expected 1 pass, got %u\n", npasses);
>> +
>> +    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_BLENDOP, 3);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAFUNC, 2);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +
>> +    hr = effect->lpVtbl->End(effect);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +
>> +    hr = IDirect3DDevice9_GetRenderState(device, D3DRS_BLENDOP, &value);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(value == 1, "Got result %u, expected %u.\n", value, 1);
>> +    hr = IDirect3DDevice9_GetRenderState(device, D3DRS_ALPHAFUNC, &value);
>> +    ok(value == 2, "Got result %u, expected %u.\n", value, 2);
>> +
>> +    /* 2. Test states application in BeginPass. No states are restored
>> +       on EndPass. */
>> +    hr = IDirect3DDevice9_SetSamplerState(device, 1, D3DSAMP_MIPFILTER, 0);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, 0);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +
>> +    hr = IDirect3DDevice9_GetLightEnable(device, 2, &bval);
>> +    todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    if (hr == D3D_OK)
>> +        ok(!bval,"Got result %u, expected 0.", bval);
>> +
>> +    hr = IDirect3DDevice9_SetTransform(device, D3DTS_WORLDMATRIX(1), &test_mat);
>> +    hr = effect->lpVtbl->Begin(effect, &npasses, 0);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +
>> +    hr = IDirect3DDevice9_GetTransform(device, D3DTS_WORLDMATRIX(1), &mat);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    ok(mat.m[0][0] == test_mat.m[0][0], "Unexpected value: %f.\n", mat.m[0][0]);
> Any reason you're not checking the entire matrix this time only?
>
>> +
>> +    hr = effect->lpVtbl->BeginPass(effect, 0);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +
>> +    hr = IDirect3DDevice9_GetTransform(device, D3DTS_WORLDMATRIX(1), &mat);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(!memcmp(mat.m, test_mat_world1.m, sizeof(mat)), "World matrix does not match.\n");
>> +
>> +    hr = IDirect3DDevice9_GetTransform(device, D3DTS_VIEW, &mat);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(!memcmp(mat.m, test_mat_camera.m, sizeof(mat)), "View matrix does not match.\n");
>> +
>> +    hr = IDirect3DDevice9_GetRenderState(device, D3DRS_BLENDOP, &value);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(value == 2, "Got result %u, expected %u\n", value, 2);
>> +
>> +    hr = IDirect3DDevice9_GetVertexShader(device, &vshader);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(vshader != NULL, "Got NULL vshader.\n");
>> +    if (vshader)
>> +    {
>> +        byte_code_size = sizeof(test_effect_states_vshader_buf);
>> +        hr = IDirect3DVertexShader9_GetFunction(vshader, test_effect_states_vshader_buf,&byte_code_size);
> Whitespace after comma.
>
>> +        ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +        ok(byte_code_size > 1, "Got unexpected byte code size %u.\n", byte_code_size);
>> +        ok(test_effect_states_vshader_buf[0] == 0xfffe0200, "Incorrect shader selected: %#x.\n", test_effect_states_vshader_buf[0]);
> Here you could memcmp the entire shader with the one from the effect blob.
>
>> +        IDirect3DVertexShader9_Release(vshader);
>> +    }
>> +
>> +    hr = IDirect3DDevice9_GetLightEnable(device, 2, &bval);
>> +    todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    if (hr == D3D_OK)
>> +        ok(bval,"Got result %u, expected TRUE.\n", bval);
>> +    hr = IDirect3DDevice9_GetLight(device, 2, &light);
>> +    todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    if (hr == D3D_OK)
>> +        ok(light.Position.x == 4.0f && light.Position.y == 5.0f && light.Position.z == 6.0f,
>> +                "Got unexpected light position (%f, %f, %f).\n", light.Position.x, light.Position.y, light.Position.z);
>> +    hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 3, float_data, 1);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(float_data[0] == 2.0f && float_data[1] == 2.0f && float_data[2] == 2.0f && float_data[3] == 2.0f,
>> +            "Got unexpected vertex shader floats: (%f %f %f %f).\n",
>> +            float_data[0], float_data[1], float_data[2], float_data[3]);
>> +
>> +    hr = effect->lpVtbl->EndPass(effect);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    hr = IDirect3DDevice9_GetRenderState(device, D3DRS_BLENDOP, &value);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(value == 2, "Got result %u, expected %u\n", value, 2);
>> +
>> +    hr = IDirect3DDevice9_GetRenderState(device, D3DRS_ZENABLE, &value);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(value,"Got result %u, expected TRUE.\n", value);
>> +
>> +    hr = IDirect3DDevice9_GetSamplerState(device, 1, D3DSAMP_MIPFILTER, &value);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(value == D3DTEXF_LINEAR, "Unexpected sampler 1 mipfilter %u.\n", value);
>> +
>> +    hr = IDirect3DDevice9_GetTextureStageState(device, 3, D3DTSS_ALPHAOP, &value);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    todo_wine ok(value == 4, "Unexpected texture stage 3 AlphaOp %u.\n", value);
>> +
>> +    hr = effect->lpVtbl->End(effect);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +
>> +    hr = IDirect3DDevice9_GetTransform(device, D3DTS_WORLDMATRIX(1), &mat);
>> +    ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    ok(!memcmp(mat.m, test_mat.m, sizeof(mat)), "World matrix not restored.\n");
>> +
>> +    hr = IDirect3DDevice9_GetLightEnable(device, 2, &bval);
>> +    todo_wine ok(hr == D3D_OK, "Got result %x, expected 0 (D3D_OK).\n", hr);
>> +    if (hr == D3D_OK)
>> +        ok(!bval,"Got result %u, expected 0.\n", bval);
>> +
>> +    if (effect)
>> +        effect->lpVtbl->Release(effect);
>> +}
>> +
>>  START_TEST(effect)
>>  {
>>      HWND wnd;
>> @@ -2730,6 +2989,7 @@ START_TEST(effect)
>>      test_effect_parameter_value(device);
>>      test_effect_variable_names(device);
>>      test_effect_compilation_errors(device);
>> +    test_effect_states(device);
>>
>>      count = IDirect3DDevice9_Release(device);
>>      ok(count == 0, "The device was not properly freed: refcount %u\n", count);
>> --
>> 2.5.0





More information about the wine-devel mailing list