Commit a844ce7d authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3dx9: Don't apply unmodified states in CommitChanges().

parent f68de78d
......@@ -222,6 +222,11 @@ struct d3dx_parameter
DWORD *dirty_flag_ptr;
};
static inline BOOL is_param_dirty(struct d3dx_parameter *param)
{
return *param->dirty_flag_ptr & PARAMETER_FLAG_DIRTY;
}
struct d3dx9_base_effect;
struct d3dx_parameter *get_parameter_by_name(struct d3dx9_base_effect *base,
......@@ -231,8 +236,9 @@ void d3dx_create_param_eval(struct d3dx9_base_effect *base_effect, void *byte_co
unsigned int byte_code_size, D3DXPARAMETER_TYPE type, struct d3dx_param_eval **peval) DECLSPEC_HIDDEN;
void d3dx_free_param_eval(struct d3dx_param_eval *peval) DECLSPEC_HIDDEN;
HRESULT d3dx_evaluate_parameter(struct d3dx_param_eval *peval,
const struct d3dx_parameter *param, void *param_value) DECLSPEC_HIDDEN;
const struct d3dx_parameter *param, void *param_value, BOOL update_all) DECLSPEC_HIDDEN;
HRESULT d3dx_param_eval_set_shader_constants(struct IDirect3DDevice9 *device,
struct d3dx_param_eval *peval) DECLSPEC_HIDDEN;
struct d3dx_param_eval *peval, BOOL update_all) DECLSPEC_HIDDEN;
BOOL is_param_eval_input_dirty(struct d3dx_param_eval *peval) DECLSPEC_HIDDEN;
#endif /* __WINE_D3DX9_PRIVATE_H */
......@@ -835,7 +835,7 @@ void d3dx_free_param_eval(struct d3dx_param_eval *peval)
HeapFree(GetProcessHeap(), 0, peval);
}
static void set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const_tab)
static void set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const_tab, BOOL update_all)
{
unsigned int const_idx;
......@@ -850,6 +850,9 @@ static void set_constants(struct d3dx_regstore *rs, struct d3dx_const_tab *const
BOOL transpose;
unsigned int count;
if (!(update_all || is_param_dirty(param)))
continue;
transpose = (const_set->constant_class == D3DXPC_MATRIX_COLUMNS && param->class == D3DXPC_MATRIX_ROWS)
|| (param->class == D3DXPC_MATRIX_COLUMNS && const_set->constant_class == D3DXPC_MATRIX_ROWS);
if (const_set->constant_class == D3DXPC_MATRIX_COLUMNS)
......@@ -1148,7 +1151,26 @@ static HRESULT execute_preshader(struct d3dx_preshader *pres)
return D3D_OK;
}
HRESULT d3dx_evaluate_parameter(struct d3dx_param_eval *peval, const struct d3dx_parameter *param, void *param_value)
static BOOL is_const_tab_input_dirty(struct d3dx_const_tab *ctab)
{
unsigned int i;
for (i = 0; i < ctab->const_set_count; ++i)
{
if (is_param_dirty(ctab->const_set[i].param))
return TRUE;
}
return FALSE;
}
BOOL is_param_eval_input_dirty(struct d3dx_param_eval *peval)
{
return is_const_tab_input_dirty(&peval->pres.inputs)
|| is_const_tab_input_dirty(&peval->shader_inputs);
}
HRESULT d3dx_evaluate_parameter(struct d3dx_param_eval *peval, const struct d3dx_parameter *param,
void *param_value, BOOL update_all)
{
HRESULT hr;
unsigned int i;
......@@ -1157,7 +1179,7 @@ HRESULT d3dx_evaluate_parameter(struct d3dx_param_eval *peval, const struct d3dx
TRACE("peval %p, param %p, param_value %p.\n", peval, param, param_value);
set_constants(&peval->pres.regs, &peval->pres.inputs);
set_constants(&peval->pres.regs, &peval->pres.inputs, update_all);
if (FAILED(hr = execute_preshader(&peval->pres)))
return hr;
......@@ -1246,7 +1268,8 @@ static HRESULT set_shader_constants_device(struct IDirect3DDevice9 *device, stru
return result;
}
HRESULT d3dx_param_eval_set_shader_constants(struct IDirect3DDevice9 *device, struct d3dx_param_eval *peval)
HRESULT d3dx_param_eval_set_shader_constants(struct IDirect3DDevice9 *device, struct d3dx_param_eval *peval,
BOOL update_all)
{
static const enum pres_reg_tables set_tables[] =
{PRES_REGTAB_OCONST, PRES_REGTAB_OICONST, PRES_REGTAB_OBCONST};
......@@ -1257,11 +1280,14 @@ HRESULT d3dx_param_eval_set_shader_constants(struct IDirect3DDevice9 *device, st
TRACE("device %p, peval %p, param_type %u.\n", device, peval, peval->param_type);
set_constants(rs, &pres->inputs);
if (FAILED(hr = execute_preshader(pres)))
return hr;
if (update_all || is_const_tab_input_dirty(&pres->inputs))
{
set_constants(rs, &pres->inputs, update_all);
if (FAILED(hr = execute_preshader(pres)))
return hr;
}
set_constants(rs, &peval->shader_inputs);
set_constants(rs, &peval->shader_inputs, update_all);
result = D3D_OK;
for (i = 0; i < ARRAY_SIZE(set_tables); ++i)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment