[PATCH v4 2/2] d3dx9: Implement d3dx_effect_ApplyParameterBlock().
Paul Gofman
gofmanp at gmail.com
Tue Nov 19 02:52:41 CST 2019
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
v4:
- do not update parameter values if parameter block is being recorded.
dlls/d3dx9_36/effect.c | 20 +++++++++++++++---
dlls/d3dx9_36/tests/effect.c | 40 ++++++++++++++++++------------------
2 files changed, 37 insertions(+), 23 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index a8819f3a6b..73347a6c3d 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 buffer_size;
size_t current_size;
@@ -4224,6 +4225,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;
}
@@ -4252,11 +4254,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->current_size)
+ return D3DERR_INVALIDCALL;
+
+ record = (struct d3dx_recorded_parameter *)block->buffer;
+ while ((BYTE *)record < block->buffer + block->current_size)
+ {
+ set_value(record->param, record + 1, record->bytes,
+ param_get_and_flag_data(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->current_size);
+ 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 706ae126b8..c72049d553 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);
--
2.23.0
More information about the wine-devel
mailing list