Debian Codegraph @

profiles/mojoshader_profile_spirv.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_spirv.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_SPIRVcxx . . $ `mojoshader_internal.h:210:9`!
16 #include "spirv/spirv.h"cxx . . $ `<file>/spirv/spirv.h`/
17 #include "spirv/GLSL.std.450.h"cxx . . $ `<file>/spirv/GLSL.std.450.h`/
18 #include <float.h>
19
20 static const int SPV_NO_SWIZZLEcxx . . $ SPV_NO_SWIZZLE. = 0xE4; // 0xE4 == 11100100 ... 0 1 2 3. No swizzle.
21
22 #define EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(op) \
23 void emit_SPIRV_##op(Context *ctx) { \
24 fail(ctx, #op " unimplemented in spirv profile"); \
25 }
26
27 typedef struct SpirvTexm3x3SetupResultcxx . . $ SpirvTexm3x3SetupResult#
28 {
29 // vec4 load results
30 uint32cxx . . $ uint32# id_dst_pad0cxx . . $ SpirvTexm3x3SetupResult#id_dst_pad0.;
31 uint32cxx . . $ uint32# id_dst_pad1cxx . . $ SpirvTexm3x3SetupResult#id_dst_pad1.;
32 uint32cxx . . $ uint32# id_dstcxx . . $ SpirvTexm3x3SetupResult#id_dst.;
33
34 // float dot results
35 uint32cxx . . $ uint32# id_res_xcxx . . $ SpirvTexm3x3SetupResult#id_res_x.;
36 uint32cxx . . $ uint32# id_res_ycxx . . $ SpirvTexm3x3SetupResult#id_res_y.;
37 uint32cxx . . $ uint32# id_res_zcxx . . $ SpirvTexm3x3SetupResult#id_res_z.;
38 } SpirvTexm3x3SetupResultcxx . . $ SpirvTexm3x3SetupResult#;
39
40 static const char *spv_get_uniform_array_varnamecxx . . $ spv_get_uniform_array_varname(c3e577f4fac3a123).(Contextcxx . . $ Context# *ctx,
41 const RegisterTypecxx . . $ RegisterType# regtype,
42 char *buf, const size_t len)
43 {
44 const char *shadertype = ctx->shader_type_strcxx . . $ Context#shader_type_str.;
45 const char *type = "";
46 switch (regtype)
47 {
48 case REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST.: type = "vec4"; break;
49 case REG_TYPE_CONSTINTcxx . . $ REG_TYPE_CONSTINT.: type = "ivec4"; break;
50 case REG_TYPE_CONSTBOOLcxx . . $ REG_TYPE_CONSTBOOL.: type = "bool"; break;
51 default: failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: used a uniform we don't know how to define.");
52 } // switch
53 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, len, "%s_uniforms_%s", shadertype, type);
54 return buf;
55 } // spv_get_uniform_array_varname
56
57 static uint32cxx . . $ uint32# spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(Contextcxx . . $ Context# *ctx)
58 {
59 return (ctx->spirvcxx . . $ Context#spirv..idmaxcxx . . $ SpirvContext#idmax. += 1);
60 } // spv_bumpid
61
62 static RegisterListcxx . . $ RegisterList# *spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(Contextcxx . . $ Context# *ctx, const RegisterTypecxx . . $ RegisterType# regtype, const int regnum)
63 {
64 RegisterListcxx . . $ RegisterList# *r = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->used_registerscxx . . $ Context#used_registers., regtype, regnum);
65 if (!r)
66 {
67 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "register not found rt=%d, rn=%d", regtype, regnum);
68 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
69 } // if
70 return r;
71 } // spv_getreg
72
73 static void spv_componentlist_freecxx . . $ spv_componentlist_free(e67ba04bcb351a03).(Contextcxx . . $ Context# *ctx, ComponentListcxx . . $ ComponentList# *cl)
74 {
75 ComponentListcxx . . $ ComponentList# *next;
76 while (cl)
77 {
78 next = cl->nextcxx . . $ ComponentList#next.;
79 Freecxx . . $ Free(b86e3b3d45e44ecf).(ctx, cl);
80 cl = next;
81 } // while
82 } // spv_componentlist_free
83
84 static ComponentListcxx . . $ ComponentList# *spv_componentlist_alloccxx . . $ spv_componentlist_alloc(64319e692197638).(Contextcxx . . $ Context# *ctx)
85 {
86 ComponentListcxx . . $ ComponentList# *ret = (ComponentListcxx . . $ ComponentList# *) Malloccxx . . $ Malloc(a6ec60c25fe5143e).(ctx, sizeof(ComponentListcxx . . $ ComponentList#));
87 if (!ret) return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
88 ret->idcxx . . $ ComponentList#id. = 0;
89 ret->vcxx . . $ ComponentList#v..icxx . . $ ComponentList#$anonymous_type_0#i. = 0;
90 ret->nextcxx . . $ ComponentList#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
91 return ret;
92 } // spv_componentlist_alloc
93
94 static const char *get_SPIRV_varname_in_bufcxx . . $ get_SPIRV_varname_in_buf(e11e601b5c61efa5).(Contextcxx . . $ Context# *ctx, const RegisterTypecxx . . $ RegisterType# rt,
95 const int regnum, char *buf,
96 const size_t buflen)
97 {
98 // turns out these are identical at the moment.
99 return get_D3D_varname_in_bufcxx . . $ get_D3D_varname_in_buf(e11e601b5c61efa5).(ctx, rt, regnum, buf, buflen);
100 } // get_SPIRV_varname_in_buf
101
102 const char *get_SPIRV_varnamecxx . . $ get_SPIRV_varname(790d45e57673741b).(Contextcxx . . $ Context# *ctx, const RegisterTypecxx . . $ RegisterType# rt,
103 const int regnum)
104 {
105 // turns out these are identical at the moment.
106 return get_D3D_varnamecxx . . $ get_D3D_varname(790d45e57673741b).(ctx, rt, regnum);
107 } // get_SPIRV_varname
108
109
110 static inline const char *get_SPIRV_const_array_varname_in_bufcxx . . $ get_SPIRV_const_array_varname_in_buf(7e1cca04738fe06f).(Contextcxx . . $ Context# *ctx,
111 const int base, const int size,
112 char *buf, const size_t buflen)
113 {
114 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, buflen, "c_array_%d_%d", base, size);
115 return buf;
116 } // get_SPIRV_const_array_varname_in_buf
117
118
119 const char *get_SPIRV_const_array_varnamecxx . . $ get_SPIRV_const_array_varname(dd436b49467e1d26).(Contextcxx . . $ Context# *ctx, int base, int size)
120 {
121 char buf[64];
122 get_SPIRV_const_array_varname_in_bufcxx . . $ get_SPIRV_const_array_varname_in_buf(7e1cca04738fe06f).(ctx, base, size, buf, sizeof (buf));
123 return StrDupcxx . . $ StrDup(5771b401aae6b992).(ctx, buf);
124 } // get_SPIRV_const_array_varname
125
126 static uint32cxx . . $ uint32# spv_get_uniform_array_idcxx . . $ spv_get_uniform_array_id(35cf31a541e25ef9).(Contextcxx . . $ Context# *ctx, const RegisterTypecxx . . $ RegisterType# regtype)
127 {
128 uint32cxx . . $ uint32# id;
129 switch (regtype)
130 {
131 case REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST.:
132 id = ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idvec4cxx . . $ SpirvContext#$anonymous_type_1#idvec4.;
133 if (id == 0)
134 {
135 id = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
136 ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idvec4cxx . . $ SpirvContext#$anonymous_type_1#idvec4. = id;
137 } // if
138 break;
139
140 case REG_TYPE_CONSTINTcxx . . $ REG_TYPE_CONSTINT.:
141 id = ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idivec4cxx . . $ SpirvContext#$anonymous_type_1#idivec4.;
142 if (id == 0)
143 {
144 id = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
145 ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idivec4cxx . . $ SpirvContext#$anonymous_type_1#idivec4. = id;
146 } // if
147 break;
148
149 case REG_TYPE_CONSTBOOLcxx . . $ REG_TYPE_CONSTBOOL.:
150 id = ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idboolcxx . . $ SpirvContext#$anonymous_type_1#idbool.;
151 if (id == 0)
152 {
153 id = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
154 ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idboolcxx . . $ SpirvContext#$anonymous_type_1#idbool. = id;
155 } // if
156 break;
157
158 default:
159 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Unexpected register type used to access uniform array.");
160 id = 0;
161 } // switch
162
163 return id;
164 } // spv_get_uniform_array_id
165
166 static void spv_emit_part_vacxx . . $ spv_emit_part_va(7a0191b0a6e9f3ef).(Contextcxx . . $ Context#* ctx, uint32cxx . . $ uint32# word_count, uint32cxx . . $ uint32# argc, SpvOpcxx . . $ SpvOp# op, va_listcxx . . $ va_list# args)
167 {
168 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->output != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
169 if (isfailcxx . . $ isfail(73332d3452342b36).(ctx))
170 return; // we failed previously, don't go on...
171
172 uint32cxx . . $ uint32# word = op | (word_count << 16);
173 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., &word, sizeof(word));
174 while (--argc)
175 {
176 word = va_argcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:53:9`!(args, uint32);
177 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., &word, sizeof(word));
178 } // while
179 } // spv_emit_part_va
180
181 static void spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(Contextcxx . . $ Context#* ctx, uint32cxx . . $ uint32# word_count, uint32cxx . . $ uint32# argc, SpvOpcxx . . $ SpvOp# op, ...)
182 {
183 va_listcxx . . $ va_list# args;
184 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, op);
185 spv_emit_part_vacxx . . $ spv_emit_part_va(7a0191b0a6e9f3ef).(ctx, word_count, argc, op, args);
186 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args);
187 } // spv_emit_part
188
189 static void spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# word_count, SpvOpcxx . . $ SpvOp# op, ...)
190 {
191 va_listcxx . . $ va_list# args;
192 va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, op);
193 spv_emit_part_vacxx . . $ spv_emit_part_va(7a0191b0a6e9f3ef).(ctx, word_count, word_count, op, args);
194 va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args);
195 } // spv_emit
196
197 static void spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# word)
198 {
199 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->output != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
200 if (isfailcxx . . $ isfail(73332d3452342b36).(ctx))
201 return; // we failed previously, don't go on...
202
203 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., &word, sizeof(word));
204 } // spv_emit_word
205
206 static void spv_emit_strcxx . . $ spv_emit_str(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *str)
207 {
208 size_t len;
209 uint32cxx . . $ uint32# trail;
210 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->output != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
211 if (isfailcxx . . $ isfail(73332d3452342b36).(ctx))
212 return; // we failed previously, don't go on...
213
214 if (str == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
215 return spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 0);
216 len = strlencxx . . $ strlen(751346f8406fd082).(str) + 1;
217 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., str, len);
218 len = len % 4;
219 if (len)
220 {
221 trail = 0;
222 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., &trail, 4 - len);
223 } // if
224 } // spv_emit_str
225
226 // get the word count of a string
227 static uint32cxx . . $ uint32# spv_strlencxx . . $ spv_strlen(c61c63047ce273de).(const char *str)
228 {
229 size_t len = strlencxx . . $ strlen(751346f8406fd082).(str);
230 return (uint32cxx . . $ uint32#) ((len / 4) + 1);
231 } // spv_strlen
232
233 // emits an OpName straight into ctx->globals
234 static void spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id, const char *str)
235 {
236 if (isfailcxx . . $ isfail(73332d3452342b36).(ctx))
237 return; // we failed previously, don't go on...
238
239 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->globalscxx . . $ Context#globals.);
240 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 2 + spv_strlencxx . . $ spv_strlen(c61c63047ce273de).(str), 2, SpvOpNamecxx . . $ SpvOpName., id);
241 spv_emit_strcxx . . $ spv_emit_str(72ff1ec6cf40f147).(ctx, str);
242 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
243 } // spv_output_name
244
245 // emit an OpName instruction to identify a register
246 static void spv_output_regnamecxx . . $ spv_output_regname(ae7757ab60d819c8).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id, RegisterTypecxx . . $ RegisterType# regtype, int regnum)
247 {
248 char varname[64];
249 snprintfcxx . . $ snprintf(ea502d73e74c754c).(varname, sizeof(varname), "%s_", ctx->shader_type_strcxx . . $ Context#shader_type_str.);
250 size_t offset = strlencxx . . $ strlen(751346f8406fd082).(varname);
251 get_SPIRV_varname_in_bufcxx . . $ get_SPIRV_varname_in_buf(e11e601b5c61efa5).(ctx, regtype, regnum, varname + offset, sizeof(varname) - offset);
252 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, id, varname);
253 } // spv_output_regname
254
255 // emits an OpDecorate BuiltIn straight into ctx->helpers
256 static void spv_output_builtincxx . . $ spv_output_builtin(f45776df1a665a6e).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id, SpvBuiltIncxx . . $ SpvBuiltIn# builtin)
257 {
258 if (isfailcxx . . $ isfail(73332d3452342b36).(ctx))
259 return; // we failed previously, don't go on...
260
261 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->helperscxx . . $ Context#helpers.);
262 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpDecoratecxx . . $ SpvOpDecorate., id, SpvDecorationBuiltIncxx . . $ SpvDecorationBuiltIn., builtin);
263 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
264 } // spv_output_builtin
265
266 static uint32cxx . . $ uint32# spv_output_locationcxx . . $ spv_output_location(a939eba8b1993c99).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id, uint32cxx . . $ uint32# loc)
267 {
268 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->helperscxx . . $ Context#helpers.);
269 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpDecoratecxx . . $ SpvOpDecorate., id, SpvDecorationLocationcxx . . $ SpvDecorationLocation., loc);
270 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
271 return (buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->helperscxx . . $ Context#helpers.) >> 2) - 1;
272 } // spv_output_location
273
274 static void spv_output_color_locationcxx . . $ spv_output_color_location(faac5a9eeb4c548).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id, uint32cxx . . $ uint32# index)
275 {
276 SpirvPatchTablecxx . . $ SpirvPatchTable#* table = &ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table.;
277 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->helperscxx . . $ Context#helpers.);
278 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpDecoratecxx . . $ SpvOpDecorate., id, SpvDecorationLocationcxx . . $ SpvDecorationLocation., index);
279 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
280 table->output_offsetscxx . . $ SpirvPatchTable#output_offsets.[index] = (buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->helperscxx . . $ Context#helpers.) >> 2) - 1;
281 } // spv_output_color_location
282
283 static void spv_output_attrib_locationcxx . . $ spv_output_attrib_location(2c6464f593a9ec59).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id,
284 MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, uint32cxx . . $ uint32# index)
285 {
286 SpirvPatchTablecxx . . $ SpirvPatchTable#* table = &ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table.;
287 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->helperscxx . . $ Context#helpers.);
288 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpDecoratecxx . . $ SpvOpDecorate., id, SpvDecorationLocationcxx . . $ SpvDecorationLocation., 0xDEADBEEF);
289 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
290 table->attrib_offsetscxx . . $ SpirvPatchTable#attrib_offsets.[usage][index] = (buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->helperscxx . . $ Context#helpers.) >> 2) - 1;
291 } // spv_output_attrib_location
292
293 static void spv_output_sampler_bindingcxx . . $ spv_output_sampler_binding(faac5a9eeb4c548).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id, uint32cxx . . $ uint32# binding)
294 {
295 if (isfailcxx . . $ isfail(73332d3452342b36).(ctx))
296 return;
297
298 uint32cxx . . $ uint32# set = 0;
299 if (ctx->spirvcxx . . $ Context#spirv..modecxx . . $ SpirvContext#mode. == SPIRV_MODE_VKcxx . . $ SPIRV_MODE_VK.)
300 {
301 set = shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx) ? MOJOSHADER_SPIRV_VS_SAMPLER_SETcxx . . $ `profiles/mojoshader_profile_spirv.h:15:9`!
302 : MOJOSHADER_SPIRV_PS_SAMPLER_SETcxx . . $ `profiles/mojoshader_profile_spirv.h:17:9`!;
303 } // if
304
305 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->helperscxx . . $ Context#helpers.);
306 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpDecoratecxx . . $ SpvOpDecorate., id, SpvDecorationDescriptorSetcxx . . $ SpvDecorationDescriptorSet., set);
307 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpDecoratecxx . . $ SpvOpDecorate., id, SpvDecorationBindingcxx . . $ SpvDecorationBinding., binding);
308 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
309 } // spv_output_sampler_binding
310
311 static SpirvTypeIdxcxx . . $ SpirvTypeIdx# spv_change_base_type_vec_dimcxx . . $ spv_change_base_type_vec_dim(e0ad52047bd92d8).(SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti, uint32cxx . . $ uint32# dim)
312 {
313 uint32cxx . . $ uint32# dimSub1 = dim - 1;
314 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(STI_CORE_START_ <= sti && sti < STI_CORE_END_);
315 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(dimSub1 < 4);
316
317 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_base = (SpirvTypeIdxcxx . . $ SpirvTypeIdx#)(sti & ~0x3);
318 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_new = (SpirvTypeIdxcxx . . $ SpirvTypeIdx#)(sti_base | dimSub1);
319 return sti_new;
320 } // spv_change_base_type_vec_dim
321
322 static uint32cxx . . $ uint32# spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(Contextcxx . . $ Context# *ctx, SpirvTypeIdxcxx . . $ SpirvTypeIdx# tidx)
323 {
324 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(((uint32)tidx) < ((uint32)STI_LENGTH_));
325
326 uint32cxx . . $ uint32# tid = ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[tidx];
327 if (tid)
328 return tid;
329
330 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
331 if (STI_CORE_START_cxx . . $ STI_CORE_START_. <= tidx && tidx < STI_CORE_END_cxx . . $ STI_CORE_END_.)
332 {
333 uint32cxx . . $ uint32# dim = tidx & 0x3;
334 SpirvTypecxx . . $ SpirvType# type = (SpirvTypecxx . . $ SpirvType#)((tidx >> 2) & 0x3);
335 if (dim)
336 {
337 uint32cxx . . $ uint32# tid_base = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, (SpirvTypeIdxcxx . . $ SpirvTypeIdx#)(tidx - dim));
338 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
339 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypeVectorcxx . . $ SpvOpTypeVector., tid, tid_base, dim + 1);
340 } // if
341 else
342 {
343 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
344 switch (type)
345 {
346 case ST_FLOATcxx . . $ ST_FLOAT.: spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpTypeFloatcxx . . $ SpvOpTypeFloat., tid, 32); break;
347 case ST_SINTcxx . . $ ST_SINT.: spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypeIntcxx . . $ SpvOpTypeInt., tid, 32, 1); break;
348 case ST_UINTcxx . . $ ST_UINT.: spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypeIntcxx . . $ SpvOpTypeInt., tid, 32, 0); break;
349 case ST_BOOLcxx . . $ ST_BOOL.: spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpTypeBoolcxx . . $ SpvOpTypeBool., tid); break;
350 default: assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!"Unexpected value of SpirvType."); break;
351 } // switch
352 } // else
353 } // if
354 else if (STI_IMAGE2Dcxx . . $ STI_IMAGE2D. <= tidx && tidx <= STI_IMAGECUBEcxx . . $ STI_IMAGECUBE.)
355 {
356 static const SpvDimcxx . . $ SpvDim# dim_table[] = {SpvDim2Dcxx . . $ SpvDim2D., SpvDim3Dcxx . . $ SpvDim3D., SpvDimCubecxx . . $ SpvDimCube.};
357 SpvDimcxx . . $ SpvDim# dim = dim_table[tidx - STI_IMAGE2Dcxx . . $ STI_IMAGE2D.];
358 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
359 uint32cxx . . $ uint32# id_image = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
360 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
361 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 9, SpvOpTypeImagecxx . . $ SpvOpTypeImage., id_image, tid_float, dim, 0, 0, 0, 1, SpvImageFormatUnknowncxx . . $ SpvImageFormatUnknown.);
362 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpTypeSampledImagecxx . . $ SpvOpTypeSampledImage., tid, id_image);
363 } // else if
364 else if (tidx == STI_VOIDcxx . . $ STI_VOID.)
365 {
366 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
367 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpTypeVoidcxx . . $ SpvOpTypeVoid., tid);
368 } // else if
369 else if (tidx == STI_FUNC_VOIDcxx . . $ STI_FUNC_VOID.)
370 {
371 uint32cxx . . $ uint32# tid_void = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VOIDcxx . . $ STI_VOID.);
372 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
373 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpTypeFunctioncxx . . $ SpvOpTypeFunction., tid, tid_void);
374 } // else if
375 else if (tidx == STI_FUNC_LITcxx . . $ STI_FUNC_LIT.)
376 {
377 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
378 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
379 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 1, SpvOpTypeFunctioncxx . . $ SpvOpTypeFunction., tid, tid_vec4, tid_vec4);
380 } // else if
381 else if (STI_PTR_START_cxx . . $ STI_PTR_START_. <= tidx && tidx < STI_PTR_END_cxx . . $ STI_PTR_END_.)
382 {
383 uint32cxx . . $ uint32# dim = (tidx & (1 << 4)) ? 3 : 0;
384 SpirvTypecxx . . $ SpirvType# type = (SpirvTypecxx . . $ SpirvType#)((tidx >> 2) & 0x3);
385 uint32cxx . . $ uint32# tid_base = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, (SpirvTypeIdxcxx . . $ SpirvTypeIdx#)((1 << 4) | (type << 2) | dim));
386 static const SpvStorageClasscxx . . $ SpvStorageClass# sc_map[] = {
387 SpvStorageClassInputcxx . . $ SpvStorageClassInput.,
388 SpvStorageClassInputcxx . . $ SpvStorageClassInput.,
389 SpvStorageClassOutputcxx . . $ SpvStorageClassOutput.,
390 SpvStorageClassOutputcxx . . $ SpvStorageClassOutput.,
391 SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate.,
392 SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate.,
393 SpvStorageClassUniformConstantcxx . . $ SpvStorageClassUniformConstant.,
394 SpvStorageClassUniformcxx . . $ SpvStorageClassUniform.,
395 };
396 SpvStorageClasscxx . . $ SpvStorageClass# sc = sc_map[((tidx & 0x3) << 1) | (ctx->spirvcxx . . $ Context#spirv..modecxx . . $ SpirvContext#mode. == SPIRV_MODE_VKcxx . . $ SPIRV_MODE_VK.)];
397 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
398 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypePointercxx . . $ SpvOpTypePointer., tid, sc, tid_base);
399 } // else if
400 else if (STI_PTR_IMAGE2Dcxx . . $ STI_PTR_IMAGE2D. <= tidx && tidx <= STI_PTR_IMAGECUBEcxx . . $ STI_PTR_IMAGECUBE.)
401 {
402 uint32cxx . . $ uint32# tid_image = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, (SpirvTypeIdxcxx . . $ SpirvTypeIdx#)(tidx - (STI_PTR_IMAGE2Dcxx . . $ STI_PTR_IMAGE2D. - STI_IMAGE2Dcxx . . $ STI_IMAGE2D.)));
403 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
404 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypePointercxx . . $ SpvOpTypePointer., tid, SpvStorageClassUniformConstantcxx . . $ SpvStorageClassUniformConstant., tid_image);
405 } // else if
406 else if (tidx == STI_PTR_VEC2_Icxx . . $ STI_PTR_VEC2_I.)
407 {
408 uint32cxx . . $ uint32# tid_base = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC2cxx . . $ STI_VEC2.);
409 tid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
410 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypePointercxx . . $ SpvOpTypePointer., tid, SpvStorageClassInputcxx . . $ SpvStorageClassInput., tid_base);
411 } // else if
412 else
413 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!"Unexpected value of type index.");
414 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
415
416 ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[tidx] = tid;
417 return tid;
418 } // spv_get_type
419
420 static uint32cxx . . $ uint32# spv_gettruecxx . . $ spv_gettrue(6d86621a4076bebf).(Contextcxx . . $ Context# *ctx)
421 {
422 if (ctx->spirvcxx . . $ Context#spirv..idtruecxx . . $ SpirvContext#idtrue.)
423 return ctx->spirvcxx . . $ Context#spirv..idtruecxx . . $ SpirvContext#idtrue.;
424
425 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
426 uint32cxx . . $ uint32# id = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
427
428 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
429 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpConstantTruecxx . . $ SpvOpConstantTrue., tid_bool, id);
430 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
431 return ctx->spirvcxx . . $ Context#spirv..idtruecxx . . $ SpirvContext#idtrue. = id;
432 } // spv_gettrue
433
434 static uint32cxx . . $ uint32# spv_getfalsecxx . . $ spv_getfalse(6d86621a4076bebf).(Contextcxx . . $ Context# *ctx)
435 {
436 if (ctx->spirvcxx . . $ Context#spirv..idfalsecxx . . $ SpirvContext#idfalse.)
437 return ctx->spirvcxx . . $ Context#spirv..idfalsecxx . . $ SpirvContext#idfalse.;
438
439 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
440 uint32cxx . . $ uint32# id = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
441
442 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
443 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpConstantFalsecxx . . $ SpvOpConstantFalse., tid_bool, id);
444 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
445 return ctx->spirvcxx . . $ Context#spirv..idfalsecxx . . $ SpirvContext#idfalse. = id;
446 } // spv_getfalse
447
448 static uint32cxx . . $ uint32# spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(Contextcxx . . $ Context# *ctx)
449 {
450 if (ctx->spirvcxx . . $ Context#spirv..idextcxx . . $ SpirvContext#idext.)
451 return ctx->spirvcxx . . $ Context#spirv..idextcxx . . $ SpirvContext#idext.;
452
453 return ctx->spirvcxx . . $ Context#spirv..idextcxx . . $ SpirvContext#idext. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
454 } // spv_getext
455
456 static uint32cxx . . $ uint32# spv_output_scalarcxx . . $ spv_output_scalar(97815ea68cdfd88e).(Contextcxx . . $ Context# *ctx, ComponentListcxx . . $ ComponentList# *cl,
457 MOJOSHADER_attributeTypecxx . . $ MOJOSHADER_attributeType# type)
458 {
459 uint32cxx . . $ uint32# idret, idtype;
460 if (type == MOJOSHADER_ATTRIBUTE_FLOATcxx . . $ MOJOSHADER_ATTRIBUTE_FLOAT.)
461 idtype = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
462 else if (type == MOJOSHADER_ATTRIBUTE_INTcxx . . $ MOJOSHADER_ATTRIBUTE_INT.)
463 idtype = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
464 else if (type == MOJOSHADER_ATTRIBUTE_UINTcxx . . $ MOJOSHADER_ATTRIBUTE_UINT.)
465 idtype = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_UINTcxx . . $ STI_UINT.);
466 else
467 {
468 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "spv_output_scalar: invalid attribute type %d", type);
469 return 0;
470 } // else
471 idret = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
472
473 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
474 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConstantcxx . . $ SpvOpConstant., idtype, idret, cl->vcxx . . $ ComponentList#v..ucxx . . $ ComponentList#$anonymous_type_0#u.);
475 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
476 return idret;
477 } // spv_output_scalar
478
479 // The spv_getscalar* functions retrieve the result id of an OpConstant
480 // instruction with the corresponding value v, or generate a new one.
481 static uint32cxx . . $ uint32# spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(Contextcxx . . $ Context# *ctx, float v)
482 {
483 ComponentListcxx . . $ ComponentList# *prev = &(ctx->spirvcxx . . $ Context#spirv..clcxx . . $ SpirvContext#cl..fcxx . . $ SpirvContext#$anonymous_type_3#f.), *cl = ctx->spirvcxx . . $ Context#spirv..clcxx . . $ SpirvContext#cl..fcxx . . $ SpirvContext#$anonymous_type_3#f..nextcxx . . $ ComponentList#next.;
484 while (cl)
485 {
486 if (v == cl->vcxx . . $ ComponentList#v..fcxx . . $ ComponentList#$anonymous_type_0#f.)
487 return cl->idcxx . . $ ComponentList#id.;
488 else if (v < cl->vcxx . . $ ComponentList#v..fcxx . . $ ComponentList#$anonymous_type_0#f.)
489 break;
490 prev = cl;
491 cl = cl->nextcxx . . $ ComponentList#next.;
492 } // while
493 cl = spv_componentlist_alloccxx . . $ spv_componentlist_alloc(64319e692197638).(ctx);
494 cl->nextcxx . . $ ComponentList#next. = prev->nextcxx . . $ ComponentList#next.;
495 prev->nextcxx . . $ ComponentList#next. = cl;
496 cl->vcxx . . $ ComponentList#v..fcxx . . $ ComponentList#$anonymous_type_0#f. = v;
497 cl->idcxx . . $ ComponentList#id. = spv_output_scalarcxx . . $ spv_output_scalar(97815ea68cdfd88e).(ctx, cl, MOJOSHADER_ATTRIBUTE_FLOATcxx . . $ MOJOSHADER_ATTRIBUTE_FLOAT.);
498 return cl->idcxx . . $ ComponentList#id.;
499 } // spv_getscalarf
500
501 static uint32cxx . . $ uint32# spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(Contextcxx . . $ Context# *ctx, int v)
502 {
503 ComponentListcxx . . $ ComponentList# *prev = &(ctx->spirvcxx . . $ Context#spirv..clcxx . . $ SpirvContext#cl..icxx . . $ SpirvContext#$anonymous_type_3#i.), *cl = ctx->spirvcxx . . $ Context#spirv..clcxx . . $ SpirvContext#cl..icxx . . $ SpirvContext#$anonymous_type_3#i..nextcxx . . $ ComponentList#next.;
504 while (cl)
505 {
506 if (v == cl->vcxx . . $ ComponentList#v..icxx . . $ ComponentList#$anonymous_type_0#i.)
507 return cl->idcxx . . $ ComponentList#id.;
508 else if (v < cl->vcxx . . $ ComponentList#v..icxx . . $ ComponentList#$anonymous_type_0#i.)
509 break;
510 prev = cl;
511 cl = cl->nextcxx . . $ ComponentList#next.;
512 } // while
513 cl = spv_componentlist_alloccxx . . $ spv_componentlist_alloc(64319e692197638).(ctx);
514 cl->nextcxx . . $ ComponentList#next. = prev->nextcxx . . $ ComponentList#next.;
515 prev->nextcxx . . $ ComponentList#next. = cl;
516 cl->vcxx . . $ ComponentList#v..icxx . . $ ComponentList#$anonymous_type_0#i. = v;
517 cl->idcxx . . $ ComponentList#id. = spv_output_scalarcxx . . $ spv_output_scalar(97815ea68cdfd88e).(ctx, cl, MOJOSHADER_ATTRIBUTE_INTcxx . . $ MOJOSHADER_ATTRIBUTE_INT.);
518 return cl->idcxx . . $ ComponentList#id.;
519 } // spv_getscalari
520
521 static uint32cxx . . $ uint32# spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# tid, uint32cxx . . $ uint32#* cache, float scalar)
522 {
523 uint32cxx . . $ uint32# i;
524
525 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(tid != 0);
526 uint32cxx . . $ uint32# dim =
527 (tid == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC4cxx . . $ STI_VEC4.]) ? 4 :
528 (tid == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC3cxx . . $ STI_VEC3.]) ? 3 :
529 (tid == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC2cxx . . $ STI_VEC2.]) ? 2 : 1;
530
531 uint32cxx . . $ uint32# id = cache[dim - 1];
532 if (id)
533 return id;
534
535 uint32cxx . . $ uint32# sid = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, scalar);
536 if (dim == 1)
537 {
538 cache[0] = sid;
539 return sid;
540 } // if
541
542 id = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
543 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
544 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 3 + dim, 3, SpvOpConstantCompositecxx . . $ SpvOpConstantComposite., tid, id);
545 for (i = 0; i < dim; i++)
546 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, sid);
547 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
548 cache[dim - 1] = id;
549 return id;
550 } // spv_get_constant_composite
551
552 static uint32cxx . . $ uint32# spv_get_zerocxx . . $ spv_get_zero(1e2deca95f3d56bd).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# tid)
553 {
554 return spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, tid, ctx->spirvcxx . . $ Context#spirv..id_0_0cxx . . $ SpirvContext#id_0_0., 0.0f);
555 } // spv_get_zero
556
557 static uint32cxx . . $ uint32# spv_get_onecxx . . $ spv_get_one(1e2deca95f3d56bd).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# tid)
558 {
559 return spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, tid, ctx->spirvcxx . . $ Context#spirv..id_1_0cxx . . $ SpirvContext#id_1_0., 1.0f);
560 } // spv_get_one
561
562 static uint32cxx . . $ uint32# spv_get_flt_maxcxx . . $ spv_get_flt_max(1e2deca95f3d56bd).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# tid)
563 {
564 return spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, tid, ctx->spirvcxx . . $ Context#spirv..id_flt_maxcxx . . $ SpirvContext#id_flt_max., FLT_MAXcxx . . $ `<external>/18143172452841944454/float.h:104:9`!);
565 } // spv_get_one
566
567 static uint32cxx . . $ uint32# spv_getvec4_zerocxx . . $ spv_getvec4_zero(6d86621a4076bebf).(Contextcxx . . $ Context# *ctx)
568 {
569 return spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.), ctx->spirvcxx . . $ Context#spirv..id_0_0cxx . . $ SpirvContext#id_0_0., 0.0f);
570 } // spv_getvec4_zero
571
572 static uint32cxx . . $ uint32# spv_getvec4_onecxx . . $ spv_getvec4_one(6d86621a4076bebf).(Contextcxx . . $ Context# *ctx)
573 {
574 return spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.), ctx->spirvcxx . . $ Context#spirv..id_1_0cxx . . $ SpirvContext#id_1_0., 1.0f);
575 } // spv_getvec4_one
576
577 // Make a 4-channel vector with a value broadcast across all channels. Roughly equivalent to `vec4(value)` in GLSL
578 static uint32cxx . . $ uint32# spv_vectorbroadcastcxx . . $ spv_vectorbroadcast(a939eba8b1993c99).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# tid, uint32cxx . . $ uint32# value)
579 {
580 uint32cxx . . $ uint32# result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
581 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
582 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid, result, value, value, value, value);
583 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
584 return result;
585 } // spv_vectorbroadcast
586
587 static void spv_branch_pushcxx . . $ spv_branch_push(faac5a9eeb4c548).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id_merge, uint32cxx . . $ uint32# patch_offset)
588 {
589 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(((size_t)ctx->branch_labels_stack_index) < STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->branch_labels_stack));
590 int pos = ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.++;
591 ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[pos] = id_merge;
592 ctx->branch_labels_patch_stackcxx . . $ Context#branch_labels_patch_stack.[pos] = patch_offset;
593 } // spv_branch_push
594
595 static void spv_branch_getcxx . . $ spv_branch_get(9fc2ff0b2fdf2d33).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32#* out_id_merge, uint32cxx . . $ uint32#* out_patch_offset)
596 {
597 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->branch_labels_stack_index > 0);
598 int pos = ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index. - 1;
599 *out_id_merge = ctx->branch_labels_stackcxx . . $ Context#branch_labels_stack.[pos];
600 *out_patch_offset = ctx->branch_labels_patch_stackcxx . . $ Context#branch_labels_patch_stack.[pos];
601 } // spv_branch_get
602
603 static void spv_branch_popcxx . . $ spv_branch_pop(9fc2ff0b2fdf2d33).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32#* out_id_merge, uint32cxx . . $ uint32#* out_patch_offset)
604 {
605 spv_branch_getcxx . . $ spv_branch_get(9fc2ff0b2fdf2d33).(ctx, out_id_merge, out_patch_offset);
606 ctx->branch_labels_stack_indexcxx . . $ Context#branch_labels_stack_index.--;
607 } // spv_branch_pop
608
609 static void spv_loop_pushcxx . . $ spv_loop_push(74c03ff29b28db54).(Contextcxx . . $ Context# *ctx, const SpirvLoopInfocxx . . $ SpirvLoopInfo# *loop)
610 {
611 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(((size_t)ctx->spirv.loop_stack_idx) < STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->spirv.loop_stack));
612 int pos = ctx->spirvcxx . . $ Context#spirv..loop_stack_idxcxx . . $ SpirvContext#loop_stack_idx.++;
613 ctx->spirvcxx . . $ Context#spirv..loop_stackcxx . . $ SpirvContext#loop_stack.[pos] = *loop;
614 } // spv_loop_push
615
616 static void spv_loop_getcxx . . $ spv_loop_get(cc007d5229ba26e6).(Contextcxx . . $ Context# *ctx, SpirvLoopInfocxx . . $ SpirvLoopInfo# *loop)
617 {
618 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->spirv.loop_stack_idx > 0);
619 int pos = ctx->spirvcxx . . $ Context#spirv..loop_stack_idxcxx . . $ SpirvContext#loop_stack_idx. - 1;
620 *loop = ctx->spirvcxx . . $ Context#spirv..loop_stackcxx . . $ SpirvContext#loop_stack.[pos];
621 } // spv_loop_get
622
623 static void spv_loop_popcxx . . $ spv_loop_pop(cc007d5229ba26e6).(Contextcxx . . $ Context# *ctx, SpirvLoopInfocxx . . $ SpirvLoopInfo# *loop)
624 {
625 spv_loop_getcxx . . $ spv_loop_get(cc007d5229ba26e6).(ctx, loop);
626 ctx->spirvcxx . . $ Context#spirv..loop_stack_idxcxx . . $ SpirvContext#loop_stack_idx.--;
627 } // spv_loop_pop
628
629 static uint32cxx . . $ uint32# spv_loop_get_aLcxx . . $ spv_loop_get_aL(6d86621a4076bebf).(Contextcxx . . $ Context# *ctx)
630 {
631 int i;
632
633 // Find the first enclosing loop..endloop. There may be rep..endrep nested inside, so it might
634 // not be at the top of the stack.
635 for (i = ctx->spirvcxx . . $ Context#spirv..loop_stack_idxcxx . . $ SpirvContext#loop_stack_idx. - 1; i >= 0; i--)
636 {
637 uint32cxx . . $ uint32# id_aL = ctx->spirvcxx . . $ Context#spirv..loop_stackcxx . . $ SpirvContext#loop_stack.[i].id_aLcxx . . $ SpirvLoopInfo#id_aL.;
638 if (id_aL)
639 return id_aL;
640 } // for
641
642 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!"Referencing loop counter register aL in code not part of loop..endloop region.");
643 return 0;
644 } // spv_loop_get_aL
645
646 static SpvOpcxx . . $ SpvOp# spv_get_comparisoncxx . . $ spv_get_comparison(707404df50257c9c).(Contextcxx . . $ Context# *ctx)
647 {
648 static const SpvOpcxx . . $ SpvOp# spv_cmp_ops[] = {
649 SpvOpUndefcxx . . $ SpvOpUndef.,
650 SpvOpFOrdGreaterThancxx . . $ SpvOpFOrdGreaterThan.,
651 SpvOpFOrdEqualcxx . . $ SpvOpFOrdEqual.,
652 SpvOpFOrdGreaterThanEqualcxx . . $ SpvOpFOrdGreaterThanEqual.,
653 SpvOpFOrdLessThancxx . . $ SpvOpFOrdLessThan.,
654 SpvOpFOrdNotEqualcxx . . $ SpvOpFOrdNotEqual.,
655 SpvOpFOrdLessThanEqualcxx . . $ SpvOpFOrdLessThanEqual.,
656 };
657
658 if (ctx->instruction_controlscxx . . $ Context#instruction_controls. >= STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(spv_cmp_ops))
659 {
660 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown comparison control");
661 return SpvOpUndefcxx . . $ SpvOpUndef.;
662 } // if
663
664 return spv_cmp_ops[ctx->instruction_controlscxx . . $ Context#instruction_controls.];
665 } // spv_get_comparison
666
667 static void spv_check_read_reg_idcxx . . $ spv_check_read_reg_id(5816d8773d24d3ec).(Contextcxx . . $ Context# *ctx, RegisterListcxx . . $ RegisterList# *r)
668 {
669 if (r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. == 0)
670 {
671 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(r->regtype != REG_TYPE_SAMPLER || (shader_is_pixel(ctx) && !shader_version_atleast(ctx, 1, 4)));
672 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(r->regtype != REG_TYPE_TEXTURE || (shader_is_pixel(ctx) && !shader_version_atleast(ctx, 1, 4)));
673 switch (r->regtypecxx . . $ RegisterList#regtype.)
674 {
675 case REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER.: // s# (only ps_1_1)
676 case REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE.: // t# (only ps_1_1)
677 case REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.: // v#
678 case REG_TYPE_TEMPcxx . . $ REG_TYPE_TEMP.: // r#
679 case REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST.: // c#
680 case REG_TYPE_CONSTINTcxx . . $ REG_TYPE_CONSTINT.: // i#
681 case REG_TYPE_CONSTBOOLcxx . . $ REG_TYPE_CONSTBOOL.: // b#
682 case REG_TYPE_LABELcxx . . $ REG_TYPE_LABEL.: // l#
683 case REG_TYPE_PREDICATEcxx . . $ REG_TYPE_PREDICATE.: // p0
684 r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
685 break;
686
687 case REG_TYPE_LOOPcxx . . $ REG_TYPE_LOOP.: // aL
688 r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = spv_loop_get_aLcxx . . $ spv_loop_get_aL(6d86621a4076bebf).(ctx);
689 break;
690
691 default:
692 {
693 char varname[64];
694 get_SPIRV_varname_in_bufcxx . . $ get_SPIRV_varname_in_buf(e11e601b5c61efa5).(ctx, r->regtypecxx . . $ RegisterList#regtype., r->regnumcxx . . $ RegisterList#regnum., varname, sizeof(varname));
695 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "register type %s is unimplemented\n", varname);
696 break;
697 } // default
698 } // switch
699 } // if
700 } // spv_check_read_reg_id
701
702 static void spv_check_write_reg_idcxx . . $ spv_check_write_reg_id(5816d8773d24d3ec).(Contextcxx . . $ Context# *ctx, RegisterListcxx . . $ RegisterList# *r)
703 {
704 if (r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. == 0)
705 {
706 switch (r->regtypecxx . . $ RegisterList#regtype.)
707 {
708 // These registers require no declarations, so we can just create them as we see them
709 case REG_TYPE_ADDRESScxx . . $ REG_TYPE_ADDRESS.:
710 case REG_TYPE_TEMPcxx . . $ REG_TYPE_TEMP.:
711 case REG_TYPE_RASTOUTcxx . . $ REG_TYPE_RASTOUT.:
712 case REG_TYPE_COLOROUTcxx . . $ REG_TYPE_COLOROUT.:
713 case REG_TYPE_TEXCRDOUTcxx . . $ REG_TYPE_TEXCRDOUT.:
714 case REG_TYPE_DEPTHOUTcxx . . $ REG_TYPE_DEPTHOUT.:
715 case REG_TYPE_ATTROUTcxx . . $ REG_TYPE_ATTROUT.:
716 case REG_TYPE_PREDICATEcxx . . $ REG_TYPE_PREDICATE.:
717 r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
718 break;
719
720 // Other register types should be explicitly declared, so it is an error for them to have iddecl == 0 by now
721 default:
722 {
723 char varname[64];
724 get_SPIRV_varname_in_bufcxx . . $ get_SPIRV_varname_in_buf(e11e601b5c61efa5).(ctx, r->regtypecxx . . $ RegisterList#regtype., r->regnumcxx . . $ RegisterList#regnum., varname, sizeof(varname));
725 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "tried to write to undeclared register %s\n", varname);
726 break;
727 } // default
728 } // switch
729 } // if
730 } // spv_check_write_reg_id
731
732 static uint32cxx . . $ uint32# spv_ptrimage_from_texturetypecxx . . $ spv_ptrimage_from_texturetype(ee3c21e30514eb7d).(Contextcxx . . $ Context# *ctx, TextureTypecxx . . $ TextureType# ttype)
733 {
734 switch (ttype)
735 {
736 case TEXTURE_TYPE_2Dcxx . . $ TEXTURE_TYPE_2D.:
737 return spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_IMAGE2Dcxx . . $ STI_PTR_IMAGE2D.);
738 case TEXTURE_TYPE_CUBEcxx . . $ TEXTURE_TYPE_CUBE.:
739 return spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_IMAGECUBEcxx . . $ STI_PTR_IMAGECUBE.);
740 case TEXTURE_TYPE_VOLUMEcxx . . $ TEXTURE_TYPE_VOLUME.:
741 return spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_IMAGE3Dcxx . . $ STI_PTR_IMAGE3D.);
742 default:
743 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: used a sampler we don't know how to define.");
744 return 0;
745 } // switch
746 } // spv_ptrimage_from_texturetype
747
748 static uint32cxx . . $ uint32# spv_image_from_texturetypecxx . . $ spv_image_from_texturetype(ee3c21e30514eb7d).(Contextcxx . . $ Context# *ctx, TextureTypecxx . . $ TextureType# ttype)
749 {
750 switch (ttype)
751 {
752 case TEXTURE_TYPE_2Dcxx . . $ TEXTURE_TYPE_2D.:
753 return spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IMAGE2Dcxx . . $ STI_IMAGE2D.);
754 case TEXTURE_TYPE_CUBEcxx . . $ TEXTURE_TYPE_CUBE.:
755 return spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IMAGECUBEcxx . . $ STI_IMAGECUBE.);
756 case TEXTURE_TYPE_VOLUMEcxx . . $ TEXTURE_TYPE_VOLUME.:
757 return spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IMAGE3Dcxx . . $ STI_IMAGE3D.);
758 default:
759 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: used a sampler we don't know how to define.");
760 return 0;
761 } // switch
762 } // spv_ptrimage_from_texturetype
763
764 static uint32cxx . . $ uint32# spv_access_uniformcxx . . $ spv_access_uniform(353dd63a86b7a3c5).(Contextcxx . . $ Context# *ctx, SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_ptr, RegisterTypecxx . . $ RegisterType# regtype, uint32cxx . . $ uint32# id_offset)
765 {
766 uint32cxx . . $ uint32# tid_ptr = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, sti_ptr);
767 uint32cxx . . $ uint32# id_arr = spv_get_uniform_array_idcxx . . $ spv_get_uniform_array_id(35cf31a541e25ef9).(ctx, regtype);
768 uint32cxx . . $ uint32# id_access = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
769 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
770 if (ctx->spirvcxx . . $ Context#spirv..modecxx . . $ SpirvContext#mode. == SPIRV_MODE_VKcxx . . $ SPIRV_MODE_VK.)
771 {
772 uint32cxx . . $ uint32# id_uniform_block = ctx->spirvcxx . . $ Context#spirv..id_uniform_blockcxx . . $ SpirvContext#id_uniform_block.;
773 if (id_uniform_block == 0)
774 {
775 id_uniform_block = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
776 ctx->spirvcxx . . $ Context#spirv..id_uniform_blockcxx . . $ SpirvContext#id_uniform_block. = id_uniform_block;
777 } // if
778 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4+2, SpvOpAccessChaincxx . . $ SpvOpAccessChain., tid_ptr, id_access, id_uniform_block, id_arr, id_offset);
779 } // if
780 else
781 {
782 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4+1, SpvOpAccessChaincxx . . $ SpvOpAccessChain., tid_ptr, id_access, id_arr, id_offset);
783 } // else
784 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
785 return id_access;
786 } // spv_access_uniform
787
788 static void spv_add_attrib_fixupcxx . . $ spv_add_attrib_fixup(fee7688a8e643203).(Contextcxx . . $ Context# *ctx, RegisterListcxx . . $ RegisterList# *r, unsigned int type_offset, unsigned int opcode_offset)
789 {
790 uint32cxx . . $ uint32#* next_types;
791 uint32cxx . . $ uint32#* next_opcodes;
792
793 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(r != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
794 #define TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`! ctx->spirv.patch_table.attrib_type_load_offsets[r->usage][r->index]
795
796 next_types = (uint32cxx . . $ uint32#*) Malloccxx . . $ Malloc(a6ec60c25fe5143e).(ctx, sizeof(uint32cxx . . $ uint32#) * (TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.num_loadscxx . . $ SpirvPatchTable#$anonymous_type_7#num_loads. + 1));
797 next_opcodes = (uint32cxx . . $ uint32#*) Malloccxx . . $ Malloc(a6ec60c25fe5143e).(ctx, sizeof(uint32cxx . . $ uint32#) * (TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.num_loadscxx . . $ SpirvPatchTable#$anonymous_type_7#num_loads. + 1));
798
799 memcpycxx . . $ memcpy(cc817cb175f282d).(next_types, TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.load_typescxx . . $ SpirvPatchTable#$anonymous_type_7#load_types., sizeof(uint32cxx . . $ uint32#) * TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.num_loadscxx . . $ SpirvPatchTable#$anonymous_type_7#num_loads.);
800 memcpycxx . . $ memcpy(cc817cb175f282d).(next_opcodes, TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.load_opcodescxx . . $ SpirvPatchTable#$anonymous_type_7#load_opcodes., sizeof(uint32cxx . . $ uint32#) * TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.num_loadscxx . . $ SpirvPatchTable#$anonymous_type_7#num_loads.);
801
802 Freecxx . . $ Free(b86e3b3d45e44ecf).(ctx, TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.load_typescxx . . $ SpirvPatchTable#$anonymous_type_7#load_types.);
803 Freecxx . . $ Free(b86e3b3d45e44ecf).(ctx, TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.load_opcodescxx . . $ SpirvPatchTable#$anonymous_type_7#load_opcodes.);
804
805 TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.load_typescxx . . $ SpirvPatchTable#$anonymous_type_7#load_types. = next_types;
806 TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.load_opcodescxx . . $ SpirvPatchTable#$anonymous_type_7#load_opcodes. = next_opcodes;
807
808 TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.load_typescxx . . $ SpirvPatchTable#$anonymous_type_7#load_types.[TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.num_loadscxx . . $ SpirvPatchTable#$anonymous_type_7#num_loads.] = type_offset;
809 TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.load_opcodescxx . . $ SpirvPatchTable#$anonymous_type_7#load_opcodes.[TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.num_loadscxx . . $ SpirvPatchTable#$anonymous_type_7#num_loads.] = opcode_offset;
810
811 TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!.num_loadscxx . . $ SpirvPatchTable#$anonymous_type_7#num_loads. += 1;
812 #undef TYPE_LOAD_OFFSETcxx . . $ `profiles/mojoshader_profile_spirv.c:794:13`!
813 } // spv_add_attrib_fixup
814
815 static SpirvResultcxx . . $ SpirvResult# spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(Contextcxx . . $ Context# *ctx, RegisterListcxx . . $ RegisterList# *r)
816 {
817 const RegisterTypecxx . . $ RegisterType# regtype = r->regtypecxx . . $ RegisterList#regtype.;
818 uint32cxx . . $ uint32# copy_id;
819
820 spv_check_read_reg_idcxx . . $ spv_check_read_reg_id(5816d8773d24d3ec).(ctx, r);
821
822 uint32cxx . . $ uint32# id_src = r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
823 SpirvResultcxx . . $ SpirvResult# result;
824 if (regtype == REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER.)
825 {
826 RegisterListcxx . . $ RegisterList# *sreg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., r->regnumcxx . . $ RegisterList#regnum.);
827 result.tidcxx . . $ SpirvResult#tid. = spv_image_from_texturetypecxx . . $ spv_image_from_texturetype(ee3c21e30514eb7d).(ctx, (TextureTypecxx . . $ TextureType#)sreg->indexcxx . . $ RegisterList#index.);
828 } // if
829 else if (regtype == REG_TYPE_CONSTBOOLcxx . . $ REG_TYPE_CONSTBOOL.)
830 {
831 if (!r->spirvcxx . . $ RegisterList#spirv..is_ssacxx . . $ RegisterList#$anonymous_type_0#is_ssa.)
832 id_src = spv_access_uniformcxx . . $ spv_access_uniform(353dd63a86b7a3c5).(ctx, STI_PTR_INT_Ucxx . . $ STI_PTR_INT_U., regtype, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.);
833
834 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
835 } // else if
836 else if (regtype == REG_TYPE_CONSTINTcxx . . $ REG_TYPE_CONSTINT.)
837 {
838 if (!r->spirvcxx . . $ RegisterList#spirv..is_ssacxx . . $ RegisterList#$anonymous_type_0#is_ssa.)
839 id_src = spv_access_uniformcxx . . $ spv_access_uniform(353dd63a86b7a3c5).(ctx, STI_PTR_IVEC4_Ucxx . . $ STI_PTR_IVEC4_U., regtype, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.);
840
841 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IVEC4cxx . . $ STI_IVEC4.);
842 } // else if
843 else if (regtype == REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST.)
844 {
845 if (!r->spirvcxx . . $ RegisterList#spirv..is_ssacxx . . $ RegisterList#$anonymous_type_0#is_ssa.)
846 id_src = spv_access_uniformcxx . . $ spv_access_uniform(353dd63a86b7a3c5).(ctx, STI_PTR_VEC4_Ucxx . . $ STI_PTR_VEC4_U., regtype, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.);
847
848 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
849 } // else if
850 else if (regtype == REG_TYPE_LOOPcxx . . $ REG_TYPE_LOOP.)
851 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
852 else if (regtype == REG_TYPE_PREDICATEcxx . . $ REG_TYPE_PREDICATE.)
853 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BVEC4cxx . . $ STI_BVEC4.);
854 else
855 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
856
857 // Constants can be used directly, no need to load them.
858 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(r->spirv.is_ssa == 0 || r->spirv.is_ssa == 1);
859 if (r->spirvcxx . . $ RegisterList#spirv..is_ssacxx . . $ RegisterList#$anonymous_type_0#is_ssa.)
860 {
861 result.idcxx . . $ SpirvResult#id. = r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
862 return result;
863 } // if
864
865 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(id_src);
866 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
867
868 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
869 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., id_src);
870 if (shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx) && regtype == REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.)
871 {
872 copy_id = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
873 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpCopyObjectcxx . . $ SpvOpCopyObject., result.tidcxx . . $ SpirvResult#tid., copy_id, result.idcxx . . $ SpirvResult#id.);
874 result.idcxx . . $ SpirvResult#id. = copy_id;
875 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
876
877 // Store the offsets of:
878 // - OpLoad's type id, to change the input type
879 // - OpCopyObject's opcode, to change to OpConvert if needed
880 spv_add_attrib_fixupcxx . . $ spv_add_attrib_fixup(fee7688a8e643203).(ctx,
881 reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->attributescxx . . $ Context#attributes., r->regtypecxx . . $ RegisterList#regtype., r->regnumcxx . . $ RegisterList#regnum.),
882 (buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->mainlinecxx . . $ Context#mainline.) >> 2) - 7,
883 (buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->mainlinecxx . . $ Context#mainline.) >> 2) - 4);
884 } // if
885 else
886 {
887 // Nothing left to do for this register
888 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
889 } // else
890
891 return result;
892 } // spv_loadreg
893
894 static uint32cxx . . $ uint32# spv_emit_swizzlecxx . . $ spv_emit_swizzle(bdfd39476c67e44f).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# arg, uint32cxx . . $ uint32# rtid, const int swizzle, const int writemask)
895 {
896 uint32cxx . . $ uint32# result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
897
898 const int writemask0 = (writemask >> 0) & 0x1;
899 const int writemask1 = (writemask >> 1) & 0x1;
900 const int writemask2 = (writemask >> 2) & 0x1;
901 const int writemask3 = (writemask >> 3) & 0x1;
902
903 const uint32cxx . . $ uint32# swizzle_x = (swizzle >> 0) & 0x3;
904 const uint32cxx . . $ uint32# swizzle_y = (swizzle >> 2) & 0x3;
905 const uint32cxx . . $ uint32# swizzle_z = (swizzle >> 4) & 0x3;
906 const uint32cxx . . $ uint32# swizzle_w = (swizzle >> 6) & 0x3;
907
908 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
909 // OpVectorShuffle takes two vectors to shuffle, but to do a swizzle
910 // operation we can just ignore the second argument (meaning it can be
911 // anything, and I am just making it `arg` for convenience)
912 uint32cxx . . $ uint32# word_count = 5 + writemask0 + writemask1 + writemask2 + writemask3;
913 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, word_count, 5, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., rtid, result, arg, arg);
914 if (writemask0) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, swizzle_x);
915 if (writemask1) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, swizzle_y);
916 if (writemask2) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, swizzle_z);
917 if (writemask3) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, swizzle_w);
918 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
919
920 return result;
921 } // spv_emit_swizzle
922
923 SpirvResultcxx . . $ SpirvResult# spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(Contextcxx . . $ Context# *ctx, SpirvResultcxx . . $ SpirvResult# arg, const int swizzle, const int writemask)
924 {
925 int i;
926
927 // Nothing to do, so return the same SSA value
928 if (no_swizzlecxx . . $ no_swizzle(7864480464b09eea).(swizzle) && writemask_xyzwcxx . . $ writemask_xyzw(7864480464b09eea).(writemask))
929 return arg;
930
931 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(arg.tid != 0);
932 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(writemask == 1
933 || writemask == 3
934 || writemask == 7
935 || writemask == 15
936 );
937
938 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_arg = STI_VOIDcxx . . $ STI_VOID.;
939 for (i = STI_CORE_START_cxx . . $ STI_CORE_START_.; i < STI_CORE_END_cxx . . $ STI_CORE_END_.; i++)
940 {
941 if (ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[i] == arg.tidcxx . . $ SpirvResult#tid.)
942 {
943 sti_arg = (SpirvTypeIdxcxx . . $ SpirvTypeIdx#)i;
944 break;
945 } // if
946 } // for
947 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sti_arg != STI_VOID);
948
949 // We should not leave any value undefined, as it may end up used (eg. dot
950 // product), which will make everything relying on it's result undefined.
951 // Therefore, we specifically determine true dimensionality of the result.
952 int resdim = 0;
953 switch (writemask)
954 {
955 case 1:
956 resdim = 1;
957 break;
958
959 case 3:
960 resdim = 2;
961 break;
962
963 case 7:
964 resdim = 3;
965 break;
966
967 case 15:
968 resdim = 4;
969 break;
970
971 default:
972 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Unexpected write mask in swizzle: 0x%X");
973 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(0);
974 break;
975 } // switch
976
977 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_result = spv_change_base_type_vec_dimcxx . . $ spv_change_base_type_vec_dim(e0ad52047bd92d8).(sti_arg, resdim);
978
979 SpirvResultcxx . . $ SpirvResult# result = {0};
980 result.idcxx . . $ SpirvResult#id. = (resdim != 1 || sti_arg != sti_result) ? spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx) : arg.idcxx . . $ SpirvResult#id.;
981 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, sti_result);
982 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(result.tid != 0);
983
984 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
985 if (resdim != 1)
986 {
987 // OpVectorShuffle takes two vectors to shuffle, but to do a swizzle
988 // operation we can just ignore the second argument (meaning it can be
989 // anything, and I am just making it `arg` for convenience)
990 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 5 + resdim, 5, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., arg.idcxx . . $ SpirvResult#id., arg.idcxx . . $ SpirvResult#id.);
991
992 for (i = 0; i < resdim; i++)
993 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, (swizzle >> (2*i)) & 0x3);
994 } // if
995 else if (sti_arg != sti_result)
996 {
997 // OpVectorShuffle may not produce a scalar. Instead we use OpCompositeExtract.
998 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., arg.idcxx . . $ SpirvResult#id., swizzle & 0x3);
999 } // else if
1000
1001 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1002
1003 return result;
1004 } // make_GLSL_swizzle_string
1005
1006 static SpirvResultcxx . . $ SpirvResult# spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(Contextcxx . . $ Context# *ctx, const size_t idx, const int writemask)
1007 {
1008 SpirvResultcxx . . $ SpirvResult# result = {0};
1009 if (idx >= STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->source_args))
1010 {
1011 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Too many source args");
1012 return result;
1013 } // if
1014
1015 const SourceArgInfocxx . . $ SourceArgInfo# *arg = &ctx->source_argscxx . . $ Context#source_args.[idx];
1016
1017 RegisterListcxx . . $ RegisterList# *reg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
1018
1019 if (arg->relativecxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative.)
1020 {
1021 if (arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype. == REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.)
1022 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "relative input array access is unimplemented");
1023 else
1024 {
1025 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(arg->regtype == REG_TYPE_CONST);
1026 const int arrayidx = arg->relative_arraycxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_array.->indexcxx . . $ VariableList#index.;
1027 const int offset = arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum. - arrayidx;
1028 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(offset >= 0);
1029
1030 int is_constant = (arg->relative_arraycxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_array.->constantcxx . . $ VariableList#constant. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
1031 uint32cxx . . $ uint32# id_array = 0;
1032 if (is_constant)
1033 {
1034 id_array = ctx->spirvcxx . . $ Context#spirv..constant_arrayscxx . . $ SpirvContext#constant_arrays..idvec4cxx . . $ SpirvContext#$anonymous_type_2#idvec4.;
1035 if (id_array == 0)
1036 {
1037 id_array = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1038 ctx->spirvcxx . . $ Context#spirv..constant_arrayscxx . . $ SpirvContext#constant_arrays..idvec4cxx . . $ SpirvContext#$anonymous_type_2#idvec4. = id_array;
1039 } // if
1040 } // if
1041
1042 RegisterListcxx . . $ RegisterList# *reg_rel = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, arg->relative_regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_regtype., arg->relative_regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_regnum.);
1043
1044 spv_check_read_reg_idcxx . . $ spv_check_read_reg_id(5816d8773d24d3ec).(ctx, reg_rel);
1045 spv_check_read_reg_idcxx . . $ spv_check_read_reg_id(5816d8773d24d3ec).(ctx, reg);
1046
1047 uint32cxx . . $ uint32# id_int = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
1048 uint32cxx . . $ uint32# id_offset;
1049 if (reg_rel->regtypecxx . . $ RegisterList#regtype. == REG_TYPE_LOOPcxx . . $ REG_TYPE_LOOP.)
1050 id_offset = reg_rel->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
1051 else
1052 {
1053 uint32cxx . . $ uint32# id_pint = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_INT_Pcxx . . $ STI_PTR_INT_P.);
1054 uint32cxx . . $ uint32# id_compidx = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, arg->relative_componentcxx . . $ $anonymous_type_3d78d65a03e818ad_1#relative_component.);
1055 uint32cxx . . $ uint32# id_pcomp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1056 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpAccessChaincxx . . $ SpvOpAccessChain., id_pint, id_pcomp, reg_rel->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., id_compidx);
1057
1058 id_offset = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1059 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., id_int, id_offset, id_pcomp);
1060 } // else
1061
1062 if (!is_constant)
1063 {
1064 uint32cxx . . $ uint32# id_arraybase = reg->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
1065 uint32cxx . . $ uint32# id_a = id_offset;
1066 uint32cxx . . $ uint32# id_b = id_arraybase;
1067 id_offset = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1068 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpIAddcxx . . $ SpvOpIAdd., id_int, id_offset, id_a, id_b);
1069 } // if
1070
1071 if (offset)
1072 {
1073 uint32cxx . . $ uint32# id_a = id_offset;
1074 uint32cxx . . $ uint32# id_b = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, offset);
1075 id_offset = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1076 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpIAddcxx . . $ SpvOpIAdd., id_int, id_offset, id_a, id_b);
1077 } // if
1078
1079 uint32cxx . . $ uint32# id_pvalue;
1080 if (is_constant)
1081 {
1082 uint32cxx . . $ uint32# id_pvec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Pcxx . . $ STI_PTR_VEC4_P.);
1083 id_pvalue = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1084 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4+1, SpvOpAccessChaincxx . . $ SpvOpAccessChain., id_pvec4, id_pvalue, id_array, id_offset);
1085 } // if
1086 else
1087 {
1088 id_pvalue = spv_access_uniformcxx . . $ spv_access_uniform(353dd63a86b7a3c5).(ctx, STI_PTR_VEC4_Ucxx . . $ STI_PTR_VEC4_U., arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., id_offset);
1089 } // else
1090
1091 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
1092 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1093 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., id_pvalue);
1094 } // else
1095 } // if
1096 else
1097 result = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, reg);
1098
1099 result = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, result, arg->swizzlecxx . . $ $anonymous_type_3d78d65a03e818ad_1#swizzle., writemask);
1100
1101 switch (arg->src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod.)
1102 {
1103 case SRCMOD_NEGATEcxx . . $ SRCMOD_NEGATE.:
1104 {
1105 uint32cxx . . $ uint32# id_neg = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1106 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpFNegatecxx . . $ SpvOpFNegate., result.tidcxx . . $ SpirvResult#tid., id_neg, result.idcxx . . $ SpirvResult#id.);
1107 result.idcxx . . $ SpirvResult#id. = id_neg;
1108 break;
1109 } // case
1110
1111 case SRCMOD_BIASNEGATEcxx . . $ SRCMOD_BIASNEGATE.:
1112 {
1113 uint32cxx . . $ uint32# id_half = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_0_5cxx . . $ SpirvContext#id_0_5., 0.5f);
1114 uint32cxx . . $ uint32# id_tmp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1115 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1116 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFSubcxx . . $ SpvOpFSub., result.tidcxx . . $ SpirvResult#tid., id_tmp, result.idcxx . . $ SpirvResult#id., id_half);
1117 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpFNegatecxx . . $ SpvOpFNegate., result.tidcxx . . $ SpirvResult#tid., id_new, id_tmp);
1118 result.idcxx . . $ SpirvResult#id. = id_new;
1119 break;
1120 } // case
1121
1122 case SRCMOD_BIAScxx . . $ SRCMOD_BIAS.:
1123 {
1124 uint32cxx . . $ uint32# id_half = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_0_5cxx . . $ SpirvContext#id_0_5., 0.5f);
1125 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1126 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFSubcxx . . $ SpvOpFSub., result.tidcxx . . $ SpirvResult#tid., id_new, result.idcxx . . $ SpirvResult#id., id_half);
1127 result.idcxx . . $ SpirvResult#id. = id_new;
1128 break;
1129 } // case
1130
1131 case SRCMOD_SIGNNEGATEcxx . . $ SRCMOD_SIGNNEGATE.:
1132 {
1133 uint32cxx . . $ uint32# id_half = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_0_5cxx . . $ SpirvContext#id_0_5., 0.5f);
1134 uint32cxx . . $ uint32# id_two = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_2_0cxx . . $ SpirvContext#id_2_0., 2.0f);
1135 uint32cxx . . $ uint32# id_tmp0 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1136 uint32cxx . . $ uint32# id_tmp1 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1137 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1138 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFSubcxx . . $ SpvOpFSub., result.tidcxx . . $ SpirvResult#tid., id_tmp0, result.idcxx . . $ SpirvResult#id., id_half);
1139 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., result.tidcxx . . $ SpirvResult#tid., id_tmp1, id_tmp0, id_two);
1140 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpFNegatecxx . . $ SpvOpFNegate., result.tidcxx . . $ SpirvResult#tid., id_new, id_tmp1);
1141 result.idcxx . . $ SpirvResult#id. = id_new;
1142 break;
1143 } // case
1144
1145 case SRCMOD_SIGNcxx . . $ SRCMOD_SIGN.:
1146 {
1147 uint32cxx . . $ uint32# id_half = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_0_5cxx . . $ SpirvContext#id_0_5., 0.5f);
1148 uint32cxx . . $ uint32# id_two = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_2_0cxx . . $ SpirvContext#id_2_0., 2.0f);
1149 uint32cxx . . $ uint32# id_tmp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1150 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1151 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFSubcxx . . $ SpvOpFSub., result.tidcxx . . $ SpirvResult#tid., id_tmp, result.idcxx . . $ SpirvResult#id., id_half);
1152 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., result.tidcxx . . $ SpirvResult#tid., id_new, id_tmp, id_two);
1153 result.idcxx . . $ SpirvResult#id. = id_new;
1154 break;
1155 } // case
1156
1157 case SRCMOD_COMPLEMENTcxx . . $ SRCMOD_COMPLEMENT.:
1158 {
1159 uint32cxx . . $ uint32# id_one = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_1_0cxx . . $ SpirvContext#id_1_0., 1.0f);
1160 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1161 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFSubcxx . . $ SpvOpFSub., result.tidcxx . . $ SpirvResult#tid., id_new, id_one, result.idcxx . . $ SpirvResult#id.);
1162 result.idcxx . . $ SpirvResult#id. = id_new;
1163 break;
1164 } // case
1165
1166 case SRCMOD_X2NEGATEcxx . . $ SRCMOD_X2NEGATE.:
1167 {
1168 uint32cxx . . $ uint32# id_two = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_2_0cxx . . $ SpirvContext#id_2_0., 2.0f);
1169 uint32cxx . . $ uint32# id_tmp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1170 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1171 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., result.tidcxx . . $ SpirvResult#tid., id_tmp, result.idcxx . . $ SpirvResult#id., id_two);
1172 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpFNegatecxx . . $ SpvOpFNegate., result.tidcxx . . $ SpirvResult#tid., id_new, id_tmp);
1173 result.idcxx . . $ SpirvResult#id. = id_new;
1174 break;
1175 } // case
1176
1177 case SRCMOD_X2cxx . . $ SRCMOD_X2.:
1178 {
1179 uint32cxx . . $ uint32# id_two = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, result.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_2_0cxx . . $ SpirvContext#id_2_0., 2.0f);
1180 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1181 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., result.tidcxx . . $ SpirvResult#tid., id_new, result.idcxx . . $ SpirvResult#id., id_two);
1182 result.idcxx . . $ SpirvResult#id. = id_new;
1183 break;
1184 } // case
1185
1186 // case SRCMOD_DZ:
1187 // fail(ctx, "SRCMOD_DZ unsupported"); return buf; // !!! FIXME
1188 // postmod_str = "_dz";
1189 // break;
1190
1191 // case SRCMOD_DW:
1192 // fail(ctx, "SRCMOD_DW unsupported"); return buf; // !!! FIXME
1193 // postmod_str = "_dw";
1194 // break;
1195
1196 case SRCMOD_ABSNEGATEcxx . . $ SRCMOD_ABSNEGATE.:
1197 {
1198 uint32cxx . . $ uint32# id_abs = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1199 uint32cxx . . $ uint32# id_neg = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1200 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., result.tidcxx . . $ SpirvResult#tid., id_abs, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FAbscxx . . $ GLSLstd450FAbs., result.idcxx . . $ SpirvResult#id.);
1201 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpFNegatecxx . . $ SpvOpFNegate., result.tidcxx . . $ SpirvResult#tid., id_neg, id_abs);
1202 result.idcxx . . $ SpirvResult#id. = id_neg;
1203 break;
1204 } // case
1205
1206 case SRCMOD_ABScxx . . $ SRCMOD_ABS.:
1207 {
1208 uint32cxx . . $ uint32# id_abs = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1209 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., result.tidcxx . . $ SpirvResult#tid., id_abs, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FAbscxx . . $ GLSLstd450FAbs., result.idcxx . . $ SpirvResult#id.);
1210 result.idcxx . . $ SpirvResult#id. = id_abs;
1211 break;
1212 } // case
1213
1214 case SRCMOD_NOTcxx . . $ SRCMOD_NOT.:
1215 {
1216 // We can't do OpLogicalNot on ints, so do (x ^ 1) instead
1217 uint32cxx . . $ uint32# id_one = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, 1);
1218 uint32cxx . . $ uint32# id_not = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1219 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpBitwiseXorcxx . . $ SpvOpBitwiseXor., result.tidcxx . . $ SpirvResult#tid., id_not, result.idcxx . . $ SpirvResult#id., id_one);
1220 result.idcxx . . $ SpirvResult#id. = id_not;
1221 break;
1222 } // case
1223
1224 case SRCMOD_NONEcxx . . $ SRCMOD_NONE.:
1225 case SRCMOD_TOTALcxx . . $ SRCMOD_TOTAL.:
1226 break; // stop compiler whining.
1227
1228 default:
1229 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "unsupported source modifier %d", arg->src_modcxx . . $ $anonymous_type_3d78d65a03e818ad_1#src_mod.);
1230 return result;
1231 } // switch
1232
1233 return result;
1234 } // spv_load_srcarg
1235
1236 static inline SpirvResultcxx . . $ SpirvResult# spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(Contextcxx . . $ Context# *ctx, const size_t idx)
1237 {
1238 return spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, idx, 0xF);
1239 } // spv_load_srcarg_full
1240
1241 static void spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(Contextcxx . . $ Context# *ctx, SpirvResultcxx . . $ SpirvResult# value)
1242 {
1243 const DestArgInfocxx . . $ DestArgInfo# *arg = &ctx->dest_argcxx . . $ Context#dest_arg.;
1244 RegisterListcxx . . $ RegisterList# *reg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, arg->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., arg->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
1245
1246 spv_check_write_reg_idcxx . . $ spv_check_write_reg_id(5816d8773d24d3ec).(ctx, reg);
1247
1248 if (arg->writemaskcxx . . $ $anonymous_type_32753e8ce5863620_5#writemask. == 0)
1249 {
1250 // Return without updating the reg->spirv.iddecl (all-zero writemask = no-op)
1251 return;
1252 } // if
1253
1254 if (arg->result_modcxx . . $ $anonymous_type_32753e8ce5863620_5#result_mod. & MOD_SATURATEcxx . . $ `mojoshader_internal.h:503:9`!)
1255 {
1256 uint32cxx . . $ uint32# ext, zero, one, new_value;
1257
1258 // Don't inline these, compilers will run the varargs in different orders
1259 new_value = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1260 one = spv_get_onecxx . . $ spv_get_one(1e2deca95f3d56bd).(ctx, value.tidcxx . . $ SpirvResult#tid.);
1261 zero = spv_get_zerocxx . . $ spv_get_zero(1e2deca95f3d56bd).(ctx, value.tidcxx . . $ SpirvResult#tid.);
1262 ext = spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx);
1263
1264 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1265 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpExtInstcxx . . $ SpvOpExtInst.,
1266 value.tidcxx . . $ SpirvResult#tid., new_value, ext, GLSLstd450FClampcxx . . $ GLSLstd450FClamp., value.idcxx . . $ SpirvResult#id., zero, one
1267 );
1268 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1269 value.idcxx . . $ SpirvResult#id. = new_value;
1270 } // if
1271
1272 // MSDN says MOD_PP is a hint and many implementations ignore it. So do we.
1273
1274 // CENTROID only allowed in DCL opcodes, which shouldn't come through here.
1275 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((arg->result_mod & MOD_CENTROIDcxx . . $ `mojoshader_internal.h:505:9`!) == 0);
1276
1277 if (ctx->predicatedcxx . . $ Context#predicated.)
1278 {
1279 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "predicated destinations unsupported"); // !!! FIXME
1280 return;
1281 } // if
1282
1283 if (arg->result_shiftcxx . . $ $anonymous_type_32753e8ce5863620_5#result_shift.)
1284 {
1285 float factor = 1.0f;
1286 uint32cxx . . $ uint32#* cache = ctx->spirvcxx . . $ Context#spirv..id_1_0cxx . . $ SpirvContext#id_1_0.;
1287 switch (arg->result_shiftcxx . . $ $anonymous_type_32753e8ce5863620_5#result_shift.)
1288 {
1289 case 0x1: factor = 2.0f; cache = ctx->spirvcxx . . $ Context#spirv..id_2_0cxx . . $ SpirvContext#id_2_0.; break;
1290 case 0x2: factor = 4.0f; cache = ctx->spirvcxx . . $ Context#spirv..id_4_0cxx . . $ SpirvContext#id_4_0.; break;
1291 case 0x3: factor = 8.0f; cache = ctx->spirvcxx . . $ Context#spirv..id_8_0cxx . . $ SpirvContext#id_8_0.; break;
1292 case 0xD: factor = 0.125f; cache = ctx->spirvcxx . . $ Context#spirv..id_0_125cxx . . $ SpirvContext#id_0_125.; break;
1293 case 0xE: factor = 0.25f; cache = ctx->spirvcxx . . $ Context#spirv..id_0_25cxx . . $ SpirvContext#id_0_25.; break;
1294 case 0xF: factor = 0.5f; cache = ctx->spirvcxx . . $ Context#spirv..id_0_5cxx . . $ SpirvContext#id_0_5.; break;
1295 default:
1296 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "unexpected result shift %d", arg->result_shiftcxx . . $ $anonymous_type_32753e8ce5863620_5#result_shift.);
1297 } // switch
1298
1299 uint32cxx . . $ uint32# id_factor = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, value.tidcxx . . $ SpirvResult#tid., cache, factor);
1300 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1301 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1302 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., value.tidcxx . . $ SpirvResult#tid., id_new, value.idcxx . . $ SpirvResult#id., id_factor);
1303 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1304 value.idcxx . . $ SpirvResult#id. = id_new;
1305 } // if
1306
1307 if (reg->regtypecxx . . $ RegisterList#regtype. == REG_TYPE_DEPTHOUTcxx . . $ REG_TYPE_DEPTHOUT.
1308 || isscalarcxx . . $ isscalar(9d8abf502d86d4f4).(ctx, ctx->shader_typecxx . . $ Context#shader_type., arg->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., arg->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.))
1309 {
1310 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(arg->writemask == 0x1);
1311 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_reg = STI_FLOATcxx . . $ STI_FLOAT.;
1312 uint32cxx . . $ uint32# rtid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, sti_reg);
1313 uint32cxx . . $ uint32# new_value = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1314 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1315 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., rtid, new_value, value.idcxx . . $ SpirvResult#id., 0);
1316 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1317 value.tidcxx . . $ SpirvResult#tid. = rtid;
1318 value.idcxx . . $ SpirvResult#id. = new_value;
1319 } // if
1320 else if (!writemask_xyzwcxx . . $ writemask_xyzw(7864480464b09eea).(arg->writemaskcxx . . $ $anonymous_type_32753e8ce5863620_5#writemask.))
1321 {
1322 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_reg;
1323 switch (reg->regtypecxx . . $ RegisterList#regtype.)
1324 {
1325 case REG_TYPE_ADDRESScxx . . $ REG_TYPE_ADDRESS.: sti_reg = STI_IVEC4cxx . . $ STI_IVEC4.; break;
1326 case REG_TYPE_PREDICATEcxx . . $ REG_TYPE_PREDICATE.: sti_reg = STI_BVEC4cxx . . $ STI_BVEC4.; break;
1327 default: sti_reg = STI_VEC4cxx . . $ STI_VEC4.; break;
1328 } // switch
1329
1330 uint32cxx . . $ uint32# rtid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, sti_reg);
1331 uint32cxx . . $ uint32# new_value = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1332 uint32cxx . . $ uint32# current_value = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1333
1334 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1335
1336 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., rtid, current_value, reg->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.);
1337
1338 // output id is new_value
1339 // select between current value and new value based on writemask
1340 // in the shuffle, components [0, 3] are the new value, and components
1341 // [4, 7] are the existing value
1342 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 5 + 4, 5, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., rtid, new_value, value.idcxx . . $ SpirvResult#id., current_value);
1343 if (arg->writemask0cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask0.) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 0); else spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 4);
1344 if (arg->writemask1cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask1.) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 1); else spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 5);
1345 if (arg->writemask2cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask2.) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 2); else spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 6);
1346 if (arg->writemask3cxx . . $ $anonymous_type_32753e8ce5863620_5#writemask3.) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 3); else spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 7);
1347
1348 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1349
1350 value.tidcxx . . $ SpirvResult#tid. = rtid;
1351 value.idcxx . . $ SpirvResult#id. = new_value;
1352 } // if
1353
1354 switch (reg->regtypecxx . . $ RegisterList#regtype.)
1355 {
1356 case REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.:
1357 case REG_TYPE_ADDRESScxx . . $ REG_TYPE_ADDRESS.:
1358 case REG_TYPE_TEMPcxx . . $ REG_TYPE_TEMP.:
1359 case REG_TYPE_DEPTHOUTcxx . . $ REG_TYPE_DEPTHOUT.:
1360 case REG_TYPE_COLOROUTcxx . . $ REG_TYPE_COLOROUT.:
1361 case REG_TYPE_RASTOUTcxx . . $ REG_TYPE_RASTOUT.:
1362 case REG_TYPE_ATTROUTcxx . . $ REG_TYPE_ATTROUT.:
1363 case REG_TYPE_PREDICATEcxx . . $ REG_TYPE_PREDICATE.:
1364 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1365 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpStorecxx . . $ SpvOpStore., reg->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., value.idcxx . . $ SpirvResult#id.);
1366 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1367 break;
1368
1369 default:
1370 {
1371 char varname[64];
1372 get_SPIRV_varname_in_bufcxx . . $ get_SPIRV_varname_in_buf(e11e601b5c61efa5).(ctx, reg->regtypecxx . . $ RegisterList#regtype., reg->regnumcxx . . $ RegisterList#regnum., varname, sizeof(varname));
1373 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "register %s is unimplemented for storing", varname);
1374 break;
1375 } // default
1376 } // switch
1377 } // spv_assign_destarg
1378
1379 static void spv_emit_vs_main_endcxx . . $ spv_emit_vs_main_end(612dd59919e2530e).(Contextcxx . . $ Context#* ctx)
1380 {
1381 #if SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`!
1382 #if defined(MOJOSHADER_DEPTH_CLIPPING) || defined(MOJOSHADER_FLIP_RENDERTARGET)
1383 if (!ctx->profile_supports_glspirv || !shader_is_vertex(ctx))
1384 return;
1385
1386 uint32 tid_void = spv_get_type(ctx, STI_VOID);
1387 uint32 tid_func = spv_get_type(ctx, STI_FUNC_VOID);
1388 uint32 id_func = ctx->spirv.id_vs_main_end;
1389 uint32 id_label = spv_bumpid(ctx);
1390 assert(id_func != 0);
1391
1392 push_output(ctx, &ctx->mainline);
1393 spv_emit(ctx, 5, SpvOpFunction, tid_void, id_func, SpvFunctionControlMaskNone, tid_func);
1394 spv_emit(ctx, 2, SpvOpLabel, id_label);
1395
1396 RegisterList *reg;
1397 for (reg = ctx->used_registers.next; reg != NULL; reg = reg->next)
1398 {
1399 if (reg->usage == MOJOSHADER_USAGE_POSITION &&
1400 (reg->regtype == REG_TYPE_RASTOUT || reg->regtype == REG_TYPE_OUTPUT))
1401 break;
1402 } // for
1403 SpirvResult output = spv_loadreg(ctx, reg);
1404 uint32 tid_float = spv_get_type(ctx, STI_FLOAT);
1405 uint32 id_new_output;
1406
1407 #ifdef MOJOSHADER_FLIP_RENDERTARGET
1408 // gl_Position.y = gl_Position.y * vpFlip;
1409 uint32 tid_pvpflip = spv_bumpid(ctx);
1410 uint32 id_old_y = spv_bumpid(ctx);
1411 uint32 id_pvpflip = spv_bumpid(ctx);
1412 uint32 id_vpflip = spv_bumpid(ctx);
1413 uint32 id_new_y = spv_bumpid(ctx);
1414 id_new_output = spv_bumpid(ctx);
1415
1416 spv_emit(ctx, 5, SpvOpCompositeExtract, tid_float, id_old_y, output.id, 1);
1417 spv_emit(ctx, 4, SpvOpLoad, tid_float, id_vpflip, id_pvpflip);
1418 spv_emit(ctx, 5, SpvOpFMul, tid_float, id_new_y, id_old_y, id_vpflip);
1419 spv_emit(ctx, 6, SpvOpCompositeInsert, output.tid, id_new_output, id_new_y, output.id, 1);
1420 output.id = id_new_output;
1421
1422 push_output(ctx, &ctx->mainline_intro);
1423 spv_emit(ctx, 4, SpvOpTypePointer, tid_pvpflip, SpvStorageClassUniformConstant, tid_float);
1424 spv_emit(ctx, 4, SpvOpVariable, tid_pvpflip, id_pvpflip, SpvStorageClassUniformConstant);
1425 pop_output(ctx);
1426
1427 spv_output_name(ctx, id_pvpflip, "vpFlip");
1428 ctx->spirv.patch_table.vpflip.offset = spv_output_location(ctx, id_pvpflip, ~0u);
1429 #endif // MOJOSHADER_FLIP_RENDERTARGET
1430
1431 #ifdef MOJOSHADER_DEPTH_CLIPPING
1432 // gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;
1433 uint32 id_2 = spv_getscalarf(ctx, 2.0f);
1434 uint32 id_old_z = spv_bumpid(ctx);
1435 uint32 id_old_w = spv_bumpid(ctx);
1436 uint32 id_2z = spv_bumpid(ctx);
1437 uint32 id_new_z = spv_bumpid(ctx);
1438 id_new_output = spv_bumpid(ctx);
1439
1440 spv_emit(ctx, 5, SpvOpCompositeExtract, tid_float, id_old_z, output.id, 2);
1441 spv_emit(ctx, 5, SpvOpCompositeExtract, tid_float, id_old_w, output.id, 3);
1442 spv_emit(ctx, 5, SpvOpFMul, tid_float, id_2z, id_old_z, id_2);
1443 spv_emit(ctx, 5, SpvOpFSub, tid_float, id_new_z, id_2z, id_old_w);
1444 spv_emit(ctx, 6, SpvOpCompositeInsert, output.tid, id_new_output, id_new_z, output.id, 2);
1445 output.id = id_new_output;
1446 #endif // MOJOSHADER_DEPTH_CLIPPING
1447
1448 spv_emit(ctx, 3, SpvOpStore, reg->spirv.iddecl, output.id);
1449 spv_emit(ctx, 1, SpvOpReturn);
1450 spv_emit(ctx, 1, SpvOpFunctionEnd);
1451 pop_output(ctx);
1452
1453 spv_output_name(ctx, id_func, "vs_epilogue");
1454 #endif // defined(MOJOSHADER_DEPTH_CLIPPING) || defined(MOJOSHADER_FLIP_RENDERTARGET)
1455 #endif // SUPPORT_PROFILE_GLSPIRV
1456 } // spv_emit_vs_main_end
1457
1458 static void spv_emit_func_litcxx . . $ spv_emit_func_lit(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1459 {
1460 if (!ctx->spirvcxx . . $ Context#spirv..id_func_litcxx . . $ SpirvContext#id_func_lit.)
1461 return;
1462
1463 // vec4 LIT(const vec4 src)
1464 // {
1465 // float retval_y, retval_z;
1466 // if (src.x > 0.0) {
1467 // retval_y = src.x;
1468 // if (src.y > 0.0) {
1469 // float power = clamp(src.w, -127.9961, 127.9961);
1470 // retval_z = pow(src.y, power);
1471 // } else {
1472 // retval_z = 0.0;
1473 // }
1474 // } else {
1475 // retval_y = 0.0;
1476 // retval_z = 0.0;
1477 // }
1478 // vec4 retval = vec4(1.0, retval_y, retval_z, 1.0);
1479 // return retval;
1480 // }
1481
1482 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
1483 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
1484 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
1485 uint32cxx . . $ uint32# tid_func = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FUNC_LITcxx . . $ STI_FUNC_LIT.);
1486 uint32cxx . . $ uint32# id_func = ctx->spirvcxx . . $ Context#spirv..id_func_litcxx . . $ SpirvContext#id_func_lit.;
1487 uint32cxx . . $ uint32# id_src = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1488 uint32cxx . . $ uint32# id_block_start = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1489 uint32cxx . . $ uint32# id_src_x = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1490 uint32cxx . . $ uint32# id_src_x_pos = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1491 uint32cxx . . $ uint32# id_0_0 = spv_get_zerocxx . . $ spv_get_zero(1e2deca95f3d56bd).(ctx, tid_float);
1492 uint32cxx . . $ uint32# id_branch0_true = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1493 uint32cxx . . $ uint32# id_src_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1494 uint32cxx . . $ uint32# id_src_y_pos = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1495 uint32cxx . . $ uint32# id_branch1_true = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1496 uint32cxx . . $ uint32# id_src_w = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1497 uint32cxx . . $ uint32# id_maxp = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, 127.9961f);
1498 uint32cxx . . $ uint32# id_maxp_neg = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, -127.9961f);
1499 uint32cxx . . $ uint32# id_power = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1500 uint32cxx . . $ uint32# id_pow_result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1501 uint32cxx . . $ uint32# id_branch1_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1502 uint32cxx . . $ uint32# id_branch1_result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1503 uint32cxx . . $ uint32# id_branch0_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1504 uint32cxx . . $ uint32# id_result_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1505 uint32cxx . . $ uint32# id_result_z = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1506 uint32cxx . . $ uint32# id_1_0 = spv_get_onecxx . . $ spv_get_one(1e2deca95f3d56bd).(ctx, tid_float);
1507 uint32cxx . . $ uint32# id_result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1508
1509 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1510 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFunctioncxx . . $ SpvOpFunction., tid_vec4, id_func, SpvFunctionControlMaskNonecxx . . $ SpvFunctionControlMaskNone., tid_func);
1511 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpFunctionParametercxx . . $ SpvOpFunctionParameter., tid_vec4, id_src);
1512
1513 // id_block_start
1514 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_block_start);
1515 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_src_x, id_src, 0);
1516 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdGreaterThancxx . . $ SpvOpFOrdGreaterThan., tid_bool, id_src_x_pos, id_src_x, id_0_0);
1517 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., id_branch0_merge, 0);
1518 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., id_src_x_pos, id_branch0_true, id_branch0_merge);
1519
1520 // id_branch0_true
1521 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_branch0_true);
1522 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_src_y, id_src, 1);
1523 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdGreaterThancxx . . $ SpvOpFOrdGreaterThan., tid_bool, id_src_y_pos, id_src_y, id_0_0);
1524 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., id_branch1_merge, 0);
1525 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., id_src_y_pos, id_branch1_true, id_branch1_merge);
1526
1527 // id_branch1_true
1528 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_branch1_true);
1529 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_src_w, id_src, 3);
1530 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpExtInstcxx . . $ SpvOpExtInst.,
1531 tid_float, id_power, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FClampcxx . . $ GLSLstd450FClamp., id_src_w, id_maxp_neg, id_maxp
1532 );
1533 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 2, SpvOpExtInstcxx . . $ SpvOpExtInst.,
1534 tid_float, id_pow_result, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450Powcxx . . $ GLSLstd450Pow., id_src_y, id_power
1535 );
1536 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_branch1_merge);
1537
1538 // id_branch1_merge
1539 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_branch1_merge);
1540 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 7, SpvOpPhicxx . . $ SpvOpPhi., tid_float, id_branch1_result,
1541 id_pow_result, id_branch1_true,
1542 id_0_0, id_branch0_true
1543 );
1544 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_branch0_merge);
1545
1546 // id_branch0_merge
1547 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_branch0_merge);
1548 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 7, SpvOpPhicxx . . $ SpvOpPhi., tid_float, id_result_y,
1549 id_src_x, id_branch1_merge,
1550 id_0_0, id_block_start
1551 );
1552 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 7, SpvOpPhicxx . . $ SpvOpPhi., tid_float, id_result_z,
1553 id_branch1_result, id_branch1_merge,
1554 id_0_0, id_block_start
1555 );
1556 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec4, id_result,
1557 id_1_0, id_result_y, id_result_z, id_1_0
1558 );
1559 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpReturnValuecxx . . $ SpvOpReturnValue., id_result);
1560 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 1, SpvOpFunctionEndcxx . . $ SpvOpFunctionEnd.);
1561
1562 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1563
1564 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, ctx->spirvcxx . . $ Context#spirv..id_func_litcxx . . $ SpirvContext#id_func_lit., "LIT");
1565 } // spv_emit_func_lit
1566
1567 static void spv_emit_func_endcxx . . $ spv_emit_func_end(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1568 {
1569 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1570
1571 #if SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`!
1572 #if defined(MOJOSHADER_DEPTH_CLIPPING) || defined(MOJOSHADER_FLIP_RENDERTARGET)
1573 if (ctx->profile_supports_glspirv
1574 && shader_is_vertex(ctx)
1575 && ctx->spirv.id_vs_main_end == 0)
1576 {
1577 ctx->spirv.id_vs_main_end = spv_bumpid(ctx);
1578 uint32 tid_void = spv_get_type(ctx, STI_VOID);
1579 uint32 id_res = spv_bumpid(ctx);
1580
1581 push_output(ctx, &ctx->mainline);
1582 spv_emit(ctx, 4, SpvOpFunctionCall, tid_void, id_res, ctx->spirv.id_vs_main_end);
1583 pop_output(ctx);
1584 } // if
1585 #endif // defined(MOJOSHADER_DEPTH_CLIPPING) || defined(MOJOSHADER_FLIP_RENDERTARGET)
1586 #endif // SUPPORT_PROFILE_GLSPIRV
1587
1588 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 1, SpvOpReturncxx . . $ SpvOpReturn.);
1589 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 1, SpvOpFunctionEndcxx . . $ SpvOpFunctionEnd.);
1590 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1591 } // spv_emit_func_end
1592
1593 static void spv_emit_vpos_glmodecxx . . $ spv_emit_vpos_glmode(d867d534d1c117ac).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id)
1594 {
1595 // In SM3.0 vPos only has x and y defined, but we should be
1596 // fine to leave the z and w attributes in that
1597 // SpvBuiltInFragCoord gives.
1598
1599 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
1600 uint32cxx . . $ uint32# tid_vec2 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC2cxx . . $ STI_VEC2.);
1601 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
1602 uint32cxx . . $ uint32# tid_pvec4i = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Icxx . . $ STI_PTR_VEC4_I.);
1603 uint32cxx . . $ uint32# tid_pvec2u = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1604 uint32cxx . . $ uint32# tid_pvec4p = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Pcxx . . $ STI_PTR_VEC4_P.);
1605
1606 uint32cxx . . $ uint32# id_var_fragcoord = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1607 uint32cxx . . $ uint32# id_var_vposflip = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1608 uint32cxx . . $ uint32# id_var_vpos = id;
1609
1610 uint32cxx . . $ uint32# id_fragcoord = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1611 uint32cxx . . $ uint32# id_fragcoord_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1612 uint32cxx . . $ uint32# id_vposflip = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1613 uint32cxx . . $ uint32# id_vposflip_x = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1614 uint32cxx . . $ uint32# id_vposflip_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1615 uint32cxx . . $ uint32# id_tmp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1616 uint32cxx . . $ uint32# id_vpos_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1617 uint32cxx . . $ uint32# id_vpos = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1618
1619 // vec4 gl_FragCoord = <compiler magic builtin>;
1620 // uniform vec2 vposFlip;
1621 // vec4 ps_vPos = vec4(
1622 // gl_FragCoord.x,
1623 // (gl_FragCoord.y * vposFlip.x) + vposFlip.y,
1624 // gl_FragCoord.z,
1625 // gl_FragCoord.w
1626 // );
1627
1628 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
1629 // Define uniform vec2*. This is the only place that uses it right now.
1630 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypePointercxx . . $ SpvOpTypePointer., tid_pvec2u, SpvStorageClassUniformConstantcxx . . $ SpvStorageClassUniformConstant., tid_vec2);
1631 // Define all variables involved.
1632 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4i, id_var_fragcoord, SpvStorageClassInputcxx . . $ SpvStorageClassInput.);
1633 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec2u, id_var_vposflip, SpvStorageClassUniformConstantcxx . . $ SpvStorageClassUniformConstant.);
1634 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4p, id_var_vpos, SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate.);
1635 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1636
1637 spv_output_builtincxx . . $ spv_output_builtin(f45776df1a665a6e).(ctx, id_var_fragcoord, SpvBuiltInFragCoordcxx . . $ SpvBuiltInFragCoord.);
1638 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, id_var_vposflip, "vposFlip");
1639
1640 // Initialize vPos using vPosFlip and built in FragCoord.
1641 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_topcxx . . $ Context#mainline_top.);
1642 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., tid_vec4, id_fragcoord, id_var_fragcoord);
1643 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_fragcoord_y, id_fragcoord, 1);
1644 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., tid_vec2, id_vposflip, id_var_vposflip);
1645 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_vposflip_x, id_vposflip, 0);
1646 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_vposflip_y, id_vposflip, 1);
1647 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_float, id_tmp, id_fragcoord_y, id_vposflip_x);
1648 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFAddcxx . . $ SpvOpFAdd., tid_float, id_vpos_y, id_tmp, id_vposflip_y);
1649 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpCompositeInsertcxx . . $ SpvOpCompositeInsert., tid_vec4, id_vpos, id_vpos_y, id_fragcoord, 1);
1650 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpStorecxx . . $ SpvOpStore., id_var_vpos, id_vpos);
1651 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1652
1653 ctx->spirvcxx . . $ Context#spirv..id_var_fragcoordcxx . . $ SpirvContext#id_var_fragcoord. = id_var_fragcoord;
1654 ctx->spirvcxx . . $ Context#spirv..id_var_vposcxx . . $ SpirvContext#id_var_vpos. = id_var_vpos;
1655 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..vpflipcxx . . $ SpirvPatchTable#vpflip..offsetcxx . . $ SpirvPatchEntry#offset. = spv_output_locationcxx . . $ spv_output_location(a939eba8b1993c99).(ctx, id_var_vposflip, ~0u);
1656 } // spv_emit_vpos_glmode
1657
1658 static void spv_emit_vpos_vkmodecxx . . $ spv_emit_vpos_vkmode(d867d534d1c117ac).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id)
1659 {
1660 // In SM3.0 vPos only has x and y defined, but we should be
1661 // fine to leave the z and w attributes in that
1662 // SpvBuiltInFragCoord gives.
1663
1664 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
1665 uint32cxx . . $ uint32# tid_pvec4i = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Icxx . . $ STI_PTR_VEC4_I.);
1666 uint32cxx . . $ uint32# tid_pvec4p = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Pcxx . . $ STI_PTR_VEC4_P.);
1667
1668 uint32cxx . . $ uint32# id_var_fragcoord = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1669 uint32cxx . . $ uint32# id_var_vpos = id;
1670
1671 uint32cxx . . $ uint32# id_fragcoord = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1672 uint32cxx . . $ uint32# id_vpos = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1673
1674 // vec4 gl_FragCoord = <compiler magic builtin>;
1675 // vec4 ps_vPos = gl_FragCoord;
1676
1677 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
1678 // Define all variables involved.
1679 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4i, id_var_fragcoord, SpvStorageClassInputcxx . . $ SpvStorageClassInput.);
1680 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4p, id_var_vpos, SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate.);
1681 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1682
1683 spv_output_builtincxx . . $ spv_output_builtin(f45776df1a665a6e).(ctx, id_var_fragcoord, SpvBuiltInFragCoordcxx . . $ SpvBuiltInFragCoord.);
1684
1685 // Initialize vPos using built in FragCoord.
1686 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_topcxx . . $ Context#mainline_top.);
1687 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., tid_vec4, id_fragcoord, id_var_fragcoord);
1688 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpStorecxx . . $ SpvOpStore., id_var_vpos, id_fragcoord);
1689 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1690
1691 ctx->spirvcxx . . $ Context#spirv..id_var_fragcoordcxx . . $ SpirvContext#id_var_fragcoord. = id_var_fragcoord;
1692 ctx->spirvcxx . . $ Context#spirv..id_var_vposcxx . . $ SpirvContext#id_var_vpos. = id_var_vpos;
1693 } // spv_emit_vpos_vkmode
1694
1695 static void spv_link_vs_attributescxx . . $ spv_link_vs_attributes(f8cdffb56a4e59).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id,
1696 MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, int index)
1697 {
1698 if (usage == MOJOSHADER_USAGE_POSITIONcxx . . $ MOJOSHADER_USAGE_POSITION. && index == 0)
1699 spv_output_builtincxx . . $ spv_output_builtin(f45776df1a665a6e).(ctx, id, SpvBuiltInPositioncxx . . $ SpvBuiltInPosition.);
1700 else if (usage == MOJOSHADER_USAGE_POINTSIZEcxx . . $ MOJOSHADER_USAGE_POINTSIZE. && index == 0)
1701 {
1702 spv_output_builtincxx . . $ spv_output_builtin(f45776df1a665a6e).(ctx, id, SpvBuiltInPointSizecxx . . $ SpvBuiltInPointSize.);
1703 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..attrib_offsetscxx . . $ SpirvPatchTable#attrib_offsets.[usage][index] = 1;
1704 } // else if
1705 else
1706 spv_output_attrib_locationcxx . . $ spv_output_attrib_location(2c6464f593a9ec59).(ctx, id, usage, index);
1707 } // spv_link_vs_attributes
1708
1709 static void spv_link_ps_attributescxx . . $ spv_link_ps_attributes(79703fd84bf86659).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id, RegisterTypecxx . . $ RegisterType# regtype,
1710 MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, int index)
1711 {
1712 switch (regtype)
1713 {
1714 case REG_TYPE_COLOROUTcxx . . $ REG_TYPE_COLOROUT.:
1715 // Per KHR_glsl_shader:
1716 // The fragment-stage built-in gl_FragColor, which implies a broadcast to all
1717 // outputs, is not present in SPIR-V. Shaders where writing to gl_FragColor
1718 // is allowed can still write to it, but it only means to write to an output:
1719 // - of the same type as gl_FragColor
1720 // - decorated with location 0
1721 // - not decorated as a built-in variable.
1722 // There is no implicit broadcast.
1723 spv_output_color_locationcxx . . $ spv_output_color_location(faac5a9eeb4c548).(ctx, id, index);
1724 break;
1725 case REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.: // v# (MOJOSHADER_USAGE_COLOR aka `oC#` in vertex shader)
1726 spv_output_attrib_locationcxx . . $ spv_output_attrib_location(2c6464f593a9ec59).(ctx, id, usage, index);
1727 break;
1728 case REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE.: // t# (MOJOSHADER_USAGE_TEXCOORD aka `oT#` in vertex shader)
1729 spv_output_attrib_locationcxx . . $ spv_output_attrib_location(2c6464f593a9ec59).(ctx, id, MOJOSHADER_USAGE_TEXCOORDcxx . . $ MOJOSHADER_USAGE_TEXCOORD., index);
1730 break;
1731 case REG_TYPE_DEPTHOUTcxx . . $ REG_TYPE_DEPTHOUT.:
1732 spv_output_builtincxx . . $ spv_output_builtin(f45776df1a665a6e).(ctx, id, SpvBuiltInFragDepthcxx . . $ SpvBuiltInFragDepth.);
1733 ctx->spirvcxx . . $ Context#spirv..hasdepthcxx . . $ SpirvContext#hasdepth. = 1;
1734 break;
1735 case REG_TYPE_MISCTYPEcxx . . $ REG_TYPE_MISCTYPE.:
1736 // inputs
1737 switch ((MiscTypeTypecxx . . $ MiscTypeType#)index)
1738 {
1739 case MISCTYPE_TYPE_POSITIONcxx . . $ MISCTYPE_TYPE_POSITION.: // vPos
1740 {
1741 if (ctx->spirvcxx . . $ Context#spirv..modecxx . . $ SpirvContext#mode. == SPIRV_MODE_GLcxx . . $ SPIRV_MODE_GL.)
1742 spv_emit_vpos_glmodecxx . . $ spv_emit_vpos_glmode(d867d534d1c117ac).(ctx, id);
1743 else
1744 spv_emit_vpos_vkmodecxx . . $ spv_emit_vpos_vkmode(d867d534d1c117ac).(ctx, id);
1745 break;
1746 } // case
1747
1748 case MISCTYPE_TYPE_FACEcxx . . $ MISCTYPE_TYPE_FACE.: // vFace
1749 {
1750 // The much more wordy equivalent of:
1751 // bool gl_FrontFacing = <compiler magic builtin>;
1752 // vec4 vFace;
1753 // vFace = vec4(gl_FrontFacing ? 1.0 : 0.0);
1754
1755 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
1756 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
1757 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
1758 uint32cxx . . $ uint32# tid_pbooli = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_BOOL_Icxx . . $ STI_PTR_BOOL_I.);
1759 uint32cxx . . $ uint32# tid_pvec4p = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Pcxx . . $ STI_PTR_VEC4_P.);
1760
1761 uint32cxx . . $ uint32# id_1_0 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, 1.0f);
1762 uint32cxx . . $ uint32# id_n1_0 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, -1.0f);
1763
1764 uint32cxx . . $ uint32# id_var_frontfacing = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1765 uint32cxx . . $ uint32# id_var_vface = id;
1766
1767 uint32cxx . . $ uint32# id_frontfacing = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1768 uint32cxx . . $ uint32# id_tmp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1769 uint32cxx . . $ uint32# id_vface = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1770
1771 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
1772 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pbooli, id_var_frontfacing, SpvStorageClassInputcxx . . $ SpvStorageClassInput.);
1773 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4p, id_var_vface, SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate.);
1774 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1775
1776 spv_output_builtincxx . . $ spv_output_builtin(f45776df1a665a6e).(ctx, id_var_frontfacing, SpvBuiltInFrontFacingcxx . . $ SpvBuiltInFrontFacing.);
1777
1778 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_topcxx . . $ Context#mainline_top.);
1779 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., tid_bool, id_frontfacing, id_var_frontfacing);
1780 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., tid_float, id_tmp, id_frontfacing, id_1_0, id_n1_0);
1781 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec4, id_vface, id_tmp, id_tmp, id_tmp, id_tmp);
1782 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpStorecxx . . $ SpvOpStore., id_var_vface, id_vface);
1783 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1784
1785 ctx->spirvcxx . . $ Context#spirv..id_var_frontfacingcxx . . $ SpirvContext#id_var_frontfacing. = id_var_frontfacing;
1786 ctx->spirvcxx . . $ Context#spirv..id_var_vfacecxx . . $ SpirvContext#id_var_vface. = id_var_vface;
1787 break;
1788 } // case
1789 } // switch
1790 break;
1791 default:
1792 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown pixel shader attribute register");
1793 } // switch
1794 } // spv_link_ps_attributes
1795
1796 static void spv_texbemcxx . . $ spv_texbem(a15117967af15219).(Contextcxx . . $ Context#* ctx, int luminanceCorrection)
1797 {
1798 DestArgInfocxx . . $ DestArgInfo# *info = &ctx->dest_argcxx . . $ Context#dest_arg.;
1799 uint32cxx . . $ uint32# sampler_idx = info->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.;
1800 RegisterListcxx . . $ RegisterList# *pSReg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., sampler_idx);
1801 RegisterListcxx . . $ RegisterList# *pSrc = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
1802 RegisterListcxx . . $ RegisterList# *pDst = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, info->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., sampler_idx);
1803
1804 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1805
1806 SpirvResultcxx . . $ SpirvResult# sampler = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSReg);
1807 SpirvResultcxx . . $ SpirvResult# src0 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc);
1808 SpirvResultcxx . . $ SpirvResult# src1 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pDst);
1809
1810 // <dst> = texture(
1811 // <sampler>,
1812 // vec2(
1813 // (<sampler>_texbem.x * <src0>.x) + (<sampler>_texbem.z * <src0>.y) + <src1>.x,
1814 // (<sampler>_texbem.y * <src0>.x) + (<sampler>_texbem.w * <src0>.y) + <src1>.y
1815 // )
1816 // );
1817
1818 // Load 2x2 transform matrix from uniform data (stored as vec4).
1819 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sampler_idx < 4);
1820 uint32cxx . . $ uint32# id_offset = ctx->spirvcxx . . $ Context#spirv..sampler_extrascxx . . $ SpirvContext#sampler_extras.[sampler_idx].idtexbemcxx . . $ SpirvContext#$anonymous_type_4#idtexbem.;
1821 if (!id_offset)
1822 {
1823 id_offset = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1824 ctx->spirvcxx . . $ Context#spirv..sampler_extrascxx . . $ SpirvContext#sampler_extras.[sampler_idx].idtexbemcxx . . $ SpirvContext#$anonymous_type_4#idtexbem. = id_offset;
1825 } // if
1826 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
1827 uint32cxx . . $ uint32# id_pmatrix = spv_access_uniformcxx . . $ spv_access_uniform(353dd63a86b7a3c5).(ctx, STI_PTR_VEC4_Ucxx . . $ STI_PTR_VEC4_U., REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST., id_offset);
1828 SpirvResultcxx . . $ SpirvResult# matrix;
1829 matrix.tidcxx . . $ SpirvResult#tid. = tid_vec4;
1830 matrix.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1831 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., matrix.tidcxx . . $ SpirvResult#tid., matrix.idcxx . . $ SpirvResult#id., id_pmatrix);
1832
1833 // transform src0 using matrix and translate result using src1
1834 // ie. src0 * matrix + src1
1835 SpirvResultcxx . . $ SpirvResult# matrix_xy = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, matrix, 0x4, 0x3);
1836 SpirvResultcxx . . $ SpirvResult# matrix_zw = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, matrix, 0xE, 0x3);
1837 SpirvResultcxx . . $ SpirvResult# src0_xx = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, src0, 0x0, 0x3);
1838 SpirvResultcxx . . $ SpirvResult# src0_yy = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, src0, 0x5, 0x3);
1839 SpirvResultcxx . . $ SpirvResult# src1_xy = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, src1, 0x4, 0x3);
1840 uint32cxx . . $ uint32# tid_vec2 = src0_xx.tidcxx . . $ SpirvResult#tid.;
1841 uint32cxx . . $ uint32# id_a = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1842 uint32cxx . . $ uint32# id_b = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1843 uint32cxx . . $ uint32# id_c = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1844 uint32cxx . . $ uint32# id_d = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1845 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_vec2, id_a, matrix_xy.idcxx . . $ SpirvResult#id., src0_xx.idcxx . . $ SpirvResult#id.);
1846 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_vec2, id_b, matrix_zw.idcxx . . $ SpirvResult#id., src0_yy.idcxx . . $ SpirvResult#id.);
1847 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFAddcxx . . $ SpvOpFAdd., tid_vec2, id_c, id_a, id_b);
1848 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFAddcxx . . $ SpvOpFAdd., tid_vec2, id_d, id_c, src1_xy.idcxx . . $ SpirvResult#id.);
1849
1850 // sample texture
1851 SpirvResultcxx . . $ SpirvResult# result;
1852 result.tidcxx . . $ SpirvResult#tid. = tid_vec4;
1853 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1854 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpImageSampleImplicitLodcxx . . $ SpvOpImageSampleImplicitLod., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., sampler.idcxx . . $ SpirvResult#id., id_d);
1855 if (luminanceCorrection)
1856 {
1857 uint32cxx . . $ uint32# id_l_offset = ctx->spirvcxx . . $ Context#spirv..sampler_extrascxx . . $ SpirvContext#sampler_extras.[sampler_idx].idtexbemlcxx . . $ SpirvContext#$anonymous_type_4#idtexbeml.;
1858 if (!id_l_offset)
1859 {
1860 id_l_offset = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1861 ctx->spirvcxx . . $ Context#spirv..sampler_extrascxx . . $ SpirvContext#sampler_extras.[sampler_idx].idtexbemlcxx . . $ SpirvContext#$anonymous_type_4#idtexbeml. = id_l_offset;
1862 } // if
1863
1864 // <dst> = <dst> * ((<src0>.z * <sampler>_texbeml.x) + <sampler>_texbeml.y)
1865 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
1866
1867 SpirvResultcxx . . $ SpirvResult# src0_z = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, src0, 0x2, 0x1);
1868 uint32cxx . . $ uint32# id_l_ptr = spv_access_uniformcxx . . $ spv_access_uniform(353dd63a86b7a3c5).(ctx, STI_PTR_VEC4_Ucxx . . $ STI_PTR_VEC4_U., REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST., id_l_offset);
1869
1870 SpirvResultcxx . . $ SpirvResult# l;
1871 l.tidcxx . . $ SpirvResult#tid. = tid_vec4;
1872 l.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1873
1874 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., l.tidcxx . . $ SpirvResult#tid., l.idcxx . . $ SpirvResult#id., id_l_ptr);
1875
1876 SpirvResultcxx . . $ SpirvResult# l_x = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, l, 0x0, 0x1);
1877 SpirvResultcxx . . $ SpirvResult# l_y = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, l, 0x1, 0x1);
1878 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(tid_float == l_x.tid);
1879 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(tid_float == l_y.tid);
1880 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(tid_float == src0_z.tid);
1881
1882 uint32cxx . . $ uint32# id_e = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1883 uint32cxx . . $ uint32# id_f = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1884 uint32cxx . . $ uint32# id_ffff = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1885 uint32cxx . . $ uint32# id_new = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1886 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_float, id_e, src0_z.idcxx . . $ SpirvResult#id., l_x.idcxx . . $ SpirvResult#id.);
1887 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFAddcxx . . $ SpvOpFAdd., tid_float, id_f, id_e, l_y.idcxx . . $ SpirvResult#id.);
1888 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec4, id_ffff,
1889 id_f, id_f, id_f, id_f
1890 );
1891 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_vec4, id_new, result.idcxx . . $ SpirvResult#id., id_ffff);
1892 result.idcxx . . $ SpirvResult#id. = id_new;
1893 } // if
1894
1895 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1896
1897 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
1898 }
1899
1900 void emit_SPIRV_startcxx . . $ emit_SPIRV_start(72ff1ec6cf40f147).(Contextcxx . . $ Context# *ctx, const char *profilestr)
1901 {
1902 if (!(shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx) || shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)))
1903 {
1904 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Shader type %u unsupported in this profile.",
1905 (uintcxx . . $ uint#) ctx->shader_typecxx . . $ Context#shader_type.);
1906 return;
1907 } // if
1908
1909 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&(ctx->spirvcxx . . $ Context#spirv.), '\0', sizeof(ctx->spirvcxx . . $ Context#spirv.));
1910
1911 #if SUPPORT_PROFILE_GLSPIRVcxx . . $ `mojoshader_internal.h:214:9`!
1912 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profilestr, MOJOSHADER_PROFILE_GLSPIRVcxx . . $ `mojoshader.h:753:9`!) == 0)
1913 {
1914 ctx->profile_supports_glspirvcxx . . $ Context#profile_supports_glspirv. = 1;
1915 ctx->spirvcxx . . $ Context#spirv..modecxx . . $ SpirvContext#mode. = SPIRV_MODE_GLcxx . . $ SPIRV_MODE_GL.;
1916 } // if
1917 else
1918 #endif // SUPPORT_PROFILE_GLSPIRV
1919 {
1920 ctx->spirvcxx . . $ Context#spirv..modecxx . . $ SpirvContext#mode. = SPIRV_MODE_VKcxx . . $ SPIRV_MODE_VK.;
1921 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(profilestr, MOJOSHADER_PROFILE_SPIRVcxx . . $ `mojoshader.h:748:9`!) != 0)
1922 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Profile '%s' unsupported or unknown.", profilestr);
1923 } // else
1924
1925 ctx->spirvcxx . . $ Context#spirv..idmaincxx . . $ SpirvContext#idmain. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1926
1927 // calls spv_getvoid as well
1928 uint32cxx . . $ uint32# tid_void = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VOIDcxx . . $ STI_VOID.);
1929 uint32cxx . . $ uint32# tid_func = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FUNC_VOIDcxx . . $ STI_FUNC_VOID.);
1930
1931 // slap the function declaration itself in mainline_top, so we can do type
1932 // declaration in mainline_intro (= before this in the output)
1933 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_topcxx . . $ Context#mainline_top.);
1934 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFunctioncxx . . $ SpvOpFunction., tid_void, ctx->spirvcxx . . $ Context#spirv..idmaincxx . . $ SpirvContext#idmain., SpvFunctionControlMaskNonecxx . . $ SpvFunctionControlMaskNone., tid_func);
1935 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx));
1936 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1937
1938 // also emit the name for the function
1939 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, ctx->spirvcxx . . $ Context#spirv..idmaincxx . . $ SpirvContext#idmain., ctx->mainfncxx . . $ Context#mainfn.);
1940
1941 set_outputcxx . . $ set_output(dbab56076057d0b7).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
1942 } // emit_SPIRV_start
1943
1944 void emit_SPIRV_endcxx . . $ emit_SPIRV_end(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1945 {
1946 if (ctx->previous_opcodecxx . . $ Context#previous_opcode. != OPCODE_RETcxx . . $ `mojoshader_internal.h:462:9`!)
1947 spv_emit_func_endcxx . . $ spv_emit_func_end(612dd59919e2530e).(ctx);
1948 } // emit_SPIRV_end
1949
1950 void emit_SPIRV_phasecxx . . $ emit_SPIRV_phase(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
1951 {
1952 // no-op
1953 } // emit_SPIRV_phase
1954
1955 void emit_SPIRV_globalcxx . . $ emit_SPIRV_global(8475323e8d0fe52d).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum)
1956 {
1957 RegisterListcxx . . $ RegisterList# *r = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->used_registerscxx . . $ Context#used_registers., regtype, regnum);
1958
1959 SpvStorageClasscxx . . $ SpvStorageClass# sc = SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate.;
1960 uint32cxx . . $ uint32# tid = 0;
1961 switch (regtype)
1962 {
1963 case REG_TYPE_LABELcxx . . $ REG_TYPE_LABEL.:
1964 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "unimplemented regtype %d", regtype);
1965 return;
1966
1967 case REG_TYPE_LOOPcxx . . $ REG_TYPE_LOOP.:
1968 // Using SSA id to represent loop counters, instead of a variable.
1969 return;
1970
1971 case REG_TYPE_PREDICATEcxx . . $ REG_TYPE_PREDICATE.:
1972 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_BVEC4_Pcxx . . $ STI_PTR_BVEC4_P.);
1973 break;
1974
1975 case REG_TYPE_ADDRESScxx . . $ REG_TYPE_ADDRESS.:
1976 if (shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx))
1977 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_IVEC4_Pcxx . . $ STI_PTR_IVEC4_P.);
1978 else if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx)) // actually REG_TYPE_TEXTURE
1979 {
1980 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4))
1981 {
1982 // ps_1_1 texture/address registers work like temporaries. They are initialized
1983 // with tex coords and TEX instruction then reads tex coords from it and writes
1984 // sampling result back into it. Because Input storage class is read-only, we
1985 // create private variable that is initialized to value of input.
1986
1987 uint32cxx . . $ uint32# tid_pvec4_i = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Icxx . . $ STI_PTR_VEC4_I.);
1988 uint32cxx . . $ uint32# tid_pvec4_p = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Pcxx . . $ STI_PTR_VEC4_P.);
1989 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
1990 uint32cxx . . $ uint32# id_input_var = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1991 uint32cxx . . $ uint32# id_private_var = r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
1992 uint32cxx . . $ uint32# id_tmp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
1993
1994 // Create one Input and one Private variable. Input variable is linked to prev stage.
1995 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
1996 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4_i, id_input_var, SpvStorageClassInputcxx . . $ SpvStorageClassInput.);
1997 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4_p, id_private_var, SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate.);
1998 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
1999 spv_link_ps_attributescxx . . $ spv_link_ps_attributes(79703fd84bf86659).(ctx, id_input_var, regtype, MOJOSHADER_USAGE_TEXCOORDcxx . . $ MOJOSHADER_USAGE_TEXCOORD., regnum);
2000
2001 // Initialize Private variable with Input variable.
2002 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_topcxx . . $ Context#mainline_top.);
2003 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., tid_vec4, id_tmp, id_input_var);
2004 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpStorecxx . . $ SpvOpStore., id_private_var, id_tmp);
2005 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2006
2007 // TEX instruction have already been emitted that work with Private variable.
2008
2009 // Overwrite Private variable with Input variable, so emit_SPIRV_finalize outputs
2010 // OpEntryPoint with correct references to Input and Output variables.
2011 ctx->spirvcxx . . $ Context#spirv..id_implicit_inputcxx . . $ SpirvContext#id_implicit_input.[regnum] = id_input_var;
2012 r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = id_input_var;
2013 spv_output_regnamecxx . . $ spv_output_regname(ae7757ab60d819c8).(ctx, id_input_var, regtype, regnum);
2014 return;
2015 } // if
2016 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Pcxx . . $ STI_PTR_VEC4_P.);
2017 } // else if
2018 break;
2019
2020 case REG_TYPE_TEMPcxx . . $ REG_TYPE_TEMP.:
2021 if (regnum == 0 && shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx) && !shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 2, 0))
2022 {
2023 // Value of r0 is at the end of shader execution is color output.
2024 sc = SpvStorageClassOutputcxx . . $ SpvStorageClassOutput.;
2025 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Ocxx . . $ STI_PTR_VEC4_O.);
2026 }
2027 else
2028 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Pcxx . . $ STI_PTR_VEC4_P.);
2029 break;
2030
2031 default:
2032 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: Unexpected regtype in emit_SPIRV_global");
2033 return;
2034 } // switch
2035
2036 // TODO: If the SSA id for this register is still 0 by this point, that
2037 // means no instructions actually loaded from/stored to this variable...
2038
2039 if (r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. == 0)
2040 r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2041
2042 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2043 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., sc);
2044 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2045
2046 spv_output_regnamecxx . . $ spv_output_regname(ae7757ab60d819c8).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., regtype, regnum);
2047 } // emit_SPIRV_global
2048
2049 void emit_SPIRV_arraycxx . . $ emit_SPIRV_array(4368dce1b98e99b8).(Contextcxx . . $ Context# *ctx, VariableListcxx . . $ VariableList# *var)
2050 {
2051 var->emit_positioncxx . . $ VariableList#emit_position. = ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count.;
2052 } // emit_SPIRV_array
2053
2054 void emit_SPIRV_const_arraycxx . . $ emit_SPIRV_const_array(36ee158898c90b50).(Contextcxx . . $ Context# *ctx,
2055 const struct ConstantsListcxx . . $ ConstantsList# *clist,
2056 int base, int size)
2057 {
2058 int i;
2059
2060 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->spirv.constant_arrays.idvec4 != 0);
2061
2062 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2063
2064 // FIXME: This code potentially duplicates constants defined using DEF ops.
2065 // FIXME: Multiple constant arrays probably won't work. Are those even possible?
2066 // Maybe it would be better to do this in emit_SPIRV_finalize and use used_registers for it?
2067 uint32cxx . . $ uint32# *constituents = (uint32cxx . . $ uint32# *)Malloccxx . . $ Malloc(a6ec60c25fe5143e).(ctx, size * sizeof(uint32cxx . . $ uint32#));
2068 uint32cxx . . $ uint32# tid_constituent = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2069 for (i = 0; i < size; i++)
2070 {
2071 while (clist->constantcxx . . $ ConstantsList#constant..typecxx . . $ MOJOSHADER_constant#type. != MOJOSHADER_UNIFORM_FLOATcxx . . $ MOJOSHADER_UNIFORM_FLOAT.)
2072 clist = clist->nextcxx . . $ ConstantsList#next.;
2073 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(clist->constant.index == (base + i));
2074
2075 uint32cxx . . $ uint32# id_x = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, clist->constantcxx . . $ ConstantsList#constant..valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.[0]);
2076 uint32cxx . . $ uint32# id_y = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, clist->constantcxx . . $ ConstantsList#constant..valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.[1]);
2077 uint32cxx . . $ uint32# id_z = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, clist->constantcxx . . $ ConstantsList#constant..valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.[2]);
2078 uint32cxx . . $ uint32# id_w = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, clist->constantcxx . . $ ConstantsList#constant..valuecxx . . $ MOJOSHADER_constant#value..fcxx . . $ MOJOSHADER_constant#$anonymous_type_3#f.[3]);
2079
2080 uint32cxx . . $ uint32# id = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2081 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpConstantCompositecxx . . $ SpvOpConstantComposite., tid_constituent, id, id_x, id_y, id_z, id_w);
2082 constituents[i] = id;
2083
2084 clist = clist->nextcxx . . $ ConstantsList#next.;
2085 } // for
2086
2087 uint32cxx . . $ uint32# id_array_len = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, size);
2088
2089 uint32cxx . . $ uint32# tid_array = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2090 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypeArraycxx . . $ SpvOpTypeArray., tid_array, tid_constituent, id_array_len);
2091
2092 uint32cxx . . $ uint32# id_array = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2093 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 3+size, 3, SpvOpConstantCompositecxx . . $ SpvOpConstantComposite., tid_array, id_array);
2094 for (i = 0; i < size; i++)
2095 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, constituents[i]);
2096
2097 uint32cxx . . $ uint32# tid_parray = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2098 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypePointercxx . . $ SpvOpTypePointer., tid_parray, SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate., tid_array);
2099
2100 uint32cxx . . $ uint32# id_array_var = ctx->spirvcxx . . $ Context#spirv..constant_arrayscxx . . $ SpirvContext#constant_arrays..idvec4cxx . . $ SpirvContext#$anonymous_type_2#idvec4.;
2101 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpVariablecxx . . $ SpvOpVariable., tid_parray, id_array_var, SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate., id_array);
2102
2103 Freecxx . . $ Free(b86e3b3d45e44ecf).(ctx, constituents);
2104 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2105 } // emit_SPIRV_const_array
2106
2107 void emit_SPIRV_uniformcxx . . $ emit_SPIRV_uniform(8b79ccde41759557).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum,
2108 const VariableListcxx . . $ VariableList# *var)
2109 {
2110 RegisterListcxx . . $ RegisterList# *r = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->uniformscxx . . $ Context#uniforms., regtype, regnum);
2111
2112 // TODO: If the SSA id for this register is still 0 by this point, that means no instructions actually
2113 // loaded from/stored to this variable...
2114
2115 if (r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. == 0)
2116 r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2117
2118 if (var == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
2119 {
2120 uint32cxx . . $ uint32# tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
2121 int offset = 0;
2122 switch (regtype)
2123 {
2124 case REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST.:
2125 offset = ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count.;
2126 break;
2127
2128 case REG_TYPE_CONSTINTcxx . . $ REG_TYPE_CONSTINT.:
2129 offset = ctx->uniform_int4_countcxx . . $ Context#uniform_int4_count.;
2130 break;
2131
2132 case REG_TYPE_CONSTBOOLcxx . . $ REG_TYPE_CONSTBOOL.:
2133 offset = ctx->uniform_bool_countcxx . . $ Context#uniform_bool_count.;
2134 break;
2135
2136 default:
2137 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "BUG: used a uniform we don't know how to define.");
2138 return;
2139 } // switch
2140
2141 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2142 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConstantcxx . . $ SpvOpConstant., tid, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., offset);
2143 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2144
2145 char varname[64];
2146 get_SPIRV_varname_in_bufcxx . . $ get_SPIRV_varname_in_buf(e11e601b5c61efa5).(ctx, regtype, regnum, varname, sizeof(varname));
2147 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., varname);
2148 } // if
2149 else
2150 {
2151 if (var->constantcxx . . $ VariableList#constant.)
2152 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "const array not implemented");
2153 else
2154 {
2155 // Instructions needed to reference this constant before its value was known, so unique
2156 // id had to be generated. Unfortunately, this prevents reusing already emitted
2157 // constants.
2158 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(var->emit_position != -1);
2159 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2160 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConstantcxx . . $ SpvOpConstant., spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.), r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., var->emit_positioncxx . . $ VariableList#emit_position.);
2161 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2162
2163 char varname[64];
2164 get_SPIRV_varname_in_bufcxx . . $ get_SPIRV_varname_in_buf(e11e601b5c61efa5).(ctx, regtype, regnum, varname, sizeof(varname));
2165 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., varname);
2166 } // else
2167 } // else
2168 } // emit_SPIRV_uniform
2169
2170 void emit_SPIRV_samplercxx . . $ emit_SPIRV_sampler(a3a55aa9b8aa8087).(Contextcxx . . $ Context# *ctx, int stage, TextureTypecxx . . $ TextureType# ttype, int texbem)
2171 {
2172 uint32cxx . . $ uint32# type = spv_ptrimage_from_texturetypecxx . . $ spv_ptrimage_from_texturetype(ee3c21e30514eb7d).(ctx, ttype);
2173
2174 RegisterListcxx . . $ RegisterList# *sampler_reg;
2175 // Pre ps_2_0 samplers were not dcl-ed, so we won't find them using spv_getreg().
2176 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx) && !shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 2, 0))
2177 sampler_reg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., stage);
2178 else
2179 sampler_reg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., stage);
2180
2181 uint32cxx . . $ uint32# result = sampler_reg->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
2182
2183 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2184 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., type, result, SpvStorageClassUniformConstantcxx . . $ SpvStorageClassUniformConstant.);
2185 if (texbem) // This sampler used a ps_1_1 TEXBEM opcode?
2186 {
2187 uint32cxx . . $ uint32# tid_int = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
2188 uint32cxx . . $ uint32# id_texbem = ctx->spirvcxx . . $ Context#spirv..sampler_extrascxx . . $ SpirvContext#sampler_extras.[stage].idtexbemcxx . . $ SpirvContext#$anonymous_type_4#idtexbem.;
2189 uint32cxx . . $ uint32# id_texbeml = ctx->spirvcxx . . $ Context#spirv..sampler_extrascxx . . $ SpirvContext#sampler_extras.[stage].idtexbemlcxx . . $ SpirvContext#$anonymous_type_4#idtexbeml.;
2190 const int offset = ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count.;
2191 ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count. += 2;
2192 if (id_texbem)
2193 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConstantcxx . . $ SpvOpConstant., tid_int, id_texbem, offset);
2194 if (id_texbeml)
2195 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConstantcxx . . $ SpvOpConstant., tid_int, id_texbeml, offset + 1);
2196 } // if
2197 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2198
2199 // hnn: specify uniform location for SPIR-V shaders (required per gl_arb_spirv spec)
2200 spv_output_sampler_bindingcxx . . $ spv_output_sampler_binding(faac5a9eeb4c548).(ctx, result, sampler_reg->regnumcxx . . $ RegisterList#regnum.);
2201
2202 if (ctx->spirvcxx . . $ Context#spirv..modecxx . . $ SpirvContext#mode. == SPIRV_MODE_GLcxx . . $ SPIRV_MODE_GL.)
2203 {
2204 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sampler_reg->regnum < STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(ctx->spirv.patch_table.samplers));
2205 uint32cxx . . $ uint32# location_offset = spv_output_locationcxx . . $ spv_output_location(a939eba8b1993c99).(ctx, result, ~0u);
2206 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..samplerscxx . . $ SpirvPatchTable#samplers.[sampler_reg->regnumcxx . . $ RegisterList#regnum.].offsetcxx . . $ SpirvPatchEntry#offset. = location_offset;
2207 }
2208
2209 spv_output_regnamecxx . . $ spv_output_regname(ae7757ab60d819c8).(ctx, result, REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., stage);
2210 } // emit_SPIRV_sampler
2211
2212 void emit_SPIRV_attributecxx . . $ emit_SPIRV_attribute(cc51a07b10397b54).(Contextcxx . . $ Context# *ctx, RegisterTypecxx . . $ RegisterType# regtype, int regnum,
2213 MOJOSHADER_usagecxx . . $ MOJOSHADER_usage# usage, int index, int wmask,
2214 int flags)
2215 {
2216 uint32cxx . . $ uint32# tid;
2217 RegisterListcxx . . $ RegisterList# *r = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, regtype, regnum);
2218
2219 ctx->spirvcxx . . $ Context#spirv..inoutcountcxx . . $ SpirvContext#inoutcount. += 1;
2220
2221 spv_output_regnamecxx . . $ spv_output_regname(ae7757ab60d819c8).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., regtype, regnum);
2222
2223 if (shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx))
2224 {
2225 // pre-vs3 output registers.
2226 // these don't ever happen in DCL opcodes, I think. Map to vs_3_*
2227 // output registers.
2228 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 3, 0))
2229 {
2230 if (regtype == REG_TYPE_RASTOUTcxx . . $ REG_TYPE_RASTOUT.)
2231 {
2232 regtype = REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.;
2233 index = regnum;
2234 switch ((const RastOutTypecxx . . $ RastOutType#) regnum)
2235 {
2236 case RASTOUT_TYPE_POSITIONcxx . . $ RASTOUT_TYPE_POSITION.:
2237 usage = MOJOSHADER_USAGE_POSITIONcxx . . $ MOJOSHADER_USAGE_POSITION.;
2238 break;
2239 case RASTOUT_TYPE_FOGcxx . . $ RASTOUT_TYPE_FOG.:
2240 usage = MOJOSHADER_USAGE_FOGcxx . . $ MOJOSHADER_USAGE_FOG.;
2241 break;
2242 case RASTOUT_TYPE_POINT_SIZEcxx . . $ RASTOUT_TYPE_POINT_SIZE.:
2243 usage = MOJOSHADER_USAGE_POINTSIZEcxx . . $ MOJOSHADER_USAGE_POINTSIZE.;
2244 break;
2245 } // switch
2246 } // if
2247
2248 else if (regtype == REG_TYPE_ATTROUTcxx . . $ REG_TYPE_ATTROUT.)
2249 {
2250 regtype = REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.;
2251 usage = MOJOSHADER_USAGE_COLORcxx . . $ MOJOSHADER_USAGE_COLOR.;
2252 index = regnum;
2253 } // else if
2254
2255 else if (regtype == REG_TYPE_TEXCRDOUTcxx . . $ REG_TYPE_TEXCRDOUT.)
2256 {
2257 regtype = REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.;
2258 usage = MOJOSHADER_USAGE_TEXCOORDcxx . . $ MOJOSHADER_USAGE_TEXCOORD.;
2259 index = regnum;
2260 } // else if
2261 } // if
2262 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(r->usage == MOJOSHADER_USAGE_UNKNOWN);
2263 r->usagecxx . . $ RegisterList#usage. = usage;
2264
2265 switch (regtype)
2266 {
2267 case REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.:
2268 {
2269 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..tid_vec4_pcxx . . $ SpirvPatchTable#tid_vec4_p. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Icxx . . $ STI_PTR_VEC4_I.);
2270 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..tid_ivec4_pcxx . . $ SpirvPatchTable#tid_ivec4_p. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_IVEC4_Icxx . . $ STI_PTR_IVEC4_I.);
2271 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..tid_uvec4_pcxx . . $ SpirvPatchTable#tid_uvec4_p. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_UVEC4_Icxx . . $ STI_PTR_UVEC4_I.);
2272 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..tid_vec4cxx . . $ SpirvPatchTable#tid_vec4. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2273 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..tid_ivec4cxx . . $ SpirvPatchTable#tid_ivec4. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IVEC4cxx . . $ STI_IVEC4.);
2274 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..tid_uvec4cxx . . $ SpirvPatchTable#tid_uvec4. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_UVEC4cxx . . $ STI_UVEC4.);
2275
2276 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2277 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Icxx . . $ STI_PTR_VEC4_I.);
2278 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., SpvStorageClassInputcxx . . $ SpvStorageClassInput.);
2279 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2280
2281 ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..attrib_type_offsetscxx . . $ SpirvPatchTable#attrib_type_offsets.[usage][index] = (buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->mainline_introcxx . . $ Context#mainline_intro.) >> 2) - 3;
2282
2283 // hnn: generate location decorators for the input
2284 spv_output_locationcxx . . $ spv_output_location(a939eba8b1993c99).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., regnum);
2285 break;
2286 }
2287
2288 case REG_TYPE_OUTPUTcxx . . $ REG_TYPE_OUTPUT.:
2289 {
2290 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2291 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti = STI_PTR_VEC4_Ocxx . . $ STI_PTR_VEC4_O.;
2292 if (usage == MOJOSHADER_USAGE_POINTSIZEcxx . . $ MOJOSHADER_USAGE_POINTSIZE.
2293 || usage == MOJOSHADER_USAGE_FOGcxx . . $ MOJOSHADER_USAGE_FOG.)
2294 {
2295 sti = STI_PTR_FLOAT_Ocxx . . $ STI_PTR_FLOAT_O.;
2296 } // if
2297
2298 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, sti);
2299 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., SpvStorageClassOutputcxx . . $ SpvStorageClassOutput.);
2300 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2301
2302 spv_link_vs_attributescxx . . $ spv_link_vs_attributes(f8cdffb56a4e59).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., usage, index);
2303 break;
2304 } // case
2305
2306 default:
2307 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown vertex shader attribute register");
2308 } // switch
2309 } // if
2310
2311 else if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))
2312 {
2313 // samplers DCLs get handled in emit_SPIRV_sampler().
2314
2315 if (flags & MOD_CENTROIDcxx . . $ `mojoshader_internal.h:505:9`!) // !!! FIXME
2316 {
2317 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "centroid unsupported in %s profile", ctx->profilecxx . . $ Context#profile.->namecxx . . $ Profile#name.);
2318 return;
2319 } // if
2320
2321 switch (regtype)
2322 {
2323 case REG_TYPE_COLOROUTcxx . . $ REG_TYPE_COLOROUT.:
2324 spv_link_ps_attributescxx . . $ spv_link_ps_attributes(79703fd84bf86659).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., regtype, usage, regnum);
2325 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2326 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Ocxx . . $ STI_PTR_VEC4_O.);
2327 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., SpvStorageClassOutputcxx . . $ SpvStorageClassOutput.);
2328 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2329 break;
2330 case REG_TYPE_DEPTHOUTcxx . . $ REG_TYPE_DEPTHOUT.:
2331 // maps to BuiltIn FragDepth
2332 spv_link_ps_attributescxx . . $ spv_link_ps_attributes(79703fd84bf86659).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., regtype, usage, index);
2333 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2334 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_FLOAT_Ocxx . . $ STI_PTR_FLOAT_O.);
2335 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., SpvStorageClassOutputcxx . . $ SpvStorageClassOutput.);
2336 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2337 break;
2338 case REG_TYPE_MISCTYPEcxx . . $ REG_TYPE_MISCTYPE.:
2339 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!((MiscTypeType)regnum == MISCTYPE_TYPE_FACE || (MiscTypeType)regnum == MISCTYPE_TYPE_POSITION);
2340 // SpvBuiltInFrontFacing is a input bool, and for the DX bytecode
2341 // we need to map it to a float that's either -1.0 or 1.0.
2342 // SpvBuiltInFragCoord needs to be modified using vposFlip uniform
2343 // to match vPos.
2344 // Both of these take place in spv_link_ps_attributes() so don't
2345 // create an input variable for it here.
2346 spv_link_ps_attributescxx . . $ spv_link_ps_attributes(79703fd84bf86659).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., regtype, usage, regnum);
2347 break;
2348
2349 case REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE.:
2350 case REG_TYPE_INPUTcxx . . $ REG_TYPE_INPUT.:
2351 // ps_1_1 is dealt with in emit_SPIRV_global().
2352 if (usage != MOJOSHADER_USAGE_TEXCOORDcxx . . $ MOJOSHADER_USAGE_TEXCOORD. || shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4))
2353 {
2354 if (usage == MOJOSHADER_USAGE_TEXCOORDcxx . . $ MOJOSHADER_USAGE_TEXCOORD. && index == 0)
2355 {
2356 // This can be either BuiltInPointCoord (vec2) or normal TEXCOORD0 input (vec4).
2357 // To determine correct type, we need to wait until link-time when we can see
2358 // vertex shader outputs and then patch in correct types. To avoid having to
2359 // fix all loads from the input variable, we never access it directly, but
2360 // instead go through private variable that is always vec4.
2361 // Here we generate input and private variables and helper code that gets
2362 // patched at link-time. See SpirvPatchTable for details on patching.
2363 SpirvPatchTablecxx . . $ SpirvPatchTable#* table = &ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table.;
2364
2365 uint32cxx . . $ uint32# tid_pvec2i = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC2_Icxx . . $ STI_PTR_VEC2_I.);
2366 uint32cxx . . $ uint32# tid_pvec4i = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Icxx . . $ STI_PTR_VEC4_I.);
2367 uint32cxx . . $ uint32# tid_pvec4p = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Pcxx . . $ STI_PTR_VEC4_P.);
2368 uint32cxx . . $ uint32# tid_vec2 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC2cxx . . $ STI_VEC2.);
2369 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2370
2371 table->tid_pvec2icxx . . $ SpirvPatchTable#tid_pvec2i. = tid_pvec2i;
2372 table->tid_vec2cxx . . $ SpirvPatchTable#tid_vec2. = tid_vec2;
2373 table->tid_pvec4icxx . . $ SpirvPatchTable#tid_pvec4i. = tid_pvec4i;
2374 table->tid_vec4cxx . . $ SpirvPatchTable#tid_vec4. = tid_vec4;
2375
2376 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2377 ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_privatecxx . . $ SpirvContext#id_var_texcoord0_private. = r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
2378 ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_inputcxx . . $ SpirvContext#id_var_texcoord0_input. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2379 table->pointcoord_var_offsetcxx . . $ SpirvPatchTable#pointcoord_var_offset. = buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->mainline_introcxx . . $ Context#mainline_intro.) >> 2;
2380 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4i, ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_inputcxx . . $ SpirvContext#id_var_texcoord0_input., SpvStorageClassInputcxx . . $ SpvStorageClassInput.);
2381 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pvec4p, ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_privatecxx . . $ SpirvContext#id_var_texcoord0_private., SpvStorageClassPrivatecxx . . $ SpvStorageClassPrivate.);
2382 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2383
2384 spv_link_ps_attributescxx . . $ spv_link_ps_attributes(79703fd84bf86659).(ctx, ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_inputcxx . . $ SpirvContext#id_var_texcoord0_input., regtype, usage, index);
2385 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_inputcxx . . $ SpirvContext#id_var_texcoord0_input., "ps_PointCoordOrTexCoord0");
2386
2387 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_topcxx . . $ Context#mainline_top.);
2388 uint32cxx . . $ uint32# id_loaded = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2389 uint32cxx . . $ uint32# id_shuffled = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2390 table->pointcoord_load_offsetcxx . . $ SpirvPatchTable#pointcoord_load_offset. = buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->mainline_topcxx . . $ Context#mainline_top.) >> 2;
2391 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoadcxx . . $ SpvOpLoad., tid_vec4, id_loaded, ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_inputcxx . . $ SpirvContext#id_var_texcoord0_input.);
2392 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 9, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec4, id_shuffled, id_loaded, id_loaded, 0, 1, 2, 3);
2393 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpStorecxx . . $ SpvOpStore., ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_privatecxx . . $ SpirvContext#id_var_texcoord0_private., id_shuffled);
2394 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2395 } // if
2396 else
2397 {
2398 spv_link_ps_attributescxx . . $ spv_link_ps_attributes(79703fd84bf86659).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., regtype, usage, index);
2399 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2400 tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_PTR_VEC4_Icxx . . $ STI_PTR_VEC4_I.);
2401 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., SpvStorageClassInputcxx . . $ SpvStorageClassInput.);
2402 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2403 } // else
2404 } // if
2405 break;
2406 default:
2407 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "unknown pixel shader attribute register");
2408 } // switch
2409 } // else if
2410
2411 else
2412 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "Unknown shader type"); // state machine should catch this.
2413 } // emit_SPIRV_attribute
2414
2415 static void spv_emit_uniform_constant_arraycxx . . $ spv_emit_uniform_constant_array(1c5beb42ceba24fe).(Contextcxx . . $ Context# *ctx,
2416 const RegisterTypecxx . . $ RegisterType# regtype,
2417 const int size, uint32cxx . . $ uint32# id_var,
2418 uint32cxx . . $ uint32# id_type_base,
2419 uint32cxx . . $ uint32#* dst_location_offset)
2420 {
2421 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(size > 0);
2422 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(id_var != 0);
2423 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->spirv.mode == SPIRV_MODE_GL);
2424
2425 uint32cxx . . $ uint32# id_size = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, size);
2426 uint32cxx . . $ uint32# id_type = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2427 uint32cxx . . $ uint32# id_type_ptr = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2428 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2429 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypeArraycxx . . $ SpvOpTypeArray., id_type, id_type_base, id_size);
2430 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypePointercxx . . $ SpvOpTypePointer., id_type_ptr, SpvStorageClassUniformConstantcxx . . $ SpvStorageClassUniformConstant., id_type);
2431 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., id_type_ptr, id_var, SpvStorageClassUniformConstantcxx . . $ SpvStorageClassUniformConstant.);
2432 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2433
2434 char buf[64];
2435 spv_get_uniform_array_varnamecxx . . $ spv_get_uniform_array_varname(c3e577f4fac3a123).(ctx, regtype, buf, sizeof(buf));
2436 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, id_var, buf);
2437
2438 *dst_location_offset = spv_output_locationcxx . . $ spv_output_location(a939eba8b1993c99).(ctx, id_var, ~0u);
2439 } // spv_emit_uniform_constant_array
2440
2441 void emit_SPIRV_finalizecxx . . $ emit_SPIRV_finalize(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2442 {
2443 size_t i, j, k, max;
2444
2445 /* The generator's magic number, this could be registered with Khronos
2446 * if we wanted to. 0 is fine though, so use that for now. */
2447 uint32cxx . . $ uint32# genmagic = 0x00000000;
2448
2449 /* Vertex shader main() function may need to do some position adjustments. However,
2450 position may be written in subroutines, so we can't write position adjust code
2451 at the end of main(), because output register might not be in ctx->used_registers
2452 yet. Instead, we do adjust in a subroutine generated here and called at the
2453 end of main(). */
2454 spv_emit_vs_main_endcxx . . $ spv_emit_vs_main_end(612dd59919e2530e).(ctx);
2455 spv_emit_func_litcxx . . $ spv_emit_func_lit(612dd59919e2530e).(ctx);
2456
2457 uint8cxx . . $ uint8# emit_vec4 = ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count. > 0 && ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idvec4cxx . . $ SpirvContext#$anonymous_type_1#idvec4.;
2458 uint8cxx . . $ uint8# emit_ivec4 = ctx->uniform_int4_countcxx . . $ Context#uniform_int4_count. > 0 && ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idivec4cxx . . $ SpirvContext#$anonymous_type_1#idivec4.;
2459 uint8cxx . . $ uint8# emit_bool = ctx->uniform_bool_countcxx . . $ Context#uniform_bool_count. > 0 && ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idboolcxx . . $ SpirvContext#$anonymous_type_1#idbool.;
2460 uint8cxx . . $ uint8# emit_any = emit_vec4 | emit_ivec4 | emit_bool;
2461 if (ctx->spirvcxx . . $ Context#spirv..modecxx . . $ SpirvContext#mode. == SPIRV_MODE_GLcxx . . $ SPIRV_MODE_GL.)
2462 {
2463 if (emit_vec4)
2464 spv_emit_uniform_constant_arraycxx . . $ spv_emit_uniform_constant_array(1c5beb42ceba24fe).(ctx, REG_TYPE_CONSTcxx . . $ REG_TYPE_CONST.,
2465 ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count.,
2466 ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idvec4cxx . . $ SpirvContext#$anonymous_type_1#idvec4.,
2467 spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.),
2468 &ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..array_vec4cxx . . $ SpirvPatchTable#array_vec4..offsetcxx . . $ SpirvPatchEntry#offset.
2469 );
2470
2471 if (emit_ivec4)
2472 spv_emit_uniform_constant_arraycxx . . $ spv_emit_uniform_constant_array(1c5beb42ceba24fe).(ctx, REG_TYPE_CONSTINTcxx . . $ REG_TYPE_CONSTINT.,
2473 ctx->uniform_int4_countcxx . . $ Context#uniform_int4_count.,
2474 ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idivec4cxx . . $ SpirvContext#$anonymous_type_1#idivec4.,
2475 spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IVEC4cxx . . $ STI_IVEC4.),
2476 &ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..offsetcxx . . $ SpirvPatchEntry#offset.
2477 );
2478
2479 if (emit_bool)
2480 spv_emit_uniform_constant_arraycxx . . $ spv_emit_uniform_constant_array(1c5beb42ceba24fe).(ctx, REG_TYPE_CONSTBOOLcxx . . $ REG_TYPE_CONSTBOOL.,
2481 ctx->uniform_bool_countcxx . . $ Context#uniform_bool_count.,
2482 ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idboolcxx . . $ SpirvContext#$anonymous_type_1#idbool.,
2483 spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.),
2484 &ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table..array_boolcxx . . $ SpirvPatchTable#array_bool..offsetcxx . . $ SpirvPatchEntry#offset.
2485 );
2486 } // if
2487 else if (emit_any)
2488 {
2489 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(ctx->spirv.mode == SPIRV_MODE_VK);
2490 uint32cxx . . $ uint32# member_tid[3];
2491 uint32cxx . . $ uint32# member_offset[3];
2492 uint32cxx . . $ uint32# member_count = 0;
2493 uint32cxx . . $ uint32# struct_size = 0;
2494
2495 uint32cxx . . $ uint32# tid_arr_idx = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
2496
2497 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2498
2499 if (emit_vec4)
2500 {
2501 int size = ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count.;
2502 uint32cxx . . $ uint32# id_size = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, size);
2503 uint32cxx . . $ uint32# tid_type_base = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2504 uint32cxx . . $ uint32# tid_array = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2505 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypeArraycxx . . $ SpvOpTypeArray., tid_array, tid_type_base, id_size);
2506 uint32cxx . . $ uint32# i = member_count++;
2507 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConstantcxx . . $ SpvOpConstant., tid_arr_idx, ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idvec4cxx . . $ SpirvContext#$anonymous_type_1#idvec4., i);
2508 member_tid[i] = tid_array;
2509 member_offset[i] = struct_size;
2510 struct_size += size * 16;
2511 } // if
2512
2513 if (emit_ivec4)
2514 {
2515 int size = ctx->uniform_int4_countcxx . . $ Context#uniform_int4_count.;
2516 uint32cxx . . $ uint32# id_size = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, size);
2517 uint32cxx . . $ uint32# tid_type_base = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IVEC4cxx . . $ STI_IVEC4.);
2518 uint32cxx . . $ uint32# tid_array = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2519 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypeArraycxx . . $ SpvOpTypeArray., tid_array, tid_type_base, id_size);
2520 uint32cxx . . $ uint32# i = member_count++;
2521 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConstantcxx . . $ SpvOpConstant., tid_arr_idx, ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idivec4cxx . . $ SpirvContext#$anonymous_type_1#idivec4., i);
2522 member_tid[i] = tid_array;
2523 member_offset[i] = struct_size;
2524 struct_size += size * 16;
2525 } // if
2526
2527 if (emit_bool)
2528 {
2529 int size = ctx->uniform_bool_countcxx . . $ Context#uniform_bool_count.;
2530 uint32cxx . . $ uint32# id_size = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, size);
2531 uint32cxx . . $ uint32# tid_type_base = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
2532 uint32cxx . . $ uint32# tid_array = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2533 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypeArraycxx . . $ SpvOpTypeArray., tid_array, tid_type_base, id_size);
2534 uint32cxx . . $ uint32# i = member_count++;
2535 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConstantcxx . . $ SpvOpConstant., tid_arr_idx, ctx->spirvcxx . . $ Context#spirv..uniform_arrayscxx . . $ SpirvContext#uniform_arrays..idboolcxx . . $ SpirvContext#$anonymous_type_1#idbool., i);
2536 member_tid[i] = tid_array;
2537 member_offset[i] = struct_size;
2538 struct_size += size * 16;
2539 } // if
2540
2541 uint32cxx . . $ uint32# tid_struct = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2542 uint32cxx . . $ uint32# tid_pstruct = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2543 uint32cxx . . $ uint32# id_pstruct = ctx->spirvcxx . . $ Context#spirv..id_uniform_blockcxx . . $ SpirvContext#id_uniform_block.;
2544 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 2 + member_count, 2, SpvOpTypeStructcxx . . $ SpvOpTypeStruct., tid_struct);
2545 for (i = 0; i < member_count; i++)
2546 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, member_tid[i]);
2547 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpTypePointercxx . . $ SpvOpTypePointer., tid_pstruct, SpvStorageClassUniformcxx . . $ SpvStorageClassUniform., tid_struct);
2548 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpVariablecxx . . $ SpvOpVariable., tid_pstruct, id_pstruct, SpvStorageClassUniformcxx . . $ SpvStorageClassUniform.);
2549
2550 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2551
2552 char buf[64];
2553 snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, sizeof(buf), "%s_uniforms", ctx->shader_type_strcxx . . $ Context#shader_type_str.);
2554 spv_output_namecxx . . $ spv_output_name(9dcec9a975569678).(ctx, id_pstruct, buf);
2555
2556 uint32cxx . . $ uint32# set = shader_is_vertexcxx . . $ shader_is_vertex(73332d3452342b36).(ctx) ? MOJOSHADER_SPIRV_VS_UNIFORM_SETcxx . . $ `profiles/mojoshader_profile_spirv.h:16:9`!
2557 : MOJOSHADER_SPIRV_PS_UNIFORM_SETcxx . . $ `profiles/mojoshader_profile_spirv.h:18:9`!;
2558 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->helperscxx . . $ Context#helpers.);
2559 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3+0, SpvOpDecoratecxx . . $ SpvOpDecorate., tid_struct, SpvDecorationBlockcxx . . $ SpvDecorationBlock.);
2560 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3+1, SpvOpDecoratecxx . . $ SpvOpDecorate., id_pstruct, SpvDecorationDescriptorSetcxx . . $ SpvDecorationDescriptorSet., set);
2561 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3+1, SpvOpDecoratecxx . . $ SpvOpDecorate., id_pstruct, SpvDecorationBindingcxx . . $ SpvDecorationBinding., 0);
2562
2563 for (uint32cxx . . $ uint32# i = 0; i < member_count; i++)
2564 {
2565 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3+1, SpvOpDecoratecxx . . $ SpvOpDecorate., member_tid[i], SpvDecorationArrayStridecxx . . $ SpvDecorationArrayStride., 16);
2566 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4+1, SpvOpMemberDecoratecxx . . $ SpvOpMemberDecorate., tid_struct, i, SpvDecorationOffsetcxx . . $ SpvDecorationOffset., member_offset[i]);
2567 } // for
2568
2569 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2570 } // else if
2571
2572 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->preflightcxx . . $ Context#preflight.);
2573
2574 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, SpvMagicNumbercxx . . $ SpvMagicNumber.);
2575 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, SpvVersioncxx . . $ SpvVersion.);
2576 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, genmagic);
2577 // "Bound: where all <id>s in this module are guaranteed to satisfy 0 < id < Bound"
2578 // `idmax` holds the last id that was given out, so we need to emit `idmax + 1`
2579 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, ctx->spirvcxx . . $ Context#spirv..idmaxcxx . . $ SpirvContext#idmax. + 1);
2580 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, 0);
2581
2582 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpCapabilitycxx . . $ SpvOpCapability., SpvCapabilityShadercxx . . $ SpvCapabilityShader.);
2583
2584 // only non-zero when actually needed
2585 if (ctx->spirvcxx . . $ Context#spirv..idextcxx . . $ SpirvContext#idext.)
2586 {
2587 const char *extstr = "GLSL.std.450";
2588 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 2 + spv_strlencxx . . $ spv_strlen(c61c63047ce273de).(extstr), 2, SpvOpExtInstImportcxx . . $ SpvOpExtInstImport., ctx->spirvcxx . . $ Context#spirv..idextcxx . . $ SpirvContext#idext.);
2589 spv_emit_strcxx . . $ spv_emit_str(72ff1ec6cf40f147).(ctx, extstr);
2590 } // if
2591
2592 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpMemoryModelcxx . . $ SpvOpMemoryModel., SpvAddressingModelLogicalcxx . . $ SpvAddressingModelLogical., SpvMemoryModelSimplecxx . . $ SpvMemoryModelSimple.);
2593
2594 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(shader_is_vertex(ctx) || shader_is_pixel(ctx));
2595 SpvExecutionModelcxx . . $ SpvExecutionModel# model = SpvExecutionModelVertexcxx . . $ SpvExecutionModelVertex.;
2596 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))
2597 model = SpvExecutionModelFragmentcxx . . $ SpvExecutionModelFragment.;
2598
2599 /* 3 is for opcode + exec. model + idmain */
2600 uint32cxx . . $ uint32# inoutcount = ctx->spirvcxx . . $ Context#spirv..inoutcountcxx . . $ SpirvContext#inoutcount.;
2601
2602 uint32cxx . . $ uint32# implicit_input_count = sizeof(ctx->spirvcxx . . $ Context#spirv..id_implicit_inputcxx . . $ SpirvContext#id_implicit_input.) / sizeof(uint32cxx . . $ uint32#);
2603 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))
2604 {
2605 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4))
2606 {
2607 for (uint32cxx . . $ uint32# i = 0; i < implicit_input_count; i++)
2608 {
2609 if (ctx->spirvcxx . . $ Context#spirv..id_implicit_inputcxx . . $ SpirvContext#id_implicit_input.[i])
2610 inoutcount += 1;
2611 } // for
2612 } // if
2613
2614 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 2, 0))
2615 inoutcount += 1;
2616 } // if
2617
2618 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 3 + spv_strlencxx . . $ spv_strlen(c61c63047ce273de).(ctx->mainfncxx . . $ Context#mainfn.) + inoutcount, 3, SpvOpEntryPointcxx . . $ SpvOpEntryPoint.,
2619 model, ctx->spirvcxx . . $ Context#spirv..idmaincxx . . $ SpirvContext#idmain.
2620 );
2621 spv_emit_strcxx . . $ spv_emit_str(72ff1ec6cf40f147).(ctx, ctx->mainfncxx . . $ Context#mainfn.);
2622
2623 RegisterListcxx . . $ RegisterList# *p = &ctx->attributescxx . . $ Context#attributes., *r = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
2624 // !!! FIXME: The first element of the list is always empty and I don't know why!
2625 p = p->nextcxx . . $ RegisterList#next.;
2626 while (p)
2627 {
2628 r = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, p->regtypecxx . . $ RegisterList#regtype., p->regnumcxx . . $ RegisterList#regnum.);
2629 if (r)
2630 {
2631 if (r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. == ctx->spirvcxx . . $ Context#spirv..id_var_vposcxx . . $ SpirvContext#id_var_vpos.)
2632 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, ctx->spirvcxx . . $ Context#spirv..id_var_fragcoordcxx . . $ SpirvContext#id_var_fragcoord.);
2633 else if (r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. == ctx->spirvcxx . . $ Context#spirv..id_var_vfacecxx . . $ SpirvContext#id_var_vface.)
2634 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, ctx->spirvcxx . . $ Context#spirv..id_var_frontfacingcxx . . $ SpirvContext#id_var_frontfacing.);
2635 else if (r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. == ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_privatecxx . . $ SpirvContext#id_var_texcoord0_private.)
2636 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, ctx->spirvcxx . . $ Context#spirv..id_var_texcoord0_inputcxx . . $ SpirvContext#id_var_texcoord0_input.);
2637 else
2638 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.);
2639 } // if
2640 else
2641 {
2642 char varname[64];
2643 get_SPIRV_varname_in_bufcxx . . $ get_SPIRV_varname_in_buf(e11e601b5c61efa5).(ctx, p->regtypecxx . . $ RegisterList#regtype., p->regnumcxx . . $ RegisterList#regnum., varname, sizeof (varname));
2644 failfcxx . . $ failf(f93f6dc5e2b298a0).(
2645 ctx,
2646 "missing attribute register %s (rt=%u, rn=%u, u=%u)",
2647 varname, p->regtypecxx . . $ RegisterList#regtype., p->regnumcxx . . $ RegisterList#regnum., p->usagecxx . . $ RegisterList#usage.
2648 );
2649 } // else
2650 p = p->nextcxx . . $ RegisterList#next.;
2651 } // while
2652
2653 // only applies to pixel shaders
2654 if (shader_is_pixelcxx . . $ shader_is_pixel(73332d3452342b36).(ctx))
2655 {
2656 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4))
2657 {
2658 for (uint32cxx . . $ uint32# i = 0; i < implicit_input_count; i++)
2659 {
2660 uint32cxx . . $ uint32# id = ctx->spirvcxx . . $ Context#spirv..id_implicit_inputcxx . . $ SpirvContext#id_implicit_input.[i];
2661 if (id)
2662 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, id);
2663 } // for
2664 } // if
2665
2666 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 2, 0))
2667 {
2668 // r0 is used as color output.
2669 r = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEMPcxx . . $ REG_TYPE_TEMP., 0);
2670 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, r->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.);
2671 } // if
2672
2673 // vk semantics = default origin is upper left
2674 // gl semantics = default origin is lower left
2675 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpExecutionModecxx . . $ SpvOpExecutionMode., ctx->spirvcxx . . $ Context#spirv..idmaincxx . . $ SpirvContext#idmain., SpvExecutionModeOriginUpperLeftcxx . . $ SpvExecutionModeOriginUpperLeft.);
2676
2677 // This must be explicitly marked when FragDepth is in use!
2678 if (ctx->spirvcxx . . $ Context#spirv..hasdepthcxx . . $ SpirvContext#hasdepth.)
2679 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpExecutionModecxx . . $ SpvOpExecutionMode., ctx->spirvcxx . . $ Context#spirv..idmaincxx . . $ SpirvContext#idmain., SpvExecutionModeDepthReplacingcxx . . $ SpvExecutionModeDepthReplacing.);
2680 } // if
2681
2682 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2683
2684 // Generate final patch table.
2685
2686 uint32cxx . . $ uint32# base_offset = 0;
2687 if (ctx->preflightcxx . . $ Context#preflight.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->preflightcxx . . $ Context#preflight.);
2688 if (ctx->globalscxx . . $ Context#globals.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->globalscxx . . $ Context#globals.);
2689 if (ctx->inputscxx . . $ Context#inputs.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->inputscxx . . $ Context#inputs.);
2690 if (ctx->outputscxx . . $ Context#outputs.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->outputscxx . . $ Context#outputs.);
2691 base_offset >>= 2;
2692
2693 int32cxx . . $ int32# location_count = 0;
2694 SpirvPatchTablecxx . . $ SpirvPatchTable#* table = &ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table.;
2695 if (table->vpflipcxx . . $ SpirvPatchTable#vpflip..offsetcxx . . $ SpirvPatchEntry#offset.)
2696 {
2697 table->vpflipcxx . . $ SpirvPatchTable#vpflip..offsetcxx . . $ SpirvPatchEntry#offset. += base_offset;
2698 table->vpflipcxx . . $ SpirvPatchTable#vpflip..locationcxx . . $ SpirvPatchEntry#location. = location_count;
2699 location_count += 1;
2700 } // if
2701 else
2702 table->vpflipcxx . . $ SpirvPatchTable#vpflip..locationcxx . . $ SpirvPatchEntry#location. = -1;
2703
2704 if (table->array_vec4cxx . . $ SpirvPatchTable#array_vec4..offsetcxx . . $ SpirvPatchEntry#offset.)
2705 {
2706 table->array_vec4cxx . . $ SpirvPatchTable#array_vec4..offsetcxx . . $ SpirvPatchEntry#offset. += base_offset;
2707 table->array_vec4cxx . . $ SpirvPatchTable#array_vec4..locationcxx . . $ SpirvPatchEntry#location. = location_count;
2708 location_count += ctx->uniform_float4_countcxx . . $ Context#uniform_float4_count.;
2709 } // if
2710 else
2711 table->array_vec4cxx . . $ SpirvPatchTable#array_vec4..locationcxx . . $ SpirvPatchEntry#location. = -1;
2712
2713 if (table->array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..offsetcxx . . $ SpirvPatchEntry#offset.)
2714 {
2715 table->array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..offsetcxx . . $ SpirvPatchEntry#offset. += base_offset;
2716 table->array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..locationcxx . . $ SpirvPatchEntry#location. = location_count;
2717 location_count += ctx->uniform_int4_countcxx . . $ Context#uniform_int4_count.;
2718 } // if
2719 else
2720 table->array_ivec4cxx . . $ SpirvPatchTable#array_ivec4..locationcxx . . $ SpirvPatchEntry#location. = -1;
2721
2722 if (table->array_boolcxx . . $ SpirvPatchTable#array_bool..offsetcxx . . $ SpirvPatchEntry#offset.)
2723 {
2724 table->array_boolcxx . . $ SpirvPatchTable#array_bool..offsetcxx . . $ SpirvPatchEntry#offset. += base_offset;
2725 table->array_boolcxx . . $ SpirvPatchTable#array_bool..locationcxx . . $ SpirvPatchEntry#location. = location_count;
2726 location_count += ctx->uniform_bool_countcxx . . $ Context#uniform_bool_count.;
2727 } // if
2728 else
2729 table->array_boolcxx . . $ SpirvPatchTable#array_bool..locationcxx . . $ SpirvPatchEntry#location. = -1;
2730
2731 for (i = 0, max = STATICARRAYLENcxx . . $ `mojoshader_internal.h:313:9`!(table->samplers); i < max; i++)
2732 {
2733 SpirvPatchEntrycxx . . $ SpirvPatchEntry#* entry = &table->samplerscxx . . $ SpirvPatchTable#samplers.[i];
2734 if (entry->offsetcxx . . $ SpirvPatchEntry#offset.)
2735 {
2736 entry->offsetcxx . . $ SpirvPatchEntry#offset. += base_offset;
2737 entry->locationcxx . . $ SpirvPatchEntry#location. = location_count;
2738 location_count++;
2739 } // if
2740 else
2741 entry->locationcxx . . $ SpirvPatchEntry#location. = -1;
2742 } // for
2743
2744 table->location_countcxx . . $ SpirvPatchTable#location_count. = location_count;
2745
2746 for (i = 0; i < MOJOSHADER_USAGE_TOTALcxx . . $ MOJOSHADER_USAGE_TOTAL.; i++)
2747 for (j = 0; j < 16; j++)
2748 if (table->attrib_offsetscxx . . $ SpirvPatchTable#attrib_offsets.[i][j])
2749 table->attrib_offsetscxx . . $ SpirvPatchTable#attrib_offsets.[i][j] += base_offset;
2750 for (i = 0; i < 16; i++)
2751 if (table->output_offsetscxx . . $ SpirvPatchTable#output_offsets.[i])
2752 table->output_offsetscxx . . $ SpirvPatchTable#output_offsets.[i] += base_offset;
2753
2754 base_offset <<= 2;
2755 if (ctx->helperscxx . . $ Context#helpers.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->helperscxx . . $ Context#helpers.);
2756 if (ctx->subroutinescxx . . $ Context#subroutines.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->subroutinescxx . . $ Context#subroutines.);
2757 base_offset >>= 2;
2758
2759 if (table->pointcoord_var_offsetcxx . . $ SpirvPatchTable#pointcoord_var_offset.)
2760 table->pointcoord_var_offsetcxx . . $ SpirvPatchTable#pointcoord_var_offset. += base_offset;
2761
2762 for (i = 0; i < MOJOSHADER_USAGE_TOTALcxx . . $ MOJOSHADER_USAGE_TOTAL.; i++)
2763 for (j = 0; j < 16; j++)
2764 if (table->attrib_type_offsetscxx . . $ SpirvPatchTable#attrib_type_offsets.[i][j])
2765 table->attrib_type_offsetscxx . . $ SpirvPatchTable#attrib_type_offsets.[i][j] += base_offset;
2766
2767 base_offset <<= 2;
2768 if (ctx->mainline_introcxx . . $ Context#mainline_intro.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->mainline_introcxx . . $ Context#mainline_intro.);
2769 if (ctx->mainline_argumentscxx . . $ Context#mainline_arguments.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->mainline_argumentscxx . . $ Context#mainline_arguments.);
2770 base_offset >>= 2;
2771
2772 if (table->pointcoord_load_offsetcxx . . $ SpirvPatchTable#pointcoord_load_offset.)
2773 table->pointcoord_load_offsetcxx . . $ SpirvPatchTable#pointcoord_load_offset. += base_offset;
2774
2775 base_offset <<= 2;
2776 if (ctx->mainline_topcxx . . $ Context#mainline_top.) base_offset += buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->mainline_topcxx . . $ Context#mainline_top.);
2777 base_offset >>= 2;
2778
2779 for (i = 0; i < MOJOSHADER_USAGE_TOTALcxx . . $ MOJOSHADER_USAGE_TOTAL.; i++)
2780 for (j = 0; j < 16; j++)
2781 if (table->attrib_type_offsetscxx . . $ SpirvPatchTable#attrib_type_offsets.[i][j])
2782 for (k = 0; k < table->attrib_type_load_offsetscxx . . $ SpirvPatchTable#attrib_type_load_offsets.[i][j].num_loadscxx . . $ SpirvPatchTable#$anonymous_type_7#num_loads.; k++)
2783 {
2784 table->attrib_type_load_offsetscxx . . $ SpirvPatchTable#attrib_type_load_offsets.[i][j].load_typescxx . . $ SpirvPatchTable#$anonymous_type_7#load_types.[k] += base_offset;
2785 table->attrib_type_load_offsetscxx . . $ SpirvPatchTable#attrib_type_load_offsets.[i][j].load_opcodescxx . . $ SpirvPatchTable#$anonymous_type_7#load_opcodes.[k] += base_offset;
2786 } // for
2787
2788 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->postflightcxx . . $ Context#postflight.);
2789 buffer_appendcxx . . $ buffer_append(e4e8268775a9929a).(ctx->outputcxx . . $ Context#output., &ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table., sizeof(ctx->spirvcxx . . $ Context#spirv..patch_tablecxx . . $ SpirvContext#patch_table.));
2790 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2791
2792 spv_componentlist_freecxx . . $ spv_componentlist_free(e67ba04bcb351a03).(ctx, ctx->spirvcxx . . $ Context#spirv..clcxx . . $ SpirvContext#cl..fcxx . . $ SpirvContext#$anonymous_type_3#f..nextcxx . . $ ComponentList#next.);
2793 spv_componentlist_freecxx . . $ spv_componentlist_free(e67ba04bcb351a03).(ctx, ctx->spirvcxx . . $ Context#spirv..clcxx . . $ SpirvContext#cl..icxx . . $ SpirvContext#$anonymous_type_3#i..nextcxx . . $ ComponentList#next.);
2794 spv_componentlist_freecxx . . $ spv_componentlist_free(e67ba04bcb351a03).(ctx, ctx->spirvcxx . . $ Context#spirv..clcxx . . $ SpirvContext#cl..ucxx . . $ SpirvContext#$anonymous_type_3#u..nextcxx . . $ ComponentList#next.);
2795 } // emit_SPIRV_finalize
2796
2797 void emit_SPIRV_NOPcxx . . $ emit_SPIRV_NOP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2798 {
2799 // no-op is a no-op. :)
2800 // TODO: (hnn) SPIR-V has OpNop :O
2801 } // emit_SPIRV_NOP
2802
2803 void emit_SPIRV_DEFcxx . . $ emit_SPIRV_DEF(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2804 {
2805 RegisterListcxx . . $ RegisterList# *rl;
2806 uint32cxx . . $ uint32# val0, val1, val2, val3, idv4;
2807 const float *raw = (const float *) ctx->dwordscxx . . $ Context#dwords.;
2808
2809 rl = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, ctx->dest_argcxx . . $ Context#dest_arg..regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
2810 rl->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2811 rl->spirvcxx . . $ RegisterList#spirv..is_ssacxx . . $ RegisterList#$anonymous_type_0#is_ssa. = 1;
2812
2813 val0 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, raw[0]);
2814 val1 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, raw[1]);
2815 val2 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, raw[2]);
2816 val3 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, raw[3]);
2817
2818 idv4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2819
2820 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2821 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpConstantCompositecxx . . $ SpvOpConstantComposite., idv4, rl->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., val0, val1, val2, val3);
2822 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2823 } // emit_SPIRV_DEF
2824
2825 void emit_SPIRV_DEFIcxx . . $ emit_SPIRV_DEFI(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2826 {
2827 RegisterListcxx . . $ RegisterList# *rl;
2828 uint32cxx . . $ uint32# val0, val1, val2, val3, idiv4;
2829 const int *raw = (const int *) ctx->dwordscxx . . $ Context#dwords.;
2830
2831 rl = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, ctx->dest_argcxx . . $ Context#dest_arg..regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
2832 rl->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2833 rl->spirvcxx . . $ RegisterList#spirv..is_ssacxx . . $ RegisterList#$anonymous_type_0#is_ssa. = 1;
2834
2835 val0 = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, raw[0]);
2836 val1 = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, raw[1]);
2837 val2 = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, raw[2]);
2838 val3 = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, raw[3]);
2839
2840 idiv4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IVEC4cxx . . $ STI_IVEC4.);
2841
2842 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainline_introcxx . . $ Context#mainline_intro.);
2843 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpConstantCompositecxx . . $ SpvOpConstantComposite., idiv4, rl->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl., val0, val1, val2, val3);
2844 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2845 } // emit_SPIRV_DEFI
2846
2847 void emit_SPIRV_DEFBcxx . . $ emit_SPIRV_DEFB(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2848 {
2849 RegisterListcxx . . $ RegisterList# *rl = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, ctx->dest_argcxx . . $ Context#dest_arg..regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
2850 rl->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = ctx->dwordscxx . . $ Context#dwords.[0] ? spv_gettruecxx . . $ spv_gettrue(6d86621a4076bebf).(ctx) : spv_getfalsecxx . . $ spv_getfalse(6d86621a4076bebf).(ctx);
2851 rl->spirvcxx . . $ RegisterList#spirv..is_ssacxx . . $ RegisterList#$anonymous_type_0#is_ssa. = 1;
2852 } // emit_SPIRV_DEFB
2853
2854 void emit_SPIRV_DCLcxx . . $ emit_SPIRV_DCL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2855 {
2856 // state_DCL handles checking if the registers are valid for this
2857 // instruction, and collecting samplers and attribs
2858 RegisterListcxx . . $ RegisterList# *reg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, ctx->dest_argcxx . . $ Context#dest_arg..regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
2859
2860 // This id will be assigned to in emit_SPIRV_attribute, but
2861 // emit_SPIRV_attribute is called after instructions are emitted,
2862 // so we generate the id here so it can be used in instructions
2863 reg->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2864 } // emit_SPIRV_DCL
2865
2866 static void emit_SPIRV_dotproductcxx . . $ emit_SPIRV_dotproduct(7a8c1211cff1d698).(Contextcxx . . $ Context# *ctx, SpirvResultcxx . . $ SpirvResult# src0, SpirvResultcxx . . $ SpirvResult# src1)
2867 {
2868 SpirvResultcxx . . $ SpirvResult# result;
2869
2870 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(src0.tid == src1.tid);
2871
2872 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
2873 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2874
2875 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
2876 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
2877
2878 // Broadcast scalar result across all channels of a vec4
2879 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2880 result.idcxx . . $ SpirvResult#id. = spv_vectorbroadcastcxx . . $ spv_vectorbroadcast(a939eba8b1993c99).(ctx, result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id.);
2881 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2882
2883 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
2884 } // emit_SPIRV_dotproduct
2885
2886 void emit_SPIRV_DP4cxx . . $ emit_SPIRV_DP4(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2887 {
2888 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
2889 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1);
2890
2891 emit_SPIRV_dotproductcxx . . $ emit_SPIRV_dotproduct(7a8c1211cff1d698).(ctx, src0, src1);
2892 } // emit_SPIRV_DP4
2893
2894 void emit_SPIRV_DP3cxx . . $ emit_SPIRV_DP3(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
2895 {
2896 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, 0x7);
2897 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 1, 0x7);
2898
2899 emit_SPIRV_dotproductcxx . . $ emit_SPIRV_dotproduct(7a8c1211cff1d698).(ctx, src0, src1);
2900 } // emit_SPIRV_DP3
2901
2902 static void spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(Contextcxx . . $ Context# *ctx, SpirvResultcxx . . $ SpirvResult#* dst, SpirvResultcxx . . $ SpirvResult#* src)
2903 {
2904 *src = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
2905 dst->tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2906 dst->idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2907 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
2908 } // spv_emit_begin_ds
2909
2910 static void spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(Contextcxx . . $ Context# *ctx, SpirvResultcxx . . $ SpirvResult#* dst, SpirvResultcxx . . $ SpirvResult#* src0, SpirvResultcxx . . $ SpirvResult#* src1)
2911 {
2912 *src0 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
2913 *src1 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1);
2914 dst->tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2915 dst->idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2916 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
2917 } // spv_emit_begin_dss
2918
2919 static void spv_emit_begin_dssscxx . . $ spv_emit_begin_dsss(96e971bdd9b7ae7d).(Contextcxx . . $ Context# *ctx, SpirvResultcxx . . $ SpirvResult#* dst,
2920 SpirvResultcxx . . $ SpirvResult#* src0, SpirvResultcxx . . $ SpirvResult#* src1, SpirvResultcxx . . $ SpirvResult#* src2)
2921 {
2922 *src0 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
2923 *src1 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1);
2924 *src2 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 2);
2925 dst->tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
2926 dst->idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2927 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
2928 } // spv_emit_begin_dsss
2929
2930 static void spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(Contextcxx . . $ Context# *ctx, SpirvResultcxx . . $ SpirvResult# dst)
2931 {
2932 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2933 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, dst);
2934 } // spv_emit_end
2935
2936 static SpirvTexm3x3SetupResultcxx . . $ SpirvTexm3x3SetupResult# spv_texm3x3_setupcxx . . $ spv_texm3x3_setup(d1a426149cff7b45).(Contextcxx . . $ Context# *ctx)
2937 {
2938 SpirvTexm3x3SetupResultcxx . . $ SpirvTexm3x3SetupResult# result;
2939
2940 DestArgInfocxx . . $ DestArgInfo# *pDstInfo = &ctx->dest_argcxx . . $ Context#dest_arg.;
2941
2942 RegisterListcxx . . $ RegisterList# *pSrc0 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst0cxx . . $ Context#texm3x3pad_dst0.);
2943 RegisterListcxx . . $ RegisterList# *pSrc1 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src0cxx . . $ Context#texm3x3pad_src0.);
2944 RegisterListcxx . . $ RegisterList# *pSrc2 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_dst1cxx . . $ Context#texm3x3pad_dst1.);
2945 RegisterListcxx . . $ RegisterList# *pSrc3 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1.);
2946 RegisterListcxx . . $ RegisterList# *pSrc4 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
2947 RegisterListcxx . . $ RegisterList# *pDst = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, pDstInfo->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., pDstInfo->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
2948
2949 SpirvResultcxx . . $ SpirvResult# src0 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc0);
2950 SpirvResultcxx . . $ SpirvResult# src1 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc1);
2951 SpirvResultcxx . . $ SpirvResult# src2 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc2);
2952 SpirvResultcxx . . $ SpirvResult# src3 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc3);
2953 SpirvResultcxx . . $ SpirvResult# src4 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc4);
2954 SpirvResultcxx . . $ SpirvResult# dst = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pDst);
2955
2956 result.id_dst_pad0cxx . . $ SpirvTexm3x3SetupResult#id_dst_pad0. = src0.idcxx . . $ SpirvResult#id.;
2957 result.id_dst_pad1cxx . . $ SpirvTexm3x3SetupResult#id_dst_pad1. = src2.idcxx . . $ SpirvResult#id.;
2958 result.id_dstcxx . . $ SpirvTexm3x3SetupResult#id_dst. = dst.idcxx . . $ SpirvResult#id.;
2959
2960 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
2961 uint32cxx . . $ uint32# tid_vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
2962
2963 uint32cxx . . $ uint32# id_src0_xyz = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2964 uint32cxx . . $ uint32# id_src1_xyz = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2965 uint32cxx . . $ uint32# id_src2_xyz = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2966 uint32cxx . . $ uint32# id_src3_xyz = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2967 uint32cxx . . $ uint32# id_src4_xyz = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2968 uint32cxx . . $ uint32# id_dst_xyz = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2969 uint32cxx . . $ uint32# id_res_x = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2970 uint32cxx . . $ uint32# id_res_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2971 uint32cxx . . $ uint32# id_res_z = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
2972
2973 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
2974
2975 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec3, id_src0_xyz, src0.idcxx . . $ SpirvResult#id., src0.idcxx . . $ SpirvResult#id., 0, 1, 2);
2976 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec3, id_src1_xyz, src1.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id., 0, 1, 2);
2977 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec3, id_src2_xyz, src2.idcxx . . $ SpirvResult#id., src2.idcxx . . $ SpirvResult#id., 0, 1, 2);
2978 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec3, id_src3_xyz, src3.idcxx . . $ SpirvResult#id., src3.idcxx . . $ SpirvResult#id., 0, 1, 2);
2979 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec3, id_src4_xyz, src4.idcxx . . $ SpirvResult#id., src4.idcxx . . $ SpirvResult#id., 0, 1, 2);
2980 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec3, id_dst_xyz, dst.idcxx . . $ SpirvResult#id., dst.idcxx . . $ SpirvResult#id., 0, 1, 2);
2981
2982 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., tid_float, id_res_x, id_src0_xyz, id_src1_xyz);
2983 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., tid_float, id_res_y, id_src2_xyz, id_src3_xyz);
2984 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., tid_float, id_res_z, id_dst_xyz, id_src4_xyz);
2985
2986 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
2987
2988 result.id_res_xcxx . . $ SpirvTexm3x3SetupResult#id_res_x. = id_res_x;
2989 result.id_res_ycxx . . $ SpirvTexm3x3SetupResult#id_res_y. = id_res_y;
2990 result.id_res_zcxx . . $ SpirvTexm3x3SetupResult#id_res_z. = id_res_z;
2991
2992 return result;
2993 } // spv_texm3x3_setup
2994
2995 static uint32cxx . . $ uint32# spv_reflectcxx . . $ spv_reflect(a939eba8b1993c99).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# id_normal, uint32cxx . . $ uint32# id_eyeray)
2996 {
2997 // reflect(E : vec3 = eyeray, N : vec3 = normal) -> vec3
2998 // 2 * [(N*E) / (N*N)] * N - E
2999
3000 uint32cxx . . $ uint32# tid_vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
3001 uint32cxx . . $ uint32# id_2 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, 2.0f);
3002 uint32cxx . . $ uint32# id_2_v3 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3003 uint32cxx . . $ uint32# id_refl_0 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3004 uint32cxx . . $ uint32# id_refl_1 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3005 uint32cxx . . $ uint32# id_refl_2 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3006 uint32cxx . . $ uint32# id_refl_3 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3007 uint32cxx . . $ uint32# id_refl_4 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3008 uint32cxx . . $ uint32# id_reflected = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3009
3010 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 3, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec3, id_2_v3, id_2, id_2, id_2);
3011 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_vec3, id_refl_0, id_normal, id_eyeray);
3012 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_vec3, id_refl_1, id_normal, id_normal);
3013 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFDivcxx . . $ SpvOpFDiv., tid_vec3, id_refl_2, id_refl_0, id_refl_1);
3014 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_vec3, id_refl_3, id_refl_2, id_normal);
3015 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_vec3, id_refl_4, id_refl_3, id_2_v3);
3016 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFSubcxx . . $ SpvOpFSub., tid_vec3, id_reflected, id_refl_4, id_eyeray);
3017
3018 return id_reflected;
3019 } // spv_reflect
3020
3021 void emit_SPIRV_ADDcxx . . $ emit_SPIRV_ADD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3022 {
3023 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3024 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3025 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFAddcxx . . $ SpvOpFAdd., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3026 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3027 } // emit_SPIRV_ADD
3028
3029 void emit_SPIRV_SUBcxx . . $ emit_SPIRV_SUB(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3030 {
3031 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3032 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3033 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFSubcxx . . $ SpvOpFSub., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3034 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3035 } // emit_SPIRV_SUB
3036
3037 void emit_SPIRV_MULcxx . . $ emit_SPIRV_MUL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3038 {
3039 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3040 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3041 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3042 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3043 } // emit_SPIRV_MUL
3044
3045 void emit_SPIRV_SLTcxx . . $ emit_SPIRV_SLT(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3046 {
3047 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3048 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3049
3050 // https://msdn.microsoft.com/en-us/library/windows/desktop/cc308050(v=vs.85).aspx
3051 // "The comparisons EQ, GT, GE, LT, and LE, when either or both operands is NaN returns FALSE"
3052 uint32cxx . . $ uint32# bool_result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3053 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdLessThancxx . . $ SpvOpFOrdLessThan., spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BVEC4cxx . . $ STI_BVEC4.), bool_result, src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3054
3055 uint32cxx . . $ uint32# ones = spv_getvec4_onecxx . . $ spv_getvec4_one(6d86621a4076bebf).(ctx);
3056 uint32cxx . . $ uint32# zeros = spv_getvec4_zerocxx . . $ spv_getvec4_zero(6d86621a4076bebf).(ctx);
3057 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., bool_result, ones, zeros);
3058
3059 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3060 } // emit_SPIRV_SLT
3061
3062 void emit_SPIRV_SGEcxx . . $ emit_SPIRV_SGE(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3063 {
3064 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3065 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3066
3067 // https://msdn.microsoft.com/en-us/library/windows/desktop/cc308050(v=vs.85).aspx
3068 // "The comparisons EQ, GT, GE, LT, and LE, when either or both operands is NaN returns FALSE"
3069 uint32cxx . . $ uint32# bool_result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3070 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdGreaterThanEqualcxx . . $ SpvOpFOrdGreaterThanEqual., spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BVEC4cxx . . $ STI_BVEC4.), bool_result, src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3071
3072 uint32cxx . . $ uint32# ones = spv_getvec4_onecxx . . $ spv_getvec4_one(6d86621a4076bebf).(ctx);
3073 uint32cxx . . $ uint32# zeros = spv_getvec4_zerocxx . . $ spv_getvec4_zero(6d86621a4076bebf).(ctx);
3074
3075 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., bool_result, ones, zeros);
3076 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3077 } // emit_SPIRV_SGE
3078
3079 void emit_SPIRV_MINcxx . . $ emit_SPIRV_MIN(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3080 {
3081 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3082 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3083 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 2, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FMincxx . . $ GLSLstd450FMin., src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3084 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3085 } // emit_SPIRV_MIN
3086
3087 void emit_SPIRV_MAXcxx . . $ emit_SPIRV_MAX(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3088 {
3089 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3090 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3091 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 2, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FMaxcxx . . $ GLSLstd450FMax., src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3092 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3093 } // emit_SPIRV_MAX
3094
3095 void emit_SPIRV_POWcxx . . $ emit_SPIRV_POW(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3096 {
3097 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3098 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3099 uint32cxx . . $ uint32# id_abs = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3100 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., src0.tidcxx . . $ SpirvResult#tid., id_abs, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FAbscxx . . $ GLSLstd450FAbs., src0.idcxx . . $ SpirvResult#id.);
3101 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 2, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450Powcxx . . $ GLSLstd450Pow., id_abs, src1.idcxx . . $ SpirvResult#id.);
3102 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3103 } // emit_SPIRV_POW
3104
3105 static uint32cxx . . $ uint32# spv_extract_vec3cxx . . $ spv_extract_vec3(1e2deca95f3d56bd).(Contextcxx . . $ Context# *ctx, uint32cxx . . $ uint32# input)
3106 {
3107 uint32cxx . . $ uint32# vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
3108 uint32cxx . . $ uint32# result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3109
3110 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3111 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., vec3, result, input, input, 0, 1, 2);
3112 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3113
3114 return result;
3115 } // spv_extract_vec3
3116
3117 void emit_SPIRV_CRScxx . . $ emit_SPIRV_CRS(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3118 {
3119 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3120 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3121
3122 uint32cxx . . $ uint32# vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
3123 uint32cxx . . $ uint32# src0_vec3 = spv_extract_vec3cxx . . $ spv_extract_vec3(1e2deca95f3d56bd).(ctx, src0.idcxx . . $ SpirvResult#id.);
3124 uint32cxx . . $ uint32# src1_vec3 = spv_extract_vec3cxx . . $ spv_extract_vec3(1e2deca95f3d56bd).(ctx, src1.idcxx . . $ SpirvResult#id.);
3125 uint32cxx . . $ uint32# result_vec3 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3126
3127 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 2, SpvOpExtInstcxx . . $ SpvOpExtInst., vec3, result_vec3, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx),
3128 GLSLstd450Crosscxx . . $ GLSLstd450Cross., src0_vec3, src1_vec3);
3129
3130 // According to DirectX docs, CRS doesn't allow `w` in its writemask, so we
3131 // can make this component anything and the code generated by
3132 // `spv_assign_destarg()` will just throw it away.
3133 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 4, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id.,
3134 result_vec3, result_vec3, 0, 1, 2, 0xFFFFFFFF);
3135
3136 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3137 } // emit_SPIRV_CRS
3138
3139 void emit_SPIRV_MADcxx . . $ emit_SPIRV_MAD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3140 {
3141 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
3142 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1);
3143 SpirvResultcxx . . $ SpirvResult# src2 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 2);
3144 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(src0.tid == src1.tid);
3145 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(src0.tid == src2.tid);
3146 uint32cxx . . $ uint32# mul_result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3147 SpirvResultcxx . . $ SpirvResult# result;
3148 result.tidcxx . . $ SpirvResult#tid. = src0.tidcxx . . $ SpirvResult#tid.;
3149 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3150
3151 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3152 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., src0.tidcxx . . $ SpirvResult#tid., mul_result, src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3153 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFAddcxx . . $ SpvOpFAdd., src0.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., mul_result, src2.idcxx . . $ SpirvResult#id.);
3154 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3155
3156 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
3157 } // emit_SPIRV_MAD
3158
3159 void emit_SPIRV_TEXKILLcxx . . $ emit_SPIRV_TEXKILL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3160 {
3161 const DestArgInfocxx . . $ DestArgInfo# *pDstInfo = &ctx->dest_argcxx . . $ Context#dest_arg.;
3162 RegisterListcxx . . $ RegisterList# *pDst = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, pDstInfo->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., pDstInfo->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
3163 SpirvResultcxx . . $ SpirvResult# dst = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pDst);
3164
3165 uint32cxx . . $ uint32# vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
3166 uint32cxx . . $ uint32# bvec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BVEC3cxx . . $ STI_BVEC3.);
3167
3168 uint32cxx . . $ uint32# zeros = spv_get_zerocxx . . $ spv_get_zero(1e2deca95f3d56bd).(ctx, vec3);
3169
3170 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3171 uint32cxx . . $ uint32# res_swiz = spv_emit_swizzlecxx . . $ spv_emit_swizzle(bdfd39476c67e44f).(ctx, dst.idcxx . . $ SpirvResult#id., vec3, (0 << 0) | (1 << 2) | (2 << 4), 0x7);
3172 uint32cxx . . $ uint32# res_lt = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3173 uint32cxx . . $ uint32# res_any = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3174 uint32cxx . . $ uint32# label_true = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3175 uint32cxx . . $ uint32# label_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3176 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdLessThancxx . . $ SpvOpFOrdLessThan., bvec3, res_lt, res_swiz, zeros);
3177 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpAnycxx . . $ SpvOpAny., spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.), res_any, res_lt);
3178 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., label_merge, 0);
3179 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., res_any, label_true, label_merge);
3180 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., label_true);
3181 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 1, SpvOpKillcxx . . $ SpvOpKill.);
3182 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., label_merge);
3183 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3184 } // emit_SPIRV_TEXKILL
3185
3186 void emit_SPIRV_DP2ADDcxx . . $ emit_SPIRV_DP2ADD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3187 {
3188 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, 0x3);
3189 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 1, 0x3);
3190 SpirvResultcxx . . $ SpirvResult# src2 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 2, 0x1);
3191
3192 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
3193 uint32cxx . . $ uint32# id_dot = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3194 uint32cxx . . $ uint32# id_add = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3195
3196 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3197 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., tid_float, id_dot, src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3198 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFAddcxx . . $ SpvOpFAdd., tid_float, id_add, id_dot, src2.idcxx . . $ SpirvResult#id.);
3199 SpirvResultcxx . . $ SpirvResult# result;
3200 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
3201 result.idcxx . . $ SpirvResult#id. = spv_vectorbroadcastcxx . . $ spv_vectorbroadcast(a939eba8b1993c99).(ctx, result.tidcxx . . $ SpirvResult#tid., id_add);
3202 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3203
3204 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
3205 } // emit_SPIRV_DP2ADD
3206
3207 void emit_SPIRV_MOVcxx . . $ emit_SPIRV_MOV(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3208 {
3209 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
3210 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, src0);
3211 } // emit_SPIRV_MOV
3212
3213 void emit_SPIRV_RCPcxx . . $ emit_SPIRV_RCP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3214 {
3215 /*
3216 if (src != 0.0f)
3217 dst = 1.0f / src;
3218 else
3219 dst = FLT_MAX;
3220 */
3221
3222 SpirvResultcxx . . $ SpirvResult# dst, src;
3223 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
3224
3225 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_bvec =
3226 (src.tidcxx . . $ SpirvResult#tid. == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC4cxx . . $ STI_VEC4.]) ? STI_BVEC4cxx . . $ STI_BVEC4. :
3227 (src.tidcxx . . $ SpirvResult#tid. == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC3cxx . . $ STI_VEC3.]) ? STI_BVEC3cxx . . $ STI_BVEC3. :
3228 (src.tidcxx . . $ SpirvResult#tid. == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC2cxx . . $ STI_VEC2.]) ? STI_BVEC2cxx . . $ STI_BVEC2. : STI_BOOLcxx . . $ STI_BOOL.;
3229
3230 uint32cxx . . $ uint32# tid_bvec = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, sti_bvec);
3231 uint32cxx . . $ uint32# id_one = spv_get_onecxx . . $ spv_get_one(1e2deca95f3d56bd).(ctx, src.tidcxx . . $ SpirvResult#tid.);
3232 uint32cxx . . $ uint32# id_zero = spv_get_zerocxx . . $ spv_get_zero(1e2deca95f3d56bd).(ctx, src.tidcxx . . $ SpirvResult#tid.);
3233 uint32cxx . . $ uint32# id_flt_max = spv_get_flt_maxcxx . . $ spv_get_flt_max(1e2deca95f3d56bd).(ctx, src.tidcxx . . $ SpirvResult#tid.);
3234 uint32cxx . . $ uint32# id_mask = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3235 uint32cxx . . $ uint32# id_div = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3236
3237 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdNotEqualcxx . . $ SpvOpFOrdNotEqual., tid_bvec, id_mask, src.idcxx . . $ SpirvResult#id., id_zero);
3238 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFDivcxx . . $ SpvOpFDiv., dst.tidcxx . . $ SpirvResult#tid., id_div, id_one, src.idcxx . . $ SpirvResult#id.);
3239 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., id_mask, id_div, id_flt_max);
3240
3241 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3242 } // emit_SPIRV_RCP
3243
3244 void emit_SPIRV_RSQcxx . . $ emit_SPIRV_RSQ(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3245 {
3246 /*
3247 if (src != 0.0f)
3248 dst = 1.0f / abs(src);
3249 else
3250 dst = FLT_MAX;
3251 */
3252 SpirvResultcxx . . $ SpirvResult# dst, src;
3253 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
3254
3255 SpirvTypeIdxcxx . . $ SpirvTypeIdx# sti_bvec =
3256 (src.tidcxx . . $ SpirvResult#tid. == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC4cxx . . $ STI_VEC4.]) ? STI_BVEC4cxx . . $ STI_BVEC4. :
3257 (src.tidcxx . . $ SpirvResult#tid. == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC3cxx . . $ STI_VEC3.]) ? STI_BVEC3cxx . . $ STI_BVEC3. :
3258 (src.tidcxx . . $ SpirvResult#tid. == ctx->spirvcxx . . $ Context#spirv..tidcxx . . $ SpirvContext#tid.[STI_VEC2cxx . . $ STI_VEC2.]) ? STI_BVEC2cxx . . $ STI_BVEC2. : STI_BOOLcxx . . $ STI_BOOL.;
3259
3260 uint32cxx . . $ uint32# tid_bvec = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, sti_bvec);
3261 uint32cxx . . $ uint32# id_zero = spv_get_zerocxx . . $ spv_get_zero(1e2deca95f3d56bd).(ctx, src.tidcxx . . $ SpirvResult#tid.);
3262 uint32cxx . . $ uint32# id_flt_max = spv_get_flt_maxcxx . . $ spv_get_flt_max(1e2deca95f3d56bd).(ctx, src.tidcxx . . $ SpirvResult#tid.);
3263 uint32cxx . . $ uint32# id_mask = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3264 uint32cxx . . $ uint32# id_abs = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3265 uint32cxx . . $ uint32# id_rsq = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3266
3267 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdNotEqualcxx . . $ SpvOpFOrdNotEqual., tid_bvec, id_mask, src.idcxx . . $ SpirvResult#id., id_zero);
3268 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., id_abs, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FAbscxx . . $ GLSLstd450FAbs., src.idcxx . . $ SpirvResult#id.);
3269 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., id_rsq, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450InverseSqrtcxx . . $ GLSLstd450InverseSqrt., id_abs);
3270 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., id_mask, id_rsq, id_flt_max);
3271
3272 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3273 } // emit_SPIRV_RSQ
3274
3275 void emit_SPIRV_EXPcxx . . $ emit_SPIRV_EXP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3276 {
3277 SpirvResultcxx . . $ SpirvResult# dst, src;
3278 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
3279 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450Exp2cxx . . $ GLSLstd450Exp2., src.idcxx . . $ SpirvResult#id.);
3280 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3281 } // emit_SPIRV_EXP
3282
3283 void emit_SPIRV_SGNcxx . . $ emit_SPIRV_SGN(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3284 {
3285 SpirvResultcxx . . $ SpirvResult# dst, src;
3286 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
3287
3288 // SGN also takes a src1 and src2 to use for intermediate results, they are
3289 // left undefined after the instruction executes, and as such it is
3290 // perfectly valid for us to not touch those registers in our implementation
3291 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FSigncxx . . $ GLSLstd450FSign., src.idcxx . . $ SpirvResult#id.);
3292
3293 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3294 } // emit_SPIRV_SGN
3295
3296 void emit_SPIRV_ABScxx . . $ emit_SPIRV_ABS(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3297 {
3298 SpirvResultcxx . . $ SpirvResult# dst, src;
3299 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
3300 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FAbscxx . . $ GLSLstd450FAbs., src.idcxx . . $ SpirvResult#id.);
3301 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3302 } // emit_SPIRV_ABS
3303
3304 void emit_SPIRV_NRMcxx . . $ emit_SPIRV_NRM(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3305 {
3306 /*
3307 float dot = dot(src, src);
3308
3309 float f;
3310 if (dot != 0)
3311 f = (float)(1/sqrt(dot));
3312 else
3313 f = FLT_MAX;
3314
3315 dst = src0*f;
3316 */
3317
3318 SpirvResultcxx . . $ SpirvResult# src = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
3319 uint32cxx . . $ uint32# tid_vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
3320 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
3321 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
3322 uint32cxx . . $ uint32# id_zero = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, 0.0f);
3323 uint32cxx . . $ uint32# id_flt_max = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, FLT_MAXcxx . . $ `<external>/18143172452841944454/float.h:104:9`!);
3324 uint32cxx . . $ uint32# id_src_xyz = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3325 uint32cxx . . $ uint32# id_dot = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3326 uint32cxx . . $ uint32# id_dot_valid = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3327 uint32cxx . . $ uint32# id_f = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3328 uint32cxx . . $ uint32# id_f_sane = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3329 uint32cxx . . $ uint32# id_f_vec = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3330
3331 SpirvResultcxx . . $ SpirvResult# dst;
3332 dst.tidcxx . . $ SpirvResult#tid. = src.tidcxx . . $ SpirvResult#tid.;
3333 dst.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3334
3335 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3336 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec3, id_src_xyz, src.idcxx . . $ SpirvResult#id., src.idcxx . . $ SpirvResult#id., 0, 1, 2);
3337 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., tid_float, id_dot, id_src_xyz, id_src_xyz);
3338 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdNotEqualcxx . . $ SpvOpFOrdNotEqual., tid_bool, id_dot_valid, id_dot, id_zero);
3339 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., tid_float, id_f, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450InverseSqrtcxx . . $ GLSLstd450InverseSqrt., id_dot);
3340 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., tid_float, id_f_sane, id_dot_valid, id_f, id_flt_max);
3341 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., dst.tidcxx . . $ SpirvResult#tid., id_f_vec, id_f_sane, id_f_sane, id_f_sane, id_f_sane);
3342 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., src.idcxx . . $ SpirvResult#id., id_f_vec);
3343 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3344 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, dst);
3345 } // emit_SPIRV_NRM
3346
3347 void emit_SPIRV_FRCcxx . . $ emit_SPIRV_FRC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3348 {
3349 SpirvResultcxx . . $ SpirvResult# dst, src;
3350 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
3351 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450Fractcxx . . $ GLSLstd450Fract., src.idcxx . . $ SpirvResult#id.);
3352 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3353 } // emit_SPIRV_FRC
3354
3355 void emit_SPIRV_LOGcxx . . $ emit_SPIRV_LOG(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3356 {
3357 SpirvResultcxx . . $ SpirvResult# dst, src;
3358 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
3359
3360 // LOG(x) := (x == vec4(0.0)) ? vec4(-FLT_MAX) : log2(abs(x))
3361
3362 // abs(x)
3363 uint32cxx . . $ uint32# abs_src0 = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3364 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., abs_src0, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FAbscxx . . $ GLSLstd450FAbs., src.idcxx . . $ SpirvResult#id.);
3365
3366 // vec4(0.0)
3367 uint32cxx . . $ uint32# vec4_zero = spv_vectorbroadcastcxx . . $ spv_vectorbroadcast(a939eba8b1993c99).(ctx, dst.tidcxx . . $ SpirvResult#tid., spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, 0.0f));
3368
3369 // x == vec4(0.0)
3370 uint32cxx . . $ uint32# is_zero = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3371 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFOrdEqualcxx . . $ SpvOpFOrdEqual., spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BVEC4cxx . . $ STI_BVEC4.), is_zero, abs_src0, vec4_zero);
3372
3373 // log2(abs(x))
3374 uint32cxx . . $ uint32# log2_of_nonzero = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3375 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., dst.tidcxx . . $ SpirvResult#tid., log2_of_nonzero, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450Log2cxx . . $ GLSLstd450Log2., abs_src0);
3376
3377 // vec4(-FLT_MAX)
3378 uint32cxx . . $ uint32# vec4_neg_flt_max = spv_vectorbroadcastcxx . . $ spv_vectorbroadcast(a939eba8b1993c99).(ctx, dst.tidcxx . . $ SpirvResult#tid., spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, -FLT_MAXcxx . . $ `<external>/18143172452841944454/float.h:104:9`!));
3379
3380 // (x == vec4(0.0)) ? vec4(-FLT_MAX) : log2(abs(x))
3381 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., is_zero, vec4_neg_flt_max, log2_of_nonzero);
3382
3383 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3384 } // emit_SPIRV_LOG
3385
3386 void emit_SPIRV_SINCOScxx . . $ emit_SPIRV_SINCOS(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3387 {
3388 SpirvResultcxx . . $ SpirvResult# src = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, 0x1);
3389
3390 // For vs_2_0 and vs_2_x this instruction also has a src1 and src2 which provide a couple of constants
3391 // We just ignore these in any case
3392
3393 // float V = src0.x;
3394
3395 int writemask = ctx->dest_argcxx . . $ Context#dest_arg..writemaskcxx . . $ $anonymous_type_32753e8ce5863620_5#writemask.;
3396 uint32cxx . . $ uint32# id_zero = spv_get_zerocxx . . $ spv_get_zero(1e2deca95f3d56bd).(ctx, src.tidcxx . . $ SpirvResult#tid.);
3397
3398 uint32cxx . . $ uint32# id_cos;
3399 if (writemask & 1) // .x = cos(V)
3400 {
3401 id_cos = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3402 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., src.tidcxx . . $ SpirvResult#tid., id_cos, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450Coscxx . . $ GLSLstd450Cos., src.idcxx . . $ SpirvResult#id.);
3403 } // if
3404 else
3405 id_cos = id_zero;
3406
3407 uint32cxx . . $ uint32# id_sin;
3408 if (writemask & 2) // .y = sin(V)
3409 {
3410 id_sin = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3411 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., src.tidcxx . . $ SpirvResult#tid., id_sin, spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450Sincxx . . $ GLSLstd450Sin., src.idcxx . . $ SpirvResult#id.);
3412 } // if
3413 else
3414 id_sin = id_zero;
3415
3416 SpirvResultcxx . . $ SpirvResult# dst;
3417 dst.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
3418 dst.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3419 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., id_cos, id_sin, id_zero, id_zero);
3420
3421 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, dst);
3422 } // emit_SPIRV_SINCOS
3423
3424 void emit_SPIRV_MOVAcxx . . $ emit_SPIRV_MOVA(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3425 {
3426 SpirvResultcxx . . $ SpirvResult# src = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
3427 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(src.tid == spv_get_type(ctx, STI_VEC4));
3428
3429 uint32cxx . . $ uint32# id_rounded = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3430
3431 SpirvResultcxx . . $ SpirvResult# dst;
3432 dst.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IVEC4cxx . . $ STI_IVEC4.);
3433 dst.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3434
3435 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3436 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 1, SpvOpExtInstcxx . . $ SpvOpExtInst., spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.), id_rounded,
3437 spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450Roundcxx . . $ GLSLstd450Round., src.idcxx . . $ SpirvResult#id.);
3438 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpConvertFToScxx . . $ SpvOpConvertFToS., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., id_rounded);
3439 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3440
3441 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, dst);
3442 } // emit_SPIRV_MOVA
3443
3444 void emit_SPIRV_CMPcxx . . $ emit_SPIRV_CMP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3445 {
3446 SpirvResultcxx . . $ SpirvResult# dst, src0, src1, src2;
3447 spv_emit_begin_dssscxx . . $ spv_emit_begin_dsss(96e971bdd9b7ae7d).(ctx, &dst, &src0, &src1, &src2);
3448 uint32cxx . . $ uint32# id_0_0 = spv_get_zerocxx . . $ spv_get_zero(1e2deca95f3d56bd).(ctx, src0.tidcxx . . $ SpirvResult#tid.);
3449
3450 uint32cxx . . $ uint32# id_cmp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3451 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFUnordGreaterThanEqualcxx . . $ SpvOpFUnordGreaterThanEqual., spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BVEC4cxx . . $ STI_BVEC4.), id_cmp, src0.idcxx . . $ SpirvResult#id., id_0_0);
3452 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., id_cmp, src1.idcxx . . $ SpirvResult#id., src2.idcxx . . $ SpirvResult#id.);
3453 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3454 } // emit_SPIRV_CMP
3455
3456 void emit_SPIRV_CNDcxx . . $ emit_SPIRV_CND(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3457 {
3458 SpirvResultcxx . . $ SpirvResult# dst, src0, src1, src2;
3459 spv_emit_begin_dssscxx . . $ spv_emit_begin_dsss(96e971bdd9b7ae7d).(ctx, &dst, &src0, &src1, &src2);
3460 uint32cxx . . $ uint32# id_0_5 = spv_get_constant_compositecxx . . $ spv_get_constant_composite(f49fab4a412a2082).(ctx, src0.tidcxx . . $ SpirvResult#tid., ctx->spirvcxx . . $ Context#spirv..id_0_5cxx . . $ SpirvContext#id_0_5., 0.5f);
3461
3462 uint32cxx . . $ uint32# id_cmp = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3463 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFUnordGreaterThancxx . . $ SpvOpFUnordGreaterThan., spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BVEC4cxx . . $ STI_BVEC4.), id_cmp, src0.idcxx . . $ SpirvResult#id., id_0_5);
3464 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 6, SpvOpSelectcxx . . $ SpvOpSelect., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., id_cmp, src1.idcxx . . $ SpirvResult#id., src2.idcxx . . $ SpirvResult#id.);
3465 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3466 } // emit_SPIRV_CND
3467
3468 void emit_SPIRV_LITcxx . . $ emit_SPIRV_LIT(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3469 {
3470 SpirvResultcxx . . $ SpirvResult# dst, src;
3471 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
3472
3473 if (!ctx->spirvcxx . . $ Context#spirv..id_func_litcxx . . $ SpirvContext#id_func_lit.)
3474 ctx->spirvcxx . . $ Context#spirv..id_func_litcxx . . $ SpirvContext#id_func_lit. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3475
3476 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFunctionCallcxx . . $ SpvOpFunctionCall., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., ctx->spirvcxx . . $ Context#spirv..id_func_litcxx . . $ SpirvContext#id_func_lit., src.idcxx . . $ SpirvResult#id.);
3477
3478 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3479 } // emit_SPIRV_LIT
3480
3481 void emit_SPIRV_DSTcxx . . $ emit_SPIRV_DST(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3482 {
3483 SpirvResultcxx . . $ SpirvResult# dst, src0, src1;
3484 spv_emit_begin_dsscxx . . $ spv_emit_begin_dss(d2f059aec203465a).(ctx, &dst, &src0, &src1);
3485
3486 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
3487 dst.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
3488 uint32cxx . . $ uint32# id_1_0 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, 1.0f);
3489 uint32cxx . . $ uint32# id_src0_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3490 uint32cxx . . $ uint32# id_src1_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3491 uint32cxx . . $ uint32# id_src0_z = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3492 uint32cxx . . $ uint32# id_src1_w = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3493 uint32cxx . . $ uint32# id_dst_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3494 dst.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3495
3496 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_src0_y, src0.idcxx . . $ SpirvResult#id., 1);
3497 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_src1_y, src1.idcxx . . $ SpirvResult#id., 1);
3498 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_src0_z, src0.idcxx . . $ SpirvResult#id., 2);
3499 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_src1_w, src1.idcxx . . $ SpirvResult#id., 3);
3500 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFMulcxx . . $ SpvOpFMul., tid_float, id_dst_y, id_src0_y, id_src1_y);
3501 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., id_1_0, id_dst_y, id_src0_z, id_src1_w);
3502
3503 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
3504 } // emit_SPIRV_DST
3505
3506 void emit_SPIRV_LRPcxx . . $ emit_SPIRV_LRP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3507 {
3508 // lerp(x, y, a) = x + a*(y - x)
3509 // = x*(1 - a) + y*a
3510 SpirvResultcxx . . $ SpirvResult# a = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0); // 'scale'
3511 SpirvResultcxx . . $ SpirvResult# y = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1); // 'end'
3512 SpirvResultcxx . . $ SpirvResult# x = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 2); // 'start'
3513 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(x.tid == y.tid);
3514 SpirvResultcxx . . $ SpirvResult# result;
3515 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3516 result.tidcxx . . $ SpirvResult#tid. = x.tidcxx . . $ SpirvResult#tid.;
3517
3518 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3519 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpExtInstcxx . . $ SpvOpExtInst., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., spv_getextcxx . . $ spv_getext(6d86621a4076bebf).(ctx), GLSLstd450FMixcxx . . $ GLSLstd450FMix., x.idcxx . . $ SpirvResult#id., y.idcxx . . $ SpirvResult#id., a.idcxx . . $ SpirvResult#id.);
3520 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3521
3522 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
3523 } // emit_SPIRV_LRP
3524
3525 static void spv_emit_vecXmatrixcxx . . $ spv_emit_vecXmatrix(f097640709b383).(Contextcxx . . $ Context# *ctx, int rows, int writemask)
3526 {
3527 int i;
3528
3529 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(rows <= 4);
3530 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(writemask == 0x7 || writemask == 0xF);
3531
3532 uint32cxx . . $ uint32# src0 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, writemask).idcxx . . $ SpirvResult#id.;
3533 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
3534
3535 RegisterTypecxx . . $ RegisterType# src1type = ctx->source_argscxx . . $ Context#source_args.[1].regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype.;
3536 int src1num = ctx->source_argscxx . . $ Context#source_args.[1].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.;
3537
3538 uint32cxx . . $ uint32# result_components[4];
3539 for (i = 0; i < rows; i++)
3540 {
3541 SpirvResultcxx . . $ SpirvResult# row = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, src1type, src1num + i));
3542 row = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, row, SPV_NO_SWIZZLEcxx . . $ SPV_NO_SWIZZLE., writemask);
3543 uint32cxx . . $ uint32# dot_result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3544
3545 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3546 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., tid_float, dot_result, src0, row.idcxx . . $ SpirvResult#id.);
3547 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3548
3549 result_components[i] = dot_result;
3550 } // for
3551
3552 SpirvResultcxx . . $ SpirvResult# r;
3553 r.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
3554 r.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3555
3556 uint32cxx . . $ uint32# id_zero = 0;
3557 if (rows < 4)
3558 id_zero = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, 0.0f);
3559
3560 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3561 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, 3 + 4, 3, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., r.tidcxx . . $ SpirvResult#tid., r.idcxx . . $ SpirvResult#id.);
3562 for (i = 0; i < rows; i++) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, result_components[i]);
3563 for (i = rows; i < 4; i++) spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, id_zero);
3564 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3565
3566 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, r);
3567 } // spv_emit_vecXmatrix
3568
3569 void emit_SPIRV_M4X4cxx . . $ emit_SPIRV_M4X4(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3570 {
3571 // float4 * (4 columns, 4 rows) -> float4
3572 spv_emit_vecXmatrixcxx . . $ spv_emit_vecXmatrix(f097640709b383).(ctx, 4, 0xF);
3573 } // emit_SPIRV_M4X4
3574
3575 void emit_SPIRV_M4X3cxx . . $ emit_SPIRV_M4X3(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3576 {
3577 // float4 * (4 columns, 3 rows) -> float3
3578 spv_emit_vecXmatrixcxx . . $ spv_emit_vecXmatrix(f097640709b383).(ctx, 3, 0xF);
3579 } // emit_SPIRV_M4X3
3580
3581 void emit_SPIRV_M3X4cxx . . $ emit_SPIRV_M3X4(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3582 {
3583 // float3 * (3 columns, 4 rows) -> float4
3584 spv_emit_vecXmatrixcxx . . $ spv_emit_vecXmatrix(f097640709b383).(ctx, 4, 0x7);
3585 } // emit_SPIRV_M3X4
3586
3587 void emit_SPIRV_M3X3cxx . . $ emit_SPIRV_M3X3(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3588 {
3589 // float3 * (3 columns, 3 rows) -> float3
3590 spv_emit_vecXmatrixcxx . . $ spv_emit_vecXmatrix(f097640709b383).(ctx, 3, 0x7);
3591 } // emit_SPIRV_M3X3
3592
3593 void emit_SPIRV_M3X2cxx . . $ emit_SPIRV_M3X2(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3594 {
3595 // float3 * (3 columns, 2 rows) -> float2
3596 spv_emit_vecXmatrixcxx . . $ spv_emit_vecXmatrix(f097640709b383).(ctx, 2, 0x7);
3597 } // emit_SPIRV_M3X2
3598
3599 void emit_SPIRV_TEXLDcxx . . $ emit_SPIRV_TEXLD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3600 {
3601 if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 1, 4))
3602 {
3603 DestArgInfocxx . . $ DestArgInfo# *dst_info = &ctx->dest_argcxx . . $ Context#dest_arg.;
3604
3605 RegisterListcxx . . $ RegisterList# *sreg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., dst_info->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
3606 RegisterListcxx . . $ RegisterList# *treg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, dst_info->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., dst_info->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
3607
3608 // Variables are not declared using dcl opcodes, so handle it in this instruction.
3609 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(sreg->spirv.iddecl == 0);
3610 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(treg->spirv.iddecl == 0);
3611
3612 // Prep the result
3613 SpirvResultcxx . . $ SpirvResult# result;
3614 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
3615 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3616 SpirvResultcxx . . $ SpirvResult# sampler = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, sreg);
3617 // OpImageSampleImplicitLod should ignore the components of this argument that
3618 // it doesn't need, so we don't need to mask it
3619 SpirvResultcxx . . $ SpirvResult# texcoord = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, treg);
3620
3621 // Generate the instruction.
3622 // OpImageSampleImplicitLod should ignore the components of the
3623 // texcoord that it doesn't need, so we don't need to mask it.
3624 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3625 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpImageSampleImplicitLodcxx . . $ SpvOpImageSampleImplicitLod., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id.,
3626 sampler.idcxx . . $ SpirvResult#id., texcoord.idcxx . . $ SpirvResult#id.);
3627 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3628
3629 // Emit the result, finally.
3630 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!isscalar(ctx, ctx->shader_type, sreg->regtype, sreg->regnum));
3631 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
3632 } // if
3633
3634 else if (!shader_version_atleastcxx . . $ shader_version_atleast(83a707663ee9af3d).(ctx, 2, 0))
3635 {
3636 // ps_1_4 is different, too!
3637 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "TEXLD == Shader Model 1.4 unimplemented."); // !!! FIXME
3638 return;
3639 } // else if
3640
3641 else
3642 {
3643 const SourceArgInfocxx . . $ SourceArgInfo# *samp_arg = &ctx->source_argscxx . . $ Context#source_args.[1];
3644 RegisterListcxx . . $ RegisterList# *sampler_reg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., samp_arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
3645 const SourceArgInfocxx . . $ SourceArgInfo# *texcoord_arg = &ctx->source_argscxx . . $ Context#source_args.[0];
3646 RegisterListcxx . . $ RegisterList# *texcoord_reg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, texcoord_arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., texcoord_arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
3647
3648 if (sampler_reg == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
3649 {
3650 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "TEXLD using undeclared sampler");
3651 return;
3652 } // if
3653
3654 // OpImageSampleImplicitLod should ignore the components of this argument that
3655 // it doesn't need, so we don't need to mask it
3656 uint32cxx . . $ uint32# texcoord = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0).idcxx . . $ SpirvResult#id.;
3657 uint32cxx . . $ uint32# sampler = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1).idcxx . . $ SpirvResult#id.;
3658
3659 // Special case for TEXLDB
3660 // !!! FIXME: does the d3d bias value map directly to GLSL?
3661 uint32cxx . . $ uint32# bias;
3662 uint32cxx . . $ uint32# instruction_length;
3663 if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDBcxx . . $ `mojoshader_internal.h:473:9`!)
3664 {
3665 uint32cxx . . $ uint32# float_tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
3666 bias = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3667 instruction_length = 7;
3668
3669 // The w component of texcoord_reg specifies the bias. Extract it from texcoord_reg
3670 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3671 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4 + 1, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., float_tid, bias, texcoord, 3);
3672 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3673 } // if
3674 else
3675 {
3676 bias = 0;
3677 instruction_length = 5;
3678 } // else
3679
3680 // Determine the opcode
3681 SpvOpcxx . . $ SpvOp# opcode;
3682 if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDPcxx . . $ `mojoshader_internal.h:472:9`!)
3683 {
3684 if ((TextureTypecxx . . $ TextureType#) sampler_reg->indexcxx . . $ RegisterList#index. == TEXTURE_TYPE_CUBEcxx . . $ TEXTURE_TYPE_CUBE.)
3685 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "TEXLDP on a cubemap"); // !!! FIXME: is this legal?
3686 opcode = SpvOpImageSampleProjImplicitLodcxx . . $ SpvOpImageSampleProjImplicitLod.;
3687 } // if
3688 else
3689 opcode = SpvOpImageSampleImplicitLodcxx . . $ SpvOpImageSampleImplicitLod.;
3690
3691 // Prep the result
3692 uint32cxx . . $ uint32# vec4_tid = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
3693 uint32cxx . . $ uint32# result = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3694
3695 // Generate the instruction.
3696 // OpImageSampleImplicitLod should ignore the components of the
3697 // texcoord that it doesn't need, so we don't need to mask it.
3698 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3699 spv_emit_partcxx . . $ spv_emit_part(7176a80f0d873e47).(ctx, instruction_length, 5, opcode, vec4_tid, result,
3700 sampler, texcoord);
3701 if (ctx->instruction_controlscxx . . $ Context#instruction_controls. == CONTROL_TEXLDBcxx . . $ `mojoshader_internal.h:473:9`!)
3702 {
3703 // ... include the bias operand, if applicable
3704 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, SpvImageOperandsBiasMaskcxx . . $ SpvImageOperandsBiasMask.);
3705 spv_emit_wordcxx . . $ spv_emit_word(d867d534d1c117ac).(ctx, bias);
3706 } // if
3707 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3708
3709 // Emit the result, finally.
3710 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!isscalar(ctx, ctx->shader_type, samp_arg->regtype, samp_arg->regnum));
3711 SpirvResultcxx . . $ SpirvResult# r;
3712 r.idcxx . . $ SpirvResult#id. = result;
3713 r.tidcxx . . $ SpirvResult#tid. = vec4_tid;
3714 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, r);
3715 } // else
3716 } // emit_SPIRV_TEXLD
3717
3718 void emit_SPIRV_IFcxx . . $ emit_SPIRV_IF(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3719 {
3720 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, 0x1);
3721 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
3722 uint32cxx . . $ uint32# id_cond = src0.idcxx . . $ SpirvResult#id.;
3723
3724 // Predicate register is already boolean so no need to convert.
3725 if (src0.tidcxx . . $ SpirvResult#tid. != tid_bool)
3726 {
3727 uint32cxx . . $ uint32# id_zero = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, 0);
3728 id_cond = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3729 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpINotEqualcxx . . $ SpvOpINotEqual., tid_bool, id_cond, src0.idcxx . . $ SpirvResult#id., id_zero);
3730 } // if
3731
3732 uint32cxx . . $ uint32# id_label_branch = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3733 uint32cxx . . $ uint32# id_label_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3734 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., id_label_merge, 0);
3735 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., id_cond, id_label_branch, id_label_merge);
3736 spv_branch_pushcxx . . $ spv_branch_push(faac5a9eeb4c548).(ctx, id_label_merge, buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->outputcxx . . $ Context#output.) - 4);
3737 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_branch);
3738 } // emit_SPIRV_IF
3739
3740 void emit_SPIRV_IFCcxx . . $ emit_SPIRV_IFC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3741 {
3742 SpvOpcxx . . $ SpvOp# cmp_op = spv_get_comparisoncxx . . $ spv_get_comparison(707404df50257c9c).(ctx);
3743 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, 0x1);
3744 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 1, 0x1);
3745 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
3746 uint32cxx . . $ uint32# id_cond = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3747 uint32cxx . . $ uint32# id_label_branch = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3748 uint32cxx . . $ uint32# id_label_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3749
3750 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, cmp_op, tid_bool, id_cond, src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3751 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., id_label_merge, 0);
3752 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., id_cond, id_label_branch, id_label_merge);
3753 spv_branch_pushcxx . . $ spv_branch_push(faac5a9eeb4c548).(ctx, id_label_merge, buffer_sizecxx . . $ buffer_size(ecc380cc53efe3bc).(ctx->outputcxx . . $ Context#output.) - 4);
3754 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_branch);
3755 } // emit_SPIRV_IFC
3756
3757 void emit_SPIRV_ELSEcxx . . $ emit_SPIRV_ELSE(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3758 {
3759 uint32cxx . . $ uint32# id_label_merge, patch_offset;
3760 spv_branch_getcxx . . $ spv_branch_get(9fc2ff0b2fdf2d33).(ctx, &id_label_merge, &patch_offset);
3761 uint32cxx . . $ uint32# id_label_else = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3762
3763 buffer_patchcxx . . $ buffer_patch(b50c5e09500c0639).(ctx->outputcxx . . $ Context#output., patch_offset, &id_label_else, sizeof(id_label_else));
3764 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_label_merge);
3765 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_else);
3766 } // emit_SPIRV_ELSE
3767
3768 void emit_SPIRV_ENDIFcxx . . $ emit_SPIRV_ENDIF(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3769 {
3770 uint32cxx . . $ uint32# id_label_merge, patch_offset;
3771 spv_branch_popcxx . . $ spv_branch_pop(9fc2ff0b2fdf2d33).(ctx, &id_label_merge, &patch_offset);
3772
3773 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_label_merge);
3774 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_merge);
3775 } // emit_SPIRV_ENDIF
3776
3777 void emit_SPIRV_REPcxx . . $ emit_SPIRV_REP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3778 {
3779 SpirvLoopInfocxx . . $ SpirvLoopInfo# loop = {0};
3780 uint32cxx . . $ uint32# id_label_init = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3781 loop.id_label_headercxx . . $ SpirvLoopInfo#id_label_header. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3782 uint32cxx . . $ uint32# id_label_cond = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3783 uint32cxx . . $ uint32# id_label_body = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3784 loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3785 loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3786
3787 // emit end of previous block
3788 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_label_init);
3789
3790 // emit loop init block
3791 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_init);
3792 // This block only exists to allow use of SpvOpPhi in loop header block.
3793 // SpvOpPhi needs to refer to predecessor by it's label ID, so insert dummy
3794 // block just so we know what the ID is.
3795 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, 0x1);
3796
3797 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
3798 loop.tid_countercxx . . $ SpirvLoopInfo#tid_counter. = src0.tidcxx . . $ SpirvResult#tid.;
3799 loop.id_countercxx . . $ SpirvLoopInfo#id_counter. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3800 loop.id_counter_nextcxx . . $ SpirvLoopInfo#id_counter_next. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3801
3802 uint32cxx . . $ uint32# id_cond = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3803 uint32cxx . . $ uint32# id_zero = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, 0);
3804 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., loop.id_label_headercxx . . $ SpirvLoopInfo#id_label_header.);
3805
3806 // emit loop header block
3807 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., loop.id_label_headercxx . . $ SpirvLoopInfo#id_label_header.);
3808 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 7, SpvOpPhicxx . . $ SpvOpPhi., loop.tid_countercxx . . $ SpirvLoopInfo#tid_counter., loop.id_countercxx . . $ SpirvLoopInfo#id_counter.,
3809 src0.idcxx . . $ SpirvResult#id., id_label_init,
3810 loop.id_counter_nextcxx . . $ SpirvLoopInfo#id_counter_next., loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue.
3811 );
3812 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoopMergecxx . . $ SpvOpLoopMerge., loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge., loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue., 0);
3813 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_label_cond);
3814
3815 // emit loop condition block
3816 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_cond);
3817 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpINotEqualcxx . . $ SpvOpINotEqual., tid_bool, id_cond, loop.id_countercxx . . $ SpirvLoopInfo#id_counter., id_zero);
3818 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., id_cond, id_label_body, loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge.);
3819
3820 // emit start of loop body block
3821 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_body);
3822
3823 spv_loop_pushcxx . . $ spv_loop_push(74c03ff29b28db54).(ctx, &loop);
3824 } // emit_SPIRV_REP
3825
3826 void emit_SPIRV_ENDREPcxx . . $ emit_SPIRV_ENDREP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3827 {
3828 uint32cxx . . $ uint32# id_one = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, 1);
3829 SpirvLoopInfocxx . . $ SpirvLoopInfo# loop;
3830 spv_loop_popcxx . . $ spv_loop_pop(cc007d5229ba26e6).(ctx, &loop);
3831
3832 // emit end of loop body block
3833 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue.);
3834
3835 // emit loop continue block
3836 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue.);
3837 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpISubcxx . . $ SpvOpISub., loop.tid_countercxx . . $ SpirvLoopInfo#tid_counter., loop.id_counter_nextcxx . . $ SpirvLoopInfo#id_counter_next., loop.id_countercxx . . $ SpirvLoopInfo#id_counter., id_one);
3838 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., loop.id_label_headercxx . . $ SpirvLoopInfo#id_label_header.);
3839
3840 // emit start of next block
3841 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge.);
3842 } // emit_SPIRV_ENDREP
3843
3844 void emit_SPIRV_LOOPcxx . . $ emit_SPIRV_LOOP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3845 {
3846 SpirvLoopInfocxx . . $ SpirvLoopInfo# loop = {0};
3847 uint32cxx . . $ uint32# id_label_init = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3848 loop.id_label_headercxx . . $ SpirvLoopInfo#id_label_header. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3849 uint32cxx . . $ uint32# id_label_cond = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3850 uint32cxx . . $ uint32# id_label_body = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3851 loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3852 loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3853
3854 /*
3855 i#.x = iteration count; every round we decrement it and terminate on 0.
3856 i#.y = aL initial value; every round we subtract aL step from it.
3857 i#.z = aL step value;
3858
3859 We use copy of i# as iteration variable. Compared to rep loop, we only
3860 need to add single instruction for extracting current aL value as single
3861 int.
3862
3863 rep i0
3864 for (int i = i0.x; i; i--)
3865
3866 loop aL, i0
3867 for (int3 i = i0, int aL = i.y; i.x; i.x--, aL += i.z)
3868 */
3869
3870 // emit end of previous block
3871 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_label_init);
3872
3873 // emit loop init block
3874 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_init);
3875 // This block only exists to allow use of SpvOpPhi in loop header block.
3876 // SpvOpPhi needs to refer to predecessor by it's label ID, so insert dummy block just so we
3877 // know what the ID is.
3878
3879 // src0 has aL register. Does it hold any interesting information?
3880 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 1, 0x7);
3881 uint32cxx . . $ uint32# tid_int = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
3882 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
3883
3884 loop.tid_countercxx . . $ SpirvLoopInfo#tid_counter. = src1.tidcxx . . $ SpirvResult#tid.;
3885 loop.id_countercxx . . $ SpirvLoopInfo#id_counter. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3886 loop.id_counter_nextcxx . . $ SpirvLoopInfo#id_counter_next. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3887 loop.id_aLcxx . . $ SpirvLoopInfo#id_aL. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3888 uint32cxx . . $ uint32# id_counter_x = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3889
3890 uint32cxx . . $ uint32# id_cond = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3891 uint32cxx . . $ uint32# id_zero = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, 0);
3892 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., loop.id_label_headercxx . . $ SpirvLoopInfo#id_label_header.);
3893
3894 // emit loop header block
3895 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., loop.id_label_headercxx . . $ SpirvLoopInfo#id_label_header.);
3896 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 7, SpvOpPhicxx . . $ SpvOpPhi., loop.tid_countercxx . . $ SpirvLoopInfo#tid_counter., loop.id_countercxx . . $ SpirvLoopInfo#id_counter.,
3897 src1.idcxx . . $ SpirvResult#id., id_label_init,
3898 loop.id_counter_nextcxx . . $ SpirvLoopInfo#id_counter_next., loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue.
3899 );
3900 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_int, loop.id_aLcxx . . $ SpirvLoopInfo#id_aL., loop.id_countercxx . . $ SpirvLoopInfo#id_counter., 1);
3901 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpLoopMergecxx . . $ SpvOpLoopMerge., loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge., loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue., 0);
3902 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_label_cond);
3903
3904 // emit loop condition block
3905 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_cond);
3906 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_int, id_counter_x, loop.id_countercxx . . $ SpirvLoopInfo#id_counter., 0);
3907 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpINotEqualcxx . . $ SpvOpINotEqual., tid_bool, id_cond, id_counter_x, id_zero);
3908 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., id_cond, id_label_body, loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge.);
3909
3910 // emit start of loop body block
3911 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_body);
3912
3913 spv_loop_pushcxx . . $ spv_loop_push(74c03ff29b28db54).(ctx, &loop);
3914 } // emit_SPIRV_LOOP
3915
3916 void emit_SPIRV_ENDLOOPcxx . . $ emit_SPIRV_ENDLOOP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3917 {
3918 uint32cxx . . $ uint32# tid_int = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_INTcxx . . $ STI_INT.);
3919 uint32cxx . . $ uint32# tid_ivec2 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_IVEC2cxx . . $ STI_IVEC2.);
3920
3921 uint32cxx . . $ uint32# id_minus_one = spv_getscalaricxx . . $ spv_getscalari(6a46fdf32a2b2126).(ctx, -1);
3922 uint32cxx . . $ uint32# id_counter_z = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3923 uint32cxx . . $ uint32# id_inc = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3924 uint32cxx . . $ uint32# id_counter_xy = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3925 uint32cxx . . $ uint32# id_counter_next_xy = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3926
3927 SpirvLoopInfocxx . . $ SpirvLoopInfo# loop;
3928 spv_loop_popcxx . . $ spv_loop_pop(cc007d5229ba26e6).(ctx, &loop);
3929
3930 // emit end of loop body block
3931 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue.);
3932
3933 // emit loop continue block
3934 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., loop.id_label_continuecxx . . $ SpirvLoopInfo#id_label_continue.);
3935 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_int, id_counter_z, loop.id_countercxx . . $ SpirvLoopInfo#id_counter., 2);
3936 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_ivec2, id_inc, id_minus_one, id_counter_z);
3937 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 7, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_ivec2, id_counter_xy, loop.id_countercxx . . $ SpirvLoopInfo#id_counter., loop.id_countercxx . . $ SpirvLoopInfo#id_counter., 0, 1);
3938 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpIAddcxx . . $ SpvOpIAdd., tid_ivec2, id_counter_next_xy, id_counter_xy, id_inc);
3939 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., loop.tid_countercxx . . $ SpirvLoopInfo#tid_counter., loop.id_counter_nextcxx . . $ SpirvLoopInfo#id_counter_next., id_counter_next_xy, id_counter_z);
3940 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., loop.id_label_headercxx . . $ SpirvLoopInfo#id_label_header.);
3941
3942 // emit start of next block
3943 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge.);
3944 } // emit_SPIRV_ENDLOOP
3945
3946 void emit_SPIRV_BREAKCcxx . . $ emit_SPIRV_BREAKC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3947 {
3948 SpirvLoopInfocxx . . $ SpirvLoopInfo# loop;
3949 spv_loop_getcxx . . $ spv_loop_get(cc007d5229ba26e6).(ctx, &loop);
3950
3951 SpvOpcxx . . $ SpvOp# cmp_op = spv_get_comparisoncxx . . $ spv_get_comparison(707404df50257c9c).(ctx);
3952 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, 0x1);
3953 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 1, 0x1);
3954 uint32cxx . . $ uint32# tid_bool = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BOOLcxx . . $ STI_BOOL.);
3955 uint32cxx . . $ uint32# id_cond = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3956 uint32cxx . . $ uint32# id_label_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3957
3958 // emit branch to merge target
3959 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, cmp_op, tid_bool, id_cond, src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
3960 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., id_label_merge, 0);
3961 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., id_cond, loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge., id_label_merge);
3962 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_merge);
3963 } // emit_SPIRV_BREAKC
3964
3965 void emit_SPIRV_BREAKPcxx . . $ emit_SPIRV_BREAKP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3966 {
3967 SpirvLoopInfocxx . . $ SpirvLoopInfo# loop;
3968 spv_loop_getcxx . . $ spv_loop_get(cc007d5229ba26e6).(ctx, &loop);
3969
3970 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 0, 0x1);
3971
3972 uint32cxx . . $ uint32# id_label_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3973
3974 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., id_label_merge, 0);
3975 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., src0.idcxx . . $ SpirvResult#id., loop.id_label_mergecxx . . $ SpirvLoopInfo#id_label_merge., id_label_merge);
3976 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_merge);
3977 } // emit_SPIRV_BREAKP
3978
3979 void emit_SPIRV_LABELcxx . . $ emit_SPIRV_LABEL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3980 {
3981 const SourceArgInfocxx . . $ SourceArgInfo#* arg = &ctx->source_argscxx . . $ Context#source_args.[0];
3982 RegisterListcxx . . $ RegisterList# *reg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
3983 spv_check_read_reg_idcxx . . $ spv_check_read_reg_id(5816d8773d24d3ec).(ctx, reg);
3984
3985 uint32cxx . . $ uint32# tid_void = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VOIDcxx . . $ STI_VOID.);
3986 uint32cxx . . $ uint32# tid_func = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FUNC_VOIDcxx . . $ STI_FUNC_VOID.);
3987 uint32cxx . . $ uint32# id_func = reg->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
3988 uint32cxx . . $ uint32# id_label = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
3989
3990 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
3991 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpFunctioncxx . . $ SpvOpFunction., tid_void, id_func, 0, tid_func);
3992 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label);
3993 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
3994 } // emit_SPIRV_LABEL
3995
3996 void emit_SPIRV_RETcxx . . $ emit_SPIRV_RET(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
3997 {
3998 spv_emit_func_endcxx . . $ spv_emit_func_end(612dd59919e2530e).(ctx);
3999 } // emit_SPIRV_RET
4000
4001 void emit_SPIRV_CALLcxx . . $ emit_SPIRV_CALL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4002 {
4003 const SourceArgInfocxx . . $ SourceArgInfo#* arg = &ctx->source_argscxx . . $ Context#source_args.[0];
4004 RegisterListcxx . . $ RegisterList# *reg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
4005 spv_check_read_reg_idcxx . . $ spv_check_read_reg_id(5816d8773d24d3ec).(ctx, reg);
4006
4007 uint32cxx . . $ uint32# tid_void = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VOIDcxx . . $ STI_VOID.);
4008 uint32cxx . . $ uint32# id_res = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4009 uint32cxx . . $ uint32# id_func = reg->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
4010
4011 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4012 if (ctx->loopscxx . . $ Context#loops. > 0)
4013 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Function calls referencing aL not implemented.");
4014 else
4015 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpFunctionCallcxx . . $ SpvOpFunctionCall., tid_void, id_res, id_func);
4016
4017 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4018 } // emit_SPIRV_CALL
4019
4020 void emit_SPIRV_CALLNZcxx . . $ emit_SPIRV_CALLNZ(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4021 {
4022 const SourceArgInfocxx . . $ SourceArgInfo#* arg = &ctx->source_argscxx . . $ Context#source_args.[0];
4023 RegisterListcxx . . $ RegisterList# *reg = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, arg->regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
4024 spv_check_read_reg_idcxx . . $ spv_check_read_reg_id(5816d8773d24d3ec).(ctx, reg);
4025
4026 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcargcxx . . $ spv_load_srcarg(457b7ae801ee8f).(ctx, 1, 0x1);
4027
4028 uint32cxx . . $ uint32# tid_void = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VOIDcxx . . $ STI_VOID.);
4029 uint32cxx . . $ uint32# id_label_then = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4030 uint32cxx . . $ uint32# id_func = reg->spirvcxx . . $ RegisterList#spirv..iddeclcxx . . $ RegisterList#$anonymous_type_0#iddecl.;
4031 uint32cxx . . $ uint32# id_call_res = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4032 uint32cxx . . $ uint32# id_label_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4033
4034 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., id_label_merge, 0);
4035 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpBranchConditionalcxx . . $ SpvOpBranchConditional., src1.idcxx . . $ SpirvResult#id., id_label_then, id_label_merge);
4036
4037 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_then);
4038 if (ctx->loopscxx . . $ Context#loops. > 0)
4039 failfcxx . . $ failf(f93f6dc5e2b298a0).(ctx, "Function calls referencing aL not implemented.");
4040 else
4041 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpFunctionCallcxx . . $ SpvOpFunctionCall., tid_void, id_call_res, id_func);
4042 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_label_merge);
4043
4044 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_merge);
4045 } // emit_SPIRV_CALLNZ
4046
4047 void emit_SPIRV_TEXLDDcxx . . $ emit_SPIRV_TEXLDD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4048 {
4049 const SourceArgInfocxx . . $ SourceArgInfo# *samp_arg = &ctx->source_argscxx . . $ Context#source_args.[1];
4050 if (!reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., samp_arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.))
4051 {
4052 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "TEXLDD using undeclared sampler");
4053 return;
4054 } // if
4055
4056 // Prep the result
4057 SpirvResultcxx . . $ SpirvResult# result;
4058 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
4059 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4060
4061 SpirvResultcxx . . $ SpirvResult# texcoord = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
4062 SpirvResultcxx . . $ SpirvResult# sampler = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1);
4063 SpirvResultcxx . . $ SpirvResult# grad_x = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 2);
4064 SpirvResultcxx . . $ SpirvResult# grad_y = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 3);
4065
4066 // Generate the instruction.
4067 // SpvOpImageSampleExplicitLod should ignore the components of the
4068 // texcoord that it doesn't need, so we don't need to mask it.
4069 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4070 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 8, SpvOpImageSampleExplicitLodcxx . . $ SpvOpImageSampleExplicitLod., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., sampler.idcxx . . $ SpirvResult#id.,
4071 texcoord.idcxx . . $ SpirvResult#id., SpvImageOperandsGradMaskcxx . . $ SpvImageOperandsGradMask., grad_x.idcxx . . $ SpirvResult#id., grad_y.idcxx . . $ SpirvResult#id.);
4072 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4073
4074 // Emit the result, finally.
4075 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!isscalar(ctx, ctx->shader_type, samp_arg->regtype, samp_arg->regnum));
4076 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
4077 } // emit_SPIRV_TEXLDD
4078
4079 void emit_SPIRV_SETPcxx . . $ emit_SPIRV_SETP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4080 {
4081 SpirvResultcxx . . $ SpirvResult# src0 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
4082 SpirvResultcxx . . $ SpirvResult# src1 = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1);
4083
4084 SpirvResultcxx . . $ SpirvResult# dst;
4085 dst.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_BVEC4cxx . . $ STI_BVEC4.);
4086 dst.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4087
4088 SpvOpcxx . . $ SpvOp# cmp_op = spv_get_comparisoncxx . . $ spv_get_comparison(707404df50257c9c).(ctx);
4089
4090 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4091 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, cmp_op, dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
4092 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4093
4094 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, dst);
4095 } // emit_SPIRV_SETP
4096
4097 void emit_SPIRV_TEXLDLcxx . . $ emit_SPIRV_TEXLDL(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4098 {
4099 const SourceArgInfocxx . . $ SourceArgInfo# *samp_arg = &ctx->source_argscxx . . $ Context#source_args.[1];
4100 RegisterListcxx . . $ RegisterList# *sampler_reg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., samp_arg->regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
4101 if (sampler_reg == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
4102 {
4103 failcxx . . $ fail(72ff1ec6cf40f147).(ctx, "TEXLDL using undeclared sampler");
4104 return;
4105 } // if
4106 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(!isscalar(ctx, ctx->shader_type, samp_arg->regtype, samp_arg->regnum));
4107
4108 // Prep the result
4109 SpirvResultcxx . . $ SpirvResult# result;
4110 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
4111 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4112
4113 SpirvResultcxx . . $ SpirvResult# sampler = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 1);
4114 SpirvResultcxx . . $ SpirvResult# texcoord = spv_load_srcarg_fullcxx . . $ spv_load_srcarg_full(fd9bd01da036b808).(ctx, 0);
4115
4116 // The w component of texcoord_reg specifies the LOD. Extract it from texcoord_reg
4117 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
4118 uint32cxx . . $ uint32# id_lod = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4119
4120 // Generate the instruction.
4121 // SpvOpImageSampleExplicitLod should ignore the components of the
4122 // texcoord that it doesn't need, so we don't need to mask it.
4123 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4124 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4 + 1, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_lod, texcoord.idcxx . . $ SpirvResult#id., 3);
4125 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 7, SpvOpImageSampleExplicitLodcxx . . $ SpvOpImageSampleExplicitLod., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., sampler.idcxx . . $ SpirvResult#id.,
4126 texcoord.idcxx . . $ SpirvResult#id., SpvImageOperandsLodMaskcxx . . $ SpvImageOperandsLodMask., id_lod);
4127 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4128
4129 // Emit the result, finally.
4130 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
4131 } // emit_SPIRV_TEXLDL
4132
4133 void emit_SPIRV_BREAKcxx . . $ emit_SPIRV_BREAK(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4134 {
4135 uint32cxx . . $ uint32# id_label_merge = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4136 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3, SpvOpSelectionMergecxx . . $ SpvOpSelectionMerge., id_label_merge, 0);
4137 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpBranchcxx . . $ SpvOpBranch., id_label_merge);
4138 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 2, SpvOpLabelcxx . . $ SpvOpLabel., id_label_merge);
4139 } // emit_SPIRV_BREAK
4140
4141 void emit_SPIRV_TEXM3X2PADcxx . . $ emit_SPIRV_TEXM3X2PAD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4142 {
4143 // no-op ... work happens in emit_SPIRV_TEXM3X2TEX().
4144 } // emit_SPIRV_TEXM3X2PAD
4145
4146 void emit_SPIRV_TEXM3X2TEXcxx . . $ emit_SPIRV_TEXM3X2TEX(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4147 {
4148 if (ctx->texm3x2pad_src0cxx . . $ Context#texm3x2pad_src0. == -1)
4149 return;
4150
4151 DestArgInfocxx . . $ DestArgInfo# *pDstInfo = &ctx->dest_argcxx . . $ Context#dest_arg.;
4152
4153 RegisterListcxx . . $ RegisterList# *pSReg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., pDstInfo->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
4154 RegisterListcxx . . $ RegisterList# *pSrc0 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x2pad_src0cxx . . $ Context#texm3x2pad_src0.);
4155 RegisterListcxx . . $ RegisterList# *pSrc1 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->texm3x2pad_dst0cxx . . $ Context#texm3x2pad_dst0.);
4156 RegisterListcxx . . $ RegisterList# *pSrc2 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, REG_TYPE_TEXTUREcxx . . $ REG_TYPE_TEXTURE., ctx->source_argscxx . . $ Context#source_args.[0].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
4157 RegisterListcxx . . $ RegisterList# *pDst = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, pDstInfo->regtypecxx . . $ $anonymous_type_32753e8ce5863620_5#regtype., pDstInfo->regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
4158
4159 SpirvResultcxx . . $ SpirvResult# sampler = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSReg);
4160 SpirvResultcxx . . $ SpirvResult# src0 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc0);
4161 SpirvResultcxx . . $ SpirvResult# src1 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc1);
4162 SpirvResultcxx . . $ SpirvResult# src2 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc2);
4163 SpirvResultcxx . . $ SpirvResult# src3 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pDst);
4164
4165 src0 = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, src0, SPV_NO_SWIZZLEcxx . . $ SPV_NO_SWIZZLE., 0x7);
4166 src1 = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, src1, SPV_NO_SWIZZLEcxx . . $ SPV_NO_SWIZZLE., 0x7);
4167 src2 = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, src2, SPV_NO_SWIZZLEcxx . . $ SPV_NO_SWIZZLE., 0x7);
4168 src3 = spv_swizzlecxx . . $ spv_swizzle(cda59f26e2e527c4).(ctx, src3, SPV_NO_SWIZZLEcxx . . $ SPV_NO_SWIZZLE., 0x7);
4169
4170 SpirvResultcxx . . $ SpirvResult# result;
4171 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
4172 uint32cxx . . $ uint32# tid_vec2 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC2cxx . . $ STI_VEC2.);
4173 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
4174 uint32cxx . . $ uint32# id_x = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4175 uint32cxx . . $ uint32# id_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4176 uint32cxx . . $ uint32# id_texcoord = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4177 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4178 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4179 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., tid_float, id_x, src0.idcxx . . $ SpirvResult#id., src1.idcxx . . $ SpirvResult#id.);
4180 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpDotcxx . . $ SpvOpDot., tid_float, id_y, src2.idcxx . . $ SpirvResult#id., src3.idcxx . . $ SpirvResult#id.);
4181 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3+2, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec2, id_texcoord, id_x, id_y);
4182 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpImageSampleImplicitLodcxx . . $ SpvOpImageSampleImplicitLod., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., sampler.idcxx . . $ SpirvResult#id., id_texcoord);
4183 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4184 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
4185 } // emit_SPIRV_TEXM3X2TEX
4186
4187 void emit_SPIRV_TEXM3X3PADcxx . . $ emit_SPIRV_TEXM3X3PAD(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4188 {
4189 // no-op ... work happens in emit_SPIRV_TEXM3X3*().
4190 } // emit_SPIRV_TEXM3X3PAD
4191
4192 void emit_SPIRV_TEXM3X3cxx . . $ emit_SPIRV_TEXM3X3(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4193 {
4194 if (ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1. == -1)
4195 return;
4196
4197 // vec4(
4198 // dot({src0}.xyz, {src1}.xyz),
4199 // dot({src2}.xyz, {src3}.xyz),
4200 // dot({dst}.xyz, {src4}.xyz),
4201 // 1
4202 // )
4203
4204 uint32cxx . . $ uint32# id_1 = spv_getscalarfcxx . . $ spv_getscalarf(406fe27c50b29797).(ctx, 1.0f);
4205
4206 SpirvTexm3x3SetupResultcxx . . $ SpirvTexm3x3SetupResult# setup = spv_texm3x3_setupcxx . . $ spv_texm3x3_setup(d1a426149cff7b45).(ctx);
4207
4208 SpirvResultcxx . . $ SpirvResult# result;
4209 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
4210 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4211
4212 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4213 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 4, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id.,
4214 setup.id_res_xcxx . . $ SpirvTexm3x3SetupResult#id_res_x., setup.id_res_ycxx . . $ SpirvTexm3x3SetupResult#id_res_y., setup.id_res_zcxx . . $ SpirvTexm3x3SetupResult#id_res_z., id_1
4215 );
4216 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4217
4218 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
4219 } // emit_SPIRV_TEXM3X3
4220
4221 void emit_SPIRV_TEXM3X3TEXcxx . . $ emit_SPIRV_TEXM3X3TEX(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4222 {
4223 if (ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1. == -1)
4224 return;
4225
4226 RegisterListcxx . . $ RegisterList# *pSReg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
4227
4228 // texture{ttypestr}({sampler},
4229 // vec3(
4230 // dot({src0}.xyz, {src1}.xyz),
4231 // dot({src2}.xyz, {src3}.xyz),
4232 // dot({dst}.xyz, {src4}.xyz)
4233 // ),
4234 // )
4235
4236 SpirvResultcxx . . $ SpirvResult# sampler = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSReg);
4237
4238 SpirvTexm3x3SetupResultcxx . . $ SpirvTexm3x3SetupResult# setup = spv_texm3x3_setupcxx . . $ spv_texm3x3_setup(d1a426149cff7b45).(ctx);
4239
4240 uint32cxx . . $ uint32# tid_vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
4241 uint32cxx . . $ uint32# tid_vec4 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
4242 uint32cxx . . $ uint32# id_tc = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4243
4244 SpirvResultcxx . . $ SpirvResult# result;
4245 result.tidcxx . . $ SpirvResult#tid. = tid_vec4;
4246 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4247
4248 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4249 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 3, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec3, id_tc,
4250 setup.id_res_xcxx . . $ SpirvTexm3x3SetupResult#id_res_x., setup.id_res_ycxx . . $ SpirvTexm3x3SetupResult#id_res_y., setup.id_res_zcxx . . $ SpirvTexm3x3SetupResult#id_res_z.
4251 );
4252 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpImageSampleImplicitLodcxx . . $ SpvOpImageSampleImplicitLod., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., sampler.idcxx . . $ SpirvResult#id., id_tc);
4253 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4254
4255 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
4256 } // emit_SPIRV_TEXM3X3TEX
4257
4258 void emit_SPIRV_TEXM3X3SPECcxx . . $ emit_SPIRV_TEXM3X3SPEC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4259 {
4260 if (ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1. == -1)
4261 return;
4262
4263 RegisterListcxx . . $ RegisterList# *pSReg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
4264 RegisterListcxx . . $ RegisterList# *pSrc5 = spv_getregcxx . . $ spv_getreg(e916bee4064e32a8).(ctx, ctx->source_argscxx . . $ Context#source_args.[1].regtypecxx . . $ $anonymous_type_3d78d65a03e818ad_1#regtype., ctx->source_argscxx . . $ Context#source_args.[1].regnumcxx . . $ $anonymous_type_3d78d65a03e818ad_1#regnum.);
4265
4266 SpirvTexm3x3SetupResultcxx . . $ SpirvTexm3x3SetupResult# setup = spv_texm3x3_setupcxx . . $ spv_texm3x3_setup(d1a426149cff7b45).(ctx);
4267
4268 uint32cxx . . $ uint32# tid_vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
4269
4270 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4271
4272 uint32cxx . . $ uint32# id_normal = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4273 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 3, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec3, id_normal,
4274 setup.id_res_xcxx . . $ SpirvTexm3x3SetupResult#id_res_x., setup.id_res_ycxx . . $ SpirvTexm3x3SetupResult#id_res_y., setup.id_res_zcxx . . $ SpirvTexm3x3SetupResult#id_res_z.
4275 );
4276
4277 SpirvResultcxx . . $ SpirvResult# src5 = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSrc5);
4278
4279 uint32cxx . . $ uint32# id_eyeray = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4280 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5 + 3, SpvOpVectorShufflecxx . . $ SpvOpVectorShuffle., tid_vec3, id_eyeray, src5.idcxx . . $ SpirvResult#id., src5.idcxx . . $ SpirvResult#id., 0, 1, 2);
4281
4282 uint32cxx . . $ uint32# id_reflected = spv_reflectcxx . . $ spv_reflect(a939eba8b1993c99).(ctx, id_normal, id_eyeray);
4283
4284 SpirvResultcxx . . $ SpirvResult# sampler = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSReg);
4285
4286 SpirvResultcxx . . $ SpirvResult# result;
4287 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
4288 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4289 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpImageSampleImplicitLodcxx . . $ SpvOpImageSampleImplicitLod., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., sampler.idcxx . . $ SpirvResult#id., id_reflected);
4290
4291 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4292
4293 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
4294 } // emit_SPIRV_TEXM3X3SPEC
4295
4296 void emit_SPIRV_TEXM3X3VSPECcxx . . $ emit_SPIRV_TEXM3X3VSPEC(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4297 {
4298 if (ctx->texm3x3pad_src1cxx . . $ Context#texm3x3pad_src1. == -1)
4299 return;
4300
4301 RegisterListcxx . . $ RegisterList# *pSReg = reglist_findcxx . . $ reglist_find(1623ad9ca4ff0177).(&ctx->samplerscxx . . $ Context#samplers., REG_TYPE_SAMPLERcxx . . $ REG_TYPE_SAMPLER., ctx->dest_argcxx . . $ Context#dest_arg..regnumcxx . . $ $anonymous_type_32753e8ce5863620_5#regnum.);
4302
4303 SpirvTexm3x3SetupResultcxx . . $ SpirvTexm3x3SetupResult# setup = spv_texm3x3_setupcxx . . $ spv_texm3x3_setup(d1a426149cff7b45).(ctx);
4304
4305 uint32cxx . . $ uint32# tid_float = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_FLOATcxx . . $ STI_FLOAT.);
4306 uint32cxx . . $ uint32# tid_vec3 = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC3cxx . . $ STI_VEC3.);
4307
4308 push_outputcxx . . $ push_output(80f724ef23dce062).(ctx, &ctx->mainlinecxx . . $ Context#mainline.);
4309
4310 uint32cxx . . $ uint32# id_normal = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4311 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 3, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec3, id_normal,
4312 setup.id_res_xcxx . . $ SpirvTexm3x3SetupResult#id_res_x., setup.id_res_ycxx . . $ SpirvTexm3x3SetupResult#id_res_y., setup.id_res_zcxx . . $ SpirvTexm3x3SetupResult#id_res_z.
4313 );
4314
4315 uint32cxx . . $ uint32# id_eyeray_x = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4316 uint32cxx . . $ uint32# id_eyeray_y = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4317 uint32cxx . . $ uint32# id_eyeray_z = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4318 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_eyeray_x, setup.id_dst_pad0cxx . . $ SpirvTexm3x3SetupResult#id_dst_pad0., 3);
4319 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_eyeray_y, setup.id_dst_pad1cxx . . $ SpirvTexm3x3SetupResult#id_dst_pad1., 3);
4320 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpCompositeExtractcxx . . $ SpvOpCompositeExtract., tid_float, id_eyeray_z, setup.id_dstcxx . . $ SpirvTexm3x3SetupResult#id_dst., 3);
4321
4322 uint32cxx . . $ uint32# id_eyeray = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4323 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 3 + 3, SpvOpCompositeConstructcxx . . $ SpvOpCompositeConstruct., tid_vec3, id_eyeray,
4324 id_eyeray_x, id_eyeray_y, id_eyeray_z
4325 );
4326
4327 uint32cxx . . $ uint32# id_reflected = spv_reflectcxx . . $ spv_reflect(a939eba8b1993c99).(ctx, id_normal, id_eyeray);
4328
4329 SpirvResultcxx . . $ SpirvResult# sampler = spv_loadregcxx . . $ spv_loadreg(2d7e7cdc31556793).(ctx, pSReg);
4330
4331 SpirvResultcxx . . $ SpirvResult# result;
4332 result.tidcxx . . $ SpirvResult#tid. = spv_get_typecxx . . $ spv_get_type(b56bbd2a70fe471a).(ctx, STI_VEC4cxx . . $ STI_VEC4.);
4333 result.idcxx . . $ SpirvResult#id. = spv_bumpidcxx . . $ spv_bumpid(6d86621a4076bebf).(ctx);
4334 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 5, SpvOpImageSampleImplicitLodcxx . . $ SpvOpImageSampleImplicitLod., result.tidcxx . . $ SpirvResult#tid., result.idcxx . . $ SpirvResult#id., sampler.idcxx . . $ SpirvResult#id., id_reflected);
4335
4336 pop_outputcxx . . $ pop_output(612dd59919e2530e).(ctx);
4337
4338 spv_assign_destargcxx . . $ spv_assign_destarg(aab36508dde6f88f).(ctx, result);
4339 } // emit_SPIRV_TEXM3X3VSPEC
4340
4341 void emit_SPIRV_TEXBEMcxx . . $ emit_SPIRV_TEXBEM(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4342 {
4343 spv_texbemcxx . . $ spv_texbem(a15117967af15219).(ctx, 0);
4344 } // emit_SPIRV_TEXBEM
4345
4346 void emit_SPIRV_TEXBEMLcxx . . $ emit_SPIRV_TEXBEML(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4347 {
4348 spv_texbemcxx . . $ spv_texbem(a15117967af15219).(ctx, 1);
4349 } // emit_SPIRV_TEXBEML
4350
4351 void emit_SPIRV_EXPPcxx . . $ emit_SPIRV_EXPP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4352 {
4353 // !!! FIXME: msdn's asm docs don't list this opcode, I'll have to check the driver documentation.
4354 emit_SPIRV_EXPcxx . . $ emit_SPIRV_EXP(612dd59919e2530e).(ctx); // I guess this is just partial precision EXP?
4355 } // emit_SPIRV_EXPP
4356
4357 void emit_SPIRV_LOGPcxx . . $ emit_SPIRV_LOGP(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4358 {
4359 // LOGP is just low-precision LOG, but we'll take the higher precision.
4360 emit_SPIRV_LOGcxx . . $ emit_SPIRV_LOG(612dd59919e2530e).(ctx);
4361 } // emit_SPIRV_LOGP
4362
4363 void emit_SPIRV_DSXcxx . . $ emit_SPIRV_DSX(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4364 {
4365 SpirvResultcxx . . $ SpirvResult# dst, src;
4366 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
4367 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpDPdxcxx . . $ SpvOpDPdx., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., src.idcxx . . $ SpirvResult#id.);
4368 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
4369 } // emit_SPIRV_DSX
4370
4371 void emit_SPIRV_DSYcxx . . $ emit_SPIRV_DSY(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4372 {
4373 SpirvResultcxx . . $ SpirvResult# dst, src;
4374 spv_emit_begin_dscxx . . $ spv_emit_begin_ds(2540fd6b82328820).(ctx, &dst, &src);
4375 spv_emitcxx . . $ spv_emit(60837ebb87b679cc).(ctx, 4, SpvOpDPdycxx . . $ SpvOpDPdy., dst.tidcxx . . $ SpirvResult#tid., dst.idcxx . . $ SpirvResult#id., src.idcxx . . $ SpirvResult#id.);
4376 spv_emit_endcxx . . $ spv_emit_end(aab36508dde6f88f).(ctx, dst);
4377 } // emit_SPIRV_DSY
4378
4379 void emit_SPIRV_RESERVEDcxx . . $ emit_SPIRV_RESERVED(612dd59919e2530e).(Contextcxx . . $ Context# *ctx)
4380 {
4381 // do nothing; fails in the state machine.
4382 } // emit_SPIRV_RESERVED
4383
4384 // !!! FIXME: The following are unimplemented even in the GLSL emitter.
4385 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(TEXCRD)
4386 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(TEXREG2AR)
4387 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(TEXREG2GB)
4388 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(TEXREG2RGB)
4389 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(TEXDP3TEX)
4390 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(TEXM3X2DEPTH)
4391 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(TEXDP3)
4392 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(TEXDEPTH)
4393 EMIT_SPIRV_OPCODE_UNIMPLEMENTED_FUNCcxx . . $ `profiles/mojoshader_profile_spirv.c:22:9`!(BEM)
4394
4395 #endif // SUPPORT_PROFILE_SPIRV
4396
4397 #pragma GCC visibility pop