Paul Gofman : d3dx9: Support setting texture through SetValue in effect.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Mar 9 08:05:55 CST 2016


Module: wine
Branch: master
Commit: 1da5af93640e6a46070ae6cad68d5e67dee2694b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1da5af93640e6a46070ae6cad68d5e67dee2694b

Author: Paul Gofman <gofmanp at gmail.com>
Date:   Tue Mar  8 02:33:27 2016 +0300

d3dx9: Support setting texture through SetValue in effect.

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 a374d90..e42cf86 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);




More information about the wine-cvs mailing list