[PATCH 1/5] d3dx9: Move set_number() into d3dx9_private.h.

Matteo Bruni mbruni at codeweavers.com
Fri Jun 9 14:19:35 CDT 2017


Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
---
Inlining allows the compiler to get rid of the function calls overhead
(quite significant with those small and frequently used functions) and
to do additional optimizations.

 dlls/d3dx9_36/d3dx9_private.h | 84 +++++++++++++++++++++++++++++++++++++++-
 dlls/d3dx9_36/util.c          | 89 -------------------------------------------
 2 files changed, 82 insertions(+), 91 deletions(-)

diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h
index 8eb12b7ad0..c2f497773f 100644
--- a/dlls/d3dx9_36/d3dx9_private.h
+++ b/dlls/d3dx9_36/d3dx9_private.h
@@ -123,8 +123,88 @@ const char *debug_d3dxparameter_type(D3DXPARAMETER_TYPE t) DECLSPEC_HIDDEN;
 const char *debug_d3dxparameter_registerset(D3DXREGISTER_SET r) DECLSPEC_HIDDEN;
 
 /* parameter type conversion helpers */
-void set_number(void *outdata, D3DXPARAMETER_TYPE outtype,
-        const void *indata, D3DXPARAMETER_TYPE intype) DECLSPEC_HIDDEN;
+static inline BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
+{
+    switch (type)
+    {
+        case D3DXPT_FLOAT:
+        case D3DXPT_INT:
+        case D3DXPT_BOOL:
+            return !!*(DWORD *)data;
+
+        case D3DXPT_VOID:
+            return *(BOOL *)data;
+
+        default:
+            return FALSE;
+    }
+}
+
+static inline int get_int(D3DXPARAMETER_TYPE type, const void *data)
+{
+    switch (type)
+    {
+        case D3DXPT_FLOAT:
+            return (int)(*(float *)data);
+
+        case D3DXPT_INT:
+        case D3DXPT_VOID:
+            return *(int *)data;
+
+        case D3DXPT_BOOL:
+            return get_bool(type, data);
+
+        default:
+            return 0;
+    }
+}
+
+static inline float get_float(D3DXPARAMETER_TYPE type, const void *data)
+{
+    switch (type)
+    {
+        case D3DXPT_FLOAT:
+        case D3DXPT_VOID:
+            return *(float *)data;
+
+        case D3DXPT_INT:
+            return (float)(*(int *)data);
+
+        case D3DXPT_BOOL:
+            return (float)get_bool(type, data);
+
+        default:
+            return 0.0f;
+    }
+}
+
+static inline void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
+{
+    if (outtype == intype)
+    {
+        *(DWORD *)outdata = *(DWORD *)indata;
+        return;
+    }
+
+    switch (outtype)
+    {
+        case D3DXPT_FLOAT:
+            *(float *)outdata = get_float(intype, indata);
+            break;
+
+        case D3DXPT_BOOL:
+            *(BOOL *)outdata = get_bool(intype, indata);
+            break;
+
+        case D3DXPT_INT:
+            *(int *)outdata = get_int(intype, indata);
+            break;
+
+        default:
+            *(DWORD *)outdata = 0;
+            break;
+    }
+}
 
 static inline BOOL is_param_type_sampler(D3DXPARAMETER_TYPE type)
 {
diff --git a/dlls/d3dx9_36/util.c b/dlls/d3dx9_36/util.c
index 8f9b0b3364..9e4bbbf0bc 100644
--- a/dlls/d3dx9_36/util.c
+++ b/dlls/d3dx9_36/util.c
@@ -291,95 +291,6 @@ const char *debug_d3dxparameter_registerset(D3DXREGISTER_SET r)
 
 #undef WINE_D3DX_TO_STR
 
-/* parameter type conversion helpers */
-static BOOL get_bool(D3DXPARAMETER_TYPE type, const void *data)
-{
-    switch (type)
-    {
-        case D3DXPT_FLOAT:
-        case D3DXPT_INT:
-        case D3DXPT_BOOL:
-            return *(DWORD *)data != 0;
-
-        case D3DXPT_VOID:
-            return *(BOOL *)data;
-
-        default:
-            FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(type));
-            return FALSE;
-    }
-}
-
-static INT get_int(D3DXPARAMETER_TYPE type, const void *data)
-{
-    switch (type)
-    {
-        case D3DXPT_FLOAT:
-            return (INT)(*(FLOAT *)data);
-
-        case D3DXPT_INT:
-        case D3DXPT_VOID:
-            return *(INT *)data;
-
-        case D3DXPT_BOOL:
-            return get_bool(type, data);
-
-        default:
-            FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(type));
-            return 0;
-    }
-}
-
-static FLOAT get_float(D3DXPARAMETER_TYPE type, const void *data)
-{
-    switch (type)
-    {
-        case D3DXPT_FLOAT:
-        case D3DXPT_VOID:
-            return *(FLOAT *)data;
-
-        case D3DXPT_INT:
-            return (FLOAT)(*(INT *)data);
-
-        case D3DXPT_BOOL:
-            return (FLOAT)get_bool(type, data);
-
-        default:
-            FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(type));
-            return 0.0f;
-    }
-}
-
-void set_number(void *outdata, D3DXPARAMETER_TYPE outtype, const void *indata, D3DXPARAMETER_TYPE intype)
-{
-    if (outtype == intype)
-    {
-        *(DWORD *)outdata = *(DWORD *)indata;
-        return;
-    }
-
-    switch (outtype)
-    {
-        case D3DXPT_FLOAT:
-            *(FLOAT *)outdata = get_float(intype, indata);
-            break;
-
-        case D3DXPT_BOOL:
-            *(BOOL *)outdata = get_bool(intype, indata);
-            break;
-
-        case D3DXPT_INT:
-            *(INT *)outdata = get_int(intype, indata);
-            break;
-
-        default:
-            FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(outtype));
-            *(DWORD *)outdata = 0;
-            break;
-    }
-}
-
-
 /***********************************************************************
  * D3DXDebugMute
  * Returns always FALSE for us.
-- 
2.13.0




More information about the wine-patches mailing list