Commit cfc533b4 authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dx9: Use an assert() to validate access to const_tbl[].

This check is essentially validating that the hardcoded state_table[] has reasonable values for the shader constant states. Use ARRAY_SIZE() to avoid warnings if the compiler chooses an unsigned integer to back enum SHADER_CONSTANT_TYPE. Based on an idea by Henri Verbeet. Signed-off-by: 's avatarMatteo Bruni <mbruni@codeweavers.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent f8086a3e
...@@ -1469,11 +1469,7 @@ static HRESULT d3dx_set_shader_const_state(struct d3dx_effect *effect, enum SHAD ...@@ -1469,11 +1469,7 @@ static HRESULT d3dx_set_shader_const_state(struct d3dx_effect *effect, enum SHAD
D3DXVECTOR4 value; D3DXVECTOR4 value;
HRESULT ret; HRESULT ret;
if (op < 0 || op > SCT_PSINT) assert(op < ARRAY_SIZE(const_tbl));
{
FIXME("Unknown op %u.\n", op);
return D3DERR_INVALIDCALL;
}
element_count = param->bytes / const_tbl[op].elem_size; element_count = param->bytes / const_tbl[op].elem_size;
TRACE("%s, index %u, element_count %u.\n", const_tbl[op].name, index, element_count); TRACE("%s, index %u, element_count %u.\n", const_tbl[op].name, index, element_count);
if (param->type != const_tbl[op].type) if (param->type != const_tbl[op].type)
......
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