Debian Codegraph @

profiles/mojoshader_profile_common.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_common.c:10:9`! 1
11 #include "mojoshader_profile.h"cxx . . $ `<file>/profiles/mojoshader_profile.h`/
12
13 #pragma GCC visibility push(hidden)
14
15 // Common Utilities
16
17 void out_of_memorycxx . . $ out_of_memory(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
18 {
19 ctx->isfailcxx . . $ Context#isfail. = ctx->out_of_memorycxx . . $ Context#out_of_memory. = 1;
20 } // out_of_memory
21
22 void *Malloccxx . . $ Malloc(a6ec60c25fe5143e).(Contextcxx . . $ Context# *ctx, const size_t len)
23 {
24 void *retval = ctx->malloccxx . . $ Context#malloc.((int) len, ctx->malloc_datacxx . . $ Context#malloc_data.);
25 if (retval == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
26 out_of_memorycxx . . $ out_of_memory(612dd59919e2530e).(ctx);
27 return retval;
28 } // Malloc
29
30 char *StrDupcxx . . $ StrDup(5771b401aae6b992).(Contextcxx . . $ Context# *ctx, const char *str)
31 {
32 char *retval = (char *) Malloccxx . . $ Malloc(a6ec60c25fe5143e).(ctx, strlencxx . . $ strlen(751346f8406fd082).(str) + 1);
33 if (retval != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
34 strcpycxx . . $ strcpy(b7b3a83273496486).(retval, str);
35 return retval;
36 } // StrDup
37
38 void Freecxx . . $ Free(b86e3b3d45e44ecf).(Contextcxx . . $ Context# *ctx, void *ptr)
39 {
40 ctx->freecxx . . $ Context#free.(ptr, ctx->malloc_datacxx . . $ Context#malloc_data.);
41 } // Free
42
43 void * MOJOSHADERCALLcxx . . $ `mojoshader.h:42:9`! MallocBridgecxx . . $ MallocBridge(d0e8a54466770ee5).(int bytes, void *data)
44 {
45 return Malloccxx . . $ Malloc(a6ec60c25fe5143e).((Contextcxx . . $ Context# *) data, (size_t) bytes);
46 } // MallocBridge
47
48 void MOJOSHADERCALLcxx . . $ `mojoshader.h:42:9`! FreeBridgecxx . . $ FreeBridge(6c58c5e2437d25a2).(void *ptr, void *data)
49 {
50 Freecxx . . $ Free(b86e3b3d45e44ecf).((Contextcxx . . $ Context# *) data, ptr);
51 } // FreeBridge
52
53 // Jump between output sections in the context...
54
55 int set_outputcxx . . $ set_output(dbab56076057d0b7).(Contextcxx . . $ Context# *ctx, Buffercxx . . $ Buffer# **section)
56 {
57 // only create output sections on first use.
58 if (*section == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
59 {
60 *section = buffer_createcxx . . $ buffer_create(76a014b9fd4a8dd).(256, MallocBridgecxx . . $ MallocBridge(d0e8a54466770ee5)., FreeBridgecxx . . $ FreeBridge(6c58c5e2437d25a2)., ctx);
61 if (*section == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
62 return 0;
63 } // if
64
65 ctx->outputcxx . . $ Context#output. = *section;
66 return 1;
67 } // set_output
68
69 void push_outputcxx . . $ push_output(80f724ef23dce062).(Contextcxx . . $ Context# *ctx, Buffercxx . . $ Buffer# **section)
70 {
71 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->output_stack_len < (int) (STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->output_stack)));
72 ctx->output_stackcxx . . $ Context#output_stack.[ctx->output_stack_lencxx . . $ Context#output_stack_len.] = ctx->outputcxx . . $ Context#output.;
73 ctx->indent_stackcxx . . $ Context#indent_stack.[ctx->output_stack_lencxx . . $ Context#output_stack_len.] = ctx->indentcxx . . $ Context#indent.;
74 ctx->output_stack_lencxx . . $ Context#output_stack_len.++;
75 if (!set_outputcxx . . $ set_output(dbab56076057d0b7).(ctx, section))
76 return;
77 ctx->indentcxx . . $ Context#indent. = 0;
78 } // push_output
79
80 void pop_outputcxx . . $ pop_output(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
81 {
82 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->output_stack_len > 0);
83 ctx->output_stack_lencxx . . $ Context#output_stack_len.--;
84 ctx->outputcxx . . $ Context#output. = ctx->output_stackcxx . . $ Context#output_stack.[ctx->output_stack_lencxx . . $ Context#output_stack_len.];
85 ctx->indentcxx . . $ Context#indent. = ctx->indent_stackcxx . . $ Context#indent_stack.[ctx->output_stack_lencxx . . $ Context#output_stack_len.];
86 } // pop_output
87
88 // Shader model version magic...
89
90 uint32cxx . . $ uint32# ver_ui32cxx . . $ ver_ui32(ce7b340bf7a3914f).(const uint8cxx . . $ uint8# major, const uint8cxx . . $ uint8# minor)
91 {
92 return ( (((uint32cxx . . $ uint32#) major) << 16) | (((minor) == 0xFF) ? 1 : (minor)) );
93 } // version_ui32
94
95 int shader_version_supportedcxx . . $ shader_version_supported(d6776848f30c113d).(const uint8cxx . . $ uint8# maj, const uint8cxx . . $ uint8# min)
96 {
97 return (ver_ui32cxx . . $ ver_ui32(ce7b340bf7a3914f).(maj,min) <= ver_ui32cxx . . $ ver_ui32(ce7b340bf7a3914f).(MAX_SHADER_MAJORcxx . . $ `mojoshader_internal.h:162:9`!, MAX_SHADER_MINORcxx . . $ `mojoshader_internal.h:163:9`!));
98 } // shader_version_supported
99
100 int shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(const Contextcxx . . $ Context# *ctx, const uint8cxx . . $ uint8# maj,
101 const uint8cxx . . $ uint8# min)
102 {
103 return (ver_ui32cxx . . $ ver_ui32(ce7b340bf7a3914f).(ctx->major_vercxx . . $ Context#major_ver., ctx->minor_vercxx . . $ Context#minor_ver.) >= ver_ui32cxx . . $ ver_ui32(ce7b340bf7a3914f).(maj, min));
104 } // shader_version_atleast
105
106 int shader_version_exactlycxx . . $ shader_version_exactly(83a707663ee9af3d).(const Contextcxx . . $ Context# *ctx, const uint8cxx . . $ uint8# maj,
107 const uint8cxx . . $ uint8# min)
108 {
109 return ((ctx->major_vercxx . . $ Context#major_ver. == maj) && (ctx->minor_vercxx . . $ Context#minor_ver. == min));
110 } // shader_version_exactly
111
112 int shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(const Contextcxx . . $ Context# *ctx)
113 {
114 return (ctx->shader_typecxx . . $ Context#shader_type. == MOJOSHADER_TYPE_PIXELcxx . . $ MOJOSHADER_TYPE_PIXEL.);
115 } // shader_is_pixel
116
117 int shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(const Contextcxx . . $ Context# *ctx)
118 {
119 return (ctx->shader_typecxx . . $ Context#shader_type. == MOJOSHADER_TYPE_VERTEXcxx . . $ MOJOSHADER_TYPE_VERTEX.);
120 } // shader_is_vertex
121
122 // Fail...
123
124 int isfailcxx . . $ isfail(73332d3452342b36).(const Contextcxx . . $ Context# *ctx)
125 {
126 return ctx->isfailcxx . . $ Context#isfail.;
127 } // isfail
128
129 void failfcxx . . $ failf(f93f6dc5e2b298a0).(Contextcxx . . $ Context# *ctx, const char *fmt, ...) ISPRINTFcxx . . $ `mojoshader_internal.h:308:9`!(2,3);
130 void failfcxx . . $ failf(f93f6dc5e2b298a0).(Contextcxx . . $ Context# *ctx, const char *fmt, ...)
131 {
132 ctx->isfailcxx . . $ Context#isfail. = 1;
133 if (ctx->out_of_memorycxx . . $ Context#out_of_memory.)
134 return;
135
136 // no filename at this level (we pass a NULL to errorlist_add_va()...)
137 va_listcxx . . $ va_list# ap;
138 va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(ap, fmt);
139 errorlist_add_vacxx . . $ errorlist_add_va(97218a3e36e3d3b0).(ctx->errorscxx . . $ Context#errors., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, ctx->current_positioncxx . . $ Context#current_position., fmt, ap);
140 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap);
141 } // failf
142
143 void failcxx . . $ fail(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *reason)
144 {
145 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "%s", reason);
146 } // fail
147
148 // Output Lines...
149
150 void output_linecxx . . $ output_line(f93f6dc5e2b298a0).(Contextcxx . . $ Context# *ctx, const char *fmt, ...) ISPRINTFcxx . . $ `mojoshader_internal.h:308:9`!(2,3);
151 void output_linecxx . . $ output_line(f93f6dc5e2b298a0).(Contextcxx . . $ Context# *ctx, const char *fmt, ...)
152 {
153 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->output != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
154 if (isfailcxx . . $ isfail(73332d3452342b36).(ctx))
155 return; // we failed previously, don't go on...
156
157 const int indent = ctx->indentcxx . . $ Context#indent.;
158 if (indent > 0)
159 {
160 char *indentbuf = (char *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(indent);
161 memsetcxx . . $ memset(d1de1e4fb215f1c6).(indentbuf, '\t', indent);
162 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., indentbuf, indent);
163 } // if
164
165 va_listcxx . . $ va_list# ap;
166 va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(ap, fmt);
167 buffer_append_vacxx . . $ buffer_append_va(70652df479affa1f).(ctx->outputcxx . . $ Context#output., fmt, ap);
168 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap);
169
170 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., ctx->endlinecxx . . $ Context#endline., ctx->endline_lencxx . . $ Context#endline_len.);
171 } // output_line
172
173 void output_blank_linecxx . . $ output_blank_line(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
174 {
175 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->output != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
176 if (!isfailcxx . . $ isfail(73332d3452342b36).(ctx))
177 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., ctx->endlinecxx . . $ Context#endline., ctx->endline_lencxx . . $ Context#endline_len.);
178 } // output_blank_line
179
180 // !!! FIXME: this is sort of nasty.
181 void floatstrcxx . . $ floatstr(c547f24a0ba6b59c).(Contextcxx . . $ Context# *ctx, char *buf, size_t bufsize, float f,
182 int leavedecimal)
183 {
184 const size_t len = MOJOSHADER_printFloatcxx . . $ MOJOSHADER_printFloat(d760c2ad178ccd37).(buf, bufsize, f);
185 if ((len+2) >= bufsize)
186 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: internal buffer is too small");
187 else
188 {
189 char *end = buf + len;
190 char *ptr = strchrcxx . . $ strchr(2050848944e00d54).(buf, '.');
191 if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
192 {
193 if (leavedecimal)
194 strcatcxx . . $ strcat(b7b3a83273496486).(buf, ".0");
195 return; // done.
196 } // if
197
198 while (--end != ptr)
199 {
200 if (*end != '0')
201 {
202 end++;
203 break;
204 } // if
205 } // while
206 if ((leavedecimal) && (end == ptr))
207 end += 2;
208 *end = '\0'; // chop extra '0' or all decimal places off.
209 } // else
210 } // floatstr
211
212 // Deal with register lists...
213
214 static inline uint32cxx . . $ uint32# reg_to_ui32cxx . . $ reg_to_ui32(66a4622705488358).(const RegisterTypecxx . . $ RegisterType# regtype, const int regnum)
215 {
216 return ( ((uint32cxx . . $ uint32#) regnum) | (((uint32cxx . . $ uint32#) regtype) << 16) );
217 } // reg_to_uint32
218
219 // !!! FIXME: ditch this for a hash table.
220 RegisterListcxx . . $ RegisterList# *reglist_insertcxx . . $ reglist_insert(ecaaee1ec12f4c21).(Contextcxx . . $ Context# *ctx, RegisterListcxx . . $ RegisterList# *prev,
221 const RegisterTypecxx . . $ RegisterType# regtype,
222 const int regnum)
223 {
224 const uint32cxx . . $ uint32# newval = reg_to_ui32cxx . . $ reg_to_ui32(66a4622705488358).(regtype, regnum);
225 RegisterListcxx . . $ RegisterList# *item = prev->nextcxx . . $ RegisterList#next.;
226 while (item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
227 {
228 const uint32cxx . . $ uint32# val = reg_to_ui32cxx . . $ reg_to_ui32(66a4622705488358).(item->regtypecxx . . $ RegisterList#regtype., item->regnumcxx . . $ RegisterList#regnum.);
229 if (newval == val)
230 return item; // already set, so we're done.
231 else if (newval < val) // insert it here.
232 break;
233 else // if (newval > val)
234 {
235 // keep going, we're not to the insertion point yet.
236 prev = item;
237 item = item->nextcxx . . $ RegisterList#next.;
238 } // else
239 } // while
240
241 // we need to insert an entry after (prev).
242 item = (RegisterListcxx . . $ RegisterList# *) Malloccxx . . $ Malloc(a6ec60c25fe5143e).(ctx, sizeof (RegisterListcxx . . $ RegisterList#));
243 if (item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
244 {
245 item->regtypecxx . . $ RegisterList#regtype. = regtype;
246 item->regnumcxx . . $ RegisterList#regnum. = regnum;
247 item->usagecxx . . $ RegisterList#usage. = MOJOSHADER_USAGE_UNKNOWNcxx . . $ MOJOSHADER_USAGE_UNKNOWN.;
248 item->indexcxx . . $ RegisterList#index. = 0;
249 item->writemaskcxx . . $ RegisterList#writemask. = 0;
250 item->misccxx . . $ RegisterList#misc. = 0;
251 item->writtencxx . . $ RegisterList#written. = 0;
252 #if SUPPORT_PROFILE_SPIRVcxx . . $ `mojoshader_internal.h:210:9`!
253 item->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = 0;
254 item->spirvcxx . . $ RegisterList#spirv..is_ssacxx . . $ RegisterList#$anonymous_type_0#is_ssa. = 0;
255 #endif
256 item->arraycxx . . $ RegisterList#array. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
257 item->nextcxx . . $ RegisterList#next. = prev->nextcxx . . $ RegisterList#next.;
258 prev->nextcxx . . $ RegisterList#next. = item;
259 } // if
260
261 return item;
262 } // reglist_insert
263
264 RegisterListcxx . . $ RegisterList# *reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(const RegisterListcxx . . $ RegisterList# *prev,
265 const RegisterTypecxx . . $ RegisterType# rtype,
266 const int regnum)
267 {
268 const uint32cxx . . $ uint32# newval = reg_to_ui32cxx . . $ reg_to_ui32(66a4622705488358).(rtype, regnum);
269 RegisterListcxx . . $ RegisterList# *item = prev->nextcxx . . $ RegisterList#next.;
270 while (item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
271 {
272 const uint32cxx . . $ uint32# val = reg_to_ui32cxx . . $ reg_to_ui32(66a4622705488358).(item->regtypecxx . . $ RegisterList#regtype., item->regnumcxx . . $ RegisterList#regnum.);
273 if (newval == val)
274 return item; // here it is.
275 else if (newval < val) // should have been here if it existed.
276 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
277 else // if (newval > val)
278 item = item->nextcxx . . $ RegisterList#next.;
279 } // while
280
281 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; // wasn't in the list.
282 } // reglist_find
283
284 RegisterListcxx . . $ RegisterList# *set_used_registercxx . . $ set_used_register(e54d43264d6a4c0d).(Contextcxx . . $ Context# *ctx,
285 const RegisterTypecxx . . $ RegisterType# regtype,
286 const int regnum,
287 const int written)
288 {
289 RegisterListcxx . . $ RegisterList# *reg = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
290 if ((regtype == REG_TYPE_COLOROUTcxx . . $ REG_TYPE_COLOROUT.) && (regnum > 0))
291 ctx->have_multi_color_outputscxx . . $ Context#have_multi_color_outputs. = 1;
292
293 reg = reglist_insertcxx . . $ reglist_insert(ecaaee1ec12f4c21).(ctx, &ctx->used_registerscxx . . $ Context#used_registers., regtype, regnum);
294 if (reg && written)
295 reg->writtencxx . . $ RegisterList#written. = 1;
296 return reg;
297 } // set_used_register
298
299 void set_defined_registercxx . . $ set_defined_register(8475323e8d0fe52d).(Contextcxx . . $ Context# *ctx, const RegisterTypecxx . . $ RegisterType# rtype,
300 const int regnum)
301 {
302 reglist_insertcxx . . $ reglist_insert(ecaaee1ec12f4c21).(ctx, &ctx->defined_registerscxx . . $ Context#defined_registers., rtype, regnum);
303 } // set_defined_register
304
305 // Writemasks
306
307 int writemask_xyzwcxx . . $ writemask_xyzw(7864480464b09eea).(const int writemask)
308 {
309 return (writemask == 0xF); // 0xF == 1111. No explicit mask (full!).
310 } // writemask_xyzw
311
312 int writemask_xyzcxx . . $ writemask_xyz(7864480464b09eea).(const int writemask)
313 {
314 return (writemask == 0x7); // 0x7 == 0111. (that is: xyz)
315 } // writemask_xyz
316
317 int writemask_xycxx . . $ writemask_xy(7864480464b09eea).(const int writemask)
318 {
319 return (writemask == 0x3); // 0x3 == 0011. (that is: xy)
320 } // writemask_xy
321
322 int writemask_xcxx . . $ writemask_x(7864480464b09eea).(const int writemask)
323 {
324 return (writemask == 0x1); // 0x1 == 0001. (that is: x)
325 } // writemask_x
326
327 int writemask_ycxx . . $ writemask_y(7864480464b09eea).(const int writemask)
328 {
329 return (writemask == 0x2); // 0x2 == 0010. (that is: y)
330 } // writemask_y
331
332 int replicate_swizzlecxx . . $ replicate_swizzle(7864480464b09eea).(const int swizzle)
333 {
334 // elements 1|2 match 3|4 and element 1 matches element 2.
335 return ( (((swizzle >> 4) & 0xF) == ((swizzle >> 0) & 0xF)) &&
336 (((swizzle >> 0) & 0x3) == ((swizzle >> 2) & 0x3)) );
337 } // replicate_swizzle
338
339 int no_swizzlecxx . . $ no_swizzle(7864480464b09eea).(const int swizzle)
340 {
341 return (swizzle == 0xE4); // 0xE4 == 11100100 ... 0 1 2 3. No swizzle.
342 } // no_swizzle
343
344 int vecsize_from_writemaskcxx . . $ vecsize_from_writemask(7864480464b09eea).(const int m)
345 {
346 return (m & 1) + ((m >> 1) & 1) + ((m >> 2) & 1) + ((m >> 3) & 1);
347 } // vecsize_from_writemask
348
349 void set_dstarg_writemaskcxx . . $ set_dstarg_writemask(3dc30233075ee5d2).(DestArgInfocxx . . $ DestArgInfo# *dst, const int mask)
350 {
351 dst->writemaskcxx . . $ $anonymous_type_32753e8ce5863620_5#writemask. = mask;
352 dst->writemask0cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask0. = ((mask >> 0) & 1);
353 dst->writemask1cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask1. = ((mask >> 1) & 1);
354 dst->writemask2cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask2. = ((mask >> 2) & 1);
355 dst->writemask3cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask3. = ((mask >> 3) & 1);
356 } // set_dstarg_writemask
357
358 // D3D stuff that's used in more than just the d3d profile...
359
360 int isscalarcxx . . $ isscalar(9d8abf502d86d4f4).(Contextcxx . . $ Context# *ctx, const MOJOSHADER_shaderTypecxx . . $ MOJOSHADER_shaderType# shader_type,
361 const RegisterTypecxx . . $ RegisterType# rtype, const int rnum)
362 {
363 const int uses_psize = ctx->uses_pointsizecxx . . $ Context#uses_pointsize.;
364 const int uses_fog = ctx->uses_fogcxx . . $ Context#uses_fog.;
365 if ( (rtype == REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.) && ((uses_psize) || (uses_fog)) )
366 {
367 const RegisterListcxx . . $ RegisterList# *reg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->attributescxx . . $ Context#attributes., rtype, rnum);
368 if (reg != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
369 {
370 const MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage = reg->usagecxx . . $ RegisterList#usage.;
371 return ( (uses_psize && (usage == MOJOSHADER_USAGE_POINTSIZEcxx . . $ MOJOSHADER_USAGE_POINTSIZE.)) ||
372 (uses_fog && (usage == MOJOSHADER_USAGE_FOGcxx . . $ MOJOSHADER_USAGE_FOG.)) );
373 } // if
374 } // if
375
376 return scalar_registercxx . . $ scalar_register(cf871eb7ac624acc).(shader_type, rtype, rnum);
377 } // isscalar
378
379 const char *get_D3D_register_stringcxx . . $ get_D3D_register_string(e11e601b5c61efa5).(Contextcxx . . $ Context# *ctx,
380 RegisterTypecxx . . $ RegisterType# regtype,
381 int regnum, char *regnum_str,
382 size_t regnum_size)
383 {
384 const char *retval = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
385 int has_number = 1;
386
387 switch (regtype)
388 {
389 case REG_TYPE_TEMPcxx . . $ REG_TYPE_TEMP.:
390 retval = "r";
391 break;
392
393 case REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.:
394 retval = "v";
395 break;
396
397 case REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST.:
398 retval = "c";
399 break;
400
401 case REG_TYPE_ADDRESScxx . . $ REG_TYPE_ADDRESS.: // (or REG_TYPE_TEXTURE, same value.)
402 retval = shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx) ? "a" : "t";
403 break;
404
405 case REG_TYPE_RASTOUTcxx . . $ REG_TYPE_RASTOUT.:
406 switch ((RastOutTypecxx . . $ RastOutType#) regnum)
407 {
408 case RASTOUT_TYPE_POSITIONcxx . . $ RASTOUT_TYPE_POSITION.: retval = "oPos"; break;
409 case RASTOUT_TYPE_FOGcxx . . $ RASTOUT_TYPE_FOG.: retval = "oFog"; break;
410 case RASTOUT_TYPE_POINT_SIZEcxx . . $ RASTOUT_TYPE_POINT_SIZE.: retval = "oPts"; break;
411 } // switch
412 has_number = 0;
413 break;
414
415 case REG_TYPE_ATTROUTcxx . . $ REG_TYPE_ATTROUT.:
416 retval = "oD";
417 break;
418
419 case REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.: // (or REG_TYPE_TEXCRDOUT, same value.)
420 if (shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx) && shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 3, 0))
421 retval = "o";
422 else
423 retval = "oT";
424 break;
425
426 case REG_TYPE_CONSTINTcxx . . $ REG_TYPE_CONSTINT.:
427 retval = "i";
428 break;
429
430 case REG_TYPE_COLOROUTcxx . . $ REG_TYPE_COLOROUT.:
431 retval = "oC";
432 break;
433
434 case REG_TYPE_DEPTHOUTcxx . . $ REG_TYPE_DEPTHOUT.:
435 retval = "oDepth";
436 has_number = 0;
437 break;
438
439 case REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER.:
440 retval = "s";
441 break;
442
443 case REG_TYPE_CONSTBOOLcxx . . $ REG_TYPE_CONSTBOOL.:
444 retval = "b";
445 break;
446
447 case REG_TYPE_LOOPcxx . . $ REG_TYPE_LOOP.:
448 retval = "aL";
449 has_number = 0;
450 break;
451
452 case REG_TYPE_MISCTYPEcxx . . $ REG_TYPE_MISCTYPE.:
453 switch ((const MiscTypeTypecxx . . $ MiscTypeType#) regnum)
454 {
455 case MISCTYPE_TYPE_POSITIONcxx . . $ MISCTYPE_TYPE_POSITION.: retval = "vPos"; break;
456 case MISCTYPE_TYPE_FACEcxx . . $ MISCTYPE_TYPE_FACE.: retval = "vFace"; break;
457 } // switch
458 has_number = 0;
459 break;
460
461 case REG_TYPE_LABELcxx . . $ REG_TYPE_LABEL.:
462 retval = "l";
463 break;
464
465 case REG_TYPE_PREDICATEcxx . . $ REG_TYPE_PREDICATE.:
466 retval = "p";
467 break;
468
469 //case REG_TYPE_TEMPFLOAT16: // !!! FIXME: don't know this asm string
470 default:
471 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown register type");
472 retval = "???";
473 has_number = 0;
474 break;
475 } // switch
476
477 if (has_number)
478 snprintfcxx . . $ snprintf(ea502d73e74c754c).(regnum_str, regnum_size, "%u", (uintcxx . . $ uint#) regnum);
479 else
480 regnum_str[0] = '\0';
481
482 return retval;
483 } // get_D3D_register_string
484
485 // !!! FIXME: These should stay in the mojoshader_profile_d3d file
486 // !!! FIXME: but ARB1 relies on them, so we have to move them here.
487 // !!! FIXME: If/when we kill off ARB1, we can move these back.
488
489 const char *get_D3D_varname_in_bufcxx . . $ get_D3D_varname_in_buf(e11e601b5c61efa5).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# rt,
490 int regnum, char *buf,
491 const size_t len)
492 {
493 char regnum_str[16];
494 const char *regtype_str = get_D3D_register_stringcxx . . $ get_D3D_register_string(e11e601b5c61efa5).(ctx, rt, regnum,
495 regnum_str, sizeof (regnum_str));
496 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf,len,"%s%s", regtype_str, regnum_str);
497 return buf;
498 } // get_D3D_varname_in_buf
499
500
501 const char *get_D3D_varnamecxx . . $ get_D3D_varname(790d45e57673741b).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# rt, int regnum)
502 {
503 char buf[64];
504 get_D3D_varname_in_bufcxx . . $ get_D3D_varname_in_buf(e11e601b5c61efa5).(ctx, rt, regnum, buf, sizeof (buf));
505 return StrDupcxx . . $ StrDup(5771b401aae6b992).(ctx, buf);
506 } // get_D3D_varname
507
508 #pragma GCC visibility pop