From fea3cdbbac0737def28246f4e4597afb545d6929 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 14 Dec 2008 07:10:53 -0500 Subject: [PATCH] Workaround for incorrect assembly code generated by Cg. --- mojoshader_assembler.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mojoshader_assembler.c b/mojoshader_assembler.c index f3cdfebc..42efb712 100644 --- a/mojoshader_assembler.c +++ b/mojoshader_assembler.c @@ -715,13 +715,17 @@ static int parse_destination_token(Context *ctx) // !!! FIXME: can dest registers do relative addressing? + int implicit_writemask = 0; if (!tokeq(tctx, ".")) { + implicit_writemask = 1; info->writemask = 0xF; info->writemask0 = info->writemask1 = info->writemask2 = info->writemask3 = 1; pushback(ctx); // no explicit writemask; do full mask. } // if - else if (scalar_register(ctx->shader_type, info->regtype, info->regnum)) + // !!! FIXME: Cg generates code with oDepth.z ... this is a bug, I think. + //else if (scalar_register(ctx->shader_type, info->regtype, info->regnum)) + else if ( (scalar_register(ctx->shader_type, info->regtype, info->regnum)) && (info->regtype != REG_TYPE_DEPTHOUT) ) return fail(ctx, "Writemask specified for scalar register"); else if (nexttoken(ctx, 0, 1, 0, 0) == FAIL) return FAIL; @@ -752,6 +756,14 @@ static int parse_destination_token(Context *ctx) ((info->writemask3 & 0x1) << 3) ); } // else + // !!! FIXME: Cg generates code with oDepth.z ... this is a bug, I think. + if (info->regtype == REG_TYPE_DEPTHOUT) + { + if ( (!implicit_writemask) && ((info->writemask0 + info->writemask1 + + info->writemask2 + info->writemask3) > 1) ) + return fail(ctx, "Writemask specified for scalar register"); + } // if + info->orig_writemask = info->writemask; if (ctx->tokenbufpos >= STATICARRAYLEN(ctx->tokenbuf))