[v2 6/7] d3dx9: Get rid of constant's length checking for matrix in set_constants().

Paul Gofman gofmanp at gmail.com
Mon Jun 12 06:22:05 CDT 2017


When count in const_upload_info is calculated precisely (considering actual
constant set length), boolean matrix setting always fall in direct copy path.
The test has both row_major and column_major qualified boolean matrices, but
the qualifier is ignored by compiler. If change the type of matrix to int,
the matrix goes to float constants and not to bool constants. So it looks like
the case of incomplete last row for matrix should now never happen.

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
v2:
    - use 'get_reg_components(table) == 1' condition instead of explicit table type.
---
 dlls/d3dx9_36/preshader.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/dlls/d3dx9_36/preshader.c b/dlls/d3dx9_36/preshader.c
index 717d876..45bdd57 100644
--- a/dlls/d3dx9_36/preshader.c
+++ b/dlls/d3dx9_36/preshader.c
@@ -269,6 +269,7 @@ struct const_upload_info
     unsigned int major_stride;
     unsigned int major_count;
     unsigned int count;
+    unsigned int minor_remainder;
 };
 
 static enum pres_value_type table_type_from_param_type(D3DXPARAMETER_TYPE type)
@@ -1032,10 +1033,22 @@ static void get_const_upload_info(struct d3dx_const_param_eval_output *const_set
         info->major = param->rows;
         info->minor = param->columns;
     }
-    info->major_stride = max(info->minor, get_reg_components(table));
-    info->major_count = min(info->major * info->major_stride,
-            get_offset_reg(table, const_set->register_count) + info->major_stride - 1) / info->major_stride;
-    info->count = info->major_count * info->minor;
+
+    if (get_reg_components(table) == 1)
+    {
+        unsigned int const_length = get_offset_reg(table, const_set->register_count);
+
+        info->major_stride = info->minor;
+        info->major_count = const_length / info->major_stride;
+        info->minor_remainder = const_length % info->major_stride;
+    }
+    else
+    {
+        info->major_stride = get_reg_components(table);
+        info->major_count = const_set->register_count;
+        info->minor_remainder = 0;
+    }
+    info->count = info->major_count * info->minor + info->minor_remainder;
 }
 
 static void pres_float_to_int(const void *in, void *out, unsigned int count)
@@ -1166,16 +1179,11 @@ static void set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const
             {
                 for (j = 0; j < info.minor; ++j)
                 {
-                    unsigned int offset;
-
-                    offset = i * info.major_stride + j;
-                    if (get_reg_offset(table, offset) >= const_set->register_count)
-                        break;
                     if (info.transpose)
                         param_offset = i + j * info.major;
                     else
                         param_offset = i * info.minor + j;
-                    out[offset] = data[param_offset];
+                    out[i * info.major_stride + j] = data[param_offset];
                 }
             }
             start_offset += get_offset_reg(table, const_set->register_count);
@@ -1411,6 +1419,9 @@ static HRESULT init_set_constants_param(struct d3dx_const_tab *const_tab, ID3DXC
             && !info.transpose && info.minor == info.major_stride
             && info.count == get_offset_reg(const_set.table, const_set.register_count)
             && info.count * sizeof(unsigned int) <= param->bytes;
+    if (info.minor_remainder && !const_set.direct_copy)
+        FIXME("Incomplete last row of matrix for non direct copy constant, parameter %s.\n",
+                debugstr_a(param->name));
 
     if (FAILED(hr = append_const_set(const_tab, &const_set)))
         return hr;
-- 
2.9.4




More information about the wine-patches mailing list