From 6f66c1ddbd1d53589b0bf587bc23d57838652b25 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 7 Apr 2009 11:09:11 +0200 Subject: [PATCH] wined3d: Store the write mask in struct wined3d_shader_dst_param. --- dlls/wined3d/arb_program_shader.c | 8 ++++---- dlls/wined3d/baseshader.c | 1 + dlls/wined3d/glsl_shader.c | 12 +++++++----- dlls/wined3d/wined3d_private.h | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 794f1e32353..42af7558395 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -688,7 +688,7 @@ static void shader_hw_sample(const struct wined3d_shader_instruction *ins, DWORD if (shader_is_pshader_version(ins->reg_maps->shader_version)) { IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)ins->shader; - gen_color_correction(buffer, dst_str, ins->dst[0].token & WINED3DSP_WRITEMASK_ALL, + gen_color_correction(buffer, dst_str, ins->dst[0].write_mask, "one", "coefmul.x", ps->cur_args->color_fixup[sampler_idx]); } } @@ -1584,10 +1584,10 @@ static void shader_hw_mnxn(const struct wined3d_shader_instruction *ins) break; } + tmp_dst = ins->dst[0]; for (i = 0; i < nComponents; i++) { - tmp_dst.register_idx = ins->dst[0].register_idx; - tmp_dst.modifiers = ins->dst[0].modifiers; - tmp_dst.token = ((ins->dst[0].token) & ~WINED3DSP_WRITEMASK_ALL) | (WINED3DSP_WRITEMASK_0 << i); + tmp_dst.write_mask = WINED3DSP_WRITEMASK_0 << i; + tmp_dst.token = (tmp_dst.token & ~WINED3DSP_WRITEMASK_ALL) | tmp_dst.write_mask; tmp_ins.src[1] = ins->src[1]+i; shader_hw_map2gl(&tmp_ins); } diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c index ed6c069456e..db3ab1ef6eb 100644 --- a/dlls/wined3d/baseshader.c +++ b/dlls/wined3d/baseshader.c @@ -851,6 +851,7 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer, dst_param.addr_token = 0; pToken += shader_get_param(pToken, shader_version, &dst_param.token, &dst_param.addr_token); dst_param.register_idx = dst_param.token & WINED3DSP_REGNUM_MASK; + dst_param.write_mask = dst_param.token & WINED3DSP_WRITEMASK_ALL; dst_param.modifiers = dst_param.token & WINED3DSP_DSTMOD_MASK; } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index e18224dea5d..7c0ea51d999 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1446,7 +1446,7 @@ static void shader_glsl_color_correction(const struct wined3d_shader_instruction if (fixup.y_sign_fixup || fixup.y_source != CHANNEL_SOURCE_Y) mask |= WINED3DSP_WRITEMASK_1; if (fixup.z_sign_fixup || fixup.z_source != CHANNEL_SOURCE_Z) mask |= WINED3DSP_WRITEMASK_2; if (fixup.w_sign_fixup || fixup.w_source != CHANNEL_SOURCE_W) mask |= WINED3DSP_WRITEMASK_3; - mask &= ins->dst[0].token; + mask &= ins->dst[0].write_mask; if (!mask) return; /* Nothing to do */ @@ -1509,7 +1509,7 @@ static void PRINTF_ATTR(6, 7) shader_glsl_gen_sample_code(const struct wined3d_s BOOL rect_fixup = FALSE; va_list args; - shader_glsl_get_swizzle(swizzle, FALSE, ins->dst[0].token, dst_swizzle); + shader_glsl_get_swizzle(swizzle, FALSE, ins->dst[0].write_mask, dst_swizzle); if (shader_is_pshader_version(ins->reg_maps->shader_version)) { @@ -1947,6 +1947,7 @@ static void shader_glsl_cmp(const struct wined3d_shader_instruction *ins) temp_destination = TRUE; } else { struct wined3d_shader_dst_param dst = ins->dst[0]; + dst.write_mask &= write_mask; dst.token &= ~WINED3DSP_WRITEMASK_ALL | write_mask; write_mask = shader_glsl_append_dst_ext(ins->buffer, ins, &dst); if (!write_mask) continue; @@ -2010,6 +2011,7 @@ static void shader_glsl_cnd(const struct wined3d_shader_instruction *ins) } } dst = ins->dst[0]; + dst.write_mask &= write_mask; dst.token &= ~WINED3DSP_WRITEMASK_ALL | write_mask; write_mask = shader_glsl_append_dst_ext(ins->buffer, ins, &dst); if (!write_mask) continue; @@ -2087,11 +2089,11 @@ static void shader_glsl_mnxn(const struct wined3d_shader_instruction *ins) break; } + tmp_dst = ins->dst[0]; for (i = 0; i < nComponents; ++i) { - tmp_dst.register_idx = ins->dst[0].register_idx; - tmp_dst.modifiers = ins->dst[0].modifiers; - tmp_dst.token = ((ins->dst[0].token) & ~WINED3DSP_WRITEMASK_ALL) | (WINED3DSP_WRITEMASK_0 << i); + tmp_dst.write_mask = WINED3DSP_WRITEMASK_0 << i; + tmp_dst.token = (tmp_dst.token & ~WINED3DSP_WRITEMASK_ALL) | tmp_dst.write_mask; tmp_ins.src[1] = ins->src[1] + i; shader_glsl_dot(&tmp_ins); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ff03d3d788e..ccc681f0c7d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -453,6 +453,7 @@ typedef struct SHADER_OPCODE struct wined3d_shader_dst_param { UINT register_idx; + DWORD write_mask; DWORD modifiers; DWORD token; DWORD addr_token;