1 // GENERATED FILE - DO NOT EDIT.
2 // Generated by gen_spirv_builder_and_parser.py using data from spirv.core.grammar.json.
3 //
4 // Copyright 2021 The ANGLE Project Authors. All rights reserved.
5 // Use of this source code is governed by a BSD-style license that can be
6 // found in the LICENSE file.
7 //
8 // spirv_instruction_builder_autogen.cpp:
9 // Functions to generate SPIR-V binary for each instruction.
10
11 #include "spirv_instruction_builder_autogen.h"
12
13 #include <string.h>
14
15 #include "common/debug.h"
16
17 namespace angle
18 {
19 namespace spirv
20 {
21 namespace
22 {
MakeLengthOp(size_t length,spv::Op op)23 uint32_t MakeLengthOp(size_t length, spv::Op op)
24 {
25 ASSERT(length <= 0xFFFFu);
26 ASSERT(op <= 0xFFFFu);
27
28 return static_cast<uint32_t>(length) << 16 | op;
29 }
30 } // anonymous namespace
31
WriteSpirvHeader(std::vector<uint32_t> * blob,uint32_t idCount)32 void WriteSpirvHeader(std::vector<uint32_t> *blob, uint32_t idCount)
33 {
34 // Header:
35 //
36 // - Magic number
37 // - Version (1.0)
38 // - ANGLE's Generator number:
39 // * 24 for tool id (higher 16 bits)
40 // * 1 for tool version (lower 16 bits))
41 // - Bound (idCount)
42 // - 0 (reserved)
43 constexpr uint32_t kANGLEGeneratorId = 24;
44 constexpr uint32_t kANGLEGeneratorVersion = 1;
45
46 ASSERT(blob->empty());
47
48 blob->push_back(spv::MagicNumber);
49 blob->push_back(0x00010000);
50 blob->push_back(kANGLEGeneratorId << 16 | kANGLEGeneratorVersion);
51 blob->push_back(idCount);
52 blob->push_back(0x00000000);
53 }
54
WriteNop(Blob * blob)55 void WriteNop(Blob *blob)
56 {
57 const size_t startSize = blob->size();
58 blob->push_back(0);
59
60 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpNop);
61 }
WriteUndef(Blob * blob,IdResultType idResultType,IdResult idResult)62 void WriteUndef(Blob *blob, IdResultType idResultType, IdResult idResult)
63 {
64 const size_t startSize = blob->size();
65 blob->push_back(0);
66 blob->push_back(idResultType);
67 blob->push_back(idResult);
68 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUndef);
69 }
WriteSourceContinued(Blob * blob,LiteralString continuedSource)70 void WriteSourceContinued(Blob *blob, LiteralString continuedSource)
71 {
72 const size_t startSize = blob->size();
73 blob->push_back(0);
74 {
75 size_t d = blob->size();
76 blob->resize(d + strlen(continuedSource) / 4 + 1, 0);
77 ASSERT(IsLittleEndian());
78 strcpy(reinterpret_cast<char *>(blob->data() + d), continuedSource);
79 }
80 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSourceContinued);
81 }
WriteSource(Blob * blob,spv::SourceLanguage sourceLanguage,LiteralInteger version,const IdRef * file,const LiteralString * source)82 void WriteSource(Blob *blob,
83 spv::SourceLanguage sourceLanguage,
84 LiteralInteger version,
85 const IdRef *file,
86 const LiteralString *source)
87 {
88 const size_t startSize = blob->size();
89 blob->push_back(0);
90 blob->push_back(sourceLanguage);
91 blob->push_back(version);
92 if (file)
93 {
94 blob->push_back(*file);
95 }
96 if (source)
97 {
98 {
99 size_t d = blob->size();
100 blob->resize(d + strlen(*source) / 4 + 1, 0);
101 ASSERT(IsLittleEndian());
102 strcpy(reinterpret_cast<char *>(blob->data() + d), *source);
103 }
104 }
105 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSource);
106 }
WriteSourceExtension(Blob * blob,LiteralString extension)107 void WriteSourceExtension(Blob *blob, LiteralString extension)
108 {
109 const size_t startSize = blob->size();
110 blob->push_back(0);
111 {
112 size_t d = blob->size();
113 blob->resize(d + strlen(extension) / 4 + 1, 0);
114 ASSERT(IsLittleEndian());
115 strcpy(reinterpret_cast<char *>(blob->data() + d), extension);
116 }
117 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSourceExtension);
118 }
WriteName(Blob * blob,IdRef target,LiteralString name)119 void WriteName(Blob *blob, IdRef target, LiteralString name)
120 {
121 const size_t startSize = blob->size();
122 blob->push_back(0);
123 blob->push_back(target);
124 {
125 size_t d = blob->size();
126 blob->resize(d + strlen(name) / 4 + 1, 0);
127 ASSERT(IsLittleEndian());
128 strcpy(reinterpret_cast<char *>(blob->data() + d), name);
129 }
130 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpName);
131 }
WriteMemberName(Blob * blob,IdRef type,LiteralInteger member,LiteralString name)132 void WriteMemberName(Blob *blob, IdRef type, LiteralInteger member, LiteralString name)
133 {
134 const size_t startSize = blob->size();
135 blob->push_back(0);
136 blob->push_back(type);
137 blob->push_back(member);
138 {
139 size_t d = blob->size();
140 blob->resize(d + strlen(name) / 4 + 1, 0);
141 ASSERT(IsLittleEndian());
142 strcpy(reinterpret_cast<char *>(blob->data() + d), name);
143 }
144 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMemberName);
145 }
WriteString(Blob * blob,IdResult idResult,LiteralString string)146 void WriteString(Blob *blob, IdResult idResult, LiteralString string)
147 {
148 const size_t startSize = blob->size();
149 blob->push_back(0);
150 blob->push_back(idResult);
151 {
152 size_t d = blob->size();
153 blob->resize(d + strlen(string) / 4 + 1, 0);
154 ASSERT(IsLittleEndian());
155 strcpy(reinterpret_cast<char *>(blob->data() + d), string);
156 }
157 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpString);
158 }
WriteLine(Blob * blob,IdRef file,LiteralInteger line,LiteralInteger column)159 void WriteLine(Blob *blob, IdRef file, LiteralInteger line, LiteralInteger column)
160 {
161 const size_t startSize = blob->size();
162 blob->push_back(0);
163 blob->push_back(file);
164 blob->push_back(line);
165 blob->push_back(column);
166 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLine);
167 }
WriteExtension(Blob * blob,LiteralString name)168 void WriteExtension(Blob *blob, LiteralString name)
169 {
170 const size_t startSize = blob->size();
171 blob->push_back(0);
172 {
173 size_t d = blob->size();
174 blob->resize(d + strlen(name) / 4 + 1, 0);
175 ASSERT(IsLittleEndian());
176 strcpy(reinterpret_cast<char *>(blob->data() + d), name);
177 }
178 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExtension);
179 }
WriteExtInstImport(Blob * blob,IdResult idResult,LiteralString name)180 void WriteExtInstImport(Blob *blob, IdResult idResult, LiteralString name)
181 {
182 const size_t startSize = blob->size();
183 blob->push_back(0);
184 blob->push_back(idResult);
185 {
186 size_t d = blob->size();
187 blob->resize(d + strlen(name) / 4 + 1, 0);
188 ASSERT(IsLittleEndian());
189 strcpy(reinterpret_cast<char *>(blob->data() + d), name);
190 }
191 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExtInstImport);
192 }
WriteExtInst(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef set,LiteralExtInstInteger instruction,const IdRefList & operandList)193 void WriteExtInst(Blob *blob,
194 IdResultType idResultType,
195 IdResult idResult,
196 IdRef set,
197 LiteralExtInstInteger instruction,
198 const IdRefList &operandList)
199 {
200 const size_t startSize = blob->size();
201 blob->push_back(0);
202 blob->push_back(idResultType);
203 blob->push_back(idResult);
204 blob->push_back(set);
205 blob->push_back(instruction);
206 for (const auto &operand : operandList)
207 {
208 blob->push_back(operand);
209 }
210 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExtInst);
211 }
WriteMemoryModel(Blob * blob,spv::AddressingModel addressingModel,spv::MemoryModel memoryModel)212 void WriteMemoryModel(Blob *blob,
213 spv::AddressingModel addressingModel,
214 spv::MemoryModel memoryModel)
215 {
216 const size_t startSize = blob->size();
217 blob->push_back(0);
218 blob->push_back(addressingModel);
219 blob->push_back(memoryModel);
220 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMemoryModel);
221 }
WriteEntryPoint(Blob * blob,spv::ExecutionModel executionModel,IdRef entryPoint,LiteralString name,const IdRefList & interfaceList)222 void WriteEntryPoint(Blob *blob,
223 spv::ExecutionModel executionModel,
224 IdRef entryPoint,
225 LiteralString name,
226 const IdRefList &interfaceList)
227 {
228 const size_t startSize = blob->size();
229 blob->push_back(0);
230 blob->push_back(executionModel);
231 blob->push_back(entryPoint);
232 {
233 size_t d = blob->size();
234 blob->resize(d + strlen(name) / 4 + 1, 0);
235 ASSERT(IsLittleEndian());
236 strcpy(reinterpret_cast<char *>(blob->data() + d), name);
237 }
238 for (const auto &operand : interfaceList)
239 {
240 blob->push_back(operand);
241 }
242 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEntryPoint);
243 }
WriteExecutionMode(Blob * blob,IdRef entryPoint,spv::ExecutionMode mode,const LiteralIntegerList & operandsList)244 void WriteExecutionMode(Blob *blob,
245 IdRef entryPoint,
246 spv::ExecutionMode mode,
247 const LiteralIntegerList &operandsList)
248 {
249 const size_t startSize = blob->size();
250 blob->push_back(0);
251 blob->push_back(entryPoint);
252 blob->push_back(mode);
253 for (const auto &operand : operandsList)
254 {
255 blob->push_back(operand);
256 }
257 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpExecutionMode);
258 }
WriteCapability(Blob * blob,spv::Capability capability)259 void WriteCapability(Blob *blob, spv::Capability capability)
260 {
261 const size_t startSize = blob->size();
262 blob->push_back(0);
263 blob->push_back(capability);
264 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCapability);
265 }
WriteTypeVoid(Blob * blob,IdResult idResult)266 void WriteTypeVoid(Blob *blob, IdResult idResult)
267 {
268 const size_t startSize = blob->size();
269 blob->push_back(0);
270 blob->push_back(idResult);
271 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeVoid);
272 }
WriteTypeBool(Blob * blob,IdResult idResult)273 void WriteTypeBool(Blob *blob, IdResult idResult)
274 {
275 const size_t startSize = blob->size();
276 blob->push_back(0);
277 blob->push_back(idResult);
278 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeBool);
279 }
WriteTypeInt(Blob * blob,IdResult idResult,LiteralInteger width,LiteralInteger signedness)280 void WriteTypeInt(Blob *blob, IdResult idResult, LiteralInteger width, LiteralInteger signedness)
281 {
282 const size_t startSize = blob->size();
283 blob->push_back(0);
284 blob->push_back(idResult);
285 blob->push_back(width);
286 blob->push_back(signedness);
287 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeInt);
288 }
WriteTypeFloat(Blob * blob,IdResult idResult,LiteralInteger width)289 void WriteTypeFloat(Blob *blob, IdResult idResult, LiteralInteger width)
290 {
291 const size_t startSize = blob->size();
292 blob->push_back(0);
293 blob->push_back(idResult);
294 blob->push_back(width);
295 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeFloat);
296 }
WriteTypeVector(Blob * blob,IdResult idResult,IdRef componentType,LiteralInteger componentCount)297 void WriteTypeVector(Blob *blob,
298 IdResult idResult,
299 IdRef componentType,
300 LiteralInteger componentCount)
301 {
302 const size_t startSize = blob->size();
303 blob->push_back(0);
304 blob->push_back(idResult);
305 blob->push_back(componentType);
306 blob->push_back(componentCount);
307 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeVector);
308 }
WriteTypeMatrix(Blob * blob,IdResult idResult,IdRef columnType,LiteralInteger columnCount)309 void WriteTypeMatrix(Blob *blob, IdResult idResult, IdRef columnType, LiteralInteger columnCount)
310 {
311 const size_t startSize = blob->size();
312 blob->push_back(0);
313 blob->push_back(idResult);
314 blob->push_back(columnType);
315 blob->push_back(columnCount);
316 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeMatrix);
317 }
WriteTypeImage(Blob * blob,IdResult idResult,IdRef sampledType,spv::Dim dim,LiteralInteger depth,LiteralInteger arrayed,LiteralInteger mS,LiteralInteger sampled,spv::ImageFormat imageFormat,const spv::AccessQualifier * accessQualifier)318 void WriteTypeImage(Blob *blob,
319 IdResult idResult,
320 IdRef sampledType,
321 spv::Dim dim,
322 LiteralInteger depth,
323 LiteralInteger arrayed,
324 LiteralInteger mS,
325 LiteralInteger sampled,
326 spv::ImageFormat imageFormat,
327 const spv::AccessQualifier *accessQualifier)
328 {
329 const size_t startSize = blob->size();
330 blob->push_back(0);
331 blob->push_back(idResult);
332 blob->push_back(sampledType);
333 blob->push_back(dim);
334 blob->push_back(depth);
335 blob->push_back(arrayed);
336 blob->push_back(mS);
337 blob->push_back(sampled);
338 blob->push_back(imageFormat);
339 if (accessQualifier)
340 {
341 blob->push_back(*accessQualifier);
342 }
343 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeImage);
344 }
WriteTypeSampler(Blob * blob,IdResult idResult)345 void WriteTypeSampler(Blob *blob, IdResult idResult)
346 {
347 const size_t startSize = blob->size();
348 blob->push_back(0);
349 blob->push_back(idResult);
350 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeSampler);
351 }
WriteTypeSampledImage(Blob * blob,IdResult idResult,IdRef imageType)352 void WriteTypeSampledImage(Blob *blob, IdResult idResult, IdRef imageType)
353 {
354 const size_t startSize = blob->size();
355 blob->push_back(0);
356 blob->push_back(idResult);
357 blob->push_back(imageType);
358 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeSampledImage);
359 }
WriteTypeArray(Blob * blob,IdResult idResult,IdRef elementType,IdRef length)360 void WriteTypeArray(Blob *blob, IdResult idResult, IdRef elementType, IdRef length)
361 {
362 const size_t startSize = blob->size();
363 blob->push_back(0);
364 blob->push_back(idResult);
365 blob->push_back(elementType);
366 blob->push_back(length);
367 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeArray);
368 }
WriteTypeRuntimeArray(Blob * blob,IdResult idResult,IdRef elementType)369 void WriteTypeRuntimeArray(Blob *blob, IdResult idResult, IdRef elementType)
370 {
371 const size_t startSize = blob->size();
372 blob->push_back(0);
373 blob->push_back(idResult);
374 blob->push_back(elementType);
375 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeRuntimeArray);
376 }
WriteTypeStruct(Blob * blob,IdResult idResult,const IdRefList & memberList)377 void WriteTypeStruct(Blob *blob, IdResult idResult, const IdRefList &memberList)
378 {
379 const size_t startSize = blob->size();
380 blob->push_back(0);
381 blob->push_back(idResult);
382 for (const auto &operand : memberList)
383 {
384 blob->push_back(operand);
385 }
386 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeStruct);
387 }
WriteTypePointer(Blob * blob,IdResult idResult,spv::StorageClass storageClass,IdRef type)388 void WriteTypePointer(Blob *blob, IdResult idResult, spv::StorageClass storageClass, IdRef type)
389 {
390 const size_t startSize = blob->size();
391 blob->push_back(0);
392 blob->push_back(idResult);
393 blob->push_back(storageClass);
394 blob->push_back(type);
395 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypePointer);
396 }
WriteTypeFunction(Blob * blob,IdResult idResult,IdRef returnType,const IdRefList & parameterList)397 void WriteTypeFunction(Blob *blob,
398 IdResult idResult,
399 IdRef returnType,
400 const IdRefList ¶meterList)
401 {
402 const size_t startSize = blob->size();
403 blob->push_back(0);
404 blob->push_back(idResult);
405 blob->push_back(returnType);
406 for (const auto &operand : parameterList)
407 {
408 blob->push_back(operand);
409 }
410 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTypeFunction);
411 }
WriteConstantTrue(Blob * blob,IdResultType idResultType,IdResult idResult)412 void WriteConstantTrue(Blob *blob, IdResultType idResultType, IdResult idResult)
413 {
414 const size_t startSize = blob->size();
415 blob->push_back(0);
416 blob->push_back(idResultType);
417 blob->push_back(idResult);
418 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstantTrue);
419 }
WriteConstantFalse(Blob * blob,IdResultType idResultType,IdResult idResult)420 void WriteConstantFalse(Blob *blob, IdResultType idResultType, IdResult idResult)
421 {
422 const size_t startSize = blob->size();
423 blob->push_back(0);
424 blob->push_back(idResultType);
425 blob->push_back(idResult);
426 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstantFalse);
427 }
WriteConstant(Blob * blob,IdResultType idResultType,IdResult idResult,LiteralContextDependentNumber value)428 void WriteConstant(Blob *blob,
429 IdResultType idResultType,
430 IdResult idResult,
431 LiteralContextDependentNumber value)
432 {
433 const size_t startSize = blob->size();
434 blob->push_back(0);
435 blob->push_back(idResultType);
436 blob->push_back(idResult);
437 blob->push_back(value);
438 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstant);
439 }
WriteConstantComposite(Blob * blob,IdResultType idResultType,IdResult idResult,const IdRefList & constituentsList)440 void WriteConstantComposite(Blob *blob,
441 IdResultType idResultType,
442 IdResult idResult,
443 const IdRefList &constituentsList)
444 {
445 const size_t startSize = blob->size();
446 blob->push_back(0);
447 blob->push_back(idResultType);
448 blob->push_back(idResult);
449 for (const auto &operand : constituentsList)
450 {
451 blob->push_back(operand);
452 }
453 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstantComposite);
454 }
WriteConstantNull(Blob * blob,IdResultType idResultType,IdResult idResult)455 void WriteConstantNull(Blob *blob, IdResultType idResultType, IdResult idResult)
456 {
457 const size_t startSize = blob->size();
458 blob->push_back(0);
459 blob->push_back(idResultType);
460 blob->push_back(idResult);
461 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConstantNull);
462 }
WriteSpecConstantTrue(Blob * blob,IdResultType idResultType,IdResult idResult)463 void WriteSpecConstantTrue(Blob *blob, IdResultType idResultType, IdResult idResult)
464 {
465 const size_t startSize = blob->size();
466 blob->push_back(0);
467 blob->push_back(idResultType);
468 blob->push_back(idResult);
469 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSpecConstantTrue);
470 }
WriteSpecConstantFalse(Blob * blob,IdResultType idResultType,IdResult idResult)471 void WriteSpecConstantFalse(Blob *blob, IdResultType idResultType, IdResult idResult)
472 {
473 const size_t startSize = blob->size();
474 blob->push_back(0);
475 blob->push_back(idResultType);
476 blob->push_back(idResult);
477 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSpecConstantFalse);
478 }
WriteSpecConstant(Blob * blob,IdResultType idResultType,IdResult idResult,LiteralContextDependentNumber value)479 void WriteSpecConstant(Blob *blob,
480 IdResultType idResultType,
481 IdResult idResult,
482 LiteralContextDependentNumber value)
483 {
484 const size_t startSize = blob->size();
485 blob->push_back(0);
486 blob->push_back(idResultType);
487 blob->push_back(idResult);
488 blob->push_back(value);
489 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSpecConstant);
490 }
WriteSpecConstantComposite(Blob * blob,IdResultType idResultType,IdResult idResult,const IdRefList & constituentsList)491 void WriteSpecConstantComposite(Blob *blob,
492 IdResultType idResultType,
493 IdResult idResult,
494 const IdRefList &constituentsList)
495 {
496 const size_t startSize = blob->size();
497 blob->push_back(0);
498 blob->push_back(idResultType);
499 blob->push_back(idResult);
500 for (const auto &operand : constituentsList)
501 {
502 blob->push_back(operand);
503 }
504 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSpecConstantComposite);
505 }
WriteFunction(Blob * blob,IdResultType idResultType,IdResult idResult,spv::FunctionControlMask functionControl,IdRef functionType)506 void WriteFunction(Blob *blob,
507 IdResultType idResultType,
508 IdResult idResult,
509 spv::FunctionControlMask functionControl,
510 IdRef functionType)
511 {
512 const size_t startSize = blob->size();
513 blob->push_back(0);
514 blob->push_back(idResultType);
515 blob->push_back(idResult);
516 blob->push_back(functionControl);
517 blob->push_back(functionType);
518 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFunction);
519 }
WriteFunctionParameter(Blob * blob,IdResultType idResultType,IdResult idResult)520 void WriteFunctionParameter(Blob *blob, IdResultType idResultType, IdResult idResult)
521 {
522 const size_t startSize = blob->size();
523 blob->push_back(0);
524 blob->push_back(idResultType);
525 blob->push_back(idResult);
526 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFunctionParameter);
527 }
WriteFunctionEnd(Blob * blob)528 void WriteFunctionEnd(Blob *blob)
529 {
530 const size_t startSize = blob->size();
531 blob->push_back(0);
532
533 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFunctionEnd);
534 }
WriteFunctionCall(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef function,const IdRefList & argumentList)535 void WriteFunctionCall(Blob *blob,
536 IdResultType idResultType,
537 IdResult idResult,
538 IdRef function,
539 const IdRefList &argumentList)
540 {
541 const size_t startSize = blob->size();
542 blob->push_back(0);
543 blob->push_back(idResultType);
544 blob->push_back(idResult);
545 blob->push_back(function);
546 for (const auto &operand : argumentList)
547 {
548 blob->push_back(operand);
549 }
550 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFunctionCall);
551 }
WriteVariable(Blob * blob,IdResultType idResultType,IdResult idResult,spv::StorageClass storageClass,const IdRef * initializer)552 void WriteVariable(Blob *blob,
553 IdResultType idResultType,
554 IdResult idResult,
555 spv::StorageClass storageClass,
556 const IdRef *initializer)
557 {
558 const size_t startSize = blob->size();
559 blob->push_back(0);
560 blob->push_back(idResultType);
561 blob->push_back(idResult);
562 blob->push_back(storageClass);
563 if (initializer)
564 {
565 blob->push_back(*initializer);
566 }
567 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVariable);
568 }
WriteImageTexelPointer(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,IdRef sample)569 void WriteImageTexelPointer(Blob *blob,
570 IdResultType idResultType,
571 IdResult idResult,
572 IdRef image,
573 IdRef coordinate,
574 IdRef sample)
575 {
576 const size_t startSize = blob->size();
577 blob->push_back(0);
578 blob->push_back(idResultType);
579 blob->push_back(idResult);
580 blob->push_back(image);
581 blob->push_back(coordinate);
582 blob->push_back(sample);
583 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageTexelPointer);
584 }
WriteLoad(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,const spv::MemoryAccessMask * memoryAccess)585 void WriteLoad(Blob *blob,
586 IdResultType idResultType,
587 IdResult idResult,
588 IdRef pointer,
589 const spv::MemoryAccessMask *memoryAccess)
590 {
591 const size_t startSize = blob->size();
592 blob->push_back(0);
593 blob->push_back(idResultType);
594 blob->push_back(idResult);
595 blob->push_back(pointer);
596 if (memoryAccess)
597 {
598 blob->push_back(*memoryAccess);
599 }
600 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLoad);
601 }
WriteStore(Blob * blob,IdRef pointer,IdRef object,const spv::MemoryAccessMask * memoryAccess)602 void WriteStore(Blob *blob, IdRef pointer, IdRef object, const spv::MemoryAccessMask *memoryAccess)
603 {
604 const size_t startSize = blob->size();
605 blob->push_back(0);
606 blob->push_back(pointer);
607 blob->push_back(object);
608 if (memoryAccess)
609 {
610 blob->push_back(*memoryAccess);
611 }
612 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpStore);
613 }
WriteCopyMemory(Blob * blob,IdRef target,IdRef source,const spv::MemoryAccessMask * memoryAccess)614 void WriteCopyMemory(Blob *blob,
615 IdRef target,
616 IdRef source,
617 const spv::MemoryAccessMask *memoryAccess)
618 {
619 const size_t startSize = blob->size();
620 blob->push_back(0);
621 blob->push_back(target);
622 blob->push_back(source);
623 if (memoryAccess)
624 {
625 blob->push_back(*memoryAccess);
626 }
627 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCopyMemory);
628 }
WriteAccessChain(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,const IdRefList & indexesList)629 void WriteAccessChain(Blob *blob,
630 IdResultType idResultType,
631 IdResult idResult,
632 IdRef base,
633 const IdRefList &indexesList)
634 {
635 const size_t startSize = blob->size();
636 blob->push_back(0);
637 blob->push_back(idResultType);
638 blob->push_back(idResult);
639 blob->push_back(base);
640 for (const auto &operand : indexesList)
641 {
642 blob->push_back(operand);
643 }
644 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAccessChain);
645 }
WriteInBoundsAccessChain(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,const IdRefList & indexesList)646 void WriteInBoundsAccessChain(Blob *blob,
647 IdResultType idResultType,
648 IdResult idResult,
649 IdRef base,
650 const IdRefList &indexesList)
651 {
652 const size_t startSize = blob->size();
653 blob->push_back(0);
654 blob->push_back(idResultType);
655 blob->push_back(idResult);
656 blob->push_back(base);
657 for (const auto &operand : indexesList)
658 {
659 blob->push_back(operand);
660 }
661 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpInBoundsAccessChain);
662 }
WriteArrayLength(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef structure,LiteralInteger arraymember)663 void WriteArrayLength(Blob *blob,
664 IdResultType idResultType,
665 IdResult idResult,
666 IdRef structure,
667 LiteralInteger arraymember)
668 {
669 const size_t startSize = blob->size();
670 blob->push_back(0);
671 blob->push_back(idResultType);
672 blob->push_back(idResult);
673 blob->push_back(structure);
674 blob->push_back(arraymember);
675 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpArrayLength);
676 }
WriteDecorate(Blob * blob,IdRef target,spv::Decoration decoration,const LiteralIntegerList & valuesList)677 void WriteDecorate(Blob *blob,
678 IdRef target,
679 spv::Decoration decoration,
680 const LiteralIntegerList &valuesList)
681 {
682 const size_t startSize = blob->size();
683 blob->push_back(0);
684 blob->push_back(target);
685 blob->push_back(decoration);
686 for (const auto &operand : valuesList)
687 {
688 blob->push_back(operand);
689 }
690 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDecorate);
691 }
WriteMemberDecorate(Blob * blob,IdRef structureType,LiteralInteger member,spv::Decoration decoration,const LiteralIntegerList & valuesList)692 void WriteMemberDecorate(Blob *blob,
693 IdRef structureType,
694 LiteralInteger member,
695 spv::Decoration decoration,
696 const LiteralIntegerList &valuesList)
697 {
698 const size_t startSize = blob->size();
699 blob->push_back(0);
700 blob->push_back(structureType);
701 blob->push_back(member);
702 blob->push_back(decoration);
703 for (const auto &operand : valuesList)
704 {
705 blob->push_back(operand);
706 }
707 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMemberDecorate);
708 }
WriteDecorationGroup(Blob * blob,IdResult idResult)709 void WriteDecorationGroup(Blob *blob, IdResult idResult)
710 {
711 const size_t startSize = blob->size();
712 blob->push_back(0);
713 blob->push_back(idResult);
714 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDecorationGroup);
715 }
WriteGroupDecorate(Blob * blob,IdRef decorationGroup,const IdRefList & targetsList)716 void WriteGroupDecorate(Blob *blob, IdRef decorationGroup, const IdRefList &targetsList)
717 {
718 const size_t startSize = blob->size();
719 blob->push_back(0);
720 blob->push_back(decorationGroup);
721 for (const auto &operand : targetsList)
722 {
723 blob->push_back(operand);
724 }
725 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupDecorate);
726 }
WriteGroupMemberDecorate(Blob * blob,IdRef decorationGroup,const PairIdRefLiteralIntegerList & targetsPairList)727 void WriteGroupMemberDecorate(Blob *blob,
728 IdRef decorationGroup,
729 const PairIdRefLiteralIntegerList &targetsPairList)
730 {
731 const size_t startSize = blob->size();
732 blob->push_back(0);
733 blob->push_back(decorationGroup);
734 for (const auto &operand : targetsPairList)
735 {
736 blob->push_back(operand.id);
737 blob->push_back(operand.literal);
738 }
739 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupMemberDecorate);
740 }
WriteVectorExtractDynamic(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector,IdRef index)741 void WriteVectorExtractDynamic(Blob *blob,
742 IdResultType idResultType,
743 IdResult idResult,
744 IdRef vector,
745 IdRef index)
746 {
747 const size_t startSize = blob->size();
748 blob->push_back(0);
749 blob->push_back(idResultType);
750 blob->push_back(idResult);
751 blob->push_back(vector);
752 blob->push_back(index);
753 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorExtractDynamic);
754 }
WriteVectorInsertDynamic(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector,IdRef component,IdRef index)755 void WriteVectorInsertDynamic(Blob *blob,
756 IdResultType idResultType,
757 IdResult idResult,
758 IdRef vector,
759 IdRef component,
760 IdRef index)
761 {
762 const size_t startSize = blob->size();
763 blob->push_back(0);
764 blob->push_back(idResultType);
765 blob->push_back(idResult);
766 blob->push_back(vector);
767 blob->push_back(component);
768 blob->push_back(index);
769 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorInsertDynamic);
770 }
WriteVectorShuffle(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector1,IdRef vector2,const LiteralIntegerList & componentsList)771 void WriteVectorShuffle(Blob *blob,
772 IdResultType idResultType,
773 IdResult idResult,
774 IdRef vector1,
775 IdRef vector2,
776 const LiteralIntegerList &componentsList)
777 {
778 const size_t startSize = blob->size();
779 blob->push_back(0);
780 blob->push_back(idResultType);
781 blob->push_back(idResult);
782 blob->push_back(vector1);
783 blob->push_back(vector2);
784 for (const auto &operand : componentsList)
785 {
786 blob->push_back(operand);
787 }
788 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorShuffle);
789 }
WriteCompositeConstruct(Blob * blob,IdResultType idResultType,IdResult idResult,const IdRefList & constituentsList)790 void WriteCompositeConstruct(Blob *blob,
791 IdResultType idResultType,
792 IdResult idResult,
793 const IdRefList &constituentsList)
794 {
795 const size_t startSize = blob->size();
796 blob->push_back(0);
797 blob->push_back(idResultType);
798 blob->push_back(idResult);
799 for (const auto &operand : constituentsList)
800 {
801 blob->push_back(operand);
802 }
803 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCompositeConstruct);
804 }
WriteCompositeExtract(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef composite,const LiteralIntegerList & indexesList)805 void WriteCompositeExtract(Blob *blob,
806 IdResultType idResultType,
807 IdResult idResult,
808 IdRef composite,
809 const LiteralIntegerList &indexesList)
810 {
811 const size_t startSize = blob->size();
812 blob->push_back(0);
813 blob->push_back(idResultType);
814 blob->push_back(idResult);
815 blob->push_back(composite);
816 for (const auto &operand : indexesList)
817 {
818 blob->push_back(operand);
819 }
820 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCompositeExtract);
821 }
WriteCompositeInsert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef object,IdRef composite,const LiteralIntegerList & indexesList)822 void WriteCompositeInsert(Blob *blob,
823 IdResultType idResultType,
824 IdResult idResult,
825 IdRef object,
826 IdRef composite,
827 const LiteralIntegerList &indexesList)
828 {
829 const size_t startSize = blob->size();
830 blob->push_back(0);
831 blob->push_back(idResultType);
832 blob->push_back(idResult);
833 blob->push_back(object);
834 blob->push_back(composite);
835 for (const auto &operand : indexesList)
836 {
837 blob->push_back(operand);
838 }
839 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCompositeInsert);
840 }
WriteCopyObject(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)841 void WriteCopyObject(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
842 {
843 const size_t startSize = blob->size();
844 blob->push_back(0);
845 blob->push_back(idResultType);
846 blob->push_back(idResult);
847 blob->push_back(operand);
848 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpCopyObject);
849 }
WriteTranspose(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef matrix)850 void WriteTranspose(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef matrix)
851 {
852 const size_t startSize = blob->size();
853 blob->push_back(0);
854 blob->push_back(idResultType);
855 blob->push_back(idResult);
856 blob->push_back(matrix);
857 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpTranspose);
858 }
WriteSampledImage(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef sampler)859 void WriteSampledImage(Blob *blob,
860 IdResultType idResultType,
861 IdResult idResult,
862 IdRef image,
863 IdRef sampler)
864 {
865 const size_t startSize = blob->size();
866 blob->push_back(0);
867 blob->push_back(idResultType);
868 blob->push_back(idResult);
869 blob->push_back(image);
870 blob->push_back(sampler);
871 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSampledImage);
872 }
WriteImageSampleImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)873 void WriteImageSampleImplicitLod(Blob *blob,
874 IdResultType idResultType,
875 IdResult idResult,
876 IdRef sampledImage,
877 IdRef coordinate,
878 const spv::ImageOperandsMask *imageOperands,
879 const IdRefList &imageOperandIdsList)
880 {
881 const size_t startSize = blob->size();
882 blob->push_back(0);
883 blob->push_back(idResultType);
884 blob->push_back(idResult);
885 blob->push_back(sampledImage);
886 blob->push_back(coordinate);
887 if (imageOperands)
888 {
889 blob->push_back(*imageOperands);
890 }
891 for (const auto &operand : imageOperandIdsList)
892 {
893 blob->push_back(operand);
894 }
895 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleImplicitLod);
896 }
WriteImageSampleExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)897 void WriteImageSampleExplicitLod(Blob *blob,
898 IdResultType idResultType,
899 IdResult idResult,
900 IdRef sampledImage,
901 IdRef coordinate,
902 spv::ImageOperandsMask imageOperands,
903 const IdRefList &imageOperandIdsList)
904 {
905 const size_t startSize = blob->size();
906 blob->push_back(0);
907 blob->push_back(idResultType);
908 blob->push_back(idResult);
909 blob->push_back(sampledImage);
910 blob->push_back(coordinate);
911 blob->push_back(imageOperands);
912 for (const auto &operand : imageOperandIdsList)
913 {
914 blob->push_back(operand);
915 }
916 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleExplicitLod);
917 }
WriteImageSampleDrefImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)918 void WriteImageSampleDrefImplicitLod(Blob *blob,
919 IdResultType idResultType,
920 IdResult idResult,
921 IdRef sampledImage,
922 IdRef coordinate,
923 IdRef dref,
924 const spv::ImageOperandsMask *imageOperands,
925 const IdRefList &imageOperandIdsList)
926 {
927 const size_t startSize = blob->size();
928 blob->push_back(0);
929 blob->push_back(idResultType);
930 blob->push_back(idResult);
931 blob->push_back(sampledImage);
932 blob->push_back(coordinate);
933 blob->push_back(dref);
934 if (imageOperands)
935 {
936 blob->push_back(*imageOperands);
937 }
938 for (const auto &operand : imageOperandIdsList)
939 {
940 blob->push_back(operand);
941 }
942 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleDrefImplicitLod);
943 }
WriteImageSampleDrefExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)944 void WriteImageSampleDrefExplicitLod(Blob *blob,
945 IdResultType idResultType,
946 IdResult idResult,
947 IdRef sampledImage,
948 IdRef coordinate,
949 IdRef dref,
950 spv::ImageOperandsMask imageOperands,
951 const IdRefList &imageOperandIdsList)
952 {
953 const size_t startSize = blob->size();
954 blob->push_back(0);
955 blob->push_back(idResultType);
956 blob->push_back(idResult);
957 blob->push_back(sampledImage);
958 blob->push_back(coordinate);
959 blob->push_back(dref);
960 blob->push_back(imageOperands);
961 for (const auto &operand : imageOperandIdsList)
962 {
963 blob->push_back(operand);
964 }
965 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleDrefExplicitLod);
966 }
WriteImageSampleProjImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)967 void WriteImageSampleProjImplicitLod(Blob *blob,
968 IdResultType idResultType,
969 IdResult idResult,
970 IdRef sampledImage,
971 IdRef coordinate,
972 const spv::ImageOperandsMask *imageOperands,
973 const IdRefList &imageOperandIdsList)
974 {
975 const size_t startSize = blob->size();
976 blob->push_back(0);
977 blob->push_back(idResultType);
978 blob->push_back(idResult);
979 blob->push_back(sampledImage);
980 blob->push_back(coordinate);
981 if (imageOperands)
982 {
983 blob->push_back(*imageOperands);
984 }
985 for (const auto &operand : imageOperandIdsList)
986 {
987 blob->push_back(operand);
988 }
989 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleProjImplicitLod);
990 }
WriteImageSampleProjExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)991 void WriteImageSampleProjExplicitLod(Blob *blob,
992 IdResultType idResultType,
993 IdResult idResult,
994 IdRef sampledImage,
995 IdRef coordinate,
996 spv::ImageOperandsMask imageOperands,
997 const IdRefList &imageOperandIdsList)
998 {
999 const size_t startSize = blob->size();
1000 blob->push_back(0);
1001 blob->push_back(idResultType);
1002 blob->push_back(idResult);
1003 blob->push_back(sampledImage);
1004 blob->push_back(coordinate);
1005 blob->push_back(imageOperands);
1006 for (const auto &operand : imageOperandIdsList)
1007 {
1008 blob->push_back(operand);
1009 }
1010 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSampleProjExplicitLod);
1011 }
WriteImageSampleProjDrefImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1012 void WriteImageSampleProjDrefImplicitLod(Blob *blob,
1013 IdResultType idResultType,
1014 IdResult idResult,
1015 IdRef sampledImage,
1016 IdRef coordinate,
1017 IdRef dref,
1018 const spv::ImageOperandsMask *imageOperands,
1019 const IdRefList &imageOperandIdsList)
1020 {
1021 const size_t startSize = blob->size();
1022 blob->push_back(0);
1023 blob->push_back(idResultType);
1024 blob->push_back(idResult);
1025 blob->push_back(sampledImage);
1026 blob->push_back(coordinate);
1027 blob->push_back(dref);
1028 if (imageOperands)
1029 {
1030 blob->push_back(*imageOperands);
1031 }
1032 for (const auto &operand : imageOperandIdsList)
1033 {
1034 blob->push_back(operand);
1035 }
1036 (*blob)[startSize] =
1037 MakeLengthOp(blob->size() - startSize, spv::OpImageSampleProjDrefImplicitLod);
1038 }
WriteImageSampleProjDrefExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)1039 void WriteImageSampleProjDrefExplicitLod(Blob *blob,
1040 IdResultType idResultType,
1041 IdResult idResult,
1042 IdRef sampledImage,
1043 IdRef coordinate,
1044 IdRef dref,
1045 spv::ImageOperandsMask imageOperands,
1046 const IdRefList &imageOperandIdsList)
1047 {
1048 const size_t startSize = blob->size();
1049 blob->push_back(0);
1050 blob->push_back(idResultType);
1051 blob->push_back(idResult);
1052 blob->push_back(sampledImage);
1053 blob->push_back(coordinate);
1054 blob->push_back(dref);
1055 blob->push_back(imageOperands);
1056 for (const auto &operand : imageOperandIdsList)
1057 {
1058 blob->push_back(operand);
1059 }
1060 (*blob)[startSize] =
1061 MakeLengthOp(blob->size() - startSize, spv::OpImageSampleProjDrefExplicitLod);
1062 }
WriteImageFetch(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1063 void WriteImageFetch(Blob *blob,
1064 IdResultType idResultType,
1065 IdResult idResult,
1066 IdRef image,
1067 IdRef coordinate,
1068 const spv::ImageOperandsMask *imageOperands,
1069 const IdRefList &imageOperandIdsList)
1070 {
1071 const size_t startSize = blob->size();
1072 blob->push_back(0);
1073 blob->push_back(idResultType);
1074 blob->push_back(idResult);
1075 blob->push_back(image);
1076 blob->push_back(coordinate);
1077 if (imageOperands)
1078 {
1079 blob->push_back(*imageOperands);
1080 }
1081 for (const auto &operand : imageOperandIdsList)
1082 {
1083 blob->push_back(operand);
1084 }
1085 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageFetch);
1086 }
WriteImageGather(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef component,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1087 void WriteImageGather(Blob *blob,
1088 IdResultType idResultType,
1089 IdResult idResult,
1090 IdRef sampledImage,
1091 IdRef coordinate,
1092 IdRef component,
1093 const spv::ImageOperandsMask *imageOperands,
1094 const IdRefList &imageOperandIdsList)
1095 {
1096 const size_t startSize = blob->size();
1097 blob->push_back(0);
1098 blob->push_back(idResultType);
1099 blob->push_back(idResult);
1100 blob->push_back(sampledImage);
1101 blob->push_back(coordinate);
1102 blob->push_back(component);
1103 if (imageOperands)
1104 {
1105 blob->push_back(*imageOperands);
1106 }
1107 for (const auto &operand : imageOperandIdsList)
1108 {
1109 blob->push_back(operand);
1110 }
1111 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageGather);
1112 }
WriteImageDrefGather(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1113 void WriteImageDrefGather(Blob *blob,
1114 IdResultType idResultType,
1115 IdResult idResult,
1116 IdRef sampledImage,
1117 IdRef coordinate,
1118 IdRef dref,
1119 const spv::ImageOperandsMask *imageOperands,
1120 const IdRefList &imageOperandIdsList)
1121 {
1122 const size_t startSize = blob->size();
1123 blob->push_back(0);
1124 blob->push_back(idResultType);
1125 blob->push_back(idResult);
1126 blob->push_back(sampledImage);
1127 blob->push_back(coordinate);
1128 blob->push_back(dref);
1129 if (imageOperands)
1130 {
1131 blob->push_back(*imageOperands);
1132 }
1133 for (const auto &operand : imageOperandIdsList)
1134 {
1135 blob->push_back(operand);
1136 }
1137 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageDrefGather);
1138 }
WriteImageRead(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1139 void WriteImageRead(Blob *blob,
1140 IdResultType idResultType,
1141 IdResult idResult,
1142 IdRef image,
1143 IdRef coordinate,
1144 const spv::ImageOperandsMask *imageOperands,
1145 const IdRefList &imageOperandIdsList)
1146 {
1147 const size_t startSize = blob->size();
1148 blob->push_back(0);
1149 blob->push_back(idResultType);
1150 blob->push_back(idResult);
1151 blob->push_back(image);
1152 blob->push_back(coordinate);
1153 if (imageOperands)
1154 {
1155 blob->push_back(*imageOperands);
1156 }
1157 for (const auto &operand : imageOperandIdsList)
1158 {
1159 blob->push_back(operand);
1160 }
1161 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageRead);
1162 }
WriteImageWrite(Blob * blob,IdRef image,IdRef coordinate,IdRef texel,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)1163 void WriteImageWrite(Blob *blob,
1164 IdRef image,
1165 IdRef coordinate,
1166 IdRef texel,
1167 const spv::ImageOperandsMask *imageOperands,
1168 const IdRefList &imageOperandIdsList)
1169 {
1170 const size_t startSize = blob->size();
1171 blob->push_back(0);
1172 blob->push_back(image);
1173 blob->push_back(coordinate);
1174 blob->push_back(texel);
1175 if (imageOperands)
1176 {
1177 blob->push_back(*imageOperands);
1178 }
1179 for (const auto &operand : imageOperandIdsList)
1180 {
1181 blob->push_back(operand);
1182 }
1183 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageWrite);
1184 }
WriteImage(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage)1185 void WriteImage(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef sampledImage)
1186 {
1187 const size_t startSize = blob->size();
1188 blob->push_back(0);
1189 blob->push_back(idResultType);
1190 blob->push_back(idResult);
1191 blob->push_back(sampledImage);
1192 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImage);
1193 }
WriteImageQuerySizeLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef levelofDetail)1194 void WriteImageQuerySizeLod(Blob *blob,
1195 IdResultType idResultType,
1196 IdResult idResult,
1197 IdRef image,
1198 IdRef levelofDetail)
1199 {
1200 const size_t startSize = blob->size();
1201 blob->push_back(0);
1202 blob->push_back(idResultType);
1203 blob->push_back(idResult);
1204 blob->push_back(image);
1205 blob->push_back(levelofDetail);
1206 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQuerySizeLod);
1207 }
WriteImageQuerySize(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image)1208 void WriteImageQuerySize(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef image)
1209 {
1210 const size_t startSize = blob->size();
1211 blob->push_back(0);
1212 blob->push_back(idResultType);
1213 blob->push_back(idResult);
1214 blob->push_back(image);
1215 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQuerySize);
1216 }
WriteImageQueryLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate)1217 void WriteImageQueryLod(Blob *blob,
1218 IdResultType idResultType,
1219 IdResult idResult,
1220 IdRef sampledImage,
1221 IdRef coordinate)
1222 {
1223 const size_t startSize = blob->size();
1224 blob->push_back(0);
1225 blob->push_back(idResultType);
1226 blob->push_back(idResult);
1227 blob->push_back(sampledImage);
1228 blob->push_back(coordinate);
1229 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQueryLod);
1230 }
WriteImageQueryLevels(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image)1231 void WriteImageQueryLevels(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef image)
1232 {
1233 const size_t startSize = blob->size();
1234 blob->push_back(0);
1235 blob->push_back(idResultType);
1236 blob->push_back(idResult);
1237 blob->push_back(image);
1238 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQueryLevels);
1239 }
WriteImageQuerySamples(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image)1240 void WriteImageQuerySamples(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef image)
1241 {
1242 const size_t startSize = blob->size();
1243 blob->push_back(0);
1244 blob->push_back(idResultType);
1245 blob->push_back(idResult);
1246 blob->push_back(image);
1247 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageQuerySamples);
1248 }
WriteConvertFToU(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef floatValue)1249 void WriteConvertFToU(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef floatValue)
1250 {
1251 const size_t startSize = blob->size();
1252 blob->push_back(0);
1253 blob->push_back(idResultType);
1254 blob->push_back(idResult);
1255 blob->push_back(floatValue);
1256 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConvertFToU);
1257 }
WriteConvertFToS(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef floatValue)1258 void WriteConvertFToS(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef floatValue)
1259 {
1260 const size_t startSize = blob->size();
1261 blob->push_back(0);
1262 blob->push_back(idResultType);
1263 blob->push_back(idResult);
1264 blob->push_back(floatValue);
1265 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConvertFToS);
1266 }
WriteConvertSToF(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef signedValue)1267 void WriteConvertSToF(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef signedValue)
1268 {
1269 const size_t startSize = blob->size();
1270 blob->push_back(0);
1271 blob->push_back(idResultType);
1272 blob->push_back(idResult);
1273 blob->push_back(signedValue);
1274 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConvertSToF);
1275 }
WriteConvertUToF(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef unsignedValue)1276 void WriteConvertUToF(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef unsignedValue)
1277 {
1278 const size_t startSize = blob->size();
1279 blob->push_back(0);
1280 blob->push_back(idResultType);
1281 blob->push_back(idResult);
1282 blob->push_back(unsignedValue);
1283 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpConvertUToF);
1284 }
WriteUConvert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef unsignedValue)1285 void WriteUConvert(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef unsignedValue)
1286 {
1287 const size_t startSize = blob->size();
1288 blob->push_back(0);
1289 blob->push_back(idResultType);
1290 blob->push_back(idResult);
1291 blob->push_back(unsignedValue);
1292 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUConvert);
1293 }
WriteSConvert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef signedValue)1294 void WriteSConvert(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef signedValue)
1295 {
1296 const size_t startSize = blob->size();
1297 blob->push_back(0);
1298 blob->push_back(idResultType);
1299 blob->push_back(idResult);
1300 blob->push_back(signedValue);
1301 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSConvert);
1302 }
WriteFConvert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef floatValue)1303 void WriteFConvert(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef floatValue)
1304 {
1305 const size_t startSize = blob->size();
1306 blob->push_back(0);
1307 blob->push_back(idResultType);
1308 blob->push_back(idResult);
1309 blob->push_back(floatValue);
1310 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFConvert);
1311 }
WriteQuantizeToF16(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef value)1312 void WriteQuantizeToF16(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef value)
1313 {
1314 const size_t startSize = blob->size();
1315 blob->push_back(0);
1316 blob->push_back(idResultType);
1317 blob->push_back(idResult);
1318 blob->push_back(value);
1319 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpQuantizeToF16);
1320 }
WriteBitcast(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)1321 void WriteBitcast(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
1322 {
1323 const size_t startSize = blob->size();
1324 blob->push_back(0);
1325 blob->push_back(idResultType);
1326 blob->push_back(idResult);
1327 blob->push_back(operand);
1328 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitcast);
1329 }
WriteSNegate(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)1330 void WriteSNegate(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
1331 {
1332 const size_t startSize = blob->size();
1333 blob->push_back(0);
1334 blob->push_back(idResultType);
1335 blob->push_back(idResult);
1336 blob->push_back(operand);
1337 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSNegate);
1338 }
WriteFNegate(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)1339 void WriteFNegate(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
1340 {
1341 const size_t startSize = blob->size();
1342 blob->push_back(0);
1343 blob->push_back(idResultType);
1344 blob->push_back(idResult);
1345 blob->push_back(operand);
1346 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFNegate);
1347 }
WriteIAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1348 void WriteIAdd(Blob *blob,
1349 IdResultType idResultType,
1350 IdResult idResult,
1351 IdRef operand1,
1352 IdRef operand2)
1353 {
1354 const size_t startSize = blob->size();
1355 blob->push_back(0);
1356 blob->push_back(idResultType);
1357 blob->push_back(idResult);
1358 blob->push_back(operand1);
1359 blob->push_back(operand2);
1360 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIAdd);
1361 }
WriteFAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1362 void WriteFAdd(Blob *blob,
1363 IdResultType idResultType,
1364 IdResult idResult,
1365 IdRef operand1,
1366 IdRef operand2)
1367 {
1368 const size_t startSize = blob->size();
1369 blob->push_back(0);
1370 blob->push_back(idResultType);
1371 blob->push_back(idResult);
1372 blob->push_back(operand1);
1373 blob->push_back(operand2);
1374 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFAdd);
1375 }
WriteISub(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1376 void WriteISub(Blob *blob,
1377 IdResultType idResultType,
1378 IdResult idResult,
1379 IdRef operand1,
1380 IdRef operand2)
1381 {
1382 const size_t startSize = blob->size();
1383 blob->push_back(0);
1384 blob->push_back(idResultType);
1385 blob->push_back(idResult);
1386 blob->push_back(operand1);
1387 blob->push_back(operand2);
1388 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpISub);
1389 }
WriteFSub(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1390 void WriteFSub(Blob *blob,
1391 IdResultType idResultType,
1392 IdResult idResult,
1393 IdRef operand1,
1394 IdRef operand2)
1395 {
1396 const size_t startSize = blob->size();
1397 blob->push_back(0);
1398 blob->push_back(idResultType);
1399 blob->push_back(idResult);
1400 blob->push_back(operand1);
1401 blob->push_back(operand2);
1402 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFSub);
1403 }
WriteIMul(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1404 void WriteIMul(Blob *blob,
1405 IdResultType idResultType,
1406 IdResult idResult,
1407 IdRef operand1,
1408 IdRef operand2)
1409 {
1410 const size_t startSize = blob->size();
1411 blob->push_back(0);
1412 blob->push_back(idResultType);
1413 blob->push_back(idResult);
1414 blob->push_back(operand1);
1415 blob->push_back(operand2);
1416 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIMul);
1417 }
WriteFMul(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1418 void WriteFMul(Blob *blob,
1419 IdResultType idResultType,
1420 IdResult idResult,
1421 IdRef operand1,
1422 IdRef operand2)
1423 {
1424 const size_t startSize = blob->size();
1425 blob->push_back(0);
1426 blob->push_back(idResultType);
1427 blob->push_back(idResult);
1428 blob->push_back(operand1);
1429 blob->push_back(operand2);
1430 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFMul);
1431 }
WriteUDiv(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1432 void WriteUDiv(Blob *blob,
1433 IdResultType idResultType,
1434 IdResult idResult,
1435 IdRef operand1,
1436 IdRef operand2)
1437 {
1438 const size_t startSize = blob->size();
1439 blob->push_back(0);
1440 blob->push_back(idResultType);
1441 blob->push_back(idResult);
1442 blob->push_back(operand1);
1443 blob->push_back(operand2);
1444 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUDiv);
1445 }
WriteSDiv(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1446 void WriteSDiv(Blob *blob,
1447 IdResultType idResultType,
1448 IdResult idResult,
1449 IdRef operand1,
1450 IdRef operand2)
1451 {
1452 const size_t startSize = blob->size();
1453 blob->push_back(0);
1454 blob->push_back(idResultType);
1455 blob->push_back(idResult);
1456 blob->push_back(operand1);
1457 blob->push_back(operand2);
1458 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSDiv);
1459 }
WriteFDiv(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1460 void WriteFDiv(Blob *blob,
1461 IdResultType idResultType,
1462 IdResult idResult,
1463 IdRef operand1,
1464 IdRef operand2)
1465 {
1466 const size_t startSize = blob->size();
1467 blob->push_back(0);
1468 blob->push_back(idResultType);
1469 blob->push_back(idResult);
1470 blob->push_back(operand1);
1471 blob->push_back(operand2);
1472 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFDiv);
1473 }
WriteUMod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1474 void WriteUMod(Blob *blob,
1475 IdResultType idResultType,
1476 IdResult idResult,
1477 IdRef operand1,
1478 IdRef operand2)
1479 {
1480 const size_t startSize = blob->size();
1481 blob->push_back(0);
1482 blob->push_back(idResultType);
1483 blob->push_back(idResult);
1484 blob->push_back(operand1);
1485 blob->push_back(operand2);
1486 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUMod);
1487 }
WriteSRem(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1488 void WriteSRem(Blob *blob,
1489 IdResultType idResultType,
1490 IdResult idResult,
1491 IdRef operand1,
1492 IdRef operand2)
1493 {
1494 const size_t startSize = blob->size();
1495 blob->push_back(0);
1496 blob->push_back(idResultType);
1497 blob->push_back(idResult);
1498 blob->push_back(operand1);
1499 blob->push_back(operand2);
1500 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSRem);
1501 }
WriteSMod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1502 void WriteSMod(Blob *blob,
1503 IdResultType idResultType,
1504 IdResult idResult,
1505 IdRef operand1,
1506 IdRef operand2)
1507 {
1508 const size_t startSize = blob->size();
1509 blob->push_back(0);
1510 blob->push_back(idResultType);
1511 blob->push_back(idResult);
1512 blob->push_back(operand1);
1513 blob->push_back(operand2);
1514 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSMod);
1515 }
WriteFRem(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1516 void WriteFRem(Blob *blob,
1517 IdResultType idResultType,
1518 IdResult idResult,
1519 IdRef operand1,
1520 IdRef operand2)
1521 {
1522 const size_t startSize = blob->size();
1523 blob->push_back(0);
1524 blob->push_back(idResultType);
1525 blob->push_back(idResult);
1526 blob->push_back(operand1);
1527 blob->push_back(operand2);
1528 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFRem);
1529 }
WriteFMod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1530 void WriteFMod(Blob *blob,
1531 IdResultType idResultType,
1532 IdResult idResult,
1533 IdRef operand1,
1534 IdRef operand2)
1535 {
1536 const size_t startSize = blob->size();
1537 blob->push_back(0);
1538 blob->push_back(idResultType);
1539 blob->push_back(idResult);
1540 blob->push_back(operand1);
1541 blob->push_back(operand2);
1542 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFMod);
1543 }
WriteVectorTimesScalar(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector,IdRef scalar)1544 void WriteVectorTimesScalar(Blob *blob,
1545 IdResultType idResultType,
1546 IdResult idResult,
1547 IdRef vector,
1548 IdRef scalar)
1549 {
1550 const size_t startSize = blob->size();
1551 blob->push_back(0);
1552 blob->push_back(idResultType);
1553 blob->push_back(idResult);
1554 blob->push_back(vector);
1555 blob->push_back(scalar);
1556 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorTimesScalar);
1557 }
WriteMatrixTimesScalar(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef matrix,IdRef scalar)1558 void WriteMatrixTimesScalar(Blob *blob,
1559 IdResultType idResultType,
1560 IdResult idResult,
1561 IdRef matrix,
1562 IdRef scalar)
1563 {
1564 const size_t startSize = blob->size();
1565 blob->push_back(0);
1566 blob->push_back(idResultType);
1567 blob->push_back(idResult);
1568 blob->push_back(matrix);
1569 blob->push_back(scalar);
1570 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMatrixTimesScalar);
1571 }
WriteVectorTimesMatrix(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector,IdRef matrix)1572 void WriteVectorTimesMatrix(Blob *blob,
1573 IdResultType idResultType,
1574 IdResult idResult,
1575 IdRef vector,
1576 IdRef matrix)
1577 {
1578 const size_t startSize = blob->size();
1579 blob->push_back(0);
1580 blob->push_back(idResultType);
1581 blob->push_back(idResult);
1582 blob->push_back(vector);
1583 blob->push_back(matrix);
1584 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpVectorTimesMatrix);
1585 }
WriteMatrixTimesVector(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef matrix,IdRef vector)1586 void WriteMatrixTimesVector(Blob *blob,
1587 IdResultType idResultType,
1588 IdResult idResult,
1589 IdRef matrix,
1590 IdRef vector)
1591 {
1592 const size_t startSize = blob->size();
1593 blob->push_back(0);
1594 blob->push_back(idResultType);
1595 blob->push_back(idResult);
1596 blob->push_back(matrix);
1597 blob->push_back(vector);
1598 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMatrixTimesVector);
1599 }
WriteMatrixTimesMatrix(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef leftMatrix,IdRef rightMatrix)1600 void WriteMatrixTimesMatrix(Blob *blob,
1601 IdResultType idResultType,
1602 IdResult idResult,
1603 IdRef leftMatrix,
1604 IdRef rightMatrix)
1605 {
1606 const size_t startSize = blob->size();
1607 blob->push_back(0);
1608 blob->push_back(idResultType);
1609 blob->push_back(idResult);
1610 blob->push_back(leftMatrix);
1611 blob->push_back(rightMatrix);
1612 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMatrixTimesMatrix);
1613 }
WriteOuterProduct(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector1,IdRef vector2)1614 void WriteOuterProduct(Blob *blob,
1615 IdResultType idResultType,
1616 IdResult idResult,
1617 IdRef vector1,
1618 IdRef vector2)
1619 {
1620 const size_t startSize = blob->size();
1621 blob->push_back(0);
1622 blob->push_back(idResultType);
1623 blob->push_back(idResult);
1624 blob->push_back(vector1);
1625 blob->push_back(vector2);
1626 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpOuterProduct);
1627 }
WriteDot(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector1,IdRef vector2)1628 void WriteDot(Blob *blob,
1629 IdResultType idResultType,
1630 IdResult idResult,
1631 IdRef vector1,
1632 IdRef vector2)
1633 {
1634 const size_t startSize = blob->size();
1635 blob->push_back(0);
1636 blob->push_back(idResultType);
1637 blob->push_back(idResult);
1638 blob->push_back(vector1);
1639 blob->push_back(vector2);
1640 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDot);
1641 }
WriteIAddCarry(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1642 void WriteIAddCarry(Blob *blob,
1643 IdResultType idResultType,
1644 IdResult idResult,
1645 IdRef operand1,
1646 IdRef operand2)
1647 {
1648 const size_t startSize = blob->size();
1649 blob->push_back(0);
1650 blob->push_back(idResultType);
1651 blob->push_back(idResult);
1652 blob->push_back(operand1);
1653 blob->push_back(operand2);
1654 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIAddCarry);
1655 }
WriteISubBorrow(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1656 void WriteISubBorrow(Blob *blob,
1657 IdResultType idResultType,
1658 IdResult idResult,
1659 IdRef operand1,
1660 IdRef operand2)
1661 {
1662 const size_t startSize = blob->size();
1663 blob->push_back(0);
1664 blob->push_back(idResultType);
1665 blob->push_back(idResult);
1666 blob->push_back(operand1);
1667 blob->push_back(operand2);
1668 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpISubBorrow);
1669 }
WriteUMulExtended(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1670 void WriteUMulExtended(Blob *blob,
1671 IdResultType idResultType,
1672 IdResult idResult,
1673 IdRef operand1,
1674 IdRef operand2)
1675 {
1676 const size_t startSize = blob->size();
1677 blob->push_back(0);
1678 blob->push_back(idResultType);
1679 blob->push_back(idResult);
1680 blob->push_back(operand1);
1681 blob->push_back(operand2);
1682 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUMulExtended);
1683 }
WriteSMulExtended(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1684 void WriteSMulExtended(Blob *blob,
1685 IdResultType idResultType,
1686 IdResult idResult,
1687 IdRef operand1,
1688 IdRef operand2)
1689 {
1690 const size_t startSize = blob->size();
1691 blob->push_back(0);
1692 blob->push_back(idResultType);
1693 blob->push_back(idResult);
1694 blob->push_back(operand1);
1695 blob->push_back(operand2);
1696 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSMulExtended);
1697 }
WriteAny(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector)1698 void WriteAny(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef vector)
1699 {
1700 const size_t startSize = blob->size();
1701 blob->push_back(0);
1702 blob->push_back(idResultType);
1703 blob->push_back(idResult);
1704 blob->push_back(vector);
1705 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAny);
1706 }
WriteAll(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef vector)1707 void WriteAll(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef vector)
1708 {
1709 const size_t startSize = blob->size();
1710 blob->push_back(0);
1711 blob->push_back(idResultType);
1712 blob->push_back(idResult);
1713 blob->push_back(vector);
1714 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAll);
1715 }
WriteIsNan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef x)1716 void WriteIsNan(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef x)
1717 {
1718 const size_t startSize = blob->size();
1719 blob->push_back(0);
1720 blob->push_back(idResultType);
1721 blob->push_back(idResult);
1722 blob->push_back(x);
1723 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIsNan);
1724 }
WriteIsInf(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef x)1725 void WriteIsInf(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef x)
1726 {
1727 const size_t startSize = blob->size();
1728 blob->push_back(0);
1729 blob->push_back(idResultType);
1730 blob->push_back(idResult);
1731 blob->push_back(x);
1732 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIsInf);
1733 }
WriteLogicalEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1734 void WriteLogicalEqual(Blob *blob,
1735 IdResultType idResultType,
1736 IdResult idResult,
1737 IdRef operand1,
1738 IdRef operand2)
1739 {
1740 const size_t startSize = blob->size();
1741 blob->push_back(0);
1742 blob->push_back(idResultType);
1743 blob->push_back(idResult);
1744 blob->push_back(operand1);
1745 blob->push_back(operand2);
1746 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalEqual);
1747 }
WriteLogicalNotEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1748 void WriteLogicalNotEqual(Blob *blob,
1749 IdResultType idResultType,
1750 IdResult idResult,
1751 IdRef operand1,
1752 IdRef operand2)
1753 {
1754 const size_t startSize = blob->size();
1755 blob->push_back(0);
1756 blob->push_back(idResultType);
1757 blob->push_back(idResult);
1758 blob->push_back(operand1);
1759 blob->push_back(operand2);
1760 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalNotEqual);
1761 }
WriteLogicalOr(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1762 void WriteLogicalOr(Blob *blob,
1763 IdResultType idResultType,
1764 IdResult idResult,
1765 IdRef operand1,
1766 IdRef operand2)
1767 {
1768 const size_t startSize = blob->size();
1769 blob->push_back(0);
1770 blob->push_back(idResultType);
1771 blob->push_back(idResult);
1772 blob->push_back(operand1);
1773 blob->push_back(operand2);
1774 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalOr);
1775 }
WriteLogicalAnd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1776 void WriteLogicalAnd(Blob *blob,
1777 IdResultType idResultType,
1778 IdResult idResult,
1779 IdRef operand1,
1780 IdRef operand2)
1781 {
1782 const size_t startSize = blob->size();
1783 blob->push_back(0);
1784 blob->push_back(idResultType);
1785 blob->push_back(idResult);
1786 blob->push_back(operand1);
1787 blob->push_back(operand2);
1788 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalAnd);
1789 }
WriteLogicalNot(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)1790 void WriteLogicalNot(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
1791 {
1792 const size_t startSize = blob->size();
1793 blob->push_back(0);
1794 blob->push_back(idResultType);
1795 blob->push_back(idResult);
1796 blob->push_back(operand);
1797 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLogicalNot);
1798 }
WriteSelect(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef condition,IdRef object1,IdRef object2)1799 void WriteSelect(Blob *blob,
1800 IdResultType idResultType,
1801 IdResult idResult,
1802 IdRef condition,
1803 IdRef object1,
1804 IdRef object2)
1805 {
1806 const size_t startSize = blob->size();
1807 blob->push_back(0);
1808 blob->push_back(idResultType);
1809 blob->push_back(idResult);
1810 blob->push_back(condition);
1811 blob->push_back(object1);
1812 blob->push_back(object2);
1813 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSelect);
1814 }
WriteIEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1815 void WriteIEqual(Blob *blob,
1816 IdResultType idResultType,
1817 IdResult idResult,
1818 IdRef operand1,
1819 IdRef operand2)
1820 {
1821 const size_t startSize = blob->size();
1822 blob->push_back(0);
1823 blob->push_back(idResultType);
1824 blob->push_back(idResult);
1825 blob->push_back(operand1);
1826 blob->push_back(operand2);
1827 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpIEqual);
1828 }
WriteINotEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1829 void WriteINotEqual(Blob *blob,
1830 IdResultType idResultType,
1831 IdResult idResult,
1832 IdRef operand1,
1833 IdRef operand2)
1834 {
1835 const size_t startSize = blob->size();
1836 blob->push_back(0);
1837 blob->push_back(idResultType);
1838 blob->push_back(idResult);
1839 blob->push_back(operand1);
1840 blob->push_back(operand2);
1841 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpINotEqual);
1842 }
WriteUGreaterThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1843 void WriteUGreaterThan(Blob *blob,
1844 IdResultType idResultType,
1845 IdResult idResult,
1846 IdRef operand1,
1847 IdRef operand2)
1848 {
1849 const size_t startSize = blob->size();
1850 blob->push_back(0);
1851 blob->push_back(idResultType);
1852 blob->push_back(idResult);
1853 blob->push_back(operand1);
1854 blob->push_back(operand2);
1855 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUGreaterThan);
1856 }
WriteSGreaterThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1857 void WriteSGreaterThan(Blob *blob,
1858 IdResultType idResultType,
1859 IdResult idResult,
1860 IdRef operand1,
1861 IdRef operand2)
1862 {
1863 const size_t startSize = blob->size();
1864 blob->push_back(0);
1865 blob->push_back(idResultType);
1866 blob->push_back(idResult);
1867 blob->push_back(operand1);
1868 blob->push_back(operand2);
1869 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSGreaterThan);
1870 }
WriteUGreaterThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1871 void WriteUGreaterThanEqual(Blob *blob,
1872 IdResultType idResultType,
1873 IdResult idResult,
1874 IdRef operand1,
1875 IdRef operand2)
1876 {
1877 const size_t startSize = blob->size();
1878 blob->push_back(0);
1879 blob->push_back(idResultType);
1880 blob->push_back(idResult);
1881 blob->push_back(operand1);
1882 blob->push_back(operand2);
1883 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUGreaterThanEqual);
1884 }
WriteSGreaterThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1885 void WriteSGreaterThanEqual(Blob *blob,
1886 IdResultType idResultType,
1887 IdResult idResult,
1888 IdRef operand1,
1889 IdRef operand2)
1890 {
1891 const size_t startSize = blob->size();
1892 blob->push_back(0);
1893 blob->push_back(idResultType);
1894 blob->push_back(idResult);
1895 blob->push_back(operand1);
1896 blob->push_back(operand2);
1897 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSGreaterThanEqual);
1898 }
WriteULessThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1899 void WriteULessThan(Blob *blob,
1900 IdResultType idResultType,
1901 IdResult idResult,
1902 IdRef operand1,
1903 IdRef operand2)
1904 {
1905 const size_t startSize = blob->size();
1906 blob->push_back(0);
1907 blob->push_back(idResultType);
1908 blob->push_back(idResult);
1909 blob->push_back(operand1);
1910 blob->push_back(operand2);
1911 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpULessThan);
1912 }
WriteSLessThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1913 void WriteSLessThan(Blob *blob,
1914 IdResultType idResultType,
1915 IdResult idResult,
1916 IdRef operand1,
1917 IdRef operand2)
1918 {
1919 const size_t startSize = blob->size();
1920 blob->push_back(0);
1921 blob->push_back(idResultType);
1922 blob->push_back(idResult);
1923 blob->push_back(operand1);
1924 blob->push_back(operand2);
1925 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSLessThan);
1926 }
WriteULessThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1927 void WriteULessThanEqual(Blob *blob,
1928 IdResultType idResultType,
1929 IdResult idResult,
1930 IdRef operand1,
1931 IdRef operand2)
1932 {
1933 const size_t startSize = blob->size();
1934 blob->push_back(0);
1935 blob->push_back(idResultType);
1936 blob->push_back(idResult);
1937 blob->push_back(operand1);
1938 blob->push_back(operand2);
1939 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpULessThanEqual);
1940 }
WriteSLessThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1941 void WriteSLessThanEqual(Blob *blob,
1942 IdResultType idResultType,
1943 IdResult idResult,
1944 IdRef operand1,
1945 IdRef operand2)
1946 {
1947 const size_t startSize = blob->size();
1948 blob->push_back(0);
1949 blob->push_back(idResultType);
1950 blob->push_back(idResult);
1951 blob->push_back(operand1);
1952 blob->push_back(operand2);
1953 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSLessThanEqual);
1954 }
WriteFOrdEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1955 void WriteFOrdEqual(Blob *blob,
1956 IdResultType idResultType,
1957 IdResult idResult,
1958 IdRef operand1,
1959 IdRef operand2)
1960 {
1961 const size_t startSize = blob->size();
1962 blob->push_back(0);
1963 blob->push_back(idResultType);
1964 blob->push_back(idResult);
1965 blob->push_back(operand1);
1966 blob->push_back(operand2);
1967 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdEqual);
1968 }
WriteFUnordEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1969 void WriteFUnordEqual(Blob *blob,
1970 IdResultType idResultType,
1971 IdResult idResult,
1972 IdRef operand1,
1973 IdRef operand2)
1974 {
1975 const size_t startSize = blob->size();
1976 blob->push_back(0);
1977 blob->push_back(idResultType);
1978 blob->push_back(idResult);
1979 blob->push_back(operand1);
1980 blob->push_back(operand2);
1981 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordEqual);
1982 }
WriteFOrdNotEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1983 void WriteFOrdNotEqual(Blob *blob,
1984 IdResultType idResultType,
1985 IdResult idResult,
1986 IdRef operand1,
1987 IdRef operand2)
1988 {
1989 const size_t startSize = blob->size();
1990 blob->push_back(0);
1991 blob->push_back(idResultType);
1992 blob->push_back(idResult);
1993 blob->push_back(operand1);
1994 blob->push_back(operand2);
1995 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdNotEqual);
1996 }
WriteFUnordNotEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)1997 void WriteFUnordNotEqual(Blob *blob,
1998 IdResultType idResultType,
1999 IdResult idResult,
2000 IdRef operand1,
2001 IdRef operand2)
2002 {
2003 const size_t startSize = blob->size();
2004 blob->push_back(0);
2005 blob->push_back(idResultType);
2006 blob->push_back(idResult);
2007 blob->push_back(operand1);
2008 blob->push_back(operand2);
2009 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordNotEqual);
2010 }
WriteFOrdLessThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2011 void WriteFOrdLessThan(Blob *blob,
2012 IdResultType idResultType,
2013 IdResult idResult,
2014 IdRef operand1,
2015 IdRef operand2)
2016 {
2017 const size_t startSize = blob->size();
2018 blob->push_back(0);
2019 blob->push_back(idResultType);
2020 blob->push_back(idResult);
2021 blob->push_back(operand1);
2022 blob->push_back(operand2);
2023 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdLessThan);
2024 }
WriteFUnordLessThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2025 void WriteFUnordLessThan(Blob *blob,
2026 IdResultType idResultType,
2027 IdResult idResult,
2028 IdRef operand1,
2029 IdRef operand2)
2030 {
2031 const size_t startSize = blob->size();
2032 blob->push_back(0);
2033 blob->push_back(idResultType);
2034 blob->push_back(idResult);
2035 blob->push_back(operand1);
2036 blob->push_back(operand2);
2037 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordLessThan);
2038 }
WriteFOrdGreaterThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2039 void WriteFOrdGreaterThan(Blob *blob,
2040 IdResultType idResultType,
2041 IdResult idResult,
2042 IdRef operand1,
2043 IdRef operand2)
2044 {
2045 const size_t startSize = blob->size();
2046 blob->push_back(0);
2047 blob->push_back(idResultType);
2048 blob->push_back(idResult);
2049 blob->push_back(operand1);
2050 blob->push_back(operand2);
2051 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdGreaterThan);
2052 }
WriteFUnordGreaterThan(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2053 void WriteFUnordGreaterThan(Blob *blob,
2054 IdResultType idResultType,
2055 IdResult idResult,
2056 IdRef operand1,
2057 IdRef operand2)
2058 {
2059 const size_t startSize = blob->size();
2060 blob->push_back(0);
2061 blob->push_back(idResultType);
2062 blob->push_back(idResult);
2063 blob->push_back(operand1);
2064 blob->push_back(operand2);
2065 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordGreaterThan);
2066 }
WriteFOrdLessThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2067 void WriteFOrdLessThanEqual(Blob *blob,
2068 IdResultType idResultType,
2069 IdResult idResult,
2070 IdRef operand1,
2071 IdRef operand2)
2072 {
2073 const size_t startSize = blob->size();
2074 blob->push_back(0);
2075 blob->push_back(idResultType);
2076 blob->push_back(idResult);
2077 blob->push_back(operand1);
2078 blob->push_back(operand2);
2079 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdLessThanEqual);
2080 }
WriteFUnordLessThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2081 void WriteFUnordLessThanEqual(Blob *blob,
2082 IdResultType idResultType,
2083 IdResult idResult,
2084 IdRef operand1,
2085 IdRef operand2)
2086 {
2087 const size_t startSize = blob->size();
2088 blob->push_back(0);
2089 blob->push_back(idResultType);
2090 blob->push_back(idResult);
2091 blob->push_back(operand1);
2092 blob->push_back(operand2);
2093 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordLessThanEqual);
2094 }
WriteFOrdGreaterThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2095 void WriteFOrdGreaterThanEqual(Blob *blob,
2096 IdResultType idResultType,
2097 IdResult idResult,
2098 IdRef operand1,
2099 IdRef operand2)
2100 {
2101 const size_t startSize = blob->size();
2102 blob->push_back(0);
2103 blob->push_back(idResultType);
2104 blob->push_back(idResult);
2105 blob->push_back(operand1);
2106 blob->push_back(operand2);
2107 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFOrdGreaterThanEqual);
2108 }
WriteFUnordGreaterThanEqual(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2109 void WriteFUnordGreaterThanEqual(Blob *blob,
2110 IdResultType idResultType,
2111 IdResult idResult,
2112 IdRef operand1,
2113 IdRef operand2)
2114 {
2115 const size_t startSize = blob->size();
2116 blob->push_back(0);
2117 blob->push_back(idResultType);
2118 blob->push_back(idResult);
2119 blob->push_back(operand1);
2120 blob->push_back(operand2);
2121 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFUnordGreaterThanEqual);
2122 }
WriteShiftRightLogical(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef shift)2123 void WriteShiftRightLogical(Blob *blob,
2124 IdResultType idResultType,
2125 IdResult idResult,
2126 IdRef base,
2127 IdRef shift)
2128 {
2129 const size_t startSize = blob->size();
2130 blob->push_back(0);
2131 blob->push_back(idResultType);
2132 blob->push_back(idResult);
2133 blob->push_back(base);
2134 blob->push_back(shift);
2135 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpShiftRightLogical);
2136 }
WriteShiftRightArithmetic(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef shift)2137 void WriteShiftRightArithmetic(Blob *blob,
2138 IdResultType idResultType,
2139 IdResult idResult,
2140 IdRef base,
2141 IdRef shift)
2142 {
2143 const size_t startSize = blob->size();
2144 blob->push_back(0);
2145 blob->push_back(idResultType);
2146 blob->push_back(idResult);
2147 blob->push_back(base);
2148 blob->push_back(shift);
2149 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpShiftRightArithmetic);
2150 }
WriteShiftLeftLogical(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef shift)2151 void WriteShiftLeftLogical(Blob *blob,
2152 IdResultType idResultType,
2153 IdResult idResult,
2154 IdRef base,
2155 IdRef shift)
2156 {
2157 const size_t startSize = blob->size();
2158 blob->push_back(0);
2159 blob->push_back(idResultType);
2160 blob->push_back(idResult);
2161 blob->push_back(base);
2162 blob->push_back(shift);
2163 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpShiftLeftLogical);
2164 }
WriteBitwiseOr(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2165 void WriteBitwiseOr(Blob *blob,
2166 IdResultType idResultType,
2167 IdResult idResult,
2168 IdRef operand1,
2169 IdRef operand2)
2170 {
2171 const size_t startSize = blob->size();
2172 blob->push_back(0);
2173 blob->push_back(idResultType);
2174 blob->push_back(idResult);
2175 blob->push_back(operand1);
2176 blob->push_back(operand2);
2177 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitwiseOr);
2178 }
WriteBitwiseXor(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2179 void WriteBitwiseXor(Blob *blob,
2180 IdResultType idResultType,
2181 IdResult idResult,
2182 IdRef operand1,
2183 IdRef operand2)
2184 {
2185 const size_t startSize = blob->size();
2186 blob->push_back(0);
2187 blob->push_back(idResultType);
2188 blob->push_back(idResult);
2189 blob->push_back(operand1);
2190 blob->push_back(operand2);
2191 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitwiseXor);
2192 }
WriteBitwiseAnd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand1,IdRef operand2)2193 void WriteBitwiseAnd(Blob *blob,
2194 IdResultType idResultType,
2195 IdResult idResult,
2196 IdRef operand1,
2197 IdRef operand2)
2198 {
2199 const size_t startSize = blob->size();
2200 blob->push_back(0);
2201 blob->push_back(idResultType);
2202 blob->push_back(idResult);
2203 blob->push_back(operand1);
2204 blob->push_back(operand2);
2205 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitwiseAnd);
2206 }
WriteNot(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef operand)2207 void WriteNot(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef operand)
2208 {
2209 const size_t startSize = blob->size();
2210 blob->push_back(0);
2211 blob->push_back(idResultType);
2212 blob->push_back(idResult);
2213 blob->push_back(operand);
2214 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpNot);
2215 }
WriteBitFieldInsert(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef insert,IdRef offset,IdRef count)2216 void WriteBitFieldInsert(Blob *blob,
2217 IdResultType idResultType,
2218 IdResult idResult,
2219 IdRef base,
2220 IdRef insert,
2221 IdRef offset,
2222 IdRef count)
2223 {
2224 const size_t startSize = blob->size();
2225 blob->push_back(0);
2226 blob->push_back(idResultType);
2227 blob->push_back(idResult);
2228 blob->push_back(base);
2229 blob->push_back(insert);
2230 blob->push_back(offset);
2231 blob->push_back(count);
2232 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitFieldInsert);
2233 }
WriteBitFieldSExtract(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef offset,IdRef count)2234 void WriteBitFieldSExtract(Blob *blob,
2235 IdResultType idResultType,
2236 IdResult idResult,
2237 IdRef base,
2238 IdRef offset,
2239 IdRef count)
2240 {
2241 const size_t startSize = blob->size();
2242 blob->push_back(0);
2243 blob->push_back(idResultType);
2244 blob->push_back(idResult);
2245 blob->push_back(base);
2246 blob->push_back(offset);
2247 blob->push_back(count);
2248 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitFieldSExtract);
2249 }
WriteBitFieldUExtract(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base,IdRef offset,IdRef count)2250 void WriteBitFieldUExtract(Blob *blob,
2251 IdResultType idResultType,
2252 IdResult idResult,
2253 IdRef base,
2254 IdRef offset,
2255 IdRef count)
2256 {
2257 const size_t startSize = blob->size();
2258 blob->push_back(0);
2259 blob->push_back(idResultType);
2260 blob->push_back(idResult);
2261 blob->push_back(base);
2262 blob->push_back(offset);
2263 blob->push_back(count);
2264 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitFieldUExtract);
2265 }
WriteBitReverse(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base)2266 void WriteBitReverse(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef base)
2267 {
2268 const size_t startSize = blob->size();
2269 blob->push_back(0);
2270 blob->push_back(idResultType);
2271 blob->push_back(idResult);
2272 blob->push_back(base);
2273 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitReverse);
2274 }
WriteBitCount(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef base)2275 void WriteBitCount(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef base)
2276 {
2277 const size_t startSize = blob->size();
2278 blob->push_back(0);
2279 blob->push_back(idResultType);
2280 blob->push_back(idResult);
2281 blob->push_back(base);
2282 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBitCount);
2283 }
WriteDPdx(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2284 void WriteDPdx(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2285 {
2286 const size_t startSize = blob->size();
2287 blob->push_back(0);
2288 blob->push_back(idResultType);
2289 blob->push_back(idResult);
2290 blob->push_back(p);
2291 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdx);
2292 }
WriteDPdy(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2293 void WriteDPdy(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2294 {
2295 const size_t startSize = blob->size();
2296 blob->push_back(0);
2297 blob->push_back(idResultType);
2298 blob->push_back(idResult);
2299 blob->push_back(p);
2300 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdy);
2301 }
WriteFwidth(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2302 void WriteFwidth(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2303 {
2304 const size_t startSize = blob->size();
2305 blob->push_back(0);
2306 blob->push_back(idResultType);
2307 blob->push_back(idResult);
2308 blob->push_back(p);
2309 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFwidth);
2310 }
WriteDPdxFine(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2311 void WriteDPdxFine(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2312 {
2313 const size_t startSize = blob->size();
2314 blob->push_back(0);
2315 blob->push_back(idResultType);
2316 blob->push_back(idResult);
2317 blob->push_back(p);
2318 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdxFine);
2319 }
WriteDPdyFine(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2320 void WriteDPdyFine(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2321 {
2322 const size_t startSize = blob->size();
2323 blob->push_back(0);
2324 blob->push_back(idResultType);
2325 blob->push_back(idResult);
2326 blob->push_back(p);
2327 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdyFine);
2328 }
WriteFwidthFine(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2329 void WriteFwidthFine(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2330 {
2331 const size_t startSize = blob->size();
2332 blob->push_back(0);
2333 blob->push_back(idResultType);
2334 blob->push_back(idResult);
2335 blob->push_back(p);
2336 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFwidthFine);
2337 }
WriteDPdxCoarse(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2338 void WriteDPdxCoarse(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2339 {
2340 const size_t startSize = blob->size();
2341 blob->push_back(0);
2342 blob->push_back(idResultType);
2343 blob->push_back(idResult);
2344 blob->push_back(p);
2345 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdxCoarse);
2346 }
WriteDPdyCoarse(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2347 void WriteDPdyCoarse(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2348 {
2349 const size_t startSize = blob->size();
2350 blob->push_back(0);
2351 blob->push_back(idResultType);
2352 blob->push_back(idResult);
2353 blob->push_back(p);
2354 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpDPdyCoarse);
2355 }
WriteFwidthCoarse(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef p)2356 void WriteFwidthCoarse(Blob *blob, IdResultType idResultType, IdResult idResult, IdRef p)
2357 {
2358 const size_t startSize = blob->size();
2359 blob->push_back(0);
2360 blob->push_back(idResultType);
2361 blob->push_back(idResult);
2362 blob->push_back(p);
2363 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpFwidthCoarse);
2364 }
WriteEmitVertex(Blob * blob)2365 void WriteEmitVertex(Blob *blob)
2366 {
2367 const size_t startSize = blob->size();
2368 blob->push_back(0);
2369
2370 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEmitVertex);
2371 }
WriteEndPrimitive(Blob * blob)2372 void WriteEndPrimitive(Blob *blob)
2373 {
2374 const size_t startSize = blob->size();
2375 blob->push_back(0);
2376
2377 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEndPrimitive);
2378 }
WriteEmitStreamVertex(Blob * blob,IdRef stream)2379 void WriteEmitStreamVertex(Blob *blob, IdRef stream)
2380 {
2381 const size_t startSize = blob->size();
2382 blob->push_back(0);
2383 blob->push_back(stream);
2384 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEmitStreamVertex);
2385 }
WriteEndStreamPrimitive(Blob * blob,IdRef stream)2386 void WriteEndStreamPrimitive(Blob *blob, IdRef stream)
2387 {
2388 const size_t startSize = blob->size();
2389 blob->push_back(0);
2390 blob->push_back(stream);
2391 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEndStreamPrimitive);
2392 }
WriteControlBarrier(Blob * blob,IdScope execution,IdScope memory,IdMemorySemantics semantics)2393 void WriteControlBarrier(Blob *blob, IdScope execution, IdScope memory, IdMemorySemantics semantics)
2394 {
2395 const size_t startSize = blob->size();
2396 blob->push_back(0);
2397 blob->push_back(execution);
2398 blob->push_back(memory);
2399 blob->push_back(semantics);
2400 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpControlBarrier);
2401 }
WriteMemoryBarrier(Blob * blob,IdScope memory,IdMemorySemantics semantics)2402 void WriteMemoryBarrier(Blob *blob, IdScope memory, IdMemorySemantics semantics)
2403 {
2404 const size_t startSize = blob->size();
2405 blob->push_back(0);
2406 blob->push_back(memory);
2407 blob->push_back(semantics);
2408 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpMemoryBarrier);
2409 }
WriteAtomicLoad(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics)2410 void WriteAtomicLoad(Blob *blob,
2411 IdResultType idResultType,
2412 IdResult idResult,
2413 IdRef pointer,
2414 IdScope scope,
2415 IdMemorySemantics semantics)
2416 {
2417 const size_t startSize = blob->size();
2418 blob->push_back(0);
2419 blob->push_back(idResultType);
2420 blob->push_back(idResult);
2421 blob->push_back(pointer);
2422 blob->push_back(scope);
2423 blob->push_back(semantics);
2424 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicLoad);
2425 }
WriteAtomicStore(Blob * blob,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2426 void WriteAtomicStore(Blob *blob,
2427 IdRef pointer,
2428 IdScope scope,
2429 IdMemorySemantics semantics,
2430 IdRef value)
2431 {
2432 const size_t startSize = blob->size();
2433 blob->push_back(0);
2434 blob->push_back(pointer);
2435 blob->push_back(scope);
2436 blob->push_back(semantics);
2437 blob->push_back(value);
2438 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicStore);
2439 }
WriteAtomicExchange(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2440 void WriteAtomicExchange(Blob *blob,
2441 IdResultType idResultType,
2442 IdResult idResult,
2443 IdRef pointer,
2444 IdScope scope,
2445 IdMemorySemantics semantics,
2446 IdRef value)
2447 {
2448 const size_t startSize = blob->size();
2449 blob->push_back(0);
2450 blob->push_back(idResultType);
2451 blob->push_back(idResult);
2452 blob->push_back(pointer);
2453 blob->push_back(scope);
2454 blob->push_back(semantics);
2455 blob->push_back(value);
2456 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicExchange);
2457 }
WriteAtomicCompareExchange(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics equal,IdMemorySemantics unequal,IdRef value,IdRef comparator)2458 void WriteAtomicCompareExchange(Blob *blob,
2459 IdResultType idResultType,
2460 IdResult idResult,
2461 IdRef pointer,
2462 IdScope scope,
2463 IdMemorySemantics equal,
2464 IdMemorySemantics unequal,
2465 IdRef value,
2466 IdRef comparator)
2467 {
2468 const size_t startSize = blob->size();
2469 blob->push_back(0);
2470 blob->push_back(idResultType);
2471 blob->push_back(idResult);
2472 blob->push_back(pointer);
2473 blob->push_back(scope);
2474 blob->push_back(equal);
2475 blob->push_back(unequal);
2476 blob->push_back(value);
2477 blob->push_back(comparator);
2478 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicCompareExchange);
2479 }
WriteAtomicIIncrement(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics)2480 void WriteAtomicIIncrement(Blob *blob,
2481 IdResultType idResultType,
2482 IdResult idResult,
2483 IdRef pointer,
2484 IdScope scope,
2485 IdMemorySemantics semantics)
2486 {
2487 const size_t startSize = blob->size();
2488 blob->push_back(0);
2489 blob->push_back(idResultType);
2490 blob->push_back(idResult);
2491 blob->push_back(pointer);
2492 blob->push_back(scope);
2493 blob->push_back(semantics);
2494 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicIIncrement);
2495 }
WriteAtomicIDecrement(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics)2496 void WriteAtomicIDecrement(Blob *blob,
2497 IdResultType idResultType,
2498 IdResult idResult,
2499 IdRef pointer,
2500 IdScope scope,
2501 IdMemorySemantics semantics)
2502 {
2503 const size_t startSize = blob->size();
2504 blob->push_back(0);
2505 blob->push_back(idResultType);
2506 blob->push_back(idResult);
2507 blob->push_back(pointer);
2508 blob->push_back(scope);
2509 blob->push_back(semantics);
2510 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicIDecrement);
2511 }
WriteAtomicIAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2512 void WriteAtomicIAdd(Blob *blob,
2513 IdResultType idResultType,
2514 IdResult idResult,
2515 IdRef pointer,
2516 IdScope scope,
2517 IdMemorySemantics semantics,
2518 IdRef value)
2519 {
2520 const size_t startSize = blob->size();
2521 blob->push_back(0);
2522 blob->push_back(idResultType);
2523 blob->push_back(idResult);
2524 blob->push_back(pointer);
2525 blob->push_back(scope);
2526 blob->push_back(semantics);
2527 blob->push_back(value);
2528 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicIAdd);
2529 }
WriteAtomicISub(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2530 void WriteAtomicISub(Blob *blob,
2531 IdResultType idResultType,
2532 IdResult idResult,
2533 IdRef pointer,
2534 IdScope scope,
2535 IdMemorySemantics semantics,
2536 IdRef value)
2537 {
2538 const size_t startSize = blob->size();
2539 blob->push_back(0);
2540 blob->push_back(idResultType);
2541 blob->push_back(idResult);
2542 blob->push_back(pointer);
2543 blob->push_back(scope);
2544 blob->push_back(semantics);
2545 blob->push_back(value);
2546 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicISub);
2547 }
WriteAtomicSMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2548 void WriteAtomicSMin(Blob *blob,
2549 IdResultType idResultType,
2550 IdResult idResult,
2551 IdRef pointer,
2552 IdScope scope,
2553 IdMemorySemantics semantics,
2554 IdRef value)
2555 {
2556 const size_t startSize = blob->size();
2557 blob->push_back(0);
2558 blob->push_back(idResultType);
2559 blob->push_back(idResult);
2560 blob->push_back(pointer);
2561 blob->push_back(scope);
2562 blob->push_back(semantics);
2563 blob->push_back(value);
2564 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicSMin);
2565 }
WriteAtomicUMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2566 void WriteAtomicUMin(Blob *blob,
2567 IdResultType idResultType,
2568 IdResult idResult,
2569 IdRef pointer,
2570 IdScope scope,
2571 IdMemorySemantics semantics,
2572 IdRef value)
2573 {
2574 const size_t startSize = blob->size();
2575 blob->push_back(0);
2576 blob->push_back(idResultType);
2577 blob->push_back(idResult);
2578 blob->push_back(pointer);
2579 blob->push_back(scope);
2580 blob->push_back(semantics);
2581 blob->push_back(value);
2582 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicUMin);
2583 }
WriteAtomicSMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2584 void WriteAtomicSMax(Blob *blob,
2585 IdResultType idResultType,
2586 IdResult idResult,
2587 IdRef pointer,
2588 IdScope scope,
2589 IdMemorySemantics semantics,
2590 IdRef value)
2591 {
2592 const size_t startSize = blob->size();
2593 blob->push_back(0);
2594 blob->push_back(idResultType);
2595 blob->push_back(idResult);
2596 blob->push_back(pointer);
2597 blob->push_back(scope);
2598 blob->push_back(semantics);
2599 blob->push_back(value);
2600 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicSMax);
2601 }
WriteAtomicUMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2602 void WriteAtomicUMax(Blob *blob,
2603 IdResultType idResultType,
2604 IdResult idResult,
2605 IdRef pointer,
2606 IdScope scope,
2607 IdMemorySemantics semantics,
2608 IdRef value)
2609 {
2610 const size_t startSize = blob->size();
2611 blob->push_back(0);
2612 blob->push_back(idResultType);
2613 blob->push_back(idResult);
2614 blob->push_back(pointer);
2615 blob->push_back(scope);
2616 blob->push_back(semantics);
2617 blob->push_back(value);
2618 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicUMax);
2619 }
WriteAtomicAnd(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2620 void WriteAtomicAnd(Blob *blob,
2621 IdResultType idResultType,
2622 IdResult idResult,
2623 IdRef pointer,
2624 IdScope scope,
2625 IdMemorySemantics semantics,
2626 IdRef value)
2627 {
2628 const size_t startSize = blob->size();
2629 blob->push_back(0);
2630 blob->push_back(idResultType);
2631 blob->push_back(idResult);
2632 blob->push_back(pointer);
2633 blob->push_back(scope);
2634 blob->push_back(semantics);
2635 blob->push_back(value);
2636 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicAnd);
2637 }
WriteAtomicOr(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2638 void WriteAtomicOr(Blob *blob,
2639 IdResultType idResultType,
2640 IdResult idResult,
2641 IdRef pointer,
2642 IdScope scope,
2643 IdMemorySemantics semantics,
2644 IdRef value)
2645 {
2646 const size_t startSize = blob->size();
2647 blob->push_back(0);
2648 blob->push_back(idResultType);
2649 blob->push_back(idResult);
2650 blob->push_back(pointer);
2651 blob->push_back(scope);
2652 blob->push_back(semantics);
2653 blob->push_back(value);
2654 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicOr);
2655 }
WriteAtomicXor(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef pointer,IdScope scope,IdMemorySemantics semantics,IdRef value)2656 void WriteAtomicXor(Blob *blob,
2657 IdResultType idResultType,
2658 IdResult idResult,
2659 IdRef pointer,
2660 IdScope scope,
2661 IdMemorySemantics semantics,
2662 IdRef value)
2663 {
2664 const size_t startSize = blob->size();
2665 blob->push_back(0);
2666 blob->push_back(idResultType);
2667 blob->push_back(idResult);
2668 blob->push_back(pointer);
2669 blob->push_back(scope);
2670 blob->push_back(semantics);
2671 blob->push_back(value);
2672 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpAtomicXor);
2673 }
WritePhi(Blob * blob,IdResultType idResultType,IdResult idResult,const PairIdRefIdRefList & variableParentPairList)2674 void WritePhi(Blob *blob,
2675 IdResultType idResultType,
2676 IdResult idResult,
2677 const PairIdRefIdRefList &variableParentPairList)
2678 {
2679 const size_t startSize = blob->size();
2680 blob->push_back(0);
2681 blob->push_back(idResultType);
2682 blob->push_back(idResult);
2683 for (const auto &operand : variableParentPairList)
2684 {
2685 blob->push_back(operand.id1);
2686 blob->push_back(operand.id2);
2687 }
2688 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpPhi);
2689 }
WriteLoopMerge(Blob * blob,IdRef mergeBlock,IdRef continueTarget,spv::LoopControlMask loopControl)2690 void WriteLoopMerge(Blob *blob,
2691 IdRef mergeBlock,
2692 IdRef continueTarget,
2693 spv::LoopControlMask loopControl)
2694 {
2695 const size_t startSize = blob->size();
2696 blob->push_back(0);
2697 blob->push_back(mergeBlock);
2698 blob->push_back(continueTarget);
2699 blob->push_back(loopControl);
2700 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLoopMerge);
2701 }
WriteSelectionMerge(Blob * blob,IdRef mergeBlock,spv::SelectionControlMask selectionControl)2702 void WriteSelectionMerge(Blob *blob, IdRef mergeBlock, spv::SelectionControlMask selectionControl)
2703 {
2704 const size_t startSize = blob->size();
2705 blob->push_back(0);
2706 blob->push_back(mergeBlock);
2707 blob->push_back(selectionControl);
2708 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSelectionMerge);
2709 }
WriteLabel(Blob * blob,IdResult idResult)2710 void WriteLabel(Blob *blob, IdResult idResult)
2711 {
2712 const size_t startSize = blob->size();
2713 blob->push_back(0);
2714 blob->push_back(idResult);
2715 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpLabel);
2716 }
WriteBranch(Blob * blob,IdRef targetLabel)2717 void WriteBranch(Blob *blob, IdRef targetLabel)
2718 {
2719 const size_t startSize = blob->size();
2720 blob->push_back(0);
2721 blob->push_back(targetLabel);
2722 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBranch);
2723 }
WriteBranchConditional(Blob * blob,IdRef condition,IdRef trueLabel,IdRef falseLabel,const LiteralIntegerList & branchweightsList)2724 void WriteBranchConditional(Blob *blob,
2725 IdRef condition,
2726 IdRef trueLabel,
2727 IdRef falseLabel,
2728 const LiteralIntegerList &branchweightsList)
2729 {
2730 const size_t startSize = blob->size();
2731 blob->push_back(0);
2732 blob->push_back(condition);
2733 blob->push_back(trueLabel);
2734 blob->push_back(falseLabel);
2735 for (const auto &operand : branchweightsList)
2736 {
2737 blob->push_back(operand);
2738 }
2739 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBranchConditional);
2740 }
WriteSwitch(Blob * blob,IdRef selector,IdRef default_,const PairLiteralIntegerIdRefList & targetPairList)2741 void WriteSwitch(Blob *blob,
2742 IdRef selector,
2743 IdRef default_,
2744 const PairLiteralIntegerIdRefList &targetPairList)
2745 {
2746 const size_t startSize = blob->size();
2747 blob->push_back(0);
2748 blob->push_back(selector);
2749 blob->push_back(default_);
2750 for (const auto &operand : targetPairList)
2751 {
2752 blob->push_back(operand.literal);
2753 blob->push_back(operand.id);
2754 }
2755 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpSwitch);
2756 }
WriteKill(Blob * blob)2757 void WriteKill(Blob *blob)
2758 {
2759 const size_t startSize = blob->size();
2760 blob->push_back(0);
2761
2762 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpKill);
2763 }
WriteReturn(Blob * blob)2764 void WriteReturn(Blob *blob)
2765 {
2766 const size_t startSize = blob->size();
2767 blob->push_back(0);
2768
2769 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpReturn);
2770 }
WriteReturnValue(Blob * blob,IdRef value)2771 void WriteReturnValue(Blob *blob, IdRef value)
2772 {
2773 const size_t startSize = blob->size();
2774 blob->push_back(0);
2775 blob->push_back(value);
2776 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpReturnValue);
2777 }
WriteUnreachable(Blob * blob)2778 void WriteUnreachable(Blob *blob)
2779 {
2780 const size_t startSize = blob->size();
2781 blob->push_back(0);
2782
2783 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpUnreachable);
2784 }
WriteGroupAll(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,IdRef predicate)2785 void WriteGroupAll(Blob *blob,
2786 IdResultType idResultType,
2787 IdResult idResult,
2788 IdScope execution,
2789 IdRef predicate)
2790 {
2791 const size_t startSize = blob->size();
2792 blob->push_back(0);
2793 blob->push_back(idResultType);
2794 blob->push_back(idResult);
2795 blob->push_back(execution);
2796 blob->push_back(predicate);
2797 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupAll);
2798 }
WriteGroupAny(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,IdRef predicate)2799 void WriteGroupAny(Blob *blob,
2800 IdResultType idResultType,
2801 IdResult idResult,
2802 IdScope execution,
2803 IdRef predicate)
2804 {
2805 const size_t startSize = blob->size();
2806 blob->push_back(0);
2807 blob->push_back(idResultType);
2808 blob->push_back(idResult);
2809 blob->push_back(execution);
2810 blob->push_back(predicate);
2811 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupAny);
2812 }
WriteGroupBroadcast(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,IdRef value,IdRef localId)2813 void WriteGroupBroadcast(Blob *blob,
2814 IdResultType idResultType,
2815 IdResult idResult,
2816 IdScope execution,
2817 IdRef value,
2818 IdRef localId)
2819 {
2820 const size_t startSize = blob->size();
2821 blob->push_back(0);
2822 blob->push_back(idResultType);
2823 blob->push_back(idResult);
2824 blob->push_back(execution);
2825 blob->push_back(value);
2826 blob->push_back(localId);
2827 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupBroadcast);
2828 }
WriteGroupIAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2829 void WriteGroupIAdd(Blob *blob,
2830 IdResultType idResultType,
2831 IdResult idResult,
2832 IdScope execution,
2833 spv::GroupOperation operation,
2834 IdRef x)
2835 {
2836 const size_t startSize = blob->size();
2837 blob->push_back(0);
2838 blob->push_back(idResultType);
2839 blob->push_back(idResult);
2840 blob->push_back(execution);
2841 blob->push_back(operation);
2842 blob->push_back(x);
2843 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupIAdd);
2844 }
WriteGroupFAdd(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2845 void WriteGroupFAdd(Blob *blob,
2846 IdResultType idResultType,
2847 IdResult idResult,
2848 IdScope execution,
2849 spv::GroupOperation operation,
2850 IdRef x)
2851 {
2852 const size_t startSize = blob->size();
2853 blob->push_back(0);
2854 blob->push_back(idResultType);
2855 blob->push_back(idResult);
2856 blob->push_back(execution);
2857 blob->push_back(operation);
2858 blob->push_back(x);
2859 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFAdd);
2860 }
WriteGroupFMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2861 void WriteGroupFMin(Blob *blob,
2862 IdResultType idResultType,
2863 IdResult idResult,
2864 IdScope execution,
2865 spv::GroupOperation operation,
2866 IdRef x)
2867 {
2868 const size_t startSize = blob->size();
2869 blob->push_back(0);
2870 blob->push_back(idResultType);
2871 blob->push_back(idResult);
2872 blob->push_back(execution);
2873 blob->push_back(operation);
2874 blob->push_back(x);
2875 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFMin);
2876 }
WriteGroupUMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2877 void WriteGroupUMin(Blob *blob,
2878 IdResultType idResultType,
2879 IdResult idResult,
2880 IdScope execution,
2881 spv::GroupOperation operation,
2882 IdRef x)
2883 {
2884 const size_t startSize = blob->size();
2885 blob->push_back(0);
2886 blob->push_back(idResultType);
2887 blob->push_back(idResult);
2888 blob->push_back(execution);
2889 blob->push_back(operation);
2890 blob->push_back(x);
2891 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupUMin);
2892 }
WriteGroupSMin(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2893 void WriteGroupSMin(Blob *blob,
2894 IdResultType idResultType,
2895 IdResult idResult,
2896 IdScope execution,
2897 spv::GroupOperation operation,
2898 IdRef x)
2899 {
2900 const size_t startSize = blob->size();
2901 blob->push_back(0);
2902 blob->push_back(idResultType);
2903 blob->push_back(idResult);
2904 blob->push_back(execution);
2905 blob->push_back(operation);
2906 blob->push_back(x);
2907 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupSMin);
2908 }
WriteGroupFMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2909 void WriteGroupFMax(Blob *blob,
2910 IdResultType idResultType,
2911 IdResult idResult,
2912 IdScope execution,
2913 spv::GroupOperation operation,
2914 IdRef x)
2915 {
2916 const size_t startSize = blob->size();
2917 blob->push_back(0);
2918 blob->push_back(idResultType);
2919 blob->push_back(idResult);
2920 blob->push_back(execution);
2921 blob->push_back(operation);
2922 blob->push_back(x);
2923 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFMax);
2924 }
WriteGroupUMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2925 void WriteGroupUMax(Blob *blob,
2926 IdResultType idResultType,
2927 IdResult idResult,
2928 IdScope execution,
2929 spv::GroupOperation operation,
2930 IdRef x)
2931 {
2932 const size_t startSize = blob->size();
2933 blob->push_back(0);
2934 blob->push_back(idResultType);
2935 blob->push_back(idResult);
2936 blob->push_back(execution);
2937 blob->push_back(operation);
2938 blob->push_back(x);
2939 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupUMax);
2940 }
WriteGroupSMax(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)2941 void WriteGroupSMax(Blob *blob,
2942 IdResultType idResultType,
2943 IdResult idResult,
2944 IdScope execution,
2945 spv::GroupOperation operation,
2946 IdRef x)
2947 {
2948 const size_t startSize = blob->size();
2949 blob->push_back(0);
2950 blob->push_back(idResultType);
2951 blob->push_back(idResult);
2952 blob->push_back(execution);
2953 blob->push_back(operation);
2954 blob->push_back(x);
2955 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupSMax);
2956 }
WriteImageSparseSampleImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)2957 void WriteImageSparseSampleImplicitLod(Blob *blob,
2958 IdResultType idResultType,
2959 IdResult idResult,
2960 IdRef sampledImage,
2961 IdRef coordinate,
2962 const spv::ImageOperandsMask *imageOperands,
2963 const IdRefList &imageOperandIdsList)
2964 {
2965 const size_t startSize = blob->size();
2966 blob->push_back(0);
2967 blob->push_back(idResultType);
2968 blob->push_back(idResult);
2969 blob->push_back(sampledImage);
2970 blob->push_back(coordinate);
2971 if (imageOperands)
2972 {
2973 blob->push_back(*imageOperands);
2974 }
2975 for (const auto &operand : imageOperandIdsList)
2976 {
2977 blob->push_back(operand);
2978 }
2979 (*blob)[startSize] =
2980 MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleImplicitLod);
2981 }
WriteImageSparseSampleExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)2982 void WriteImageSparseSampleExplicitLod(Blob *blob,
2983 IdResultType idResultType,
2984 IdResult idResult,
2985 IdRef sampledImage,
2986 IdRef coordinate,
2987 spv::ImageOperandsMask imageOperands,
2988 const IdRefList &imageOperandIdsList)
2989 {
2990 const size_t startSize = blob->size();
2991 blob->push_back(0);
2992 blob->push_back(idResultType);
2993 blob->push_back(idResult);
2994 blob->push_back(sampledImage);
2995 blob->push_back(coordinate);
2996 blob->push_back(imageOperands);
2997 for (const auto &operand : imageOperandIdsList)
2998 {
2999 blob->push_back(operand);
3000 }
3001 (*blob)[startSize] =
3002 MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleExplicitLod);
3003 }
WriteImageSparseSampleDrefImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3004 void WriteImageSparseSampleDrefImplicitLod(Blob *blob,
3005 IdResultType idResultType,
3006 IdResult idResult,
3007 IdRef sampledImage,
3008 IdRef coordinate,
3009 IdRef dref,
3010 const spv::ImageOperandsMask *imageOperands,
3011 const IdRefList &imageOperandIdsList)
3012 {
3013 const size_t startSize = blob->size();
3014 blob->push_back(0);
3015 blob->push_back(idResultType);
3016 blob->push_back(idResult);
3017 blob->push_back(sampledImage);
3018 blob->push_back(coordinate);
3019 blob->push_back(dref);
3020 if (imageOperands)
3021 {
3022 blob->push_back(*imageOperands);
3023 }
3024 for (const auto &operand : imageOperandIdsList)
3025 {
3026 blob->push_back(operand);
3027 }
3028 (*blob)[startSize] =
3029 MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleDrefImplicitLod);
3030 }
WriteImageSparseSampleDrefExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)3031 void WriteImageSparseSampleDrefExplicitLod(Blob *blob,
3032 IdResultType idResultType,
3033 IdResult idResult,
3034 IdRef sampledImage,
3035 IdRef coordinate,
3036 IdRef dref,
3037 spv::ImageOperandsMask imageOperands,
3038 const IdRefList &imageOperandIdsList)
3039 {
3040 const size_t startSize = blob->size();
3041 blob->push_back(0);
3042 blob->push_back(idResultType);
3043 blob->push_back(idResult);
3044 blob->push_back(sampledImage);
3045 blob->push_back(coordinate);
3046 blob->push_back(dref);
3047 blob->push_back(imageOperands);
3048 for (const auto &operand : imageOperandIdsList)
3049 {
3050 blob->push_back(operand);
3051 }
3052 (*blob)[startSize] =
3053 MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleDrefExplicitLod);
3054 }
WriteImageSparseSampleProjImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3055 void WriteImageSparseSampleProjImplicitLod(Blob *blob,
3056 IdResultType idResultType,
3057 IdResult idResult,
3058 IdRef sampledImage,
3059 IdRef coordinate,
3060 const spv::ImageOperandsMask *imageOperands,
3061 const IdRefList &imageOperandIdsList)
3062 {
3063 const size_t startSize = blob->size();
3064 blob->push_back(0);
3065 blob->push_back(idResultType);
3066 blob->push_back(idResult);
3067 blob->push_back(sampledImage);
3068 blob->push_back(coordinate);
3069 if (imageOperands)
3070 {
3071 blob->push_back(*imageOperands);
3072 }
3073 for (const auto &operand : imageOperandIdsList)
3074 {
3075 blob->push_back(operand);
3076 }
3077 (*blob)[startSize] =
3078 MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleProjImplicitLod);
3079 }
WriteImageSparseSampleProjExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)3080 void WriteImageSparseSampleProjExplicitLod(Blob *blob,
3081 IdResultType idResultType,
3082 IdResult idResult,
3083 IdRef sampledImage,
3084 IdRef coordinate,
3085 spv::ImageOperandsMask imageOperands,
3086 const IdRefList &imageOperandIdsList)
3087 {
3088 const size_t startSize = blob->size();
3089 blob->push_back(0);
3090 blob->push_back(idResultType);
3091 blob->push_back(idResult);
3092 blob->push_back(sampledImage);
3093 blob->push_back(coordinate);
3094 blob->push_back(imageOperands);
3095 for (const auto &operand : imageOperandIdsList)
3096 {
3097 blob->push_back(operand);
3098 }
3099 (*blob)[startSize] =
3100 MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleProjExplicitLod);
3101 }
WriteImageSparseSampleProjDrefImplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3102 void WriteImageSparseSampleProjDrefImplicitLod(Blob *blob,
3103 IdResultType idResultType,
3104 IdResult idResult,
3105 IdRef sampledImage,
3106 IdRef coordinate,
3107 IdRef dref,
3108 const spv::ImageOperandsMask *imageOperands,
3109 const IdRefList &imageOperandIdsList)
3110 {
3111 const size_t startSize = blob->size();
3112 blob->push_back(0);
3113 blob->push_back(idResultType);
3114 blob->push_back(idResult);
3115 blob->push_back(sampledImage);
3116 blob->push_back(coordinate);
3117 blob->push_back(dref);
3118 if (imageOperands)
3119 {
3120 blob->push_back(*imageOperands);
3121 }
3122 for (const auto &operand : imageOperandIdsList)
3123 {
3124 blob->push_back(operand);
3125 }
3126 (*blob)[startSize] =
3127 MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleProjDrefImplicitLod);
3128 }
WriteImageSparseSampleProjDrefExplicitLod(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,spv::ImageOperandsMask imageOperands,const IdRefList & imageOperandIdsList)3129 void WriteImageSparseSampleProjDrefExplicitLod(Blob *blob,
3130 IdResultType idResultType,
3131 IdResult idResult,
3132 IdRef sampledImage,
3133 IdRef coordinate,
3134 IdRef dref,
3135 spv::ImageOperandsMask imageOperands,
3136 const IdRefList &imageOperandIdsList)
3137 {
3138 const size_t startSize = blob->size();
3139 blob->push_back(0);
3140 blob->push_back(idResultType);
3141 blob->push_back(idResult);
3142 blob->push_back(sampledImage);
3143 blob->push_back(coordinate);
3144 blob->push_back(dref);
3145 blob->push_back(imageOperands);
3146 for (const auto &operand : imageOperandIdsList)
3147 {
3148 blob->push_back(operand);
3149 }
3150 (*blob)[startSize] =
3151 MakeLengthOp(blob->size() - startSize, spv::OpImageSparseSampleProjDrefExplicitLod);
3152 }
WriteImageSparseFetch(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3153 void WriteImageSparseFetch(Blob *blob,
3154 IdResultType idResultType,
3155 IdResult idResult,
3156 IdRef image,
3157 IdRef coordinate,
3158 const spv::ImageOperandsMask *imageOperands,
3159 const IdRefList &imageOperandIdsList)
3160 {
3161 const size_t startSize = blob->size();
3162 blob->push_back(0);
3163 blob->push_back(idResultType);
3164 blob->push_back(idResult);
3165 blob->push_back(image);
3166 blob->push_back(coordinate);
3167 if (imageOperands)
3168 {
3169 blob->push_back(*imageOperands);
3170 }
3171 for (const auto &operand : imageOperandIdsList)
3172 {
3173 blob->push_back(operand);
3174 }
3175 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseFetch);
3176 }
WriteImageSparseGather(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef component,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3177 void WriteImageSparseGather(Blob *blob,
3178 IdResultType idResultType,
3179 IdResult idResult,
3180 IdRef sampledImage,
3181 IdRef coordinate,
3182 IdRef component,
3183 const spv::ImageOperandsMask *imageOperands,
3184 const IdRefList &imageOperandIdsList)
3185 {
3186 const size_t startSize = blob->size();
3187 blob->push_back(0);
3188 blob->push_back(idResultType);
3189 blob->push_back(idResult);
3190 blob->push_back(sampledImage);
3191 blob->push_back(coordinate);
3192 blob->push_back(component);
3193 if (imageOperands)
3194 {
3195 blob->push_back(*imageOperands);
3196 }
3197 for (const auto &operand : imageOperandIdsList)
3198 {
3199 blob->push_back(operand);
3200 }
3201 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseGather);
3202 }
WriteImageSparseDrefGather(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef sampledImage,IdRef coordinate,IdRef dref,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3203 void WriteImageSparseDrefGather(Blob *blob,
3204 IdResultType idResultType,
3205 IdResult idResult,
3206 IdRef sampledImage,
3207 IdRef coordinate,
3208 IdRef dref,
3209 const spv::ImageOperandsMask *imageOperands,
3210 const IdRefList &imageOperandIdsList)
3211 {
3212 const size_t startSize = blob->size();
3213 blob->push_back(0);
3214 blob->push_back(idResultType);
3215 blob->push_back(idResult);
3216 blob->push_back(sampledImage);
3217 blob->push_back(coordinate);
3218 blob->push_back(dref);
3219 if (imageOperands)
3220 {
3221 blob->push_back(*imageOperands);
3222 }
3223 for (const auto &operand : imageOperandIdsList)
3224 {
3225 blob->push_back(operand);
3226 }
3227 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseDrefGather);
3228 }
WriteImageSparseTexelsResident(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef residentCode)3229 void WriteImageSparseTexelsResident(Blob *blob,
3230 IdResultType idResultType,
3231 IdResult idResult,
3232 IdRef residentCode)
3233 {
3234 const size_t startSize = blob->size();
3235 blob->push_back(0);
3236 blob->push_back(idResultType);
3237 blob->push_back(idResult);
3238 blob->push_back(residentCode);
3239 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseTexelsResident);
3240 }
WriteNoLine(Blob * blob)3241 void WriteNoLine(Blob *blob)
3242 {
3243 const size_t startSize = blob->size();
3244 blob->push_back(0);
3245
3246 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpNoLine);
3247 }
WriteImageSparseRead(Blob * blob,IdResultType idResultType,IdResult idResult,IdRef image,IdRef coordinate,const spv::ImageOperandsMask * imageOperands,const IdRefList & imageOperandIdsList)3248 void WriteImageSparseRead(Blob *blob,
3249 IdResultType idResultType,
3250 IdResult idResult,
3251 IdRef image,
3252 IdRef coordinate,
3253 const spv::ImageOperandsMask *imageOperands,
3254 const IdRefList &imageOperandIdsList)
3255 {
3256 const size_t startSize = blob->size();
3257 blob->push_back(0);
3258 blob->push_back(idResultType);
3259 blob->push_back(idResult);
3260 blob->push_back(image);
3261 blob->push_back(coordinate);
3262 if (imageOperands)
3263 {
3264 blob->push_back(*imageOperands);
3265 }
3266 for (const auto &operand : imageOperandIdsList)
3267 {
3268 blob->push_back(operand);
3269 }
3270 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpImageSparseRead);
3271 }
WriteGroupIAddNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3272 void WriteGroupIAddNonUniformAMD(Blob *blob,
3273 IdResultType idResultType,
3274 IdResult idResult,
3275 IdScope execution,
3276 spv::GroupOperation operation,
3277 IdRef x)
3278 {
3279 const size_t startSize = blob->size();
3280 blob->push_back(0);
3281 blob->push_back(idResultType);
3282 blob->push_back(idResult);
3283 blob->push_back(execution);
3284 blob->push_back(operation);
3285 blob->push_back(x);
3286 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupIAddNonUniformAMD);
3287 }
WriteGroupFAddNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3288 void WriteGroupFAddNonUniformAMD(Blob *blob,
3289 IdResultType idResultType,
3290 IdResult idResult,
3291 IdScope execution,
3292 spv::GroupOperation operation,
3293 IdRef x)
3294 {
3295 const size_t startSize = blob->size();
3296 blob->push_back(0);
3297 blob->push_back(idResultType);
3298 blob->push_back(idResult);
3299 blob->push_back(execution);
3300 blob->push_back(operation);
3301 blob->push_back(x);
3302 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFAddNonUniformAMD);
3303 }
WriteGroupFMinNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3304 void WriteGroupFMinNonUniformAMD(Blob *blob,
3305 IdResultType idResultType,
3306 IdResult idResult,
3307 IdScope execution,
3308 spv::GroupOperation operation,
3309 IdRef x)
3310 {
3311 const size_t startSize = blob->size();
3312 blob->push_back(0);
3313 blob->push_back(idResultType);
3314 blob->push_back(idResult);
3315 blob->push_back(execution);
3316 blob->push_back(operation);
3317 blob->push_back(x);
3318 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFMinNonUniformAMD);
3319 }
WriteGroupUMinNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3320 void WriteGroupUMinNonUniformAMD(Blob *blob,
3321 IdResultType idResultType,
3322 IdResult idResult,
3323 IdScope execution,
3324 spv::GroupOperation operation,
3325 IdRef x)
3326 {
3327 const size_t startSize = blob->size();
3328 blob->push_back(0);
3329 blob->push_back(idResultType);
3330 blob->push_back(idResult);
3331 blob->push_back(execution);
3332 blob->push_back(operation);
3333 blob->push_back(x);
3334 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupUMinNonUniformAMD);
3335 }
WriteGroupSMinNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3336 void WriteGroupSMinNonUniformAMD(Blob *blob,
3337 IdResultType idResultType,
3338 IdResult idResult,
3339 IdScope execution,
3340 spv::GroupOperation operation,
3341 IdRef x)
3342 {
3343 const size_t startSize = blob->size();
3344 blob->push_back(0);
3345 blob->push_back(idResultType);
3346 blob->push_back(idResult);
3347 blob->push_back(execution);
3348 blob->push_back(operation);
3349 blob->push_back(x);
3350 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupSMinNonUniformAMD);
3351 }
WriteGroupFMaxNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3352 void WriteGroupFMaxNonUniformAMD(Blob *blob,
3353 IdResultType idResultType,
3354 IdResult idResult,
3355 IdScope execution,
3356 spv::GroupOperation operation,
3357 IdRef x)
3358 {
3359 const size_t startSize = blob->size();
3360 blob->push_back(0);
3361 blob->push_back(idResultType);
3362 blob->push_back(idResult);
3363 blob->push_back(execution);
3364 blob->push_back(operation);
3365 blob->push_back(x);
3366 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupFMaxNonUniformAMD);
3367 }
WriteGroupUMaxNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3368 void WriteGroupUMaxNonUniformAMD(Blob *blob,
3369 IdResultType idResultType,
3370 IdResult idResult,
3371 IdScope execution,
3372 spv::GroupOperation operation,
3373 IdRef x)
3374 {
3375 const size_t startSize = blob->size();
3376 blob->push_back(0);
3377 blob->push_back(idResultType);
3378 blob->push_back(idResult);
3379 blob->push_back(execution);
3380 blob->push_back(operation);
3381 blob->push_back(x);
3382 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupUMaxNonUniformAMD);
3383 }
WriteGroupSMaxNonUniformAMD(Blob * blob,IdResultType idResultType,IdResult idResult,IdScope execution,spv::GroupOperation operation,IdRef x)3384 void WriteGroupSMaxNonUniformAMD(Blob *blob,
3385 IdResultType idResultType,
3386 IdResult idResult,
3387 IdScope execution,
3388 spv::GroupOperation operation,
3389 IdRef x)
3390 {
3391 const size_t startSize = blob->size();
3392 blob->push_back(0);
3393 blob->push_back(idResultType);
3394 blob->push_back(idResult);
3395 blob->push_back(execution);
3396 blob->push_back(operation);
3397 blob->push_back(x);
3398 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpGroupSMaxNonUniformAMD);
3399 }
WriteBeginInvocationInterlockEXT(Blob * blob)3400 void WriteBeginInvocationInterlockEXT(Blob *blob)
3401 {
3402 const size_t startSize = blob->size();
3403 blob->push_back(0);
3404
3405 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpBeginInvocationInterlockEXT);
3406 }
WriteEndInvocationInterlockEXT(Blob * blob)3407 void WriteEndInvocationInterlockEXT(Blob *blob)
3408 {
3409 const size_t startSize = blob->size();
3410 blob->push_back(0);
3411
3412 (*blob)[startSize] = MakeLengthOp(blob->size() - startSize, spv::OpEndInvocationInterlockEXT);
3413 }
3414
3415 } // namespace spirv
3416 } // namespace angle
3417