mojoshader.c
branchtrunk
changeset 265 8de29efea862
parent 264 2d8d84d1c640
child 266 b9a7b08d3dee
equal deleted inserted replaced
264:2d8d84d1c640 265:8de29efea862
  1886 static inline char *make_GLSL_srcarg_string_vec3(Context *ctx, const int idx)
  1886 static inline char *make_GLSL_srcarg_string_vec3(Context *ctx, const int idx)
  1887 {
  1887 {
  1888     return make_GLSL_srcarg_string(ctx, idx, 0x7);
  1888     return make_GLSL_srcarg_string(ctx, idx, 0x7);
  1889 } // make_GLSL_srcarg_string_vec3
  1889 } // make_GLSL_srcarg_string_vec3
  1890 
  1890 
       
  1891 static inline char *make_GLSL_srcarg_string_vec2(Context *ctx, const int idx)
       
  1892 {
       
  1893     return make_GLSL_srcarg_string(ctx, idx, 0x3);
       
  1894 } // make_GLSL_srcarg_string_vec2
       
  1895 
  1891 
  1896 
  1892 // special cases for comparison opcodes...
  1897 // special cases for comparison opcodes...
  1893 
  1898 
  1894 static const char *get_GLSL_comparison_string_scalar(Context *ctx)
  1899 static const char *get_GLSL_comparison_string_scalar(Context *ctx)
  1895 {
  1900 {
  2942     fail(ctx, "unimplemented.");  // !!! FIXME
  2947     fail(ctx, "unimplemented.");  // !!! FIXME
  2943 } // emit_GLSL_BEM
  2948 } // emit_GLSL_BEM
  2944 
  2949 
  2945 static void emit_GLSL_DP2ADD(Context *ctx)
  2950 static void emit_GLSL_DP2ADD(Context *ctx)
  2946 {
  2951 {
  2947     fail(ctx, "unimplemented.");  // !!! FIXME
  2952     const char *src0 = make_GLSL_srcarg_string_vec2(ctx, 0);
       
  2953     const char *src1 = make_GLSL_srcarg_string_vec2(ctx, 1);
       
  2954     const char *src2 = make_GLSL_srcarg_string_scalar(ctx, 2);
       
  2955     const char *code = make_GLSL_destarg_assign(ctx, "dot(%s, %s) + %s", src0, src1, src2);
       
  2956     output_line(ctx, "%s", code);
  2948 } // emit_GLSL_DP2ADD
  2957 } // emit_GLSL_DP2ADD
  2949 
  2958 
  2950 static void emit_GLSL_DSX(Context *ctx)
  2959 static void emit_GLSL_DSX(Context *ctx)
  2951 {
  2960 {
  2952     const char *src0 = make_GLSL_srcarg_string_masked(ctx, 0);
  2961     const char *src0 = make_GLSL_srcarg_string_masked(ctx, 0);
  4005 
  4014 
  4006     // !!! FIXME: "If a temporary register is used, all components must have been previously written."
  4015     // !!! FIXME: "If a temporary register is used, all components must have been previously written."
  4007     // !!! FIXME: "If a texture register is used, all components that are read must have been declared."
  4016     // !!! FIXME: "If a texture register is used, all components that are read must have been declared."
  4008     // !!! FIXME: there are further limitations in ps_1_3 and earlier.
  4017     // !!! FIXME: there are further limitations in ps_1_3 and earlier.
  4009 } // state_TEXKILL
  4018 } // state_TEXKILL
       
  4019 
       
  4020 static void state_DP2ADD(Context *ctx)
       
  4021 {
       
  4022     if (!replicate_swizzle(ctx->source_args[2].swizzle))
       
  4023         fail(ctx, "IFC src2 must have replicate swizzle");
       
  4024 } // state_DP2ADD
  4010 
  4025 
  4011 
  4026 
  4012 // Lookup table for instruction opcodes...
  4027 // Lookup table for instruction opcodes...
  4013 typedef struct
  4028 typedef struct
  4014 {
  4029 {
  4124     INSTRUCTION(TEXDP3, DS, MOJOSHADER_TYPE_PIXEL),
  4139     INSTRUCTION(TEXDP3, DS, MOJOSHADER_TYPE_PIXEL),
  4125     INSTRUCTION(TEXM3X3, DS, MOJOSHADER_TYPE_PIXEL),
  4140     INSTRUCTION(TEXM3X3, DS, MOJOSHADER_TYPE_PIXEL),
  4126     INSTRUCTION(TEXDEPTH, D, MOJOSHADER_TYPE_PIXEL),
  4141     INSTRUCTION(TEXDEPTH, D, MOJOSHADER_TYPE_PIXEL),
  4127     INSTRUCTION_STATE(CMP, DSSS, MOJOSHADER_TYPE_PIXEL),
  4142     INSTRUCTION_STATE(CMP, DSSS, MOJOSHADER_TYPE_PIXEL),
  4128     INSTRUCTION(BEM, DSS, MOJOSHADER_TYPE_PIXEL),
  4143     INSTRUCTION(BEM, DSS, MOJOSHADER_TYPE_PIXEL),
  4129     INSTRUCTION(DP2ADD, DSSS, MOJOSHADER_TYPE_PIXEL),
  4144     INSTRUCTION_STATE(DP2ADD, DSSS, MOJOSHADER_TYPE_PIXEL),
  4130     INSTRUCTION(DSX, DS, MOJOSHADER_TYPE_PIXEL),
  4145     INSTRUCTION(DSX, DS, MOJOSHADER_TYPE_PIXEL),
  4131     INSTRUCTION(DSY, DS, MOJOSHADER_TYPE_PIXEL),
  4146     INSTRUCTION(DSY, DS, MOJOSHADER_TYPE_PIXEL),
  4132     INSTRUCTION(TEXLDD, DSSSS, MOJOSHADER_TYPE_PIXEL),
  4147     INSTRUCTION(TEXLDD, DSSSS, MOJOSHADER_TYPE_PIXEL),
  4133     INSTRUCTION_STATE(SETP, DSS, MOJOSHADER_TYPE_ANY),
  4148     INSTRUCTION_STATE(SETP, DSS, MOJOSHADER_TYPE_ANY),
  4134     INSTRUCTION(TEXLDL, DSS, MOJOSHADER_TYPE_ANY),
  4149     INSTRUCTION(TEXLDL, DSS, MOJOSHADER_TYPE_ANY),