Skip to content
Permalink
Browse files
Fixed wrong data from scalar_register().
Apparently the predicate register is scalar, but only in pixel shaders.
  • Loading branch information
icculus committed Dec 10, 2008
1 parent 42412b5 commit bdb1153ca8d5d623e51cd069ed40b78999f2ced1
Showing with 15 additions and 12 deletions.
  1. +8 −8 mojoshader.c
  2. +2 −2 mojoshader_assembler.c
  3. +5 −2 mojoshader_internal.h
@@ -895,7 +895,7 @@ static const char *make_D3D_srcarg_string_in_buf(Context *ctx,

char swizzle_str[6];
int i = 0;
const int scalar = scalar_register(arg->regtype, arg->regnum);
const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
if (!scalar && !no_swizzle(arg->swizzle))
{
swizzle_str[i++] = '.';
@@ -952,7 +952,7 @@ static const char *make_D3D_destarg_string(Context *ctx)

char writemask_str[6];
int i = 0;
const int scalar = scalar_register(arg->regtype, arg->regnum);
const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
if (!scalar && !writemask_xyzw(arg->writemask))
{
writemask_str[i++] = '.';
@@ -1723,7 +1723,7 @@ static const char *make_GLSL_destarg_assign(Context *ctx, const char *fmt, ...)
sizeof (regnum_str));
char writemask_str[6];
int i = 0;
const int scalar = scalar_register(arg->regtype, arg->regnum);
const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
if (!scalar && !writemask_xyzw(arg->writemask))
{
writemask_str[i++] = '.';
@@ -1890,7 +1890,7 @@ static char *make_GLSL_srcarg_string(Context *ctx, const int idx,
} // if

char swiz_str[6] = { '\0' };
if (!scalar_register(arg->regtype, arg->regnum))
if (!scalar_register(ctx->shader_type, arg->regtype, arg->regnum))
{
make_GLSL_swizzle_string(swiz_str, sizeof (swiz_str),
arg->swizzle, writemask);
@@ -2962,7 +2962,7 @@ static void emit_GLSL_TEXLD(Context *ctx)
return;
} // switch

assert(!scalar_register(samp_arg->regtype, samp_arg->regnum));
assert(!scalar_register(ctx->shader_type, samp_arg->regtype, samp_arg->regnum));
char swiz_str[6] = { '\0' };
make_GLSL_swizzle_string(swiz_str, sizeof (swiz_str),
samp_arg->swizzle, ctx->dest_arg.writemask);
@@ -3381,7 +3381,7 @@ static const char *make_ARB1_srcarg_string_in_buf(Context *ctx,
} // if
} // if

const int scalar = scalar_register(arg->regtype, arg->regnum);
const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
if (!scalar && !no_swizzle(arg->swizzle))
{
swizzle_str[i++] = '.';
@@ -3469,7 +3469,7 @@ static const char *make_ARB1_destarg_string(Context *ctx)

char writemask_str[6];
int i = 0;
const int scalar = scalar_register(arg->regtype, arg->regnum);
const int scalar = scalar_register(ctx->shader_type, arg->regtype, arg->regnum);
if (!scalar && !writemask_xyzw(arg->writemask))
{
writemask_str[i++] = '.';
@@ -4929,7 +4929,7 @@ static int parse_destination_token(Context *ctx, DestArgInfo *info)
info->regtype = (RegisterType) (((token >> 28) & 0x7) | ((token >> 8) & 0x18)); // bits 28-30, 11-12

int writemask;
if (scalar_register(info->regtype, info->regnum))
if (scalar_register(ctx->shader_type, info->regtype, info->regnum))
writemask = 0x1; // just x.
else
writemask = info->orig_writemask;
@@ -669,7 +669,7 @@ static int parse_destination_token(Context *ctx, DestArgInfo *info)
info->writemask0 = info->writemask1 = info->writemask2 = info->writemask3 = 1;
pushback(ctx); // no explicit writemask; do full mask.
} // if
else if (scalar_register(info->regtype, info->regnum))
else if (scalar_register(ctx->shader_type, info->regtype, info->regnum))
return fail(ctx, "Writemask specified for scalar register");
else if (nexttoken(ctx, 0, 1, 0, 0) == FAIL)
return FAIL;
@@ -830,7 +830,7 @@ static int parse_source_token_maybe_relative(Context *ctx, const int relok)
swizzle = 0xE4; // 0xE4 == 11100100 ... 0 1 2 3. No swizzle.
pushback(ctx); // no explicit writemask; do full mask.
} // if
else if (scalar_register(regtype, regnum))
else if (scalar_register(ctx->shader_type, regtype, regnum))
return fail(ctx, "Swizzle specified for scalar register");
else if (nexttoken(ctx, 0, 1, 0, 0) == FAIL)
return FAIL;
@@ -227,13 +227,13 @@ typedef struct
} DestArgInfo;


static inline int scalar_register(const RegisterType regtype, const int regnum)
static inline int scalar_register(const MOJOSHADER_shaderType shader_type,
const RegisterType regtype, const int regnum)
{
switch (regtype)
{
case REG_TYPE_DEPTHOUT:
case REG_TYPE_CONSTBOOL:
case REG_TYPE_PREDICATE:
case REG_TYPE_LOOP:
return 1;

@@ -242,6 +242,9 @@ static inline int scalar_register(const RegisterType regtype, const int regnum)
return 1;
return 0;

case REG_TYPE_PREDICATE:
return (shader_type == MOJOSHADER_TYPE_PIXEL) ? 1 : 0;

default: break;
} // switch

0 comments on commit bdb1153

Please sign in to comment.