From 1da5af93640e6a46070ae6cad68d5e67dee2694b Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 8 Mar 2016 02:33:27 +0300 Subject: [PATCH] d3dx9: Support setting texture through SetValue in effect. Signed-off-by: Paul Gofman Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- dlls/d3dx9_36/effect.c | 20 ++++++++++++++++++++ dlls/d3dx9_36/tests/effect.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index a374d90116e..e42cf865b27 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -1366,6 +1366,26 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base, { switch (param->type) { + case D3DXPT_TEXTURE: + case D3DXPT_TEXTURE1D: + case D3DXPT_TEXTURE2D: + case D3DXPT_TEXTURE3D: + case D3DXPT_TEXTURECUBE: + { + unsigned int i; + + for (i = 0; i < (param->element_count ? param->element_count : 1); ++i) + { + IUnknown *unk = ((IUnknown **)data)[i]; + if (unk) + IUnknown_AddRef(unk); + + unk = ((IUnknown **)param->data)[i]; + if (unk) + IUnknown_Release(unk); + } + } + /* fallthrough */ case D3DXPT_VOID: case D3DXPT_BOOL: case D3DXPT_INT: diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index de7d1e9e884..a785f4d5185 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -2389,6 +2389,43 @@ static void test_effect_parameter_value(IDirect3DDevice9 *device) } } +static void test_effect_setvalue_object(IDirect3DDevice9 *device) +{ + ID3DXEffect *effect; + D3DXHANDLE parameter; + IDirect3DTexture9 *texture; + IDirect3DTexture9 *texture_set; + HRESULT hr; + ULONG count; + + hr = D3DXCreateEffect(device, test_effect_parameter_value_blob_object, + sizeof(test_effect_parameter_value_blob_object), NULL, NULL, 0, NULL, &effect, NULL); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + + parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "tex"); + ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter); + + texture = NULL; + 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->SetValue(effect, parameter, &texture, sizeof(texture)); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + texture_set = NULL; + hr = effect->lpVtbl->GetValue(effect, parameter, &texture_set, sizeof(texture_set)); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + ok(texture == texture_set, "Texture does not match.\n"); + + count = IDirect3DTexture9_Release(texture_set); + ok(count == 2, "Got reference count %u, expected 2.\n", count); + texture_set = NULL; + hr = effect->lpVtbl->SetValue(effect, parameter, &texture_set, sizeof(texture_set)); + ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr); + count = IDirect3DTexture9_Release(texture); + ok(!count, "Got reference count %u, expected 0.\n", count); + + effect->lpVtbl->Release(effect); +} + /* * fxc.exe /Tfx_2_0 */ @@ -3008,6 +3045,7 @@ START_TEST(effect) test_create_effect_and_pool(device); test_create_effect_compiler(); test_effect_parameter_value(device); + test_effect_setvalue_object(device); test_effect_variable_names(device); test_effect_compilation_errors(device); test_effect_states(device); -- 2.11.4.GIT