Skip to content

Commit

Permalink
[svn] Simplified and corrected source arg swizzle.
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
icculus committed Mar 17, 2008
1 parent e930f46 commit c76f4b4
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions d3d2glsl.c
Expand Up @@ -253,6 +253,7 @@ struct Context
uint32 minor_ver;
DestArgInfo dest_args[1];
SourceArgInfo source_args[4];
uint32 instruction_count;
};


Expand Down Expand Up @@ -604,20 +605,14 @@ static char *make_D3D_sourcearg_string(Context *ctx, const int idx)
{
static const char channel[] = { 'x', 'y', 'z', 'w' };
swizzle_str[i++] = '.';

if ( (arg->swizzle_x == arg->swizzle_y) &&
(arg->swizzle_x == arg->swizzle_z) &&
(arg->swizzle_x == arg->swizzle_w) )
{
swizzle_str[i++] = channel[arg->swizzle_x]; // syntactic sugar.
} // if
else
{
swizzle_str[i++] = channel[arg->swizzle_x];
swizzle_str[i++] = channel[arg->swizzle_y];
swizzle_str[i++] = channel[arg->swizzle_z];
swizzle_str[i++] = channel[arg->swizzle_w];
} // else
swizzle_str[i++] = channel[arg->swizzle_x];
swizzle_str[i++] = channel[arg->swizzle_y];
swizzle_str[i++] = channel[arg->swizzle_z];
swizzle_str[i++] = channel[arg->swizzle_w];

// .xyzz is the same as .xyz, .z is the same as .zzzz, etc.
while (swizzle_str[i-1] == swizzle_str[i-2])
i--;
} // if
swizzle_str[i] = '\0';
assert(i < sizeof (swizzle_str));
Expand Down Expand Up @@ -1705,6 +1700,8 @@ static int parse_instruction_token(Context *ctx)
} // else if
} // if

ctx->instruction_count++;

// Update the context with instruction's arguments.
ctx->tokens++;
ctx->tokencount--;
Expand Down

0 comments on commit c76f4b4

Please sign in to comment.