| 1 | /** |
| 2 | * MojoShader; generate shader programs from bytecode of compiled |
| 3 | * Direct3D shaders. |
| 4 | * |
| 5 | * Please see the file LICENSE.txt in the source's root directory. |
| 6 | * |
| 7 | * This file written by Ryan C. Gordon. |
| 8 | */ |
| 9 | |
| 10 | #define __MOJOSHADER_INTERNAL__cxx . . $ `profiles/mojoshader_profile_bytecode.c:10:9`! 1 |
| 11 | #include "mojoshader_profile.h"cxx . . $ `<file>/profiles/mojoshader_profile.h`/ |
| 12 | |
| 13 | #pragma GCC visibility push(hidden) |
| 14 | |
| 15 | #if SUPPORT_PROFILE_BYTECODEcxx . . $ `mojoshader_internal.h:174:9`! |
| 16 | |
| 17 | void emit_BYTECODE_startcxx . . $ emit_BYTECODE_start(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *profilestr) |
| 18 | { |
| 19 | ctx->ignores_ctabcxx . . $ Context#ignores_ctab. = 1; |
| 20 | } // emit_BYTECODE_start |
| 21 | |
| 22 | void emit_BYTECODE_finalizecxx . . $ emit_BYTECODE_finalize(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 23 | { |
| 24 | // just copy the whole token stream and make all other emitters no-ops. |
| 25 | if (set_outputcxx . . $ set_output(dbab56076057d0b7).(ctx, &ctx->mainlinecxx . . $ Context#mainline.)) |
| 26 | { |
| 27 | const size_tcxx . . $ size_t# len = ((size_tcxx . . $ size_t#) (ctx->tokenscxx . . $ Context#tokens. - ctx->orig_tokenscxx . . $ Context#orig_tokens.)) * sizeof (uint32cxx . . $ uint32#); |
| 28 | buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->mainlinecxx . . $ Context#mainline., (const char *) ctx->orig_tokenscxx . . $ Context#orig_tokens., len); |
| 29 | } // if |
| 30 | } // emit_BYTECODE_finalize |
| 31 | |
| 32 | void emit_BYTECODE_endcxx . . $ emit_BYTECODE_end(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) {} |
| 33 | void emit_BYTECODE_phasecxx . . $ emit_BYTECODE_phase(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) {} |
| 34 | void emit_BYTECODE_globalcxx . . $ emit_BYTECODE_global(8475323e8d0fe52d).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# t, int n) {} |
| 35 | void emit_BYTECODE_arraycxx . . $ emit_BYTECODE_array(4368dce1b98e99b8).(Contextcxx . . $ Context# *ctx, VariableListcxx . . $ VariableList# *var) {} |
| 36 | void emit_BYTECODE_samplercxx . . $ emit_BYTECODE_sampler(a3a55aa9b8aa8087).(Contextcxx . . $ Context# *c, int s, TextureTypecxx . . $ TextureType# t, int tb) {} |
| 37 | void emit_BYTECODE_const_arraycxx . . $ emit_BYTECODE_const_array(36ee158898c90b50).(Contextcxx . . $ Context# *ctx, const ConstantsListcxx . . $ ConstantsList# *c, |
| 38 | int base, int size) {} |
| 39 | void emit_BYTECODE_uniformcxx . . $ emit_BYTECODE_uniform(8b79ccde41759557).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# t, int n, |
| 40 | const VariableListcxx . . $ VariableList# *var) {} |
| 41 | void emit_BYTECODE_attributecxx . . $ emit_BYTECODE_attribute(cc51a07b10397b54).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# t, int n, |
| 42 | MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# u, int i, int w, |
| 43 | int f) {} |
| 44 | |
| 45 | const char *get_BYTECODE_varnamecxx . . $ get_BYTECODE_varname(790d45e57673741b).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# rt, int regnum) |
| 46 | { |
| 47 | char regnum_str[16]; |
| 48 | const char *regtype_str = get_D3D_register_stringcxx . . $ get_D3D_register_string(e11e601b5c61efa5).(ctx, rt, regnum, |
| 49 | regnum_str, sizeof (regnum_str)); |
| 50 | char buf[64]; |
| 51 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof (buf), "%s%s", regtype_str, regnum_str); |
| 52 | return StrDupcxx . . $ StrDup(5771b401aae6b992).(ctx, buf); |
| 53 | } // get_BYTECODE_varname |
| 54 | |
| 55 | const char *get_BYTECODE_const_array_varnamecxx . . $ get_BYTECODE_const_array_varname(dd436b49467e1d26).(Contextcxx . . $ Context# *ctx, int base, int size) |
| 56 | { |
| 57 | char buf[64]; |
| 58 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof (buf), "c_array_%d_%d", base, size); |
| 59 | return StrDupcxx . . $ StrDup(5771b401aae6b992).(ctx, buf); |
| 60 | } // get_BYTECODE_const_array_varname |
| 61 | |
| 62 | #define EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(op) \ |
| 63 | void emit_BYTECODE_##op(Context *ctx) {} |
| 64 | |
| 65 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(RESERVED) |
| 66 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(NOP) |
| 67 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(MOV) |
| 68 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(ADD) |
| 69 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(SUB) |
| 70 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(MAD) |
| 71 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(MUL) |
| 72 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(RCP) |
| 73 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(RSQ) |
| 74 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DP3) |
| 75 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DP4) |
| 76 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(MIN) |
| 77 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(MAX) |
| 78 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(SLT) |
| 79 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(SGE) |
| 80 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(EXP) |
| 81 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(LOG) |
| 82 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(LIT) |
| 83 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DST) |
| 84 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(LRP) |
| 85 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(FRC) |
| 86 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(M4X4) |
| 87 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(M4X3) |
| 88 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(M3X4) |
| 89 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(M3X3) |
| 90 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(M3X2) |
| 91 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(CALL) |
| 92 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(CALLNZ) |
| 93 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(LOOP) |
| 94 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(RET) |
| 95 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(ENDLOOP) |
| 96 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(LABEL) |
| 97 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(POW) |
| 98 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(CRS) |
| 99 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(SGN) |
| 100 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(ABS) |
| 101 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(NRM) |
| 102 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(SINCOS) |
| 103 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(REP) |
| 104 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(ENDREP) |
| 105 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(IF) |
| 106 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(ELSE) |
| 107 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(ENDIF) |
| 108 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(BREAK) |
| 109 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(MOVA) |
| 110 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXKILL) |
| 111 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXBEM) |
| 112 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXBEML) |
| 113 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXREG2AR) |
| 114 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXREG2GB) |
| 115 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXM3X2PAD) |
| 116 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXM3X2TEX) |
| 117 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXM3X3PAD) |
| 118 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXM3X3TEX) |
| 119 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXM3X3SPEC) |
| 120 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXM3X3VSPEC) |
| 121 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(EXPP) |
| 122 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(LOGP) |
| 123 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(CND) |
| 124 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXREG2RGB) |
| 125 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXDP3TEX) |
| 126 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXM3X2DEPTH) |
| 127 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXDP3) |
| 128 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXM3X3) |
| 129 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXDEPTH) |
| 130 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(CMP) |
| 131 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(BEM) |
| 132 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DP2ADD) |
| 133 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DSX) |
| 134 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DSY) |
| 135 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXLDD) |
| 136 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXLDL) |
| 137 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(BREAKP) |
| 138 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(BREAKC) |
| 139 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(IFC) |
| 140 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(SETP) |
| 141 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DEF) |
| 142 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DEFI) |
| 143 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DEFB) |
| 144 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(DCL) |
| 145 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXCRD) |
| 146 | EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`!(TEXLD) |
| 147 | |
| 148 | #undef EMIT_BYTECODE_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_bytecode.c:62:9`! |
| 149 | |
| 150 | #endif // SUPPORT_PROFILE_BYTECODE |
| 151 | |
| 152 | #pragma GCC visibility pop |