From e28888c9fe504f75d985e34a2c271f43abd95497 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Wed, 20 Nov 2019 17:50:12 +0100 Subject: [PATCH] d3dx9: Implement d3dx_effect_ApplyParameterBlock(). Signed-off-by: Paul Gofman Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- dlls/d3dx9_36/effect.c | 22 +++++++++++++++----- dlls/d3dx9_36/tests/effect.c | 40 ++++++++++++++++++------------------ 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 84e71cd1b71..b0bf8e3c38d 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -153,6 +153,7 @@ struct d3dx_technique struct d3dx_parameter_block { char magic_string[ARRAY_SIZE(parameter_block_magic_string)]; + struct d3dx_effect *effect; struct list entry; size_t size; size_t offset; @@ -519,7 +520,6 @@ static struct d3dx_parameter *get_valid_parameter(struct d3dx_effect *effect, D3 return effect->flags & D3DXFX_LARGEADDRESSAWARE ? NULL : get_parameter_by_name(effect, NULL, parameter); } -#if D3DX_SDK_VERSION >= 26 static struct d3dx_parameter_block *get_valid_parameter_block(D3DXHANDLE handle) { struct d3dx_parameter_block *block = (struct d3dx_parameter_block *)handle; @@ -527,7 +527,6 @@ static struct d3dx_parameter_block *get_valid_parameter_block(D3DXHANDLE handle) return block && !strncmp(block->magic_string, parameter_block_magic_string, sizeof(parameter_block_magic_string)) ? block : NULL; } -#endif static void free_state(struct d3dx_state *state) { @@ -4223,6 +4222,7 @@ static HRESULT WINAPI d3dx_effect_BeginParameterBlock(ID3DXEffect *iface) effect->current_parameter_block = heap_alloc_zero(sizeof(*effect->current_parameter_block)); memcpy(effect->current_parameter_block->magic_string, parameter_block_magic_string, sizeof(parameter_block_magic_string)); + effect->current_parameter_block->effect = effect; return D3D_OK; } @@ -4251,11 +4251,23 @@ static D3DXHANDLE WINAPI d3dx_effect_EndParameterBlock(ID3DXEffect *iface) static HRESULT WINAPI d3dx_effect_ApplyParameterBlock(ID3DXEffect *iface, D3DXHANDLE parameter_block) { - struct d3dx_effect *This = impl_from_ID3DXEffect(iface); + struct d3dx_parameter_block *block = get_valid_parameter_block(parameter_block); + struct d3dx_recorded_parameter *record; - FIXME("(%p)->(%p): stub\n", This, parameter_block); + TRACE("iface %p, paramater_block %p.\n", iface, parameter_block); - return E_NOTIMPL; + if (!block || !block->offset) + return D3DERR_INVALIDCALL; + + record = (struct d3dx_recorded_parameter *)block->buffer; + while ((BYTE *)record < block->buffer + block->offset) + { + set_value(record->param, record + 1, record->bytes, + param_get_data_and_dirtify(block->effect, record->param, record->bytes, TRUE)); + record = (struct d3dx_recorded_parameter *)((BYTE *)record + get_recorded_parameter_size(record)); + } + assert((BYTE *)record == block->buffer + block->offset); + return D3D_OK; } #if D3DX_SDK_VERSION >= 26 diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 706ae126b82..c72049d553e 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -8079,7 +8079,7 @@ static void test_effect_parameter_block(void) ok(refcount == 1, "Got unexpected refcount %u.\n", refcount); hr = effect->lpVtbl->ApplyParameterBlock(effect, block); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->DeleteParameterBlock(effect, block); ok(hr == D3D_OK, "Got result %#x.\n", hr); @@ -8092,7 +8092,7 @@ static void test_effect_parameter_block(void) block = effect->lpVtbl->EndParameterBlock(effect); ok(!!block, "Got unexpected block %p.\n", block); hr = effect->lpVtbl->ApplyParameterBlock(effect, block); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->DeleteParameterBlock(effect2, block); ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr); @@ -8100,9 +8100,9 @@ static void test_effect_parameter_block(void) ok(hr == D3D_OK, "Got result %#x.\n", hr); hr = effect->lpVtbl->ApplyParameterBlock(effect, NULL); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->ApplyParameterBlock(effect, "parameter_block"); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); hr = D3DXCreateTexture(device, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, 0, D3DPOOL_DEFAULT, &texture); ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); @@ -8188,14 +8188,14 @@ static void test_effect_parameter_block(void) ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->ApplyParameterBlock(effect, block); - todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr); + 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); + 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); + 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); @@ -8206,16 +8206,16 @@ static void test_effect_parameter_block(void) hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - todo_wine ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n"); + 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"); + ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n"); hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value); - todo_wine ok(hr == D3D_OK && float_value == 28.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value); + 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); - todo_wine ok(hr == D3D_OK && float_array[0] == -29.0f + 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]); @@ -8240,7 +8240,7 @@ static void test_effect_parameter_block(void) hr = effect->lpVtbl->BeginParameterBlock(effect); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->ApplyParameterBlock(effect, block); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->GetFloat(effect, "arr2[0]", &float_value); ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value); @@ -8272,10 +8272,10 @@ static void test_effect_parameter_block(void) ok(!!block2, "Got unexpected block %p.\n", block2); hr = effect->lpVtbl->ApplyParameterBlock(effect, block2); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); 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); + 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); @@ -8286,16 +8286,16 @@ static void test_effect_parameter_block(void) hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - todo_wine ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n"); + 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"); + ok(!memcmp(&mat, &test_mat, sizeof(mat)), "Got unexpected matrix.\n"); hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value); - todo_wine ok(hr == D3D_OK && float_value == 28.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value); + 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); - todo_wine ok(hr == D3D_OK && float_array[0] == -29.0f + 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]); @@ -8333,11 +8333,11 @@ static void test_effect_parameter_block(void) hr = effect->lpVtbl->SetMatrixArray(effect, "f33_2", mat_arr, 2); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->ApplyParameterBlock(effect, block); - todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr); + ok(hr == D3D_OK, "Got result %#x.\n", hr); hr = effect->lpVtbl->GetMatrixArray(effect, "f33_2", mat_arr, 2); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); - todo_wine ok(!memcmp(&mat_arr[0], &test_mat, sizeof(test_mat)) + ok(!memcmp(&mat_arr[0], &test_mat, sizeof(test_mat)) && !memcmp(&mat_arr[1], &test_mat, sizeof(test_mat)), "Got unexpected matrix array.\n"); refcount = effect->lpVtbl->Release(effect);