mojoshader_assembler.c
changeset 521 57e1945104cb
parent 519 c9b27381c971
child 522 3c08f4d2aa2e
equal deleted inserted replaced
520:7195f0183d0c 521:57e1945104cb
   713     if (nexttoken(ctx, 0, 1, 1, 1) == FAIL)
   713     if (nexttoken(ctx, 0, 1, 1, 1) == FAIL)
   714         return FAIL;
   714         return FAIL;
   715 
   715 
   716     // !!! FIXME: can dest registers do relative addressing?
   716     // !!! FIXME: can dest registers do relative addressing?
   717 
   717 
       
   718     int implicit_writemask = 0;
   718     if (!tokeq(tctx, "."))
   719     if (!tokeq(tctx, "."))
   719     {
   720     {
       
   721         implicit_writemask = 1;
   720         info->writemask = 0xF;
   722         info->writemask = 0xF;
   721         info->writemask0 = info->writemask1 = info->writemask2 = info->writemask3 = 1;
   723         info->writemask0 = info->writemask1 = info->writemask2 = info->writemask3 = 1;
   722         pushback(ctx);  // no explicit writemask; do full mask.
   724         pushback(ctx);  // no explicit writemask; do full mask.
   723     } // if
   725     } // if
   724     else if (scalar_register(ctx->shader_type, info->regtype, info->regnum))
   726     // !!! FIXME: Cg generates code with oDepth.z ... this is a bug, I think.
       
   727     //else if (scalar_register(ctx->shader_type, info->regtype, info->regnum))
       
   728     else if ( (scalar_register(ctx->shader_type, info->regtype, info->regnum)) && (info->regtype != REG_TYPE_DEPTHOUT) )
   725         return fail(ctx, "Writemask specified for scalar register");
   729         return fail(ctx, "Writemask specified for scalar register");
   726     else if (nexttoken(ctx, 0, 1, 0, 0) == FAIL)
   730     else if (nexttoken(ctx, 0, 1, 0, 0) == FAIL)
   727         return FAIL;
   731         return FAIL;
   728     else if (tokeq(tctx, ""))
   732     else if (tokeq(tctx, ""))
   729         return fail(ctx, "Invalid writemask");
   733         return fail(ctx, "Invalid writemask");
   749         info->writemask = ( ((info->writemask0 & 0x1) << 0) |
   753         info->writemask = ( ((info->writemask0 & 0x1) << 0) |
   750                             ((info->writemask1 & 0x1) << 1) |
   754                             ((info->writemask1 & 0x1) << 1) |
   751                             ((info->writemask2 & 0x1) << 2) |
   755                             ((info->writemask2 & 0x1) << 2) |
   752                             ((info->writemask3 & 0x1) << 3) );
   756                             ((info->writemask3 & 0x1) << 3) );
   753     } // else
   757     } // else
       
   758 
       
   759     // !!! FIXME: Cg generates code with oDepth.z ... this is a bug, I think.
       
   760     if (info->regtype == REG_TYPE_DEPTHOUT)
       
   761     {
       
   762         if ( (!implicit_writemask) && ((info->writemask0 + info->writemask1 +
       
   763                info->writemask2 + info->writemask3) > 1) )
       
   764             return fail(ctx, "Writemask specified for scalar register");
       
   765     } // if
   754 
   766 
   755     info->orig_writemask = info->writemask;
   767     info->orig_writemask = info->writemask;
   756 
   768 
   757     if (ctx->tokenbufpos >= STATICARRAYLEN(ctx->tokenbuf))
   769     if (ctx->tokenbufpos >= STATICARRAYLEN(ctx->tokenbuf))
   758         return fail(ctx, "Too many tokens");
   770         return fail(ctx, "Too many tokens");