- 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, TRUE);
if (FAILED(hr = execute_preshader(pres)))
return hr;
regstore_reset_table(rs, PRES_REGTAB_CONST);
- }
This is technically a separate bugfix which would be better as a separate patch, before this one.
This chunk actually avoids redundant preshader recompute. I don't quite understand how can I do it as a separate previous patch, as this patch introduce "update_all" parameter, is_const_tab_input_dirty() function and all the other logic around it. Or can it be that you were thinking of changes on light and material state update, and copy pasted different chunk?
I just meant the regstore_reset_table() part.
I am sorry, I still don't understand how it is a separate bugfix. I don't see the absence of it as a bug in previous code, reset of constants is not required as they are updated anyway. Actually regstore_reset_table() call along with ultimate TRUE for update_all parameter in set_constants() call here is redundant. I added it just to make things a bit more robuts and more robust checking of unitialized input in preshader in case of some bugs in their update logic, which got more complicated with selective constants update. It should actually work (without updating constants from unchanged parameters) if change set_constants(rs, &pres->inputs, TRUE); to set_constants(rs, &pres->inputs, update_all); and remove regstore_reset_table(). Maybe I should do it like this?