From: Connor McAdams cmcadams@codeweavers.com
Add support for setting vec4 effect parameters.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=44795 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46012 Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/d3dx9_36/effect.c | 42 +++++++++++++++++++++++++++++++++--- dlls/d3dx9_36/tests/effect.c | 6 ++---- 2 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 628d8ebc3eb..67eaf2b5d63 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -4431,10 +4431,46 @@ static HRESULT WINAPI d3dx_effect_CloneEffect(ID3DXEffect *iface, IDirect3DDevic static HRESULT WINAPI d3dx_effect_SetRawValue(ID3DXEffect *iface, D3DXHANDLE parameter, const void *data, UINT byte_offset, UINT bytes) { - FIXME("iface %p, parameter %p, data %p, byte_offset %u, bytes %u stub!\n", - iface, parameter, data, byte_offset, bytes); + struct d3dx_effect *effect = impl_from_ID3DXEffect(iface); + struct d3dx_parameter *param = get_valid_parameter(effect, parameter);
- return E_NOTIMPL; + TRACE("iface %p, parameter %p, data %p, byte_offset %u, bytes %u.\n", iface, parameter, data, byte_offset, bytes); + + if (!param) + { + WARN("Invalid parameter %p specified.\n", parameter); + return D3DERR_INVALIDCALL; + } + + switch (param->class) + { + case D3DXPC_VECTOR: + { + uint8_t *dst_data; + + if (param->columns != 4) + { + FIXME("Vec%u parameters are currently unsupported.\n", param->columns); + return E_NOTIMPL; + } + + if ((byte_offset + bytes) > param->bytes) + { + FIXME("Writing adjacent parameters is currently unsupported.\n"); + return E_NOTIMPL; + } + + dst_data = param_get_data_and_dirtify(effect, param, !byte_offset ? bytes : param->bytes, TRUE); + memcpy(dst_data + byte_offset, data, bytes); + break; + } + + default: + FIXME("Unhandled parameter class %s.\n", debug_d3dxparameter_class(param->class)); + return E_NOTIMPL; + } + + return D3D_OK; } #endif
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 9e46a0c6b38..9b166384364 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -8993,12 +8993,10 @@ static void test_effect_set_raw_value(IDirect3DDevice9 *device) { "4", 0, 16, { .f = { 1.0f, 2.0f, 0.0f, 3.0f } }, { .f = { 1.0f, 2.0f, 0.0f, 3.0f } }, - .todo_hr = TRUE }, { "4_2", 0, 32, { .f = { 2.0f, 0.0f, 0.0f, 8.0f, 3.0f, 4.0f, 0.0f, 5.0f } }, { .f = { 2.0f, 0.0f, 0.0f, 8.0f, 3.0f, 4.0f, 0.0f, 5.0f } }, - .todo_hr = TRUE }, /* 10. */ { "22", 0, 64, @@ -9150,14 +9148,14 @@ static void test_effect_set_raw_value(IDirect3DDevice9 *device)
/* Test passing a NULL parameter. */ hr = effect->lpVtbl->SetRawValue(effect, NULL, tmp, 4, 0); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#lx.\n", hr);
param = effect->lpVtbl->GetParameterByName(effect, NULL, "i4"); param2 = effect->lpVtbl->GetParameterByName(effect, NULL, "i44");
/* Test setting with a size of 0. */ hr = effect->lpVtbl->SetRawValue(effect, param, tmp, 0, 0); - todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr); + ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);
hr = effect->lpVtbl->SetRawValue(effect, param2, tmp, 0, 0); todo_wine ok(hr == D3D_OK, "Unexpected hr %#lx.\n", hr);