mojoshader_internal.h
author Ryan C. Gordon <icculus@icculus.org>
Sat, 20 Dec 2008 05:48:38 -0500
changeset 524 03eea2f0762c
parent 523 699696afd731
child 542 a56d3bfd2e36
permissions -rw-r--r--
First (incomplete!) shot at more robust CTAB support. Assembler can now add it, but we still need to parse it better and report it all back to the app in MOJOSHADER_parse().
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
464
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
#ifndef _INCLUDE_MOJOSHADER_INTERNAL_H_
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
#define _INCLUDE_MOJOSHADER_INTERNAL_H_
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
#ifndef __MOJOSHADER_INTERNAL__
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
#error Do not include this header from your applications.
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
// Shader bytecode format is described at MSDN:
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
//  http://msdn2.microsoft.com/en-us/library/ms800307.aspx
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
#include <stdio.h>
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
#include <string.h>
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
#include <stdlib.h>
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
#include <stdarg.h>
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
#include <assert.h>
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
#include "mojoshader.h"
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
#if (defined(__APPLE__) && defined(__MACH__))
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
#define PLATFORM_MACOSX 1
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
// This is the highest shader version we currently support.
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
#define MAX_SHADER_MAJOR 3
493
e2c930ab84b5 Allow SM3 shaders that are vs_3_x or vs_3_sw.
Ryan C. Gordon <icculus@icculus.org>
parents: 491
diff changeset
    26
#define MAX_SHADER_MINOR 255  // vs_3_sw
464
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
// If SUPPORT_PROFILE_* isn't defined, we assume an implicit desire to support.
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
//  You get all the profiles unless you go out of your way to disable them.
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
#ifndef SUPPORT_PROFILE_D3D
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
#define SUPPORT_PROFILE_D3D 1
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
#ifndef SUPPORT_PROFILE_PASSTHROUGH
484
dfce8e965115 s/PASSTHROUGH/BYTECODE that I missed.
Ryan C. Gordon <icculus@icculus.org>
parents: 470
diff changeset
    37
#define SUPPORT_PROFILE_BYTECODE 1
464
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
#ifndef SUPPORT_PROFILE_GLSL
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
#define SUPPORT_PROFILE_GLSL 1
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
#ifndef SUPPORT_PROFILE_ARB1
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
#define SUPPORT_PROFILE_ARB1 1
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
// Get basic wankery out of the way here...
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
#ifdef _WINDOWS
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
#define ENDLINE_STR "\r\n"
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
#else
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
#define ENDLINE_STR "\n";
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
typedef unsigned int uint;  // this is a printf() helper. don't use for code.
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
#ifdef _MSC_VER
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
#include <malloc.h>
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
#define snprintf _snprintf
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
    62
