RetroArch
SpvBuilder.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2014-2015 LunarG, Inc.
3 // Copyright (C) 2015-2016 Google, Inc.
4 // Copyright (C) 2017 ARM Limited.
5 //
6 // All rights reserved.
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above
16 // copyright notice, this list of conditions and the following
17 // disclaimer in the documentation and/or other materials provided
18 // with the distribution.
19 //
20 // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
21 // contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 // POSSIBILITY OF SUCH DAMAGE.
36 
37 //
38 // "Builder" is an interface to fully build SPIR-V IR. Allocate one of
39 // these to build (a thread safe) internal SPIR-V representation (IR),
40 // and then dump it as a binary stream according to the SPIR-V specification.
41 //
42 // A Builder has a 1:1 relationship with a SPIR-V module.
43 //
44 
45 #pragma once
46 #ifndef SpvBuilder_H
47 #define SpvBuilder_H
48 
49 #include "Logger.h"
50 #include "spirv.hpp"
51 #include "spvIR.h"
52 
53 #include <algorithm>
54 #include <map>
55 #include <memory>
56 #include <set>
57 #include <sstream>
58 #include <stack>
59 #include <unordered_map>
60 
61 namespace spv {
62 
63 class Builder {
64 public:
65  Builder(unsigned int spvVersion, unsigned int userNumber, SpvBuildLogger* logger);
66  virtual ~Builder();
67 
68  static const int maxMatrixSize = 4;
69 
70  unsigned int getSpvVersion() const { return spvVersion; }
71 
73  {
74  source = lang;
76  }
78  {
79  Instruction* fileString = new Instruction(getUniqueId(), NoType, OpString);
80  fileString->addStringOperand(file.c_str());
81  sourceFileStringId = fileString->getResultId();
82  strings.push_back(std::unique_ptr<Instruction>(fileString));
83  }
84  void setSourceText(const std::string& text) { sourceText = text; }
85  void addSourceExtension(const char* ext) { sourceExtensions.push_back(ext); }
86  void addModuleProcessed(const std::string& p) { moduleProcesses.push_back(p.c_str()); }
87  void setEmitOpLines() { emitOpLines = true; }
88  void addExtension(const char* ext) { extensions.insert(ext); }
89  Id import(const char*);
91  {
93  memoryModel = mem;
94  }
95 
97 
98  // To get a new <id> for anything needing a new one.
99  Id getUniqueId() { return ++uniqueId; }
100 
101  // To get a set of new <id>s, e.g., for a set of function parameters
102  Id getUniqueIds(int numIds)
103  {
104  Id id = uniqueId + 1;
105  uniqueId += numIds;
106  return id;
107  }
108 
109  // Log the current line, and if different than the last one,
110  // issue a new OpLine, using the current file name.
111  void setLine(int line);
112  // Low-level OpLine. See setLine() for a layered helper.
113  void addLine(Id fileName, int line, int column);
114 
115  // For creating new types (will return old type if the requested one was already made).
116  Id makeVoidType();
117  Id makeBoolType();
119  Id makeIntegerType(int width, bool hasSign); // generic
120  Id makeIntType(int width) { return makeIntegerType(width, true); }
121  Id makeUintType(int width) { return makeIntegerType(width, false); }
122  Id makeFloatType(int width);
123  Id makeStructType(const std::vector<Id>& members, const char*);
124  Id makeStructResultType(Id type0, Id type1);
125  Id makeVectorType(Id component, int size);
126  Id makeMatrixType(Id component, int cols, int rows);
127  Id makeArrayType(Id element, Id sizeId, int stride); // 0 stride means no stride decoration
128  Id makeRuntimeArray(Id element);
129  Id makeFunctionType(Id returnType, const std::vector<Id>& paramTypes);
130  Id makeImageType(Id sampledType, Dim, bool depth, bool arrayed, bool ms, unsigned sampled, ImageFormat format);
132  Id makeSampledImageType(Id imageType);
133 
134  // For querying about types.
135  Id getTypeId(Id resultId) const { return module.getTypeId(resultId); }
136  Id getDerefTypeId(Id resultId) const;
137  Op getOpCode(Id id) const { return module.getInstruction(id)->getOpCode(); }
138  Op getTypeClass(Id typeId) const { return getOpCode(typeId); }
139  Op getMostBasicTypeClass(Id typeId) const;
140  int getNumComponents(Id resultId) const { return getNumTypeComponents(getTypeId(resultId)); }
141  int getNumTypeConstituents(Id typeId) const;
142  int getNumTypeComponents(Id typeId) const { return getNumTypeConstituents(typeId); }
143  Id getScalarTypeId(Id typeId) const;
144  Id getContainedTypeId(Id typeId) const;
145  Id getContainedTypeId(Id typeId, int) const;
146  StorageClass getTypeStorageClass(Id typeId) const { return module.getStorageClass(typeId); }
147  ImageFormat getImageTypeFormat(Id typeId) const { return (ImageFormat)module.getInstruction(typeId)->getImmediateOperand(6); }
148 
149  bool isPointer(Id resultId) const { return isPointerType(getTypeId(resultId)); }
150  bool isScalar(Id resultId) const { return isScalarType(getTypeId(resultId)); }
151  bool isVector(Id resultId) const { return isVectorType(getTypeId(resultId)); }
152  bool isMatrix(Id resultId) const { return isMatrixType(getTypeId(resultId)); }
153  bool isAggregate(Id resultId) const { return isAggregateType(getTypeId(resultId)); }
154  bool isSampledImage(Id resultId) const { return isSampledImageType(getTypeId(resultId)); }
155 
156  bool isBoolType(Id typeId) { return groupedTypes[OpTypeBool].size() > 0 && typeId == groupedTypes[OpTypeBool].back()->getResultId(); }
157  bool isIntType(Id typeId) const { return getTypeClass(typeId) == OpTypeInt && module.getInstruction(typeId)->getImmediateOperand(1) != 0; }
158  bool isUintType(Id typeId) const { return getTypeClass(typeId) == OpTypeInt && module.getInstruction(typeId)->getImmediateOperand(1) == 0; }
159  bool isFloatType(Id typeId) const { return getTypeClass(typeId) == OpTypeFloat; }
160  bool isPointerType(Id typeId) const { return getTypeClass(typeId) == OpTypePointer; }
161  bool isScalarType(Id typeId) const { return getTypeClass(typeId) == OpTypeFloat || getTypeClass(typeId) == OpTypeInt || getTypeClass(typeId) == OpTypeBool; }
162  bool isVectorType(Id typeId) const { return getTypeClass(typeId) == OpTypeVector; }
163  bool isMatrixType(Id typeId) const { return getTypeClass(typeId) == OpTypeMatrix; }
164  bool isStructType(Id typeId) const { return getTypeClass(typeId) == OpTypeStruct; }
165  bool isArrayType(Id typeId) const { return getTypeClass(typeId) == OpTypeArray; }
166  bool isAggregateType(Id typeId) const { return isArrayType(typeId) || isStructType(typeId); }
167  bool isImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeImage; }
168  bool isSamplerType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampler; }
169  bool isSampledImageType(Id typeId) const { return getTypeClass(typeId) == OpTypeSampledImage; }
170 
171  bool isConstantOpCode(Op opcode) const;
172  bool isSpecConstantOpCode(Op opcode) const;
173  bool isConstant(Id resultId) const { return isConstantOpCode(getOpCode(resultId)); }
174  bool isConstantScalar(Id resultId) const { return getOpCode(resultId) == OpConstant; }
175  bool isSpecConstant(Id resultId) const { return isSpecConstantOpCode(getOpCode(resultId)); }
176  unsigned int getConstantScalar(Id resultId) const { return module.getInstruction(resultId)->getImmediateOperand(0); }
177  StorageClass getStorageClass(Id resultId) const { return getTypeStorageClass(getTypeId(resultId)); }
178 
179  int getScalarTypeWidth(Id typeId) const
180  {
181  Id scalarTypeId = getScalarTypeId(typeId);
182  assert(getTypeClass(scalarTypeId) == OpTypeInt || getTypeClass(scalarTypeId) == OpTypeFloat);
183  return module.getInstruction(scalarTypeId)->getImmediateOperand(0);
184  }
185 
186  int getTypeNumColumns(Id typeId) const
187  {
188  assert(isMatrixType(typeId));
189  return getNumTypeConstituents(typeId);
190  }
191  int getNumColumns(Id resultId) const { return getTypeNumColumns(getTypeId(resultId)); }
192  int getTypeNumRows(Id typeId) const
193  {
194  assert(isMatrixType(typeId));
196  }
197  int getNumRows(Id resultId) const { return getTypeNumRows(getTypeId(resultId)); }
198 
200  {
201  assert(isImageType(typeId));
202  return (Dim)module.getInstruction(typeId)->getImmediateOperand(1);
203  }
204  Id getImageType(Id resultId) const
205  {
206  Id typeId = getTypeId(resultId);
207  assert(isImageType(typeId) || isSampledImageType(typeId));
208  return isSampledImageType(typeId) ? module.getInstruction(typeId)->getIdOperand(0) : typeId;
209  }
210  bool isArrayedImageType(Id typeId) const
211  {
212  assert(isImageType(typeId));
213  return module.getInstruction(typeId)->getImmediateOperand(3) != 0;
214  }
215 
216  // For making new constants (will return old constant if the requested one was already made).
217  Id makeBoolConstant(bool b, bool specConstant = false);
218  Id makeInt8Constant(int i, bool specConstant = false) { return makeIntConstant(makeIntType(8), (unsigned)i, specConstant); }
219  Id makeUint8Constant(unsigned u, bool specConstant = false) { return makeIntConstant(makeUintType(8), u, specConstant); }
220  Id makeInt16Constant(int i, bool specConstant = false) { return makeIntConstant(makeIntType(16), (unsigned)i, specConstant); }
221  Id makeUint16Constant(unsigned u, bool specConstant = false) { return makeIntConstant(makeUintType(16), u, specConstant); }
222  Id makeIntConstant(int i, bool specConstant = false) { return makeIntConstant(makeIntType(32), (unsigned)i, specConstant); }
223  Id makeUintConstant(unsigned u, bool specConstant = false) { return makeIntConstant(makeUintType(32), u, specConstant); }
224  Id makeInt64Constant(long long i, bool specConstant = false) { return makeInt64Constant(makeIntType(64), (unsigned long long)i, specConstant); }
225  Id makeUint64Constant(unsigned long long u, bool specConstant = false) { return makeInt64Constant(makeUintType(64), u, specConstant); }
226  Id makeFloatConstant(float f, bool specConstant = false);
227  Id makeDoubleConstant(double d, bool specConstant = false);
228  Id makeFloat16Constant(float f16, bool specConstant = false);
229  Id makeFpConstant(Id type, double d, bool specConstant = false);
230 
231  // Turn the array of constants into a proper spv constant of the requested type.
232  Id makeCompositeConstant(Id type, const std::vector<Id>& comps, bool specConst = false);
233 
234  // Methods for adding information outside the CFG.
236  void addExecutionMode(Function*, ExecutionMode mode, int value1 = -1, int value2 = -1, int value3 = -1);
237  void addName(Id, const char* name);
238  void addMemberName(Id, int member, const char* name);
239  void addDecoration(Id, Decoration, int num = -1);
240  void addDecoration(Id, Decoration, const char*);
241  void addDecorationId(Id id, Decoration, Id idDecoration);
242  void addMemberDecoration(Id, unsigned int member, Decoration, int num = -1);
243  void addMemberDecoration(Id, unsigned int member, Decoration, const char*);
244 
245  // At the end of what block do the next create*() instructions go?
246  void setBuildPoint(Block* bp) { buildPoint = bp; }
247  Block* getBuildPoint() const { return buildPoint; }
248 
249  // Make the entry-point function. The returned pointer is only valid
250  // for the lifetime of this builder.
251  Function* makeEntryPoint(const char*);
252 
253  // Make a shader-style function, and create its entry block if entry is non-zero.
254  // Return the function, pass back the entry.
255  // The returned pointer is only valid for the lifetime of this builder.
256  Function* makeFunctionEntry(Decoration precision, Id returnType, const char* name, const std::vector<Id>& paramTypes,
257  const std::vector<std::vector<Decoration>>& precisions, Block **entry = 0);
258 
259  // Create a return. An 'implicit' return is one not appearing in the source
260  // code. In the case of an implicit return, no post-return block is inserted.
261  void makeReturn(bool implicit, Id retVal = 0);
262 
263  // Generate all the code needed to finish up a function.
264  void leaveFunction();
265 
266  // Create a discard.
267  void makeDiscard();
268 
269  // Create a global or function local or IO variable.
270  Id createVariable(StorageClass, Id type, const char* name = 0);
271 
272  // Create an intermediate with an undefined value.
274 
275  // Store into an Id and return the l-value
276  void createStore(Id rValue, Id lValue);
277 
278  // Load from an Id and return it
279  Id createLoad(Id lValue);
280 
281  // Create an OpAccessChain instruction
282  Id createAccessChain(StorageClass, Id base, const std::vector<Id>& offsets);
283 
284  // Create an OpArrayLength instruction
285  Id createArrayLength(Id base, unsigned int member);
286 
287  // Create an OpCompositeExtract instruction
288  Id createCompositeExtract(Id composite, Id typeId, unsigned index);
289  Id createCompositeExtract(Id composite, Id typeId, const std::vector<unsigned>& indexes);
290  Id createCompositeInsert(Id object, Id composite, Id typeId, unsigned index);
291  Id createCompositeInsert(Id object, Id composite, Id typeId, const std::vector<unsigned>& indexes);
292 
293  Id createVectorExtractDynamic(Id vector, Id typeId, Id componentIndex);
294  Id createVectorInsertDynamic(Id vector, Id typeId, Id component, Id componentIndex);
295 
296  void createNoResultOp(Op);
297  void createNoResultOp(Op, Id operand);
298  void createNoResultOp(Op, const std::vector<Id>& operands);
299  void createControlBarrier(Scope execution, Scope memory, MemorySemanticsMask);
300  void createMemoryBarrier(unsigned executionScope, unsigned memorySemantics);
301  Id createUnaryOp(Op, Id typeId, Id operand);
302  Id createBinOp(Op, Id typeId, Id operand1, Id operand2);
303  Id createTriOp(Op, Id typeId, Id operand1, Id operand2, Id operand3);
304  Id createOp(Op, Id typeId, const std::vector<Id>& operands);
305  Id createFunctionCall(spv::Function*, const std::vector<spv::Id>&);
306  Id createSpecConstantOp(Op, Id typeId, const std::vector<spv::Id>& operands, const std::vector<unsigned>& literals);
307 
308  // Take an rvalue (source) and a set of channels to extract from it to
309  // make a new rvalue, which is returned.
310  Id createRvalueSwizzle(Decoration precision, Id typeId, Id source, const std::vector<unsigned>& channels);
311 
312  // Take a copy of an lvalue (target) and a source of components, and set the
313  // source components into the lvalue where the 'channels' say to put them.
314  // An updated version of the target is returned.
315  // (No true lvalue or stores are used.)
316  Id createLvalueSwizzle(Id typeId, Id target, Id source, const std::vector<unsigned>& channels);
317 
318  // If both the id and precision are valid, the id
319  // gets tagged with the requested precision.
320  // The passed in id is always the returned id, to simplify use patterns.
322  {
323  if (precision != NoPrecision && id != NoResult)
325 
326  return id;
327  }
328 
329  // Can smear a scalar to a vector for the following forms:
330  // - promoteScalar(scalar, vector) // smear scalar to width of vector
331  // - promoteScalar(vector, scalar) // smear scalar to width of vector
332  // - promoteScalar(pointer, scalar) // smear scalar to width of what pointer points to
333  // - promoteScalar(scalar, scalar) // do nothing
334  // Other forms are not allowed.
335  //
336  // Generally, the type of 'scalar' does not need to be the same type as the components in 'vector'.
337  // The type of the created vector is a vector of components of the same type as the scalar.
338  //
339  // Note: One of the arguments will change, with the result coming back that way rather than
340  // through the return value.
342 
343  // Make a value by smearing the scalar to fill the type.
344  // vectorType should be the correct type for making a vector of scalarVal.
345  // (No conversions are done.)
346  Id smearScalar(Decoration precision, Id scalarVal, Id vectorType);
347 
348  // Create a call to a built-in function.
349  Id createBuiltinCall(Id resultType, Id builtins, int entryPoint, const std::vector<Id>& args);
350 
351  // List of parameters used to create a texture operation
366  };
367 
368  // Select the correct texture operation based on all inputs, and emit the correct instruction
369  Id createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather, bool noImplicit, const TextureParameters&);
370 
371  // Emit the OpTextureQuery* instruction that was passed in.
372  // Figure out the right return value and type, and return it.
373  Id createTextureQueryCall(Op, const TextureParameters&, bool isUnsignedResult);
374 
376 
379 
380  // Reduction comparison for composites: For equal and not-equal resulting in a scalar.
381  Id createCompositeCompare(Decoration precision, Id, Id, bool /* true if for equal, false if for not-equal */);
382 
383  // OpCompositeConstruct
384  Id createCompositeConstruct(Id typeId, const std::vector<Id>& constituents);
385 
386  // vector or scalar constructor
387  Id createConstructor(Decoration precision, const std::vector<Id>& sources, Id resultTypeId);
388 
389  // matrix constructor
390  Id createMatrixConstructor(Decoration precision, const std::vector<Id>& sources, Id constructee);
391 
392  // Helper to use for building nested control flow with if-then-else.
393  class If {
394  public:
395  If(Id condition, unsigned int ctrl, Builder& builder);
396  ~If() {}
397 
398  void makeBeginElse();
399  void makeEndIf();
400 
401  private:
402  If(const If&);
403  If& operator=(If&);
404 
407  unsigned int control;
408  Function* function;
413  };
414 
415  // Make a switch statement. A switch has 'numSegments' of pieces of code, not containing
416  // any case/default labels, all separated by one or more case/default labels. Each possible
417  // case value v is a jump to the caseValues[v] segment. The defaultSegment is also in this
418  // number space. How to compute the value is given by 'condition', as in switch(condition).
419  //
420  // The SPIR-V Builder will maintain the stack of post-switch merge blocks for nested switches.
421  //
422  // Use a defaultSegment < 0 if there is no default segment (to branch to post switch).
423  //
424  // Returns the right set of basic blocks to start each code segment with, so that the caller's
425  // recursion stack can hold the memory for it.
426  //
427  void makeSwitch(Id condition, unsigned int control, int numSegments, const std::vector<int>& caseValues,
428  const std::vector<int>& valueToSegment, int defaultSegment, std::vector<Block*>& segmentBB); // return argument
429 
430  // Add a branch to the innermost switch's merge block.
431  void addSwitchBreak();
432 
433  // Move to the next code segment, passing in the return argument in makeSwitch()
434  void nextSwitchSegment(std::vector<Block*>& segmentBB, int segment);
435 
436  // Finish off the innermost switch.
437  void endSwitch(std::vector<Block*>& segmentBB);
438 
439  struct LoopBlocks {
443  private:
444  LoopBlocks();
446  };
447 
448  // Start a new loop and prepare the builder to generate code for it. Until
449  // closeLoop() is called for this loop, createLoopContinue() and
450  // createLoopExit() will target its corresponding blocks.
452 
453  // Create a new block in the function containing the build point. Memory is
454  // owned by the function object.
455  Block& makeNewBlock();
456 
457  // Add a branch to the continue_target of the current (innermost) loop.
458  void createLoopContinue();
459 
460  // Add an exit (e.g. "break") from the innermost loop that we're currently
461  // in.
462  void createLoopExit();
463 
464  // Close the innermost loop that you're in
465  void closeLoop();
466 
467  //
468  // Access chain design for an R-Value vs. L-Value:
469  //
470  // There is a single access chain the builder is building at
471  // any particular time. Such a chain can be used to either to a load or
472  // a store, when desired.
473  //
474  // Expressions can be r-values, l-values, or both, or only r-values:
475  // a[b.c].d = .... // l-value
476  // ... = a[b.c].d; // r-value, that also looks like an l-value
477  // ++a[b.c].d; // r-value and l-value
478  // (x + y)[2]; // r-value only, can't possibly be l-value
479  //
480  // Computing an r-value means generating code. Hence,
481  // r-values should only be computed when they are needed, not speculatively.
482  //
483  // Computing an l-value means saving away information for later use in the compiler,
484  // no code is generated until the l-value is later dereferenced. It is okay
485  // to speculatively generate an l-value, just not okay to speculatively dereference it.
486  //
487  // The base of the access chain (the left-most variable or expression
488  // from which everything is based) can be set either as an l-value
489  // or as an r-value. Most efficient would be to set an l-value if one
490  // is available. If an expression was evaluated, the resulting r-value
491  // can be set as the chain base.
492  //
493  // The users of this single access chain can save and restore if they
494  // want to nest or manage multiple chains.
495  //
496 
497  struct AccessChain {
498  Id base; // for l-values, pointer to the base object, for r-values, the base object
499  std::vector<Id> indexChain;
500  Id instr; // cache the instruction that generates this access chain
501  std::vector<unsigned> swizzle; // each std::vector element selects the next GLSL component number
502  Id component; // a dynamic component index, can coexist with a swizzle, done after the swizzle, NoResult if not present
503  Id preSwizzleBaseType; // dereferenced type, before swizzle or component is applied; NoType unless a swizzle or component is present
504  bool isRValue; // true if 'base' is an r-value, otherwise, base is an l-value
505  };
506 
507  //
508  // the SPIR-V builder maintains a single active chain that
509  // the following methods operate on
510  //
511 
512  // for external save and restore
514  void setAccessChain(AccessChain newChain) { accessChain = newChain; }
515 
516  // clear accessChain
517  void clearAccessChain();
518 
519  // set new base as an l-value base
521  {
522  assert(isPointer(lValue));
523  accessChain.base = lValue;
524  }
525 
526  // set new base value as an r-value
528  {
529  accessChain.isRValue = true;
530  accessChain.base = rValue;
531  }
532 
533  // push offset onto the end of the chain
535  {
536  accessChain.indexChain.push_back(offset);
537  }
538 
539  // push new swizzle onto the end of any existing swizzle, merging into a single swizzle
540  void accessChainPushSwizzle(std::vector<unsigned>& swizzle, Id preSwizzleBaseType);
541 
542  // push a dynamic component selection onto the access chain, only applicable with a
543  // non-trivial swizzle or no swizzle
544  void accessChainPushComponent(Id component, Id preSwizzleBaseType)
545  {
546  if (accessChain.swizzle.size() != 1) {
547  accessChain.component = component;
549  accessChain.preSwizzleBaseType = preSwizzleBaseType;
550  }
551  }
552 
553  // use accessChain and swizzle to store value
554  void accessChainStore(Id rvalue);
555 
556  // use accessChain and swizzle to load an r-value
557  Id accessChainLoad(Decoration precision, Decoration nonUniform, Id ResultType);
558 
559  // get the direct pointer for an l-value
561 
562  // Get the inferred SPIR-V type of the result of the current access chain,
563  // based on the type of the base and the chain of dereferences.
565 
566  // Remove OpDecorate instructions whose operands are defined in unreachable
567  // blocks.
569  void dump(std::vector<unsigned int>&) const;
570 
571  void createBranch(Block* block);
572  void createConditionalBranch(Id condition, Block* thenBlock, Block* elseBlock);
573  void createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned int control, unsigned int dependencyLength);
574 
575  // Sets to generate opcode for specialization constants.
577  // Sets to generate opcode for non-specialization constants (normal mode).
579  // Check if the builder is generating code for spec constants.
581 
582  protected:
583  Id makeIntConstant(Id typeId, unsigned value, bool specConstant);
584  Id makeInt64Constant(Id typeId, unsigned long long value, bool specConstant);
585  Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value);
586  Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2);
587  Id findCompositeConstant(Op typeClass, const std::vector<Id>& comps);
588  Id findStructConstant(Id typeId, const std::vector<Id>& comps);
590  void remapDynamicSwizzle();
591  void transferAccessChainSwizzle(bool dynamic);
593  void createAndSetNoPredecessorBlock(const char*);
594  void createSelectionMerge(Block* mergeBlock, unsigned int control);
595  void dumpSourceInstructions(std::vector<unsigned int>&) const;
596  void dumpInstructions(std::vector<unsigned int>&, const std::vector<std::unique_ptr<Instruction> >&) const;
597  void dumpModuleProcesses(std::vector<unsigned int>&) const;
598 
599  unsigned int spvVersion; // the version of SPIR-V to emit in the header
606  std::set<std::string> extensions;
607  std::vector<const char*> sourceExtensions;
608  std::vector<const char*> moduleProcesses;
611  std::set<spv::Capability> capabilities;
619 
620  // special blocks of instructions for output
621  std::vector<std::unique_ptr<Instruction> > strings;
622  std::vector<std::unique_ptr<Instruction> > imports;
623  std::vector<std::unique_ptr<Instruction> > entryPoints;
624  std::vector<std::unique_ptr<Instruction> > executionModes;
625  std::vector<std::unique_ptr<Instruction> > names;
626  std::vector<std::unique_ptr<Instruction> > decorations;
627  std::vector<std::unique_ptr<Instruction> > constantsTypesGlobals;
628  std::vector<std::unique_ptr<Instruction> > externals;
629  std::vector<std::unique_ptr<Function> > functions;
630 
631  // not output, internally used for quick & dirty canonical (unique) creation
632  std::unordered_map<unsigned int, std::vector<Instruction*>> groupedConstants; // map type opcodes to constant inst.
633  std::unordered_map<unsigned int, std::vector<Instruction*>> groupedStructConstants; // map struct-id to constant instructions
634  std::unordered_map<unsigned int, std::vector<Instruction*>> groupedTypes; // map type opcodes to type instructions
635 
636  // stack of switches
637  std::stack<Block*> switchMerges;
638 
639  // Our loop stack.
640  std::stack<LoopBlocks> loops;
641 
642  // The stream for outputting warnings and errors.
644 }; // end Builder class
645 
646 }; // end spv namespace
647 
648 #endif // SpvBuilder_H
StorageClass getTypeStorageClass(Id typeId) const
Definition: SpvBuilder.h:146
unsigned int Id
Definition: spirv.hpp:47
bool emitOpLines
Definition: SpvBuilder.h:605
unsigned long Instruction
Definition: llimits.h:165
void makeBeginElse()
Definition: SpvBuilder.cpp:2137
Id makeImageType(Id sampledType, Dim, bool depth, bool arrayed, bool ms, unsigned sampled, ImageFormat format)
Definition: SpvBuilder.cpp:405
int builderNumber
Definition: SpvBuilder.h:612
Id createBitFieldInsertCall(Decoration precision, Id, Id, Id, Id)
int getTypeNumRows(Id typeId) const
Definition: SpvBuilder.h:192
GLsizeiptr size
Definition: glext.h:6559
bool isAggregate(Id resultId) const
Definition: SpvBuilder.h:153
GLuint GLsizei const GLuint const GLintptr * offsets
Definition: glsym_gl.h:634
GLenum GLuint id
Definition: glext.h:6233
std::stack< Block * > switchMerges
Definition: SpvBuilder.h:637
Function * makeFunctionEntry(Decoration precision, Id returnType, const char *name, const std::vector< Id > &paramTypes, const std::vector< std::vector< Decoration >> &precisions, Block **entry=0)
Definition: SpvBuilder.cpp:1095
Definition: spirv.hpp:735
LoopBlocks & operator=(const LoopBlocks &)
void setAccessChain(AccessChain newChain)
Definition: SpvBuilder.h:514
Id createRvalueSwizzle(Decoration precision, Id typeId, Id source, const std::vector< unsigned > &channels)
Definition: SpvBuilder.cpp:1457
Id condition
Definition: SpvBuilder.h:406
Id lod
Definition: SpvBuilder.h:356
void addExecutionMode(Function *, ExecutionMode mode, int value1=-1, int value2=-1, int value3=-1)
Definition: SpvBuilder.cpp:977
StorageClass
Definition: spirv.hpp:137
void addExtension(const char *ext)
Definition: SpvBuilder.h:88
Block * getBuildPoint() const
Definition: SpvBuilder.h:247
std::unordered_map< unsigned int, std::vector< Instruction * > > groupedConstants
Definition: SpvBuilder.h:632
unsigned int spvVersion
Definition: SpvBuilder.h:599
Id accessChainGetInferredType()
Definition: SpvBuilder.cpp:2424
virtual ~Builder()
Definition: SpvBuilder.cpp:76
void leaveFunction()
Definition: SpvBuilder.cpp:1140
Block & makeNewBlock()
Definition: SpvBuilder.cpp:2237
GLfloat GLfloat GLfloat v2
Definition: glext.h:6703
Decoration
Definition: spirv.hpp:344
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:6316
void setBuildPoint(Block *bp)
Definition: SpvBuilder.h:246
Id createMatrixConstructor(Decoration precision, const std::vector< Id > &sources, Id constructee)
Definition: SpvBuilder.cpp:2025
Id makeIntType(int width)
Definition: SpvBuilder.h:120
Id getScalarTypeId(Id typeId) const
Definition: SpvBuilder.cpp:570
bool isConstantScalar(Id resultId) const
Definition: SpvBuilder.h:174
std::set< spv::Capability > capabilities
Definition: SpvBuilder.h:611
Id instr
Definition: SpvBuilder.h:500
GLfloat GLfloat v1
Definition: glext.h:6702
bool isBoolType(Id typeId)
Definition: SpvBuilder.h:156
Id createSamplePositionCall(Decoration precision, Id, Id)
static const signed char indexes[2][4][20]
Definition: camellia.c:218
Id createArrayLength(Id base, unsigned int member)
Definition: SpvBuilder.cpp:1241
void promoteScalar(Decoration precision, Id &left, Id &right)
Definition: SpvBuilder.cpp:1512
std::vector< std::unique_ptr< Instruction > > externals
Definition: SpvBuilder.h:628
Dim
Definition: spirv.hpp:154
GLsizei GLenum * sources
Definition: glext.h:8420
const Decoration NoPrecision
Definition: spvIR.h:67
Definition: SpvBuilder.h:439
Op getMostBasicTypeClass(Id typeId) const
Definition: SpvBuilder.cpp:515
Block & merge
Definition: SpvBuilder.h:442
dictionary args
Definition: test_shaders.py:20
If(Id condition, unsigned int ctrl, Builder &builder)
Definition: SpvBuilder.cpp:2114
Id makeUintConstant(unsigned u, bool specConstant=false)
Definition: SpvBuilder.h:223
Id makeFpConstant(Id type, double d, bool specConstant=false)
Definition: SpvBuilder.cpp:851
Definition: SpvBuilder.h:63
GLenum condition
Definition: glext.h:10162
GLsizei GLsizei GLchar * source
Definition: glext.h:6688
ImageFormat
Definition: spirv.hpp:180
LoopBlocks(Block &head, Block &body, Block &merge, Block &continue_target)
Definition: SpvBuilder.h:440
Block & continue_target
Definition: SpvBuilder.h:442
void closeLoop()
Definition: SpvBuilder.cpp:2274
AccessChain getAccessChain()
Definition: SpvBuilder.h:513
Op
Definition: spirv.hpp:714
Id createUnaryOp(Op, Id typeId, Id operand)
Definition: SpvBuilder.cpp:1369
Op getOpCode(Id id) const
Definition: SpvBuilder.h:137
GLsizei const GLchar *const * string
Definition: glext.h:6699
void createControlBarrier(Scope execution, Scope memory, MemorySemanticsMask)
Definition: SpvBuilder.cpp:1351
Block * mergeBlock
Definition: SpvBuilder.h:412
Id makeFloat16Constant(float f16, bool specConstant=false)
Definition: SpvBuilder.cpp:823
Id makeFloatConstant(float f, bool specConstant=false)
Definition: SpvBuilder.cpp:770
Id makeUintType(int width)
Definition: SpvBuilder.h:121
bool isInSpecConstCodeGenMode()
Definition: SpvBuilder.h:580
Definition: spvIR.h:313
Id sampler
Definition: SpvBuilder.h:353
GLuint const GLchar * name
Definition: glext.h:6671
GLfloat f
Definition: glext.h:8207
void accessChainPushComponent(Id component, Id preSwizzleBaseType)
Definition: SpvBuilder.h:544
void addSwitchBreak()
Definition: SpvBuilder.cpp:2203
Id createCompositeInsert(Id object, Id composite, Id typeId, unsigned index)
Definition: SpvBuilder.cpp:1283
SpvBuildLogger * logger
Definition: SpvBuilder.h:643
MemoryModel
Definition: spirv.hpp:86
AddressingModel addressModel
Definition: SpvBuilder.h:609
Id base
Definition: SpvBuilder.h:498
void dump(std::vector< unsigned int > &) const
Definition: SpvBuilder.cpp:2492
Id createTextureQueryCall(Op, const TextureParameters &, bool isUnsignedResult)
Definition: SpvBuilder.cpp:1775
Definition: spvIR.h:86
int getScalarTypeWidth(Id typeId) const
Definition: SpvBuilder.h:179
int getNumComponents(Id resultId) const
Definition: SpvBuilder.h:140
bool isStructType(Id typeId) const
Definition: SpvBuilder.h:164
Id makeStructType(const std::vector< Id > &members, const char *)
Definition: SpvBuilder.cpp:247
const char * fileName
Definition: Hlsl.FromFile.cpp:44
void createNoResultOp(Op)
Definition: SpvBuilder.cpp:1328
Id makeVoidType()
Definition: SpvBuilder.cpp:110
Definition: disassemble.cpp:50
Definition: SpvBuilder.h:393
std::vector< std::unique_ptr< Instruction > > names
Definition: SpvBuilder.h:625
Id makeVectorType(Id component, int size)
Definition: SpvBuilder.cpp:288
void simplifyAccessChainSwizzle()
Definition: SpvBuilder.cpp:2613
bool isArrayedImageType(Id typeId) const
Definition: SpvBuilder.h:210
void makeDiscard()
Definition: SpvBuilder.cpp:1157
Id smearScalar(Decoration precision, Id scalarVal, Id vectorType)
Definition: SpvBuilder.cpp:1525
SourceLanguage source
Definition: SpvBuilder.h:600
bool isScalarType(Id typeId) const
Definition: SpvBuilder.h:161
void remapDynamicSwizzle()
Definition: SpvBuilder.cpp:2594
Definition: Logger.h:45
int getNumTypeComponents(Id typeId) const
Definition: SpvBuilder.h:142
std::unordered_map< unsigned int, std::vector< Instruction * > > groupedStructConstants
Definition: SpvBuilder.h:633
bool isVectorType(Id typeId) const
Definition: SpvBuilder.h:162
Definition: spirv.hpp:744
Id bias
Definition: SpvBuilder.h:355
int currentLine
Definition: SpvBuilder.h:604
Definition: spirv.hpp:742
void createStore(Id rValue, Id lValue)
Definition: SpvBuilder.cpp:1197
void setToNormalCodeGenMode()
Definition: SpvBuilder.h:578
Definition: spirv.hpp:736
Id makeSamplerType()
Definition: SpvBuilder.cpp:138
Id accessChainLoad(Decoration precision, Decoration nonUniform, Id ResultType)
Definition: SpvBuilder.cpp:2336
Id makeFunctionType(Id returnType, const std::vector< Id > &paramTypes)
Definition: SpvBuilder.cpp:374
Id offset
Definition: SpvBuilder.h:358
int getTypeNumColumns(Id typeId) const
Definition: SpvBuilder.h:186
Definition: civetweb.c:1024
Id createSpecConstantOp(Op, Id typeId, const std::vector< spv::Id > &operands, const std::vector< unsigned > &literals)
Definition: SpvBuilder.cpp:1431
unsigned int getConstantScalar(Id resultId) const
Definition: SpvBuilder.h:176
bool isPointerType(Id typeId) const
Definition: SpvBuilder.h:160
ExecutionModel
Definition: spirv.hpp:68
Definition: spvIR.h:249
version
Definition: setup.py:6
Id accessChainGetLValue()
Definition: SpvBuilder.cpp:2407
GLsizei const GLfloat * value
Definition: glext.h:6709
std::vector< std::unique_ptr< Instruction > > constantsTypesGlobals
Definition: SpvBuilder.h:627
std::vector< std::unique_ptr< Instruction > > executionModes
Definition: SpvBuilder.h:624
bool isMatrix(Id resultId) const
Definition: SpvBuilder.h:152
void makeSwitch(Id condition, unsigned int control, int numSegments, const std::vector< int > &caseValues, const std::vector< int > &valueToSegment, int defaultSegment, std::vector< Block *> &segmentBB)
Definition: SpvBuilder.cpp:2170
void addModuleProcessed(const std::string &p)
Definition: SpvBuilder.h:86
void nextSwitchSegment(std::vector< Block *> &segmentBB, int segment)
Definition: SpvBuilder.cpp:2211
Definition: SpvBuilder.h:497
Id makePointer(StorageClass, Id type)
Definition: SpvBuilder.cpp:152
Id createOp(Op, Id typeId, const std::vector< Id > &operands)
Definition: SpvBuilder.cpp:1421
std::set< std::string > extensions
Definition: SpvBuilder.h:606
LoopBlocks & makeNewLoop()
Definition: SpvBuilder.cpp:2245
Function * entryPointFunction
Definition: SpvBuilder.h:616
std::vector< std::unique_ptr< Instruction > > strings
Definition: SpvBuilder.h:621
bool isVector(Id resultId) const
Definition: SpvBuilder.h:151
Id makeUint64Constant(unsigned long long u, bool specConstant=false)
Definition: SpvBuilder.h:225
std::vector< std::unique_ptr< Function > > functions
Definition: SpvBuilder.h:629
Id collapseAccessChain()
Definition: SpvBuilder.cpp:2554
void transferAccessChainSwizzle(bool dynamic)
Definition: SpvBuilder.cpp:2638
std::stack< LoopBlocks > loops
Definition: SpvBuilder.h:640
Id makeUint16Constant(unsigned u, bool specConstant=false)
Definition: SpvBuilder.h:221
bool isSampledImageType(Id typeId) const
Definition: SpvBuilder.h:169
Id uniqueId
Definition: SpvBuilder.h:615
MemorySemanticsMask
Definition: spirv.hpp:534
bool generatingOpCodeForSpecConst
Definition: SpvBuilder.h:617
Id createConstructor(Decoration precision, const std::vector< Id > &sources, Id resultTypeId)
Definition: SpvBuilder.cpp:1941
GLenum cap
Definition: glext.h:10546
std::vector< const char * > sourceExtensions
Definition: SpvBuilder.h:607
Id makeIntegerType(int width, bool hasSign)
Definition: SpvBuilder.cpp:174
Id makeInt16Constant(int i, bool specConstant=false)
Definition: SpvBuilder.h:220
int sourceVersion
Definition: SpvBuilder.h:601
Id gradX
Definition: SpvBuilder.h:360
bool isSpecConstantOpCode(Op opcode) const
Definition: SpvBuilder.cpp:681
void setSourceFile(const std::string &file)
Definition: SpvBuilder.h:77
Definition: spirv.hpp:734
const Id NoResult
Definition: spvIR.h:64
void createLoopContinue()
Definition: SpvBuilder.cpp:2260
std::string sourceText
Definition: SpvBuilder.h:603
void addSourceExtension(const char *ext)
Definition: SpvBuilder.h:85
void makeReturn(bool implicit, Id retVal=0)
Definition: SpvBuilder.cpp:1126
Instruction * addEntryPoint(ExecutionModel, Function *, const char *name)
Definition: SpvBuilder.cpp:964
void dumpInstructions(std::vector< unsigned int > &, const std::vector< std::unique_ptr< Instruction > > &) const
Definition: SpvBuilder.cpp:2761
Capability
Definition: spirv.hpp:599
std::vector< std::unique_ptr< Instruction > > entryPoints
Definition: SpvBuilder.h:623
Id Dref
Definition: SpvBuilder.h:357
MemoryModel memoryModel
Definition: SpvBuilder.h:610
GLuint GLuint num
Definition: glext.h:10525
Block * elseBlock
Definition: SpvBuilder.h:411
Id createFunctionCall(spv::Function *, const std::vector< spv::Id > &)
Definition: SpvBuilder.cpp:1445
Id makeFloatType(int width)
Definition: SpvBuilder.cpp:211
GLenum mode
Definition: glext.h:6857
Id makeUint8Constant(unsigned u, bool specConstant=false)
Definition: SpvBuilder.h:219
Dim getTypeDimensionality(Id typeId) const
Definition: SpvBuilder.h:199
void setSourceText(const std::string &text)
Definition: SpvBuilder.h:84
static int block
Definition: psp2.c:31
Id component
Definition: SpvBuilder.h:363
const Id NoType
Definition: spvIR.h:65
ExecutionMode
Definition: spirv.hpp:93
Id getTypeId(Id resultId) const
Definition: SpvBuilder.h:135
void createAndSetNoPredecessorBlock(const char *)
Definition: SpvBuilder.cpp:2668
Id createCompositeCompare(Decoration precision, Id, Id, bool)
Definition: SpvBuilder.cpp:1846
Id createCompositeExtract(Id composite, Id typeId, unsigned index)
Definition: SpvBuilder.cpp:1252
Id makeInt8Constant(int i, bool specConstant=false)
Definition: SpvBuilder.h:218
Id createVectorExtractDynamic(Id vector, Id typeId, Id componentIndex)
Definition: SpvBuilder.cpp:1306
void addMemberName(Id, int member, const char *name)
Definition: SpvBuilder.cpp:1001
Block & head
Definition: SpvBuilder.h:442
void createSelectionMerge(Block *mergeBlock, unsigned int control)
Definition: SpvBuilder.cpp:2688
void accessChainStore(Id rvalue)
Definition: SpvBuilder.cpp:2314
Id getContainedTypeId(Id typeId) const
Definition: SpvBuilder.cpp:619
Id findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value)
Definition: SpvBuilder.cpp:626
std::vector< unsigned > swizzle
Definition: SpvBuilder.h:501
void endSwitch(std::vector< Block *> &segmentBB)
Definition: SpvBuilder.cpp:2225
void setToSpecConstCodeGenMode()
Definition: SpvBuilder.h:576
Op getTypeClass(Id typeId) const
Definition: SpvBuilder.h:138
unsigned int getSpvVersion() const
Definition: SpvBuilder.h:70
void addCapability(spv::Capability cap)
Definition: SpvBuilder.h:96
Block * buildPoint
Definition: SpvBuilder.h:614
bool isMatrixType(Id typeId) const
Definition: SpvBuilder.h:163
Definition: spirv.hpp:739
void eliminateDeadDecorations()
Definition: SpvBuilder.cpp:2457
bool isPointer(Id resultId) const
Definition: SpvBuilder.h:149
Definition: spirv.hpp:738
Id getImageType(Id resultId) const
Definition: SpvBuilder.h:204
Id makeCompositeConstant(Id type, const std::vector< Id > &comps, bool specConst=false)
Definition: SpvBuilder.cpp:923
void addDecorationId(Id id, Decoration, Id idDecoration)
Definition: SpvBuilder.cpp:1038
Function * makeEntryPoint(const char *)
Definition: SpvBuilder.cpp:1081
GLenum type
Definition: glext.h:6233
Id makeMatrixType(Id component, int cols, int rows)
Definition: SpvBuilder.cpp:310
Definition: spirv.hpp:722
GLfloat GLfloat p
Definition: glext.h:9809
std::vector< std::unique_ptr< Instruction > > decorations
Definition: SpvBuilder.h:626
Id getDerefTypeId(Id resultId) const
Definition: SpvBuilder.cpp:507
GLintptr offset
Definition: glext.h:6560
GLint left
Definition: glext.h:8393
Id setPrecision(Id id, Decoration precision)
Definition: SpvBuilder.h:321
bool isUintType(Id typeId) const
Definition: SpvBuilder.h:158
Id getUniqueId()
Definition: SpvBuilder.h:99
bool isAggregateType(Id typeId) const
Definition: SpvBuilder.h:166
Definition: spirv.hpp:732
Id createBitFieldExtractCall(Decoration precision, Id, Id, Id, bool isSigned)
void accessChainPush(Id offset)
Definition: SpvBuilder.h:534
StorageClass getStorageClass(Id resultId) const
Definition: SpvBuilder.h:177
void dumpSourceInstructions(std::vector< unsigned int > &) const
Definition: SpvBuilder.cpp:2722
Id makeDoubleConstant(double d, bool specConstant=false)
Definition: SpvBuilder.cpp:795
void addStringOperand(const char *str)
Definition: spvIR.h:93
void addName(Id, const char *name)
Definition: SpvBuilder.cpp:992
Definition: ffmpeg_fft.c:36
Id getUniqueIds(int numIds)
Definition: SpvBuilder.h:102
Id getResultId() const
Definition: spvIR.h:123
Id findCompositeConstant(Op typeClass, const std::vector< Id > &comps)
Definition: SpvBuilder.cpp:870
void addMemberDecoration(Id, unsigned int member, Decoration, int num=-1)
Definition: SpvBuilder.cpp:1051
int getNumTypeConstituents(Id typeId) const
Definition: SpvBuilder.cpp:541
Block & body
Definition: SpvBuilder.h:442
Builder(unsigned int spvVersion, unsigned int userNumber, SpvBuildLogger *logger)
Definition: SpvBuilder.cpp:57
Id coords
Definition: SpvBuilder.h:354
Id lodClamp
Definition: SpvBuilder.h:365
bool isArrayType(Id typeId) const
Definition: SpvBuilder.h:165
Id texelOut
Definition: SpvBuilder.h:364
bool isConstant(Id resultId) const
Definition: SpvBuilder.h:173
void makeEndIf()
Definition: SpvBuilder.cpp:2151
Id makeStructResultType(Id type0, Id type1)
Definition: SpvBuilder.cpp:266
Definition: spirv.hpp:740
void accessChainPushSwizzle(std::vector< unsigned > &swizzle, Id preSwizzleBaseType)
Definition: SpvBuilder.cpp:2291
Definition: memr.c:17
void setAccessChainLValue(Id lValue)
Definition: SpvBuilder.h:520
bool isConstantOpCode(Op opcode) const
Definition: SpvBuilder.cpp:659
Id createVariable(StorageClass, Id type, const char *name=0)
Definition: SpvBuilder.cpp:1164
AccessChain accessChain
Definition: SpvBuilder.h:618
std::vector< const char * > moduleProcesses
Definition: SpvBuilder.h:608
Id makeBoolType()
Definition: SpvBuilder.cpp:124
Id createBuiltinCall(Id resultType, Id builtins, int entryPoint, const std::vector< Id > &args)
Definition: SpvBuilder.cpp:1558
void setMemoryModel(spv::AddressingModel addr, spv::MemoryModel mem)
Definition: SpvBuilder.h:90
GLsizei stride
Definition: glext.h:6488
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glext.h:6293
Id makeRuntimeArray(Id element)
Definition: SpvBuilder.cpp:364
Id offsets
Definition: SpvBuilder.h:359
Id makeIntConstant(int i, bool specConstant=false)
Definition: SpvBuilder.h:222
spv::Id sourceFileStringId
Definition: SpvBuilder.h:602
std::vector< std::unique_ptr< Instruction > > imports
Definition: SpvBuilder.h:622
Scope
Definition: spirv.hpp:562
void setSource(spv::SourceLanguage lang, int version)
Definition: SpvBuilder.h:72
unsigned int control
Definition: SpvBuilder.h:407
std::unordered_map< unsigned int, std::vector< Instruction * > > groupedTypes
Definition: SpvBuilder.h:634
Id createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather, bool noImplicit, const TextureParameters &)
Definition: SpvBuilder.cpp:1573
GLsizei GLsizei numSegments
Definition: glext.h:12661
void createMemoryBarrier(unsigned executionScope, unsigned memorySemantics)
Definition: SpvBuilder.cpp:1360
Block * thenBlock
Definition: SpvBuilder.h:410
Id makeArrayType(Id element, Id sizeId, int stride)
Definition: SpvBuilder.cpp:340
Builder & builder
Definition: SpvBuilder.h:405
bool isFloatType(Id typeId) const
Definition: SpvBuilder.h:159
void setEmitOpLines()
Definition: SpvBuilder.h:87
bool isIntType(Id typeId) const
Definition: SpvBuilder.h:157
Block * headerBlock
Definition: SpvBuilder.h:409
Id createUndefined(Id type)
Definition: SpvBuilder.cpp:1189
Definition: ibxm.h:39
Definition: SpvBuilder.h:352
Id makeInt64Constant(long long i, bool specConstant=false)
Definition: SpvBuilder.h:224
bool isSampledImage(Id resultId) const
Definition: SpvBuilder.h:154
SourceLanguage
Definition: spirv.hpp:58
void createLoopExit()
Definition: SpvBuilder.cpp:2267
Id findStructConstant(Id typeId, const std::vector< Id > &comps)
Definition: SpvBuilder.cpp:898
const char * entryPoint
Definition: Hlsl.FromFile.cpp:45
bool isScalar(Id resultId) const
Definition: SpvBuilder.h:150
std::vector< Id > indexChain
Definition: SpvBuilder.h:499
Id preSwizzleBaseType
Definition: SpvBuilder.h:503
GLuint GLenum swizzle
Definition: glext.h:10418
Id makeBoolConstant(bool b, bool specConstant=false)
Definition: SpvBuilder.cpp:695
void createBranch(Block *block)
Definition: SpvBuilder.cpp:2680
void createConditionalBranch(Id condition, Block *thenBlock, Block *elseBlock)
Definition: SpvBuilder.cpp:2708
bool isSpecConstant(Id resultId) const
Definition: SpvBuilder.h:175
void clearAccessChain()
Definition: SpvBuilder.cpp:2279
void addDecoration(Id, Decoration, int num=-1)
Definition: SpvBuilder.cpp:1011
void setLine(int line)
Definition: SpvBuilder.cpp:91
ImageFormat getImageTypeFormat(Id typeId) const
Definition: SpvBuilder.h:147
AddressingModel
Definition: spirv.hpp:79
Id makeSampledImageType(Id imageType)
Definition: SpvBuilder.cpp:486
GLenum GLint GLint * precision
Definition: glext.h:8206
bool isSamplerType(Id typeId) const
Definition: SpvBuilder.h:168
bool isRValue
Definition: SpvBuilder.h:504
Id createLvalueSwizzle(Id typeId, Id target, Id source, const std::vector< unsigned > &channels)
Definition: SpvBuilder.cpp:1479
Id createLoad(Id lValue)
Definition: SpvBuilder.cpp:1206
bool isImageType(Id typeId) const
Definition: SpvBuilder.h:167
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: glext.h:6293
Definition: spirv.hpp:754
Id createCompositeConstruct(Id typeId, const std::vector< Id > &constituents)
Definition: SpvBuilder.cpp:1914
Module module
Definition: SpvBuilder.h:613
~If()
Definition: SpvBuilder.h:396
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
void createLoopMerge(Block *mergeBlock, Block *continueBlock, unsigned int control, unsigned int dependencyLength)
Definition: SpvBuilder.cpp:2696
GLenum const GLvoid * addr
Definition: glext.h:10528
Definition: spvIR.h:164
GLint GLint GLsizei width
Definition: glext.h:6293
Id sample
Definition: SpvBuilder.h:362
int getNumRows(Id resultId) const
Definition: SpvBuilder.h:197
GLdouble GLdouble right
Definition: glext.h:11766
Definition: spirv.hpp:733
void dumpModuleProcesses(std::vector< unsigned int > &) const
Definition: SpvBuilder.cpp:2768
Id createVectorInsertDynamic(Id vector, Id typeId, Id component, Id componentIndex)
Definition: SpvBuilder.cpp:1316
Id createBinOp(Op, Id typeId, Id operand1, Id operand2)
Definition: SpvBuilder.cpp:1383
If & operator=(If &)
Id createTriOp(Op, Id typeId, Id operand1, Id operand2, Id operand3)
Definition: SpvBuilder.cpp:1400
Id createAccessChain(StorageClass, Id base, const std::vector< Id > &offsets)
Definition: SpvBuilder.cpp:1216
Definition: spirv.hpp:737
void addLine(Id fileName, int line, int column)
Definition: SpvBuilder.cpp:100
int getNumColumns(Id resultId) const
Definition: SpvBuilder.h:191
Id gradY
Definition: SpvBuilder.h:361
static const int maxMatrixSize
Definition: SpvBuilder.h:68
Id component
Definition: SpvBuilder.h:502
void setAccessChainRValue(Id rValue)
Definition: SpvBuilder.h:527
GLsizei const GLchar *const * strings
Definition: glext.h:8289
GLuint index
Definition: glext.h:6671