d3dx9: Move referenced_param definition from d3dx_parameter to d3dx_state.
Signed-off-by: Paul Gofman <gofmanp@gmail.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f09bf52d5d
commit
3a10679b7a
|
@ -306,11 +306,7 @@ struct d3dx_parameter
|
||||||
struct d3dx_param_eval *param_eval;
|
struct d3dx_param_eval *param_eval;
|
||||||
|
|
||||||
struct d3dx_parameter *top_level_param;
|
struct d3dx_parameter *top_level_param;
|
||||||
union
|
struct d3dx_shared_data *shared_data;
|
||||||
{
|
|
||||||
struct d3dx_parameter *referenced_param;
|
|
||||||
struct d3dx_shared_data *shared_data;
|
|
||||||
} u;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct d3dx_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;
|
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;
|
return update_version < shared_data->update_version;
|
||||||
else
|
else
|
||||||
return update_version < param->top_level_param->update_version;
|
return update_version < param->top_level_param->update_version;
|
||||||
|
|
|
@ -111,6 +111,7 @@ struct d3dx_state
|
||||||
UINT index;
|
UINT index;
|
||||||
enum STATE_TYPE type;
|
enum STATE_TYPE type;
|
||||||
struct d3dx_parameter parameter;
|
struct d3dx_parameter parameter;
|
||||||
|
struct d3dx_parameter *referenced_param;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct d3dx_sampler
|
struct d3dx_sampler
|
||||||
|
@ -1030,7 +1031,7 @@ static HRESULT d3dx9_get_param_value_ptr(struct d3dx_pass *pass, struct d3dx_sta
|
||||||
switch (state->type)
|
switch (state->type)
|
||||||
{
|
{
|
||||||
case ST_PARAMETER:
|
case ST_PARAMETER:
|
||||||
param = param->u.referenced_param;
|
param = state->referenced_param;
|
||||||
*param_dirty = is_param_dirty(param, pass->update_version);
|
*param_dirty = is_param_dirty(param, pass->update_version);
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case ST_CONSTANT:
|
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;
|
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,
|
TRACE("Array index %u, stored array index %u, element_count %u.\n", array_idx, state->index,
|
||||||
ref_param->element_count);
|
ref_param->element_count);
|
||||||
/* According to the tests, native d3dx handles the case of array index evaluated to -1
|
/* 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;
|
struct d3dx_parameter *top_param = param->top_level_param;
|
||||||
ULONG64 new_update_version = next_update_version(top_param->version_counter);
|
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;
|
shared_data->update_version = new_update_version;
|
||||||
else
|
else
|
||||||
top_param->update_version = new_update_version;
|
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 (j = 0; j < pool->size; ++j)
|
||||||
for (k = 0; k < new_alloc[j].count; ++k)
|
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;
|
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;
|
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;
|
pool->shared_data[i].parameters[new_count - 1] = param;
|
||||||
|
|
||||||
TRACE("name %s, parameter idx %u, new refcount %u.\n", param->name, i,
|
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;
|
unsigned int new_count;
|
||||||
|
|
||||||
if (!(param->flags & PARAMETER_FLAG_SHARED) || !param->u.shared_data)
|
if (!(param->flags & PARAMETER_FLAG_SHARED) || !param->shared_data)
|
||||||
return;
|
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)
|
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)
|
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],
|
memmove(¶m->shared_data->parameters[i],
|
||||||
¶m->u.shared_data->parameters[i + 1],
|
¶m->shared_data->parameters[i + 1],
|
||||||
sizeof(param->u.shared_data->parameters[i]) * (new_count - i));
|
sizeof(param->shared_data->parameters[i]) * (new_count - i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3289,10 +3290,10 @@ static void d3dx_pool_release_shared_parameter(struct d3dx_parameter *param)
|
||||||
}
|
}
|
||||||
else
|
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. */
|
/* Zeroing table size is required as the entry in pool parameters table can be reused. */
|
||||||
param->u.shared_data->size = 0;
|
param->shared_data->size = 0;
|
||||||
param->u.shared_data = NULL;
|
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)
|
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 TRUE;
|
||||||
}
|
}
|
||||||
return walk_param_eval_dep(state->parameter.param_eval, param_func, data);
|
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;
|
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)
|
const char **skip_constants, unsigned int skip_constants_count)
|
||||||
{
|
{
|
||||||
DWORD string_size;
|
DWORD string_size;
|
||||||
|
struct d3dx_parameter *param = &state->parameter;
|
||||||
struct d3dx_object *object = &base->objects[param->object_id];
|
struct d3dx_object *object = &base->objects[param->object_id];
|
||||||
char *ptr = object->data;
|
char *ptr = object->data;
|
||||||
HRESULT ret;
|
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);
|
TRACE("Parsing array entry selection state for parameter %p.\n", param);
|
||||||
|
|
||||||
string_size = *(DWORD *)ptr;
|
string_size = *(DWORD *)ptr;
|
||||||
param->u.referenced_param = get_parameter_by_name(base, NULL, ptr + 4);
|
state->referenced_param = get_parameter_by_name(base, NULL, ptr + 4);
|
||||||
if (param->u.referenced_param)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -5971,7 +5973,7 @@ static HRESULT d3dx9_parse_array_selector(struct d3dx9_base_effect *base, struct
|
||||||
get_version_counter_ptr(base), NULL, 0)))
|
get_version_counter_ptr(base), NULL, 0)))
|
||||||
return ret;
|
return ret;
|
||||||
ret = D3D_OK;
|
ret = D3D_OK;
|
||||||
param = param->u.referenced_param;
|
param = state->referenced_param;
|
||||||
if (param->type == D3DXPT_VERTEXSHADER || param->type == D3DXPT_PIXELSHADER)
|
if (param->type == D3DXPT_VERTEXSHADER || param->type == D3DXPT_PIXELSHADER)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -6135,10 +6137,10 @@ static HRESULT d3dx9_parse_resource(struct d3dx9_base_effect *base, const char *
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
TRACE("Looking for parameter %s.\n", debugstr_a(object->data));
|
TRACE("Looking for parameter %s.\n", debugstr_a(object->data));
|
||||||
param->u.referenced_param = get_parameter_by_name(base, NULL, object->data);
|
state->referenced_param = get_parameter_by_name(base, NULL, object->data);
|
||||||
if (param->u.referenced_param)
|
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);
|
TRACE("Mapping to parameter %p, having object id %u.\n", refpar, refpar->object_id);
|
||||||
if (refpar->type == D3DXPT_VERTEXSHADER || refpar->type == D3DXPT_PIXELSHADER)
|
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;
|
state->type = ST_ARRAY_SELECTOR;
|
||||||
if (FAILED(hr = d3dx9_copy_data(base, param->object_id, ptr)))
|
if (FAILED(hr = d3dx9_copy_data(base, param->object_id, ptr)))
|
||||||
return hr;
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -6722,12 +6724,12 @@ static void free_effect_pool(struct d3dx_effect_pool *pool)
|
||||||
WARN("Releasing pool with referenced parameters.\n");
|
WARN("Releasing pool with referenced parameters.\n");
|
||||||
|
|
||||||
param_set_data_pointer(pool->shared_data[i].parameters[0], NULL, FALSE, TRUE);
|
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)
|
for (j = 1; j < pool->shared_data[i].count; ++j)
|
||||||
{
|
{
|
||||||
walk_parameter_tree(pool->shared_data[i].parameters[j], param_zero_data_func, NULL);
|
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);
|
HeapFree(GetProcessHeap(), 0, pool->shared_data[i].parameters);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue