From 6cefc5fa6c7c55050ee0daf43b654440086fb0e2 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 30 May 2017 12:38:29 +0300 Subject: [PATCH] d3dx9: Factor out table_type_from_param_type() function. Signed-off-by: Paul Gofman Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- 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 8bb2217c2ac..e2bd26ba1f0 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) -- 2.11.4.GIT