From 3a10679b7a0afd58d3769cd0abcfe2f95403864a Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Wed, 19 Jul 2017 16:43:06 +0300 Subject: [PATCH] d3dx9: Move referenced_param definition from d3dx_parameter to d3dx_state. Signed-off-by: Paul Gofman Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- dlls/d3dx9_36/d3dx9_private.h | 8 ++--- dlls/d3dx9_36/effect.c | 56 ++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/dlls/d3dx9_36/d3dx9_private.h b/dlls/d3dx9_36/d3dx9_private.h index bf5ad7d8365..1136d48927b 100644 --- a/dlls/d3dx9_36/d3dx9_private.h +++ b/dlls/d3dx9_36/d3dx9_private.h @@ -306,11 +306,7 @@ struct d3dx_parameter struct d3dx_param_eval *param_eval; struct d3dx_parameter *top_level_param; - union - { - struct d3dx_parameter *referenced_param; - struct d3dx_shared_data *shared_data; - } u; + struct d3dx_shared_data *shared_data; }; struct d3dx_shared_data @@ -332,7 +328,7 @@ static inline BOOL is_param_dirty(struct d3dx_parameter *param, ULONG64 update_v { struct d3dx_shared_data *shared_data; - if ((shared_data = param->top_level_param->u.shared_data)) + if ((shared_data = param->top_level_param->shared_data)) return update_version < shared_data->update_version; else return update_version < param->top_level_param->update_version; diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 48f55460777..d52301cff95 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -111,6 +111,7 @@ struct d3dx_state UINT index; enum STATE_TYPE type; struct d3dx_parameter parameter; + struct d3dx_parameter *referenced_param; }; struct d3dx_sampler @@ -1030,7 +1031,7 @@ static HRESULT d3dx9_get_param_value_ptr(struct d3dx_pass *pass, struct d3dx_sta switch (state->type) { case ST_PARAMETER: - param = param->u.referenced_param; + param = state->referenced_param; *param_dirty = is_param_dirty(param, pass->update_version); /* fallthrough */ case ST_CONSTANT: @@ -1061,7 +1062,7 @@ static HRESULT d3dx9_get_param_value_ptr(struct d3dx_pass *pass, struct d3dx_sta { array_idx = state->index; } - ref_param = param->u.referenced_param; + ref_param = state->referenced_param; TRACE("Array index %u, stored array index %u, element_count %u.\n", array_idx, state->index, ref_param->element_count); /* According to the tests, native d3dx handles the case of array index evaluated to -1 @@ -1498,7 +1499,7 @@ static void set_dirty(struct d3dx_parameter *param) struct d3dx_parameter *top_param = param->top_level_param; ULONG64 new_update_version = next_update_version(top_param->version_counter); - if ((shared_data = top_param->u.shared_data)) + if ((shared_data = top_param->shared_data)) shared_data->update_version = new_update_version; else top_param->update_version = new_update_version; @@ -3215,7 +3216,7 @@ static HRESULT d3dx_pool_sync_shared_parameter(struct d3dx_effect_pool *pool, st for (j = 0; j < pool->size; ++j) for (k = 0; k < new_alloc[j].count; ++k) - new_alloc[j].parameters[k]->u.shared_data = &new_alloc[j]; + new_alloc[j].parameters[k]->shared_data = &new_alloc[j]; } } pool->shared_data = new_alloc; @@ -3246,7 +3247,7 @@ static HRESULT d3dx_pool_sync_shared_parameter(struct d3dx_effect_pool *pool, st pool->shared_data[i].size = new_size; } - param->u.shared_data = &pool->shared_data[i]; + param->shared_data = &pool->shared_data[i]; pool->shared_data[i].parameters[new_count - 1] = param; TRACE("name %s, parameter idx %u, new refcount %u.\n", param->name, i, @@ -3265,11 +3266,11 @@ static void d3dx_pool_release_shared_parameter(struct d3dx_parameter *param) { unsigned int new_count; - if (!(param->flags & PARAMETER_FLAG_SHARED) || !param->u.shared_data) + if (!(param->flags & PARAMETER_FLAG_SHARED) || !param->shared_data) return; - new_count = --param->u.shared_data->count; + new_count = --param->shared_data->count; - TRACE("param %p, param->u.shared_data %p, new_count %d.\n", param, param->u.shared_data, new_count); + TRACE("param %p, param->shared_data %p, new_count %d.\n", param, param->shared_data, new_count); if (new_count) { @@ -3277,11 +3278,11 @@ static void d3dx_pool_release_shared_parameter(struct d3dx_parameter *param) for (i = 0; i < new_count; ++i) { - if (param->u.shared_data->parameters[i] == param) + if (param->shared_data->parameters[i] == param) { - memmove(¶m->u.shared_data->parameters[i], - ¶m->u.shared_data->parameters[i + 1], - sizeof(param->u.shared_data->parameters[i]) * (new_count - i)); + memmove(¶m->shared_data->parameters[i], + ¶m->shared_data->parameters[i + 1], + sizeof(param->shared_data->parameters[i]) * (new_count - i)); break; } } @@ -3289,10 +3290,10 @@ static void d3dx_pool_release_shared_parameter(struct d3dx_parameter *param) } else { - HeapFree(GetProcessHeap(), 0, param->u.shared_data->parameters); + HeapFree(GetProcessHeap(), 0, param->shared_data->parameters); /* Zeroing table size is required as the entry in pool parameters table can be reused. */ - param->u.shared_data->size = 0; - param->u.shared_data = NULL; + param->shared_data->size = 0; + param->shared_data = NULL; } } @@ -3982,7 +3983,7 @@ static BOOL walk_state_dep(struct d3dx_state *state, walk_parameter_dep_func par } else if (state->type == ST_ARRAY_SELECTOR || state->type == ST_PARAMETER) { - if (walk_parameter_dep(state->parameter.u.referenced_param, param_func, data)) + if (walk_parameter_dep(state->referenced_param, param_func, data)) return TRUE; } return walk_param_eval_dep(state->parameter.param_eval, param_func, data); @@ -5941,10 +5942,11 @@ static HRESULT d3dx9_create_object(struct d3dx9_base_effect *base, struct d3dx_o return D3D_OK; } -static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct d3dx_parameter *param, +static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct d3dx_state *state, const char **skip_constants, unsigned int skip_constants_count) { DWORD string_size; + struct d3dx_parameter *param = &state->parameter; struct d3dx_object *object = &base->objects[param->object_id]; char *ptr = object->data; HRESULT ret; @@ -5952,10 +5954,10 @@ static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct TRACE("Parsing array entry selection state for parameter %p.\n", param); string_size = *(DWORD *)ptr; - param->u.referenced_param = get_parameter_by_name(base, NULL, ptr + 4); - if (param->u.referenced_param) + state->referenced_param = get_parameter_by_name(base, NULL, ptr + 4); + if (state->referenced_param) { - TRACE("Mapping to parameter %s.\n", debugstr_a(param->u.referenced_param->name)); + TRACE("Mapping to parameter %s.\n", debugstr_a(state->referenced_param->name)); } else { @@ -5971,7 +5973,7 @@ static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct get_version_counter_ptr(base), NULL, 0))) return ret; ret = D3D_OK; - param = param->u.referenced_param; + param = state->referenced_param; if (param->type == D3DXPT_VERTEXSHADER || param->type == D3DXPT_PIXELSHADER) { unsigned int i; @@ -6135,10 +6137,10 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char * return hr; TRACE("Looking for parameter %s.\n", debugstr_a(object->data)); - param->u.referenced_param = get_parameter_by_name(base, NULL, object->data); - if (param->u.referenced_param) + state->referenced_param = get_parameter_by_name(base, NULL, object->data); + if (state->referenced_param) { - struct d3dx_parameter *refpar = param->u.referenced_param; + struct d3dx_parameter *refpar = state->referenced_param; TRACE("Mapping to parameter %p, having object id %u.\n", refpar, refpar->object_id); if (refpar->type == D3DXPT_VERTEXSHADER || refpar->type == D3DXPT_PIXELSHADER) @@ -6165,7 +6167,7 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char * state->type = ST_ARRAY_SELECTOR; if (FAILED(hr = d3dx9_copy_data(base, param->object_id, ptr))) return hr; - hr = d3dx9_parse_array_selector(base, param, skip_constants, skip_constants_count); + hr = d3dx9_parse_array_selector(base, state, skip_constants, skip_constants_count); break; default: @@ -6722,12 +6724,12 @@ static void free_effect_pool(struct d3dx_effect_pool *pool) WARN("Releasing pool with referenced parameters.\n"); param_set_data_pointer(pool->shared_data[i].parameters[0], NULL, FALSE, TRUE); - pool->shared_data[i].parameters[0]->u.shared_data = NULL; + pool->shared_data[i].parameters[0]->shared_data = NULL; for (j = 1; j < pool->shared_data[i].count; ++j) { walk_parameter_tree(pool->shared_data[i].parameters[j], param_zero_data_func, NULL); - pool->shared_data[i].parameters[j]->u.shared_data = NULL; + pool->shared_data[i].parameters[j]->shared_data = NULL; } HeapFree(GetProcessHeap(), 0, pool->shared_data[i].parameters); }