[v4] d3dx9: support setting texture through SetValue in effect.
Paul Gofman
gofmanp at gmail.com
Mon Mar 7 17:33:27 CST 2016
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
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 4be6e4b..47a7c38 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 de7d1e9..a785f4d 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.5.0
Changed sizeof(IDirect3DTexture9 **) to sizeof(texture) and sizeof(texture_set).
More information about the wine-patches
mailing list