Debian Codegraph @

profiles/mojoshader_profile_arb1.c

raw symbols SCIP
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_arb1.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_ARB1cxx . . $ `mojoshader_internal.h:198:9`!
16
17 static inline const char *get_ARB1_register_stringcxx . . $ get_ARB1_register_string(e11e601b5c61efa5).(Contextcxx . . $ Context# *ctx,
18 const RegisterTypecxx . . $ RegisterType# regtype, const int regnum,
19 char *regnum_str, const size_t regnum_size)
20 {
21 // turns out these are identical at the moment.
22 return get_D3D_register_stringcxx . . $ get_D3D_register_string(e11e601b5c61efa5).(ctx,regtype,regnum,regnum_str,regnum_size);
23 } // get_ARB1_register_string
24
25 int allocate_scratch_registercxx . . $ allocate_scratch_register(c6cdb7a367dd06c9).(Contextcxx . . $ Context# *ctx)
26 {
27 const int retval = ctx->scratch_registerscxx . . $ Context#scratch_registers.++;
28 if (retval >= ctx->max_scratch_registerscxx . . $ Context#max_scratch_registers.)
29 ctx->max_scratch_registerscxx . . $ Context#max_scratch_registers. = retval + 1;
30 return retval;
31 } // allocate_scratch_register
32
33 int allocate_branch_labelcxx . . $ allocate_branch_label(c6cdb7a367dd06c9).(Contextcxx . . $ Context# *ctx)
34 {
35 return ctx->assigned_branch_labelscxx . . $ Context#assigned_branch_labels.++;
36 } // allocate_branch_label
37
38 const char *allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(Contextcxx . . $ Context# *ctx, char *buf,
39 const size_t buflen)
40 {
41 const int scratch = allocate_scratch_registercxx . . $ allocate_scratch_register(c6cdb7a367dd06c9).(ctx);
42 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "scratch%d", scratch);
43 return buf;
44 } // allocate_ARB1_scratch_reg_name
45
46 static inline const char *get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(Contextcxx . . $ Context# *ctx, const int id,
47 char *buf, const size_t buflen)
48 {
49 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "branch_label%d", id);
50 return buf;
51 } // get_ARB1_branch_label_name
52
53 const char *get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(Contextcxx . . $ Context# *ctx, const RegisterTypecxx . . $ RegisterType# rt,
54 const int regnum, char *buf,
55 const size_t buflen)
56 {
57 // turns out these are identical at the moment.
58 return get_D3D_varname_in_bufcxx . . $ get_D3D_varname_in_buf(e11e601b5c61efa5).(ctx, rt, regnum, buf, buflen);
59 } // get_ARB1_varname_in_buf
60
61 const char *get_ARB1_varnamecxx . . $ get_ARB1_varname(790d45e57673741b).(Contextcxx . . $ Context# *ctx, const RegisterTypecxx . . $ RegisterType# rt,
62 const int regnum)
63 {
64 // turns out these are identical at the moment.
65 return get_D3D_varnamecxx . . $ get_D3D_varname(790d45e57673741b).(ctx, rt, regnum);
66 } // get_ARB1_varname
67
68
69 static inline const char *get_ARB1_const_array_varname_in_bufcxx . . $ get_ARB1_const_array_varname_in_buf(7e1cca04738fe06f).(Contextcxx . . $ Context# *ctx,
70 const int base, const int size,
71 char *buf, const size_t buflen)
72 {
73 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "c_array_%d_%d", base, size);
74 return buf;
75 } // get_ARB1_const_array_varname_in_buf
76
77
78 const char *get_ARB1_const_array_varnamecxx . . $ get_ARB1_const_array_varname(dd436b49467e1d26).(Contextcxx . . $ Context# *ctx, int base, int size)
79 {
80 char buf[64];
81 get_ARB1_const_array_varname_in_bufcxx . . $ get_ARB1_const_array_varname_in_buf(7e1cca04738fe06f).(ctx, base, size, buf, sizeof (buf));
82 return StrDupcxx . . $ StrDup(5771b401aae6b992).(ctx, buf);
83 } // get_ARB1_const_array_varname
84
85
86 const char *make_ARB1_srcarg_string_in_bufcxx . . $ make_ARB1_srcarg_string_in_buf(20f5a7578b5368a).(Contextcxx . . $ Context# *ctx,
87 const SourceArgInfocxx . . $ SourceArgInfo# *arg,
88 char *buf, size_t buflen)
89 {
90 // !!! FIXME: this can hit pathological cases where we look like this...
91 //
92 // dp3 r1.xyz, t0_bx2, t0_bx2
93 // mad r1.xyz, t0_bias, 1-r1, t0_bx2
94 //
95 // ...which do a lot of duplicate work in arb1...
96 //
97 // SUB scratch0, t0, { 0.5, 0.5, 0.5, 0.5 };
98 // MUL scratch0, scratch0, { 2.0, 2.0, 2.0, 2.0 };
99 // SUB scratch1, t0, { 0.5, 0.5, 0.5, 0.5 };
100 // MUL scratch1, scratch1, { 2.0, 2.0, 2.0, 2.0 };
101 // DP3 r1.xyz, scratch0, scratch1;
102 // SUB scratch0, t0, { 0.5, 0.5, 0.5, 0.5 };
103 // SUB scratch1, { 1.0, 1.0, 1.0, 1.0 }, r1;
104 // SUB scratch2, t0, { 0.5, 0.5, 0.5, 0.5 };
105 // MUL scratch2, scratch2, { 2.0, 2.0, 2.0, 2.0 };
106 // MAD r1.xyz, scratch0, scratch1, scratch2;
107 //
108 // ...notice that the dp3 calculates the same value into two scratch
109 // registers. This case is easier to handle; just see if multiple
110 // source args are identical, build it up once, and use the same
111 // scratch register for multiple arguments in that opcode.
112 // Even better still, only calculate things once across instructions,
113 // and be smart about letting it linger in a scratch register until we
114 // definitely don't need the calculation anymore. That's harder to
115 // write, though.
116
117 char regnum_str[16] = { '\0' };
118
119 // !!! FIXME: use get_ARB1_varname_in_buf() instead?
120 const char *regtype_str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
121 if (!arg->relativecxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative.)
122 {
123 regtype_str = get_ARB1_register_stringcxx . . $ get_ARB1_register_string(e11e601b5c61efa5).(ctx, arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype.,
124 arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum., regnum_str,
125 sizeof (regnum_str));
126 } // if
127
128 const char *rel_lbracket = "";
129 char rel_offset[32] = { '\0' };
130 const char *rel_rbracket = "";
131 char rel_swizzle[4] = { '\0' };
132 const char *rel_regtype_str = "";
133 if (arg->relativecxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative.)
134 {
135 rel_regtype_str = get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, arg->relative_regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_regtype.,
136 arg->relative_regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_regnum.,
137 (char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(64), 64);
138
139 rel_swizzle[0] = '.';
140 rel_swizzle[1] = swizzle_channelscxx . . $ swizzle_channels.[arg->relative_componentcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_component.];
141 rel_swizzle[2] = '\0';
142
143 if (!support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
144 {
145 // The address register in ARB1 only allows the '.x' component, so
146 // we need to load the component we need from a temp vector
147 // register into .x as needed.
148 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(arg->relative_regtype == REG_TYPE_ADDRESS);
149 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(arg->relative_regnum == 0);
150 if (ctx->last_address_reg_componentcxx . . $ Context#last_address_reg_component. != arg->relative_componentcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_component.)
151 {
152 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ARL %s.x, addr%d.%c;", rel_regtype_str,
153 arg->relative_regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_regnum.,
154 swizzle_channelscxx . . $ swizzle_channels.[arg->relative_componentcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_component.]);
155 ctx->last_address_reg_componentcxx . . $ Context#last_address_reg_component. = arg->relative_componentcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_component.;
156 } // if
157
158 rel_swizzle[1] = 'x';
159 } // if
160
161 if (arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype. == REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.)
162 regtype_str = "vertex.attrib";
163 else
164 {
165 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(arg->regtype == REG_TYPE_CONST);
166 const int arrayidx = arg->relative_arraycxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_array.->indexcxx . . $ VariableList#index.;
167 const int arraysize = arg->relative_arraycxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_array.->countcxx . . $ VariableList#count.;
168 const int offset = arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum. - arrayidx;
169 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(offset >= 0);
170 regtype_str = get_ARB1_const_array_varname_in_bufcxx . . $ get_ARB1_const_array_varname_in_buf(7e1cca04738fe06f).(ctx, arrayidx,
171 arraysize, (char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(64), 64);
172 if (offset != 0)
173 snprintfcxx . . $ snprintf(ea502d73e74c754c).(rel_offset, sizeof (rel_offset), " + %d", offset);
174 } // else
175
176 rel_lbracket = "[";
177 rel_rbracket = "]";
178 } // if
179
180 // This is the source register with everything but swizzle and source mods.
181 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "%s%s%s%s%s%s%s", regtype_str, regnum_str,
182 rel_lbracket, rel_regtype_str, rel_swizzle, rel_offset,
183 rel_rbracket);
184
185 // Some of the source mods need to generate instructions to a temp
186 // register, in which case we'll replace the register name.
187 const SourceModcxx . . $ SourceMod# mod = arg->src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod.;
188 const int inplace = ( (mod == SRCMOD_NONEcxx . . $ SRCMOD_NONE.) || (mod == SRCMOD_NEGATEcxx . . $ SRCMOD_NEGATE.) ||
189 ((mod == SRCMOD_ABScxx . . $ SRCMOD_ABS.) && support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) );
190
191 if (!inplace)
192 {
193 const size_t len = 64;
194 char *stackbuf = (char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(len);
195 regtype_str = allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, stackbuf, len);
196 regnum_str[0] = '\0'; // move value to scratch register.
197 rel_lbracket = ""; // scratch register won't use array.
198 rel_rbracket = "";
199 rel_offset[0] = '\0';
200 rel_swizzle[0] = '\0';
201 rel_regtype_str = "";
202 } // if
203
204 const char *premod_str = "";
205 const char *postmod_str = "";
206 switch (mod)
207 {
208 case SRCMOD_NEGATEcxx . . $ SRCMOD_NEGATE.:
209 premod_str = "-";
210 break;
211
212 case SRCMOD_BIASNEGATEcxx . . $ SRCMOD_BIASNEGATE.:
213 premod_str = "-";
214 // fall through.
215 case SRCMOD_BIAScxx . . $ SRCMOD_BIAS.:
216 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SUB %s, %s, { 0.5, 0.5, 0.5, 0.5 };",
217 regtype_str, buf);
218 break;
219
220 case SRCMOD_SIGNNEGATEcxx . . $ SRCMOD_SIGNNEGATE.:
221 premod_str = "-";
222 // fall through.
223 case SRCMOD_SIGNcxx . . $ SRCMOD_SIGN.:
224 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx,
225 "MAD %s, %s, { 2.0, 2.0, 2.0, 2.0 }, { -1.0, -1.0, -1.0, -1.0 };",
226 regtype_str, buf);
227 break;
228
229 case SRCMOD_COMPLEMENTcxx . . $ SRCMOD_COMPLEMENT.:
230 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SUB %s, { 1.0, 1.0, 1.0, 1.0 }, %s;",
231 regtype_str, buf);
232 break;
233
234 case SRCMOD_X2NEGATEcxx . . $ SRCMOD_X2NEGATE.:
235 premod_str = "-";
236 // fall through.
237 case SRCMOD_X2cxx . . $ SRCMOD_X2.:
238 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, { 2.0, 2.0, 2.0, 2.0 };",
239 regtype_str, buf);
240 break;
241
242 case SRCMOD_DZcxx . . $ SRCMOD_DZ.:
243 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "SRCMOD_DZ currently unsupported in arb1");
244 postmod_str = "_dz";
245 break;
246
247 case SRCMOD_DWcxx . . $ SRCMOD_DW.:
248 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "SRCMOD_DW currently unsupported in arb1");
249 postmod_str = "_dw";
250 break;
251
252 case SRCMOD_ABSNEGATEcxx . . $ SRCMOD_ABSNEGATE.:
253 premod_str = "-";
254 // fall through.
255 case SRCMOD_ABScxx . . $ SRCMOD_ABS.:
256 if (!support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) // GL_NV_vertex_program2_option adds this.
257 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ABS %s, %s;", regtype_str, buf);
258 else
259 {
260 premod_str = (mod == SRCMOD_ABSNEGATEcxx . . $ SRCMOD_ABSNEGATE.) ? "-|" : "|";
261 postmod_str = "|";
262 } // else
263 break;
264
265 case SRCMOD_NOTcxx . . $ SRCMOD_NOT.:
266 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "SRCMOD_NOT currently unsupported in arb1");
267 premod_str = "!";
268 break;
269
270 case SRCMOD_NONEcxx . . $ SRCMOD_NONE.:
271 case SRCMOD_TOTALcxx . . $ SRCMOD_TOTAL.:
272 break; // stop compiler whining.
273 } // switch
274
275 char swizzle_str[6];
276 size_t i = 0;
277
278 if (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) // vFace must be output as "vFace.x" in nv4.
279 {
280 if (arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype. == REG_TYPE_MISCTYPEcxx . . $ REG_TYPE_MISCTYPE.)
281 {
282 if ( ((const MiscTypeTypecxx . . $ MiscTypeType#) arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.) == MISCTYPE_TYPE_FACEcxx . . $ MISCTYPE_TYPE_FACE. )
283 {
284 swizzle_str[i++] = '.';
285 swizzle_str[i++] = 'x';
286 } // if
287 } // if
288 } // if
289
290 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.);
291 if (!scalar && !no_swizzlecxx . . $ no_swizzle(7864480464b09eea).(arg->swizzlecxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle.))
292 {
293 swizzle_str[i++] = '.';
294
295 // .xxxx is the same as .x, but .xx is illegal...scalar or full!
296 if (replicate_swizzlecxx . . $ replicate_swizzle(7864480464b09eea).(arg->swizzlecxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle.))
297 swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_xcxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_x.];
298 else
299 {
300 swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_xcxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_x.];
301 swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_ycxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_y.];
302 swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_zcxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_z.];
303 swizzle_str[i++] = swizzle_channelscxx . . $ swizzle_channels.[arg->swizzle_wcxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle_w.];
304 } // else
305 } // if
306 swizzle_str[i] = '\0';
307 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < sizeof (swizzle_str));
308
309 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "%s%s%s%s%s%s%s%s%s%s", premod_str,
310 regtype_str, regnum_str, rel_lbracket,
311 rel_regtype_str, rel_swizzle, rel_offset, rel_rbracket,
312 swizzle_str, postmod_str);
313 // !!! FIXME: make sure the scratch buffer was large enough.
314 return buf;
315 } // make_ARB1_srcarg_string_in_buf
316
317 const char *get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(Contextcxx . . $ Context# *ctx, char *buf,
318 const size_t buflen)
319 {
320 const DestArgInfocxx . . $ DestArgInfo# *arg = &ctx->dest_argcxx . . $ Context#dest_arg.;
321 return get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, arg->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., arg->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum., buf, buflen);
322 } // get_ARB1_destarg_varname
323
324 const char *get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(Contextcxx . . $ Context# *ctx, const size_t idx,
325 char *buf, const size_t buflen)
326 {
327 if (idx >= STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->source_args))
328 {
329 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Too many source args");
330 *buf = '\0';
331 return buf;
332 } // if
333
334 const SourceArgInfocxx . . $ SourceArgInfo# *arg = &ctx->source_argscxx . . $ Context#source_args.[idx];
335 return get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum., buf, buflen);
336 } // get_ARB1_srcarg_varname
337
338
339 const char *make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(Contextcxx . . $ Context# *ctx, char *buf,
340 const size_t buflen)
341 {
342 const DestArgInfocxx . . $ DestArgInfo# *arg = &ctx->dest_argcxx . . $ Context#dest_arg.;
343
344 *buf = '\0';
345
346 const char *sat_str = "";
347 if (arg->result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. & MOD_SATURATEcxx . . $ `mojoshader_internal.h:503:9`!)
348 {
349 // nv4 can use ".SAT" in all program types.
350 // For less than nv4, the "_SAT" modifier is only available in
351 // fragment shaders. Every thing else will fake it later in
352 // emit_ARB1_dest_modifiers() ...
353 if (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx))
354 sat_str = ".SAT";
355 else if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))
356 sat_str = "_SAT";
357 } // if
358
359 const char *pp_str = "";
360 if (arg->result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. & MOD_PPcxx . . $ `mojoshader_internal.h:504:9`!)
361 {
362 // Most ARB1 profiles can't do partial precision (MOD_PP), but that's
363 // okay. The spec says lots of Direct3D implementations ignore the
364 // flag anyhow.
365 if (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx))
366 pp_str = "H";
367 } // if
368
369 // CENTROID only allowed in DCL opcodes, which shouldn't come through here.
370 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((arg->result_mod & MOD_CENTROIDcxx . . $ `mojoshader_internal.h:505:9`!) == 0);
371
372 char regnum_str[16];
373 const char *regtype_str = get_ARB1_register_stringcxx . . $ get_ARB1_register_string(e11e601b5c61efa5).(ctx, arg->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype.,
374 arg->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum., regnum_str,
375 sizeof (regnum_str));
376 if (regtype_str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
377 {
378 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Unknown destination register type.");
379 return buf;
380 } // if
381
382 char writemask_str[6];
383 size_t i = 0;
384 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.);
385 if (!scalar && !writemask_xyzwcxx . . $ writemask_xyzw(7864480464b09eea).(arg->writemaskcxx . . $ $anonymous_type_32753e8ce5863620_5#writemask.))
386 {
387 writemask_str[i++] = '.';
388 if (arg->writemask0cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask0.) writemask_str[i++] = 'x';
389 if (arg->writemask1cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask1.) writemask_str[i++] = 'y';
390 if (arg->writemask2cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask2.) writemask_str[i++] = 'z';
391 if (arg->writemask3cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask3.) writemask_str[i++] = 'w';
392 } // if
393 writemask_str[i] = '\0';
394 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < sizeof (writemask_str));
395
396 //const char *pred_left = "";
397 //const char *pred_right = "";
398 char pred[32] = { '\0' };
399 if (ctx->predicatedcxx . . $ Context#predicated.)
400 {
401 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "dest register predication currently unsupported in arb1");
402 return buf;
403 //pred_left = "(";
404 //pred_right = ") ";
405 make_ARB1_srcarg_string_in_bufcxx . . $ make_ARB1_srcarg_string_in_buf(20f5a7578b5368a).(ctx, &ctx->predicate_argcxx . . $ Context#predicate_arg.,
406 pred, sizeof (pred));
407 } // if
408
409 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "%s%s %s%s%s", pp_str, sat_str,
410 regtype_str, regnum_str, writemask_str);
411 // !!! FIXME: make sure the scratch buffer was large enough.
412 return buf;
413 } // make_ARB1_destarg_string
414
415
416 void emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
417 {
418 const DestArgInfocxx . . $ DestArgInfo# *arg = &ctx->dest_argcxx . . $ Context#dest_arg.;
419
420 if (arg->result_shiftcxx . . $ $anonymous_type_32753e8ce5863620_5#result_shift. != 0x0)
421 {
422 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
423 const char *multiplier = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
424
425 switch (arg->result_shiftcxx . . $ $anonymous_type_32753e8ce5863620_5#result_shift.)
426 {
427 case 0x1: multiplier = "2.0"; break;
428 case 0x2: multiplier = "4.0"; break;
429 case 0x3: multiplier = "8.0"; break;
430 case 0xD: multiplier = "0.125"; break;
431 case 0xE: multiplier = "0.25"; break;
432 case 0xF: multiplier = "0.5"; break;
433 } // switch
434
435 if (multiplier != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
436 {
437 char var[64]; get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, var, sizeof (var));
438 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL%s, %s, %s;", dst, var, multiplier);
439 } // if
440 } // if
441
442 if (arg->result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. & MOD_SATURATEcxx . . $ `mojoshader_internal.h:503:9`!)
443 {
444 // nv4 and/or pixel shaders just used the "SAT" modifier, instead.
445 if ( (!support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) && (!shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) )
446 {
447 char var[64]; get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, var, sizeof (var));
448 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
449 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MIN%s, %s, 1.0;", dst, var);
450 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAX%s, %s, 0.0;", dst, var);
451 } // if
452 } // if
453 } // emit_ARB1_dest_modifiers
454
455
456 const char *make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(Contextcxx . . $ Context# *ctx, const size_t idx,
457 char *buf, const size_t buflen)
458 {
459 if (idx >= STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->source_args))
460 {
461 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Too many source args");
462 *buf = '\0';
463 return buf;
464 } // if
465
466 const SourceArgInfocxx . . $ SourceArgInfo# *arg = &ctx->source_argscxx . . $ Context#source_args.[idx];
467 return make_ARB1_srcarg_string_in_bufcxx . . $ make_ARB1_srcarg_string_in_buf(20f5a7578b5368a).(ctx, arg, buf, buflen);
468 } // make_ARB1_srcarg_string
469
470 void emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode)
471 {
472 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
473 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
474 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s, %s;", opcode, dst, src0);
475 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
476 } // emit_ARB1_opcode_ds
477
478 void emit_ARB1_opcode_dsscxx . . $ emit_ARB1_opcode_dss(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode)
479 {
480 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
481 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
482 char src1[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
483 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s, %s, %s;", opcode, dst, src0, src1);
484 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
485 } // emit_ARB1_opcode_dss
486
487 void emit_ARB1_opcode_dssscxx . . $ emit_ARB1_opcode_dsss(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode)
488 {
489 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
490 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
491 char src1[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
492 char src2[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 2, src2, sizeof (src2));
493 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s, %s, %s, %s;", opcode, dst, src0, src1, src2);
494 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
495 } // emit_ARB1_opcode_dsss
496
497
498 #define EMIT_ARB1_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:498:9`!(op) \
499 void emit_ARB1_##op(Context *ctx) { \
500 emit_ARB1_opcode(ctx, #op); \
501 }
502 #define EMIT_ARB1_OPCODE_D_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:502:9`!(op) \
503 void emit_ARB1_##op(Context *ctx) { \
504 emit_ARB1_opcode_d(ctx, #op); \
505 }
506 #define EMIT_ARB1_OPCODE_S_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:506:9`!(op) \
507 void emit_ARB1_##op(Context *ctx) { \
508 emit_ARB1_opcode_s(ctx, #op); \
509 }
510 #define EMIT_ARB1_OPCODE_SS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:510:9`!(op) \
511 void emit_ARB1_##op(Context *ctx) { \
512 emit_ARB1_opcode_ss(ctx, #op); \
513 }
514 #define EMIT_ARB1_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:514:9`!(op) \
515 void emit_ARB1_##op(Context *ctx) { \
516 emit_ARB1_opcode_ds(ctx, #op); \
517 }
518 #define EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(op) \
519 void emit_ARB1_##op(Context *ctx) { \
520 emit_ARB1_opcode_dss(ctx, #op); \
521 }
522 #define EMIT_ARB1_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:522:9`!(op) \
523 void emit_ARB1_##op(Context *ctx) { \
524 emit_ARB1_opcode_dsss(ctx, #op); \
525 }
526 #define EMIT_ARB1_OPCODE_DSSSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:526:9`!(op) \
527 void emit_ARB1_##op(Context *ctx) { \
528 emit_ARB1_opcode_dssss(ctx, #op); \
529 }
530 #define EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(op) \
531 void emit_ARB1_##op(Context *ctx) { \
532 failf(ctx, #op " unimplemented in %s profile", ctx->profile->name); \
533 }
534
535
536 void emit_ARB1_startcxx . . $ emit_ARB1_start(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *profilestr)
537 {
538 const char *shader_str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
539 const char *shader_full_str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
540 if (shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx))
541 {
542 shader_str = "vp";
543 shader_full_str = "vertex";
544 } // if
545 else if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))
546 {
547 shader_str = "fp";
548 shader_full_str = "fragment";
549 } // else if
550 else
551 {
552 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Shader type %u unsupported in this profile.",
553 (uintcxx . . $ uint#) ctx->shader_typecxx . . $ Context#shader_type.);
554 return;
555 } // if
556
557 set_outputcxx . . $ set_output(dbab56076057d0b7).(ctx, &ctx->preflightcxx . . $ Context#preflight.);
558
559 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profilestr, MOJOSHADER_PROFILE_ARB1cxx . . $ `mojoshader.h:720:9`!) == 0)
560 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "!!ARB%s1.0", shader_str);
561
562 #if SUPPORT_PROFILE_ARB1_NVcxx . . $ `mojoshader_internal.h:202:9`!
563 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profilestr, MOJOSHADER_PROFILE_NV2cxx . . $ `mojoshader.h:726:9`!) == 0)
564 {
565 ctx->profile_supports_nv2cxx . . $ Context#profile_supports_nv2. = 1;
566 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "!!ARB%s1.0", shader_str);
567 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "OPTION NV_%s_program2;", shader_full_str);
568 } // else if
569
570 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profilestr, MOJOSHADER_PROFILE_NV3cxx . . $ `mojoshader.h:732:9`!) == 0)
571 {
572 // there's no NV_fragment_program3, so just use 2.
573 const int ver = shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx) ? 2 : 3;
574 ctx->profile_supports_nv2cxx . . $ Context#profile_supports_nv2. = 1;
575 ctx->profile_supports_nv3cxx . . $ Context#profile_supports_nv3. = 1;
576 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "!!ARB%s1.0", shader_str);
577 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "OPTION NV_%s_program%d;", shader_full_str, ver);
578 } // else if
579
580 else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profilestr, MOJOSHADER_PROFILE_NV4cxx . . $ `mojoshader.h:738:9`!) == 0)
581 {
582 ctx->profile_supports_nv2cxx . . $ Context#profile_supports_nv2. = 1;
583 ctx->profile_supports_nv3cxx . . $ Context#profile_supports_nv3. = 1;
584 ctx->profile_supports_nv4cxx . . $ Context#profile_supports_nv4. = 1;
585 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "!!NV%s4.0", shader_str);
586 } // else if
587 #endif
588
589 else
590 {
591 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Profile '%s' unsupported or unknown.", profilestr);
592 } // else
593
594 set_outputcxx . . $ set_output(dbab56076057d0b7).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
595 } // emit_ARB1_start
596
597 void emit_ARB1_endcxx . . $ emit_ARB1_end(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
598 {
599 // ps_1_* writes color to r0 instead oC0. We move it to the right place.
600 // We don't have to worry about a RET opcode messing this up, since
601 // RET isn't available before ps_2_0.
602 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx) && !shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 2, 0))
603 {
604 set_used_registercxx . . $ set_used_register(e54d43264d6a4c0d).(ctx, REG_TYPE_COLOROUTcxx . . $ REG_TYPE_COLOROUT., 0, 1);
605 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOV oC0, r0;");
606 } // if
607
608 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "END");
609 } // emit_ARB1_end
610
611 void emit_ARB1_phasecxx . . $ emit_ARB1_phase(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
612 {
613 // no-op in arb1.
614 } // emit_ARB1_phase
615
616 static inline const char *arb1_float_tempcxx . . $ arb1_float_temp(1fb8ee174bd57523).(const Contextcxx . . $ Context# *ctx)
617 {
618 // nv4 lets you specify data type.
619 return (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) ? "FLOAT TEMP" : "TEMP";
620 } // arb1_float_temp
621
622 void emit_ARB1_finalizecxx . . $ emit_ARB1_finalize(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
623 {
624 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->preflightcxx . . $ Context#preflight.);
625
626 if (shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx) && !ctx->arb1_wrote_positioncxx . . $ Context#arb1_wrote_position.)
627 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "OPTION ARB_position_invariant;");
628
629 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx) && ctx->have_multi_color_outputscxx . . $ Context#have_multi_color_outputs.)
630 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "OPTION ARB_draw_buffers;");
631
632 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
633
634 const char *tmpstr = arb1_float_tempcxx . . $ arb1_float_temp(1fb8ee174bd57523).(ctx);
635 int i;
636 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
637 for (i = 0; i < ctx->max_scratch_registerscxx . . $ Context#max_scratch_registers.; i++)
638 {
639 char buf[64];
640 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, buf, sizeof (buf));
641 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s %s;", tmpstr, buf);
642 } // for
643
644 // nv2 fragment programs (and anything nv4) have a real REP/ENDREP.
645 if ( (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) && (!shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) && (!support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) )
646 {
647 // set up temps for nv2 REP/ENDREP emulation through branching.
648 for (i = 0; i < ctx->max_repscxx . . $ Context#max_reps.; i++)
649 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "TEMP rep%d;", i);
650 } // if
651
652 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
653 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->scratch_registers == ctx->max_scratch_registers);
654 } // emit_ARB1_finalize
655
656 void emit_ARB1_globalcxx . . $ emit_ARB1_global(8475323e8d0fe52d).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum)
657 {
658 // !!! FIXME: dependency on ARB1 profile. // !!! FIXME about FIXME: huh?
659 char varname[64];
660 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, regtype, regnum, varname, sizeof (varname));
661
662 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
663 switch (regtype)
664 {
665 case REG_TYPE_ADDRESScxx . . $ REG_TYPE_ADDRESS.:
666 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) // actually REG_TYPE_TEXTURE.
667 {
668 // We have to map texture registers to temps for ps_1_1, since
669 // they work like temps, initialize with tex coords, and the
670 // ps_1_1 TEX opcode expects to overwrite it.
671 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4))
672 {
673 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s %s;", arb1_float_tempcxx . . $ arb1_float_temp(1fb8ee174bd57523).(ctx), varname);
674 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_topcxx . . $ Context#mainline_top.);
675 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOV %s, fragment.texcoord[%d];",
676 varname, regnum);
677 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
678 } // if
679 break;
680 } // if
681
682 // nv4 replaced address registers with generic int registers.
683 if (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx))
684 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "INT TEMP %s;", varname);
685 else
686 {
687 // nv2 has four-component address already, but stock arb1 has
688 // to emulate it in a temporary, and move components to the
689 // scalar ADDRESS register on demand.
690 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ADDRESS %s;", varname);
691 if (!support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
692 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "TEMP addr%d;", regnum);
693 } // else
694 break;
695
696 //case REG_TYPE_PREDICATE:
697 // output_line(ctx, "bvec4 %s;", varname);
698 // break;
699 case REG_TYPE_TEMPcxx . . $ REG_TYPE_TEMP.:
700 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s %s;", arb1_float_tempcxx . . $ arb1_float_temp(1fb8ee174bd57523).(ctx), varname);
701 break;
702 //case REG_TYPE_LOOP:
703 // break; // no-op. We declare these in for loops at the moment.
704 //case REG_TYPE_LABEL:
705 // break; // no-op. If we see it here, it means we optimized it out.
706 default:
707 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: we used a register we don't know how to define.");
708 break;
709 } // switch
710 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
711 } // emit_ARB1_global
712
713 void emit_ARB1_arraycxx . . $ emit_ARB1_array(4368dce1b98e99b8).(Contextcxx . . $ Context# *ctx, VariableListcxx . . $ VariableList# *var)
714 {
715 // All uniforms are now packed tightly into the program.local array,
716 // instead of trying to map them to the d3d registers. So this needs to
717 // map to the next piece of the array we haven't used yet. Thankfully,
718 // arb1 lets you make a PARAM array that maps to a subset of another
719 // array; we don't need to do offsets, since myarray[0] can map to
720 // program.local[5] without any extra math from us.
721 const int base = var->indexcxx . . $ VariableList#index.;
722 const int size = var->countcxx . . $ VariableList#count.;
723 const int arb1base = ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count. +
724 ctx->uniform_int4_countcxx . . $ Context#uniform_int4_count. +
725 ctx->uniform_bool_countcxx . . $ Context#uniform_bool_count.;
726 char varname[64];
727 get_ARB1_const_array_varname_in_bufcxx . . $ get_ARB1_const_array_varname_in_buf(7e1cca04738fe06f).(ctx, base, size, varname, sizeof (varname));
728 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
729 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "PARAM %s[%d] = { program.local[%d..%d] };", varname,
730 size, arb1base, (arb1base + size) - 1);
731 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
732 var->emit_positioncxx . . $ VariableList#emit_position. = arb1base;
733 } // emit_ARB1_array
734
735 void emit_ARB1_const_arraycxx . . $ emit_ARB1_const_array(36ee158898c90b50).(Contextcxx . . $ Context# *ctx, const ConstantsListcxx . . $ ConstantsList# *clist,
736 int base, int size)
737 {
738 char varname[64];
739 get_ARB1_const_array_varname_in_bufcxx . . $ get_ARB1_const_array_varname_in_buf(7e1cca04738fe06f).(ctx, base, size, varname, sizeof (varname));
740 int i;
741
742 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
743 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "PARAM %s[%d] = {", varname, size);
744 ctx->indentcxx . . $ Context#indent.++;
745
746 for (i = 0; i < size; i++)
747 {
748 while (clist->constantcxx . . $ ConstantsList#constant..typecxx . . $ MOJOSHADER_constant#type. != MOJOSHADER_UNIFORM_FLOATcxx . . $ MOJOSHADER_UNIFORM_FLOAT.)
749 clist = clist->nextcxx . . $ ConstantsList#next.;
750 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(clist->constant.index == (base + i));
751
752 char val0[32];
753 char val1[32];
754 char val2[32];
755 char val3[32];
756 floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val0, sizeof (val0), clist->constantcxx . . $ ConstantsList#constant..valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.[0], 1);
757 floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val1, sizeof (val1), clist->constantcxx . . $ ConstantsList#constant..valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.[1], 1);
758 floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val2, sizeof (val2), clist->constantcxx . . $ ConstantsList#constant..valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.[2], 1);
759 floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val3, sizeof (val3), clist->constantcxx . . $ ConstantsList#constant..valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.[3], 1);
760
761 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "{ %s, %s, %s, %s }%s", val0, val1, val2, val3,
762 (i < (size-1)) ? "," : "");
763
764 clist = clist->nextcxx . . $ ConstantsList#next.;
765 } // for
766
767 ctx->indentcxx . . $ Context#indent.--;
768 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "};");
769 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
770 } // emit_ARB1_const_array
771
772 void emit_ARB1_uniformcxx . . $ emit_ARB1_uniform(8b79ccde41759557).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum,
773 const VariableListcxx . . $ VariableList# *var)
774 {
775 // We pack these down into the program.local array, so if we only use
776 // register c439, it'll actually map to program.local[0]. This will
777 // prevent overflows when we actually have enough resources to run.
778
779 const char *arrayname = "program.local";
780 int index = 0;
781
782 char varname[64];
783 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, regtype, regnum, varname, sizeof (varname));
784
785 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
786
787 if (var == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
788 {
789 // all types share one array (rather, all types convert to float4).
790 index = ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count. + ctx->uniform_int4_countcxx . . $ Context#uniform_int4_count. +
791 ctx->uniform_bool_countcxx . . $ Context#uniform_bool_count.;
792 } // if
793
794 else
795 {
796 const int arraybase = var->indexcxx . . $ VariableList#index.;
797 if (var->constantcxx . . $ VariableList#constant.)
798 {
799 const int arraysize = var->countcxx . . $ VariableList#count.;
800 arrayname = get_ARB1_const_array_varname_in_bufcxx . . $ get_ARB1_const_array_varname_in_buf(7e1cca04738fe06f).(ctx, arraybase,
801 arraysize, (char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(64), 64);
802 index = (regnum - arraybase);
803 } // if
804 else
805 {
806 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(var->emit_position != -1);
807 index = (regnum - arraybase) + var->emit_positioncxx . . $ VariableList#emit_position.;
808 } // else
809 } // else
810
811 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "PARAM %s = %s[%d];", varname, arrayname, index);
812 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
813 } // emit_ARB1_uniform
814
815 void emit_ARB1_samplercxx . . $ emit_ARB1_sampler(a3a55aa9b8aa8087).(Contextcxx . . $ Context# *ctx,int stage,TextureTypecxx . . $ TextureType# ttype,int tb)
816 {
817 // this is mostly a no-op...you don't predeclare samplers in arb1.
818
819 if (tb) // This sampler used a ps_1_1 TEXBEM opcode?
820 {
821 const int index = ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count. + ctx->uniform_int4_countcxx . . $ Context#uniform_int4_count. +
822 ctx->uniform_bool_countcxx . . $ Context#uniform_bool_count.;
823 char var[64];
824 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., stage, var, sizeof(var));
825 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
826 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "PARAM %s_texbem = program.local[%d];", var, index);
827 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "PARAM %s_texbeml = program.local[%d];", var, index+1);
828 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
829 ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count. += 2;
830 } // if
831 } // emit_ARB1_sampler
832
833 // !!! FIXME: a lot of cut-and-paste here from emit_GLSL_attribute().
834 void emit_ARB1_attributecxx . . $ emit_ARB1_attribute(cc51a07b10397b54).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum,
835 MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, int index, int wmask,
836 int flags)
837 {
838 // !!! FIXME: this function doesn't deal with write masks at all yet!
839 const char *usage_str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
840 const char *arrayleft = "";
841 const char *arrayright = "";
842 char index_str[16] = { '\0' };
843
844 char varname[64];
845 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, regtype, regnum, varname, sizeof (varname));
846
847 //assert((flags & MOD_PP) == 0); // !!! FIXME: is PP allowed?
848
849 if (index != 0) // !!! FIXME: a lot of these MUST be zero.
850 snprintfcxx . . $ snprintf(ea502d73e74c754c).(index_str, sizeof (index_str), "%u", (uintcxx . . $ uint#) index);
851
852 if (shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx))
853 {
854 // pre-vs3 output registers.
855 // these don't ever happen in DCL opcodes, I think. Map to vs_3_*
856 // output registers.
857 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 3, 0))
858 {
859 if (regtype == REG_TYPE_RASTOUTcxx . . $ REG_TYPE_RASTOUT.)
860 {
861 regtype = REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.;
862 index = regnum;
863 switch ((const RastOutTypecxx . . $ RastOutType#) regnum)
864 {
865 case RASTOUT_TYPE_POSITIONcxx . . $ RASTOUT_TYPE_POSITION.:
866 usage = MOJOSHADER_USAGE_POSITIONcxx . . $ MOJOSHADER_USAGE_POSITION.;
867 break;
868 case RASTOUT_TYPE_FOGcxx . . $ RASTOUT_TYPE_FOG.:
869 usage = MOJOSHADER_USAGE_FOGcxx . . $ MOJOSHADER_USAGE_FOG.;
870 break;
871 case RASTOUT_TYPE_POINT_SIZEcxx . . $ RASTOUT_TYPE_POINT_SIZE.:
872 usage = MOJOSHADER_USAGE_POINTSIZEcxx . . $ MOJOSHADER_USAGE_POINTSIZE.;
873 break;
874 } // switch
875 } // if
876
877 else if (regtype == REG_TYPE_ATTROUTcxx . . $ REG_TYPE_ATTROUT.)
878 {
879 regtype = REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.;
880 usage = MOJOSHADER_USAGE_COLORcxx . . $ MOJOSHADER_USAGE_COLOR.;
881 index = regnum;
882 } // else if
883
884 else if (regtype == REG_TYPE_TEXCRDOUTcxx . . $ REG_TYPE_TEXCRDOUT.)
885 {
886 regtype = REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.;
887 usage = MOJOSHADER_USAGE_TEXCOORDcxx . . $ MOJOSHADER_USAGE_TEXCOORD.;
888 index = regnum;
889 } // else if
890 } // if
891
892 // to avoid limitations of various GL entry points for input
893 // attributes (glSecondaryColorPointer() can only take 3 component
894 // items, glVertexPointer() can't do GL_UNSIGNED_BYTE, many other
895 // issues), we set up all inputs as generic vertex attributes, so we
896 // can pass data in just about any form, and ignore the built-in GLSL
897 // attributes like gl_SecondaryColor. Output needs to use the the
898 // built-ins, though, but we don't have to worry about the GL entry
899 // point limitations there.
900
901 if (regtype == REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.)
902 {
903 const int attr = ctx->assigned_vertex_attributescxx . . $ Context#assigned_vertex_attributes.++;
904 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
905 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ATTRIB %s = vertex.attrib[%d];", varname, attr);
906 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
907 } // if
908
909 else if (regtype == REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.)
910 {
911 switch (usage)
912 {
913 case MOJOSHADER_USAGE_POSITIONcxx . . $ MOJOSHADER_USAGE_POSITION.:
914 ctx->arb1_wrote_positioncxx . . $ Context#arb1_wrote_position. = 1;
915 usage_str = "result.position";
916 break;
917 case MOJOSHADER_USAGE_POINTSIZEcxx . . $ MOJOSHADER_USAGE_POINTSIZE.:
918 usage_str = "result.pointsize";
919 break;
920 case MOJOSHADER_USAGE_COLORcxx . . $ MOJOSHADER_USAGE_COLOR.:
921 index_str[0] = '\0'; // no explicit number.
922 if (index == 0)
923 usage_str = "result.color.primary";
924 else if (index == 1)
925 usage_str = "result.color.secondary";
926 break;
927 case MOJOSHADER_USAGE_FOGcxx . . $ MOJOSHADER_USAGE_FOG.:
928 usage_str = "result.fogcoord";
929 break;
930 case MOJOSHADER_USAGE_TEXCOORDcxx . . $ MOJOSHADER_USAGE_TEXCOORD.:
931 snprintfcxx . . $ snprintf(ea502d73e74c754c).(index_str, sizeof (index_str), "%u", (uintcxx . . $ uint#) index);
932 usage_str = "result.texcoord";
933 arrayleft = "[";
934 arrayright = "]";
935 break;
936 default:
937 // !!! FIXME: we need to deal with some more built-in varyings here.
938 break;
939 } // switch
940
941 // !!! FIXME: the #define is a little hacky, but it means we don't
942 // !!! FIXME: have to track these separately if this works.
943 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
944 // no mapping to built-in var? Just make it a regular global, pray.
945 if (usage_str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
946 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s %s;", arb1_float_tempcxx . . $ arb1_float_temp(1fb8ee174bd57523).(ctx), varname);
947 else
948 {
949 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "OUTPUT %s = %s%s%s%s;", varname, usage_str,
950 arrayleft, index_str, arrayright);
951 } // else
952 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
953 } // else if
954
955 else
956 {
957 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown vertex shader attribute register");
958 } // else
959 } // if
960
961 else if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))
962 {
963 const char *paramtype_str = "ATTRIB";
964
965 // samplers DCLs get handled in emit_ARB1_sampler().
966
967 if (flags & MOD_CENTROIDcxx . . $ `mojoshader_internal.h:505:9`!)
968 {
969 if (!support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) // GL_NV_fragment_program4 adds centroid.
970 {
971 // !!! FIXME: should we just wing it without centroid here?
972 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "centroid unsupported in %s profile",
973 ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
974 return;
975 } // if
976
977 paramtype_str = "CENTROID ATTRIB";
978 } // if
979
980 if (regtype == REG_TYPE_COLOROUTcxx . . $ REG_TYPE_COLOROUT.)
981 {
982 paramtype_str = "OUTPUT";
983 usage_str = "result.color";
984 if (ctx->have_multi_color_outputscxx . . $ Context#have_multi_color_outputs.)
985 {
986 // We have to gamble that you have GL_ARB_draw_buffers.
987 // You probably do at this point if you have a sane setup.
988 snprintfcxx . . $ snprintf(ea502d73e74c754c).(index_str, sizeof (index_str), "%u", (uintcxx . . $ uint#) regnum);
989 arrayleft = "[";
990 arrayright = "]";
991 } // if
992 } // if
993
994 else if (regtype == REG_TYPE_DEPTHOUTcxx . . $ REG_TYPE_DEPTHOUT.)
995 {
996 paramtype_str = "OUTPUT";
997 usage_str = "result.depth";
998 } // else if
999
1000 // !!! FIXME: can you actualy have a texture register with COLOR usage?
1001 else if ((regtype == REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE.) || (regtype == REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.))
1002 {
1003 if (usage == MOJOSHADER_USAGE_TEXCOORDcxx . . $ MOJOSHADER_USAGE_TEXCOORD.)
1004 {
1005 // ps_1_1 does a different hack for this attribute.
1006 // Refer to emit_ARB1_global()'s REG_TYPE_TEXTURE code.
1007 if (shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4))
1008 {
1009 snprintfcxx . . $ snprintf(ea502d73e74c754c).(index_str, sizeof (index_str), "%u", (uintcxx . . $ uint#) index);
1010 usage_str = "fragment.texcoord";
1011 arrayleft = "[";
1012 arrayright = "]";
1013 } // if
1014 } // if
1015
1016 else if (usage == MOJOSHADER_USAGE_COLORcxx . . $ MOJOSHADER_USAGE_COLOR.)
1017 {
1018 index_str[0] = '\0'; // no explicit number.
1019 if (index == 0)
1020 usage_str = "fragment.color.primary";
1021 else if (index == 1)
1022 usage_str = "fragment.color.secondary";
1023 else
1024 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unsupported color index");
1025 } // else if
1026 } // else if
1027
1028 else if (regtype == REG_TYPE_MISCTYPEcxx . . $ REG_TYPE_MISCTYPE.)
1029 {
1030 const MiscTypeTypecxx . . $ MiscTypeType# mt = (MiscTypeTypecxx . . $ MiscTypeType#) regnum;
1031 if (mt == MISCTYPE_TYPE_FACEcxx . . $ MISCTYPE_TYPE_FACE.)
1032 {
1033 if (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) // FINALLY, a vFace equivalent in nv4!
1034 {
1035 index_str[0] = '\0'; // no explicit number.
1036 usage_str = "fragment.facing";
1037 } // if
1038 else
1039 {
1040 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "vFace unsupported in %s profile",
1041 ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
1042 } // else
1043 } // if
1044 else if (mt == MISCTYPE_TYPE_POSITIONcxx . . $ MISCTYPE_TYPE_POSITION.)
1045 {
1046 index_str[0] = '\0'; // no explicit number.
1047 usage_str = "fragment.position"; // !!! FIXME: is this the same coord space as D3D?
1048 } // else if
1049 else
1050 {
1051 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: unhandled misc register");
1052 } // else
1053 } // else if
1054
1055 else
1056 {
1057 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown pixel shader attribute register");
1058 } // else
1059
1060 if (usage_str != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1061 {
1062 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
1063 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s %s = %s%s%s%s;", paramtype_str, varname,
1064 usage_str, arrayleft, index_str, arrayright);
1065 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1066 } // if
1067 } // else if
1068
1069 else
1070 {
1071 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Unknown shader type"); // state machine should catch this.
1072 } // else
1073 } // emit_ARB1_attribute
1074
1075 void emit_ARB1_RESERVEDcxx . . $ emit_ARB1_RESERVED(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { /* no-op. */ }
1076
1077 void emit_ARB1_NOPcxx . . $ emit_ARB1_NOP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1078 {
1079 // There is no NOP in arb1. Just don't output anything here.
1080 } // emit_ARB1_NOP
1081
1082 EMIT_ARB1_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:514:9`!(MOV)
1083 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(ADD)
1084 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(SUB)
1085 EMIT_ARB1_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:522:9`!(MAD)
1086 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(MUL)
1087 EMIT_ARB1_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:514:9`!(RCP)
1088
1089 void emit_ARB1_RSQcxx . . $ emit_ARB1_RSQ(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1090 {
1091 // nv4 doesn't force abs() on this, so negative values will generate NaN.
1092 // The spec says you should force the abs() yourself.
1093 if (!support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx))
1094 {
1095 emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "RSQ"); // pre-nv4 implies ABS.
1096 return;
1097 } // if
1098
1099 // we can optimize this to use nv2's |abs| construct in some cases.
1100 if ( (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_NONEcxx . . $ SRCMOD_NONE.) ||
1101 (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_NEGATEcxx . . $ SRCMOD_NEGATE.) ||
1102 (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_ABSNEGATEcxx . . $ SRCMOD_ABSNEGATE.) )
1103 ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. = SRCMOD_ABScxx . . $ SRCMOD_ABS.;
1104
1105 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1106 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1107
1108 if (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_ABScxx . . $ SRCMOD_ABS.)
1109 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RSQ%s, %s;", dst, src0);
1110 else
1111 {
1112 char buf[64]; allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, buf, sizeof (buf));
1113 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ABS %s, %s;", buf, src0);
1114 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RSQ%s, %s.x;", dst, buf);
1115 } // else
1116
1117 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1118 } // emit_ARB1_RSQ
1119
1120 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(DP3)
1121 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(DP4)
1122 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(MIN)
1123 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(MAX)
1124 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(SLT)
1125 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(SGE)
1126
1127 void emit_ARB1_EXPcxx . . $ emit_ARB1_EXP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "EX2"); }
1128
1129 static void arb1_logcxx . . $ arb1_log(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *opcode)
1130 {
1131 // !!! FIXME: SRCMOD_NEGATE can be made into SRCMOD_ABS here, too
1132 // we can optimize this to use nv2's |abs| construct in some cases.
1133 if ( (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_NONEcxx . . $ SRCMOD_NONE.) ||
1134 (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_ABSNEGATEcxx . . $ SRCMOD_ABSNEGATE.) )
1135 ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. = SRCMOD_ABScxx . . $ SRCMOD_ABS.;
1136
1137 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1138 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1139
1140 if (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_ABScxx . . $ SRCMOD_ABS.)
1141 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s, %s;", opcode, dst, src0);
1142 else
1143 {
1144 char buf[64]; allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, buf, sizeof (buf));
1145 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ABS %s, %s;", buf, src0);
1146 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s, %s.x;", opcode, dst, buf);
1147 } // else
1148
1149 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1150 } // arb1_log
1151
1152
1153 void emit_ARB1_LOGcxx . . $ emit_ARB1_LOG(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1154 {
1155 arb1_logcxx . . $ arb1_log(72ff1ec6cf40f147).(ctx, "LG2");
1156 } // emit_ARB1_LOG
1157
1158
1159 EMIT_ARB1_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:514:9`!(LIT)
1160 EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!(DST)
1161
1162 void emit_ARB1_LRPcxx . . $ emit_ARB1_LRP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1163 {
1164 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) // fragment shaders have a matching LRP opcode.
1165 emit_ARB1_opcode_dssscxx . . $ emit_ARB1_opcode_dsss(72ff1ec6cf40f147).(ctx, "LRP");
1166 else
1167 {
1168 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1169 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1170 char src1[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
1171 char src2[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 2, src2, sizeof (src2));
1172 char buf[64]; allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, buf, sizeof (buf));
1173
1174 // LRP is: dest = src2 + src0 * (src1 - src2)
1175 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SUB %s, %s, %s;", buf, src1, src2);
1176 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAD%s, %s, %s, %s;", dst, buf, src0, src2);
1177 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1178 } // else
1179 } // emit_ARB1_LRP
1180
1181 EMIT_ARB1_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:514:9`!(FRC)
1182
1183 static void arb1_MxXycxx . . $ arb1_MxXy(f097640709b383).(Contextcxx . . $ Context# *ctx, const int x, const int y)
1184 {
1185 DestArgInfocxx . . $ DestArgInfo# *dstarg = &ctx->dest_argcxx . . $ Context#dest_arg.;
1186 const int origmask = dstarg->writemaskcxx . . $ $anonymous_type_32753e8ce5863620_5#writemask.;
1187 char src0[64];
1188 int i;
1189
1190 make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1191
1192 for (i = 0; i < y; i++)
1193 {
1194 char dst[64];
1195 char row[64];
1196 make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, i + 1, row, sizeof (row));
1197 set_dstarg_writemaskcxx . . $ set_dstarg_writemask(3dc30233075ee5d2).(dstarg, 1 << i);
1198 make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1199 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP%d%s, %s, %s;", x, dst, src0, row);
1200 } // for
1201
1202 set_dstarg_writemaskcxx . . $ set_dstarg_writemask(3dc30233075ee5d2).(dstarg, origmask);
1203 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1204 } // arb1_MxXy
1205
1206 void emit_ARB1_M4X4cxx . . $ emit_ARB1_M4X4(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { arb1_MxXycxx . . $ arb1_MxXy(f097640709b383).(ctx, 4, 4); }
1207 void emit_ARB1_M4X3cxx . . $ emit_ARB1_M4X3(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { arb1_MxXycxx . . $ arb1_MxXy(f097640709b383).(ctx, 4, 3); }
1208 void emit_ARB1_M3X4cxx . . $ emit_ARB1_M3X4(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { arb1_MxXycxx . . $ arb1_MxXy(f097640709b383).(ctx, 3, 4); }
1209 void emit_ARB1_M3X3cxx . . $ emit_ARB1_M3X3(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { arb1_MxXycxx . . $ arb1_MxXy(f097640709b383).(ctx, 3, 3); }
1210 void emit_ARB1_M3X2cxx . . $ emit_ARB1_M3X2(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { arb1_MxXycxx . . $ arb1_MxXy(f097640709b383).(ctx, 3, 2); }
1211
1212 void emit_ARB1_CALLcxx . . $ emit_ARB1_CALL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1213 {
1214 if (!support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) // no branching in stock ARB1.
1215 {
1216 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "branching unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
1217 return;
1218 } // if
1219
1220 char labelstr[64];
1221 get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 0, labelstr, sizeof (labelstr));
1222 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "CAL %s;", labelstr);
1223 } // emit_ARB1_CALL
1224
1225 void emit_ARB1_CALLNZcxx . . $ emit_ARB1_CALLNZ(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1226 {
1227 // !!! FIXME: if src1 is a constbool that's true, we can remove the
1228 // !!! FIXME: if. If it's false, we can make this a no-op.
1229
1230 if (!support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) // no branching in stock ARB1.
1231 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "branching unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
1232 else
1233 {
1234 // !!! FIXME: double-check this.
1235 char labelstr[64];
1236 char scratch[64];
1237 char src1[64];
1238 get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 0, labelstr, sizeof (labelstr));
1239 get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
1240 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, scratch, sizeof (scratch));
1241 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOVC %s, %s;", scratch, src1);
1242 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "CAL %s (NE.x);", labelstr);
1243 } // else
1244 } // emit_ARB1_CALLNZ
1245
1246 // !!! FIXME: needs BRA in nv2, LOOP in nv2 fragment progs, and REP in nv4.
1247 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(LOOP)
1248
1249 void emit_ARB1_RETcxx . . $ emit_ARB1_RET(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1250 {
1251 // don't fail() if no nv2...maybe we're just ending the mainline?
1252 // if we're ending a LABEL that had no CALL, this would all be written
1253 // to ctx->ignore anyhow, so this should be "safe" ... arb1 profile will
1254 // just end up throwing all this code out.
1255 if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) // no branching in stock ARB1.
1256 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RET;");
1257 set_outputcxx . . $ set_output(dbab56076057d0b7).(ctx, &ctx->mainlinecxx . . $ Context#mainline.); // in case we were ignoring this function.
1258 } // emit_ARB1_RET
1259
1260
1261 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(ENDLOOP)
1262
1263 void emit_ARB1_LABELcxx . . $ emit_ARB1_LABEL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1264 {
1265 if (!support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) // no branching in stock ARB1.
1266 return; // don't fail()...maybe we never use it, but do fail in CALL.
1267
1268 const int label = ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.;
1269 RegisterListcxx . . $ RegisterList# *reg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->used_registerscxx . . $ Context#used_registers., REG_TYPE_LABELcxx . . $ REG_TYPE_LABEL., label);
1270
1271 // MSDN specs say CALL* has to come before the LABEL, so we know if we
1272 // can ditch the entire function here as unused.
1273 if (reg == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1274 set_outputcxx . . $ set_output(dbab56076057d0b7).(ctx, &ctx->ignorecxx . . $ Context#ignore.); // Func not used. Parse, but don't output.
1275
1276 // !!! FIXME: it would be nice if we could determine if a function is
1277 // !!! FIXME: only called once and, if so, forcibly inline it.
1278
1279 //const char *uses_loopreg = ((reg) && (reg->misc == 1)) ? "int aL" : "";
1280 char labelstr[64];
1281 get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 0, labelstr, sizeof (labelstr));
1282 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s:", labelstr);
1283 } // emit_ARB1_LABEL
1284
1285
1286 void emit_ARB1_POWcxx . . $ emit_ARB1_POW(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1287 {
1288 // we can optimize this to use nv2's |abs| construct in some cases.
1289 if ( (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_NONEcxx . . $ SRCMOD_NONE.) ||
1290 (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_ABSNEGATEcxx . . $ SRCMOD_ABSNEGATE.) )
1291 ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. = SRCMOD_ABScxx . . $ SRCMOD_ABS.;
1292
1293 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1294 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1295 char src1[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
1296
1297 if (ctx->source_argscxx . . $ Context#source_args.[0].src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod. == SRCMOD_ABScxx . . $ SRCMOD_ABS.)
1298 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "POW%s, %s, %s;", dst, src0, src1);
1299 else
1300 {
1301 char buf[64]; allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, buf, sizeof (buf));
1302 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ABS %s, %s;", buf, src0);
1303 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "POW%s, %s.x, %s;", dst, buf, src1);
1304 } // else
1305
1306 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1307 } // emit_ARB1_POW
1308
1309 void emit_ARB1_CRScxx . . $ emit_ARB1_CRS(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { emit_ARB1_opcode_dsscxx . . $ emit_ARB1_opcode_dss(72ff1ec6cf40f147).(ctx, "XPD"); }
1310
1311 void emit_ARB1_SGNcxx . . $ emit_ARB1_SGN(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1312 {
1313 if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
1314 emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "SSG");
1315 else
1316 {
1317 char dst[64];
1318 char src0[64];
1319 char scratch1[64];
1320 char scratch2[64];
1321 make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1322 make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1323 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, scratch1, sizeof (scratch1));
1324 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, scratch2, sizeof (scratch2));
1325 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SLT %s, %s, 0.0;", scratch1, src0);
1326 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SLT %s, -%s, 0.0;", scratch2, src0);
1327 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ADD%s -%s, %s;", dst, scratch1, scratch2);
1328 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1329 } // else
1330 } // emit_ARB1_SGN
1331
1332 EMIT_ARB1_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:514:9`!(ABS)
1333
1334 void emit_ARB1_NRMcxx . . $ emit_ARB1_NRM(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1335 {
1336 // nv2 fragment programs (and anything nv4) have a real NRM.
1337 if ( (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) || ((support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) && (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))) )
1338 emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "NRM");
1339 else
1340 {
1341 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1342 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1343 char buf[64]; allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, buf, sizeof (buf));
1344 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.w, %s, %s;", buf, src0, src0);
1345 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RSQ %s.w, %s.w;", buf, buf);
1346 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL%s, %s.w, %s;", dst, buf, src0);
1347 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1348 } // else
1349 } // emit_ARB1_NRM
1350
1351
1352 void emit_ARB1_SINCOScxx . . $ emit_ARB1_SINCOS(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1353 {
1354 // we don't care about the temp registers that <= sm2 demands; ignore them.
1355 const int mask = ctx->dest_argcxx . . $ Context#dest_arg..writemaskcxx . . $ $anonymous_type_32753e8ce5863620_5#writemask.;
1356
1357 // arb1 fragment programs and everything nv4 have sin/cos/sincos opcodes.
1358 if ((shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) || (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)))
1359 {
1360 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1361 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1362 if (writemask_xcxx . . $ writemask_x(7864480464b09eea).(mask))
1363 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "COS%s, %s;", dst, src0);
1364 else if (writemask_ycxx . . $ writemask_y(7864480464b09eea).(mask))
1365 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SIN%s, %s;", dst, src0);
1366 else if (writemask_xycxx . . $ writemask_xy(7864480464b09eea).(mask))
1367 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SCS%s, %s;", dst, src0);
1368 } // if
1369
1370 // nv2+ profiles have sin and cos opcodes.
1371 else if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
1372 {
1373 char dst[64]; get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1374 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1375 if (writemask_xcxx . . $ writemask_x(7864480464b09eea).(mask))
1376 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "COS %s.x, %s;", dst, src0);
1377 else if (writemask_ycxx . . $ writemask_y(7864480464b09eea).(mask))
1378 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SIN %s.y, %s;", dst, src0);
1379 else if (writemask_xycxx . . $ writemask_xy(7864480464b09eea).(mask))
1380 {
1381 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SIN %s.x, %s;", dst, src0);
1382 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "COS %s.y, %s;", dst, src0);
1383 } // else if
1384 } // if
1385
1386 else // big nasty.
1387 {
1388 char dst[64]; get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1389 char src0[64]; get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1390 const int need_sin = (writemask_xcxx . . $ writemask_x(7864480464b09eea).(mask) || writemask_xycxx . . $ writemask_xy(7864480464b09eea).(mask));
1391 const int need_cos = (writemask_ycxx . . $ writemask_y(7864480464b09eea).(mask) || writemask_xycxx . . $ writemask_xy(7864480464b09eea).(mask));
1392 char scratch[64];
1393
1394 if (need_sin || need_cos)
1395 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, scratch, sizeof (scratch));
1396
1397 // These sin() and cos() approximations originally found here:
1398 // http://www.devmaster.net/forums/showthread.php?t=5784
1399 //
1400 // const float B = 4.0f / M_PI;
1401 // const float C = -4.0f / (M_PI * M_PI);
1402 // float y = B * x + C * x * fabs(x);
1403 //
1404 // // optional better precision...
1405 // const float P = 0.225f;
1406 // y = P * (y * fabs(y) - y) + y;
1407 //
1408 //
1409 // That first thing can be reduced to:
1410 // const float y = ((1.2732395447351626861510701069801f * x) +
1411 // ((-0.40528473456935108577551785283891f * x) * fabs(x)));
1412
1413 if (need_sin)
1414 {
1415 // !!! FIXME: use SRCMOD_ABS here?
1416 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ABS %s.x, %s.x;", dst, src0);
1417 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s.x, %s.x, -0.40528473456935108577551785283891;", dst, dst);
1418 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s.x, %s.x, 1.2732395447351626861510701069801;", scratch, src0);
1419 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAD %s.x, %s.x, %s.x, %s.x;", dst, dst, src0, scratch);
1420 } // if
1421
1422 // cosine is sin(x + M_PI/2), but you have to wrap x to pi:
1423 // if (x+(M_PI/2) > M_PI)
1424 // x -= 2 * M_PI;
1425 //
1426 // which is...
1427 // if (x+(1.57079637050628662109375) > 3.1415927410125732421875)
1428 // x += -6.283185482025146484375;
1429
1430 if (need_cos)
1431 {
1432 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ADD %s.x, %s.x, 1.57079637050628662109375;", scratch, src0);
1433 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SGE %s.y, %s.x, 3.1415927410125732421875;", scratch, scratch);
1434 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAD %s.x, %s.y, -6.283185482025146484375, %s.x;", scratch, scratch, scratch);
1435 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ABS %s.x, %s.x;", dst, src0);
1436 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s.x, %s.x, -0.40528473456935108577551785283891;", dst, dst);
1437 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s.x, %s.x, 1.2732395447351626861510701069801;", scratch, src0);
1438 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAD %s.y, %s.x, %s.x, %s.x;", dst, dst, src0, scratch);
1439 } // if
1440 } // else
1441
1442 // !!! FIXME: might not have done anything. Don't emit if we didn't.
1443 if (!(ctx->isfailcxx . . $ Context#isfail.))
1444 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1445 } // emit_ARB1_SINCOS
1446
1447
1448 void emit_ARB1_REPcxx . . $ emit_ARB1_REP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1449 {
1450 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1451
1452 // nv2 fragment programs (and everything nv4) have a real REP.
1453 if ( (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) || ((support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) && (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))) )
1454 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "REP %s;", src0);
1455
1456 else if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
1457 {
1458 // no REP, but we can use branches.
1459 char failbranch[32];
1460 char topbranch[32];
1461 const int toplabel = allocate_branch_labelcxx . . $ allocate_branch_label(c6cdb7a367dd06c9).(ctx);
1462 const int faillabel = allocate_branch_labelcxx . . $ allocate_branch_label(c6cdb7a367dd06c9).(ctx);
1463 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx,faillabel,failbranch,sizeof(failbranch));
1464 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx,toplabel,topbranch,sizeof(topbranch));
1465
1466 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(((size_t) ctx->branch_labels_stack_index) <
1467 STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->branch_labels_stack)-1);
1468
1469 ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.++] = toplabel;
1470 ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.++] = faillabel;
1471
1472 char scratch[32];
1473 snprintfcxx . . $ snprintf(ea502d73e74c754c).(scratch, sizeof (scratch), "rep%d", ctx->repscxx . . $ Context#reps.);
1474 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOVC %s.x, %s;", scratch, src0);
1475 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "BRA %s (LE.x);", failbranch);
1476 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s:", topbranch);
1477 } // else if
1478
1479 else // stock ARB1 has no branching.
1480 {
1481 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "branching unsupported in this profile");
1482 } // else
1483 } // emit_ARB1_REP
1484
1485
1486 void emit_ARB1_ENDREPcxx . . $ emit_ARB1_ENDREP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1487 {
1488 // nv2 fragment programs (and everything nv4) have a real ENDREP.
1489 if ( (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) || ((support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) && (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))) )
1490 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ENDREP;");
1491
1492 else if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
1493 {
1494 // no ENDREP, but we can use branches.
1495 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->branch_labels_stack_index >= 2);
1496
1497 char failbranch[32];
1498 char topbranch[32];
1499 const int faillabel = ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[--ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.];
1500 const int toplabel = ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[--ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.];
1501 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx,faillabel,failbranch,sizeof(failbranch));
1502 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx,toplabel,topbranch,sizeof(topbranch));
1503
1504 char scratch[32];
1505 snprintfcxx . . $ snprintf(ea502d73e74c754c).(scratch, sizeof (scratch), "rep%d", ctx->repscxx . . $ Context#reps.);
1506 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SUBC %s.x, %s.x, 1.0;", scratch, scratch);
1507 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "BRA %s (GT.x);", topbranch);
1508 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s:", failbranch);
1509 } // else if
1510
1511 else // stock ARB1 has no branching.
1512 {
1513 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "branching unsupported in this profile");
1514 } // else
1515 } // emit_ARB1_ENDREP
1516
1517
1518 void nv2_ifcxx . . $ nv2_if(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1519 {
1520 // The condition code register MUST be set up before this!
1521 // nv2 fragment programs (and everything nv4) have a real IF.
1522 if ( (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) || (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) )
1523 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "IF EQ.x;");
1524 else
1525 {
1526 // there's no IF construct, but we can use a branch to a label.
1527 char failbranch[32];
1528 const int label = allocate_branch_labelcxx . . $ allocate_branch_label(c6cdb7a367dd06c9).(ctx);
1529 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx, label, failbranch, sizeof (failbranch));
1530
1531 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(((size_t) ctx->branch_labels_stack_index)
1532 < STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->branch_labels_stack));
1533
1534 ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.++] = label;
1535
1536 // !!! FIXME: should this be NE? (EQ would jump to the ELSE for the IF condition, right?).
1537 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "BRA %s (EQ.x);", failbranch);
1538 } // else
1539 } // nv2_if
1540
1541
1542 void emit_ARB1_IFcxx . . $ emit_ARB1_IF(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1543 {
1544 if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
1545 {
1546 char buf[64]; allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, buf, sizeof (buf));
1547 char src0[64]; get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1548 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOVC %s.x, %s;", buf, src0);
1549 nv2_ifcxx . . $ nv2_if(612dd59919e2530e).(ctx);
1550 } // if
1551
1552 else // stock ARB1 has no branching.
1553 {
1554 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "branching unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
1555 } // else
1556 } // emit_ARB1_IF
1557
1558
1559 void emit_ARB1_ELSEcxx . . $ emit_ARB1_ELSE(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1560 {
1561 // nv2 fragment programs (and everything nv4) have a real ELSE.
1562 if ( (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) || ((support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) && (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))) )
1563 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ELSE;");
1564
1565 else if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
1566 {
1567 // there's no ELSE construct, but we can use a branch to a label.
1568 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->branch_labels_stack_index > 0);
1569
1570 // At the end of the IF block, unconditionally jump to the ENDIF.
1571 const int endlabel = allocate_branch_labelcxx . . $ allocate_branch_label(c6cdb7a367dd06c9).(ctx);
1572 char endbranch[32];
1573 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx,endlabel,endbranch,sizeof (endbranch));
1574 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "BRA %s;", endbranch);
1575
1576 // Now mark the ELSE section with a lable.
1577 const int elselabel = ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.-1];
1578 char elsebranch[32];
1579 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx,elselabel,elsebranch,sizeof(elsebranch));
1580 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s:", elsebranch);
1581
1582 // Replace the ELSE label with the ENDIF on the label stack.
1583 ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.-1] = endlabel;
1584 } // else if
1585
1586 else // stock ARB1 has no branching.
1587 {
1588 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "branching unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
1589 } // else
1590 } // emit_ARB1_ELSE
1591
1592
1593 void emit_ARB1_ENDIFcxx . . $ emit_ARB1_ENDIF(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1594 {
1595 // nv2 fragment programs (and everything nv4) have a real ENDIF.
1596 if ( (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) || ((support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) && (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))) )
1597 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ENDIF;");
1598
1599 else if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
1600 {
1601 // there's no ENDIF construct, but we can use a branch to a label.
1602 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->branch_labels_stack_index > 0);
1603 const int endlabel = ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[--ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.];
1604 char endbranch[32];
1605 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx,endlabel,endbranch,sizeof (endbranch));
1606 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s:", endbranch);
1607 } // if
1608
1609 else // stock ARB1 has no branching.
1610 {
1611 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "branching unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
1612 } // else
1613 } // emit_ARB1_ENDIF
1614
1615
1616 void emit_ARB1_BREAKcxx . . $ emit_ARB1_BREAK(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1617 {
1618 // nv2 fragment programs (and everything nv4) have a real BREAK.
1619 if ( (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) || ((support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) && (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))) )
1620 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "BRK;");
1621
1622 else if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
1623 {
1624 // no BREAK, but we can use branches.
1625 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->branch_labels_stack_index >= 2);
1626 const int faillabel = ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.];
1627 char failbranch[32];
1628 get_ARB1_branch_label_namecxx . . $ get_ARB1_branch_label_name(9867cc71409fe246).(ctx,faillabel,failbranch,sizeof(failbranch));
1629 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "BRA %s;", failbranch);
1630 } // else if
1631
1632 else // stock ARB1 has no branching.
1633 {
1634 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "branching unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
1635 } // else
1636 } // emit_ARB1_BREAK
1637
1638
1639 void emit_ARB1_MOVAcxx . . $ emit_ARB1_MOVA(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1640 {
1641 // nv2 and nv3 can use the ARR opcode.
1642 // But nv4 removed ARR (and ADDRESS registers!). Just ROUND to an INT.
1643 if (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx))
1644 emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "ROUND.S"); // !!! FIXME: don't use a modifier here.
1645 else if ((support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) || (support_nv3cxx . . $ `profiles/mojoshader_profile.h:228:9`!(ctx)))
1646 emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "ARR");
1647 else
1648 {
1649 char src0[64];
1650 char scratch[64];
1651 char addr[32];
1652
1653 make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1654 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, scratch, sizeof (scratch));
1655 snprintfcxx . . $ snprintf(ea502d73e74c754c).(addr, sizeof (addr), "addr%d", ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
1656
1657 // !!! FIXME: we can optimize this if src_mod is ABS or ABSNEGATE.
1658
1659 // ARL uses floor(), but D3D expects round-to-nearest.
1660 // There is probably a more efficient way to do this.
1661 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) // CMP only exists in fragment programs. :/
1662 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "CMP %s, %s, -1.0, 1.0;", scratch, src0);
1663 else
1664 {
1665 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SLT %s, %s, 0.0;", scratch, src0);
1666 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAD %s, %s, -2.0, 1.0;", scratch, scratch);
1667 } // else
1668
1669 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ABS %s, %s;", addr, src0);
1670 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ADD %s, %s, 0.5;", addr, addr);
1671 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "FLR %s, %s;", addr, addr);
1672 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", addr, addr, scratch);
1673
1674 // we don't handle these right now, since emit_ARB1_dest_modifiers(ctx)
1675 // wants to look at dest_arg, not our temp register.
1676 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->dest_arg.result_mod == 0);
1677 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->dest_arg.result_shift == 0);
1678
1679 // we assign to the actual address register as needed.
1680 ctx->last_address_reg_componentcxx . . $ Context#last_address_reg_component. = -1;
1681 } // else
1682 } // emit_ARB1_MOVA
1683
1684
1685 void emit_ARB1_TEXKILLcxx . . $ emit_ARB1_TEXKILL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1686 {
1687 // d3d kills on xyz, arb1 kills on xyzw. Fix the swizzle.
1688 // We just map the x component to w. If it's negative, the fragment
1689 // would discard anyhow, otherwise, it'll pass through okay. This saves
1690 // us a temp register.
1691 char dst[64];
1692 get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1693 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "KIL %s.xyzx;", dst);
1694 } // emit_ARB1_TEXKILL
1695
1696 static void arb1_texbemcxx . . $ arb1_texbem(a15117967af15219).(Contextcxx . . $ Context# *ctx, const int luminance)
1697 {
1698 // !!! FIXME: this code counts on the register not having swizzles, etc.
1699 const int stage = ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.;
1700 char dst[64]; get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1701 char src[64]; get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 0, src, sizeof (src));
1702 char tmp[64]; allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, tmp, sizeof (tmp));
1703 char sampler[64];
1704 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., stage,
1705 sampler, sizeof (sampler));
1706
1707 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s_texbem.xzyw, %s.xyxy;", tmp, sampler, src);
1708 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ADD %s.xy, %s.xzxx, %s.ywxx;", tmp, tmp, tmp);
1709 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ADD %s.xy, %s, %s;", tmp, tmp, dst);
1710 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "TEX %s, %s, texture[%d], 2D;", dst, tmp, stage);
1711
1712 if (luminance) // TEXBEML, not just TEXBEM?
1713 {
1714 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAD %s, %s.zzzz, %s_texbeml.xxxx, %s_texbeml.yyyy;",
1715 tmp, src, sampler, sampler);
1716 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", dst, dst, tmp);
1717 } // if
1718
1719 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1720 } // arb1_texbem
1721
1722 void emit_ARB1_TEXBEMcxx . . $ emit_ARB1_TEXBEM(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1723 {
1724 arb1_texbemcxx . . $ arb1_texbem(a15117967af15219).(ctx, 0);
1725 } // emit_ARB1_TEXBEM
1726
1727 void emit_ARB1_TEXBEMLcxx . . $ emit_ARB1_TEXBEML(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1728 {
1729 arb1_texbemcxx . . $ arb1_texbem(a15117967af15219).(ctx, 1);
1730 } // emit_ARB1_TEXBEML
1731
1732 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(TEXREG2AR)
1733 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(TEXREG2GB)
1734
1735
1736 void emit_ARB1_TEXM3X2PADcxx . . $ emit_ARB1_TEXM3X2PAD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1737 {
1738 // no-op ... work happens in emit_ARB1_TEXM3X2TEX().
1739 } // emit_ARB1_TEXM3X2PAD
1740
1741 void emit_ARB1_TEXM3X2TEXcxx . . $ emit_ARB1_TEXM3X2TEX(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1742 {
1743 if (ctx->texm3x2pad_src0cxx . . $ Context#texm3x2pad_src0. == -1)
1744 return;
1745
1746 char dst[64];
1747 char src0[64];
1748 char src1[64];
1749 char src2[64];
1750
1751 // !!! FIXME: this code counts on the register not having swizzles, etc.
1752 const int stage = ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.;
1753 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x2pad_src0cxx . . $ Context#texm3x2pad_src0.,
1754 src0, sizeof (src0));
1755 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x2pad_dst0cxx . . $ Context#texm3x2pad_dst0.,
1756 src1, sizeof (src1));
1757 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.,
1758 src2, sizeof (src2));
1759 get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1760
1761 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.y, %s, %s;", dst, src2, dst);
1762 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.x, %s, %s;", dst, src0, src1);
1763 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "TEX %s, %s, texture[%d], 2D;", dst, dst, stage);
1764 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1765 } // emit_ARB1_TEXM3X2TEX
1766
1767
1768 void emit_ARB1_TEXM3X3PADcxx . . $ emit_ARB1_TEXM3X3PAD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1769 {
1770 // no-op ... work happens in emit_ARB1_TEXM3X3*().
1771 } // emit_ARB1_TEXM3X3PAD
1772
1773
1774 void emit_ARB1_TEXM3X3TEXcxx . . $ emit_ARB1_TEXM3X3TEX(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1775 {
1776 if (ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1. == -1)
1777 return;
1778
1779 char dst[64];
1780 char src0[64];
1781 char src1[64];
1782 char src2[64];
1783 char src3[64];
1784 char src4[64];
1785
1786 // !!! FIXME: this code counts on the register not having swizzles, etc.
1787 const int stage = ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.;
1788 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst0cxx . . $ Context#texm3x3pad_dst0.,
1789 src0, sizeof (src0));
1790 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src0cxx . . $ Context#texm3x3pad_src0.,
1791 src1, sizeof (src1));
1792 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst1cxx . . $ Context#texm3x3pad_dst1.,
1793 src2, sizeof (src2));
1794 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1.,
1795 src3, sizeof (src3));
1796 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.,
1797 src4, sizeof (src4));
1798 get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1799
1800 RegisterListcxx . . $ RegisterList# *sreg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., stage);
1801 const TextureTypecxx . . $ TextureType# ttype = (TextureTypecxx . . $ TextureType#) (sreg ? sreg->indexcxx . . $ RegisterList#index. : 0);
1802 const char *ttypestr = (ttype == TEXTURE_TYPE_CUBEcxx . . $ TEXTURE_TYPE_CUBE.) ? "CUBE" : "3D";
1803
1804 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.z, %s, %s;", dst, dst, src4);
1805 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.x, %s, %s;", dst, src0, src1);
1806 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.y, %s, %s;", dst, src2, src3);
1807 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "TEX %s, %s, texture[%d], %s;", dst, dst, stage, ttypestr);
1808 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1809 } // emit_ARB1_TEXM3X3TEX
1810
1811 void emit_ARB1_TEXM3X3SPECcxx . . $ emit_ARB1_TEXM3X3SPEC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1812 {
1813 if (ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1. == -1)
1814 return;
1815
1816 char dst[64];
1817 char src0[64];
1818 char src1[64];
1819 char src2[64];
1820 char src3[64];
1821 char src4[64];
1822 char src5[64];
1823 char tmp[64];
1824 char tmp2[64];
1825
1826 // !!! FIXME: this code counts on the register not having swizzles, etc.
1827 const int stage = ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.;
1828 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, tmp, sizeof (tmp));
1829 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, tmp2, sizeof (tmp2));
1830 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst0cxx . . $ Context#texm3x3pad_dst0.,
1831 src0, sizeof (src0));
1832 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src0cxx . . $ Context#texm3x3pad_src0.,
1833 src1, sizeof (src1));
1834 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst1cxx . . $ Context#texm3x3pad_dst1.,
1835 src2, sizeof (src2));
1836 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1.,
1837 src3, sizeof (src3));
1838 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.,
1839 src4, sizeof (src4));
1840 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[1].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.,
1841 src5, sizeof (src5));
1842 get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1843
1844 RegisterListcxx . . $ RegisterList# *sreg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., stage);
1845 const TextureTypecxx . . $ TextureType# ttype = (TextureTypecxx . . $ TextureType#) (sreg ? sreg->indexcxx . . $ RegisterList#index. : 0);
1846 const char *ttypestr = (ttype == TEXTURE_TYPE_CUBEcxx . . $ TEXTURE_TYPE_CUBE.) ? "CUBE" : "3D";
1847
1848 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.z, %s, %s;", dst, dst, src4);
1849 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.x, %s, %s;", dst, src0, src1);
1850 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.y, %s, %s;", dst, src2, src3);
1851 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", tmp, dst, dst); // normal * normal
1852 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", tmp2, dst, src5); // normal * eyeray
1853
1854 // !!! FIXME: This is goofy. There's got to be a way to do vector-wide
1855 // !!! FIXME: divides or reciprocals...right?
1856 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RCP %s.x, %s.x;", tmp2, tmp2);
1857 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RCP %s.y, %s.y;", tmp2, tmp2);
1858 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RCP %s.z, %s.z;", tmp2, tmp2);
1859 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RCP %s.w, %s.w;", tmp2, tmp2);
1860 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", tmp, tmp, tmp2);
1861
1862 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, { 2.0, 2.0, 2.0, 2.0 };", tmp, tmp);
1863 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAD %s, %s, %s, -%s;", tmp, tmp, dst, src5);
1864 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "TEX %s, %s, texture[%d], %s;", dst, tmp, stage, ttypestr);
1865 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1866 } // emit_ARB1_TEXM3X3SPEC
1867
1868 void emit_ARB1_TEXM3X3VSPECcxx . . $ emit_ARB1_TEXM3X3VSPEC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1869 {
1870 if (ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1. == -1)
1871 return;
1872
1873 char dst[64];
1874 char src0[64];
1875 char src1[64];
1876 char src2[64];
1877 char src3[64];
1878 char src4[64];
1879 char tmp[64];
1880 char tmp2[64];
1881 char tmp3[64];
1882
1883 // !!! FIXME: this code counts on the register not having swizzles, etc.
1884 const int stage = ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.;
1885 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, tmp, sizeof (tmp));
1886 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, tmp2, sizeof (tmp2));
1887 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, tmp3, sizeof (tmp3));
1888 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst0cxx . . $ Context#texm3x3pad_dst0.,
1889 src0, sizeof (src0));
1890 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src0cxx . . $ Context#texm3x3pad_src0.,
1891 src1, sizeof (src1));
1892 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst1cxx . . $ Context#texm3x3pad_dst1.,
1893 src2, sizeof (src2));
1894 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1.,
1895 src3, sizeof (src3));
1896 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.,
1897 src4, sizeof (src4));
1898 get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1899
1900 RegisterListcxx . . $ RegisterList# *sreg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., stage);
1901 const TextureTypecxx . . $ TextureType# ttype = (TextureTypecxx . . $ TextureType#) (sreg ? sreg->indexcxx . . $ RegisterList#index. : 0);
1902 const char *ttypestr = (ttype == TEXTURE_TYPE_CUBEcxx . . $ TEXTURE_TYPE_CUBE.) ? "CUBE" : "3D";
1903
1904 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOV %s.x, %s.w;", tmp3, src0);
1905 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOV %s.y, %s.w;", tmp3, src2);
1906 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOV %s.z, %s.w;", tmp3, dst);
1907 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.z, %s, %s;", dst, dst, src4);
1908 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.x, %s, %s;", dst, src0, src1);
1909 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.y, %s, %s;", dst, src2, src3);
1910 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", tmp, dst, dst); // normal * normal
1911 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", tmp2, dst, tmp3); // normal * eyeray
1912
1913 // !!! FIXME: This is goofy. There's got to be a way to do vector-wide
1914 // !!! FIXME: divides or reciprocals...right?
1915 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RCP %s.x, %s.x;", tmp2, tmp2);
1916 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RCP %s.y, %s.y;", tmp2, tmp2);
1917 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RCP %s.z, %s.z;", tmp2, tmp2);
1918 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "RCP %s.w, %s.w;", tmp2, tmp2);
1919 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", tmp, tmp, tmp2);
1920
1921 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, { 2.0, 2.0, 2.0, 2.0 };", tmp, tmp);
1922 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MAD %s, %s, %s, -%s;", tmp, tmp, dst, tmp3);
1923 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "TEX %s, %s, texture[%d], %s;", dst, tmp, stage, ttypestr);
1924 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1925 } // emit_ARB1_TEXM3X3VSPEC
1926
1927 void emit_ARB1_EXPPcxx . . $ emit_ARB1_EXPP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "EX2"); }
1928 void emit_ARB1_LOGPcxx . . $ emit_ARB1_LOGP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx) { arb1_logcxx . . $ arb1_log(72ff1ec6cf40f147).(ctx, "LG2"); }
1929
1930 void emit_ARB1_CNDcxx . . $ emit_ARB1_CND(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1931 {
1932 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1933 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1934 char src1[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
1935 char src2[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 2, src2, sizeof (src2));
1936 char tmp[64]; allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, tmp, sizeof (tmp));
1937
1938 // CND compares against 0.5, but we need to compare against 0.0...
1939 // ...subtract to make up the difference.
1940 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "SUB %s, %s, { 0.5, 0.5, 0.5, 0.5 };", tmp, src0);
1941 // D3D tests (src0 >= 0.0), but ARB1 tests (src0 < 0.0) ... so just
1942 // switch src1 and src2 to get the same results.
1943 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "CMP%s, %s, %s, %s;", dst, tmp, src2, src1);
1944 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1945 } // emit_ARB1_CND
1946
1947 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(TEXREG2RGB)
1948 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(TEXDP3TEX)
1949 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(TEXM3X2DEPTH)
1950 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(TEXDP3)
1951
1952 void emit_ARB1_TEXM3X3cxx . . $ emit_ARB1_TEXM3X3(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1953 {
1954 if (ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1. == -1)
1955 return;
1956
1957 char dst[64];
1958 char src0[64];
1959 char src1[64];
1960 char src2[64];
1961 char src3[64];
1962 char src4[64];
1963
1964 // !!! FIXME: this code counts on the register not having swizzles, etc.
1965 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst0cxx . . $ Context#texm3x3pad_dst0.,
1966 src0, sizeof (src0));
1967 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src0cxx . . $ Context#texm3x3pad_src0.,
1968 src1, sizeof (src1));
1969 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst1cxx . . $ Context#texm3x3pad_dst1.,
1970 src2, sizeof (src2));
1971 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1.,
1972 src3, sizeof (src3));
1973 get_ARB1_varname_in_bufcxx . . $ get_ARB1_varname_in_buf(e11e601b5c61efa5).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.,
1974 src4, sizeof (src4));
1975 get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1976
1977 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.z, %s, %s;", dst, dst, src4);
1978 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.x, %s, %s;", dst, src0, src1);
1979 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "DP3 %s.y, %s, %s;", dst, src2, src3);
1980 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MOV %s.w, { 1.0, 1.0, 1.0, 1.0 };", dst);
1981 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1982 } // emit_ARB1_TEXM3X3
1983
1984 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(TEXDEPTH)
1985
1986 void emit_ARB1_CMPcxx . . $ emit_ARB1_CMP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1987 {
1988 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
1989 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
1990 char src1[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
1991 char src2[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 2, src2, sizeof (src2));
1992 // D3D tests (src0 >= 0.0), but ARB1 tests (src0 < 0.0) ... so just
1993 // switch src1 and src2 to get the same results.
1994 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "CMP%s, %s, %s, %s;", dst, src0, src2, src1);
1995 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
1996 } // emit_ARB1_CMP
1997
1998 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(BEM)
1999
2000
2001 void emit_ARB1_DP2ADDcxx . . $ emit_ARB1_DP2ADD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2002 {
2003 if (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)) // nv4 has a built-in equivalent to DP2ADD.
2004 emit_ARB1_opcode_dssscxx . . $ emit_ARB1_opcode_dsss(72ff1ec6cf40f147).(ctx, "DP2A");
2005 else
2006 {
2007 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
2008 char src0[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
2009 char src1[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
2010 char src2[64]; make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 2, src2, sizeof (src2));
2011 char scratch[64];
2012
2013 // DP2ADD is:
2014 // dst = (src0.r * src1.r) + (src0.g * src1.g) + src2.replicate_swiz
2015 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, scratch, sizeof (scratch));
2016 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "MUL %s, %s, %s;", scratch, src0, src1);
2017 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ADD %s, %s.x, %s.y;", scratch, scratch, scratch);
2018 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "ADD%s, %s.x, %s;", dst, scratch, src2);
2019 emit_ARB1_dest_modifierscxx . . $ emit_ARB1_dest_modifiers(612dd59919e2530e).(ctx);
2020 } // else
2021 } // emit_ARB1_DP2ADD
2022
2023
2024 void emit_ARB1_DSXcxx . . $ emit_ARB1_DSX(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2025 {
2026 if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) // nv2 has a built-in equivalent to DSX.
2027 emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "DDX");
2028 else
2029 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "DSX unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
2030 } // emit_ARB1_DSX
2031
2032
2033 void emit_ARB1_DSYcxx . . $ emit_ARB1_DSY(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2034 {
2035 if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)) // nv2 has a built-in equivalent to DSY.
2036 emit_ARB1_opcode_dscxx . . $ emit_ARB1_opcode_ds(72ff1ec6cf40f147).(ctx, "DDY");
2037 else
2038 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "DSY unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
2039 } // emit_ARB1_DSY
2040
2041 static void arb1_texldcxx . . $ arb1_texld(4bebb3ec92396cca).(Contextcxx . . $ Context# *ctx, const char *opcode, const int texldd)
2042 {
2043 // !!! FIXME: Hack: "TEXH" is invalid in nv4. Fix this more cleanly.
2044 if ((ctx->dest_argcxx . . $ Context#dest_arg..result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. & MOD_PPcxx . . $ `mojoshader_internal.h:504:9`!) && (support_nv4cxx . . $ `profiles/mojoshader_profile.h:229:9`!(ctx)))
2045 ctx->dest_argcxx . . $ Context#dest_arg..result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. &= ~MOD_PPcxx . . $ `mojoshader_internal.h:504:9`!;
2046
2047 char dst[64]; make_ARB1_destarg_stringcxx . . $ make_ARB1_destarg_string(dc03443d56ed936a).(ctx, dst, sizeof (dst));
2048
2049 const int sm1 = !shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4);
2050 const int regnum = sm1 ? ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum. : ctx->source_argscxx . . $ Context#source_args.[1].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.;
2051 RegisterListcxx . . $ RegisterList# *sreg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., regnum);
2052
2053 const char *ttype = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
2054 char src0[64];
2055 if (sm1)
2056 get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, src0, sizeof (src0));
2057 else
2058 get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
2059 //char src1[64]; get_ARB1_srcarg_varname(ctx, 1, src1, sizeof (src1)); // !!! FIXME: SRC_MOD?
2060
2061 char src2[64] = { 0 };
2062 char src3[64] = { 0 };
2063
2064 if (texldd)
2065 {
2066 make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 2, src2, sizeof (src2));
2067 make_ARB1_srcarg_stringcxx . . $ make_ARB1_srcarg_string(977c8228f57f653a).(ctx, 3, src3, sizeof (src3));
2068 } // if
2069
2070 // !!! FIXME: this should be in state_TEXLD, not in the arb1/glsl emitters.
2071 if (sreg == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
2072 {
2073 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "TEXLD using undeclared sampler");
2074 return;
2075 } // if
2076
2077 // SM1 only specifies dst, so don't check swizzle there.
2078 if ( !sm1 && (!no_swizzlecxx . . $ no_swizzle(7864480464b09eea).(ctx->source_argscxx . . $ Context#source_args.[1].swizzlecxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle.)) )
2079 {
2080 // !!! FIXME: does this ever actually happen?
2081 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: can't handle TEXLD with sampler swizzle at the moment");
2082 } // if
2083
2084 switch ((const TextureTypecxx . . $ TextureType#) sreg->indexcxx . . $ RegisterList#index.)
2085 {
2086 case TEXTURE_TYPE_2Dcxx . . $ TEXTURE_TYPE_2D.: ttype = "2D"; break; // !!! FIXME: "RECT"?
2087 case TEXTURE_TYPE_CUBEcxx . . $ TEXTURE_TYPE_CUBE.: ttype = "CUBE"; break;
2088 case TEXTURE_TYPE_VOLUMEcxx . . $ TEXTURE_TYPE_VOLUME.: ttype = "3D"; break;
2089 default: failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown texture type"); return;
2090 } // switch
2091
2092 if (texldd)
2093 {
2094 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s, %s, %s, %s, texture[%d], %s;", opcode, dst,
2095 src0, src2, src3, regnum, ttype);
2096 } // if
2097 else
2098 {
2099 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s%s, %s, texture[%d], %s;", opcode, dst, src0,
2100 regnum, ttype);
2101 } // else
2102 } // arb1_texld
2103
2104
2105 void emit_ARB1_TEXLDDcxx . . $ emit_ARB1_TEXLDD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2106 {
2107 // With GL_NV_fragment_program2, we can use the TXD opcode.
2108 // In stock arb1, we can settle for a standard texld, which isn't
2109 // perfect, but oh well.
2110 if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
2111 arb1_texldcxx . . $ arb1_texld(4bebb3ec92396cca).(ctx, "TXD", 1);
2112 else
2113 arb1_texldcxx . . $ arb1_texld(4bebb3ec92396cca).(ctx, "TEX", 0);
2114 } // emit_ARB1_TEXLDD
2115
2116
2117 void emit_ARB1_TEXLDLcxx . . $ emit_ARB1_TEXLDL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2118 {
2119 if ((shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx)) && (!support_nv3cxx . . $ `profiles/mojoshader_profile.h:228:9`!(ctx)))
2120 {
2121 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Vertex shader TEXLDL unsupported in %s profile",
2122 ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
2123 return;
2124 } // if
2125
2126 else if ((shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) && (!support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx)))
2127 {
2128 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Pixel shader TEXLDL unsupported in %s profile",
2129 ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
2130 return;
2131 } // if
2132
2133 // !!! FIXME: this doesn't map exactly to TEXLDL. Review this.
2134 arb1_texldcxx . . $ arb1_texld(4bebb3ec92396cca).(ctx, "TXL", 0);
2135 } // emit_ARB1_TEXLDL
2136
2137
2138 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(BREAKP)
2139 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(BREAKC)
2140
2141 void emit_ARB1_IFCcxx . . $ emit_ARB1_IFC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2142 {
2143 if (support_nv2cxx . . $ `profiles/mojoshader_profile.h:227:9`!(ctx))
2144 {
2145 const char *comps[] = {
2146 "", "SGTC", "SEQC", "SGEC", "SGTC", "SNEC", "SLEC"
2147 };
2148
2149 if (ctx->instruction_controlscxx . . $ Context#instruction_controls. >= STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(comps))
2150 {
2151 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown comparison control");
2152 return;
2153 } // if
2154
2155 char src0[64];
2156 char src1[64];
2157 char scratch[64];
2158
2159 const char *comp = comps[ctx->instruction_controlscxx . . $ Context#instruction_controls.];
2160 get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 0, src0, sizeof (src0));
2161 get_ARB1_srcarg_varnamecxx . . $ get_ARB1_srcarg_varname(977c8228f57f653a).(ctx, 1, src1, sizeof (src1));
2162 allocate_ARB1_scratch_reg_namecxx . . $ allocate_ARB1_scratch_reg_name(dc03443d56ed936a).(ctx, scratch, sizeof (scratch));
2163 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "%s %s.x, %s, %s;", comp, scratch, src0, src1);
2164 nv2_ifcxx . . $ nv2_if(612dd59919e2530e).(ctx);
2165 } // if
2166
2167 else // stock ARB1 has no branching.
2168 {
2169 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "branching unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
2170 } // else
2171 } // emit_ARB1_IFC
2172
2173
2174 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(SETP)
2175
2176 void emit_ARB1_DEFcxx . . $ emit_ARB1_DEF(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2177 {
2178 const float *val = (const float *) ctx->dwordscxx . . $ Context#dwords.; // !!! FIXME: could be int?
2179 char dst[64]; get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
2180 char val0[32]; floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val0, sizeof (val0), val[0], 1);
2181 char val1[32]; floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val1, sizeof (val1), val[1], 1);
2182 char val2[32]; floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val2, sizeof (val2), val[2], 1);
2183 char val3[32]; floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(ctx, val3, sizeof (val3), val[3], 1);
2184
2185 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
2186 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "PARAM %s = { %s, %s, %s, %s };",
2187 dst, val0, val1, val2, val3);
2188 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2189 } // emit_ARB1_DEF
2190
2191 void emit_ARB1_DEFIcxx . . $ emit_ARB1_DEFI(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2192 {
2193 char dst[64]; get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
2194 const int32cxx . . $ int32# *x = (const int32cxx . . $ int32# *) ctx->dwordscxx . . $ Context#dwords.;
2195 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
2196 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "PARAM %s = { %d, %d, %d, %d };",
2197 dst, (int) x[0], (int) x[1], (int) x[2], (int) x[3]);
2198 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2199 } // emit_ARB1_DEFI
2200
2201 void emit_ARB1_DEFBcxx . . $ emit_ARB1_DEFB(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2202 {
2203 char dst[64]; get_ARB1_destarg_varnamecxx . . $ get_ARB1_destarg_varname(dc03443d56ed936a).(ctx, dst, sizeof (dst));
2204 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
2205 output_linecxx . . $ output_line(f93f6dc5e2b298a0).(ctx, "PARAM %s = %d;", dst, ctx->dwordscxx . . $ Context#dwords.[0] ? 1 : 0);
2206 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2207 } // emit_ARB1_DEFB
2208
2209 void emit_ARB1_DCLcxx . . $ emit_ARB1_DCL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2210 {
2211 // no-op. We do this in our emit_attribute() and emit_uniform().
2212 } // emit_ARB1_DCL
2213
2214 EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!(TEXCRD)
2215
2216 void emit_ARB1_TEXLDcxx . . $ emit_ARB1_TEXLD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2217 {
2218 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4))
2219 {
2220 arb1_texldcxx . . $ arb1_texld(4bebb3ec92396cca).(ctx, "TEX", 0);
2221 return;
2222 } // if
2223
2224 else if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 2, 0))
2225 {
2226 // ps_1_4 is different, too!
2227 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "TEXLD == Shader Model 1.4 unimplemented."); // !!! FIXME
2228 return;
2229 } // if
2230
2231 // !!! FIXME: do texldb and texldp map between OpenGL and D3D correctly?
2232 if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDcxx . . $ `mojoshader_internal.h:471:9`!)
2233 arb1_texldcxx . . $ arb1_texld(4bebb3ec92396cca).(ctx, "TEX", 0);
2234 else if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDPcxx . . $ `mojoshader_internal.h:472:9`!)
2235 arb1_texldcxx . . $ arb1_texld(4bebb3ec92396cca).(ctx, "TXP", 0);
2236 else if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDBcxx . . $ `mojoshader_internal.h:473:9`!)
2237 arb1_texldcxx . . $ arb1_texld(4bebb3ec92396cca).(ctx, "TXB", 0);
2238 } // emit_ARB1_TEXLD
2239
2240 #undef EMIT_ARB1_OPCODE_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:498:9`!
2241 #undef EMIT_ARB1_OPCODE_D_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:502:9`!
2242 #undef EMIT_ARB1_OPCODE_S_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:506:9`!
2243 #undef EMIT_ARB1_OPCODE_SS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:510:9`!
2244 #undef EMIT_ARB1_OPCODE_DS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:514:9`!
2245 #undef EMIT_ARB1_OPCODE_DSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:518:9`!
2246 #undef EMIT_ARB1_OPCODE_DSSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:522:9`!
2247 #undef EMIT_ARB1_OPCODE_DSSSS_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:526:9`!
2248 #undef EMIT_ARB1_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_arb1.c:530:9`!
2249
2250 #endif // SUPPORT_PROFILE_ARB1
2251
2252 #pragma GCC visibility pop