Commit c889bab8 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Add a test for shader constant application through IDirect3DStateBlock9_Apply().

We already behave correctly here, the test just verifies it.
parent 42036ab6
......@@ -1459,6 +1459,110 @@ static void test_state_management(
execute_test_chain_all(device, tests, tcount);
}
static void test_shader_constant_apply(IDirect3DDevice9 *device)
{
static const float initial[] = {0.0f, 0.0f, 0.0f, 0.0f};
static const float vs_const[] = {1.0f, 2.0f, 3.0f, 4.0f};
static const float ps_const[] = {5.0f, 6.0f, 7.0f, 8.0f};
IDirect3DStateBlock9 *stateblock;
float ret[4];
HRESULT hr;
hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, initial, 1);
ok(SUCCEEDED(hr), "SetVertexShaderConstantF returned %#x\n", hr);
hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, initial, 1);
ok(SUCCEEDED(hr), "SetVertexShaderConstantF returned %#x\n", hr);
hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, initial, 1);
ok(SUCCEEDED(hr), "SetPixelShaderConstantF returned %#x\n", hr);
hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 1, initial, 1);
ok(SUCCEEDED(hr), "SetPixelShaderConstantF returned %#x\n", hr);
hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 0, ret, 1);
ok(SUCCEEDED(hr), "GetVertexShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, initial, sizeof(initial)),
"GetVertexShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 1, ret, 1);
ok(SUCCEEDED(hr), "GetVertexShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, initial, sizeof(initial)),
"GetVertexShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 0, ret, 1);
ok(SUCCEEDED(hr), "GetPixelShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, initial, sizeof(initial)),
"GetpixelShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 1, ret, 1);
ok(SUCCEEDED(hr), "GetPixelShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, initial, sizeof(initial)),
"GetPixelShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 0, vs_const, 1);
ok(SUCCEEDED(hr), "SetVertexShaderConstantF returned %#x\n", hr);
hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 0, ps_const, 1);
ok(SUCCEEDED(hr), "SetPixelShaderConstantF returned %#x\n", hr);
hr = IDirect3DDevice9_BeginStateBlock(device);
ok(SUCCEEDED(hr), "BeginStateBlock returned %#x\n", hr);
hr = IDirect3DDevice9_SetVertexShaderConstantF(device, 1, vs_const, 1);
ok(SUCCEEDED(hr), "SetVertexShaderConstantF returned %#x\n", hr);
hr = IDirect3DDevice9_SetPixelShaderConstantF(device, 1, ps_const, 1);
ok(SUCCEEDED(hr), "SetPixelShaderConstantF returned %#x\n", hr);
hr = IDirect3DDevice9_EndStateBlock(device, &stateblock);
ok(SUCCEEDED(hr), "EndStateBlock returned %#x\n", hr);
hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 0, ret, 1);
ok(SUCCEEDED(hr), "GetVertexShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, vs_const, sizeof(vs_const)),
"GetVertexShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], vs_const[0], vs_const[1], vs_const[2], vs_const[3]);
hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 1, ret, 1);
ok(SUCCEEDED(hr), "GetVertexShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, initial, sizeof(initial)),
"GetVertexShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 0, ret, 1);
ok(SUCCEEDED(hr), "GetPixelShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, ps_const, sizeof(ps_const)),
"GetPixelShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], ps_const[0], ps_const[1], ps_const[2], ps_const[3]);
hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 1, ret, 1);
ok(SUCCEEDED(hr), "GetPixelShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, initial, sizeof(initial)),
"GetPixelShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], initial[0], initial[1], initial[2], initial[3]);
hr = IDirect3DStateBlock9_Apply(stateblock);
ok(SUCCEEDED(hr), "Apply returned %#x\n", hr);
/* Apply doesn't overwrite constants that aren't explicitly set on the source stateblock. */
hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 0, ret, 1);
ok(SUCCEEDED(hr), "GetVertexShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, vs_const, sizeof(vs_const)),
"GetVertexShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], vs_const[0], vs_const[1], vs_const[2], vs_const[3]);
hr = IDirect3DDevice9_GetVertexShaderConstantF(device, 1, ret, 1);
ok(SUCCEEDED(hr), "GetVertexShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, vs_const, sizeof(vs_const)),
"GetVertexShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], vs_const[0], vs_const[1], vs_const[2], vs_const[3]);
hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 0, ret, 1);
ok(SUCCEEDED(hr), "GetPixelShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, ps_const, sizeof(ps_const)),
"GetPixelShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], ps_const[0], ps_const[1], ps_const[2], ps_const[3]);
hr = IDirect3DDevice9_GetPixelShaderConstantF(device, 1, ret, 1);
ok(SUCCEEDED(hr), "GetPixelShaderConstantF returned %#x\n", hr);
ok(!memcmp(ret, ps_const, sizeof(ps_const)),
"GetPixelShaderConstantF got {%f, %f, %f, %f}, expected {%f, %f, %f, %f}\n",
ret[0], ret[1], ret[2], ret[3], ps_const[0], ps_const[1], ps_const[2], ps_const[3]);
IDirect3DStateBlock9_Release(stateblock);
}
START_TEST(stateblock)
{
IDirect3DDevice9 *device_ptr = NULL;
......@@ -1477,6 +1581,7 @@ START_TEST(stateblock)
test_begin_end_state_block(device_ptr);
test_state_management(device_ptr, &device_pparams);
test_shader_constant_apply(device_ptr);
if (device_ptr) IUnknown_Release(device_ptr);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment