1 #ifndef _INCLUDE_MOJOSHADER_INTERNAL_H_
2 #define _INCLUDE_MOJOSHADER_INTERNAL_H_
3
4 #ifndef __MOJOSHADER_INTERNAL__
5 #error Do not include this header from your applications.
6 #endif
7
8 // Shader bytecode format is described at MSDN:
9 // http://msdn.microsoft.com/en-us/library/ff569705.aspx
10
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdlib.h>
14 #include <stdarg.h>
15 #include <assert.h>
16
17 #include "mojoshader.h"
18
19 #define DEBUG_LEXER 0
20 #define DEBUG_PREPROCESSOR 0
21 #define DEBUG_ASSEMBLER_PARSER 0
22 #define DEBUG_COMPILER_PARSER 0
23 #define DEBUG_TOKENIZER \
24 (DEBUG_PREPROCESSOR || DEBUG_ASSEMBLER_PARSER || DEBUG_LEXER)
25
26 #if (defined(__APPLE__) && defined(__MACH__))
27 #define PLATFORM_MACOSX 1
28 #endif
29
30 // This is the highest shader version we currently support.
31
32 #define MAX_SHADER_MAJOR 3
33 #define MAX_SHADER_MINOR 255 // vs_3_sw
34
35
36 // If SUPPORT_PROFILE_* isn't defined, we assume an implicit desire to support.
37 // You get all the profiles unless you go out of your way to disable them.
38
39 #ifndef SUPPORT_PROFILE_D3D
40 #define SUPPORT_PROFILE_D3D 1
41 #endif
42
43 #ifndef SUPPORT_PROFILE_BYTECODE
44 #define SUPPORT_PROFILE_BYTECODE 1
45 #endif
46
47 #ifndef SUPPORT_PROFILE_GLSL
48 #define SUPPORT_PROFILE_GLSL 1
49 #endif
50
51 #ifndef SUPPORT_PROFILE_GLSL120
52 #define SUPPORT_PROFILE_GLSL120 1
53 #endif
54
55 #ifndef SUPPORT_PROFILE_ARB1
56 #define SUPPORT_PROFILE_ARB1 1
57 #endif
58
59 #ifndef SUPPORT_PROFILE_ARB1_NV
60 #define SUPPORT_PROFILE_ARB1_NV 1
61 #endif
62
63 #if SUPPORT_PROFILE_ARB1_NV && !SUPPORT_PROFILE_ARB1
64 #error nv profiles require arb1 profile. Fix your build.
65 #endif
66
67 #if SUPPORT_PROFILE_GLSL120 && !SUPPORT_PROFILE_GLSL
68 #error glsl120 profile requires glsl profile. Fix your build.
69 #endif
70
71
72 // Other stuff you can disable...
73
74 // This removes the preshader parsing and execution code. You can save some
75 // bytes if you have normal shaders and not Effect files.
76 #ifndef SUPPORT_PRESHADERS
77 #define SUPPORT_PRESHADERS 1
78 #endif
79
80 #if SUPPORT_PRESHADERS
81 void MOJOSHADER_runPreshader(const MOJOSHADER_preshader*, const float*, float*);
82 #else
83 #define MOJOSHADER_runPreshader(a, b)
84 #endif
85
86
87 // Get basic wankery out of the way here...
88
89 #ifdef _WINDOWS
90 #define ENDLINE_STR "\r\n"
91 #else
92 #define ENDLINE_STR "\n"
93 #endif
94
95 typedef unsigned int uint; // this is a printf() helper. don't use for code.
96
97 #ifdef _MSC_VER
98 #include <malloc.h>
99 #define va_copy(a, b) a = b
100 #define snprintf _snprintf // !!! FIXME: not a safe replacement!
101 #define vsnprintf _vsnprintf // !!! FIXME: not a safe replacement!
102 #define strcasecmp stricmp
103 #define strncasecmp strnicmp
104 typedef unsigned __int8 uint8;
105 typedef unsigned __int16 uint16;
106 typedef unsigned __int32 uint32;
107 typedef unsigned __int64 uint64;
108 typedef __int32 int32;
109 typedef __int64 int64;
110 #ifdef _WIN64
111 typedef __int64 ssize_t;
112 #elif defined _WIN32
113 typedef __int32 ssize_t;
114 #else
115 #error Please define your platform.
116 #endif
117 // Warning Level 4 considered harmful. :)
118 #pragma warning(disable: 4100) // "unreferenced formal parameter"
119 #pragma warning(disable: 4389) // "signed/unsigned mismatch"
120 #else
121 #include <stdint.h>
122 typedef uint8_t uint8;
123 typedef uint16_t uint16;
124 typedef uint32_t uint32;
125 typedef int32_t int32;
126 typedef int64_t int64;
127 typedef uint64_t uint64;
128 #endif
129
130 #ifdef sun
131 #include <alloca.h>
132 #endif
133
134 #ifdef __GNUC__
135 #define ISPRINTF(x,y) __attribute__((format (printf, x, y)))
136 #else
137 #define ISPRINTF(x,y)
138 #endif
139
140 #define STATICARRAYLEN(x) ( (sizeof ((x))) / (sizeof ((x)[0])) )
141
142
143 // Byteswap magic...
144
145 #if ((defined __GNUC__) && (defined __POWERPC__))
SWAP32(uint32 x)146 static inline uint32 SWAP32(uint32 x)
147 {
148 __asm__ __volatile__("lwbrx %0,0,%1" : "=r" (x) : "r" (&x));
149 return x;
150 } // SWAP32
SWAP16(uint16 x)151 static inline uint16 SWAP16(uint16 x)
152 {
153 __asm__ __volatile__("lhbrx %0,0,%1" : "=r" (x) : "r" (&x));
154 return x;
155 } // SWAP16
156 #elif defined(__POWERPC__)
SWAP32(uint32 x)157 static inline uint32 SWAP32(uint32 x)
158 {
159 return ( (((x) >> 24) & 0x000000FF) | (((x) >> 8) & 0x0000FF00) |
160 (((x) << 8) & 0x00FF0000) | (((x) << 24) & 0xFF000000) );
161 } // SWAP32
SWAP16(uint16 x)162 static inline uint16 SWAP16(uint16 x)
163 {
164 return ( (((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00) );
165 } // SWAP16
166 #else
167 # define SWAP16(x) (x)
168 # define SWAP32(x) (x)
169 #endif
170
171 #define SWAPDBL(x) (x) // !!! FIXME
172
Min(const int a,const int b)173 static inline int Min(const int a, const int b)
174 {
175 return ((a < b) ? a : b);
176 } // Min
177
178
179 // Hashtables...
180
181 typedef struct HashTable HashTable;
182 typedef uint32 (*HashTable_HashFn)(const void *key, void *data);
183 typedef int (*HashTable_KeyMatchFn)(const void *a, const void *b, void *data);
184 typedef void (*HashTable_NukeFn)(const void *key, const void *value, void *data);
185
186 HashTable *hash_create(void *data, const HashTable_HashFn hashfn,
187 const HashTable_KeyMatchFn keymatchfn,
188 const HashTable_NukeFn nukefn,
189 const int stackable,
190 MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
191 void hash_destroy(HashTable *table);
192 int hash_insert(HashTable *table, const void *key, const void *value);
193 int hash_remove(HashTable *table, const void *key);
194 int hash_find(const HashTable *table, const void *key, const void **_value);
195 int hash_iter(const HashTable *table, const void *key, const void **_value, void **iter);
196 int hash_iter_keys(const HashTable *table, const void **_key, void **iter);
197
198 uint32 hash_hash_string(const void *sym, void *unused);
199 int hash_keymatch_string(const void *a, const void *b, void *unused);
200
201
202 // String -> String map ...
203 typedef HashTable StringMap;
204 StringMap *stringmap_create(const int copy, MOJOSHADER_malloc m,
205 MOJOSHADER_free f, void *d);
206 void stringmap_destroy(StringMap *smap);
207 int stringmap_insert(StringMap *smap, const char *key, const char *value);
208 int stringmap_remove(StringMap *smap, const char *key);
209 int stringmap_find(const StringMap *smap, const char *key, const char **_val);
210
211
212 // String caching...
213
214 typedef struct StringCache StringCache;
215 StringCache *stringcache_create(MOJOSHADER_malloc m,MOJOSHADER_free f,void *d);
216 const char *stringcache(StringCache *cache, const char *str);
217 const char *stringcache_len(StringCache *cache, const char *str,
218 const unsigned int len);
219 const char *stringcache_fmt(StringCache *cache, const char *fmt, ...);
220 void stringcache_destroy(StringCache *cache);
221
222
223 // Error lists...
224
225 typedef struct ErrorList ErrorList;
226 ErrorList *errorlist_create(MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
227 int errorlist_add(ErrorList *list, const char *fname,
228 const int errpos, const char *str);
229 int errorlist_add_fmt(ErrorList *list, const char *fname,
230 const int errpos, const char *fmt, ...) ISPRINTF(4,5);
231 int errorlist_add_va(ErrorList *list, const char *_fname,
232 const int errpos, const char *fmt, va_list va);
233 int errorlist_count(ErrorList *list);
234 MOJOSHADER_error *errorlist_flatten(ErrorList *list); // resets the list!
235 void errorlist_destroy(ErrorList *list);
236
237
238
239 // Dynamic buffers...
240
241 typedef struct Buffer Buffer;
242 Buffer *buffer_create(size_t blksz,MOJOSHADER_malloc m,MOJOSHADER_free f,void *d);
243 char *buffer_reserve(Buffer *buffer, const size_t len);
244 int buffer_append(Buffer *buffer, const void *_data, size_t len);
245 int buffer_append_fmt(Buffer *buffer, const char *fmt, ...) ISPRINTF(2,3);
246 int buffer_append_va(Buffer *buffer, const char *fmt, va_list va);
247 size_t buffer_size(Buffer *buffer);
248 void buffer_empty(Buffer *buffer);
249 char *buffer_flatten(Buffer *buffer);
250 char *buffer_merge(Buffer **buffers, const size_t n, size_t *_len);
251 void buffer_destroy(Buffer *buffer);
252 ssize_t buffer_find(Buffer *buffer, const size_t start,
253 const void *data, const size_t len);
254
255
256
257 // This is the ID for a D3DXSHADER_CONSTANTTABLE in the bytecode comments.
258 #define CTAB_ID 0x42415443 // 0x42415443 == 'CTAB'
259 #define CTAB_SIZE 28 // sizeof (D3DXSHADER_CONSTANTTABLE).
260 #define CINFO_SIZE 20 // sizeof (D3DXSHADER_CONSTANTINFO).
261 #define CTYPEINFO_SIZE 16 // sizeof (D3DXSHADER_TYPEINFO).
262 #define CMEMBERINFO_SIZE 8 // sizeof (D3DXSHADER_STRUCTMEMBERINFO)
263
264 // Preshader magic values...
265 #define PRES_ID 0x53455250 // 0x53455250 == 'PRES'
266 #define PRSI_ID 0x49535250 // 0x49535250 == 'PRSI'
267 #define CLIT_ID 0x54494C43 // 0x54494C43 == 'CLIT'
268 #define FXLC_ID 0x434C5846 // 0x434C5846 == 'FXLC'
269
270 // we need to reference these by explicit value occasionally...
271 #define OPCODE_RET 28
272 #define OPCODE_IF 40
273 #define OPCODE_IFC 41
274 #define OPCODE_BREAK 44
275 #define OPCODE_BREAKC 45
276 #define OPCODE_TEXLD 66
277 #define OPCODE_SETP 94
278
279 // TEXLD becomes a different instruction with these instruction controls.
280 #define CONTROL_TEXLD 0
281 #define CONTROL_TEXLDP 1
282 #define CONTROL_TEXLDB 2
283
284 // #define this to force app to supply an allocator, so there's no reference
285 // to the C runtime's malloc() and free()...
286 #if MOJOSHADER_FORCE_ALLOCATOR
287 #define MOJOSHADER_internal_malloc NULL
288 #define MOJOSHADER_internal_free NULL
289 #else
290 void *MOJOSHADER_internal_malloc(int bytes, void *d);
291 void MOJOSHADER_internal_free(void *ptr, void *d);
292 #endif
293
294 #if MOJOSHADER_FORCE_INCLUDE_CALLBACKS
295 #define MOJOSHADER_internal_include_open NULL
296 #define MOJOSHADER_internal_include_close NULL
297 #else
298 int MOJOSHADER_internal_include_open(MOJOSHADER_includeType inctype,
299 const char *fname, const char *parent,
300 const char **outdata,
301 unsigned int *outbytes,
302 MOJOSHADER_malloc m, MOJOSHADER_free f,
303 void *d);
304
305 void MOJOSHADER_internal_include_close(const char *data, MOJOSHADER_malloc m,
306 MOJOSHADER_free f, void *d);
307 #endif
308
309
310 // result modifiers.
311 // !!! FIXME: why isn't this an enum?
312 #define MOD_SATURATE 0x01
313 #define MOD_PP 0x02
314 #define MOD_CENTROID 0x04
315
316 typedef enum
317 {
318 REG_TYPE_TEMP = 0,
319 REG_TYPE_INPUT = 1,
320 REG_TYPE_CONST = 2,
321 REG_TYPE_ADDRESS = 3,
322 REG_TYPE_TEXTURE = 3, // ALSO 3!
323 REG_TYPE_RASTOUT = 4,
324 REG_TYPE_ATTROUT = 5,
325 REG_TYPE_TEXCRDOUT = 6,
326 REG_TYPE_OUTPUT = 6, // ALSO 6!
327 REG_TYPE_CONSTINT = 7,
328 REG_TYPE_COLOROUT = 8,
329 REG_TYPE_DEPTHOUT = 9,
330 REG_TYPE_SAMPLER = 10,
331 REG_TYPE_CONST2 = 11,
332 REG_TYPE_CONST3 = 12,
333 REG_TYPE_CONST4 = 13,
334 REG_TYPE_CONSTBOOL = 14,
335 REG_TYPE_LOOP = 15,
336 REG_TYPE_TEMPFLOAT16 = 16,
337 REG_TYPE_MISCTYPE = 17,
338 REG_TYPE_LABEL = 18,
339 REG_TYPE_PREDICATE = 19,
340 REG_TYPE_MAX = 19
341 } RegisterType;
342
343 typedef enum
344 {
345 TEXTURE_TYPE_2D = 2,
346 TEXTURE_TYPE_CUBE = 3,
347 TEXTURE_TYPE_VOLUME = 4,
348 } TextureType;
349
350 typedef enum
351 {
352 RASTOUT_TYPE_POSITION = 0,
353 RASTOUT_TYPE_FOG = 1,
354 RASTOUT_TYPE_POINT_SIZE = 2,
355 RASTOUT_TYPE_MAX = 2
356 } RastOutType;
357
358 typedef enum
359 {
360 MISCTYPE_TYPE_POSITION = 0,
361 MISCTYPE_TYPE_FACE = 1,
362 MISCTYPE_TYPE_MAX = 1
363 } MiscTypeType;
364
365 // source modifiers.
366 typedef enum
367 {
368 SRCMOD_NONE,
369 SRCMOD_NEGATE,
370 SRCMOD_BIAS,
371 SRCMOD_BIASNEGATE,
372 SRCMOD_SIGN,
373 SRCMOD_SIGNNEGATE,
374 SRCMOD_COMPLEMENT,
375 SRCMOD_X2,
376 SRCMOD_X2NEGATE,
377 SRCMOD_DZ,
378 SRCMOD_DW,
379 SRCMOD_ABS,
380 SRCMOD_ABSNEGATE,
381 SRCMOD_NOT,
382 SRCMOD_TOTAL
383 } SourceMod;
384
385
386 typedef struct
387 {
388 const uint32 *token; // this is the unmolested token in the stream.
389 int regnum;
390 int relative;
391 int writemask; // xyzw or rgba (all four, not split out).
392 int writemask0; // x or red
393 int writemask1; // y or green
394 int writemask2; // z or blue
395 int writemask3; // w or alpha
396 int orig_writemask; // writemask before mojoshader tweaks it.
397 int result_mod;
398 int result_shift;
399 RegisterType regtype;
400 } DestArgInfo;
401
402 // NOTE: This will NOT know a dcl_psize or dcl_fog output register should be
403 // scalar! This function doesn't have access to that information.
scalar_register(const MOJOSHADER_shaderType shader_type,const RegisterType regtype,const int regnum)404 static inline int scalar_register(const MOJOSHADER_shaderType shader_type,
405 const RegisterType regtype, const int regnum)
406 {
407 switch (regtype)
408 {
409 case REG_TYPE_RASTOUT:
410 if (((const RastOutType) regnum) == RASTOUT_TYPE_FOG)
411 return 1;
412 else if (((const RastOutType) regnum) == RASTOUT_TYPE_POINT_SIZE)
413 return 1;
414 return 0;
415
416 case REG_TYPE_DEPTHOUT:
417 case REG_TYPE_CONSTBOOL:
418 case REG_TYPE_LOOP:
419 return 1;
420
421 case REG_TYPE_MISCTYPE:
422 if ( ((const MiscTypeType) regnum) == MISCTYPE_TYPE_FACE )
423 return 1;
424 return 0;
425
426 case REG_TYPE_PREDICATE:
427 return (shader_type == MOJOSHADER_TYPE_PIXEL) ? 1 : 0;
428
429 default: break;
430 } // switch
431
432 return 0;
433 } // scalar_register
434
435
436 extern MOJOSHADER_error MOJOSHADER_out_of_mem_error;
437 extern MOJOSHADER_parseData MOJOSHADER_out_of_mem_data;
438
439
440 // preprocessor stuff.
441
442 typedef enum
443 {
444 TOKEN_UNKNOWN = 256, // start past ASCII character values.
445
446 // These are all C-like constructs. Tokens < 256 may be single
447 // chars (like '+' or whatever). These are just multi-char sequences
448 // (like "+=" or whatever).
449 TOKEN_IDENTIFIER,
450 TOKEN_INT_LITERAL,
451 TOKEN_FLOAT_LITERAL,
452 TOKEN_STRING_LITERAL,
453 TOKEN_RSHIFTASSIGN,
454 TOKEN_LSHIFTASSIGN,
455 TOKEN_ADDASSIGN,
456 TOKEN_SUBASSIGN,
457 TOKEN_MULTASSIGN,
458 TOKEN_DIVASSIGN,
459 TOKEN_MODASSIGN,
460 TOKEN_XORASSIGN,
461 TOKEN_ANDASSIGN,
462 TOKEN_ORASSIGN,
463 TOKEN_INCREMENT,
464 TOKEN_DECREMENT,
465 TOKEN_RSHIFT,
466 TOKEN_LSHIFT,
467 TOKEN_ANDAND,
468 TOKEN_OROR,
469 TOKEN_LEQ,
470 TOKEN_GEQ,
471 TOKEN_EQL,
472 TOKEN_NEQ,
473 TOKEN_HASH,
474 TOKEN_HASHHASH,
475
476 // This is returned at the end of input...no more to process.
477 TOKEN_EOI,
478
479 // This is returned for char sequences we think are bogus. You'll have
480 // to judge for yourself. In most cases, you'll probably just fail with
481 // bogus syntax without explicitly checking for this token.
482 TOKEN_BAD_CHARS,
483
484 // This is returned if there's an error condition (the error is returned
485 // as a NULL-terminated string from preprocessor_nexttoken(), instead
486 // of actual token data). You can continue getting tokens after this
487 // is reported. It happens for things like missing #includes, etc.
488 TOKEN_PREPROCESSING_ERROR,
489
490 // These are all caught by the preprocessor. Caller won't ever see them,
491 // except TOKEN_PP_PRAGMA.
492 // They control the preprocessor (#includes new files, etc).
493 TOKEN_PP_INCLUDE,
494 TOKEN_PP_LINE,
495 TOKEN_PP_DEFINE,
496 TOKEN_PP_UNDEF,
497 TOKEN_PP_IF,
498 TOKEN_PP_IFDEF,
499 TOKEN_PP_IFNDEF,
500 TOKEN_PP_ELSE,
501 TOKEN_PP_ELIF,
502 TOKEN_PP_ENDIF,
503 TOKEN_PP_ERROR, // caught, becomes TOKEN_PREPROCESSING_ERROR
504 TOKEN_PP_PRAGMA,
505 TOKEN_INCOMPLETE_COMMENT, // caught, becomes TOKEN_PREPROCESSING_ERROR
506 TOKEN_PP_UNARY_MINUS, // used internally, never returned.
507 TOKEN_PP_UNARY_PLUS, // used internally, never returned.
508 } Token;
509
510
511 // This is opaque.
512 struct Preprocessor;
513 typedef struct Preprocessor Preprocessor;
514
515 typedef struct Conditional
516 {
517 Token type;
518 int linenum;
519 int skipping;
520 int chosen;
521 struct Conditional *next;
522 } Conditional;
523
524 typedef struct Define
525 {
526 const char *identifier;
527 const char *definition;
528 const char *original;
529 const char **parameters;
530 int paramcount;
531 struct Define *next;
532 } Define;
533
534 typedef struct IncludeState
535 {
536 const char *filename;
537 const char *source_base;
538 const char *source;
539 const char *token;
540 unsigned int tokenlen;
541 Token tokenval;
542 int pushedback;
543 const unsigned char *lexer_marker;
544 int report_whitespace;
545 int asm_comments;
546 unsigned int orig_length;
547 unsigned int bytes_left;
548 unsigned int line;
549 Conditional *conditional_stack;
550 MOJOSHADER_includeClose close_callback;
551 struct IncludeState *next;
552 } IncludeState;
553
554 Token preprocessor_lexer(IncludeState *s);
555
556 // This will only fail if the allocator fails, so it doesn't return any
557 // error code...NULL on failure.
558 Preprocessor *preprocessor_start(const char *fname, const char *source,
559 unsigned int sourcelen,
560 MOJOSHADER_includeOpen open_callback,
561 MOJOSHADER_includeClose close_callback,
562 const MOJOSHADER_preprocessorDefine *defines,
563 unsigned int define_count, int asm_comments,
564 MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
565
566 void preprocessor_end(Preprocessor *pp);
567 int preprocessor_outofmemory(Preprocessor *pp);
568 const char *preprocessor_nexttoken(Preprocessor *_ctx,
569 unsigned int *_len, Token *_token);
570 const char *preprocessor_sourcepos(Preprocessor *pp, unsigned int *pos);
571
572
573 void MOJOSHADER_print_debug_token(const char *subsystem, const char *token,
574 const unsigned int tokenlen,
575 const Token tokenval);
576
577 #endif // _INCLUDE_MOJOSHADER_INTERNAL_H_
578
579
580 #if MOJOSHADER_DO_INSTRUCTION_TABLE
581 // These have to be in the right order! Arrays are indexed by the value
582 // of the instruction token.
583
584 // INSTRUCTION_STATE means this opcode has to update the state machine
585 // (we're entering an ELSE block, etc). INSTRUCTION means there's no
586 // state, just go straight to the emitters.
587
588 // !!! FIXME: Some of these MOJOSHADER_TYPE_ANYs need to have their scope
589 // !!! FIXME: reduced to just PIXEL or VERTEX.
590
591 INSTRUCTION(NOP, "NOP", 1, NULL, MOJOSHADER_TYPE_ANY)
592 INSTRUCTION(MOV, "MOV", 1, DS, MOJOSHADER_TYPE_ANY)
593 INSTRUCTION(ADD, "ADD", 1, DSS, MOJOSHADER_TYPE_ANY)
594 INSTRUCTION(SUB, "SUB", 1, DSS, MOJOSHADER_TYPE_ANY)
595 INSTRUCTION(MAD, "MAD", 1, DSSS, MOJOSHADER_TYPE_ANY)
596 INSTRUCTION(MUL, "MUL", 1, DSS, MOJOSHADER_TYPE_ANY)
597 INSTRUCTION_STATE(RCP, "RCP", 1, DS, MOJOSHADER_TYPE_ANY)
598 INSTRUCTION(RSQ, "RSQ", 1, DS, MOJOSHADER_TYPE_ANY)
599 INSTRUCTION(DP3, "DP3", 1, DSS, MOJOSHADER_TYPE_ANY)
600 INSTRUCTION_STATE(DP4, "DP4", 1, DSS, MOJOSHADER_TYPE_ANY)
601 INSTRUCTION(MIN, "MIN", 1, DSS, MOJOSHADER_TYPE_ANY)
602 INSTRUCTION(MAX, "MAX", 1, DSS, MOJOSHADER_TYPE_ANY)
603 INSTRUCTION(SLT, "SLT", 1, DSS, MOJOSHADER_TYPE_ANY)
604 INSTRUCTION(SGE, "SGE", 1, DSS, MOJOSHADER_TYPE_ANY)
605 INSTRUCTION(EXP, "EXP", 1, DS, MOJOSHADER_TYPE_ANY)
606 INSTRUCTION_STATE(LOG, "LOG", 1, DS, MOJOSHADER_TYPE_ANY)
607 INSTRUCTION(LIT, "LIT", 3, DS, MOJOSHADER_TYPE_ANY)
608 INSTRUCTION(DST, "DST", 1, DSS, MOJOSHADER_TYPE_VERTEX)
609 INSTRUCTION(LRP, "LRP", 2, DSSS, MOJOSHADER_TYPE_ANY)
610 INSTRUCTION_STATE(FRC, "FRC", 1, DS, MOJOSHADER_TYPE_ANY)
611 INSTRUCTION_STATE(M4X4, "M4X4", 4, DSS, MOJOSHADER_TYPE_ANY)
612 INSTRUCTION_STATE(M4X3, "M4X3", 3, DSS, MOJOSHADER_TYPE_ANY)
613 INSTRUCTION_STATE(M3X4, "M3X4", 4, DSS, MOJOSHADER_TYPE_ANY)
614 INSTRUCTION_STATE(M3X3, "M3X3", 3, DSS, MOJOSHADER_TYPE_ANY)
615 INSTRUCTION_STATE(M3X2, "M3X2", 2, DSS, MOJOSHADER_TYPE_ANY)
616 INSTRUCTION_STATE(CALL, "CALL", 2, S, MOJOSHADER_TYPE_ANY)
617 INSTRUCTION_STATE(CALLNZ, "CALLNZ", 3, SS, MOJOSHADER_TYPE_ANY)
618 INSTRUCTION_STATE(LOOP, "LOOP", 3, SS, MOJOSHADER_TYPE_ANY)
619 INSTRUCTION_STATE(RET, "RET", 1, NULL, MOJOSHADER_TYPE_ANY)
620 INSTRUCTION_STATE(ENDLOOP, "ENDLOOP", 2, NULL, MOJOSHADER_TYPE_ANY)
621 INSTRUCTION_STATE(LABEL, "LABEL", 0, S, MOJOSHADER_TYPE_ANY)
622 INSTRUCTION_STATE(DCL, "DCL", 0, DCL, MOJOSHADER_TYPE_ANY)
623 INSTRUCTION_STATE(POW, "POW", 3, DSS, MOJOSHADER_TYPE_ANY)
624 INSTRUCTION(CRS, "CRS", 2, DSS, MOJOSHADER_TYPE_ANY)
625 INSTRUCTION(SGN, "SGN", 3, DSSS, MOJOSHADER_TYPE_ANY)
626 INSTRUCTION(ABS, "ABS", 1, DS, MOJOSHADER_TYPE_ANY)
627 INSTRUCTION(NRM, "NRM", 3, DS, MOJOSHADER_TYPE_ANY)
628 INSTRUCTION_STATE(SINCOS, "SINCOS", 8, SINCOS, MOJOSHADER_TYPE_ANY)
629 INSTRUCTION_STATE(REP, "REP", 3, S, MOJOSHADER_TYPE_ANY)
630 INSTRUCTION_STATE(ENDREP, "ENDREP", 2, NULL, MOJOSHADER_TYPE_ANY)
631 INSTRUCTION_STATE(IF, "IF", 3, S, MOJOSHADER_TYPE_ANY)
632 INSTRUCTION_STATE(IFC, "IF", 3, SS, MOJOSHADER_TYPE_ANY)
633 INSTRUCTION(ELSE, "ELSE", 1, NULL, MOJOSHADER_TYPE_ANY) // !!! FIXME: state!
634 INSTRUCTION(ENDIF, "ENDIF", 1, NULL, MOJOSHADER_TYPE_ANY) // !!! FIXME: state!
635 INSTRUCTION_STATE(BREAK, "BREAK", 1, NULL, MOJOSHADER_TYPE_ANY)
636 INSTRUCTION_STATE(BREAKC, "BREAK", 3, SS, MOJOSHADER_TYPE_ANY)
637 INSTRUCTION_STATE(MOVA, "MOVA", 1, DS, MOJOSHADER_TYPE_VERTEX)
638 INSTRUCTION_STATE(DEFB, "DEFB", 0, DEFB, MOJOSHADER_TYPE_ANY)
639 INSTRUCTION_STATE(DEFI, "DEFI", 0, DEFI, MOJOSHADER_TYPE_ANY)
640 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
641 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
642 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
643 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
644 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
645 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
646 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
647 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
648 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
649 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
650 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
651 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
652 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
653 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
654 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
655 INSTRUCTION_STATE(TEXCRD, "TEXCRD", 1, TEXCRD, MOJOSHADER_TYPE_PIXEL)
656 INSTRUCTION_STATE(TEXKILL, "TEXKILL", 2, D, MOJOSHADER_TYPE_PIXEL)
657 INSTRUCTION_STATE(TEXLD, "TEXLD", 1, TEXLD, MOJOSHADER_TYPE_PIXEL)
658 INSTRUCTION_STATE(TEXBEM, "TEXBEM", 1, DS, MOJOSHADER_TYPE_PIXEL)
659 INSTRUCTION_STATE(TEXBEML, "TEXBEML", 2, DS, MOJOSHADER_TYPE_PIXEL)
660 INSTRUCTION(TEXREG2AR, "TEXREG2AR", 1, DS, MOJOSHADER_TYPE_PIXEL)
661 INSTRUCTION(TEXREG2GB, "TEXREG2GB", 1, DS, MOJOSHADER_TYPE_PIXEL)
662 INSTRUCTION_STATE(TEXM3X2PAD, "TEXM3X2PAD", 1, DS, MOJOSHADER_TYPE_PIXEL)
663 INSTRUCTION_STATE(TEXM3X2TEX, "TEXM3X2TEX", 1, DS, MOJOSHADER_TYPE_PIXEL)
664 INSTRUCTION_STATE(TEXM3X3PAD, "TEXM3X3PAD", 1, DS, MOJOSHADER_TYPE_PIXEL)
665 INSTRUCTION_STATE(TEXM3X3TEX, "TEXM3X3TEX", 1, DS, MOJOSHADER_TYPE_PIXEL)
666 INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN)
667 INSTRUCTION_STATE(TEXM3X3SPEC, "TEXM3X3SPEC", 1, DSS, MOJOSHADER_TYPE_PIXEL)
668 INSTRUCTION_STATE(TEXM3X3VSPEC, "TEXM3X3VSPEC", 1, DS, MOJOSHADER_TYPE_PIXEL)
669 INSTRUCTION(EXPP, "EXPP", 1, DS, MOJOSHADER_TYPE_ANY)
670 INSTRUCTION_STATE(LOGP, "LOGP", 1, DS, MOJOSHADER_TYPE_ANY)
671 INSTRUCTION_STATE(CND, "CND", 1, DSSS, MOJOSHADER_TYPE_PIXEL)
672 INSTRUCTION_STATE(DEF, "DEF", 0, DEF, MOJOSHADER_TYPE_ANY)
673 INSTRUCTION(TEXREG2RGB, "TEXREG2RGB", 1, DS, MOJOSHADER_TYPE_PIXEL)
674 INSTRUCTION(TEXDP3TEX, "TEXDP3TEX", 1, DS, MOJOSHADER_TYPE_PIXEL)
675 INSTRUCTION(TEXM3X2DEPTH, "TEXM3X2DEPTH", 1, DS, MOJOSHADER_TYPE_PIXEL)
676 INSTRUCTION(TEXDP3, "TEXDP3", 1, DS, MOJOSHADER_TYPE_PIXEL)
677 INSTRUCTION_STATE(TEXM3X3, "TEXM3X3", 1, DS, MOJOSHADER_TYPE_PIXEL)
678 INSTRUCTION(TEXDEPTH, "TEXDEPTH", 1, D, MOJOSHADER_TYPE_PIXEL)
679 INSTRUCTION_STATE(CMP, "CMP", 1, DSSS, MOJOSHADER_TYPE_PIXEL)
680 INSTRUCTION(BEM, "BEM", 2, DSS, MOJOSHADER_TYPE_PIXEL)
681 INSTRUCTION_STATE(DP2ADD, "DP2ADD", 2, DSSS, MOJOSHADER_TYPE_PIXEL)
682 INSTRUCTION(DSX, "DSX", 2, DS, MOJOSHADER_TYPE_PIXEL)
683 INSTRUCTION(DSY, "DSY", 2, DS, MOJOSHADER_TYPE_PIXEL)
684 INSTRUCTION(TEXLDD, "TEXLDD", 3, DSSSS, MOJOSHADER_TYPE_PIXEL)
685 INSTRUCTION_STATE(SETP, "SETP", 1, DSS, MOJOSHADER_TYPE_ANY)
686 INSTRUCTION_STATE(TEXLDL, "TEXLDL", 2, DSS, MOJOSHADER_TYPE_ANY)
687 INSTRUCTION_STATE(BREAKP, "BREAKP", 3, S, MOJOSHADER_TYPE_ANY)
688 #endif
689
690 // end of mojoshader_internal.h ...
691
692