/
d3d2glsl.c
1662 lines (1348 loc) · 45.6 KB
1
2
3
4
5
6
7
8
/**
* d3d2glsl; generate GLSL programs from bytecode of compiled Direct3D shaders.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
9
10
// !!! FIXME: I keep changing coding styles for symbols and typedefs.
11
12
13
// Shader bytecode format is described at MSDN:
// http://msdn2.microsoft.com/en-us/library/ms800307.aspx
14
#include <stdio.h>
15
#include <string.h>
16
#include <stdlib.h>
17
#include <stdint.h>
18
#include <stdarg.h>
19
20
21
#include "d3d2glsl.h"
22
23
24
25
26
// This is the highest shader version we currently support.
#define MAX_SHADER_MAJOR 3
#define MAX_SHADER_MINOR 0
27
28
29
// You get all the profiles unless you go out of your way to disable them.
30
31
32
33
34
35
36
37
#ifndef SUPPORT_PROFILE_D3D
#define SUPPORT_PROFILE_D3D 1
#endif
#ifndef SUPPORT_PROFILE_GLSL
#define SUPPORT_PROFILE_GLSL 1
#endif
38
39
40
41
42
43
44
// Get basic wankery out of the way here...
typedef unsigned int uint; // this is a printf() helper. don't use for code.
typedef uint8_t uint8;
typedef uint32_t uint32;
45
46
47
48
49
50
#ifdef __GNUC__
#define ISPRINTF(x,y) __attribute__((format (printf, x, y)))
#else
#define ISPRINTF(x,y)
#endif
51
52
#define STATICARRAYLEN(x) ( (sizeof ((x))) / (sizeof ((x)[0])) )
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 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
#elif defined(__POWERPC__)
static inline uint32 SWAP32(uint32 x)
{
return ( (((x) >> 24) & 0x000000FF) | (((x) >> 8) & 0x0000FF00) |
(((x) << 8) & 0x00FF0000) | (((x) << 24) & 0xFF000000) );
} // SWAP32
#else
# define SWAP32(x) (x)
#endif
72
73
74
75
76
77
78
79
80
81
82
// Shader model version magic.
static inline uint32 ver_ui32(const uint8 major, const uint8 minor)
{
return ( (((uint32) major) << 16) | (((minor) == 0xFF) ? 0 : (minor)) );
} // version_ui32
#define SHADER_VERSION_SUPPORTED(maj, min) \
(ver_ui32(maj, min) <= ver_ui32(MAX_SHADER_MAJOR, MAX_SHADER_MINOR))
83
// predeclare.
84
typedef struct Context Context;
85
86
// one emit function for each opcode in each profile.
87
typedef void (*emit_function)(Context *ctx);
88
89
// one emit function for comments in each profile.
90
typedef void (*emit_comment)(Context *ctx, const char *str);
91
92
// one emit function for starting output in each profile.
93
typedef void (*emit_start)(Context *ctx);
94
95
// one emit function for ending output in each profile.
96
typedef void (*emit_end)(Context *ctx);
97
98
99
100
// one args function for each possible sequence of opcode arguments.
typedef int (*args_function)(Context *ctx);
101
// one state function for each opcode where we have state machine updates.
102
typedef int (*state_function)(Context *ctx);
103
104
105
106
107
108
109
110
111
typedef struct
{
const char *name;
emit_start start_emitter;
emit_end end_emitter;
emit_comment comment_emitter;
} D3D2GLSL_profile;
112
113
114
115
116
117
118
119
120
121
typedef enum
{
SHADER_TYPE_UNKNOWN = -1,
SHADER_TYPE_PIXEL,
SHADER_TYPE_VERTEX,
SHADER_TYPE_TOTAL
} D3D2GLSL_shaderType;
122
123
124
125
126
127
128
129
130
// A simple linked list of strings, so we can build the final output without
// realloc()ing for each new line, and easily insert lines into the middle
// of the output without much trouble.
typedef struct OutputList
{
char *str;
struct OutputList *next;
} OutputList;
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
typedef struct
{
int regnum;
int relative;
int writemask;
int result_mod;
int result_shift;
int regtype;
} DestArgInfo;
typedef struct
{
int regnum;
int relative;
int swizzle_x;
int swizzle_y;
int swizzle_z;
int swizzle_w;
int src_mod;
int regtype;
} SourceArgInfo;
155
#define D3D2GLSL_SCRATCH_BUFFER_SIZE 256
156
#define D3D2GLSL_SCRATCH_BUFFERS 10
157
158
// Context...this is state that changes as we parse through a shader...
159
struct Context
160
{
161
162
D3D2GLSL_malloc malloc;
D3D2GLSL_free free;
163
164
const uint32 *tokens;
uint32 tokencount;
165
166
167
168
169
170
171
172
173
OutputList output;
OutputList *output_tail;
int output_len; // total strlen; prevents walking the list just to malloc.
const char *endline;
int endline_len;
const char *failstr;
char scratch[D3D2GLSL_SCRATCH_BUFFERS][D3D2GLSL_SCRATCH_BUFFER_SIZE];
int scratchidx; // current scratch buffer.
int profileid;
174
const D3D2GLSL_profile *profile;
175
176
177
D3D2GLSL_shaderType shader_type;
uint32 major_ver;
uint32 minor_ver;
178
179
DestArgInfo dest_args[1];
SourceArgInfo source_args[4];
180
181
182
};
183
static inline char *get_scratch_buffer(Context *ctx)
184
{
185
186
ctx->scratchidx = (ctx->scratchidx + 1) % D3D2GLSL_SCRATCH_BUFFERS;
return ctx->scratch[ctx->scratchidx];
187
188
} // get_scratch_buffer
189
190
191
// Special-case return values from the parsing pipeline...
#define FAIL (-1)
192
#define END_OF_STREAM (-2)
193
194
195
196
197
198
199
200
201
202
203
204
static const char *out_of_mem_string = "Out of memory";
static inline int out_of_memory(Context *ctx)
{
if (ctx->failstr == NULL)
ctx->failstr = out_of_mem_string; // fail() would call malloc().
return FAIL;
} // out_of_memory
static int failf(Context *ctx, const char *fmt, ...) ISPRINTF(2,3);
static int failf(Context *ctx, const char *fmt, ...)
205
{
206
207
if (ctx->failstr == NULL) // don't change existing error.
{
208
char *scratch = get_scratch_buffer(ctx);
209
210
va_list ap;
va_start(ap, fmt);
211
const int len = vsnprintf(scratch,D3D2GLSL_SCRATCH_BUFFER_SIZE,fmt,ap);
212
213
va_end(ap);
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
char *failstr = (char *) ctx->malloc(len + 1);
if (failstr == NULL)
out_of_memory(ctx);
else
{
// see comments about scratch buffer overflow in output_line().
if (len < D3D2GLSL_SCRATCH_BUFFER_SIZE)
strcpy(failstr, scratch); // copy it over.
else
{
va_start(ap, fmt);
vsnprintf(failstr, len + 1, fmt, ap); // rebuild it.
va_end(ap);
} // else
ctx->failstr = failstr;
} // else
230
231
232
233
234
235
} // if
return FAIL;
} // failf
236
static inline int fail(Context *ctx, const char *reason)
237
238
239
240
241
{
return failf(ctx, "%s", reason);
} // fail
242
243
static int output_line(Context *ctx, const char *fmt, ...) ISPRINTF(2,3);
static int output_line(Context *ctx, const char *fmt, ...)
244
245
246
247
{
if (ctx->failstr != NULL)
return FAIL; // we failed previously, don't go on...
248
249
250
251
252
OutputList *item = (OutputList *) ctx->malloc(sizeof (OutputList));
if (item == NULL)
return out_of_memory(ctx);
char *scratch = get_scratch_buffer(ctx);
253
254
va_list ap;
va_start(ap, fmt);
255
const int len = vsnprintf(scratch, D3D2GLSL_SCRATCH_BUFFER_SIZE, fmt, ap);
256
257
va_end(ap);
258
259
item->str = (char *) ctx->malloc(len + 1);
if (item->str == NULL)
260
{
261
262
free(item);
return out_of_memory(ctx);
263
264
} // if
265
266
267
268
269
270
271
272
273
274
275
// If we overflowed our scratch buffer, that's okay. We were going to
// allocate anyhow...the scratch buffer just lets us avoid a second
// run of vsnprintf().
if (len < D3D2GLSL_SCRATCH_BUFFER_SIZE)
strcpy(item->str, scratch); // copy it over.
else
{
va_start(ap, fmt);
vsnprintf(item->str, len + 1, fmt, ap); // rebuild it.
va_end(ap);
} // else
276
277
278
279
280
item->next = NULL;
ctx->output_tail->next = item;
ctx->output_tail = item;
ctx->output_len += len + ctx->endline_len;
281
282
283
284
return 0;
} // output_line
285
286
// if SUPPORT_PROFILE_* isn't defined, we assume an implicit desire to support.
287
288
289
290
291
292
293
294
295
#define AT_LEAST_ONE_PROFILE 0
#if !SUPPORT_PROFILE_D3D
#define PROFILE_EMITTER_D3D(op)
#else
#undef AT_LEAST_ONE_PROFILE
#define AT_LEAST_ONE_PROFILE 1
#define PROFILE_EMITTER_D3D(op) emit_D3D_##op,
296
static char *make_D3D_destarg_string(Context *ctx, const int idx)
297
298
{
char *retval = NULL;
299
300
301
if (idx >= STATICARRAYLEN(ctx->dest_args))
{
fail(ctx, "Too many destination args");
302
return "";
303
} // if
304
305
306
307
308
retval = get_scratch_buffer(ctx);
strcpy(retval, "DST"); // !!! FIXME
return retval;
309
} // make_D3D_destarg_string
310
311
312
static char *make_D3D_sourcearg_string(Context *ctx, const int idx)
313
314
{
char *retval = NULL;
315
316
317
if (idx >= STATICARRAYLEN(ctx->source_args))
{
fail(ctx, "Too many source args");
318
return "";
319
} // if
320
321
322
323
324
retval = get_scratch_buffer(ctx);
strcpy(retval, "SRC"); // !!! FIXME
return retval;
325
} // make_D3D_sourcearg_string
326
327
328
static void emit_D3D_start(Context *ctx)
329
330
331
{
const uint major = (uint) ctx->major_ver;
const uint minor = (uint) ctx->minor_ver;
332
333
334
335
if (ctx->shader_type == SHADER_TYPE_PIXEL)
output_line(ctx, "ps_%u_%u", major, minor);
else if (ctx->shader_type == SHADER_TYPE_VERTEX)
336
337
338
339
340
341
342
343
344
{
char minorstr[16];
if (minor == 0xFF)
strcpy(minorstr, "sw");
else
snprintf(minorstr, sizeof (minorstr), "%u", (uint) minor);
output_line(ctx, "vs_%u_%s", major, minorstr);
} // else if
345
else
346
347
348
349
{
failf(ctx, "Shader type %u unsupported in this profile.",
(uint) ctx->shader_type);
} // else
350
351
} // emit_D3D_start
352
353
static void emit_D3D_end(Context *ctx)
354
355
356
{
output_line(ctx, "END");
} // emit_D3D_end
357
358
359
static void emit_D3D_comment(Context *ctx, const char *str)
360
{
361
362
output_line(ctx, "; %s", str);
} // emit_D3D_comment
363
364
365
static void emit_D3D_RESERVED(Context *ctx)
366
{
367
368
369
// do nothing; fails in the state machine.
} // emit_D3D_RESERVED
370
371
372
373
// Generic D3D opcode emitters. A list of macros generate all the entry points
// that call into these...
374
static void emit_D3D_opcode_d(Context *ctx, const char *opcode)
375
{
376
377
const char *dst0 = make_D3D_destarg_string(ctx, 0);
output_line(ctx, "%s %s", opcode, dst0);
378
379
380
} // emit_D3D_opcode_d
381
static void emit_D3D_opcode_s(Context *ctx, const char *opcode)
382
{
383
384
const char *src0 = make_D3D_destarg_string(ctx, 0);
output_line(ctx, "%s %s", opcode, src0);
385
386
387
} // emit_D3D_opcode_s
388
static void emit_D3D_opcode_ss(Context *ctx, const char *opcode)
389
{
390
391
392
const char *src0 = make_D3D_sourcearg_string(ctx, 0);
const char *src1 = make_D3D_sourcearg_string(ctx, 1);
output_line(ctx, "%s %s, %s", opcode, src0, src1);
393
394
395
} // emit_D3D_opcode_s
396
static void emit_D3D_opcode_ds(Context *ctx, const char *opcode)
397
{
398
399
400
const char *dst0 = make_D3D_destarg_string(ctx, 0);
const char *src0 = make_D3D_sourcearg_string(ctx, 0);
output_line(ctx, "%s %s, %s", opcode, dst0, src0);
401
402
403
} // emit_D3D_opcode_ds
404
static void emit_D3D_opcode_dss(Context *ctx, const char *opcode)
405
{
406
407
408
409
const char *dst0 = make_D3D_destarg_string(ctx, 0);
const char *src0 = make_D3D_sourcearg_string(ctx, 0);
const char *src1 = make_D3D_sourcearg_string(ctx, 1);
output_line(ctx, "%s %s, %s, %s", opcode, dst0, src0, src1);
410
411
412
} // emit_D3D_opcode_dss
413
static void emit_D3D_opcode_dsss(Context *ctx, const char *opcode)
414
{
415
416
417
418
419
const char *dst0 = make_D3D_destarg_string(ctx, 0);
const char *src0 = make_D3D_sourcearg_string(ctx, 0);
const char *src1 = make_D3D_sourcearg_string(ctx, 1);
const char *src2 = make_D3D_sourcearg_string(ctx, 2);
output_line(ctx, "%s %s, %s, %s, %s", opcode, dst0, src0, src1, src2);
420
421
422
} // emit_D3D_opcode_dsss
423
static void emit_D3D_opcode_dssss(Context *ctx, const char *opcode)
424
{
425
426
427
428
429
430
const char *dst0 = make_D3D_destarg_string(ctx, 0);
const char *src0 = make_D3D_sourcearg_string(ctx, 0);
const char *src1 = make_D3D_sourcearg_string(ctx, 1);
const char *src2 = make_D3D_sourcearg_string(ctx, 2);
const char *src3 = make_D3D_sourcearg_string(ctx, 3);
output_line(ctx,"%s %s, %s, %s, %s, %s",opcode,dst0,src0,src1,src2,src3);
431
432
433
434
} // emit_D3D_opcode_dssss
#define EMIT_D3D_OPCODE_FUNC(op) \
435
static void emit_D3D_##op(Context *ctx) { \
436
437
438
output_line(ctx, #op); \
}
#define EMIT_D3D_OPCODE_D_FUNC(op) \
439
static void emit_D3D_##op(Context *ctx) { \
440
441
442
emit_D3D_opcode_d(ctx, #op); \
}
#define EMIT_D3D_OPCODE_S_FUNC(op) \
443
static void emit_D3D_##op(Context *ctx) { \
444
445
446
emit_D3D_opcode_s(ctx, #op); \
}
#define EMIT_D3D_OPCODE_SS_FUNC(op) \
447
static void emit_D3D_##op(Context *ctx) { \
448
449
450
emit_D3D_opcode_ss(ctx, #op); \
}
#define EMIT_D3D_OPCODE_DS_FUNC(op) \
451
static void emit_D3D_##op(Context *ctx) { \
452
453
454
emit_D3D_opcode_ds(ctx, #op); \
}
#define EMIT_D3D_OPCODE_DSS_FUNC(op) \
455
static void emit_D3D_##op(Context *ctx) { \
456
457
458
emit_D3D_opcode_dss(ctx, #op); \
}
#define EMIT_D3D_OPCODE_DSSS_FUNC(op) \
459
static void emit_D3D_##op(Context *ctx) { \
460
461
462
emit_D3D_opcode_dsss(ctx, #op); \
}
#define EMIT_D3D_OPCODE_DSSSS_FUNC(op) \
463
static void emit_D3D_##op(Context *ctx) { \
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
emit_D3D_opcode_dssss(ctx, #op); \
}
EMIT_D3D_OPCODE_FUNC(NOP)
EMIT_D3D_OPCODE_DS_FUNC(MOV)
EMIT_D3D_OPCODE_DSS_FUNC(ADD)
EMIT_D3D_OPCODE_DSS_FUNC(SUB)
EMIT_D3D_OPCODE_DSSS_FUNC(MAD)
EMIT_D3D_OPCODE_DSS_FUNC(MUL)
EMIT_D3D_OPCODE_DS_FUNC(RCP)
EMIT_D3D_OPCODE_DS_FUNC(RSQ)
EMIT_D3D_OPCODE_DSS_FUNC(DP3)
EMIT_D3D_OPCODE_DSS_FUNC(DP4)
EMIT_D3D_OPCODE_DSS_FUNC(MIN)
EMIT_D3D_OPCODE_DSS_FUNC(MAX)
EMIT_D3D_OPCODE_DSS_FUNC(SLT)
EMIT_D3D_OPCODE_DSS_FUNC(SGE)
EMIT_D3D_OPCODE_DS_FUNC(EXP)
EMIT_D3D_OPCODE_DS_FUNC(LOG)
EMIT_D3D_OPCODE_DS_FUNC(LIT)
EMIT_D3D_OPCODE_DSS_FUNC(DST)
EMIT_D3D_OPCODE_DSSS_FUNC(LRP)
EMIT_D3D_OPCODE_DS_FUNC(FRC)
EMIT_D3D_OPCODE_DSS_FUNC(M4X4)
EMIT_D3D_OPCODE_DSS_FUNC(M4X3)
EMIT_D3D_OPCODE_DSS_FUNC(M3X4)
EMIT_D3D_OPCODE_DSS_FUNC(M3X3)
EMIT_D3D_OPCODE_DSS_FUNC(M3X2)
EMIT_D3D_OPCODE_S_FUNC(CALL)
EMIT_D3D_OPCODE_SS_FUNC(CALLNZ)
494
EMIT_D3D_OPCODE_SS_FUNC(LOOP)
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
546
EMIT_D3D_OPCODE_FUNC(RET)
EMIT_D3D_OPCODE_FUNC(ENDLOOP)
EMIT_D3D_OPCODE_S_FUNC(LABEL)
EMIT_D3D_OPCODE_FUNC(DCL) // !!! FIXME!
EMIT_D3D_OPCODE_DSS_FUNC(POW)
EMIT_D3D_OPCODE_DSS_FUNC(CRS)
EMIT_D3D_OPCODE_DSSS_FUNC(SGN)
EMIT_D3D_OPCODE_DS_FUNC(ABS)
EMIT_D3D_OPCODE_DS_FUNC(NRM)
EMIT_D3D_OPCODE_DS_FUNC(SINCOS)
EMIT_D3D_OPCODE_S_FUNC(REP)
EMIT_D3D_OPCODE_FUNC(ENDREP)
EMIT_D3D_OPCODE_S_FUNC(IF)
EMIT_D3D_OPCODE_SS_FUNC(IFC)
EMIT_D3D_OPCODE_FUNC(ELSE)
EMIT_D3D_OPCODE_FUNC(ENDIF)
EMIT_D3D_OPCODE_FUNC(BREAK)
EMIT_D3D_OPCODE_SS_FUNC(BREAKC)
EMIT_D3D_OPCODE_DS_FUNC(MOVA)
EMIT_D3D_OPCODE_FUNC(DEFB) // !!! FIXME!
EMIT_D3D_OPCODE_FUNC(DEFI) // !!! FIXME!
EMIT_D3D_OPCODE_FUNC(TEXCOORD) // !!! FIXME!
EMIT_D3D_OPCODE_D_FUNC(TEXKILL)
EMIT_D3D_OPCODE_FUNC(TEX) // !!! FIXME!
EMIT_D3D_OPCODE_DS_FUNC(TEXBEM)
EMIT_D3D_OPCODE_DS_FUNC(TEXBEML)
EMIT_D3D_OPCODE_DS_FUNC(TEXREG2AR)
EMIT_D3D_OPCODE_DS_FUNC(TEXREG2GB)
EMIT_D3D_OPCODE_DS_FUNC(TEXM3X2PAD)
EMIT_D3D_OPCODE_DS_FUNC(TEXM3X2TEX)
EMIT_D3D_OPCODE_DS_FUNC(TEXM3X3PAD)
EMIT_D3D_OPCODE_DS_FUNC(TEXM3X3TEX)
EMIT_D3D_OPCODE_DSS_FUNC(TEXM3X3SPEC)
EMIT_D3D_OPCODE_DS_FUNC(TEXM3X3VSPEC)
EMIT_D3D_OPCODE_DS_FUNC(EXPP)
EMIT_D3D_OPCODE_DS_FUNC(LOGP)
EMIT_D3D_OPCODE_DSSS_FUNC(CND)
EMIT_D3D_OPCODE_FUNC(DEF) // !!! FIXME!
EMIT_D3D_OPCODE_DS_FUNC(TEXREG2RGB)
EMIT_D3D_OPCODE_DS_FUNC(TEXDP3TEX)
EMIT_D3D_OPCODE_DS_FUNC(TEXM3X2DEPTH)
EMIT_D3D_OPCODE_DS_FUNC(TEXDP3)
EMIT_D3D_OPCODE_DS_FUNC(TEXM3X3)
EMIT_D3D_OPCODE_D_FUNC(TEXDEPTH)
EMIT_D3D_OPCODE_DSSS_FUNC(CMP)
EMIT_D3D_OPCODE_DSS_FUNC(BEM)
EMIT_D3D_OPCODE_DSSS_FUNC(DP2ADD)
EMIT_D3D_OPCODE_DS_FUNC(DSX)
EMIT_D3D_OPCODE_DS_FUNC(DSY)
EMIT_D3D_OPCODE_DSSSS_FUNC(TEXLDD)
EMIT_D3D_OPCODE_DSS_FUNC(SETP)
EMIT_D3D_OPCODE_DSS_FUNC(TEXLDL)
547
EMIT_D3D_OPCODE_S_FUNC(BREAKP)
548
549
550
551
552
553
554
555
556
557
#undef EMIT_D3D_OPCODE_FUNC
#undef EMIT_D3D_OPCODE_D_FUNC
#undef EMIT_D3D_OPCODE_S_FUNC
#undef EMIT_D3D_OPCODE_SS_FUNC
#undef EMIT_D3D_OPCODE_DS_FUNC
#undef EMIT_D3D_OPCODE_DSS_FUNC
#undef EMIT_D3D_OPCODE_DSSS_FUNC
#undef EMIT_D3D_OPCODE_DSSSS_FUNC
558
559
560
561
562
#endif // SUPPORT_PROFILE_D3D
#if !SUPPORT_PROFILE_GLSL
563
#define PROFILE_EMITTER_GLSL(op)
564
565
566
#else
#undef AT_LEAST_ONE_PROFILE
#define AT_LEAST_ONE_PROFILE 1
567
568
#define PROFILE_EMITTER_GLSL(op) emit_GLSL_##op,
569
static void emit_GLSL_start(Context *ctx)
570
{
571
572
573
574
575
576
577
578
579
580
581
582
const uint major = (uint) ctx->major_ver;
const uint minor = (uint) ctx->minor_ver;
if (ctx->shader_type == SHADER_TYPE_PIXEL)
output_line(ctx, "// Pixel shader, version %u.%u", major, minor);
else if (ctx->shader_type == SHADER_TYPE_VERTEX)
output_line(ctx, "// Vertex shader, version %u.%u", major, minor);
else
{
failf(ctx, "Shader type %u unsupported in this profile.",
(uint) ctx->shader_type);
} // else
583
584
585
output_line(ctx, "void main() {");
} // emit_GLSL_start
586
static void emit_GLSL_end(Context *ctx)
587
588
589
{
output_line(ctx, "}");
} // emit_GLSL_end
590
591
static void emit_GLSL_comment(Context *ctx, const char *str)
592
593
594
595
{
output_line(ctx, "// %s", str);
} // emit_GLSL_comment
596
static void emit_GLSL_NOP(Context *ctx)
597
598
599
600
{
// no-op is a no-op. :)
} // emit_GLSL_NOP
601
static void emit_GLSL_MOV(Context *ctx)
602
603
604
605
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_MOV
606
static void emit_GLSL_ADD(Context *ctx)
607
608
609
610
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_ADD
611
static void emit_GLSL_SUB(Context *ctx)
612
613
614
615
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_SUB
616
static void emit_GLSL_MAD(Context *ctx)
617
618
619
620
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_MAD
621
static void emit_GLSL_MUL(Context *ctx)
622
623
624
625
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_MUL
626
static void emit_GLSL_RCP(Context *ctx)
627
628
629
630
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_RCP
631
static void emit_GLSL_RSQ(Context *ctx)
632
633
634
635
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_RSQ
636
static void emit_GLSL_DP3(Context *ctx)
637
638
639
640
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DP3
641
static void emit_GLSL_DP4(Context *ctx)
642
643
644
645
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DP4
646
static void emit_GLSL_MIN(Context *ctx)
647
648
649
650
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_MIN
651
static void emit_GLSL_MAX(Context *ctx)
652
653
654
655
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_MAX
656
static void emit_GLSL_SLT(Context *ctx)
657
658
659
660
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_SLT
661
static void emit_GLSL_SGE(Context *ctx)
662
663
664
665
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_SGE
666
static void emit_GLSL_EXP(Context *ctx)
667
668
669
670
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_EXP
671
static void emit_GLSL_LOG(Context *ctx)
672
673
674
675
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_LOG
676
static void emit_GLSL_LIT(Context *ctx)
677
678
679
680
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_LIT
681
static void emit_GLSL_DST(Context *ctx)
682
683
684
685
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DST
686
static void emit_GLSL_LRP(Context *ctx)
687
688
689
690
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_LRP
691
static void emit_GLSL_FRC(Context *ctx)
692
693
694
695
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_FRC
696
static void emit_GLSL_M4X4(Context *ctx)
697
698
699
700
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_M4X4
701
static void emit_GLSL_M4X3(Context *ctx)
702
703
704
705
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_M4X3
706
static void emit_GLSL_M3X4(Context *ctx)
707
708
709
710
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_M3X4
711
static void emit_GLSL_M3X3(Context *ctx)
712
713
714
715
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_M3X3
716
static void emit_GLSL_M3X2(Context *ctx)
717
718
719
720
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_M3X2
721
static void emit_GLSL_CALL(Context *ctx)
722
723
724
725
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_CALL
726
static void emit_GLSL_CALLNZ(Context *ctx)
727
728
729
730
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_CALLNZ
731
static void emit_GLSL_LOOP(Context *ctx)
732
733
734
735
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_LOOP
736
static void emit_GLSL_RET(Context *ctx)
737
738
739
740
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_RET
741
static void emit_GLSL_ENDLOOP(Context *ctx)
742
743
744
745
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_ENDLOOP
746
static void emit_GLSL_LABEL(Context *ctx)
747
748
749
750
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_LABEL
751
static void emit_GLSL_DCL(Context *ctx)
752
753
754
755
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DCL
756
static void emit_GLSL_POW(Context *ctx)
757
758
759
760
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_POW
761
static void emit_GLSL_CRS(Context *ctx)
762
763
764
765
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_CRS
766
static void emit_GLSL_SGN(Context *ctx)
767
768
769
770
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_SGN
771
static void emit_GLSL_ABS(Context *ctx)
772
773
774
775
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_ABS
776
static void emit_GLSL_NRM(Context *ctx)
777
778
779
780
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_NRM
781
static void emit_GLSL_SINCOS(Context *ctx)
782
783
784
785
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_SINCOS
786
static void emit_GLSL_REP(Context *ctx)
787
788
789
790
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_REP
791
static void emit_GLSL_ENDREP(Context *ctx)
792
793
794
795
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_ENDREP
796
static void emit_GLSL_IF(Context *ctx)
797
798
799
800
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_IF
801
static void emit_GLSL_IFC(Context *ctx)
802
803
804
805
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_IFC
806
static void emit_GLSL_ELSE(Context *ctx)
807
808
809
810
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_ELSE
811
static void emit_GLSL_ENDIF(Context *ctx)
812
813
814
815
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_ENDIF
816
static void emit_GLSL_BREAK(Context *ctx)
817
818
819
820
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_BREAK
821
static void emit_GLSL_BREAKC(Context *ctx)
822
823
824
825
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_BREAKC
826
static void emit_GLSL_MOVA(Context *ctx)
827
828
829
830
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_MOVA
831
static void emit_GLSL_DEFB(Context *ctx)
832
833
834
835
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DEFB
836
static void emit_GLSL_DEFI(Context *ctx)
837
838
839
840
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DEFI
841
static void emit_GLSL_TEXCOORD(Context *ctx)
842
843
844
845
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXCOORD
846
static void emit_GLSL_TEXKILL(Context *ctx)
847
848
849
850
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXKILL
851
static void emit_GLSL_TEX(Context *ctx)
852
853
854
855
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEX
856
static void emit_GLSL_TEXBEM(Context *ctx)
857
858
859
860
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXBEM
861
static void emit_GLSL_TEXBEML(Context *ctx)
862
863
864
865
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXBEML
866
static void emit_GLSL_TEXREG2AR(Context *ctx)
867
868
869
870
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXREG2AR
871
static void emit_GLSL_TEXREG2GB(Context *ctx)
872
873
874
875
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXREG2GB
876
static void emit_GLSL_TEXM3X2PAD(Context *ctx)
877
878
879
880
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXM3X2PAD
881
static void emit_GLSL_TEXM3X2TEX(Context *ctx)
882
883
884
885
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXM3X2TEX
886
static void emit_GLSL_TEXM3X3PAD(Context *ctx)
887
888
889
890
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXM3X3PAD
891
static void emit_GLSL_TEXM3X3TEX(Context *ctx)
892
893
894
895
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXM3X3TEX
896
static void emit_GLSL_TEXM3X3SPEC(Context *ctx)
897
898
899
900
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXM3X3SPEC
901
static void emit_GLSL_TEXM3X3VSPEC(Context *ctx)
902
903
904
905
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXM3X3VSPEC
906
static void emit_GLSL_EXPP(Context *ctx)
907
908
909
910
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_EXPP
911
static void emit_GLSL_LOGP(Context *ctx)
912
913
914
915
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_LOGP
916
static void emit_GLSL_CND(Context *ctx)
917
918
919
920
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_CND
921
static void emit_GLSL_DEF(Context *ctx)
922
923
924
925
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DEF
926
static void emit_GLSL_TEXREG2RGB(Context *ctx)
927
928
929
930
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXREG2RGB
931
static void emit_GLSL_TEXDP3TEX(Context *ctx)
932
933
934
935
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXDP3TEX
936
static void emit_GLSL_TEXM3X2DEPTH(Context *ctx)
937
938
939
940
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXM3X2DEPTH
941
static void emit_GLSL_TEXDP3(Context *ctx)
942
943
944
945
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXDP3
946
static void emit_GLSL_TEXM3X3(Context *ctx)
947
948
949
950
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXM3X3
951
static void emit_GLSL_TEXDEPTH(Context *ctx)
952
953
954
955
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXDEPTH
956
static void emit_GLSL_CMP(Context *ctx)
957
958
959
960
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_CMP
961
static void emit_GLSL_BEM(Context *ctx)
962
963
964
965
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_BEM
966
static void emit_GLSL_DP2ADD(Context *ctx)
967
968
969
970
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DP2ADD
971
static void emit_GLSL_DSX(Context *ctx)
972
973
974
975
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DSX
976
static void emit_GLSL_DSY(Context *ctx)
977
978
979
980
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_DSY
981
static void emit_GLSL_TEXLDD(Context *ctx)
982
983
984
985
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXLDD
986
static void emit_GLSL_SETP(Context *ctx)
987
988
989
990
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_SETP
991
static void emit_GLSL_TEXLDL(Context *ctx)
992
993
994
995
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_TEXLDL
996
static void emit_GLSL_BREAKP(Context *ctx)
997
998
999
1000
{
fail(ctx, "unimplemented."); // !!! FIXME
} // emit_GLSL_BREAKP