Skip to content

Latest commit

 

History

History
881 lines (755 loc) · 28 KB

mojoshader_internal.h

File metadata and controls

881 lines (755 loc) · 28 KB
 
1
2
3
4
5
6
7
8
#ifndef _INCLUDE_MOJOSHADER_INTERNAL_H_
#define _INCLUDE_MOJOSHADER_INTERNAL_H_
#ifndef __MOJOSHADER_INTERNAL__
#error Do not include this header from your applications.
#endif
// Shader bytecode format is described at MSDN:
Apr 6, 2010
Apr 6, 2010
9
// http://msdn.microsoft.com/en-us/library/ff569705.aspx
Feb 12, 2009
Feb 12, 2009
10
Apr 1, 2020
Apr 1, 2020
11
12
13
#ifdef MOJOSHADER_USE_SDL_STDLIB
#include <SDL_assert.h>
#include <SDL_stdinc.h>
Apr 19, 2020
Apr 19, 2020
14
#include <math.h> /* Needed for isinf/isnan :( */
May 22, 2020
May 22, 2020
15
16
17
/* FIXME: These includes are needed for alloca :( */
#include <stdlib.h>
Apr 19, 2020
Apr 19, 2020
18
#ifndef __APPLE__
May 22, 2020
May 22, 2020
19
#include <malloc.h>
Apr 2, 2020
Apr 2, 2020
20
#endif
Apr 1, 2020
Apr 1, 2020
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* stdint.h */
typedef Uint8 uint8;
typedef Uint16 uint16;
typedef Uint32 uint32;
typedef Sint32 int32;
typedef Sint64 int64;
typedef Uint64 uint64;
/* assert.h */
#define assert SDL_assert
/* stdlib.h */
#define malloc SDL_malloc
#define free SDL_free
/* stdio.h */
#define sscanf SDL_sscanf
Apr 1, 2020
Apr 1, 2020
39
40
41
#ifdef snprintf
#undef snprintf
#endif
Apr 1, 2020
Apr 1, 2020
42
#define snprintf SDL_snprintf
Apr 1, 2020
Apr 1, 2020
43
44
45
#ifdef vsnprintf
#undef vsnprintf
#endif
Apr 1, 2020
Apr 1, 2020
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#define vsnprintf SDL_vsnprintf
/* math.h */
#define acos SDL_acos
#define asin SDL_asin
#define atan SDL_atan
#define atan2 SDL_atan2
#define cos SDL_acos
#define exp SDL_exp
#define floor SDL_floor
#define log SDL_log
#define sin SDL_sin
#define sqrt SDL_sqrt
/* string.h */
#ifdef memcmp
#undef memcmp
#endif
#define memcmp SDL_memcmp
#ifdef memcpy
#undef memcpy
#endif
#define memcpy SDL_memcpy
#ifdef memset
Apr 1, 2020
Apr 1, 2020
70
#undef memset
Apr 1, 2020
Apr 1, 2020
71
72
#endif
#define memset SDL_memset
Apr 19, 2020
Apr 19, 2020
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifdef strchr
#undef strchr
#endif
#define strchr SDL_strchr
#ifdef strcmp
#undef strcmp
#endif
#define strcmp SDL_strcmp
#ifdef strlen
#undef strlen
#endif
#define strlen SDL_strlen
#ifdef strncmp
#undef strncmp
#endif
#define strncmp SDL_strncmp
#ifdef strstr
#undef strstr
#endif
#define strstr SDL_strstr
Apr 2, 2020
Apr 2, 2020
93
94
95
96
97
#ifdef strcat
#undef strcat
#endif
/* TODO: Move MojoShader away from strcat! This len is awful! */
#define strcat(dst, src) SDL_strlcat(dst, src, SDL_strlen(src) + 1)
Apr 1, 2020
Apr 1, 2020
98
99
100
101
102
#ifdef strcpy
#undef strcpy
#endif
/* TODO: Move MojoShader away from strcpy! This len is awful! */
#define strcpy(dst, src) SDL_strlcpy(dst, src, SDL_strlen(src) + 1)
Apr 1, 2020
Apr 1, 2020
103
#else /* MOJOSHADER_USE_SDL_STDLIB */
104
105
106
107
108
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
Apr 1, 2020
Apr 1, 2020
109
#endif /* MOJOSHADER_USE_SDL_STDLIB */
110
111
112
#include "mojoshader.h"
Feb 15, 2009
Feb 15, 2009
113
#define DEBUG_LEXER 0
Feb 12, 2009
Feb 12, 2009
114
#define DEBUG_PREPROCESSOR 0
Feb 28, 2009
Feb 28, 2009
115
116
#define DEBUG_ASSEMBLER_PARSER 0
#define DEBUG_COMPILER_PARSER 0
Feb 15, 2009
Feb 15, 2009
117
#define DEBUG_TOKENIZER \
Feb 28, 2009
Feb 28, 2009
118
(DEBUG_PREPROCESSOR || DEBUG_ASSEMBLER_PARSER || DEBUG_LEXER)
Feb 12, 2009
Feb 12, 2009
119
120
121
122
// This is the highest shader version we currently support.
#define MAX_SHADER_MAJOR 3
Dec 10, 2008
Dec 10, 2008
123
#define MAX_SHADER_MINOR 255 // vs_3_sw
124
125
126
127
128
129
130
131
132
// If SUPPORT_PROFILE_* isn't defined, we assume an implicit desire to support.
// You get all the profiles unless you go out of your way to disable them.
#ifndef SUPPORT_PROFILE_D3D
#define SUPPORT_PROFILE_D3D 1
#endif
Dec 29, 2009
Dec 29, 2009
133
#ifndef SUPPORT_PROFILE_BYTECODE
Dec 10, 2008
Dec 10, 2008
134
#define SUPPORT_PROFILE_BYTECODE 1
135
136
#endif
May 21, 2020
May 21, 2020
137
138
139
140
#ifndef SUPPORT_PROFILE_HLSL
#define SUPPORT_PROFILE_HLSL 1
#endif
141
142
143
144
#ifndef SUPPORT_PROFILE_GLSL
#define SUPPORT_PROFILE_GLSL 1
#endif
Dec 30, 2009
Dec 30, 2009
145
146
147
148
#ifndef SUPPORT_PROFILE_GLSL120
#define SUPPORT_PROFILE_GLSL120 1
#endif
Jan 1, 2016
Jan 1, 2016
149
150
151
152
#ifndef SUPPORT_PROFILE_GLSLES
#define SUPPORT_PROFILE_GLSLES 1
#endif
153
154
155
156
#ifndef SUPPORT_PROFILE_ARB1
#define SUPPORT_PROFILE_ARB1 1
#endif
Dec 30, 2009
Dec 30, 2009
157
158
159
160
#ifndef SUPPORT_PROFILE_ARB1_NV
#define SUPPORT_PROFILE_ARB1_NV 1
#endif
Apr 25, 2016
Apr 25, 2016
161
162
163
164
#ifndef SUPPORT_PROFILE_METAL
#define SUPPORT_PROFILE_METAL 1
#endif
Dec 31, 2019
Dec 31, 2019
165
166
167
168
#ifndef SUPPORT_PROFILE_SPIRV
#define SUPPORT_PROFILE_SPIRV 1
#endif
Dec 31, 2019
Dec 31, 2019
169
170
171
172
#ifndef SUPPORT_PROFILE_GLSPIRV
#define SUPPORT_PROFILE_GLSPIRV 1
#endif
Dec 30, 2009
Dec 30, 2009
173
174
175
176
177
178
179
180
#if SUPPORT_PROFILE_ARB1_NV && !SUPPORT_PROFILE_ARB1
#error nv profiles require arb1 profile. Fix your build.
#endif
#if SUPPORT_PROFILE_GLSL120 && !SUPPORT_PROFILE_GLSL
#error glsl120 profile requires glsl profile. Fix your build.
#endif
Jan 1, 2016
Jan 1, 2016
181
182
183
184
#if SUPPORT_PROFILE_GLSLES && !SUPPORT_PROFILE_GLSL
#error glsles profile requires glsl profile. Fix your build.
#endif
Dec 31, 2019
Dec 31, 2019
185
186
187
188
#if SUPPORT_PROFILE_GLSPIRV && !SUPPORT_PROFILE_SPIRV
#error glspirv profile requires spirv profile. Fix your build.
#endif
Oct 2, 2014
Oct 2, 2014
189
190
191
192
193
// Microsoft's preprocessor has some quirks. In some ways, it doesn't work
// like you'd expect a C preprocessor to function.
#ifndef MATCH_MICROSOFT_PREPROCESSOR
#define MATCH_MICROSOFT_PREPROCESSOR 1
#endif
Dec 30, 2009
Dec 30, 2009
194
May 31, 2011
May 31, 2011
195
196
// Other stuff you can disable...
Jan 1, 2016
Jan 1, 2016
197
198
#ifdef MOJOSHADER_EFFECT_SUPPORT
void MOJOSHADER_runPreshader(const MOJOSHADER_preshader*, float*);
May 31, 2011
May 31, 2011
199
200
#endif
201
202
203
204
205
206
// Get basic wankery out of the way here...
#ifdef _WINDOWS
#define ENDLINE_STR "\r\n"
#else
Feb 24, 2009
Feb 24, 2009
207
#define ENDLINE_STR "\n"
208
209
210
211
#endif
typedef unsigned int uint; // this is a printf() helper. don't use for code.
Jan 1, 2016
Jan 1, 2016
212
213
214
// Locale-independent float printing replacement for snprintf
size_t MOJOSHADER_printFloat(char *text, size_t maxlen, float arg);
215
#ifdef _MSC_VER
Apr 23, 2019
Apr 23, 2019
216
217
#include <float.h>
#define isnan _isnan // !!! FIXME: not a safe replacement!
Apr 27, 2019
Apr 27, 2019
218
#if _MSC_VER < 1900 // pre MSVC 2015
Mar 25, 2020
Mar 25, 2020
219
#define isinf(x) (!_finite(x)) // FIXME: not a safe replacement!
Apr 27, 2019
Apr 27, 2019
220
#endif
Apr 2, 2020
Apr 2, 2020
221
222
223
224
225
226
227
228
#define va_copy(a, b) a = b
#endif
#ifndef MOJOSHADER_USE_SDL_STDLIB
#ifdef _MSC_VER
#include <malloc.h>
#define snprintf _snprintf // !!! FIXME: not a safe replacement!
#define vsnprintf _vsnprintf // !!! FIXME: not a safe replacement!
Dec 5, 2008
Dec 5, 2008
229
#define strcasecmp stricmp
Nov 19, 2010
Nov 19, 2010
230
#define strncasecmp strnicmp
231
232
233
typedef unsigned __int8 uint8;
typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
Feb 8, 2010
Feb 8, 2010
234
typedef unsigned __int64 uint64;
235
typedef __int32 int32;
Feb 8, 2010
Feb 8, 2010
236
typedef __int64 int64;
Nov 19, 2010
Nov 19, 2010
237
238
239
240
241
242
243
#ifdef _WIN64
typedef __int64 ssize_t;
#elif defined _WIN32
typedef __int32 ssize_t;
#else
#error Please define your platform.
#endif
244
245
246
247
248
249
250
251
252
// Warning Level 4 considered harmful. :)
#pragma warning(disable: 4100) // "unreferenced formal parameter"
#pragma warning(disable: 4389) // "signed/unsigned mismatch"
#else
#include <stdint.h>
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef int32_t int32;
Feb 8, 2010
Feb 8, 2010
253
254
typedef int64_t int64;
typedef uint64_t uint64;
255
256
#endif
Apr 17, 2009
Apr 17, 2009
257
258
259
#ifdef sun
#include <alloca.h>
#endif
Apr 1, 2020
Apr 1, 2020
260
#endif /* MOJOSHADER_USE_SDL_STDLIB */
Apr 17, 2009
Apr 17, 2009
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#ifdef __GNUC__
#define ISPRINTF(x,y) __attribute__((format (printf, x, y)))
#else
#define ISPRINTF(x,y)
#endif
#define STATICARRAYLEN(x) ( (sizeof ((x))) / (sizeof ((x)[0])) )
// Byteswap magic...
#if ((defined __GNUC__) && (defined __POWERPC__))
static inline uint32 SWAP32(uint32 x)
{
__asm__ __volatile__("lwbrx %0,0,%1" : "=r" (x) : "r" (&x));
return x;
} // SWAP32
static inline uint16 SWAP16(uint16 x)
{
__asm__ __volatile__("lhbrx %0,0,%1" : "=r" (x) : "r" (&x));
return x;
} // SWAP16
#elif defined(__POWERPC__)
static inline uint32 SWAP32(uint32 x)
{
return ( (((x) >> 24) & 0x000000FF) | (((x) >> 8) & 0x0000FF00) |
(((x) << 8) & 0x00FF0000) | (((x) << 24) & 0xFF000000) );
} // SWAP32
static inline uint16 SWAP16(uint16 x)
{
return ( (((x) >> 8) & 0x00FF) | (((x) << 8) & 0xFF00) );
} // SWAP16
#else
# define SWAP16(x) (x)
# define SWAP32(x) (x)
#endif
May 30, 2011
May 30, 2011
299
300
#define SWAPDBL(x) (x) // !!! FIXME
Feb 13, 2009
Feb 13, 2009
301
302
303
304
305
static inline int Min(const int a, const int b)
{
return ((a < b) ? a : b);
} // Min
Apr 5, 2009
Apr 5, 2009
306
307
308
309
// Hashtables...
typedef struct HashTable HashTable;
Feb 24, 2010
Feb 24, 2010
310
311
312
313
314
315
316
317
318
typedef uint32 (*HashTable_HashFn)(const void *key, void *data);
typedef int (*HashTable_KeyMatchFn)(const void *a, const void *b, void *data);
typedef void (*HashTable_NukeFn)(const void *key, const void *value, void *data);
HashTable *hash_create(void *data, const HashTable_HashFn hashfn,
const HashTable_KeyMatchFn keymatchfn,
const HashTable_NukeFn nukefn,
const int stackable,
MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
Apr 5, 2009
Apr 5, 2009
319
void hash_destroy(HashTable *table);
Apr 5, 2009
Apr 5, 2009
320
321
322
int hash_insert(HashTable *table, const void *key, const void *value);
int hash_remove(HashTable *table, const void *key);
int hash_find(const HashTable *table, const void *key, const void **_value);
Dec 12, 2010
Dec 12, 2010
323
int hash_iter(const HashTable *table, const void *key, const void **_value, void **iter);
Nov 11, 2011
Nov 11, 2011
324
int hash_iter_keys(const HashTable *table, const void **_key, void **iter);
Apr 5, 2009
Apr 5, 2009
325
Feb 24, 2010
Feb 24, 2010
326
327
328
329
330
331
332
333
334
335
336
337
uint32 hash_hash_string(const void *sym, void *unused);
int hash_keymatch_string(const void *a, const void *b, void *unused);
// String -> String map ...
typedef HashTable StringMap;
StringMap *stringmap_create(const int copy, MOJOSHADER_malloc m,
MOJOSHADER_free f, void *d);
void stringmap_destroy(StringMap *smap);
int stringmap_insert(StringMap *smap, const char *key, const char *value);
int stringmap_remove(StringMap *smap, const char *key);
int stringmap_find(const StringMap *smap, const char *key, const char **_val);
Apr 5, 2009
Apr 5, 2009
338
Feb 24, 2010
Feb 24, 2010
339
340
341
342
343
344
345
346
347
// String caching...
typedef struct StringCache StringCache;
StringCache *stringcache_create(MOJOSHADER_malloc m,MOJOSHADER_free f,void *d);
const char *stringcache(StringCache *cache, const char *str);
const char *stringcache_len(StringCache *cache, const char *str,
const unsigned int len);
const char *stringcache_fmt(StringCache *cache, const char *fmt, ...);
Oct 11, 2012
Oct 11, 2012
348
int stringcache_iscached(StringCache *cache, const char *str);
Feb 24, 2010
Feb 24, 2010
349
350
351
void stringcache_destroy(StringCache *cache);
Nov 9, 2010
Nov 9, 2010
352
// Error lists...
Nov 4, 2010
Nov 4, 2010
353
Nov 9, 2010
Nov 9, 2010
354
typedef struct ErrorList ErrorList;
Nov 4, 2010
Nov 4, 2010
355
356
357
358
359
360
361
ErrorList *errorlist_create(MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
int errorlist_add(ErrorList *list, const char *fname,
const int errpos, const char *str);
int errorlist_add_fmt(ErrorList *list, const char *fname,
const int errpos, const char *fmt, ...) ISPRINTF(4,5);
int errorlist_add_va(ErrorList *list, const char *_fname,
const int errpos, const char *fmt, va_list va);
Nov 9, 2010
Nov 9, 2010
362
int errorlist_count(ErrorList *list);
Nov 4, 2010
Nov 4, 2010
363
364
365
366
MOJOSHADER_error *errorlist_flatten(ErrorList *list); // resets the list!
void errorlist_destroy(ErrorList *list);
Nov 9, 2010
Nov 9, 2010
367
368
369
// Dynamic buffers...
Apr 1, 2020
Apr 1, 2020
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
typedef struct BufferBlock
{
uint8 *data;
size_t bytes;
struct BufferBlock *next;
} BufferBlock;
typedef struct Buffer
{
size_t total_bytes;
BufferBlock *head;
BufferBlock *tail;
size_t block_size;
MOJOSHADER_malloc m;
MOJOSHADER_free f;
void *d;
} Buffer;
Nov 9, 2010
Nov 9, 2010
386
Buffer *buffer_create(size_t blksz,MOJOSHADER_malloc m,MOJOSHADER_free f,void *d);
Nov 19, 2010
Nov 19, 2010
387
char *buffer_reserve(Buffer *buffer, const size_t len);
Nov 10, 2010
Nov 10, 2010
388
int buffer_append(Buffer *buffer, const void *_data, size_t len);
Nov 9, 2010
Nov 9, 2010
389
390
391
392
int buffer_append_fmt(Buffer *buffer, const char *fmt, ...) ISPRINTF(2,3);
int buffer_append_va(Buffer *buffer, const char *fmt, va_list va);
size_t buffer_size(Buffer *buffer);
void buffer_empty(Buffer *buffer);
Nov 19, 2010
Nov 19, 2010
393
394
char *buffer_flatten(Buffer *buffer);
char *buffer_merge(Buffer **buffers, const size_t n, size_t *_len);
Nov 9, 2010
Nov 9, 2010
395
void buffer_destroy(Buffer *buffer);
Dec 31, 2019
Dec 31, 2019
396
397
void buffer_patch(Buffer *buffer, const size_t start,
const void *data, const size_t len);
Nov 9, 2010
Nov 9, 2010
398
399
400
Dec 20, 2008
Dec 20, 2008
401
402
403
404
405
406
// This is the ID for a D3DXSHADER_CONSTANTTABLE in the bytecode comments.
#define CTAB_ID 0x42415443 // 0x42415443 == 'CTAB'
#define CTAB_SIZE 28 // sizeof (D3DXSHADER_CONSTANTTABLE).
#define CINFO_SIZE 20 // sizeof (D3DXSHADER_CONSTANTINFO).
#define CTYPEINFO_SIZE 16 // sizeof (D3DXSHADER_TYPEINFO).
#define CMEMBERINFO_SIZE 8 // sizeof (D3DXSHADER_STRUCTMEMBERINFO)
Dec 5, 2008
Dec 5, 2008
407
May 30, 2011
May 30, 2011
408
409
410
411
412
413
// Preshader magic values...
#define PRES_ID 0x53455250 // 0x53455250 == 'PRES'
#define PRSI_ID 0x49535250 // 0x49535250 == 'PRSI'
#define CLIT_ID 0x54494C43 // 0x54494C43 == 'CLIT'
#define FXLC_ID 0x434C5846 // 0x434C5846 == 'FXLC'
Dec 5, 2008
Dec 5, 2008
414
415
// we need to reference these by explicit value occasionally...
#define OPCODE_RET 28
Feb 11, 2009
Feb 11, 2009
416
#define OPCODE_IF 40
Dec 5, 2008
Dec 5, 2008
417
#define OPCODE_IFC 41
Feb 11, 2009
Feb 11, 2009
418
#define OPCODE_BREAK 44
Dec 5, 2008
Dec 5, 2008
419
#define OPCODE_BREAKC 45
Feb 11, 2009
Feb 11, 2009
420
421
#define OPCODE_TEXLD 66
#define OPCODE_SETP 94
Dec 5, 2008
Dec 5, 2008
422
Dec 13, 2008
Dec 13, 2008
423
424
425
426
427
// TEXLD becomes a different instruction with these instruction controls.
#define CONTROL_TEXLD 0
#define CONTROL_TEXLDP 1
#define CONTROL_TEXLDB 2
Dec 5, 2008
Dec 5, 2008
428
429
430
// #define this to force app to supply an allocator, so there's no reference
// to the C runtime's malloc() and free()...
#if MOJOSHADER_FORCE_ALLOCATOR
Feb 7, 2009
Feb 7, 2009
431
432
#define MOJOSHADER_internal_malloc NULL
#define MOJOSHADER_internal_free NULL
Dec 5, 2008
Dec 5, 2008
433
#else
Jan 1, 2016
Jan 1, 2016
434
435
void * MOJOSHADERCALL MOJOSHADER_internal_malloc(int bytes, void *d);
void MOJOSHADERCALL MOJOSHADER_internal_free(void *ptr, void *d);
Dec 5, 2008
Dec 5, 2008
436
437
#endif
Feb 13, 2009
Feb 13, 2009
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
#if MOJOSHADER_FORCE_INCLUDE_CALLBACKS
#define MOJOSHADER_internal_include_open NULL
#define MOJOSHADER_internal_include_close NULL
#else
int MOJOSHADER_internal_include_open(MOJOSHADER_includeType inctype,
const char *fname, const char *parent,
const char **outdata,
unsigned int *outbytes,
MOJOSHADER_malloc m, MOJOSHADER_free f,
void *d);
void MOJOSHADER_internal_include_close(const char *data, MOJOSHADER_malloc m,
MOJOSHADER_free f, void *d);
#endif
Dec 5, 2008
Dec 5, 2008
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
// result modifiers.
// !!! FIXME: why isn't this an enum?
#define MOD_SATURATE 0x01
#define MOD_PP 0x02
#define MOD_CENTROID 0x04
typedef enum
{
REG_TYPE_TEMP = 0,
REG_TYPE_INPUT = 1,
REG_TYPE_CONST = 2,
REG_TYPE_ADDRESS = 3,
REG_TYPE_TEXTURE = 3, // ALSO 3!
REG_TYPE_RASTOUT = 4,
REG_TYPE_ATTROUT = 5,
REG_TYPE_TEXCRDOUT = 6,
REG_TYPE_OUTPUT = 6, // ALSO 6!
REG_TYPE_CONSTINT = 7,
REG_TYPE_COLOROUT = 8,
REG_TYPE_DEPTHOUT = 9,
REG_TYPE_SAMPLER = 10,
REG_TYPE_CONST2 = 11,
REG_TYPE_CONST3 = 12,
REG_TYPE_CONST4 = 13,
REG_TYPE_CONSTBOOL = 14,
REG_TYPE_LOOP = 15,
REG_TYPE_TEMPFLOAT16 = 16,
REG_TYPE_MISCTYPE = 17,
REG_TYPE_LABEL = 18,
REG_TYPE_PREDICATE = 19,
REG_TYPE_MAX = 19
} RegisterType;
typedef enum
{
TEXTURE_TYPE_2D = 2,
TEXTURE_TYPE_CUBE = 3,
TEXTURE_TYPE_VOLUME = 4,
} TextureType;
typedef enum
{
RASTOUT_TYPE_POSITION = 0,
RASTOUT_TYPE_FOG = 1,
RASTOUT_TYPE_POINT_SIZE = 2,
RASTOUT_TYPE_MAX = 2
} RastOutType;
typedef enum
{
MISCTYPE_TYPE_POSITION = 0,
MISCTYPE_TYPE_FACE = 1,
MISCTYPE_TYPE_MAX = 1
} MiscTypeType;
// source modifiers.
typedef enum
{
SRCMOD_NONE,
SRCMOD_NEGATE,
SRCMOD_BIAS,
SRCMOD_BIASNEGATE,
SRCMOD_SIGN,
SRCMOD_SIGNNEGATE,
SRCMOD_COMPLEMENT,
SRCMOD_X2,
SRCMOD_X2NEGATE,
SRCMOD_DZ,
SRCMOD_DW,
SRCMOD_ABS,
SRCMOD_ABSNEGATE,
SRCMOD_NOT,
SRCMOD_TOTAL
} SourceMod;
typedef struct
{
const uint32 *token; // this is the unmolested token in the stream.
int regnum;
int relative;
int writemask; // xyzw or rgba (all four, not split out).
int writemask0; // x or red
int writemask1; // y or green
int writemask2; // z or blue
int writemask3; // w or alpha
int orig_writemask; // writemask before mojoshader tweaks it.
int result_mod;
int result_shift;
RegisterType regtype;
} DestArgInfo;
Apr 13, 2012
Apr 13, 2012
546
547
// NOTE: This will NOT know a dcl_psize or dcl_fog output register should be
// scalar! This function doesn't have access to that information.
Dec 10, 2008
Dec 10, 2008
548
549
static inline int scalar_register(const MOJOSHADER_shaderType shader_type,
const RegisterType regtype, const int regnum)
Dec 5, 2008
Dec 5, 2008
550
551
552
{
switch (regtype)
{
Apr 13, 2012
Apr 13, 2012
553
554
555
556
557
558
559
case REG_TYPE_RASTOUT:
if (((const RastOutType) regnum) == RASTOUT_TYPE_FOG)
return 1;
else if (((const RastOutType) regnum) == RASTOUT_TYPE_POINT_SIZE)
return 1;
return 0;
Dec 5, 2008
Dec 5, 2008
560
561
562
563
564
565
566
567
568
569
case REG_TYPE_DEPTHOUT:
case REG_TYPE_CONSTBOOL:
case REG_TYPE_LOOP:
return 1;
case REG_TYPE_MISCTYPE:
if ( ((const MiscTypeType) regnum) == MISCTYPE_TYPE_FACE )
return 1;
return 0;
Dec 10, 2008
Dec 10, 2008
570
571
572
case REG_TYPE_PREDICATE:
return (shader_type == MOJOSHADER_TYPE_PIXEL) ? 1 : 0;
Dec 5, 2008
Dec 5, 2008
573
574
575
576
577
578
default: break;
} // switch
return 0;
} // scalar_register
Dec 19, 2008
Dec 19, 2008
579
Feb 3, 2009
Feb 3, 2009
580
581
extern MOJOSHADER_error MOJOSHADER_out_of_mem_error;
extern MOJOSHADER_parseData MOJOSHADER_out_of_mem_data;
Feb 3, 2009
Feb 3, 2009
582
583
Feb 9, 2009
Feb 9, 2009
584
585
586
587
588
// preprocessor stuff.
typedef enum
{
TOKEN_UNKNOWN = 256, // start past ASCII character values.
Feb 13, 2009
Feb 13, 2009
589
590
591
592
// These are all C-like constructs. Tokens < 256 may be single
// chars (like '+' or whatever). These are just multi-char sequences
// (like "+=" or whatever).
Feb 9, 2009
Feb 9, 2009
593
594
595
596
TOKEN_IDENTIFIER,
TOKEN_INT_LITERAL,
TOKEN_FLOAT_LITERAL,
TOKEN_STRING_LITERAL,
Feb 12, 2009
Feb 12, 2009
597
598
599
600
601
602
603
604
605
606
607
608
TOKEN_RSHIFTASSIGN,
TOKEN_LSHIFTASSIGN,
TOKEN_ADDASSIGN,
TOKEN_SUBASSIGN,
TOKEN_MULTASSIGN,
TOKEN_DIVASSIGN,
TOKEN_MODASSIGN,
TOKEN_XORASSIGN,
TOKEN_ANDASSIGN,
TOKEN_ORASSIGN,
TOKEN_INCREMENT,
TOKEN_DECREMENT,
Feb 9, 2009
Feb 9, 2009
609
610
611
612
613
614
615
616
TOKEN_RSHIFT,
TOKEN_LSHIFT,
TOKEN_ANDAND,
TOKEN_OROR,
TOKEN_LEQ,
TOKEN_GEQ,
TOKEN_EQL,
TOKEN_NEQ,
Feb 25, 2010
Feb 25, 2010
617
TOKEN_HASH,
Feb 9, 2009
Feb 9, 2009
618
TOKEN_HASHHASH,
Feb 13, 2009
Feb 13, 2009
619
Feb 14, 2013
Feb 14, 2013
620
621
622
623
624
625
626
// This is returned if the preprocessor isn't stripping comments. Note
// that in asm files, the ';' counts as a single-line comment, same as
// "//". Note that both eat newline tokens: all of the ones inside a
// multiline comment, and the ending newline on a single-line comment.
TOKEN_MULTI_COMMENT,
TOKEN_SINGLE_COMMENT,
Feb 13, 2009
Feb 13, 2009
627
628
629
630
631
632
633
634
635
636
637
638
639
640
// This is returned at the end of input...no more to process.
TOKEN_EOI,
// This is returned for char sequences we think are bogus. You'll have
// to judge for yourself. In most cases, you'll probably just fail with
// bogus syntax without explicitly checking for this token.
TOKEN_BAD_CHARS,
// This is returned if there's an error condition (the error is returned
// as a NULL-terminated string from preprocessor_nexttoken(), instead
// of actual token data). You can continue getting tokens after this
// is reported. It happens for things like missing #includes, etc.
TOKEN_PREPROCESSING_ERROR,
May 31, 2010
May 31, 2010
641
642
// These are all caught by the preprocessor. Caller won't ever see them,
// except TOKEN_PP_PRAGMA.
Feb 13, 2009
Feb 13, 2009
643
// They control the preprocessor (#includes new files, etc).
Feb 9, 2009
Feb 9, 2009
644
645
646
647
648
649
650
651
652
653
TOKEN_PP_INCLUDE,
TOKEN_PP_LINE,
TOKEN_PP_DEFINE,
TOKEN_PP_UNDEF,
TOKEN_PP_IF,
TOKEN_PP_IFDEF,
TOKEN_PP_IFNDEF,
TOKEN_PP_ELSE,
TOKEN_PP_ELIF,
TOKEN_PP_ENDIF,
Feb 13, 2009
Feb 13, 2009
654
TOKEN_PP_ERROR, // caught, becomes TOKEN_PREPROCESSING_ERROR
May 31, 2010
May 31, 2010
655
TOKEN_PP_PRAGMA,
Feb 13, 2009
Feb 13, 2009
656
TOKEN_INCOMPLETE_COMMENT, // caught, becomes TOKEN_PREPROCESSING_ERROR
Feb 23, 2009
Feb 23, 2009
657
658
TOKEN_PP_UNARY_MINUS, // used internally, never returned.
TOKEN_PP_UNARY_PLUS, // used internally, never returned.
Feb 9, 2009
Feb 9, 2009
659
660
661
662
663
664
665
} Token;
// This is opaque.
struct Preprocessor;
typedef struct Preprocessor Preprocessor;
Feb 14, 2009
Feb 14, 2009
666
667
668
669
670
typedef struct Conditional
{
Token type;
int linenum;
int skipping;
Feb 15, 2009
Feb 15, 2009
671
int chosen;
Feb 14, 2009
Feb 14, 2009
672
673
674
struct Conditional *next;
} Conditional;
Feb 20, 2009
Feb 20, 2009
675
676
677
678
typedef struct Define
{
const char *identifier;
const char *definition;
Mar 12, 2010
Mar 12, 2010
679
const char *original;
Feb 20, 2009
Feb 20, 2009
680
const char **parameters;
Apr 9, 2009
Apr 9, 2009
681
int paramcount;
Feb 20, 2009
Feb 20, 2009
682
683
684
struct Define *next;
} Define;
Feb 9, 2009
Feb 9, 2009
685
686
typedef struct IncludeState
{
Feb 13, 2009
Feb 13, 2009
687
const char *filename;
Feb 9, 2009
Feb 9, 2009
688
689
690
const char *source_base;
const char *source;
const char *token;
Feb 18, 2009
Feb 18, 2009
691
unsigned int tokenlen;
Feb 18, 2009
Feb 18, 2009
692
Token tokenval;
Feb 18, 2009
Feb 18, 2009
693
int pushedback;
Feb 9, 2009
Feb 9, 2009
694
const unsigned char *lexer_marker;
Feb 17, 2009
Feb 17, 2009
695
int report_whitespace;
Feb 14, 2013
Feb 14, 2013
696
int report_comments;
Feb 24, 2009
Feb 24, 2009
697
int asm_comments;
Feb 17, 2009
Feb 17, 2009
698
unsigned int orig_length;
Feb 9, 2009
Feb 9, 2009
699
700
unsigned int bytes_left;
unsigned int line;
Feb 14, 2009
Feb 14, 2009
701
Conditional *conditional_stack;
Feb 19, 2009
Feb 19, 2009
702
MOJOSHADER_includeClose close_callback;
Feb 9, 2009
Feb 9, 2009
703
704
705
struct IncludeState *next;
} IncludeState;
Feb 18, 2009
Feb 18, 2009
706
Token preprocessor_lexer(IncludeState *s);
Feb 9, 2009
Feb 9, 2009
707
708
709
710
711
712
713
// This will only fail if the allocator fails, so it doesn't return any
// error code...NULL on failure.
Preprocessor *preprocessor_start(const char *fname, const char *source,
unsigned int sourcelen,
MOJOSHADER_includeOpen open_callback,
MOJOSHADER_includeClose close_callback,
Feb 19, 2009
Feb 19, 2009
714
const MOJOSHADER_preprocessorDefine *defines,
Feb 24, 2009
Feb 24, 2009
715
unsigned int define_count, int asm_comments,
Feb 9, 2009
Feb 9, 2009
716
717
718
719
720
721
722
723
MOJOSHADER_malloc m, MOJOSHADER_free f, void *d);
void preprocessor_end(Preprocessor *pp);
int preprocessor_outofmemory(Preprocessor *pp);
const char *preprocessor_nexttoken(Preprocessor *_ctx,
unsigned int *_len, Token *_token);
const char *preprocessor_sourcepos(Preprocessor *pp, unsigned int *pos);
Dec 8, 2008
Dec 8, 2008
724
Feb 12, 2009
Feb 12, 2009
725
726
727
728
void MOJOSHADER_print_debug_token(const char *subsystem, const char *token,
const unsigned int tokenlen,
const Token tokenval);
Dec 31, 2019
Dec 31, 2019
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
#if SUPPORT_PROFILE_SPIRV
// Patching SPIR-V binaries before linking is needed to ensure locations do not
// overlap between shader stages. Unfortunately, OpDecorate takes Literal, so we
// can't use Result <id> from OpSpecConstant and leave this up to specialization
// mechanism.
// Patch table must be propagated from parsing to program linking, but since
// MOJOSHADER_parseData is public and I'd like to avoid changing ABI and exposing
// this, it is appended to MOJOSHADER_parseData::output using postflight buffer.
typedef struct SpirvPatchEntry
{
uint32 offset;
int32 location;
} SpirvPatchEntry;
typedef struct SpirvPatchTable
{
Jul 7, 2020
Jul 7, 2020
746
// Patches for uniforms
Dec 31, 2019
Dec 31, 2019
747
748
749
750
751
752
SpirvPatchEntry vpflip;
SpirvPatchEntry array_vec4;
SpirvPatchEntry array_ivec4;
SpirvPatchEntry array_bool;
SpirvPatchEntry samplers[16];
int32 location_count;
Jul 7, 2020
Jul 7, 2020
753
754
755
// Patches for linking vertex output/pixel input
uint32 attrib_offsets[MOJOSHADER_USAGE_TOTAL][16];
Dec 31, 2019
Dec 31, 2019
756
} SpirvPatchTable;
Jul 7, 2020
Jul 7, 2020
757
758
759
void MOJOSHADER_spirv_link_attributes(const MOJOSHADER_parseData *vertex,
const MOJOSHADER_parseData *pixel);
Dec 31, 2019
Dec 31, 2019
760
761
#endif
762
763
#endif // _INCLUDE_MOJOSHADER_INTERNAL_H_
Dec 5, 2008
Dec 5, 2008
764
765
766
767
768
769
770
771
772
773
774
775
#if MOJOSHADER_DO_INSTRUCTION_TABLE
// These have to be in the right order! Arrays are indexed by the value
// of the instruction token.
// INSTRUCTION_STATE means this opcode has to update the state machine
// (we're entering an ELSE block, etc). INSTRUCTION means there's no
// state, just go straight to the emitters.
// !!! FIXME: Some of these MOJOSHADER_TYPE_ANYs need to have their scope
// !!! FIXME: reduced to just PIXEL or VERTEX.
Jul 20, 2020
Jul 20, 2020
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
INSTRUCTION(NOP, "NOP", 1, NULL, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(MOV, "MOV", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(ADD, "ADD", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(SUB, "SUB", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(MAD, "MAD", 1, DSSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(MUL, "MUL", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(RCP, "RCP", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(RSQ, "RSQ", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(DP3, "DP3", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(DP4, "DP4", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(MIN, "MIN", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(MAX, "MAX", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(SLT, "SLT", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(SGE, "SGE", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(EXP, "EXP", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(LOG, "LOG", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(LIT, "LIT", 3, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(DST, "DST", 1, DSS, MOJOSHADER_TYPE_VERTEX, 0xF)
INSTRUCTION(LRP, "LRP", 2, DSSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(FRC, "FRC", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(M4X4, "M4X4", 4, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(M4X3, "M4X3", 3, DSS, MOJOSHADER_TYPE_ANY, 0x7)
INSTRUCTION_STATE(M3X4, "M3X4", 4, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(M3X3, "M3X3", 3, DSS, MOJOSHADER_TYPE_ANY, 0x7)
INSTRUCTION_STATE(M3X2, "M3X2", 2, DSS, MOJOSHADER_TYPE_ANY, 0x3)
INSTRUCTION_STATE(CALL, "CALL", 2, S, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(CALLNZ, "CALLNZ", 3, SS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(LOOP, "LOOP", 3, SS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(RET, "RET", 1, NULL, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(ENDLOOP, "ENDLOOP", 2, NULL, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(LABEL, "LABEL", 0, S, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(DCL, "DCL", 0, DCL, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(POW, "POW", 3, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(CRS, "CRS", 2, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(SGN, "SGN", 3, DSSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(ABS, "ABS", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(NRM, "NRM", 3, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(SINCOS, "SINCOS", 8, SINCOS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(REP, "REP", 3, S, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(ENDREP, "ENDREP", 2, NULL, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(IF, "IF", 3, S, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(IFC, "IF", 3, SS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(ELSE, "ELSE", 1, NULL, MOJOSHADER_TYPE_ANY, 0xF) // !!! FIXME: state!
INSTRUCTION(ENDIF, "ENDIF", 1, NULL, MOJOSHADER_TYPE_ANY, 0xF) // !!! FIXME: state!
INSTRUCTION_STATE(BREAK, "BREAK", 1, NULL, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(BREAKC, "BREAK", 3, SS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(MOVA, "MOVA", 1, DS, MOJOSHADER_TYPE_VERTEX, 0xF)
INSTRUCTION_STATE(DEFB, "DEFB", 0, DEFB, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(DEFI, "DEFI", 0, DEFI, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION_STATE(TEXCRD, "TEXCRD", 1, TEXCRD, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXKILL, "TEXKILL", 2, D, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXLD, "TEXLD", 1, TEXLD, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXBEM, "TEXBEM", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXBEML, "TEXBEML", 2, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(TEXREG2AR, "TEXREG2AR", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(TEXREG2GB, "TEXREG2GB", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXM3X2PAD, "TEXM3X2PAD", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXM3X2TEX, "TEXM3X2TEX", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXM3X3PAD, "TEXM3X3PAD", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXM3X3TEX, "TEXM3X3TEX", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(RESERVED, 0, 0, NULL, MOJOSHADER_TYPE_UNKNOWN, 0xF)
INSTRUCTION_STATE(TEXM3X3SPEC, "TEXM3X3SPEC", 1, DSS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXM3X3VSPEC, "TEXM3X3VSPEC", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(EXPP, "EXPP", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(LOGP, "LOGP", 1, DS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(CND, "CND", 1, DSSS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(DEF, "DEF", 0, DEF, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION(TEXREG2RGB, "TEXREG2RGB", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(TEXDP3TEX, "TEXDP3TEX", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(TEXM3X2DEPTH, "TEXM3X2DEPTH", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(TEXDP3, "TEXDP3", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(TEXM3X3, "TEXM3X3", 1, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(TEXDEPTH, "TEXDEPTH", 1, D, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(CMP, "CMP", 1, DSSS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(BEM, "BEM", 2, DSS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(DP2ADD, "DP2ADD", 2, DSSS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(DSX, "DSX", 2, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(DSY, "DSY", 2, DS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION(TEXLDD, "TEXLDD", 3, DSSSS, MOJOSHADER_TYPE_PIXEL, 0xF)
INSTRUCTION_STATE(SETP, "SETP", 1, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(TEXLDL, "TEXLDL", 2, DSS, MOJOSHADER_TYPE_ANY, 0xF)
INSTRUCTION_STATE(BREAKP, "BREAKP", 3, S, MOJOSHADER_TYPE_ANY, 0xF)
Jul 20, 2020
Jul 20, 2020
873
874
875
876
877
#undef MOJOSHADER_DO_INSTRUCTION_TABLE
#undef INSTRUCTION
#undef INSTRUCTION_STATE
Dec 5, 2008
Dec 5, 2008
878
879
#endif
880
// end of mojoshader_internal.h ...