[PATCH 4/6] d3dx9: Evaluate condition if parameter can be directly copied during initialization.

Paul Gofman gofmanp at gmail.com
Wed May 24 04:46:54 CDT 2017


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
 dlls/d3dx9_36/d3dx9_private.h |  1 +
 dlls/d3dx9_36/preshader.c     | 25 ++++++++++++++++++-------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h
index 62213ac..ccb8e8a 100644
--- a/dlls/d3dx9_36/d3dx9_private.h
+++ b/dlls/d3dx9_36/d3dx9_private.h
@@ -154,6 +154,7 @@ struct d3dx_const_param_eval_output
     enum D3DXPARAMETER_CLASS constant_class;
     unsigned int register_index;
     unsigned int register_count;
+    BOOL direct_copy;
 };
 
 struct d3dx_const_tab
diff --git a/dlls/d3dx9_36/preshader.c b/dlls/d3dx9_36/preshader.c
index bddd74f..0cd6813 100644
--- a/dlls/d3dx9_36/preshader.c
+++ b/dlls/d3dx9_36/preshader.c
@@ -1043,17 +1043,14 @@ static void set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const
         if (!is_param_dirty(param, const_tab->update_version))
             continue;
 
-        get_constant_dimensions(const_set, &transpose, &major, &minor, &major_stride, &n, &count);
         start_offset = get_offset_reg(table, const_set->register_index);
-
-        if (param_type_to_table_type(param->type) == table_type
-                && !transpose && minor == major_stride
-                && count == get_offset_reg(table, const_set->register_count)
-                && count * sizeof(unsigned int) <= param->bytes)
+        if (const_set->direct_copy)
         {
-            regstore_set_values(rs, table, param->data, start_offset, count);
+            regstore_set_values(rs, table, param->data, start_offset,
+                    get_offset_reg(table, const_set->register_count));
             continue;
         }
+        get_constant_dimensions(const_set, &transpose, &major, &minor, &major_stride, &n, &count);
 
         for (i = 0; i < n; ++i)
         {
@@ -1142,6 +1139,9 @@ static HRESULT init_set_constants_param(struct d3dx_const_tab *const_tab, ID3DXC
     unsigned int const_count, param_count, i;
     BOOL get_element;
     struct d3dx_const_param_eval_output const_set;
+    unsigned int major, minor, major_stride, n, count;
+    enum pres_value_type table_type;
+    BOOL transpose;
     HRESULT hr;
 
     if (FAILED(get_ctab_constant_desc(ctab, hc, &desc)))
@@ -1218,6 +1218,17 @@ static HRESULT init_set_constants_param(struct d3dx_const_tab *const_tab, ID3DXC
         return D3DERR_INVALIDCALL;
     }
     const_set.register_count = desc.RegisterCount;
+    table_type = table_info[const_set.table].type;
+    get_constant_dimensions(&const_set, &transpose, &major, &minor, &major_stride, &n, &count);
+
+    if (param_type_to_table_type(param->type) == PRES_VT_MAX)
+        return D3DERR_INVALIDCALL;
+
+    const_set.direct_copy = param_type_to_table_type(param->type) == table_type
+            && !transpose && minor == major_stride
+            && count == get_offset_reg(const_set.table, const_set.register_count)
+            && count * sizeof(unsigned int) <= param->bytes;
+
     if (FAILED(hr = append_const_set(const_tab, &const_set)))
         return hr;
 
-- 
2.9.3




More information about the wine-patches mailing list