Paul Gofman : d3dx9: Factor out table_type_from_param_type() function.

Alexandre Julliard julliard at winehq.org
Thu Jun 1 18:49:36 CDT 2017


Module: wine
Branch: master
Commit: 6cefc5fa6c7c55050ee0daf43b654440086fb0e2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6cefc5fa6c7c55050ee0daf43b654440086fb0e2

Author: Paul Gofman <gofmanp at gmail.com>
Date:   Tue May 30 12:38:29 2017 +0300

d3dx9: Factor out table_type_from_param_type() function.

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 8bb2217..e2bd26b 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_COUNT
 };
 
 static const struct
@@ -269,6 +270,22 @@ struct const_upload_info
     unsigned int count;
 };
 
+static enum pres_value_type table_type_from_param_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_COUNT;
+    }
+}
+
 static unsigned int get_reg_offset(unsigned int table, unsigned int offset)
 {
     return table == PRES_REGTAB_OBCONST ? offset : offset >> 2;
@@ -392,6 +409,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] |=
@@ -1033,9 +1053,7 @@ static void set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const
         get_const_upload_info(const_set, &info);
         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 (table_type_from_param_type(param->type) == table_type
                 && !info.transpose && info.minor == info.major_stride
                 && info.count == get_offset_reg(table, const_set->register_count)
                 && info.count * sizeof(unsigned int) <= param->bytes)




More information about the wine-cvs mailing list