mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 20:59:54 +00:00
wined3d: Use dot() instead of length() in shader_glsl_nrm().
As Eric Anholt pointed out, using length() here is suboptimal. It essentially translates into "inversesqrt(dot(x, x));", but needs to handle the case of zero-length vectors, much like nrm.
This commit is contained in:
parent
010e285b88
commit
a50546e563
@ -2314,16 +2314,18 @@ static void shader_glsl_nrm(const struct wined3d_shader_instruction *ins)
|
||||
mask_size = shader_glsl_get_write_mask_size(write_mask);
|
||||
shader_glsl_add_src_param(ins, &ins->src[0], write_mask, &src_param);
|
||||
|
||||
shader_addline(buffer, "tmp0.x = length(%s);\n", src_param.param_str);
|
||||
shader_addline(buffer, "tmp0.x = dot(%s, %s);\n",
|
||||
src_param.param_str, src_param.param_str);
|
||||
shader_glsl_append_dst(buffer, ins);
|
||||
|
||||
if (mask_size > 1)
|
||||
{
|
||||
shader_addline(buffer, "tmp0.x == 0.0 ? vec%u(0.0) : (%s / tmp0.x));\n",
|
||||
shader_addline(buffer, "tmp0.x == 0.0 ? vec%u(0.0) : (%s * inversesqrt(tmp0.x)));\n",
|
||||
mask_size, src_param.param_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
shader_addline(buffer, "tmp0.x == 0.0 ? 0.0 : (%s / tmp0.x));\n",
|
||||
shader_addline(buffer, "tmp0.x == 0.0 ? 0.0 : (%s * inversesqrt(tmp0.x)));\n",
|
||||
src_param.param_str);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user