[PATCH 3/6] d3dx9: Factor out param_type_to_table_type() function.

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


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
 dlls/d3dx9_36/preshader.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dx9_36/preshader.c b/dlls/d3dx9_36/preshader.c
index 262b7c1..bddd74f 100644
--- a/dlls/d3dx9_36/preshader.c
+++ b/dlls/d3dx9_36/preshader.c
@@ -193,7 +193,8 @@ enum pres_value_type
     PRES_VT_FLOAT,
     PRES_VT_DOUBLE,
     PRES_VT_INT,
-    PRES_VT_BOOL
+    PRES_VT_BOOL,
+    PRES_VT_MAX
 };
 
 static const struct
@@ -260,6 +261,22 @@ struct d3dx_pres_ins
     struct d3dx_pres_operand output;
 };
 
+static enum pres_value_type param_type_to_table_type(D3DXPARAMETER_TYPE type)
+{
+    switch (type)
+    {
+        case D3DXPT_FLOAT:
+            return PRES_VT_FLOAT;
+        case D3DXPT_INT:
+            return PRES_VT_INT;
+        case D3DXPT_BOOL:
+            return PRES_VT_BOOL;
+        default:
+            FIXME("Unsupported type %u.\n", type);
+            return PRES_VT_MAX;
+    }
+}
+
 static unsigned int get_reg_offset(unsigned int table, unsigned int offset)
 {
     return table == PRES_REGTAB_OBCONST ? offset : offset >> 2;
@@ -383,6 +400,9 @@ static void regstore_set_double(struct d3dx_regstore *rs, unsigned int table, un
         case PRES_VT_DOUBLE: *(double *)p = v; break;
         case PRES_VT_INT   : *(int *)p = lrint(v); break;
         case PRES_VT_BOOL  : *(BOOL *)p = !!v; break;
+        default:
+            FIXME("Bad type %u.\n", table_info[table].type);
+            break;
     }
     reg_idx = get_reg_offset(table, offset);
     rs->table_value_set[table][reg_idx / PRES_BITMASK_BLOCK_SIZE] |=
@@ -1026,9 +1046,7 @@ static void set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const
         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 == D3DXPT_FLOAT && table_type == PRES_VT_FLOAT)
-                || (param->type == D3DXPT_INT && table_type == PRES_VT_INT)
-                || (param->type == D3DXPT_BOOL && table_type == PRES_VT_BOOL))
+        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)
-- 
2.9.3




More information about the wine-patches mailing list