Henri Verbeet : wined3d: Handle the swizzle shift in the frontend rather than the backend.
Alexandre Julliard
julliard at winehq.org
Wed Apr 22 10:18:49 CDT 2009
Module: wine
Branch: master
Commit: fec1fa93cf3ed240781f2479f641f1731777db96
URL: http://source.winehq.org/git/wine.git/?a=commit;h=fec1fa93cf3ed240781f2479f641f1731777db96
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Wed Apr 22 10:48:34 2009 +0200
wined3d: Handle the swizzle shift in the frontend rather than the backend.
---
dlls/wined3d/arb_program_shader.c | 8 ++++----
dlls/wined3d/baseshader.c | 6 +++---
dlls/wined3d/glsl_shader.c | 13 ++++++-------
dlls/wined3d/wined3d_private_types.h | 4 +---
4 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 5a77f44..9b56958 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -436,7 +436,7 @@ static void shader_arb_get_swizzle(const struct wined3d_shader_src_param *param,
char *ptr = swizzle_str;
/* swizzle bits fields: wwzzyyxx */
- DWORD swizzle = param->swizzle >> WINED3DSP_SWIZZLE_SHIFT;
+ DWORD swizzle = param->swizzle;
DWORD swizzle_x = swizzle & 0x03;
DWORD swizzle_y = (swizzle >> 2) & 0x03;
DWORD swizzle_z = (swizzle >> 4) & 0x03;
@@ -444,7 +444,8 @@ static void shader_arb_get_swizzle(const struct wined3d_shader_src_param *param,
/* If the swizzle is the default swizzle (ie, "xyzw"), we don't need to
* generate a swizzle string. Unless we need to our own swizzling. */
- if ((WINED3DSP_NOSWIZZLE >> WINED3DSP_SWIZZLE_SHIFT) != swizzle || fixup) {
+ if (swizzle != WINED3DSP_NOSWIZZLE || fixup)
+ {
*ptr++ = '.';
if (swizzle_x == swizzle_y && swizzle_x == swizzle_z && swizzle_x == swizzle_w) {
*ptr++ = swizzle_chars[swizzle_x];
@@ -1076,8 +1077,7 @@ 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.swizzle = ((ins->src[0].swizzle >> WINED3DSP_SWIZZLE_SHIFT) & 0x3)
- * (0x55 << WINED3DSP_SWIZZLE_SHIFT);
+ tmp_src.swizzle = (tmp_src.swizzle & 0x3) * 0x55;
shader_arb_add_src_param(ins, &tmp_src, src0_param);
shader_addline(buffer, "ARL A0.x, %s;\n", src0_param);
}
diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c
index 5145a41..d3e0e1e 100644
--- a/dlls/wined3d/baseshader.c
+++ b/dlls/wined3d/baseshader.c
@@ -147,7 +147,7 @@ static int shader_get_param(const DWORD *pToken, DWORD shader_version, DWORD *pa
*addr_token = (1 << 31)
| ((WINED3DSPR_ADDR << WINED3DSP_REGTYPE_SHIFT2) & WINED3DSP_REGTYPE_MASK2)
| ((WINED3DSPR_ADDR << WINED3DSP_REGTYPE_SHIFT) & WINED3DSP_REGTYPE_MASK)
- | WINED3DSP_NOSWIZZLE;
+ | (WINED3DSP_NOSWIZZLE << WINED3DSP_SWIZZLE_SHIFT);
}
else
{
@@ -245,7 +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->swizzle = (param & WINED3DSP_SWIZZLE_MASK) >> WINED3DSP_SWIZZLE_SHIFT;
src->modifiers = param & WINED3DSP_SRCMOD_MASK;
src->rel_addr = rel_addr;
}
@@ -789,7 +789,7 @@ static void shader_dump_param(const DWORD param, const DWORD addr_token, int inp
* swizzle bits fields:
* RRGGBBAA
*/
- if ((WINED3DSP_NOSWIZZLE >> WINED3DSP_SWIZZLE_SHIFT) != swizzle)
+ if (swizzle != WINED3DSP_NOSWIZZLE)
{
if (swizzle_x == swizzle_y &&
swizzle_x == swizzle_z &&
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index da30432..dcb0763 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -1246,14 +1246,13 @@ static void shader_glsl_swizzle_to_str(const DWORD swizzle, BOOL fixup, DWORD ma
* but addressed as "rgba". To fix this we need to swap the register's x
* and z components. */
const char *swizzle_chars = fixup ? "zyxw" : "xyzw";
- DWORD s = swizzle >> WINED3DSP_SWIZZLE_SHIFT;
*str++ = '.';
/* swizzle bits fields: wwzzyyxx */
- if (mask & WINED3DSP_WRITEMASK_0) *str++ = swizzle_chars[s & 0x03];
- if (mask & WINED3DSP_WRITEMASK_1) *str++ = swizzle_chars[(s >> 2) & 0x03];
- if (mask & WINED3DSP_WRITEMASK_2) *str++ = swizzle_chars[(s >> 4) & 0x03];
- if (mask & WINED3DSP_WRITEMASK_3) *str++ = swizzle_chars[(s >> 6) & 0x03];
+ if (mask & WINED3DSP_WRITEMASK_0) *str++ = swizzle_chars[swizzle & 0x03];
+ if (mask & WINED3DSP_WRITEMASK_1) *str++ = swizzle_chars[(swizzle >> 2) & 0x03];
+ if (mask & WINED3DSP_WRITEMASK_2) *str++ = swizzle_chars[(swizzle >> 4) & 0x03];
+ if (mask & WINED3DSP_WRITEMASK_3) *str++ = swizzle_chars[(swizzle >> 6) & 0x03];
*str = '\0';
}
@@ -1951,7 +1950,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].swizzle >> (WINED3DSP_SWIZZLE_SHIFT + 2 * j)) & 0x3) == i)
+ if (((ins->src[0].swizzle >> (2 * j)) & 0x3) == i)
{
write_mask |= WINED3DSP_WRITEMASK_0 << j;
cmp_channel = WINED3DSP_WRITEMASK_0 << j;
@@ -2033,7 +2032,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].swizzle >> (WINED3DSP_SWIZZLE_SHIFT + 2 * j)) & 0x3) == i)
+ if (((ins->src[0].swizzle >> (2 * j)) & 0x3) == i)
{
write_mask |= WINED3DSP_WRITEMASK_0 << j;
cmp_channel = WINED3DSP_WRITEMASK_0 << j;
diff --git a/dlls/wined3d/wined3d_private_types.h b/dlls/wined3d/wined3d_private_types.h
index 42ed6c9..751cc43 100644
--- a/dlls/wined3d/wined3d_private_types.h
+++ b/dlls/wined3d/wined3d_private_types.h
@@ -101,9 +101,7 @@ typedef enum _WINED3DVS_RASTOUT_OFFSETS {
#define WINED3DSP_SWIZZLE_SHIFT 16
#define WINED3DSP_SWIZZLE_MASK (0xFF << WINED3DSP_SWIZZLE_SHIFT)
-#define WINED3DSP_NOSWIZZLE \
- ((0 << (WINED3DSP_SWIZZLE_SHIFT + 0)) | (1 << (WINED3DSP_SWIZZLE_SHIFT + 2)) | \
- (2 << (WINED3DSP_SWIZZLE_SHIFT + 4)) | (3 << (WINED3DSP_SWIZZLE_SHIFT + 6)))
+#define WINED3DSP_NOSWIZZLE (0 | (1 << 2) | (2 << 4) | (3 << 6))
#define WINED3DSP_SRCMOD_SHIFT 24
#define WINED3DSP_SRCMOD_MASK (0xF << WINED3DSP_SRCMOD_SHIFT)
More information about the wine-cvs
mailing list