[PATCH 3/3] d3dx9: Support setting strings in effect.

Paul Gofman gofmanp at gmail.com
Fri May 5 06:34:32 CDT 2017


For bug #42919.

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
 dlls/d3dx9_36/effect.c       | 47 ++++++++++++++++++++++++++++++++++++--------
 dlls/d3dx9_36/tests/effect.c |  4 ----
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index 3a6803c..6cc098d 100644
--- a/dlls/d3dx9_36/effect.c
+++ b/dlls/d3dx9_36/effect.c
@@ -1497,10 +1497,24 @@ static void clear_dirty_params(struct d3dx9_base_effect *base)
         base->parameters[i].runtime_flags &= ~PARAMETER_FLAG_DIRTY;
 }
 
+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 HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
         D3DXHANDLE parameter, const void *data, UINT bytes)
 {
     struct d3dx_parameter *param = get_valid_parameter(base, parameter);
+    unsigned int i;
 
     if (!param)
     {
@@ -1524,9 +1538,6 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
             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];
@@ -1537,19 +1548,31 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
                     if (unk)
                         IUnknown_Release(unk);
                 }
-            }
             /* fallthrough */
             case D3DXPT_VOID:
             case D3DXPT_BOOL:
             case D3DXPT_INT:
             case D3DXPT_FLOAT:
-                TRACE("Copy %u bytes\n", param->bytes);
+                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));
+                FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(param->type));
                 break;
         }
 
@@ -2578,9 +2601,17 @@ static HRESULT d3dx9_base_effect_get_matrix_transpose_pointer_array(struct d3dx9
 static HRESULT d3dx9_base_effect_set_string(struct d3dx9_base_effect *base,
         D3DXHANDLE parameter, const char *string)
 {
-    FIXME("stub!\n");
+    struct d3dx_parameter *param = get_valid_parameter(base, parameter);
 
-    return E_NOTIMPL;
+    if (param && param->type == D3DXPT_STRING)
+    {
+        set_dirty(param);
+        return set_string(param->data, string);
+    }
+
+    WARN("Parameter not found.\n");
+
+    return D3DERR_INVALIDCALL;
 }
 
 static HRESULT d3dx9_base_effect_get_string(struct d3dx9_base_effect *base,
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c
index 6e8024f..7b39e31 100644
--- a/dlls/d3dx9_36/tests/effect.c
+++ b/dlls/d3dx9_36/tests/effect.c
@@ -2441,7 +2441,6 @@ static void test_effect_setvalue_object(IDirect3DDevice9 *device)
     ok(!count, "Got reference count %u, expected 0.\n", count);
 
     hr = effect->lpVtbl->SetString(effect, "s", expected_string);
-    todo_wine
     ok(hr == D3D_OK, "Got result %#x.\n", hr);
     string = NULL;
     hr = effect->lpVtbl->GetString(effect, "s", &string);
@@ -2451,7 +2450,6 @@ static void test_effect_setvalue_object(IDirect3DDevice9 *device)
 
     ok(string != expected_string, "String pointers are the same.\n");
     ok(string == string2, "String pointers differ.\n");
-    todo_wine
     ok(!strcmp(string, expected_string), "Unexpected string '%s'.\n", string);
 
     string = expected_string2;
@@ -2466,7 +2464,6 @@ static void test_effect_setvalue_object(IDirect3DDevice9 *device)
     ok(hr == D3D_OK, "Got result %#x.\n", hr);
 
     ok(string != expected_string2, "String pointers are the same.\n");
-    todo_wine
     ok(!strcmp(string, expected_string2), "Unexpected string '%s'.\n", string);
 
     hr = effect->lpVtbl->SetValue(effect, "s_2", expected_string_array,
@@ -2477,7 +2474,6 @@ static void test_effect_setvalue_object(IDirect3DDevice9 *device)
     ok(hr == D3D_OK, "Got result %#x.\n", hr);
     for (i = 0; i < ARRAY_SIZE(expected_string_array); ++i)
     {
-        todo_wine
         ok(!strcmp(string_array[i], expected_string_array[i]), "Unexpected string '%s', i %u.\n",
                 string_array[i], i);
     }
-- 
2.9.3




More information about the wine-patches mailing list