From 7bde2792c2122704d7b89cbbe76c041461107fb9 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 2 Apr 2009 10:41:00 +0200 Subject: [PATCH] wined3d: Store the source and destination parameter count in struct wined3d_shader_instruction. --- dlls/wined3d/arb_program_shader.c | 2 ++ dlls/wined3d/baseshader.c | 6 ++++-- dlls/wined3d/glsl_shader.c | 12 +++++++----- dlls/wined3d/wined3d_private.h | 2 ++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index bf0c1147f40..a30041e6f09 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -1581,6 +1581,8 @@ static void shader_hw_mnxn(const struct wined3d_shader_instruction *ins) } tmp_ins.handler_idx = tmp_ins.opcode->handler_idx; + tmp_ins.dst_count = tmp_ins.opcode->dst_token ? 1 : 0; + tmp_ins.src_count = tmp_ins.opcode->num_params - tmp_ins.dst_count; for (i = 0; i < nComponents; i++) { tmp_ins.dst = ((ins->dst) & ~WINED3DSP_WRITEMASK_ALL)|(WINED3DSP_WRITEMASK_0<src[1]+i; diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c index a8fe8c3ec3f..71c54205d28 100644 --- a/dlls/wined3d/baseshader.c +++ b/dlls/wined3d/baseshader.c @@ -845,7 +845,8 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer, ins.coissue = opcode_token & WINED3DSI_COISSUE; /* Destination token */ - if (curOpcode->dst_token) + ins.dst_count = curOpcode->dst_token ? 1 : 0; + if (ins.dst_count) { DWORD param, addr_token = 0; pToken += shader_get_param(pToken, shader_version, ¶m, &addr_token); @@ -857,7 +858,8 @@ void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer, if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) ins.predicate = *pToken++; /* Other source tokens */ - for (i = 0; i < (curOpcode->num_params - curOpcode->dst_token); ++i) + ins.src_count = curOpcode->num_params - curOpcode->dst_token; + for (i = 0; i < ins.src_count; ++i) { DWORD param, addr_token = 0; pToken += shader_get_param(pToken, shader_version, ¶m, &addr_token); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 615b90e1756..72c07ea9b67 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -1293,7 +1293,7 @@ void shader_glsl_add_instruction_modifiers(const struct wined3d_shader_instructi { DWORD mask = ins->dst & WINED3DSP_DSTMOD_MASK; - if (ins->opcode->dst_token && mask) + if (ins->dst_count && mask) { glsl_dst_param_t dst_param; @@ -1712,7 +1712,6 @@ static void shader_glsl_log(const struct wined3d_shader_instruction *ins) /* Map the opcode 1-to-1 to the GL code (arg->dst = instruction(src0, src1, ...) */ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) { - CONST SHADER_OPCODE *curOpcode = ins->opcode; SHADER_BUFFER *buffer = ins->buffer; glsl_src_param_t src_param; const char *instruction; @@ -1741,12 +1740,13 @@ static void shader_glsl_map2gl(const struct wined3d_shader_instruction *ins) shader_addline(buffer, "%s(", instruction); - if (curOpcode->num_params > 1) + if (ins->src_count) { shader_glsl_add_src_param(ins, ins->src[0], ins->src_addr[0], write_mask, &src_param); shader_addline(buffer, "%s", src_param.param_str); - for (i = 2; i < curOpcode->num_params; ++i) { - shader_glsl_add_src_param(ins, ins->src[i-1], ins->src_addr[i-1], write_mask, &src_param); + for (i = 1; i < ins->src_count; ++i) + { + shader_glsl_add_src_param(ins, ins->src[i], ins->src_addr[i], write_mask, &src_param); shader_addline(buffer, ", %s", src_param.param_str); } } @@ -2076,6 +2076,8 @@ static void shader_glsl_mnxn(const struct wined3d_shader_instruction *ins) } tmp_ins.handler_idx = tmp_ins.opcode->handler_idx; + tmp_ins.dst_count = tmp_ins.opcode->dst_token ? 1 : 0; + tmp_ins.src_count = tmp_ins.opcode->num_params - tmp_ins.dst_count; for (i = 0; i < nComponents; ++i) { tmp_ins.dst = ((ins->dst) & ~WINED3DSP_WRITEMASK_ALL) | (WINED3DSP_WRITEMASK_0 << i); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f55750968a4..fe7132798b1 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -464,6 +464,8 @@ struct wined3d_shader_instruction DWORD src[4]; DWORD src_addr[4]; SHADER_BUFFER *buffer; + UINT dst_count; + UINT src_count; }; typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);