Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/ddraw/tests/ddraw7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 7c46f33cb7a..8875fde7f89 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -16593,7 +16593,7 @@ static void test_surface_format_conversion_alpha(void) {16}, {0x0000f800}, {0x000007e0}, {0x0000001f}, {0x00000000} }, "R5G6B5", 2, 4, 4, 0, TRUE, - /* Looks broken for sysmem texture convertions on Windows (at + /* Looks broken for sysmem texture conversions on Windows (at * least with hardware device), the result is either error from * _Blt() or a copy of the source data without any conversion. */ },
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman gofmanp@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/effect.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index ad81cb68cb2..eefd14aafa4 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -516,8 +516,7 @@ static void free_sampler(struct d3dx_sampler *sampler) { free_state(&sampler->states[i]); } - HeapFree(GetProcessHeap(), 0, sampler->states); - HeapFree(GetProcessHeap(), 0, sampler); + heap_free(sampler->states); }
static void d3dx_pool_release_shared_parameter(struct d3dx_top_level_parameter *param); @@ -531,7 +530,7 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child) switch (param->type) { case D3DXPT_STRING: - HeapFree(GetProcessHeap(), 0, *(char **)param->data); + heap_free(*(char **)param->data); break;
case D3DXPT_TEXTURE: @@ -557,8 +556,8 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child) break; } } - if (!child) - HeapFree(GetProcessHeap(), 0, param->data); + if (!child || is_param_type_sampler(param->type)) + heap_free(param->data); }
static void free_parameter(struct d3dx_parameter *param, BOOL element, BOOL child)
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman gofmanp@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- I made a few tweaks, mostly adding an explicit ApplyParameterBlock(effect, NULL) test and moving around and splitting a few comments.
The following patches are mostly just rebased on top of this with no significant changes.
dlls/d3dx9_36/tests/effect.c | 245 +++++++++++++++++++++++++++++++++++ 1 file changed, 245 insertions(+)
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 5c4a3c5e770..1a177d7a8bc 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -8001,6 +8001,250 @@ static void test_effect_find_next_valid_technique(void) DestroyWindow(window); }
+static void test_effect_parameter_block(void) +{ + static const D3DXMATRIX test_mat = + {{{ + -11.0f, -12.0f, 0.0f, 0.0f, + -21.0f, -22.0f, 0.0f, 0.0f, + -31.0f, -32.0f, 0.0f, 0.0f, + }}}; + static const D3DXMATRIX effect_orig_mat = + {{{ + 11.0f, 12.0f, 0.0f, 0.0f, + 21.0f, 22.0f, 0.0f, 0.0f, + 31.0f, 32.0f, 0.0f, 0.0f, + }}}; + D3DPRESENT_PARAMETERS present_parameters = {0}; + static const float float_array_zero[4]; + IDirect3DTexture9 *texture, *tex_test; + ID3DXEffect *effect, *effect2; + D3DXHANDLE block, handle; + IDirect3DDevice9 *device; + ID3DXEffectPool *pool; + float float_array[4]; + float float_value; + IDirect3D9 *d3d; + D3DXMATRIX mat; + ULONG refcount; + HWND window; + HRESULT hr; + + if (!(window = CreateWindowA("static", "d3dx9_test", WS_OVERLAPPEDWINDOW, 0, 0, + 640, 480, NULL, NULL, NULL, NULL))) + { + skip("Failed to create window.\n"); + return; + } + if (!(d3d = Direct3DCreate9(D3D_SDK_VERSION))) + { + skip("Failed to create IDirect3D9 object.\n"); + DestroyWindow(window); + return; + } + present_parameters.Windowed = TRUE; + present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; + hr = IDirect3D9_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, window, + D3DCREATE_HARDWARE_VERTEXPROCESSING, &present_parameters, &device); + if (FAILED(hr)) + { + skip("Failed to create IDirect3DDevice9 object, hr %#x.\n", hr); + IDirect3D9_Release(d3d); + DestroyWindow(window); + return; + } + + hr = D3DXCreateEffectPool(&pool); + ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = D3DXCreateEffect(device, test_effect_preshader_effect_blob, sizeof(test_effect_preshader_effect_blob), + NULL, NULL, 0, pool, &effect, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = D3DXCreateEffect(device, test_effect_preshader_effect_blob, sizeof(test_effect_preshader_effect_blob), + NULL, NULL, 0, pool, &effect2, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = effect->lpVtbl->BeginParameterBlock(effect); + todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->BeginParameterBlock(effect); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + block = effect->lpVtbl->EndParameterBlock(effect); + todo_wine ok(!!block, "Got unexpected block %p.\n", block); + handle = effect->lpVtbl->EndParameterBlock(effect); + ok(!handle, "Got unexpected handle %p.\n", handle); + + /* Block doesn't hold effect reference. */ + effect->lpVtbl->AddRef(effect); + refcount = effect->lpVtbl->Release(effect); + 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); + hr = effect->lpVtbl->DeleteParameterBlock(effect, block); + todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = effect->lpVtbl->BeginParameterBlock(effect); + todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloat(effect, "vec3[0]", 1001.0f); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloat(effect, "arr1[0]", 91.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + block = effect->lpVtbl->EndParameterBlock(effect); + todo_wine 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); + + hr = effect->lpVtbl->DeleteParameterBlock(effect2, block); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr); + hr = effect->lpVtbl->DeleteParameterBlock(effect, block); + todo_wine 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); + hr = effect->lpVtbl->ApplyParameterBlock(effect, "parameter_block"); + todo_wine 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); + + hr = effect->lpVtbl->BeginParameterBlock(effect); + todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + /* Effect parameters are not updated during recording. */ + hr = effect->lpVtbl->SetTexture(effect, "tex1", (IDirect3DBaseTexture9 *)texture); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = effect->lpVtbl->GetTexture(effect, "tex1", (IDirect3DBaseTexture9 **)&tex_test); + todo_wine ok(hr == D3D_OK && !tex_test, "Got unexpected hr %#x, tex_test %p.\n", hr, tex_test); + if (tex_test) + IDirect3DTexture9_Release(tex_test); + + /* Child parameters and array members are recorded separately (the whole + * parameter is not updated when parameter block is applied). */ + hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 92.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 28.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value); + todo_wine ok(hr == D3D_OK && float_value == 12.0, "Got unexpected hr %#x, float_value %g.\n", hr, float_value); + + float_array[0] = -29.0f; + hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array, 1); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 1); + todo_wine ok(hr == D3D_OK && float_array[0] == 13.0, "Got unexpected hr %#x, float_array[0] %g.\n", + hr, float_array[0]); + + memset(&mat, 0, sizeof(mat)); + hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &test_mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + todo_wine ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n"); + + hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &test_mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + todo_wine ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n"); + + /* Setting shared parameter through effect2 is not recorded to effect + * parameter block. */ + hr = effect2->lpVtbl->SetFloat(effect2, "arr2[1]", -1.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->GetFloat(effect, "arr2[1]", &float_value); + ok(float_value == -1.0f, "Unexpected value %g.\n", float_value); + + IDirect3DTexture9_AddRef(texture); + refcount = IDirect3DTexture9_Release(texture); + ok(refcount == 2, "Got unexpected refcount %u.\n", refcount); + + block = effect->lpVtbl->EndParameterBlock(effect); + todo_wine ok(!!block, "Got unexpected block %p.\n", block); + + IDirect3DTexture9_AddRef(texture); + refcount = IDirect3DTexture9_Release(texture); + ok(refcount == 2, "Got unexpected refcount %u.\n", refcount); + + hr = effect->lpVtbl->DeleteParameterBlock(effect2, block); + todo_wine ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr); + + IDirect3DTexture9_AddRef(texture); + refcount = IDirect3DTexture9_Release(texture); + ok(refcount == 2, "Got unexpected refcount %u.\n", refcount); + + hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 0.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloat(effect, "arr2[1]", 0.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v1", float_array_zero, 3); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 0.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array_zero, 4); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memset(&mat, 0, sizeof(mat)); + hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &mat); + 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); + + IDirect3DTexture9_AddRef(texture); + refcount = IDirect3DTexture9_Release(texture); + todo_wine 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); + 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); + + hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v1", float_array, 3); + ok(hr == D3D_OK && !memcmp(float_array, float_array_zero, 3 * sizeof(*float_array)), + "Got unexpected hr %#x, ts1[0].v1 (%g, %g, %g).\n", hr, + float_array[0], float_array[1], float_array[2]); + + 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"); + 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"); + + 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); + + hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4); + todo_wine 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]); + + hr = effect->lpVtbl->DeleteParameterBlock(effect, block); + todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr); + + hr = effect->lpVtbl->SetTexture(effect, "tex1", NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + refcount = IDirect3DTexture9_Release(texture); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); + + refcount = effect->lpVtbl->Release(effect); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); + + refcount = effect2->lpVtbl->Release(effect2); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); + + refcount = pool->lpVtbl->Release(pool); + ok(!refcount, "Got unexpected refcount %u.\n", refcount); + + refcount = IDirect3DDevice9_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); + IDirect3D9_Release(d3d); + DestroyWindow(window); +} + START_TEST(effect) { IDirect3DDevice9 *device; @@ -8040,4 +8284,5 @@ START_TEST(effect) test_refcount(); test_create_effect_from_file(); test_effect_find_next_valid_technique(); + test_effect_parameter_block(); }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- While reviewing the previous patch I became curious WRT ApplyParameterBlock() while recording another parameter block. I didn't notice your test in patch 9/9 at the time (a point to having the test earlier in the series, probably) so I wrote my own version. Good thing that I did: it looks like applying a parameter block while recording also doesn't update the effect parameters.
dlls/d3dx9_36/tests/effect.c | 84 +++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 1a177d7a8bc..922d8247b1f 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -8018,8 +8018,8 @@ static void test_effect_parameter_block(void) D3DPRESENT_PARAMETERS present_parameters = {0}; static const float float_array_zero[4]; IDirect3DTexture9 *texture, *tex_test; + D3DXHANDLE block, block2, handle; ID3DXEffect *effect, *effect2; - D3DXHANDLE block, handle; IDirect3DDevice9 *device; ID3DXEffectPool *pool; float float_array[4]; @@ -8216,6 +8216,86 @@ static void test_effect_parameter_block(void) 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);
+ hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4); + todo_wine 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]); + + /* Test applying a parameter block while recording a new one. */ + hr = effect->lpVtbl->SetFloat(effect, "arr2[0]", 0.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloat(effect, "arr2[1]", 0.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v1", float_array_zero, 3); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloat(effect, "ts1[0].fv", 0.0f); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetFloatArray(effect, "ts1[0].v2", float_array_zero, 4); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + memset(&mat, 0, sizeof(mat)); + hr = effect->lpVtbl->SetMatrix(effect, "m3x2row", &effect_orig_mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->SetMatrix(effect, "m3x2column", &effect_orig_mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = effect->lpVtbl->BeginParameterBlock(effect); + todo_wine 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); + + 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); + 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); + + hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v1", float_array, 3); + ok(hr == D3D_OK && !memcmp(float_array, float_array_zero, 3 * sizeof(*float_array)), + "Got unexpected hr %#x, ts1[0].v1 (%g, %g, %g).\n", hr, + float_array[0], float_array[1], float_array[2]); + + hr = effect->lpVtbl->GetMatrix(effect, "m3x2row", &mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n"); + hr = effect->lpVtbl->GetMatrix(effect, "m3x2column", &mat); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(!memcmp(&mat, &effect_orig_mat, sizeof(mat)), "Got unexpected matrix.\n"); + + hr = effect->lpVtbl->GetFloat(effect, "ts1[0].fv", &float_value); + ok(hr == D3D_OK && float_value == 0.0f, "Got unexpected hr %#x, float_value %g.\n", hr, float_value); + + hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4); + ok(hr == D3D_OK && float_array[0] == 0.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]); + + block2 = effect->lpVtbl->EndParameterBlock(effect); + todo_wine 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); + + 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); + 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); + + hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v1", float_array, 3); + ok(hr == D3D_OK && !memcmp(float_array, float_array_zero, 3 * sizeof(*float_array)), + "Got unexpected hr %#x, ts1[0].v1 (%g, %g, %g).\n", hr, + float_array[0], float_array[1], float_array[2]); + + 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"); + 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"); + + 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); + hr = effect->lpVtbl->GetFloatArray(effect, "ts1[0].v2", float_array, 4); todo_wine ok(hr == D3D_OK && float_array[0] == -29.0f && !memcmp(float_array + 1, float_array_zero, 3 * sizeof(*float_array)), @@ -8224,6 +8304,8 @@ static void test_effect_parameter_block(void)
hr = effect->lpVtbl->DeleteParameterBlock(effect, block); todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr); + hr = effect->lpVtbl->DeleteParameterBlock(effect, block2); + todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr);
hr = effect->lpVtbl->SetTexture(effect, "tex1", NULL); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
On 11/18/19 18:59, Matteo Bruni wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
While reviewing the previous patch I became curious WRT ApplyParameterBlock() while recording another parameter block. I didn't notice your test in patch 9/9 at the time (a point to having the test earlier in the series, probably) so I wrote my own version. Good thing that I did: it looks like applying a parameter block while recording also doesn't update the effect parameters.
Oh yeah, it looks like it doesn't. My test was zeroing values before 'ApplyParameterBlock' to test that, but was doing that while recording of a new block was already active, so the parameter value was not actually cleared before apply test.
On Mon, Nov 18, 2019 at 5:13 PM Paul Gofman gofmanp@gmail.com wrote:
On 11/18/19 18:59, Matteo Bruni wrote:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
While reviewing the previous patch I became curious WRT ApplyParameterBlock() while recording another parameter block. I didn't notice your test in patch 9/9 at the time (a point to having the test earlier in the series, probably) so I wrote my own version. Good thing that I did: it looks like applying a parameter block while recording also doesn't update the effect parameters.
Oh yeah, it looks like it doesn't. My test was zeroing values before 'ApplyParameterBlock' to test that, but was doing that while recording of a new block was already active, so the parameter value was not actually cleared before apply test.
Yeah, with the above I meant that it was a bit of a fortunate mistake that I didn't notice your test and ended up rewriting it, because probably I'd have overlooked that detail too otherwise.
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman gofmanp@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/effect.c | 34 +++++++++++++++++++++++++++++++--- dlls/d3dx9_36/tests/effect.c | 4 ++-- 2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index eefd14aafa4..4be7c7b6bc2 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -30,6 +30,7 @@ #define INT_FLOAT_MULTI_INVERSE (1/INT_FLOAT_MULTI)
static const char parameter_magic_string[4] = {'@', '!', '#', '\xFF'}; +static const char parameter_block_magic_string[4] = {'@', '!', '#', '\xFE'};
#define PARAMETER_FLAG_SHARED 1
@@ -147,6 +148,11 @@ struct d3dx_technique struct IDirect3DStateBlock9 *saved_state; };
+struct d3dx_parameter_block +{ + char magic_string[ARRAY_SIZE(parameter_block_magic_string)]; +}; + struct d3dx_effect { ID3DXEffect ID3DXEffect_iface; @@ -177,6 +183,8 @@ struct d3dx_effect unsigned int light_updated; D3DMATERIAL9 current_material; BOOL material_updated; + + struct d3dx_parameter_block *current_parameter_block; };
#define INITIAL_SHARED_DATA_SIZE 4 @@ -668,6 +676,14 @@ static void free_technique(struct d3dx_technique *technique) technique->name = NULL; }
+static void free_parameter_block(struct d3dx_parameter_block *block) +{ + if (!block) + return; + + heap_free(block); +} + static void d3dx_effect_cleanup(struct d3dx_effect *effect) { ID3DXEffectPool *pool; @@ -675,6 +691,8 @@ static void d3dx_effect_cleanup(struct d3dx_effect *effect)
TRACE("effect %p.\n", effect);
+ free_parameter_block(effect->current_parameter_block); + heap_free(effect->full_name_tmp);
if (effect->parameters) @@ -4045,11 +4063,21 @@ static HRESULT WINAPI d3dx_effect_GetStateManager(ID3DXEffect *iface, ID3DXEffec
static HRESULT WINAPI d3dx_effect_BeginParameterBlock(ID3DXEffect *iface) { - struct d3dx_effect *This = impl_from_ID3DXEffect(iface); + struct d3dx_effect *effect = impl_from_ID3DXEffect(iface);
- FIXME("(%p)->(): stub\n", This); + TRACE("iface %p.\n", iface);
- return E_NOTIMPL; + if (effect->current_parameter_block) + { + WARN("Parameter block is already started.\n"); + return D3DERR_INVALIDCALL; + } + + 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)); + + return D3D_OK; }
static D3DXHANDLE WINAPI d3dx_effect_EndParameterBlock(ID3DXEffect *iface) diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 922d8247b1f..bb9604194dc 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -8065,9 +8065,9 @@ static void test_effect_parameter_block(void) ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = effect->lpVtbl->BeginParameterBlock(effect); - 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->BeginParameterBlock(effect); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); block = effect->lpVtbl->EndParameterBlock(effect); todo_wine ok(!!block, "Got unexpected block %p.\n", block); handle = effect->lpVtbl->EndParameterBlock(effect);
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman gofmanp@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/effect.c | 26 +++++++++++++++++++++++--- dlls/d3dx9_36/tests/effect.c | 14 +++++++------- 2 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 4be7c7b6bc2..8317d7112c4 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -24,6 +24,7 @@ #include "d3dx9_private.h" #include "d3dcompiler.h" #include "winternl.h" +#include "wine/list.h"
/* Constants for special INT/FLOAT conversation */ #define INT_FLOAT_MULTI 255.0f @@ -151,6 +152,7 @@ struct d3dx_technique struct d3dx_parameter_block { char magic_string[ARRAY_SIZE(parameter_block_magic_string)]; + struct list entry; };
struct d3dx_effect @@ -184,6 +186,7 @@ struct d3dx_effect D3DMATERIAL9 current_material; BOOL material_updated;
+ struct list parameter_block_list; struct d3dx_parameter_block *current_parameter_block; };
@@ -686,12 +689,18 @@ static void free_parameter_block(struct d3dx_parameter_block *block)
static void d3dx_effect_cleanup(struct d3dx_effect *effect) { + struct d3dx_parameter_block *block, *cursor; ID3DXEffectPool *pool; unsigned int i;
TRACE("effect %p.\n", effect);
free_parameter_block(effect->current_parameter_block); + LIST_FOR_EACH_ENTRY_SAFE(block, cursor, &effect->parameter_block_list, struct d3dx_parameter_block, entry) + { + list_remove(&block->entry); + free_parameter_block(block); + }
heap_free(effect->full_name_tmp);
@@ -4082,11 +4091,20 @@ static HRESULT WINAPI d3dx_effect_BeginParameterBlock(ID3DXEffect *iface)
static D3DXHANDLE WINAPI d3dx_effect_EndParameterBlock(ID3DXEffect *iface) { - struct d3dx_effect *This = impl_from_ID3DXEffect(iface); + struct d3dx_effect *effect = impl_from_ID3DXEffect(iface); + struct d3dx_parameter_block *ret;
- FIXME("(%p)->(): stub\n", This); + TRACE("iface %p.\n", iface);
- return NULL; + if (!effect->current_parameter_block) + { + WARN("No active parameter block.\n"); + return NULL; + } + ret = effect->current_parameter_block; + effect->current_parameter_block = NULL; + list_add_tail(&effect->parameter_block_list, &ret->entry); + return (D3DXHANDLE)ret; }
static HRESULT WINAPI d3dx_effect_ApplyParameterBlock(ID3DXEffect *iface, D3DXHANDLE parameter_block) @@ -6232,6 +6250,8 @@ static HRESULT d3dx9_effect_init(struct d3dx_effect *effect, struct IDirect3DDev
effect->flags = eflags;
+ list_init(&effect->parameter_block_list); + read_dword(&ptr, &tag); TRACE("Tag: %x\n", tag);
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index bb9604194dc..7b6c1f00d65 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -8069,7 +8069,7 @@ static void test_effect_parameter_block(void) hr = effect->lpVtbl->BeginParameterBlock(effect); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); block = effect->lpVtbl->EndParameterBlock(effect); - todo_wine ok(!!block, "Got unexpected block %p.\n", block); + ok(!!block, "Got unexpected block %p.\n", block); handle = effect->lpVtbl->EndParameterBlock(effect); ok(!handle, "Got unexpected handle %p.\n", handle);
@@ -8084,13 +8084,13 @@ static void test_effect_parameter_block(void) todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr);
hr = effect->lpVtbl->BeginParameterBlock(effect); - 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->SetFloat(effect, "vec3[0]", 1001.0f); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->SetFloat(effect, "arr1[0]", 91.0f); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); block = effect->lpVtbl->EndParameterBlock(effect); - todo_wine ok(!!block, "Got unexpected block %p.\n", block); + 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);
@@ -8108,7 +8108,7 @@ static void test_effect_parameter_block(void) ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr);
hr = effect->lpVtbl->BeginParameterBlock(effect); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
/* Effect parameters are not updated during recording. */ hr = effect->lpVtbl->SetTexture(effect, "tex1", (IDirect3DBaseTexture9 *)texture); @@ -8160,7 +8160,7 @@ static void test_effect_parameter_block(void) ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
block = effect->lpVtbl->EndParameterBlock(effect); - todo_wine ok(!!block, "Got unexpected block %p.\n", block); + ok(!!block, "Got unexpected block %p.\n", block);
IDirect3DTexture9_AddRef(texture); refcount = IDirect3DTexture9_Release(texture); @@ -8240,7 +8240,7 @@ static void test_effect_parameter_block(void) ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = effect->lpVtbl->BeginParameterBlock(effect); - 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->ApplyParameterBlock(effect, block); todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -8271,7 +8271,7 @@ static void test_effect_parameter_block(void) float_array[0], float_array[1], float_array[2], float_array[3]);
block2 = effect->lpVtbl->EndParameterBlock(effect); - todo_wine ok(!!block2, "Got unexpected block %p.\n", block2); + 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);
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman gofmanp@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/effect.c | 30 +++++++++++++++++++++++++++--- dlls/d3dx9_36/tests/effect.c | 12 ++++++------ 2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 8317d7112c4..173bd8ea374 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -509,6 +509,14 @@ 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); }
+static struct d3dx_parameter_block *get_valid_parameter_block(D3DXHANDLE handle) +{ + struct d3dx_parameter_block *block = (struct d3dx_parameter_block *)handle; + + return block && !strncmp(block->magic_string, parameter_block_magic_string, + sizeof(parameter_block_magic_string)) ? block : NULL; +} + static void free_state(struct d3dx_state *state) { free_parameter(&state->parameter, FALSE, FALSE); @@ -4119,11 +4127,27 @@ static HRESULT WINAPI d3dx_effect_ApplyParameterBlock(ID3DXEffect *iface, D3DXHA #if D3DX_SDK_VERSION >= 26 static HRESULT WINAPI d3dx_effect_DeleteParameterBlock(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_effect *effect = impl_from_ID3DXEffect(iface); + struct d3dx_parameter_block *b;
- FIXME("(%p)->(%p): stub\n", This, parameter_block); + TRACE("iface %p, parameter_block %p.\n", iface, parameter_block);
- return E_NOTIMPL; + if (!block) + return D3DERR_INVALIDCALL; + + LIST_FOR_EACH_ENTRY(b, &effect->parameter_block_list, struct d3dx_parameter_block, entry) + { + if (b == block) + { + list_remove(&b->entry); + free_parameter_block(b); + return D3D_OK; + } + } + + WARN("Block is not found in issued block list, not freeing memory.\n"); + return D3DERR_INVALIDCALL; } #endif
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 7b6c1f00d65..f1cbe49287c 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -8081,7 +8081,7 @@ static void test_effect_parameter_block(void) hr = effect->lpVtbl->ApplyParameterBlock(effect, block); todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->DeleteParameterBlock(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->BeginParameterBlock(effect); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); @@ -8095,9 +8095,9 @@ static void test_effect_parameter_block(void) todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = effect->lpVtbl->DeleteParameterBlock(effect2, block); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr); hr = effect->lpVtbl->DeleteParameterBlock(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->ApplyParameterBlock(effect, NULL); todo_wine ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); @@ -8167,7 +8167,7 @@ static void test_effect_parameter_block(void) ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
hr = effect->lpVtbl->DeleteParameterBlock(effect2, block); - todo_wine ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr); + ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
IDirect3DTexture9_AddRef(texture); refcount = IDirect3DTexture9_Release(texture); @@ -8303,9 +8303,9 @@ static void test_effect_parameter_block(void) float_array[0], float_array[1], float_array[2], float_array[3]);
hr = effect->lpVtbl->DeleteParameterBlock(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->DeleteParameterBlock(effect, block2); - todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr); + ok(hr == D3D_OK, "Got result %#x.\n", hr);
hr = effect->lpVtbl->SetTexture(effect, "tex1", NULL); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman gofmanp@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/effect.c | 130 ++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 61 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 173bd8ea374..a5482b52107 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -825,6 +825,73 @@ static void set_matrix_transpose(struct d3dx_parameter *param, const D3DXMATRIX } }
+static HRESULT set_string(char **param_data, const char *string) +{ + heap_free(*param_data); + *param_data = heap_alloc(strlen(string) + 1); + if (!*param_data) + { + ERR("Out of memory.\n"); + return E_OUTOFMEMORY; + } + strcpy(*param_data, string); + return D3D_OK; +} + +static HRESULT set_value(struct d3dx_parameter *param, const void *data, unsigned int bytes) +{ + unsigned int i, count; + + bytes = min(bytes, param->bytes); + count = min(param->element_count ? param->element_count : 1, bytes / sizeof(void *)); + + switch (param->type) + { + case D3DXPT_TEXTURE: + case D3DXPT_TEXTURE1D: + case D3DXPT_TEXTURE2D: + case D3DXPT_TEXTURE3D: + case D3DXPT_TEXTURECUBE: + for (i = 0; i < count; ++i) + { + IUnknown *old_texture = ((IUnknown **)param->data)[i]; + IUnknown *new_texture = ((IUnknown **)data)[i]; + + if (new_texture == old_texture) + continue; + + if (new_texture) + IUnknown_AddRef(new_texture); + if (old_texture) + IUnknown_Release(old_texture); + } + /* fallthrough */ + case D3DXPT_VOID: + case D3DXPT_BOOL: + case D3DXPT_INT: + case D3DXPT_FLOAT: + TRACE("Copy %u bytes.\n", bytes); + memcpy(param->data, data, bytes); + break; + + case D3DXPT_STRING: + { + HRESULT hr; + + for (i = 0; i < count; ++i) + if (FAILED(hr = set_string(&((char **)param->data)[i], ((const char **)data)[i]))) + return hr; + break; + } + + default: + FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(param->type)); + break; + } + + return D3D_OK; +} + static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_effect *effect, struct d3dx_parameter *parameter, const char *name) { @@ -1174,19 +1241,6 @@ static void set_dirty(struct d3dx_parameter *param) top_param->update_version = new_update_version; }
-static HRESULT set_string(char **param_data, const char *string) -{ - HeapFree(GetProcessHeap(), 0, *param_data); - *param_data = HeapAlloc(GetProcessHeap(), 0, strlen(string) + 1); - if (!*param_data) - { - ERR("Out of memory.\n"); - return E_OUTOFMEMORY; - } - strcpy(*param_data, string); - return D3D_OK; -} - static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void *value) { static const struct @@ -2276,7 +2330,6 @@ static HRESULT WINAPI d3dx_effect_SetValue(ID3DXEffect *iface, D3DXHANDLE parame { struct d3dx_effect *effect = impl_from_ID3DXEffect(iface); struct d3dx_parameter *param = get_valid_parameter(effect, parameter); - unsigned int i;
TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface, parameter, data, bytes);
@@ -2293,53 +2346,8 @@ static HRESULT WINAPI d3dx_effect_SetValue(ID3DXEffect *iface, D3DXHANDLE parame
if (data && param->bytes <= bytes) { - switch (param->type) - { - case D3DXPT_TEXTURE: - case D3DXPT_TEXTURE1D: - case D3DXPT_TEXTURE2D: - case D3DXPT_TEXTURE3D: - case D3DXPT_TEXTURECUBE: - for (i = 0; i < (param->element_count ? param->element_count : 1); ++i) - { - IUnknown *old_texture = ((IUnknown **)param->data)[i]; - IUnknown *new_texture = ((IUnknown **)data)[i]; - - if (new_texture == old_texture) - continue; - - if (new_texture) - IUnknown_AddRef(new_texture); - if (old_texture) - IUnknown_Release(old_texture); - } - /* fallthrough */ - case D3DXPT_VOID: - case D3DXPT_BOOL: - case D3DXPT_INT: - case D3DXPT_FLOAT: - TRACE("Copy %u bytes.\n", param->bytes); - memcpy(param->data, data, param->bytes); - set_dirty(param); - break; - - case D3DXPT_STRING: - { - HRESULT hr; - - set_dirty(param); - for (i = 0; i < (param->element_count ? param->element_count : 1); ++i) - if (FAILED(hr = set_string(&((char **)param->data)[i], ((const char **)data)[i]))) - return hr; - break; - } - - default: - FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(param->type)); - break; - } - - return D3D_OK; + set_dirty(param); + return set_value(param, data, bytes); }
WARN("Invalid argument specified.\n");
From: Paul Gofman gofmanp@gmail.com
Signed-off-by: Paul Gofman gofmanp@gmail.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/effect.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index a5482b52107..d5b2c359379 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -540,16 +540,21 @@ static void free_sampler(struct d3dx_sampler *sampler)
static void d3dx_pool_release_shared_parameter(struct d3dx_top_level_parameter *param);
-static void free_parameter_data(struct d3dx_parameter *param, BOOL child) +static void free_parameter_object_data(struct d3dx_parameter *param, const void *data, unsigned int bytes) { - if (!param->data) + unsigned int i, count; + + if (param->class != D3DXPC_OBJECT) return; - if (param->class == D3DXPC_OBJECT && !param->element_count) + + count = min(param->element_count ? param->element_count : 1, bytes / sizeof(void *)); + + for (i = 0; i < count; ++i) { switch (param->type) { case D3DXPT_STRING: - heap_free(*(char **)param->data); + heap_free(((char **)data)[i]); break;
case D3DXPT_TEXTURE: @@ -559,7 +564,8 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child) case D3DXPT_TEXTURECUBE: case D3DXPT_PIXELSHADER: case D3DXPT_VERTEXSHADER: - if (*(IUnknown **)param->data) IUnknown_Release(*(IUnknown **)param->data); + if (*(IUnknown **)data) + IUnknown_Release(((IUnknown **)data)[i]); break;
case D3DXPT_SAMPLER: @@ -567,7 +573,8 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child) case D3DXPT_SAMPLER2D: case D3DXPT_SAMPLER3D: case D3DXPT_SAMPLERCUBE: - free_sampler((struct d3dx_sampler *)param->data); + assert(count == 1); + free_sampler((struct d3dx_sampler *)data); return;
default: @@ -575,6 +582,16 @@ static void free_parameter_data(struct d3dx_parameter *param, BOOL child) break; } } +} + +static void free_parameter_data(struct d3dx_parameter *param, BOOL child) +{ + if (!param->data) + return; + + if (!param->element_count) + free_parameter_object_data(param, param->data, param->bytes); + if (!child || is_param_type_sampler(param->type)) heap_free(param->data); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=60418
Your paranoid android.
=== w1064v1809 (32 bit report) ===
ddraw: 1938:ddraw7: unhandled exception c0000005 at 736240F8
=== w1064v1809_2scr (32 bit report) ===
ddraw: 1ac0:ddraw7: unhandled exception c0000005 at 738C40F8
=== w1064v1809_ar (32 bit report) ===
ddraw: 03e0:ddraw7: unhandled exception c0000005 at 736740F8
=== w1064v1809_he (32 bit report) ===
ddraw: 1a70:ddraw7: unhandled exception c0000005 at 737E40F8
=== w1064v1809_ja (32 bit report) ===
ddraw: 1a48:ddraw7: unhandled exception c0000005 at 71D140F8
=== w1064v1809_zh_CN (32 bit report) ===
ddraw: 1a78:ddraw7: unhandled exception c0000005 at 733440F8
On Mon, 18 Nov 2019 at 19:30, Matteo Bruni mbruni@codeweavers.com wrote:
@@ -16593,7 +16593,7 @@ static void test_surface_format_conversion_alpha(void) {16}, {0x0000f800}, {0x000007e0}, {0x0000001f}, {0x00000000} }, "R5G6B5", 2, 4, 4, 0, TRUE,
/* Looks broken for sysmem texture convertions on Windows (at
/* Looks broken for sysmem texture conversions on Windows (at * least with hardware device), the result is either error from * _Blt() or a copy of the source data without any conversion. */ },
ddraw4.c has the same issue.
On Mon, Nov 18, 2019 at 5:25 PM Henri Verbeet hverbeet@gmail.com wrote:
On Mon, 18 Nov 2019 at 19:30, Matteo Bruni mbruni@codeweavers.com wrote:
@@ -16593,7 +16593,7 @@ static void test_surface_format_conversion_alpha(void) {16}, {0x0000f800}, {0x000007e0}, {0x0000001f}, {0x00000000} }, "R5G6B5", 2, 4, 4, 0, TRUE,
/* Looks broken for sysmem texture convertions on Windows (at
/* Looks broken for sysmem texture conversions on Windows (at * least with hardware device), the result is either error from * _Blt() or a copy of the source data without any conversion. */ },
ddraw4.c has the same issue.
I thought I checked that but I must have looked at the wrong branch or something...