| 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_d3d.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_D3Dcxx . . $ `mojoshader_internal.h:170:9`! |
| 16 | |
| 17 | const char *make_D3D_srcarg_string_in_bufcxx . . $ make_D3D_srcarg_string_in_buf(20f5a7578b5368a).(Contextcxx . . $ Context# *ctx, |
| 18 | const SourceArgInfocxx . . $ SourceArgInfo# *arg, |
| 19 | char *buf, size_t buflen) |
| 20 | { |
| 21 | const char *premod_str = ""; |
| 22 | const char *postmod_str = ""; |
| 23 | switch (arg->src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod.) |
| 24 | { |
| 25 | case SRCMOD_NEGATEcxx . . $ SRCMOD_NEGATE.: |
| 26 | premod_str = "-"; |
| 27 | break; |
| 28 | |
| 29 | case SRCMOD_BIASNEGATEcxx . . $ SRCMOD_BIASNEGATE.: |
| 30 | premod_str = "-"; |
| 31 | // fall through. |
| 32 | case SRCMOD_BIAScxx . . $ SRCMOD_BIAS.: |
| 33 | postmod_str = "_bias"; |
| 34 | break; |
| 35 | |
| 36 | case SRCMOD_SIGNNEGATEcxx . . $ SRCMOD_SIGNNEGATE.: |
| 37 | premod_str = "-"; |
| 38 | // fall through. |
| 39 | case SRCMOD_SIGNcxx . . $ SRCMOD_SIGN.: |
| 40 | postmod_str = "_bx2"; |
| 41 | break; |
| 42 | |
| 43 | case SRCMOD_COMPLEMENTcxx . . $ SRCMOD_COMPLEMENT.: |
| 44 | premod_str = "1-"; |
| 45 | break; |
| 46 | |
| 47 | case SRCMOD_X2NEGATEcxx . . $ SRCMOD_X2NEGATE.: |
| 48 | premod_str = "-"; |
| 49 | // fall through. |
| 50 | case SRCMOD_X2cxx . . $ SRCMOD_X2.: |
| 51 | postmod_str = "_x2"; |
| 52 | break; |
| 53 | |
| 54 | case SRCMOD_DZcxx . . $ SRCMOD_DZ.: |
| 55 | postmod_str = "_dz"; |
| 56 | break; |
| 57 | |
| 58 | case SRCMOD_DWcxx . . $ SRCMOD_DW.: |
| 59 | postmod_str = "_dw"; |
| 60 | break; |
| 61 | |
| 62 | case SRCMOD_ABSNEGATEcxx . . $ SRCMOD_ABSNEGATE.: |
| 63 | premod_str = "-"; |
| 64 | // fall through. |
| 65 | case SRCMOD_ABScxx . . $ SRCMOD_ABS.: |
| 66 | postmod_str = "_abs"; |
| 67 | break; |
| 68 | |
| 69 | case SRCMOD_NOTcxx . . $ SRCMOD_NOT.: |
| 70 | premod_str = "!"; |
| 71 | break; |
| 72 | |
| 73 | case SRCMOD_NONEcxx . . $ SRCMOD_NONE.: |
| 74 | case SRCMOD_TOTALcxx . . $ SRCMOD_TOTAL.: |
| 75 | break; // stop compiler whining. |
| 76 | } // switch |
| 77 | |
| 78 | |
| 79 | char regnum_str[16]; |
| 80 | const char *regtype_str = get_D3D_register_stringcxx . . $ get_D3D_register_string(e11e601b5c61efa5).(ctx, arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., |
| 81 | arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum., regnum_str, |
| 82 | sizeof (regnum_str)); |
| 83 | |
| 84 | if (regtype_str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 85 | { |
| 86 | failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Unknown source register type."); |
| 87 | *buf = '\0'; |
| 88 | return buf; |
| 89 | } // if |
| 90 | |
| 91 | const char *rel_lbracket = ""; |
| 92 | const char *rel_rbracket = ""; |
| 93 | char rel_swizzle[4] = { '\0' }; |
| 94 | char rel_regnum_str[16] = { '\0' }; |
| 95 | const char *rel_regtype_str = ""; |
| 96 | if (arg->relativecxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative.) |
| 97 | { |
| 98 | if (arg->relative_regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_regtype. == REG_TYPE_LOOPcxx . . $ REG_TYPE_LOOP.) |
| 99 | { |
| 100 | rel_swizzle[0] = '\0'; |
| 101 | rel_swizzle[1] = '\0'; |
| 102 | rel_swizzle[2] = '\0'; |
| 103 | } // if |
| 104 | else |
| 105 | { |
| 106 | rel_swizzle[0] = '.'; |
| 107 | rel_swizzle[1] = swizzle_channelscxx . . $ swizzle_channels.[arg->relative_componentcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_component.]; |
| 108 | rel_swizzle[2] = '\0'; |
| 109 | } // else |
| 110 | |
| 111 | rel_lbracket = "["; |
| 112 | rel_rbracket = "]"; |
| 113 | rel_regtype_str = get_D3D_register_stringcxx . . $ get_D3D_register_string(e11e601b5c61efa5).(ctx, arg->relative_regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_regtype., |
| 114 | arg->relative_regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_regnum., |
| 115 | rel_regnum_str, |
| 116 | sizeof (rel_regnum_str)); |
| 117 | |
| 118 | if (regtype_str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 119 | { |
| 120 | failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Unknown relative source register type."); |
| 121 | *buf = '\0'; |
| 122 | return buf; |
| 123 | } // if |
| 124 | } // if |
| 125 | |
| 126 | char swizzle_str[6]; |
| 127 | size_t i = 0; |
| 128 | const int scalar = isscalarcxx . . $ isscalar(9d8abf502d86d4f4).(ctx, ctx->shader_typecxx . . $ Context#shader_type., arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.); |
| 129 | if (!scalar && !no_swizzlecxx . . $ no_swizzle(7864480464b09eea).(arg->swizzlecxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle.)) |
| 130 | { |
| 131 | swizzle_str[i++] = '.'; |
| 132 | swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_xcxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_x.]; |
| 133 | swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_ycxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_y.]; |
| 134 | swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_zcxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_z.]; |
| 135 | swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_wcxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_w.]; |
| 136 | |
| 137 | // .xyzz is the same as .xyz, .z is the same as .zzzz, etc. |
| 138 | while (swizzle_str[i-1] == swizzle_str[i-2]) |
| 139 | i--; |
| 140 | } // if |
| 141 | swizzle_str[i] = '\0'; |
| 142 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < sizeof (swizzle_str)); |
| 143 | |
| 144 | // !!! FIXME: c12[a0.x] actually needs to be c[a0.x + 12] |
| 145 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "%s%s%s%s%s%s%s%s%s%s", |
| 146 | premod_str, regtype_str, regnum_str, postmod_str, |
| 147 | rel_lbracket, rel_regtype_str, rel_regnum_str, rel_swizzle, |
| 148 | rel_rbracket, swizzle_str); |
| 149 | // !!! FIXME: make sure the scratch buffer was large enough. |
| 150 | return buf; |
| 151 | } // make_D3D_srcarg_string_in_buf |
| 152 | |
| 153 | |
| 154 | const char *make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(Contextcxx . . $ Context# *ctx, char *buf, |
| 155 | const size_t buflen) |
| 156 | { |
| 157 | const DestArgInfocxx . . $ DestArgInfo# *arg = &ctx->dest_argcxx . . $ Context#dest_arg.; |
| 158 | |
| 159 | const char *result_shift_str = ""; |
| 160 | switch (arg->result_shiftcxx . . $ $anonymous_type_32753e8ce5863620_5#result_shift.) |
| 161 | { |
| 162 | case 0x1: result_shift_str = "_x2"; break; |
| 163 | case 0x2: result_shift_str = "_x4"; break; |
| 164 | case 0x3: result_shift_str = "_x8"; break; |
| 165 | case 0xD: result_shift_str = "_d8"; break; |
| 166 | case 0xE: result_shift_str = "_d4"; break; |
| 167 | case 0xF: result_shift_str = "_d2"; break; |
| 168 | } // switch |
| 169 | |
| 170 | const char *sat_str = (arg->result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. & MOD_SATURATEcxx . . $ `mojoshader_internal.h:503:9`!) ? "_sat" : ""; |
| 171 | const char *pp_str = (arg->result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. & MOD_PPcxx . . $ `mojoshader_internal.h:504:9`!) ? "_pp" : ""; |
| 172 | const char *cent_str = (arg->result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. & MOD_CENTROIDcxx . . $ `mojoshader_internal.h:505:9`!) ? "_centroid" : ""; |
| 173 | |
| 174 | char regnum_str[16]; |
| 175 | const char *regtype_str = get_D3D_register_stringcxx . . $ get_D3D_register_string(e11e601b5c61efa5).(ctx, arg->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., |
| 176 | arg->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum., regnum_str, |
| 177 | sizeof (regnum_str)); |
| 178 | if (regtype_str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 179 | { |
| 180 | failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Unknown destination register type."); |
| 181 | *buf = '\0'; |
| 182 | return buf; |
| 183 | } // if |
| 184 | |
| 185 | char writemask_str[6]; |
| 186 | size_t i = 0; |
| 187 | const int scalar = isscalarcxx . . $ isscalar(9d8abf502d86d4f4).(ctx, ctx->shader_typecxx . . $ Context#shader_type., arg->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., arg->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.); |
| 188 | if (!scalar && !writemask_xyzwcxx . . $ writemask_xyzw(7864480464b09eea).(arg->writemaskcxx . . $ $anonymous_type_32753e8ce5863620_5#writemask.)) |
| 189 | { |
| 190 | writemask_str[i++] = '.'; |
| 191 | if (arg->writemask0cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask0.) writemask_str[i++] = 'x'; |
| 192 | if (arg->writemask1cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask1.) writemask_str[i++] = 'y'; |
| 193 | if (arg->writemask2cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask2.) writemask_str[i++] = 'z'; |
| 194 | if (arg->writemask3cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask3.) writemask_str[i++] = 'w'; |
| 195 | } // if |
| 196 | writemask_str[i] = '\0'; |
| 197 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < sizeof (writemask_str)); |
| 198 | |
| 199 | const char *pred_left = ""; |
| 200 | const char *pred_right = ""; |
| 201 | char pred[32] = { '\0' }; |
| 202 | if (ctx->predicatedcxx . . $ Context#predicated.) |
| 203 | { |
| 204 | pred_left = "("; |
| 205 | pred_right = ") "; |
| 206 | make_D3D_srcarg_string_in_bufcxx . . $ make_D3D_srcarg_string_in_buf(20f5a7578b5368a).(ctx, &ctx->predicate_argcxx . . $ Context#predicate_arg., |
| 207 | pred, sizeof (pred)); |
| 208 | } // if |
| 209 | |
| 210 | // may turn out something like "_x2_sat_pp_centroid (!p0.x) r0.xyzw" ... |
| 211 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "%s%s%s%s %s%s%s%s%s%s", |
| 212 | result_shift_str, sat_str, pp_str, cent_str, |
| 213 | pred_left, pred, pred_right, |
| 214 | regtype_str, regnum_str, writemask_str); |
| 215 | // !!! FIXME: make sure the scratch buffer was large enough. |
| 216 | return buf; |
| 217 | } // make_D3D_destarg_string |
| 218 | |
| 219 | |
| 220 | const char *make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(Contextcxx . . $ Context# *ctx, const size_t idx, |
| 221 | char *buf, size_t buflen) |
| 222 | { |
| 223 | if (idx >= STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->source_args)) |
| 224 | { |
| 225 | failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Too many source args"); |
| 226 | *buf = '\0'; |
| 227 | return buf; |
| 228 | } // if |
| 229 | |
| 230 | const SourceArgInfocxx . . $ SourceArgInfo# *arg = &ctx->source_argscxx . . $ Context#source_args.[idx]; |
| 231 | return make_D3D_srcarg_string_in_bufcxx . . $ make_D3D_srcarg_string_in_buf(20f5a7578b5368a).(ctx, arg, buf, buflen); |
| 232 | } // make_D3D_srcarg_string |
| 233 | |
| 234 | const char *get_D3D_const_array_varnamecxx . . $ get_D3D_const_array_varname(dd436b49467e1d26).(Contextcxx . . $ Context# *ctx, int base, int size) |
| 235 | { |
| 236 | char buf[64]; |
| 237 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof (buf), "c_array_%d_%d", base, size); |
| 238 | return StrDupcxx . . $ StrDup(5771b401aae6b992).(ctx, buf); |
| 239 | } // get_D3D_const_array_varname |
| 240 | |
| 241 | |
| 242 | void emit_D3D_startcxx . . $ emit_D3D_start(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *profilestr) |
| 243 | { |
| 244 | const uintcxx . . $ uint# major = (uintcxx . . $ uint#) ctx->major_vercxx . . $ Context#major_ver.; |
| 245 | const uintcxx . . $ uint# minor = (uintcxx . . $ uint#) ctx->minor_vercxx . . $ Context#minor_ver.; |
| 246 | char minor_str[16]; |
| 247 | |
| 248 | ctx->ignores_ctabcxx . . $ Context#ignores_ctab. = 1; |
| 249 | |
| 250 | if (minor == 0xFF) |
| 251 | strcpycxx . . $ strcpy(b7b3a83273496486).(minor_str, "sw"); |
| 252 | else if ((major > 1) && (minor == 1)) |
| 253 | strcpycxx . . $ strcpy(b7b3a83273496486).(minor_str, "x"); // for >= SM2, apparently this is "x". Weird. |
| 254 | else |
| 255 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(minor_str, sizeof (minor_str), "%u", (uintcxx . . $ uint#) minor); |
| 256 | |
| 257 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s_%u_%s", ctx->shader_type_strcxx . . $ Context#shader_type_str., major, minor_str); |
| 258 | } // emit_D3D_start |
| 259 | |
| 260 | |
| 261 | void emit_D3D_endcxx . . $ emit_D3D_end(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 262 | { |
| 263 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "end"); |
| 264 | } // emit_D3D_end |
| 265 | |
| 266 | |
| 267 | void emit_D3D_phasecxx . . $ emit_D3D_phase(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 268 | { |
| 269 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "phase"); |
| 270 | } // emit_D3D_phase |
| 271 | |
| 272 | |
| 273 | void emit_D3D_finalizecxx . . $ emit_D3D_finalize(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 274 | { |
| 275 | // no-op. |
| 276 | } // emit_D3D_finalize |
| 277 | |
| 278 | |
| 279 | void emit_D3D_globalcxx . . $ emit_D3D_global(8475323e8d0fe52d).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum) |
| 280 | { |
| 281 | // no-op. |
| 282 | } // emit_D3D_global |
| 283 | |
| 284 | |
| 285 | void emit_D3D_arraycxx . . $ emit_D3D_array(4368dce1b98e99b8).(Contextcxx . . $ Context# *ctx, VariableListcxx . . $ VariableList# *var) |
| 286 | { |
| 287 | // no-op. |
| 288 | } // emit_D3D_array |
| 289 | |
| 290 | |
| 291 | void emit_D3D_const_arraycxx . . $ emit_D3D_const_array(36ee158898c90b50).(Contextcxx . . $ Context# *ctx, const ConstantsListcxx . . $ ConstantsList# *clist, |
| 292 | int base, int size) |
| 293 | { |
| 294 | // no-op. |
| 295 | } // emit_D3D_const_array |
| 296 | |
| 297 | |
| 298 | void emit_D3D_uniformcxx . . $ emit_D3D_uniform(8b79ccde41759557).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum, |
| 299 | const VariableListcxx . . $ VariableList# *var) |
| 300 | { |
| 301 | // no-op. |
| 302 | } // emit_D3D_uniform |
| 303 | |
| 304 | |
| 305 | void emit_D3D_samplercxx . . $ emit_D3D_sampler(a3a55aa9b8aa8087).(Contextcxx . . $ Context# *ctx, int s, TextureTypecxx . . $ TextureType# ttype, int tb) |
| 306 | { |
| 307 | // no-op. |
| 308 | } // emit_D3D_sampler |
| 309 | |
| 310 | |
| 311 | void emit_D3D_attributecxx . . $ emit_D3D_attribute(cc51a07b10397b54).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum, |
| 312 | MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, int index, int wmask, |
| 313 | int flags) |
| 314 | { |
| 315 | // no-op. |
| 316 | } // emit_D3D_attribute |
| 317 | |
| 318 | |
| 319 | void emit_D3D_RESERVEDcxx . . $ emit_D3D_RESERVED(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 320 | { |
| 321 | // do nothing; fails in the state machine. |
| 322 | } // emit_D3D_RESERVED |
| 323 | |
| 324 | |
| 325 | // Generic D3D opcode emitters. A list of macros generate all the entry points |
| 326 | // that call into these... |
| 327 | |
| 328 | char *lowercasecxx . . $ lowercase(b7b3a83273496486).(char *dst, const char *src) |
| 329 | { |
| 330 | int i = 0; |
| 331 | do |
| 332 | { |
| 333 | const char ch = src[i]; |
| 334 | dst[i] = (((ch >= 'A') && (ch <= 'Z')) ? (ch - ('A' - 'a')) : ch); |
| 335 | } while (src[i++]); |
| 336 | return dst; |
| 337 | } // lowercase |
| 338 | |
| 339 | |
| 340 | void emit_D3D_opcode_dcxx . . $ emit_D3D_opcode_d(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode) |
| 341 | { |
| 342 | char dst[64]; make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 343 | opcode = lowercasecxx . . $ lowercase(b7b3a83273496486).((char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(strlen(opcode) + 1), opcode); |
| 344 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s%s", ctx->coissuecxx . . $ Context#coissue. ? "+" : "", opcode, dst); |
| 345 | } // emit_D3D_opcode_d |
| 346 | |
| 347 | |
| 348 | void emit_D3D_opcode_scxx . . $ emit_D3D_opcode_s(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode) |
| 349 | { |
| 350 | char src0[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0)); |
| 351 | opcode = lowercasecxx . . $ lowercase(b7b3a83273496486).((char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(strlen(opcode) + 1), opcode); |
| 352 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s %s", ctx->coissuecxx . . $ Context#coissue. ? "+" : "", opcode, src0); |
| 353 | } // emit_D3D_opcode_s |
| 354 | |
| 355 | |
| 356 | void emit_D3D_opcode_sscxx . . $ emit_D3D_opcode_ss(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode) |
| 357 | { |
| 358 | char src0[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0)); |
| 359 | char src1[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1)); |
| 360 | opcode = lowercasecxx . . $ lowercase(b7b3a83273496486).((char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(strlen(opcode) + 1), opcode); |
| 361 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s %s, %s", ctx->coissuecxx . . $ Context#coissue. ? "+" : "", opcode, src0, src1); |
| 362 | } // emit_D3D_opcode_ss |
| 363 | |
| 364 | |
| 365 | void emit_D3D_opcode_dscxx . . $ emit_D3D_opcode_ds(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode) |
| 366 | { |
| 367 | char dst[64]; make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 368 | char src0[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0)); |
| 369 | opcode = lowercasecxx . . $ lowercase(b7b3a83273496486).((char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(strlen(opcode) + 1), opcode); |
| 370 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s%s, %s", ctx->coissuecxx . . $ Context#coissue. ? "+" : "", opcode, dst, src0); |
| 371 | } // emit_D3D_opcode_ds |
| 372 | |
| 373 | |
| 374 | void emit_D3D_opcode_dsscxx . . $ emit_D3D_opcode_dss(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode) |
| 375 | { |
| 376 | char dst[64]; make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 377 | char src0[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0)); |
| 378 | char src1[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1)); |
| 379 | opcode = lowercasecxx . . $ lowercase(b7b3a83273496486).((char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(strlen(opcode) + 1), opcode); |
| 380 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s%s, %s, %s", ctx->coissuecxx . . $ Context#coissue. ? "+" : "", |
| 381 | opcode, dst, src0, src1); |
| 382 | } // emit_D3D_opcode_dss |
| 383 | |
| 384 | |
| 385 | void emit_D3D_opcode_dssscxx . . $ emit_D3D_opcode_dsss(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode) |
| 386 | { |
| 387 | char dst[64]; make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 388 | char src0[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0)); |
| 389 | char src1[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1)); |
| 390 | char src2[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 2, src2, sizeof (src2)); |
| 391 | opcode = lowercasecxx . . $ lowercase(b7b3a83273496486).((char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(strlen(opcode) + 1), opcode); |
| 392 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s%s, %s, %s, %s", ctx->coissuecxx . . $ Context#coissue. ? "+" : "", |
| 393 | opcode, dst, src0, src1, src2); |
| 394 | } // emit_D3D_opcode_dsss |
| 395 | |
| 396 | |
| 397 | void emit_D3D_opcode_dsssscxx . . $ emit_D3D_opcode_dssss(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode) |
| 398 | { |
| 399 | char dst[64]; make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 400 | char src0[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0)); |
| 401 | char src1[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1)); |
| 402 | char src2[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 2, src2, sizeof (src2)); |
| 403 | char src3[64]; make_D3D_srcarg_stringcxx . . $ make_D3D_srcarg_string(977c8228f57f653a).(ctx, 3, src3, sizeof (src3)); |
| 404 | opcode = lowercasecxx . . $ lowercase(b7b3a83273496486).((char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(strlen(opcode) + 1), opcode); |
| 405 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx,"%s%s%s, %s, %s, %s, %s", ctx->coissuecxx . . $ Context#coissue. ? "+" : "", |
| 406 | opcode, dst, src0, src1, src2, src3); |
| 407 | } // emit_D3D_opcode_dssss |
| 408 | |
| 409 | |
| 410 | void emit_D3D_opcodecxx . . $ emit_D3D_opcode(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode) |
| 411 | { |
| 412 | opcode = lowercasecxx . . $ lowercase(b7b3a83273496486).((char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(strlen(opcode) + 1), opcode); |
| 413 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s", ctx->coissuecxx . . $ Context#coissue. ? "+" : "", opcode); |
| 414 | } // emit_D3D_opcode |
| 415 | |
| 416 | |
| 417 | #define EMIT_D3D_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:417:9`!(op) \ |
| 418 | void emit_D3D_##op(Context *ctx) { \ |
| 419 | emit_D3D_opcode(ctx, #op); \ |
| 420 | } |
| 421 | #define EMIT_D3D_OPCODE_D_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:421:9`!(op) \ |
| 422 | void emit_D3D_##op(Context *ctx) { \ |
| 423 | emit_D3D_opcode_d(ctx, #op); \ |
| 424 | } |
| 425 | #define EMIT_D3D_OPCODE_S_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:425:9`!(op) \ |
| 426 | void emit_D3D_##op(Context *ctx) { \ |
| 427 | emit_D3D_opcode_s(ctx, #op); \ |
| 428 | } |
| 429 | #define EMIT_D3D_OPCODE_SS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:429:9`!(op) \ |
| 430 | void emit_D3D_##op(Context *ctx) { \ |
| 431 | emit_D3D_opcode_ss(ctx, #op); \ |
| 432 | } |
| 433 | #define EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(op) \ |
| 434 | void emit_D3D_##op(Context *ctx) { \ |
| 435 | emit_D3D_opcode_ds(ctx, #op); \ |
| 436 | } |
| 437 | #define EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(op) \ |
| 438 | void emit_D3D_##op(Context *ctx) { \ |
| 439 | emit_D3D_opcode_dss(ctx, #op); \ |
| 440 | } |
| 441 | #define EMIT_D3D_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:441:9`!(op) \ |
| 442 | void emit_D3D_##op(Context *ctx) { \ |
| 443 | emit_D3D_opcode_dsss(ctx, #op); \ |
| 444 | } |
| 445 | #define EMIT_D3D_OPCODE_DSSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:445:9`!(op) \ |
| 446 | void emit_D3D_##op(Context *ctx) { \ |
| 447 | emit_D3D_opcode_dssss(ctx, #op); \ |
| 448 | } |
| 449 | |
| 450 | EMIT_D3D_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:417:9`!(NOP) |
| 451 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(MOV) |
| 452 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(ADD) |
| 453 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(SUB) |
| 454 | EMIT_D3D_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:441:9`!(MAD) |
| 455 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(MUL) |
| 456 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(RCP) |
| 457 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(RSQ) |
| 458 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(DP3) |
| 459 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(DP4) |
| 460 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(MIN) |
| 461 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(MAX) |
| 462 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(SLT) |
| 463 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(SGE) |
| 464 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(EXP) |
| 465 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(LOG) |
| 466 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(LIT) |
| 467 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(DST) |
| 468 | EMIT_D3D_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:441:9`!(LRP) |
| 469 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(FRC) |
| 470 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(M4X4) |
| 471 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(M4X3) |
| 472 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(M3X4) |
| 473 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(M3X3) |
| 474 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(M3X2) |
| 475 | EMIT_D3D_OPCODE_S_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:425:9`!(CALL) |
| 476 | EMIT_D3D_OPCODE_SS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:429:9`!(CALLNZ) |
| 477 | EMIT_D3D_OPCODE_SS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:429:9`!(LOOP) |
| 478 | EMIT_D3D_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:417:9`!(RET) |
| 479 | EMIT_D3D_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:417:9`!(ENDLOOP) |
| 480 | EMIT_D3D_OPCODE_S_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:425:9`!(LABEL) |
| 481 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(POW) |
| 482 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(CRS) |
| 483 | EMIT_D3D_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:441:9`!(SGN) |
| 484 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(ABS) |
| 485 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(NRM) |
| 486 | EMIT_D3D_OPCODE_S_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:425:9`!(REP) |
| 487 | EMIT_D3D_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:417:9`!(ENDREP) |
| 488 | EMIT_D3D_OPCODE_S_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:425:9`!(IF) |
| 489 | EMIT_D3D_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:417:9`!(ELSE) |
| 490 | EMIT_D3D_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:417:9`!(ENDIF) |
| 491 | EMIT_D3D_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:417:9`!(BREAK) |
| 492 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(MOVA) |
| 493 | EMIT_D3D_OPCODE_D_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:421:9`!(TEXKILL) |
| 494 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXBEM) |
| 495 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXBEML) |
| 496 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXREG2AR) |
| 497 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXREG2GB) |
| 498 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXM3X2PAD) |
| 499 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXM3X2TEX) |
| 500 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXM3X3PAD) |
| 501 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXM3X3TEX) |
| 502 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(TEXM3X3SPEC) |
| 503 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXM3X3VSPEC) |
| 504 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(EXPP) |
| 505 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(LOGP) |
| 506 | EMIT_D3D_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:441:9`!(CND) |
| 507 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXREG2RGB) |
| 508 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXDP3TEX) |
| 509 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXM3X2DEPTH) |
| 510 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXDP3) |
| 511 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(TEXM3X3) |
| 512 | EMIT_D3D_OPCODE_D_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:421:9`!(TEXDEPTH) |
| 513 | EMIT_D3D_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:441:9`!(CMP) |
| 514 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(BEM) |
| 515 | EMIT_D3D_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:441:9`!(DP2ADD) |
| 516 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(DSX) |
| 517 | EMIT_D3D_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:433:9`!(DSY) |
| 518 | EMIT_D3D_OPCODE_DSSSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:445:9`!(TEXLDD) |
| 519 | EMIT_D3D_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:437:9`!(TEXLDL) |
| 520 | EMIT_D3D_OPCODE_S_FUNCcxx . . $ `profiles/mojoshader_profile_d3d.c:425:9`!(BREAKP) |
| 521 | |
| 522 | // special cases for comparison opcodes... |
| 523 | const char *get_D3D_comparison_stringcxx . . $ get_D3D_comparison_string(1b231eb8e08cb0d8).(Contextcxx . . $ Context# *ctx) |
| 524 | { |
| 525 | const char *comps[] = { |
| 526 | "", "_gt", "_eq", "_ge", "_lt", "_ne", "_le" |
| 527 | }; |
| 528 | |
| 529 | if (ctx->instruction_controlscxx . . $ Context#instruction_controls. >= STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(comps)) |
| 530 | { |
| 531 | failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown comparison control"); |
| 532 | return ""; |
| 533 | } // if |
| 534 | |
| 535 | return comps[ctx->instruction_controlscxx . . $ Context#instruction_controls.]; |
| 536 | } // get_D3D_comparison_string |
| 537 | |
| 538 | void emit_D3D_BREAKCcxx . . $ emit_D3D_BREAKC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 539 | { |
| 540 | char op[16]; |
| 541 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(op, sizeof (op), "break%s", get_D3D_comparison_stringcxx . . $ get_D3D_comparison_string(1b231eb8e08cb0d8).(ctx)); |
| 542 | emit_D3D_opcode_sscxx . . $ emit_D3D_opcode_ss(72ff1ec6cf40f147).(ctx, op); |
| 543 | } // emit_D3D_BREAKC |
| 544 | |
| 545 | void emit_D3D_IFCcxx . . $ emit_D3D_IFC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 546 | { |
| 547 | char op[16]; |
| 548 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(op, sizeof (op), "if%s", get_D3D_comparison_stringcxx . . $ get_D3D_comparison_string(1b231eb8e08cb0d8).(ctx)); |
| 549 | emit_D3D_opcode_sscxx . . $ emit_D3D_opcode_ss(72ff1ec6cf40f147).(ctx, op); |
| 550 | } // emit_D3D_IFC |
| 551 | |
| 552 | void emit_D3D_SETPcxx . . $ emit_D3D_SETP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 553 | { |
| 554 | char op[16]; |
| 555 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(op, sizeof (op), "setp%s", get_D3D_comparison_stringcxx . . $ get_D3D_comparison_string(1b231eb8e08cb0d8).(ctx)); |
| 556 | emit_D3D_opcode_dsscxx . . $ emit_D3D_opcode_dss(72ff1ec6cf40f147).(ctx, op); |
| 557 | } // emit_D3D_SETP |
| 558 | |
| 559 | void emit_D3D_DEFcxx . . $ emit_D3D_DEF(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 560 | { |
| 561 | char dst[64]; |
| 562 | make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 563 | const float *val = (const float *) ctx->dwordscxx . . $ Context#dwords.; // !!! FIXME: could be int? |
| 564 | char val0[32]; |
| 565 | char val1[32]; |
| 566 | char val2[32]; |
| 567 | char val3[32]; |
| 568 | floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val0, sizeof (val0), val[0], 0); |
| 569 | floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val1, sizeof (val1), val[1], 0); |
| 570 | floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val2, sizeof (val2), val[2], 0); |
| 571 | floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val3, sizeof (val3), val[3], 0); |
| 572 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "def%s, %s, %s, %s, %s", dst, val0, val1, val2, val3); |
| 573 | } // emit_D3D_DEF |
| 574 | |
| 575 | void emit_D3D_DEFIcxx . . $ emit_D3D_DEFI(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 576 | { |
| 577 | char dst[64]; |
| 578 | make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 579 | const int32cxx . . $ int32# *x = (const int32cxx . . $ int32# *) ctx->dwordscxx . . $ Context#dwords.; |
| 580 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "defi%s, %d, %d, %d, %d", dst, |
| 581 | (int) x[0], (int) x[1], (int) x[2], (int) x[3]); |
| 582 | } // emit_D3D_DEFI |
| 583 | |
| 584 | void emit_D3D_DEFBcxx . . $ emit_D3D_DEFB(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 585 | { |
| 586 | char dst[64]; |
| 587 | make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 588 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "defb%s, %s", dst, ctx->dwordscxx . . $ Context#dwords.[0] ? "true" : "false"); |
| 589 | } // emit_D3D_DEFB |
| 590 | |
| 591 | |
| 592 | static const char *usagestrscxx . . $ usagestrs.[] = { |
| 593 | "_position", "_blendweight", "_blendindices", "_normal", "_psize", |
| 594 | "_texcoord", "_tangent", "_binormal", "_tessfactor", "_positiont", |
| 595 | "_color", "_fog", "_depth", "_sample" |
| 596 | }; |
| 597 | |
| 598 | void emit_D3D_DCLcxx . . $ emit_D3D_DCL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 599 | { |
| 600 | char dst[64]; |
| 601 | make_D3D_destarg_stringcxx . . $ make_D3D_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst)); |
| 602 | const DestArgInfocxx . . $ DestArgInfo# *arg = &ctx->dest_argcxx . . $ Context#dest_arg.; |
| 603 | const char *usage_str = ""; |
| 604 | char index_str[16] = { '\0' }; |
| 605 | |
| 606 | if (arg->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype. == REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER.) |
| 607 | { |
| 608 | switch ((const TextureTypecxx . . $ TextureType#) ctx->dwordscxx . . $ Context#dwords.[0]) |
| 609 | { |
| 610 | case TEXTURE_TYPE_2Dcxx . . $ TEXTURE_TYPE_2D.: usage_str = "_2d"; break; |
| 611 | case TEXTURE_TYPE_CUBEcxx . . $ TEXTURE_TYPE_CUBE.: usage_str = "_cube"; break; |
| 612 | case TEXTURE_TYPE_VOLUMEcxx . . $ TEXTURE_TYPE_VOLUME.: usage_str = "_volume"; break; |
| 613 | default: failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown sampler texture type"); return; |
| 614 | } // switch |
| 615 | } // if |
| 616 | |
| 617 | else if (arg->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype. == REG_TYPE_MISCTYPEcxx . . $ REG_TYPE_MISCTYPE.) |
| 618 | { |
| 619 | switch ((const MiscTypeTypecxx . . $ MiscTypeType#) arg->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.) |
| 620 | { |
| 621 | case MISCTYPE_TYPE_POSITIONcxx . . $ MISCTYPE_TYPE_POSITION.: |
| 622 | case MISCTYPE_TYPE_FACEcxx . . $ MISCTYPE_TYPE_FACE.: |
| 623 | usage_str = ""; // just become "dcl vFace" or whatever. |
| 624 | break; |
| 625 | default: failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown misc register type"); return; |
| 626 | } // switch |
| 627 | } // else if |
| 628 | |
| 629 | else |
| 630 | { |
| 631 | const uint32cxx . . $ uint32# usage = ctx->dwordscxx . . $ Context#dwords.[0]; |
| 632 | const uint32cxx . . $ uint32# index = ctx->dwordscxx . . $ Context#dwords.[1]; |
| 633 | usage_str = usagestrscxx . . $ usagestrs.[usage]; |
| 634 | if (index != 0) |
| 635 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(index_str, sizeof (index_str), "%u", (uintcxx . . $ uint#) index); |
| 636 | } // else |
| 637 | |
| 638 | output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "dcl%s%s%s", usage_str, index_str, dst); |
| 639 | } // emit_D3D_DCL |
| 640 | |
| 641 | |
| 642 | void emit_D3D_TEXCRDcxx . . $ emit_D3D_TEXCRD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 643 | { |
| 644 | // this opcode looks and acts differently depending on the shader model. |
| 645 | if (shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4)) |
| 646 | emit_D3D_opcode_dscxx . . $ emit_D3D_opcode_ds(72ff1ec6cf40f147).(ctx, "texcrd"); |
| 647 | else |
| 648 | emit_D3D_opcode_dcxx . . $ emit_D3D_opcode_d(72ff1ec6cf40f147).(ctx, "texcoord"); |
| 649 | } // emit_D3D_TEXCOORD |
| 650 | |
| 651 | void emit_D3D_TEXLDcxx . . $ emit_D3D_TEXLD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 652 | { |
| 653 | // this opcode looks and acts differently depending on the shader model. |
| 654 | if (shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 2, 0)) |
| 655 | { |
| 656 | if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDcxx . . $ `mojoshader_internal.h:471:9`!) |
| 657 | emit_D3D_opcode_dsscxx . . $ emit_D3D_opcode_dss(72ff1ec6cf40f147).(ctx, "texld"); |
| 658 | else if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDPcxx . . $ `mojoshader_internal.h:472:9`!) |
| 659 | emit_D3D_opcode_dsscxx . . $ emit_D3D_opcode_dss(72ff1ec6cf40f147).(ctx, "texldp"); |
| 660 | else if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDBcxx . . $ `mojoshader_internal.h:473:9`!) |
| 661 | emit_D3D_opcode_dsscxx . . $ emit_D3D_opcode_dss(72ff1ec6cf40f147).(ctx, "texldb"); |
| 662 | } // if |
| 663 | |
| 664 | else if (shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4)) |
| 665 | { |
| 666 | emit_D3D_opcode_dscxx . . $ emit_D3D_opcode_ds(72ff1ec6cf40f147).(ctx, "texld"); |
| 667 | } // else if |
| 668 | |
| 669 | else |
| 670 | { |
| 671 | emit_D3D_opcode_dcxx . . $ emit_D3D_opcode_d(72ff1ec6cf40f147).(ctx, "tex"); |
| 672 | } // else |
| 673 | } // emit_D3D_TEXLD |
| 674 | |
| 675 | void emit_D3D_SINCOScxx . . $ emit_D3D_SINCOS(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) |
| 676 | { |
| 677 | // this opcode needs extra registers for sm2 and lower. |
| 678 | if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 3, 0)) |
| 679 | emit_D3D_opcode_dssscxx . . $ emit_D3D_opcode_dsss(72ff1ec6cf40f147).(ctx, "sincos"); |
| 680 | else |
| 681 | emit_D3D_opcode_dscxx . . $ emit_D3D_opcode_ds(72ff1ec6cf40f147).(ctx, "sincos"); |
| 682 | } // emit_D3D_SINCOS |
| 683 | |
| 684 | #endif // SUPPORT_PROFILE_D3D |
| 685 | |
| 686 | #pragma GCC visibility pop |