wined3d: Simplify the generated GLSL for NRM.

This commit is contained in:
Henri Verbeet 2010-03-19 13:19:50 +01:00 committed by Alexandre Julliard
parent 62981582dd
commit 4cd69b8a09
1 changed files with 12 additions and 2 deletions

View File

@ -2164,16 +2164,26 @@ static void shader_glsl_nrm(const struct wined3d_shader_instruction *ins)
{
struct wined3d_shader_buffer *buffer = ins->ctx->buffer;
glsl_src_param_t src_param;
unsigned int mask_size;
DWORD write_mask;
char dst_mask[6];
write_mask = shader_glsl_get_write_mask(ins->dst, dst_mask);
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_glsl_append_dst(buffer, ins);
shader_addline(buffer, "tmp0.x == 0.0 ? (%s * FLT_MAX) : (%s / tmp0.x));",
src_param.param_str, src_param.param_str);
if (mask_size > 1)
{
shader_addline(buffer, "tmp0.x == 0.0 ? vec%u(0.0) : (%s / tmp0.x));\n",
mask_size, src_param.param_str);
}
else
{
shader_addline(buffer, "tmp0.x == 0.0 ? 0.0 : (%s / tmp0.x));\n",
src_param.param_str);
}
}
/** Process the WINED3DSIO_EXPP instruction in GLSL: