mojoshader_effects.c
author Ryan C. Gordon <icculus@icculus.org>
Tue, 31 May 2011 03:23:39 -0400
changeset 1036 8a3597b44ff7
parent 1021 cad933999680
child 1037 b102a563d9cb
permissions -rw-r--r--
First shot at preshader interpreter. Completely untested!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1019
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/**
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * MojoShader; generate shader programs from bytecode of compiled
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *  Direct3D shaders.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 *
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 * Please see the file LICENSE.txt in the source's root directory.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 *
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 *  This file written by Ryan C. Gordon.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
 */
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
#define __MOJOSHADER_INTERNAL__ 1
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
#include "mojoshader_internal.h"
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
1036
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    13
#include <math.h>
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    14
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    15
void run_preshader(const MOJOSHADER_preshader *preshader, float *regs)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    16
{
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    17
    // this is fairly straightforward, as there aren't any branching
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    18
    //  opcodes in the preshader instruction set (at the moment, at least).
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    19
    const int scalarstart = (int) MOJOSHADER_PRESHADEROP_SCALAR_OPS;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    20
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    21
    double *temps = (double *) alloca(sizeof (double) * preshader->temp_count);
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    22
    memset(temps, '\0', sizeof (double) * preshader->temp_count);
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    23
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    24
    double dst[4];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    25
    double src[3][4];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    26
    const double *src0 = src[0];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    27
    const double *src1 = src[1];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    28
    const double *src2 = src[2];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    29
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    30
    MOJOSHADER_preshaderInstruction *inst = preshader->instructions;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    31
    int instit;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    32
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    33
    for (instit = 0; instit < preshader->instruction_count; instit++, inst++)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    34
    {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    35
        const MOJOSHADER_preshaderOperand *operand = inst->operands;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    36
        const int isscalar = (inst->opcode >= scalarstart);
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    37
        const int elems = inst->element_count;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    38
        const int elemsbytes = sizeof (double) * elems;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    39
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    40
        // load up our operands...
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    41
        int opiter, elemiter;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    42
        for (opiter = 1; opiter < inst->operand_count; opiter++, operand++)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    43
        {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    44
            const unsigned int index = operand->index;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    45
            switch (operand->type)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    46
            {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    47
                case MOJOSHADER_PRESHADEROPERAND_LITERAL:
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    48
                {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    49
                    const double *lit = &preshader->literals[index];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    50
                    if (!isscalar)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    51
                        memcpy(src[opiter], lit, elemsbytes);
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    52
                    else
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    53
                    {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    54
                        const double val = *lit;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    55
                        for (elemiter = 0; elemiter < elems; elemiter++)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    56
                            src[opiter][elemiter] = val;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    57
                    } // else
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    58
                    break;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    59
                } // case
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    60
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    61
                case MOJOSHADER_PRESHADEROPERAND_INPUT:
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    62
                case MOJOSHADER_PRESHADEROPERAND_OUTPUT:
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    63
                    if (isscalar)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    64
                        src[opiter][0] = regs[index];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    65
                    else
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    66
                    {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    67
                        int cpy;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    68
                        for (cpy = 0; cpy < elems; cpy++)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    69
                            src[opiter][cpy] = regs[index+cpy];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    70
                    } // else
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    71
                    break;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    72
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    73
                case MOJOSHADER_PRESHADEROPERAND_TEMP:
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    74
                    if (isscalar)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    75
                        src[opiter][0] = temps[index];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    76
                    else
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    77
                        memcpy(src[opiter], temps + index, elemsbytes);
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    78
                    break;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    79
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    80
                default:
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    81
                    assert(0 && "unexpected preshader operand type.");
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    82
                    break;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    83
            } // switch
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    84
        } // for
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    85
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    86
        // run the actual instruction, store result to dst.
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    87
        int i;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    88
        switch (inst->opcode)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    89
        {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    90
            #define OPCODE_CASE(op, val) \
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    91
                case MOJOSHADER_PRESHADEROP_##op: \
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    92
                    for (i = 0; i < elems; i++) { dst[i] = val; } \
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    93
                    break;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    94
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    95
            //OPCODE_CASE(NOP, 0.0)  // not a real instruction.
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    96
            OPCODE_CASE(MOV, src0[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    97
            OPCODE_CASE(NEG, -src0[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    98
            OPCODE_CASE(RCP, 1.0 / src0[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
    99
            OPCODE_CASE(FRC, src0[i] - floor(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   100
            OPCODE_CASE(EXP, exp(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   101
            OPCODE_CASE(LOG, log(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   102
            OPCODE_CASE(RSQ, 1.0 / sqrt(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   103
            OPCODE_CASE(SIN, sin(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   104
            OPCODE_CASE(COS, cos(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   105
            OPCODE_CASE(ASIN, asin(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   106
            OPCODE_CASE(ACOS, acos(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   107
            OPCODE_CASE(ATAN, atan(src0[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   108
            OPCODE_CASE(MIN, (src0[i] < src1[i]) ? src0[i] : src1[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   109
            OPCODE_CASE(MAX, (src0[i] > src1[i]) ? src0[i] : src1[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   110
            OPCODE_CASE(LT, (src0[i] < src1[i]) ? 1.0 : 0.0)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   111
            OPCODE_CASE(GE, (src0[i] >= src1[i]) ? 1.0 : 0.0)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   112
            OPCODE_CASE(ADD, src0[i] + src1[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   113
            OPCODE_CASE(MUL,  src0[i] * src1[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   114
            OPCODE_CASE(ATAN2, atan2(src0[i], src1[i]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   115
            OPCODE_CASE(DIV, src0[i] / src1[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   116
            OPCODE_CASE(CMP, (src0[i] >= 0.0) ? src1[i] : src2[i])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   117
            //OPCODE_CASE(NOISE, ???)  // !!! FIXME: don't know what this does
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   118
            //OPCODE_CASE(MOVC, ???)  // !!! FIXME: don't know what this does
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   119
            #undef OPCODE_CASE
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   120
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   121
            case MOJOSHADER_PRESHADEROP_DOT:
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   122
            {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   123
                double final = 0.0;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   124
                for (i = 0; i < elems; i++)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   125
                    final += src0[i] * src1[i];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   126
                for (i = 0; i < elems; i++)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   127
                    dst[i] = final;  // !!! FIXME: is this right?
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   128
            } // case
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   129
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   130
            #define OPCODE_CASE_SCALAR(op, val) \
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   131
                case MOJOSHADER_PRESHADEROP_##op##_SCALAR: { \
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   132
                    const double final = val; \
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   133
                    for (i = 0; i < elems; i++) { dst[i] = final; } \
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   134
                    break; \
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   135
                }
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   136
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   137
            OPCODE_CASE_SCALAR(MIN, (src0[0] < src1[0]) ? src0[0] : src1[0])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   138
            OPCODE_CASE_SCALAR(MAX, (src0[0] > src1[0]) ? src0[0] : src1[0])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   139
            OPCODE_CASE_SCALAR(LT, (src0[0] < src1[0]) ? 1.0 : 0.0)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   140
            OPCODE_CASE_SCALAR(GE, (src0[0] >= src1[0]) ? 1.0 : 0.0)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   141
            OPCODE_CASE_SCALAR(ADD, src0[0] + src1[0])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   142
            OPCODE_CASE_SCALAR(MUL, src0[0] * src1[0])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   143
            OPCODE_CASE_SCALAR(ATAN2, atan2(src0[0], src1[0]))
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   144
            OPCODE_CASE_SCALAR(DIV, src0[0] / src1[0])
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   145
            //OPCODE_CASE_SCALAR(DOT)  // !!! FIXME: isn't this just a MUL?
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   146
            //OPCODE_CASE_SCALAR(NOISE, ???)  // !!! FIXME: ?
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   147
            #undef OPCODE_CASE_SCALAR
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   148
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   149
            default:
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   150
                assert(0 && "Unhandled preshader opcode!");
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   151
                break;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   152
        } // switch
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   153
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   154
        // Figure out where dst wants to be stored.
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   155
        operand = inst->operands;
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   156
        if (operand->type == MOJOSHADER_PRESHADEROPERAND_TEMP)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   157
            memcpy(temps + operand->index, dst, elemsbytes);
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   158
        else
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   159
        {
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   160
            assert(operand->type == MOJOSHADER_PRESHADEROPERAND_OUTPUT);
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   161
            for (i = 0; i < elems; i++)
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   162
                regs[operand->index + i] = (float) dst[i];
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   163
        } // else
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   164
    } // for
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   165
} // run_preshader
8a3597b44ff7 First shot at preshader interpreter. Completely untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 1021
diff changeset
   166
1019
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
static MOJOSHADER_effect MOJOSHADER_out_of_mem_effect = {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
    1, &MOJOSHADER_out_of_mem_error, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
};
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
static uint32 readui32(const uint8 **_ptr, uint32 *_len)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
{
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
    uint32 retval = 0;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
    if (*_len < sizeof (retval))
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
        *_len = 0;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
    else
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
        const uint32 *ptr = (const uint32 *) *_ptr;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
        retval = SWAP32(*ptr);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
        *_ptr += sizeof (retval);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
        *_len -= sizeof (retval);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
    } // else
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
    return retval;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
} // readui32
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
// !!! FIXME: this is sort of a big, ugly function.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
const MOJOSHADER_effect *MOJOSHADER_parseEffect(const char *profile,
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
                                                const unsigned char *buf,
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
                                                const unsigned int _len,
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
                                                const MOJOSHADER_swizzle *swiz,
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
                                                const unsigned int swizcount,
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
                                                MOJOSHADER_malloc m,
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
                                                MOJOSHADER_free f,
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
                                                void *d)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
{
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
    if ( ((m == NULL) && (f != NULL)) || ((m != NULL) && (f == NULL)) )
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
        return &MOJOSHADER_out_of_mem_effect;  // supply both or neither.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
    if (m == NULL) m = MOJOSHADER_internal_malloc;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
    if (f == NULL) f = MOJOSHADER_internal_free;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
    MOJOSHADER_effect *retval = m(sizeof (MOJOSHADER_effect), d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
    if (retval == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   205
        return &MOJOSHADER_out_of_mem_effect;  // supply both or neither.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   206
    memset(retval, '\0', sizeof (*retval));
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   208
    retval->malloc = m;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   209
    retval->free = f;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   210
    retval->malloc_data = d;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
    const uint8 *ptr = (const uint8 *) buf;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
    uint32 len = (uint32) _len;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
    size_t siz = 0;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
    int i, j, k;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
    if (len < 8)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
        goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
    if (readui32(&ptr, &len) != 0xFEFF0901) // !!! FIXME: is this always magic?
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
        goto parseEffect_notAnEffectsFile;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
    else
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
        const uint32 offset = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
        if (offset > len)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
            goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
        ptr += offset;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
        len -= offset;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
    } // else
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   231
    // params...
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   232
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
    if (len < 16)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
        goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   235
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
    const uint32 numparams = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
    const uint32 numtechniques = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
    readui32(&ptr, &len); // !!! FIXME: there are 8 unknown bytes here.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
    readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   242
    for (i = 0; i < numparams; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
        if (len < 16)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
            goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   247
        /*const uint32 startoffset = */ readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   248
        /*const uint32 endoffset = */ readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
        readui32(&ptr, &len);  // !!! FIXME: don't know what this is.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
        const uint32 numannos = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
        for (j = 0; j < numannos; j++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
        {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
            if (len < 8)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
            // !!! FIXME: parse annotations.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
            readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   257
            readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
        } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   259
    } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
    uint32 numshaders = 0;  // we'll calculate this later.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
    // techniques...
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
    if (numtechniques > 0)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
        siz = sizeof (MOJOSHADER_effectTechnique) * numtechniques;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
        retval->techniques = (MOJOSHADER_effectTechnique *) m(siz, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
        if (retval->techniques == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
            goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   271
        memset(retval->techniques, '\0', siz);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
        retval->technique_count = numtechniques;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
        for (i = 0; i < numtechniques; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
        {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   277
            if (len < 12)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   279
            
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   280
            MOJOSHADER_effectTechnique *technique = &retval->techniques[i];
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   281
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   282
            // !!! FIXME: is this always 12?
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   283
            const uint32 nameoffset = readui32(&ptr, &len) + 12;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   284
            readui32(&ptr, &len);  // !!! FIXME: don't know what this field does.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   285
            const uint32 numpasses = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   286
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   287
            if (nameoffset >= _len)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   289
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
            if (numpasses > 0)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   291
            {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   292
                // !!! FIXME: verify this doesn't go past EOF looking for a null.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   293
                siz = strlen(((const char *) buf) + nameoffset) + 1;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   294
                technique->name = (char *) m(siz, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   295
                if (technique->name == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   296
                    goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
                strcpy((char *) technique->name, ((const char *) buf) + nameoffset);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   299
                technique->pass_count = numpasses;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   300
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
                siz = sizeof (MOJOSHADER_effectPass) * numpasses;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   302
                technique->passes = (MOJOSHADER_effectPass *) m(siz, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   303
                if (technique->passes == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
                    goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   305
                memset(technique->passes, '\0', siz);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   307
                for (j = 0; j < numpasses; j++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   308
                {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   309
                    if (len < 12)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
                        goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
                    MOJOSHADER_effectPass *pass = &technique->passes[j];
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
                    // !!! FIXME: is this always 12?
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
                    const uint32 passnameoffset = readui32(&ptr, &len) + 12;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
                    readui32(&ptr, &len);  // !!! FIXME: don't know what this field does.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
                    const uint32 numstates = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
                    if (passnameoffset >= _len)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
                        goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
                    // !!! FIXME: verify this doesn't go past EOF looking for a null.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   323
                    siz = strlen(((const char *) buf) + passnameoffset) + 1;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   324
                    pass->name = (char *) m(siz, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   325
                    if (pass->name == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
                        goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
                    strcpy((char *) pass->name, ((const char *) buf) + passnameoffset);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   329
                    if (numstates > 0)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
                    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   331
                        pass->state_count = numstates;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   332
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   333
                        siz = sizeof (MOJOSHADER_effectState) * numstates;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
                        pass->states = (MOJOSHADER_effectState *) m(siz, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
                        if (pass->states == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
                            goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   337
                        memset(pass->states, '\0', siz);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   338
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   339
                        for (k = 0; k < numstates; k++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
                        {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341
                            if (len < 16)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
                                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   344
                            MOJOSHADER_effectState *state = &pass->states[k];
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   345
                            const uint32 type = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   346
                            readui32(&ptr, &len);  // !!! FIXME: don't know what this field does.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
                            /*const uint32 offsetend = */ readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
                            /*const uint32 offsetstart = */ readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
                            state->type = type;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
                            if ((type == 0x92) || (type == 0x93))
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
                                numshaders++;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
                        } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
                    } // if
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
                } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
            } // if
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
        } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
    } // if
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
    // textures...
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
    if (len < 8)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
        goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
    const int numtextures = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
    const int numobjects = readui32(&ptr, &len);  // !!! FIXME: "objects" for lack of a better word.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
    if (numtextures > 0)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
        siz = sizeof (MOJOSHADER_effectTexture) * numtextures;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   371
        retval->textures = m(siz, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
        if (retval->textures == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
            goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
        memset(retval->textures, '\0', siz);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   375
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
        for (i = 0; i < numtextures; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
        {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
            if (len < 8)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   379
                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
            MOJOSHADER_effectTexture *texture = &retval->textures[i];
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
            const uint32 texparam = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
            const uint32 texsize = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
            // apparently texsize will pad out to 32 bits.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
            const uint32 readsize = (((texsize + 3) / 4) * 4);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
            if (len < readsize)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   389
            texture->param = texparam;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
            char *str = m(texsize + 1, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   391
            if (str == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
                goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
            memcpy(str, ptr, texsize);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
            str[texsize] = '\0';
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
            texture->name = str;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   396
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   397
            ptr += readsize;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   398
            len -= readsize;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
        } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
    } // if
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
    // shaders...
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   403
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
    if (numshaders > 0)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
        siz = sizeof (MOJOSHADER_effectShader) * numshaders;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   407
        retval->shaders = (MOJOSHADER_effectShader *) m(siz, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
        if (retval->shaders == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   409
            goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   410
        memset(retval->shaders, '\0', siz);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   411
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   412
        retval->shader_count = numshaders;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   413
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   414
        // !!! FIXME: I wonder if we should pull these from offsets and not
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   415
        // !!! FIXME:  count on them all being in a line like this.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   416
        for (i = 0; i < numshaders; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   417
        {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   418
            if (len < 24)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   419
                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   420
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   421
            MOJOSHADER_effectShader *shader = &retval->shaders[i];
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   422
            const uint32 technique = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   423
            const uint32 pass = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   424
            readui32(&ptr, &len);  // !!! FIXME: don't know what this does.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   425
            readui32(&ptr, &len);  // !!! FIXME: don't know what this does (vertex/pixel/geometry?)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   426
            readui32(&ptr, &len);  // !!! FIXME: don't know what this does.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   427
            const uint32 shadersize = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   428
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   429
            if (len < shadersize)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   430
                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   431
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   432
            shader->technique = technique;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   433
            shader->pass = pass;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   434
            shader->shader = MOJOSHADER_parse(profile, ptr, shadersize,
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   435
                                              swiz, swizcount, m, f, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   436
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   437
            // !!! FIXME: check for errors.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   438
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   439
            ptr += shadersize;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   440
            len -= shadersize;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   441
        } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   442
    } // if
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   443
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   444
    // !!! FIXME: we parse this, but don't expose the data, yet.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   445
    // mappings ...
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   446
    assert(numshaders <= numobjects);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   447
    const uint32 nummappings = numobjects - numshaders;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   448
    if (nummappings > 0)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   449
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   450
        for (i = 0; i < nummappings; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   451
        {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   452
            if (len < 24)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   453
                goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   454
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   455
            /*const uint32 magic = */ readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   456
            /*const uint32 index = */ readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   457
            readui32(&ptr, &len);  // !!! FIXME: what is this field?
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   458
            readui32(&ptr, &len);  // !!! FIXME: what is this field?
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   459
            /*const uint32 type = */ readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   460
            const uint32 mapsize = readui32(&ptr, &len);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   461
            if (mapsize > 0)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   462
            {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   463
                const uint32 readsize = (((mapsize + 3) / 4) * 4);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   464
                if (len < readsize)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   465
                    goto parseEffect_unexpectedEOF;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   466
            } // if
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   467
        } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   468
    } // if
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   469
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   470
    retval->profile = (char *) m(strlen(profile) + 1, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   471
    if (retval->profile == NULL)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   472
        goto parseEffect_outOfMemory;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   473
    strcpy((char *) retval->profile, profile);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   474
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   475
    return retval;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   476
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   477
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   478
// !!! FIXME: do something with this.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   479
parseEffect_notAnEffectsFile:
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   480
parseEffect_unexpectedEOF:
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   481
parseEffect_outOfMemory:
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   482
    MOJOSHADER_freeEffect(retval);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   483
    return &MOJOSHADER_out_of_mem_effect;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   484
} // MOJOSHADER_parseEffect
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   485
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   486
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   487
void MOJOSHADER_freeEffect(const MOJOSHADER_effect *_effect)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   488
{
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   489
    MOJOSHADER_effect *effect = (MOJOSHADER_effect *) _effect;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   490
    if ((effect == NULL) || (effect == &MOJOSHADER_out_of_mem_effect))
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   491
        return;  // no-op.
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   492
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   493
    MOJOSHADER_free f = effect->free;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   494
    void *d = effect->malloc_data;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   495
    int i, j;
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   496
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   497
    for (i = 0; i < effect->error_count; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   498
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   499
        f((void *) effect->errors[i].error, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   500
        f((void *) effect->errors[i].filename, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   501
    } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   502
    f((void *) effect->errors, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   503
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   504
    f((void *) effect->profile, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   505
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   506
    for (i = 0; i < effect->technique_count; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   507
    {
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   508
        MOJOSHADER_effectTechnique *technique = &effect->techniques[i];
1021
cad933999680 Fixed memory leak in MOJOSHADER_freeEffect().
Ryan C. Gordon <icculus@icculus.org>
parents: 1019
diff changeset
   509
        f((void *) technique->name, d);
1019
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   510
        for (j = 0; j < technique->pass_count; j++)
1021
cad933999680 Fixed memory leak in MOJOSHADER_freeEffect().
Ryan C. Gordon <icculus@icculus.org>
parents: 1019
diff changeset
   511
        {
cad933999680 Fixed memory leak in MOJOSHADER_freeEffect().
Ryan C. Gordon <icculus@icculus.org>
parents: 1019
diff changeset
   512
            f((void *) technique->passes[j].name, d);
1019
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   513
            f(technique->passes[j].states, d);
1021
cad933999680 Fixed memory leak in MOJOSHADER_freeEffect().
Ryan C. Gordon <icculus@icculus.org>
parents: 1019
diff changeset
   514
        } // for
1019
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   515
        f(technique->passes, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   516
    } // for
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   517
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   518
    f(effect->techniques, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   519
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   520
    for (i = 0; i < effect->texture_count; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   521
        f((void *) effect->textures[i].name, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   522
    f(effect->textures, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   523
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   524
    for (i = 0; i < effect->shader_count; i++)
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   525
        MOJOSHADER_freeParseData(effect->shaders[i].shader);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   526
    f(effect->shaders, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   527
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   528
    f(effect, d);
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   529
} // MOJOSHADER_freeEffect
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   530
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   531
// end of mojoshader_effects.c ...
e8988ca01c6d Initial work on parsing binary Effects files.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   532