mojoshader.c
branchtrunk
changeset 261 929496882e30
parent 252 59a608b65a0a
child 263 5eda879872ae
equal deleted inserted replaced
260:5b5fc8c5661b 261:929496882e30
  2721     fail(ctx, "unimplemented.");  // !!! FIXME
  2721     fail(ctx, "unimplemented.");  // !!! FIXME
  2722 } // emit_GLSL_TEXCOORD
  2722 } // emit_GLSL_TEXCOORD
  2723 
  2723 
  2724 static void emit_GLSL_TEXKILL(Context *ctx)
  2724 static void emit_GLSL_TEXKILL(Context *ctx)
  2725 {
  2725 {
  2726     fail(ctx, "unimplemented.");  // !!! FIXME
  2726     const char *dst0 = get_GLSL_destarg_varname(ctx);
  2727 // !!! FIXME
  2727     output_line(ctx, "if (any(lessThan(%s.xyz, vec3(0.0)))) discard;", dst0);
  2728 //    const char *dst0 = make_GLSL_destarg_string(ctx, 0);
       
  2729 //    output_line(ctx, "if (any(lessThan(vec3(%s), vec3(0.0)))) discard;", dst0);
       
  2730 } // emit_GLSL_TEXKILL
  2728 } // emit_GLSL_TEXKILL
  2731 
  2729 
  2732 static void emit_GLSL_TEX(Context *ctx)
  2730 static void emit_GLSL_TEX(Context *ctx)
  2733 {
  2731 {
  2734     // this opcode looks and acts differently depending on the shader model.
  2732     // this opcode looks and acts differently depending on the shader model.
  3989     else if (!replicate_swizzle(ctx->source_args[1].swizzle))
  3987     else if (!replicate_swizzle(ctx->source_args[1].swizzle))
  3990         fail(ctx, "BREAKC src2 must have replicate swizzle");
  3988         fail(ctx, "BREAKC src2 must have replicate swizzle");
  3991     else if ((ctx->loops == 0) && (ctx->reps == 0))
  3989     else if ((ctx->loops == 0) && (ctx->reps == 0))
  3992         fail(ctx, "BREAKC outside LOOP/ENDLOOP or REP/ENDREP");
  3990         fail(ctx, "BREAKC outside LOOP/ENDLOOP or REP/ENDREP");
  3993 } // state_BREAKC
  3991 } // state_BREAKC
       
  3992 
       
  3993 static void state_TEXKILL(Context *ctx)
       
  3994 {
       
  3995     // The MSDN docs say this should be a source arg, but the driver docs
       
  3996     //  say it's a dest arg. That's annoying.
       
  3997     const DestArgInfo *info = &ctx->dest_arg;
       
  3998     const RegisterType regtype = info->regtype;
       
  3999     if (info->writemask != 0xF)  // 0xF == 1111. No explicit mask.
       
  4000         fail(ctx, "TEXKILL writemask must be .xyzw");
       
  4001     else if ((regtype != REG_TYPE_TEMP) && (regtype != REG_TYPE_TEXTURE))
       
  4002         fail(ctx, "TEXKILL must use a temp or texture register");
       
  4003 
       
  4004     // !!! FIXME: "If a temporary register is used, all components must have been previously written."
       
  4005     // !!! FIXME: "If a texture register is used, all components that are read must have been declared."
       
  4006     // !!! FIXME: there are further limitations in ps_1_3 and earlier.
       
  4007 } // state_TEXKILL
  3994 
  4008 
  3995 
  4009 
  3996 // Lookup table for instruction opcodes...
  4010 // Lookup table for instruction opcodes...
  3997 typedef struct
  4011 typedef struct
  3998 {
  4012 {
  4083     INSTRUCTION(RESERVED, NULL, MOJOSHADER_TYPE_UNKNOWN),
  4097     INSTRUCTION(RESERVED, NULL, MOJOSHADER_TYPE_UNKNOWN),
  4084     INSTRUCTION(RESERVED, NULL, MOJOSHADER_TYPE_UNKNOWN),
  4098     INSTRUCTION(RESERVED, NULL, MOJOSHADER_TYPE_UNKNOWN),
  4085     INSTRUCTION(RESERVED, NULL, MOJOSHADER_TYPE_UNKNOWN),
  4099     INSTRUCTION(RESERVED, NULL, MOJOSHADER_TYPE_UNKNOWN),
  4086     INSTRUCTION(RESERVED, NULL, MOJOSHADER_TYPE_UNKNOWN),
  4100     INSTRUCTION(RESERVED, NULL, MOJOSHADER_TYPE_UNKNOWN),
  4087     INSTRUCTION(TEXCOORD, TEXCOORD, MOJOSHADER_TYPE_PIXEL),
  4101     INSTRUCTION(TEXCOORD, TEXCOORD, MOJOSHADER_TYPE_PIXEL),
  4088     INSTRUCTION(TEXKILL, D, MOJOSHADER_TYPE_PIXEL),
  4102     INSTRUCTION_STATE(TEXKILL, D, MOJOSHADER_TYPE_PIXEL),
  4089     INSTRUCTION(TEX, TEX, MOJOSHADER_TYPE_PIXEL),
  4103     INSTRUCTION(TEX, TEX, MOJOSHADER_TYPE_PIXEL),
  4090     INSTRUCTION(TEXBEM, DS, MOJOSHADER_TYPE_ANY),
  4104     INSTRUCTION(TEXBEM, DS, MOJOSHADER_TYPE_ANY),
  4091     INSTRUCTION(TEXBEML, DS, MOJOSHADER_TYPE_ANY),
  4105     INSTRUCTION(TEXBEML, DS, MOJOSHADER_TYPE_ANY),
  4092     INSTRUCTION(TEXREG2AR, DS, MOJOSHADER_TYPE_ANY),
  4106     INSTRUCTION(TEXREG2AR, DS, MOJOSHADER_TYPE_ANY),
  4093     INSTRUCTION(TEXREG2GB, DS, MOJOSHADER_TYPE_ANY),
  4107     INSTRUCTION(TEXREG2GB, DS, MOJOSHADER_TYPE_ANY),