#define strcasecmp stricmp
464
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
typedef unsigned __int8 uint8;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
typedef unsigned __int16 uint16;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
typedef unsigned __int32 uint32;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
typedef __int32 int32;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
// Warning Level 4 considered harmful.  :)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
#pragma warning(disable: 4100)  // "unreferenced formal parameter"
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
#pragma warning(disable: 4389)  // "signed/unsigned mismatch"
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
#else
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
#include <stdint.h>
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
typedef uint8_t uint8;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
typedef uint16_t uint16;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
typedef uint32_t uint32;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
typedef int32_t int32;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
#ifdef __GNUC__
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
#define ISPRINTF(x,y) __attribute__((format (printf, x, y)))
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
#else
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
#define ISPRINTF(x,y)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
#define STATICARRAYLEN(x) ( (sizeof ((x))) / (sizeof ((x)[0])) )
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
// Special-case return values from the parsing pipeline...
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
#define FAIL (-1)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
#define NOFAIL (-2)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
#define END_OF_STREAM (-3)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
// Byteswap magic...
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
#if ((defined __GNUC__) && (defined __POWERPC__))
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
    static inline uint32 SWAP32(uint32 x)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
    {
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
        __asm__ __volatile__("lwbrx %0,0,%1" : "=r" (x) : "r" (&x));
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
        return x;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
    } // SWAP32
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
    static inline uint16 SWAP16(uint16 x)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
    {
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
        __asm__ __volatile__("lhbrx %0,0,%1" : "=r" (x) : "r" (&x));
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
        return x;
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
    } // SWAP16
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
#elif defined(__POWERPC__)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
    static inline uint32 SWAP32(uint32 x)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
    {
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
        return ( (((x) >> 24) & 0x000000FF) | (((x) >>  8) & 0x0000FF00) |
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
                 (((x) <<  8) & 0x00FF0000) | (((x) << 24) & 0xFF000000) );
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
    } // SWAP32
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
    static inline uint16 SWAP16(uint16 x)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
    {
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
        return ( (((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00) );
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
    } // SWAP16
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
#else
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
#   define SWAP16(x) (x)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
#   define SWAP32(x) (x)
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
#endif
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
524
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   120
// This is the ID for a D3DXSHADER_CONSTANTTABLE in the bytecode comments.
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   121
#define CTAB_ID 0x42415443  // 0x42415443 == 'CTAB'
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   122
#define CTAB_SIZE 28  // sizeof (D3DXSHADER_CONSTANTTABLE).
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   123
#define CINFO_SIZE 20  // sizeof (D3DXSHADER_CONSTANTINFO).
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   124
#define CTYPEINFO_SIZE 16  // sizeof (D3DXSHADER_TYPEINFO).
03eea2f0762c First (incomplete!) shot at more robust CTAB support.
Ryan C. Gordon <icculus@icculus.org>
parents: 523
diff changeset
   125
#define CMEMBERINFO_SIZE 8  // sizeof (D3DXSHADER_STRUCTMEMBERINFO)
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   126
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   127
// we need to reference these by explicit value occasionally...
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   128
#define OPCODE_RET 28
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   129
#define OPCODE_IFC 41
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   130
#define OPCODE_BREAKC 45
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   131
519
c9b27381c971 Added TEXLDP/TEXLDP support to the assembler, cleaned up constants.
Ryan C. Gordon <icculus@icculus.org>
parents: 493
diff changeset
   132
// TEXLD becomes a different instruction with these instruction controls.
c9b27381c971 Added TEXLDP/TEXLDP support to the assembler, cleaned up constants.
Ryan C. Gordon <icculus@icculus.org>
parents: 493
diff changeset
   133
#define CONTROL_TEXLD  0
c9b27381c971 Added TEXLDP/TEXLDP support to the assembler, cleaned up constants.
Ryan C. Gordon <icculus@icculus.org>
parents: 493
diff changeset
   134
#define CONTROL_TEXLDP 1
c9b27381c971 Added TEXLDP/TEXLDP support to the assembler, cleaned up constants.
Ryan C. Gordon <icculus@icculus.org>
parents: 493
diff changeset
   135
#define CONTROL_TEXLDB 2
c9b27381c971 Added TEXLDP/TEXLDP support to the assembler, cleaned up constants.
Ryan C. Gordon <icculus@icculus.org>
parents: 493
diff changeset
   136
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   137
// #define this to force app to supply an allocator, so there's no reference
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   138
//  to the C runtime's malloc() and free()...
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   139
#if MOJOSHADER_FORCE_ALLOCATOR
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   140
#define internal_malloc NULL
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   141
#define internal_free NULL
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   142
#else
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   143
static void *internal_malloc(int bytes, void *d) { return malloc(bytes); }
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   144
static void internal_free(void *ptr, void *d) { free(ptr); }
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   145
#endif
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   146
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   147
// result modifiers.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   148
// !!! FIXME: why isn't this an enum?
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   149
#define MOD_SATURATE 0x01
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   150
#define MOD_PP 0x02
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   151
#define MOD_CENTROID 0x04
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   152
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   153
typedef enum
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   154
{
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   155
    REG_TYPE_TEMP = 0,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   156
    REG_TYPE_INPUT = 1,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   157
    REG_TYPE_CONST = 2,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   158
    REG_TYPE_ADDRESS = 3,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   159
    REG_TYPE_TEXTURE = 3,  // ALSO 3!
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   160
    REG_TYPE_RASTOUT = 4,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   161
    REG_TYPE_ATTROUT = 5,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   162
    REG_TYPE_TEXCRDOUT = 6,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   163
    REG_TYPE_OUTPUT = 6,  // ALSO 6!
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   164
    REG_TYPE_CONSTINT = 7,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   165
    REG_TYPE_COLOROUT = 8,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   166
    REG_TYPE_DEPTHOUT = 9,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   167
    REG_TYPE_SAMPLER = 10,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   168
    REG_TYPE_CONST2 = 11,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   169
    REG_TYPE_CONST3 = 12,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   170
    REG_TYPE_CONST4 = 13,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   171
    REG_TYPE_CONSTBOOL = 14,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   172
    REG_TYPE_LOOP = 15,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   173
    REG_TYPE_TEMPFLOAT16 = 16,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   174
    REG_TYPE_MISCTYPE = 17,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   175
    REG_TYPE_LABEL = 18,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   176
    REG_TYPE_PREDICATE = 19,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   177
    REG_TYPE_MAX = 19
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   178
} RegisterType;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   179
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   180
typedef enum
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   181
{
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   182
    TEXTURE_TYPE_2D = 2,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   183
    TEXTURE_TYPE_CUBE = 3,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   184
    TEXTURE_TYPE_VOLUME = 4,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   185
} TextureType;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   186
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   187
typedef enum
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   188
{
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   189
    RASTOUT_TYPE_POSITION = 0,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   190
    RASTOUT_TYPE_FOG = 1,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   191
    RASTOUT_TYPE_POINT_SIZE = 2,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   192
    RASTOUT_TYPE_MAX = 2
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   193
} RastOutType;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   194
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   195
typedef enum
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   196
{
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   197
    MISCTYPE_TYPE_POSITION = 0,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   198
    MISCTYPE_TYPE_FACE = 1,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   199
    MISCTYPE_TYPE_MAX = 1
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   200
} MiscTypeType;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   201
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   202
// source modifiers.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   203
typedef enum
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   204
{
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   205
    SRCMOD_NONE,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   206
    SRCMOD_NEGATE,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   207
    SRCMOD_BIAS,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   208
    SRCMOD_BIASNEGATE,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   209
    SRCMOD_SIGN,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   210
    SRCMOD_SIGNNEGATE,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   211
    SRCMOD_COMPLEMENT,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   212
    SRCMOD_X2,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   213
    SRCMOD_X2NEGATE,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   214
    SRCMOD_DZ,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   215
    SRCMOD_DW,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   216
    SRCMOD_ABS,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   217
    SRCMOD_ABSNEGATE,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   218
    SRCMOD_NOT,
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   219
    SRCMOD_TOTAL
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   220
} SourceMod;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   221
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   222
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   223
typedef struct
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   224
{
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   225
    const uint32 *token;   // this is the unmolested token in the stream.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   226
    int regnum;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   227
    int relative;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   228
    int writemask;   // xyzw or rgba (all four, not split out).
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   229
    int writemask0;  // x or red
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   230
    int writemask1;  // y or green
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   231
    int writemask2;  // z or blue
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   232
    int writemask3;  // w or alpha
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   233
    int orig_writemask;   // writemask before mojoshader tweaks it.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   234
    int result_mod;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   235
    int result_shift;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   236
    RegisterType regtype;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   237
} DestArgInfo;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   238
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   239
491
bcc3c215807a Fixed wrong data from scalar_register().
Ryan C. Gordon <icculus@icculus.org>
parents: 484
diff changeset
   240
static inline int scalar_register(const MOJOSHADER_shaderType shader_type,
bcc3c215807a Fixed wrong data from scalar_register().
Ryan C. Gordon <icculus@icculus.org>
parents: 484
diff changeset
   241
                                  const RegisterType regtype, const int regnum)
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   242
{
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   243
    switch (regtype)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   244
    {
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   245
        case REG_TYPE_DEPTHOUT:
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   246
        case REG_TYPE_CONSTBOOL:
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   247
        case REG_TYPE_LOOP:
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   248
            return 1;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   249
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   250
        case REG_TYPE_MISCTYPE:
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   251
            if ( ((const MiscTypeType) regnum) == MISCTYPE_TYPE_FACE )
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   252
                return 1;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   253
            return 0;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   254
491
bcc3c215807a Fixed wrong data from scalar_register().
Ryan C. Gordon <icculus@icculus.org>
parents: 484
diff changeset
   255
        case REG_TYPE_PREDICATE:
bcc3c215807a Fixed wrong data from scalar_register().
Ryan C. Gordon <icculus@icculus.org>
parents: 484
diff changeset
   256
            return (shader_type == MOJOSHADER_TYPE_PIXEL) ? 1 : 0;
bcc3c215807a Fixed wrong data from scalar_register().
Ryan C. Gordon <icculus@icculus.org>
parents: 484
diff changeset
   257
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   258
        default: break;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   259
    } // switch
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   260
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   261
    return 0;
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   262
} // scalar_register
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   263
523
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 520
diff changeset
   264
typedef enum
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 520
diff changeset
   265
{
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 520
diff changeset
   266
    MOJOSHADER_PARSEPHASE_NOTSTARTED,
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 520
diff changeset
   267
    MOJOSHADER_PARSEPHASE_WORKING,
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 520
diff changeset
   268
    MOJOSHADER_PARSEPHASE_DONE,
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 520
diff changeset
   269
} MOJOSHADER_parsePhase;
699696afd731 Allow errors to specify post-processing problems.
Ryan C. Gordon <icculus@icculus.org>
parents: 520
diff changeset
   270
470
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 468
diff changeset
   271
extern MOJOSHADER_parseData out_of_mem_data;
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 468
diff changeset
   272
extern const char *out_of_mem_str;
7d84d3452125 Bunch More Work on the assembler.
Ryan C. Gordon <icculus@icculus.org>
parents: 468
diff changeset
   273
464
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
#endif  // _INCLUDE_MOJOSHADER_INTERNAL_H_
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   276
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   277
#if MOJOSHADER_DO_INSTRUCTION_TABLE
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   278
// These have to be in the right order! Arrays are indexed by the value
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   279
//  of the instruction token.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   280
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   281
// INSTRUCTION_STATE means this opcode has to update the state machine
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   282
//  (we're entering an ELSE block, etc). INSTRUCTION means there's no
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   283
//  state, just go straight to the emitters.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   284
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   285
// !!! FIXME: Some of these MOJOSHADER_TYPE_ANYs need to have their scope
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   286
// !!! FIXME:  reduced to just PIXEL or VERTEX.
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   287
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   288
INSTRUCTION(NOP, "NOP", 1, NULL, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   289
INSTRUCTION(MOV, "MOV", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   290
INSTRUCTION(ADD, "ADD", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   291
INSTRUCTION(SUB, "SUB", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   292
INSTRUCTION(MAD, "MAD", 1, DSSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   293
INSTRUCTION(MUL, "MUL", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   294
INSTRUCTION_STATE(RCP, "RCP", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   295
INSTRUCTION(RSQ, "RSQ", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   296
INSTRUCTION(DP3, "DP3", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   297
INSTRUCTION_STATE(DP4, "DP4", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   298
INSTRUCTION(MIN, "MIN", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   299
INSTRUCTION(MAX, "MAX", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   300
INSTRUCTION(SLT, "SLT", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   301
INSTRUCTION(SGE, "SGE", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   302
INSTRUCTION(EXP, "EXP", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   303
INSTRUCTION_STATE(LOG, "LOG", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   304
INSTRUCTION(LIT, "LIT", 3, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   305
INSTRUCTION(DST, "DST", 1, DSS, MOJOSHADER_TYPE_VERTEX)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   306
INSTRUCTION(LRP, "LRP", 2, DSSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   307
INSTRUCTION_STATE(FRC, "FRC", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   308
INSTRUCTION_STATE(M4X4, "M4X4", 4, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   309
INSTRUCTION_STATE(M4X3, "M4X3", 3, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   310
INSTRUCTION_STATE(M3X4, "M3X4", 4, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   311
INSTRUCTION_STATE(M3X3, "M3X3", 3, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   312
INSTRUCTION_STATE(M3X2, "M3X2", 2, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   313
INSTRUCTION_STATE(CALL, "CALL", 2, S, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   314
INSTRUCTION_STATE(CALLNZ, "CALLNZ", 3, SS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   315
INSTRUCTION_STATE(LOOP, "LOOP", 3, SS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   316
INSTRUCTION_STATE(RET, "RET", 1, NULL, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   317
INSTRUCTION_STATE(ENDLOOP, "ENDLOOP", 2, NULL, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   318
INSTRUCTION_STATE(LABEL, "LABEL", 0, S, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   319
INSTRUCTION_STATE(DCL, "DCL", 0, DCL, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   320
INSTRUCTION_STATE(POW, "POW", 3, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   321
INSTRUCTION(CRS, "CRS", 2, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   322
INSTRUCTION(SGN, "SGN", 3, DSSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   323
INSTRUCTION(ABS, "ABS", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   324
INSTRUCTION(NRM, "NRM", 3, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   325
INSTRUCTION_STATE(SINCOS, "SINCOS", 8, SINCOS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   326
INSTRUCTION_STATE(REP, "REP", 3, S, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   327
INSTRUCTION_STATE(ENDREP, "ENDREP", 2, NULL, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   328
INSTRUCTION_STATE(IF, "IF", 3, S, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   329
INSTRUCTION_STATE(IFC, "IF", 3, SS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   330
INSTRUCTION(ELSE, "ELSE", 1, NULL, MOJOSHADER_TYPE_ANY)  // !!! FIXME: state!
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   331
INSTRUCTION(ENDIF, "ENDIF", 1, NULL, MOJOSHADER_TYPE_ANY) // !!! FIXME: state!
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   332
INSTRUCTION_STATE(BREAK, "BREAK", 1, NULL, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   333
INSTRUCTION_STATE(BREAKC, "BREAK", 3, SS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   334
INSTRUCTION_STATE(MOVA, "MOVA", 1, DS, MOJOSHADER_TYPE_VERTEX)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   335
INSTRUCTION_STATE(DEFB, "DEFB", 0, DEFB, MOJOSHADER_TYPE_ANY)
467
577a9d07b6bf DEFI has its own parse_args() now.
Ryan C. Gordon <icculus@icculus.org>
parents: 465
diff changeset
   336
INSTRUCTION_STATE(DEFI, "DEFI", 0, DEFI, MOJOSHADER_TYPE_ANY)
465
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   337
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   338
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   339
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   340
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   341
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   342
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   343
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   344
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   345
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   346
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   347
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   348
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   349
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   350
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   351
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   352
INSTRUCTION_STATE(TEXCRD, "TEXCRD", 1, TEXCRD, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   353
INSTRUCTION_STATE(TEXKILL, "TEXKILL", 2, D, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   354
INSTRUCTION_STATE(TEXLD, "TEXLD", 1, TEXLD, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   355
INSTRUCTION(TEXBEM, "TEXBEM", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   356
INSTRUCTION(TEXBEML, "TEXBEML", 2, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   357
INSTRUCTION(TEXREG2AR, "TEXREG2AR", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   358
INSTRUCTION(TEXREG2GB, "TEXREG2GB", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   359
INSTRUCTION(TEXM3X2PAD, "TEXM3X2PAD", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   360
INSTRUCTION(TEXM3X2TEX, "TEXM3X2TEX", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   361
INSTRUCTION(TEXM3X3PAD, "TEXM3X3PAD", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   362
INSTRUCTION(TEXM3X3TEX, "TEXM3X3TEX", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   363
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   364
INSTRUCTION(TEXM3X3SPEC, "TEXM3X3SPEC", 1, DSS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   365
INSTRUCTION(TEXM3X3VSPEC, "TEXM3X3VSPEC", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   366
INSTRUCTION(EXPP, "EXPP", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   367
INSTRUCTION_STATE(LOGP, "LOGP", 1, DS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   368
INSTRUCTION_STATE(CND, "CND", 1, DSSS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   369
INSTRUCTION_STATE(DEF, "DEF", 0, DEF, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   370
INSTRUCTION(TEXREG2RGB, "TEXREG2RGB", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   371
INSTRUCTION(TEXDP3TEX, "TEXDP3TEX", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   372
INSTRUCTION(TEXM3X2DEPTH, "TEXM3X2DEPTH", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   373
INSTRUCTION(TEXDP3, "TEXDP3", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   374
INSTRUCTION(TEXM3X3, "TEXM3X3", 1, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   375
INSTRUCTION(TEXDEPTH, "TEXDEPTH", 1, D, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   376
INSTRUCTION_STATE(CMP, "CMP", 1, DSSS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   377
INSTRUCTION(BEM, "BEM", 2, DSS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   378
INSTRUCTION_STATE(DP2ADD, "DP2ADD", 2, DSSS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   379
INSTRUCTION(DSX, "DSX", 2, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   380
INSTRUCTION(DSY, "DSY", 2, DS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   381
INSTRUCTION(TEXLDD, "TEXLDD", 3, DSSSS, MOJOSHADER_TYPE_PIXEL)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   382
INSTRUCTION_STATE(SETP, "SETP", 1, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   383
INSTRUCTION_STATE(TEXLDL, "TEXLDL", 2, DSS, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   384
INSTRUCTION_STATE(BREAKP, "BREAKP", 3, S, MOJOSHADER_TYPE_ANY)
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   385
#endif
0a75f98f785b Initial work on assembler. Not even close to done.
Ryan C. Gordon <icculus@icculus.org>
parents: 464
diff changeset
   386
464
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
// end of mojoshader_internal.h ...
eba4cf79437f Moved some common stuff to mojoshader_internal.h ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388