Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed GLSL source register swizzles. Kinda scary that never got caugh…
…t before.
  • Loading branch information
icculus committed Apr 6, 2010
1 parent 1b9f926 commit 171d575
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mojoshader.c
Expand Up @@ -1864,21 +1864,21 @@ static char *make_GLSL_swizzle_string(char *swiz_str, const size_t strsize,
size_t i = 0;
if ( (!no_swizzle(swizzle)) || (!writemask_xyzw(writemask)) )
{
const int writemask0 = (writemask >> 0) & 0x1;
const int writemask1 = (writemask >> 1) & 0x1;
const int writemask2 = (writemask >> 2) & 0x1;
const int writemask3 = (writemask >> 3) & 0x1;
int writemask_count = ( ((writemask >> 0) & 0x1) +
((writemask >> 1) & 0x1) +
((writemask >> 2) & 0x1) +
((writemask >> 3) & 0x1) );

const int swizzle_x = (swizzle >> 0) & 0x3;
const int swizzle_y = (swizzle >> 2) & 0x3;
const int swizzle_z = (swizzle >> 4) & 0x3;
const int swizzle_w = (swizzle >> 6) & 0x3;

swiz_str[i++] = '.';
if (writemask0) swiz_str[i++] = swizzle_channels[swizzle_x];
if (writemask1) swiz_str[i++] = swizzle_channels[swizzle_y];
if (writemask2) swiz_str[i++] = swizzle_channels[swizzle_z];
if (writemask3) swiz_str[i++] = swizzle_channels[swizzle_w];
if (writemask_count-- > 0) swiz_str[i++] = swizzle_channels[swizzle_x];
if (writemask_count-- > 0) swiz_str[i++] = swizzle_channels[swizzle_y];
if (writemask_count-- > 0) swiz_str[i++] = swizzle_channels[swizzle_z];
if (writemask_count-- > 0) swiz_str[i++] = swizzle_channels[swizzle_w];
} // if
assert(i < strsize);
swiz_str[i] = '\0';
Expand Down

0 comments on commit 171d575

Please sign in to comment.