From 146093af3374cbe4e176ba66ce59b980f1ac2740 Mon Sep 17 00:00:00 2001 From: "H. Verbeet" Date: Mon, 15 Jan 2007 19:33:06 +0100 Subject: [PATCH] wined3d: Rewrite shader_glsl_rcp() to properly take the write mask into account. --- dlls/wined3d/glsl_shader.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index e02483d27a..7739cd20f4 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1128,17 +1128,21 @@ void shader_glsl_expp(SHADER_OPCODE_ARG* arg) { /** Process the RCP (reciprocal or inverse) opcode in GLSL (dst = 1 / src) */ void shader_glsl_rcp(SHADER_OPCODE_ARG* arg) { + char src_str[100]; + char src_reg[50]; + char src_mask[6]; + DWORD write_mask; + size_t mask_size; - char tmpLine[256]; - char dst_str[100], src_str[100]; - char dst_reg[50], src_reg[50]; - char dst_mask[6], src_mask[6]; - - shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str); - shader_glsl_add_src_param_old(arg, arg->src[0], arg->src_addr[0], src_reg, src_mask, src_str); - shader_glsl_add_dst_old(arg->dst, dst_reg, dst_mask, tmpLine); - strcat(tmpLine, "1.0 / "); - shader_addline(arg->buffer, "%s%s)%s;\n", tmpLine, src_str, dst_mask); + write_mask = shader_glsl_append_dst(arg->buffer, arg); + mask_size = shader_glsl_get_write_mask_size(write_mask); + shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], WINED3DSP_WRITEMASK_0, src_reg, src_mask, src_str); + + if (mask_size > 1) { + shader_addline(arg->buffer, "vec%d(1.0 / %s));\n", mask_size, src_str); + } else { + shader_addline(arg->buffer, "1.0 / %s);\n", src_str); + } } /** Process signed comparison opcodes in GLSL. */ -- 2.32.0.93.g670b81a890