From bdb1153ca8d5d623e51cd069ed40b78999f2ced1 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 10 Dec 2008 05:05:55 -0500 Subject: [PATCH] Fixed wrong data from scalar_register(). Apparently the predicate register is scalar, but only in pixel shaders. --- mojoshader.c | 16 ++++++++-------- mojoshader_assembler.c | 4 ++-- mojoshader_internal.h | 7 +++++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index c0304474..caa36776 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -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; diff --git a/mojoshader_assembler.c b/mojoshader_assembler.c index e9de2097..363d57c3 100644 --- a/mojoshader_assembler.c +++ b/mojoshader_assembler.c @@ -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; diff --git a/mojoshader_internal.h b/mojoshader_internal.h index d5394fd9..c48aba57 100644 --- a/mojoshader_internal.h +++ b/mojoshader_internal.h @@ -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