Paul Gofman : d3dx9: Compare parameter definition instead of parameter handle in IsParameterUsed ().

Alexandre Julliard julliard at winehq.org
Wed Apr 19 14:49:37 CDT 2017


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

Author: Paul Gofman <gofmanp at gmail.com>
Date:   Fri Apr 14 13:17:07 2017 +0300

d3dx9: Compare parameter definition instead of parameter handle in IsParameterUsed().

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       | 31 +++++++++++++++++++++++++------
 dlls/d3dx9_36/tests/effect.c |  4 +---
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index 49e8a88..8dc4738 100644
--- a/dlls/d3dx9_36/effect.c
+++ b/dlls/d3dx9_36/effect.c
@@ -3011,6 +3011,30 @@ static HRESULT d3dx9_apply_pass_states(struct ID3DXEffectImpl *effect, struct d3
     return ret;
 }
 
+static BOOL is_same_parameter(void *param1_, struct d3dx_parameter *param2)
+{
+    struct d3dx_parameter *param1 = (struct d3dx_parameter *)param1_;
+    BOOL matches;
+    unsigned int i, member_count;
+
+    matches = !strcmp(param1->name, param2->name) && param1->class == param2->class
+            && param1->type == param2->type && param1->rows == param2->rows
+            && param1->columns == param2->columns && param1->element_count == param2->element_count
+            && param1->member_count == param2->member_count;
+
+    member_count = param1->element_count ? param1->element_count : param1->member_count;
+
+    if (!matches || !member_count)
+        return matches;
+
+    for (i = 0; i < member_count; ++i)
+    {
+        if (!is_same_parameter(&param1->members[i], &param2->members[i]))
+            return FALSE;
+    }
+    return TRUE;
+}
+
 static inline struct ID3DXEffectImpl *impl_from_ID3DXEffect(ID3DXEffect *iface)
 {
     return CONTAINING_RECORD(iface, struct ID3DXEffectImpl, ID3DXEffect_iface);
@@ -3733,11 +3757,6 @@ static BOOL walk_parameter_dep(struct d3dx_parameter *param, walk_parameter_dep_
     return FALSE;
 }
 
-static BOOL compare_param_ptr(void *param_comp, struct d3dx_parameter *param)
-{
-    return param_comp == param;
-}
-
 static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDLE parameter, D3DXHANDLE technique)
 {
     struct ID3DXEffectImpl *effect = impl_from_ID3DXEffect(iface);
@@ -3756,7 +3775,7 @@ static BOOL WINAPI ID3DXEffectImpl_IsParameterUsed(ID3DXEffect* iface, D3DXHANDL
         pass = &tech->passes[i];
         for (j = 0; j < pass->state_count; ++j)
         {
-            if (walk_state_dep(&pass->states[j], compare_param_ptr, param))
+            if (walk_state_dep(&pass->states[j], is_same_parameter, param))
             {
                 TRACE("Returning TRUE.\n");
                 return TRUE;
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c
index a21d4e1..9c318b4 100644
--- a/dlls/d3dx9_36/tests/effect.c
+++ b/dlls/d3dx9_36/tests/effect.c
@@ -4532,12 +4532,10 @@ static void test_isparameterused_param_with_children_(unsigned int line, ID3DXEf
         param = effect->lpVtbl->GetParameterByName(effect, NULL, name);
     ok_(__FILE__, line)(!!param, "GetParameterByName failed for %s.\n", name);
 
-    todo_wine_if(effect2 && expected_result)
     ok_(__FILE__, line)(effect->lpVtbl->IsParameterUsed(effect, param, tech) == expected_result,
             "Unexpected IsParameterUsed() result for %s (referenced by handle).\n", name);
 
-    if (!effect2)
-        test_isparameterused_children(line, effect, tech, param);
+    test_isparameterused_children(line, effect, tech, param);
 }
 
 static void test_effect_isparameterused(IDirect3DDevice9 *device)




More information about the wine-cvs mailing list