wined3d: Store the source and destination parameter count in struct wined3d_shader_instruction.

Henri Verbeet hverbeet at codeweavers.com
Thu Apr 2 03:41:00 CDT 2009


---
 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 bf0c114..a30041e 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<<i);
         tmp_ins.src[1] = ins->src[1]+i;
diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c
index a8fe8c3..71c5420 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, &param, &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, &param, &addr_token);
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 615b90e..72c07ea 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 f557509..fe71327 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 *);
-- 
1.6.0.6



--------------020401010406090000000508--



More information about the wine-patches mailing list