mojoshader_effects.c
changeset 1074 3fdc7cbd0c37
parent 1063 b10281d6eb45
child 1104 9147482e1ec7
equal deleted inserted replaced
1073:6eccf031c7e6 1074:3fdc7cbd0c37
   138             OPCODE_CASE(ATAN2, atan2(src0[i], src1[i]))
   138             OPCODE_CASE(ATAN2, atan2(src0[i], src1[i]))
   139             OPCODE_CASE(DIV, src0[i] / src1[i])
   139             OPCODE_CASE(DIV, src0[i] / src1[i])
   140             OPCODE_CASE(CMP, (src0[i] >= 0.0) ? src1[i] : src2[i])
   140             OPCODE_CASE(CMP, (src0[i] >= 0.0) ? src1[i] : src2[i])
   141             //OPCODE_CASE(NOISE, ???)  // !!! FIXME: don't know what this does
   141             //OPCODE_CASE(NOISE, ???)  // !!! FIXME: don't know what this does
   142             //OPCODE_CASE(MOVC, ???)  // !!! FIXME: don't know what this does
   142             //OPCODE_CASE(MOVC, ???)  // !!! FIXME: don't know what this does
       
   143             OPCODE_CASE(MIN_SCALAR, (src0[0] < src1[i]) ? src0[0] : src1[i])
       
   144             OPCODE_CASE(MAX_SCALAR, (src0[0] > src1[i]) ? src0[0] : src1[i])
       
   145             OPCODE_CASE(LT_SCALAR, (src0[0] < src1[i]) ? 1.0 : 0.0)
       
   146             OPCODE_CASE(GE_SCALAR, (src0[0] >= src1[i]) ? 1.0 : 0.0)
       
   147             OPCODE_CASE(ADD_SCALAR, src0[0] + src1[i])
       
   148             OPCODE_CASE(MUL_SCALAR, src0[0] * src1[i])
       
   149             OPCODE_CASE(ATAN2_SCALAR, atan2(src0[0], src1[i]))
       
   150             OPCODE_CASE(DIV_SCALAR, src0[0] / src1[i])
       
   151             //OPCODE_CASE(DOT_SCALAR)  // !!! FIXME: isn't this just a MUL?
       
   152             //OPCODE_CASE(NOISE_SCALAR, ???)  // !!! FIXME: ?
   143             #undef OPCODE_CASE
   153             #undef OPCODE_CASE
   144 
   154 
   145             case MOJOSHADER_PRESHADEROP_DOT:
   155             case MOJOSHADER_PRESHADEROP_DOT:
   146             {
   156             {
   147                 double final = 0.0;
   157                 double final = 0.0;
   148                 for (i = 0; i < elems; i++)
   158                 for (i = 0; i < elems; i++)
   149                     final += src0[i] * src1[i];
   159                     final += src0[i] * src1[i];
   150                 for (i = 0; i < elems; i++)
   160                 for (i = 0; i < elems; i++)
   151                     dst[i] = final;  // !!! FIXME: is this right?
   161                     dst[i] = final;  // !!! FIXME: is this right?
   152             } // case
   162             } // case
   153 
       
   154             #define OPCODE_CASE_SCALAR(op, val) \
       
   155                 case MOJOSHADER_PRESHADEROP_##op##_SCALAR: { \
       
   156                     const double final = val; \
       
   157                     for (i = 0; i < elems; i++) { dst[i] = final; } \
       
   158                     break; \
       
   159                 }
       
   160 
       
   161             OPCODE_CASE_SCALAR(MIN, (src0[0] < src1[0]) ? src0[0] : src1[0])
       
   162             OPCODE_CASE_SCALAR(MAX, (src0[0] > src1[0]) ? src0[0] : src1[0])
       
   163             OPCODE_CASE_SCALAR(LT, (src0[0] < src1[0]) ? 1.0 : 0.0)
       
   164             OPCODE_CASE_SCALAR(GE, (src0[0] >= src1[0]) ? 1.0 : 0.0)
       
   165             OPCODE_CASE_SCALAR(ADD, src0[0] + src1[0])
       
   166             OPCODE_CASE_SCALAR(MUL, src0[0] * src1[0])
       
   167             OPCODE_CASE_SCALAR(ATAN2, atan2(src0[0], src1[0]))
       
   168             OPCODE_CASE_SCALAR(DIV, src0[0] / src1[0])
       
   169             //OPCODE_CASE_SCALAR(DOT)  // !!! FIXME: isn't this just a MUL?
       
   170             //OPCODE_CASE_SCALAR(NOISE, ???)  // !!! FIXME: ?
       
   171             #undef OPCODE_CASE_SCALAR
       
   172 
   163 
   173             default:
   164             default:
   174                 assert(0 && "Unhandled preshader opcode!");
   165                 assert(0 && "Unhandled preshader opcode!");
   175                 break;
   166                 break;
   176         } // switch
   167         } // switch