[PATCH] d3dx9: Merge the d3dx_effect_GetValue() helper

Matteo Bruni mbruni at codeweavers.com
Fri Mar 15 13:07:06 CDT 2019


From: Michael Stefaniuc <mstefani at winehq.org>

Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
 dlls/d3dx9_36/effect.c | 122 +++++++++++++++++++----------------------
 1 file changed, 57 insertions(+), 65 deletions(-)

diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c
index 68714f7ebb7..0dc56e24063 100644
--- a/dlls/d3dx9_36/effect.c
+++ b/dlls/d3dx9_36/effect.c
@@ -1254,70 +1254,6 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
     return D3DERR_INVALIDCALL;
 }
 
-static HRESULT d3dx9_base_effect_get_value(struct d3dx9_base_effect *base,
-        D3DXHANDLE parameter, void *data, UINT bytes)
-{
-    struct d3dx_parameter *param = get_valid_parameter(base, parameter);
-
-    if (!param)
-    {
-        WARN("Invalid parameter %p specified\n", parameter);
-        return D3DERR_INVALIDCALL;
-    }
-
-    /* samplers don't touch data */
-    if (param->class == D3DXPC_OBJECT && is_param_type_sampler(param->type))
-    {
-        TRACE("Sampler: returning E_FAIL\n");
-        return E_FAIL;
-    }
-
-    if (data && param->bytes <= bytes)
-    {
-        TRACE("Type %s\n", debug_d3dxparameter_type(param->type));
-
-        switch (param->type)
-        {
-            case D3DXPT_VOID:
-            case D3DXPT_BOOL:
-            case D3DXPT_INT:
-            case D3DXPT_FLOAT:
-            case D3DXPT_STRING:
-                break;
-
-            case D3DXPT_VERTEXSHADER:
-            case D3DXPT_PIXELSHADER:
-            case D3DXPT_TEXTURE:
-            case D3DXPT_TEXTURE1D:
-            case D3DXPT_TEXTURE2D:
-            case D3DXPT_TEXTURE3D:
-            case D3DXPT_TEXTURECUBE:
-            {
-                UINT i;
-
-                for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
-                {
-                    IUnknown *unk = ((IUnknown **)param->data)[i];
-                    if (unk) IUnknown_AddRef(unk);
-                }
-                break;
-            }
-
-            default:
-                FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
-                break;
-        }
-
-        TRACE("Copy %u bytes\n", param->bytes);
-        memcpy(data, param->data, param->bytes);
-        return D3D_OK;
-    }
-
-    WARN("Parameter not found.\n");
-
-    return D3DERR_INVALIDCALL;
-}
-
 static HRESULT d3dx9_base_effect_set_vector(struct d3dx9_base_effect *base,
         D3DXHANDLE parameter, const D3DXVECTOR4 *vector)
 {
@@ -2615,10 +2551,66 @@ static HRESULT WINAPI d3dx_effect_SetValue(ID3DXEffect *iface, D3DXHANDLE parame
 static HRESULT WINAPI d3dx_effect_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, void *data, UINT bytes)
 {
     struct d3dx_effect *effect = impl_from_ID3DXEffect(iface);
+    struct d3dx_parameter *param = get_valid_parameter(&effect->base_effect, parameter);
 
     TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface, parameter, data, bytes);
 
-    return d3dx9_base_effect_get_value(&effect->base_effect, parameter, data, bytes);
+    if (!param)
+    {
+        WARN("Invalid parameter %p specified.\n", parameter);
+        return D3DERR_INVALIDCALL;
+    }
+    if (param->class == D3DXPC_OBJECT && is_param_type_sampler(param->type))
+    {
+        WARN("Parameter is a sampler, returning E_FAIL.\n");
+        return E_FAIL;
+    }
+
+    if (data && param->bytes <= bytes)
+    {
+        TRACE("Type %s.\n", debug_d3dxparameter_type(param->type));
+
+        switch (param->type)
+        {
+            case D3DXPT_VOID:
+            case D3DXPT_BOOL:
+            case D3DXPT_INT:
+            case D3DXPT_FLOAT:
+            case D3DXPT_STRING:
+                break;
+
+            case D3DXPT_VERTEXSHADER:
+            case D3DXPT_PIXELSHADER:
+            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 **)param->data)[i];
+                    if (unk)
+                        IUnknown_AddRef(unk);
+                }
+                break;
+            }
+
+            default:
+                FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(param->type));
+                break;
+        }
+
+        TRACE("Copy %u bytes.\n", param->bytes);
+        memcpy(data, param->data, param->bytes);
+        return D3D_OK;
+    }
+
+    WARN("Parameter not found.\n");
+
+    return D3DERR_INVALIDCALL;
 }
 
 static HRESULT WINAPI d3dx_effect_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)
-- 
2.19.2




More information about the wine-devel mailing list