wined3d: Handle the swizzle shift in the frontend rather than the backend.

This commit is contained in:
Henri Verbeet 2009-04-22 10:48:34 +02:00 committed by Alexandre Julliard
parent baf2f94b76
commit fec1fa93cf
4 changed files with 14 additions and 17 deletions

View File

@ -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);
}

View File

@ -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 &&

View File

@ -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;

View File

@ -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)