Henri Verbeet : wined3d: Store the source swizzle in struct wined3d_shader_src_param.

Alexandre Julliard julliard at winehq.org
Tue Apr 21 11:45:45 CDT 2009


Module: wine
Branch: master
Commit: db5ab97125396de5723ef2941b811f76913aa4de
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=db5ab97125396de5723ef2941b811f76913aa4de

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Tue Apr 21 09:35:05 2009 +0200

wined3d: Store the source swizzle in struct wined3d_shader_src_param.

---

 dlls/wined3d/arb_program_shader.c |    8 ++++----
 dlls/wined3d/baseshader.c         |    1 +
 dlls/wined3d/glsl_shader.c        |    8 ++++----
 dlls/wined3d/wined3d_private.h    |    1 +
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 9cd8d64..6648c61 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -1075,9 +1075,9 @@ static void shader_hw_mov(const struct wined3d_shader_instruction *ins)
              * with more than one component. Thus replicate the first source argument over all
              * 4 components. For example, .xyzw -> .x (or better: .xxxx), .zwxy -> .z, etc) */
             struct wined3d_shader_src_param tmp_src = ins->src[0];
-            tmp_src.token &= ~WINED3DSP_SWIZZLE_MASK;
-            tmp_src.token |= ((ins->src[0].token >> WINED3DSP_SWIZZLE_SHIFT) & 0x3)
+            tmp_src.swizzle = ((ins->src[0].swizzle >> WINED3DSP_SWIZZLE_SHIFT) & 0x3)
                     * (0x55 << WINED3DSP_SWIZZLE_SHIFT);
+            tmp_src.token = (tmp_src.token & ~WINED3DSP_SWIZZLE_MASK) | tmp_src.swizzle;
             shader_arb_add_src_param(ins, &tmp_src, src0_param);
             shader_addline(buffer, "ARL A0.x, %s;\n", src0_param);
         }
@@ -1633,7 +1633,6 @@ static void shader_hw_mnxn(const struct wined3d_shader_instruction *ins)
 static void vshader_hw_rsq_rcp(const struct wined3d_shader_instruction *ins)
 {
     SHADER_BUFFER *buffer = ins->ctx->buffer;
-    DWORD swizzle = (ins->src[0].token & WINED3DSP_SWIZZLE_MASK) >> WINED3DSP_SWIZZLE_SHIFT;
     const char *instruction;
 
     char tmpLine[256];
@@ -1651,7 +1650,8 @@ static void vshader_hw_rsq_rcp(const struct wined3d_shader_instruction *ins)
     shader_arb_add_dst_param(ins, &ins->dst[0], tmpLine); /* Destination */
     strcat(tmpLine, ",");
     shader_arb_add_src_param(ins, &ins->src[0], tmpLine);
-    if ((WINED3DSP_NOSWIZZLE >> WINED3DSP_SWIZZLE_SHIFT) == swizzle) {
+    if (ins->src[0].swizzle == WINED3DSP_NOSWIZZLE)
+    {
         /* Dx sdk says .x is used if no swizzle is given, but our test shows that
          * .w is used
          */
diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c
index 0d41fdc..05cbe9e 100644
--- a/dlls/wined3d/baseshader.c
+++ b/dlls/wined3d/baseshader.c
@@ -245,6 +245,7 @@ static void shader_parse_src_param(DWORD param, const struct wined3d_shader_src_
     src->register_type = ((param & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT)
             | ((param & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2);
     src->register_idx = param & WINED3DSP_REGNUM_MASK;
+    src->swizzle = param & WINED3DSP_SWIZZLE_MASK;
     src->modifiers = param & WINED3DSP_SRCMOD_MASK;
     src->rel_addr = rel_addr;
     src->token = param;
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index f9d63cf..a0b8c60 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -1946,7 +1946,7 @@ static void shader_glsl_cmp(const struct wined3d_shader_instruction *ins)
             write_mask = 0;
             /* Find the destination channels which use the current source0 channel */
             for (j=0; j<4; j++) {
-                if (((ins->src[0].token >> (WINED3DSP_SWIZZLE_SHIFT + 2 * j)) & 0x3) == i)
+                if (((ins->src[0].swizzle >> (WINED3DSP_SWIZZLE_SHIFT + 2 * j)) & 0x3) == i)
                 {
                     write_mask |= WINED3DSP_WRITEMASK_0 << j;
                     cmp_channel = WINED3DSP_WRITEMASK_0 << j;
@@ -2028,7 +2028,7 @@ static void shader_glsl_cnd(const struct wined3d_shader_instruction *ins)
         write_mask = 0;
         /* Find the destination channels which use the current source0 channel */
         for (j=0; j<4; j++) {
-            if (((ins->src[0].token >> (WINED3DSP_SWIZZLE_SHIFT + 2 * j)) & 0x3) == i)
+            if (((ins->src[0].swizzle >> (WINED3DSP_SWIZZLE_SHIFT + 2 * j)) & 0x3) == i)
             {
                 write_mask |= WINED3DSP_WRITEMASK_0 << j;
                 cmp_channel = WINED3DSP_WRITEMASK_0 << j;
@@ -2469,7 +2469,7 @@ static void pshader_glsl_tex(const struct wined3d_shader_instruction *ins)
     mask |= sample_function.coord_mask;
 
     if (shader_version < WINED3DPS_VERSION(2,0)) swizzle = WINED3DVS_NOSWIZZLE;
-    else swizzle = ins->src[1].token & WINED3DSP_SWIZZLE_MASK;
+    else swizzle = ins->src[1].swizzle;
 
     /* 1.0-1.3: Use destination register as coordinate source.
        1.4+: Use provided coordinate source register. */
@@ -2504,7 +2504,7 @@ static void shader_glsl_texldl(const struct wined3d_shader_instruction *ins)
     DWORD sample_flags = WINED3D_GLSL_SAMPLE_LOD;
     DWORD sampler_type;
     DWORD sampler_idx;
-    DWORD swizzle = ins->src[1].token & WINED3DSP_SWIZZLE_MASK;
+    DWORD swizzle = ins->src[1].swizzle;
 
     sampler_idx = ins->src[1].register_idx;
     sampler_type = ins->ctx->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 09f7821..b7bf220 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -465,6 +465,7 @@ struct wined3d_shader_src_param
 {
     WINED3DSHADER_PARAM_REGISTER_TYPE register_type;
     UINT register_idx;
+    DWORD swizzle;
     DWORD modifiers;
     const struct wined3d_shader_src_param *rel_addr;
     DWORD token;




More information about the wine-cvs mailing list