From ffb72392b4cedfd0ca6d7cb8aae644d32beeb6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Tue, 18 Jul 2017 00:17:17 +0200 Subject: [PATCH] wined3d: Translate bfi, ubfe, ibfe instructions more carefully. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes sure that we do not overwrite source parameters for consecutive GLSL function calls when the instruction is translated into multiple lines. Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/wined3d/glsl_shader.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 650f8adcffb..ac4dfdaf889 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -4122,6 +4122,8 @@ static void shader_glsl_bitwise_op(const struct wined3d_shader_instruction *ins) struct wined3d_shader_dst_param dst; struct glsl_src_param src[4]; const char *instruction; + BOOL tmp_dst = FALSE; + char mask_char[6]; unsigned int i, j; DWORD write_mask; @@ -4135,12 +4137,21 @@ static void shader_glsl_bitwise_op(const struct wined3d_shader_instruction *ins) return; } + for (i = 0; i < ins->src_count; ++i) + { + if (ins->dst[0].reg.idx[0].offset == ins->src[i].reg.idx[0].offset + && ins->dst[0].reg.type == ins->src[i].reg.type) + tmp_dst = TRUE; + } + dst = ins->dst[0]; for (i = 0; i < 4; ++i) { dst.write_mask = ins->dst[0].write_mask & (WINED3DSP_WRITEMASK_0 << i); - if (!(write_mask = shader_glsl_append_dst_ext(ins->ctx->buffer, ins, - &dst, dst.reg.data_type))) + if (tmp_dst && (write_mask = shader_glsl_get_write_mask(&dst, mask_char))) + shader_addline(buffer, "tmp0%s = %sBitsToFloat(", mask_char, + dst.reg.data_type == WINED3D_DATA_INT ? "int" : "uint"); + else if (!(write_mask = shader_glsl_append_dst_ext(buffer, ins, &dst, dst.reg.data_type))) continue; for (j = 0; j < ins->src_count; ++j) @@ -4150,6 +4161,13 @@ static void shader_glsl_bitwise_op(const struct wined3d_shader_instruction *ins) shader_addline(buffer, "%s, ", src[ins->src_count - j - 1].param_str); shader_addline(buffer, "%s & 0x1f, %s & 0x1f));\n", src[1].param_str, src[0].param_str); } + + if (tmp_dst) + { + shader_glsl_append_dst_ext(buffer, ins, &ins->dst[0], WINED3D_DATA_FLOAT); + shader_glsl_get_write_mask(&ins->dst[0], mask_char); + shader_addline(buffer, "tmp0%s);\n", mask_char); + } } static void shader_glsl_nop(const struct wined3d_shader_instruction *ins) {} @@ -4400,7 +4418,7 @@ static void shader_glsl_swapc(const struct wined3d_shader_instruction *ins) { shader_glsl_get_write_mask(&ins->dst[i], mask_char); shader_glsl_append_dst_ext(buffer, ins, &ins->dst[i], ins->dst[i].reg.data_type); - shader_addline(ins->ctx->buffer, "tmp%u%s);\n", i, mask_char); + shader_addline(buffer, "tmp%u%s);\n", i, mask_char); } } }