RetroArch
spirv_common.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2015-2018 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SPIRV_CROSS_COMMON_HPP
18 #define SPIRV_CROSS_COMMON_HPP
19 
20 #include "spirv.hpp"
21 
22 #include <algorithm>
23 #include <cstdio>
24 #include <cstring>
25 #include <functional>
26 #include <locale>
27 #include <memory>
28 #include <sstream>
29 #include <stack>
30 #include <stdexcept>
31 #include <stdint.h>
32 #include <string>
33 #include <unordered_map>
34 #include <unordered_set>
35 #include <utility>
36 #include <vector>
37 
38 namespace spirv_cross
39 {
40 
41 #ifdef SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
42 #ifndef _MSC_VER
43 [[noreturn]]
44 #endif
45  inline void
46  report_and_abort(const std::string &msg)
47 {
48 #ifdef NDEBUG
49  (void)msg;
50 #else
51  fprintf(stderr, "There was a compiler error: %s\n", msg.c_str());
52 #endif
53  fflush(stderr);
54  abort();
55 }
56 
57 #define SPIRV_CROSS_THROW(x) report_and_abort(x)
58 #else
59 class CompilerError : public std::runtime_error
60 {
61 public:
63  : std::runtime_error(str)
64  {
65  }
66 };
67 
68 #define SPIRV_CROSS_THROW(x) throw CompilerError(x)
69 #endif
70 
71 #if __cplusplus >= 201402l
72 #define SPIRV_CROSS_DEPRECATED(reason) [[deprecated(reason)]]
73 #elif defined(__GNUC__)
74 #define SPIRV_CROSS_DEPRECATED(reason) __attribute__((deprecated))
75 #elif defined(_MSC_VER)
76 #define SPIRV_CROSS_DEPRECATED(reason) __declspec(deprecated(reason))
77 #else
78 #define SPIRV_CROSS_DEPRECATED(reason)
79 #endif
80 
81 namespace inner
82 {
83 template <typename T>
84 void join_helper(std::ostringstream &stream, T &&t)
85 {
87 }
88 
89 template <typename T, typename... Ts>
90 void join_helper(std::ostringstream &stream, T &&t, Ts &&... ts)
91 {
93  join_helper(stream, std::forward<Ts>(ts)...);
94 }
95 } // namespace inner
96 
97 class Bitset
98 {
99 public:
100  Bitset() = default;
101  explicit inline Bitset(uint64_t lower_)
102  : lower(lower_)
103  {
104  }
105 
106  inline bool get(uint32_t bit) const
107  {
108  if (bit < 64)
109  return (lower & (1ull << bit)) != 0;
110  else
111  return higher.count(bit) != 0;
112  }
113 
114  inline void set(uint32_t bit)
115  {
116  if (bit < 64)
117  lower |= 1ull << bit;
118  else
119  higher.insert(bit);
120  }
121 
122  inline void clear(uint32_t bit)
123  {
124  if (bit < 64)
125  lower &= ~(1ull << bit);
126  else
127  higher.erase(bit);
128  }
129 
130  inline uint64_t get_lower() const
131  {
132  return lower;
133  }
134 
135  inline void reset()
136  {
137  lower = 0;
138  higher.clear();
139  }
140 
141  inline void merge_and(const Bitset &other)
142  {
143  lower &= other.lower;
144  std::unordered_set<uint32_t> tmp_set;
145  for (auto &v : higher)
146  if (other.higher.count(v) != 0)
147  tmp_set.insert(v);
148  higher = std::move(tmp_set);
149  }
150 
151  inline void merge_or(const Bitset &other)
152  {
153  lower |= other.lower;
154  for (auto &v : other.higher)
155  higher.insert(v);
156  }
157 
158  inline bool operator==(const Bitset &other) const
159  {
160  if (lower != other.lower)
161  return false;
162 
163  if (higher.size() != other.higher.size())
164  return false;
165 
166  for (auto &v : higher)
167  if (other.higher.count(v) == 0)
168  return false;
169 
170  return true;
171  }
172 
173  inline bool operator!=(const Bitset &other) const
174  {
175  return !(*this == other);
176  }
177 
178  template <typename Op>
179  void for_each_bit(const Op &op) const
180  {
181  // TODO: Add ctz-based iteration.
182  for (uint32_t i = 0; i < 64; i++)
183  {
184  if (lower & (1ull << i))
185  op(i);
186  }
187 
188  if (higher.empty())
189  return;
190 
191  // Need to enforce an order here for reproducible results,
192  // but hitting this path should happen extremely rarely, so having this slow path is fine.
193  std::vector<uint32_t> bits;
194  bits.reserve(higher.size());
195  for (auto &v : higher)
196  bits.push_back(v);
197  std::sort(std::begin(bits), std::end(bits));
198 
199  for (auto &v : bits)
200  op(v);
201  }
202 
203  inline bool empty() const
204  {
205  return lower == 0 && higher.empty();
206  }
207 
208 private:
209  // The most common bits to set are all lower than 64,
210  // so optimize for this case. Bits spilling outside 64 go into a slower data structure.
211  // In almost all cases, higher data structure will not be used.
213  std::unordered_set<uint32_t> higher;
214 };
215 
216 // Helper template to avoid lots of nasty string temporary munging.
217 template <typename... Ts>
218 std::string join(Ts &&... ts)
219 {
220  std::ostringstream stream;
221  inner::join_helper(stream, std::forward<Ts>(ts)...);
222  return stream.str();
223 }
224 
225 inline std::string merge(const std::vector<std::string> &list)
226 {
227  std::string s;
228  for (auto &elem : list)
229  {
230  s += elem;
231  if (&elem != &list.back())
232  s += ", ";
233  }
234  return s;
235 }
236 
237 template <typename T>
239 {
240  return std::to_string(std::forward<T>(t));
241 }
242 
243 // Allow implementations to set a convenient standard precision
244 #ifndef SPIRV_CROSS_FLT_FMT
245 #define SPIRV_CROSS_FLT_FMT "%.32g"
246 #endif
247 
248 #ifdef _MSC_VER
249 // sprintf warning.
250 // We cannot rely on snprintf existing because, ..., MSVC.
251 #pragma warning(push)
252 #pragma warning(disable : 4996)
253 #endif
254 
256 {
257  // std::to_string for floating point values is broken.
258  // Fallback to something more sane.
259  char buf[64];
261  // Ensure that the literal is float.
262  if (!strchr(buf, '.') && !strchr(buf, 'e'))
263  strcat(buf, ".0");
264  return buf;
265 }
266 
268 {
269  // std::to_string for floating point values is broken.
270  // Fallback to something more sane.
271  char buf[64];
273  // Ensure that the literal is float.
274  if (!strchr(buf, '.') && !strchr(buf, 'e'))
275  strcat(buf, ".0");
276  return buf;
277 }
278 
279 #ifdef _MSC_VER
280 #pragma warning(pop)
281 #endif
282 
284 {
285  Instruction(const std::vector<uint32_t> &spirv, uint32_t &index);
286 
291 };
292 
293 // Helper for Variant interface.
294 struct IVariant
295 {
296  virtual ~IVariant() = default;
297  uint32_t self = 0;
298 };
299 
300 enum Types
301 {
316 };
317 
319 {
320  enum
321  {
323  };
324  SPIRUndef(uint32_t basetype_)
325  : basetype(basetype_)
326  {
327  }
329 };
330 
331 // This type is only used by backends which need to access the combined image and sampler IDs separately after
332 // the OpSampledImage opcode.
334 {
335  enum
336  {
338  };
340  : combined_type(type_)
341  , image(image_)
342  , sampler(sampler_)
343  {
344  }
348 };
349 
351 {
352  enum
353  {
355  };
356 
358  : opcode(op)
359  , arguments(args, args + length)
360  , basetype(result_type)
361  {
362  }
363 
365  std::vector<uint32_t> arguments;
367 };
368 
370 {
371  enum
372  {
374  };
375 
376  enum BaseType
377  {
394  };
395 
396  // Scalar/vector/matrix support.
401 
402  // Arrays, support array of arrays by having a vector of array sizes.
403  std::vector<uint32_t> array;
404 
405  // Array elements can be either specialization constants or specialization ops.
406  // This array determines how to interpret the array size.
407  // If an element is true, the element is a literal,
408  // otherwise, it's an expression, which must be resolved on demand.
409  // The actual size is not really known until runtime.
410  std::vector<bool> array_size_literal;
411 
412  // Pointers
413  bool pointer = false;
415 
416  std::vector<uint32_t> member_types;
417 
418  struct ImageType
419  {
422  bool depth;
423  bool arrayed;
424  bool ms;
428  } image;
429 
430  // Structs can be declared multiple times if they are used as part of interface blocks.
431  // We want to detect this so that we only emit the struct definition once.
432  // Since we cannot rely on OpName to be equal, we need to figure out aliases.
434 
435  // Denotes the type which this type is based on.
436  // Allows the backend to traverse how a complex type is built up during access chains.
438 
439  // Used in backends to avoid emitting members with conflicting names.
440  std::unordered_set<std::string> member_name_cache;
441 };
442 
444 {
445  enum
446  {
448  };
449 
451  {
458  };
459 
461  : ext(ext_)
462  {
463  }
464 
466 };
467 
468 // SPIREntryPoint is not a variant since its IDs are used to decorate OpFunction,
469 // so in order to avoid conflicts, we can't stick them in the ids array.
471 {
472  SPIREntryPoint(uint32_t self_, spv::ExecutionModel execution_model, const std::string &entry_name)
473  : self(self_)
474  , name(entry_name)
475  , orig_name(entry_name)
476  , model(execution_model)
477  {
478  }
479  SPIREntryPoint() = default;
480 
481  uint32_t self = 0;
484  std::vector<uint32_t> interface_variables;
485 
487  struct
488  {
489  uint32_t x = 0, y = 0, z = 0;
490  uint32_t constant = 0; // Workgroup size can be expressed as a constant/spec-constant instead.
491  } workgroup_size;
495 };
496 
498 {
499  enum
500  {
502  };
503 
504  // Only created by the backend target to avoid creating tons of temporaries.
505  SPIRExpression(std::string expr, uint32_t expression_type_, bool immutable_)
506  : expression(move(expr))
507  , expression_type(expression_type_)
508  , immutable(immutable_)
509  {
510  }
511 
512  // If non-zero, prepend expression with to_expression(base_expression).
513  // Used in amortizing multiple calls to to_expression()
514  // where in certain cases that would quickly force a temporary when not needed.
516 
519 
520  // If this expression is a forwarded load,
521  // allow us to reference the original variable.
523 
524  // If this expression will never change, we can avoid lots of temporaries
525  // in high level source.
526  // An expression being immutable can be speculative,
527  // it is assumed that this is true almost always.
528  bool immutable = false;
529 
530  // Before use, this expression must be transposed.
531  // This is needed for targets which don't support row_major layouts.
532  bool need_transpose = false;
533 
534  // A list of expressions which this expression depends on.
535  std::vector<uint32_t> expression_dependencies;
536 };
537 
539 {
540  enum
541  {
543  };
544 
546  : return_type(return_type_)
547  {
548  }
549 
551  std::vector<uint32_t> parameter_types;
552 };
553 
555 {
556  enum
557  {
559  };
560 
562  {
564  Direct, // Emit next block directly without a particular condition.
565 
566  Select, // Block ends with an if/else block.
567  MultiSelect, // Block ends with switch statement.
568 
569  Return, // Block ends with return.
570  Unreachable, // Noop
571  Kill // Discard
572  };
573 
574  enum Merge
575  {
579  };
580 
581  enum Hints
582  {
588  };
589 
590  enum Method
591  {
595  };
596 
598  {
600 
601  // Continue block is branchless and has at least one instruction.
603 
604  // Noop continue block.
606 
607  // Continue block is conditional.
609 
610  // Highly unlikely that anything will use this,
611  // since it is really awkward/impossible to express in GLSL.
613  };
614 
615  enum
616  {
617  NoDominator = 0xffffffffu
618  };
619 
626 
627  uint32_t return_value = 0; // If 0, return nothing (void).
632 
633  std::vector<Instruction> ops;
634 
635  struct Phi
636  {
637  uint32_t local_variable; // flush local variable ...
638  uint32_t parent; // If we're in from_block and want to branch into this block ...
639  uint32_t function_variable; // to this function-global "phi" variable first.
640  };
641 
642  // Before entering this block flush out local variables to magical "phi" variables.
643  std::vector<Phi> phi_variables;
644 
645  // Declare these temporaries before beginning the block.
646  // Used for handling complex continue blocks which have side effects.
647  std::vector<std::pair<uint32_t, uint32_t>> declare_temporary;
648 
649  // Declare these temporaries, but only conditionally if this block turns out to be
650  // a complex loop header.
651  std::vector<std::pair<uint32_t, uint32_t>> potential_declare_temporary;
652 
653  struct Case
654  {
657  };
658  std::vector<Case> cases;
659 
660  // If we have tried to optimize code for this block but failed,
661  // keep track of this.
663 
664  // If the continue block is complex, fallback to "dumb" for loops.
665  bool complex_continue = false;
666 
667  // The dominating block which this block might be within.
668  // Used in continue; blocks to determine if we really need to write continue.
670 
671  // All access to these variables are dominated by this block,
672  // so before branching anywhere we need to make sure that we declare these variables.
673  std::vector<uint32_t> dominated_variables;
674 
675  // These are variables which should be declared in a for loop header, if we
676  // fail to use a classic for-loop,
677  // we remove these variables, and fall back to regular variables outside the loop.
678  std::vector<uint32_t> loop_variables;
679 
680  // Some expressions are control-flow dependent, i.e. any instruction which relies on derivatives or
681  // sub-group-like operations.
682  // Make sure that we only use these expressions in the original block.
683  std::vector<uint32_t> invalidate_expressions;
684 };
685 
687 {
688  enum
689  {
691  };
692 
693  SPIRFunction(uint32_t return_type_, uint32_t function_type_)
694  : return_type(return_type_)
695  , function_type(function_type_)
696  {
697  }
698 
699  struct Parameter
700  {
705 
706  // Set to true if this parameter aliases a global variable,
707  // used mostly in Metal where global variables
708  // have to be passed down to functions as regular arguments.
709  // However, for this kind of variable, we should not care about
710  // read and write counts as access to the function arguments
711  // is not local to the function in question.
713  };
714 
715  // When calling a function, and we're remapping separate image samplers,
716  // resolve these arguments into combined image samplers and pass them
717  // as additional arguments in this order.
718  // It gets more complicated as functions can pull in their own globals
719  // and combine them with parameters,
720  // so we need to distinguish if something is local parameter index
721  // or a global ID.
723  {
729  bool depth;
730  };
731 
734  std::vector<Parameter> arguments;
735 
736  // Can be used by backends to add magic arguments.
737  // Currently used by combined image/sampler implementation.
738 
739  std::vector<Parameter> shadow_arguments;
740  std::vector<uint32_t> local_variables;
742  std::vector<uint32_t> blocks;
743  std::vector<CombinedImageSamplerParameter> combined_parameters;
744 
746  {
747  local_variables.push_back(id);
748  }
749 
750  void add_parameter(uint32_t parameter_type, uint32_t id, bool alias_global_variable = false)
751  {
752  // Arguments are read-only until proven otherwise.
753  arguments.push_back({ parameter_type, id, 0u, 0u, alias_global_variable });
754  }
755 
756  // Statements to be emitted when the function returns.
757  // Mostly used for lowering internal data structures onto flattened structures.
758  std::vector<std::string> fixup_statements_out;
759 
760  // Statements to be emitted when the function begins.
761  // Mostly used for populating internal data structures from flattened structures.
762  std::vector<std::string> fixup_statements_in;
763 
764  bool active = false;
765  bool flush_undeclared = true;
767 };
768 
770 {
771  enum
772  {
774  };
775 
776  SPIRAccessChain(uint32_t basetype_, spv::StorageClass storage_, std::string base_, std::string dynamic_index_,
777  int32_t static_index_)
778  : basetype(basetype_)
779  , storage(storage_)
780  , base(base_)
781  , dynamic_index(std::move(dynamic_index_))
782  , static_index(static_index_)
783  {
784  }
785 
786  // The access chain represents an offset into a buffer.
787  // Some backends need more complicated handling of access chains to be able to use buffers, like HLSL
788  // which has no usable buffer type ala GLSL SSBOs.
789  // StructuredBuffer is too limited, so our only option is to deal with ByteAddressBuffer which works with raw addresses.
790 
796 
799  bool row_major_matrix = false;
800  bool immutable = false;
801 };
802 
804 {
805  enum
806  {
808  };
809 
810  SPIRVariable() = default;
811  SPIRVariable(uint32_t basetype_, spv::StorageClass storage_, uint32_t initializer_ = 0, uint32_t basevariable_ = 0)
812  : basetype(basetype_)
813  , storage(storage_)
814  , initializer(initializer_)
815  , basevariable(basevariable_)
816  {
817  }
818 
824 
825  std::vector<uint32_t> dereference_chain;
826  bool compat_builtin = false;
827 
828  // If a variable is shadowed, we only statically assign to it
829  // and never actually emit a statement for it.
830  // When we read the variable as an expression, just forward
831  // shadowed_id as the expression.
832  bool statically_assigned = false;
834 
835  // Temporaries which can remain forwarded as long as this variable is not modified.
836  std::vector<uint32_t> dependees;
837  bool forwardable = true;
838 
839  bool deferred_declaration = false;
840  bool phi_variable = false;
841  bool remapped_variable = false;
843 
844  // The block which dominates all access to this variable.
846  // If true, this variable is a loop variable, when accessing the variable
847  // outside a loop,
848  // we should statically forward it.
849  bool loop_variable = false;
850  // Set to true while we're inside the for loop.
851  bool loop_variable_enable = false;
852 
854 };
855 
857 {
858  enum
859  {
861  };
862 
863  union Constant {
866  float f32;
867 
870  double f64;
871  };
872 
874  {
876  // If != 0, this element is a specialization constant, and we should keep track of it as such.
877  uint32_t id[4];
879 
880  // Workaround for MSVC 2013, initializing an array breaks.
882  {
883  memset(r, 0, sizeof(r));
884  for (unsigned i = 0; i < 4; i++)
885  id[i] = 0;
886  }
887  };
888 
890  {
892  // If != 0, this column is a specialization constant, and we should keep track of it as such.
893  uint32_t id[4];
895 
896  // Workaround for MSVC 2013, initializing an array breaks.
898  {
899  for (unsigned i = 0; i < 4; i++)
900  id[i] = 0;
901  }
902  };
903 
904  static inline float f16_to_f32(uint16_t u16_value)
905  {
906  // Based on the GLM implementation.
907  int s = (u16_value >> 15) & 0x1;
908  int e = (u16_value >> 10) & 0x1f;
909  int m = (u16_value >> 0) & 0x3ff;
910 
911  union {
912  float f32;
913  uint32_t u32;
914  } u;
915 
916  if (e == 0)
917  {
918  if (m == 0)
919  {
920  u.u32 = uint32_t(s) << 31;
921  return u.f32;
922  }
923  else
924  {
925  while ((m & 0x400) == 0)
926  {
927  m <<= 1;
928  e--;
929  }
930 
931  e++;
932  m &= ~0x400;
933  }
934  }
935  else if (e == 31)
936  {
937  if (m == 0)
938  {
939  u.u32 = (uint32_t(s) << 31) | 0x7f800000u;
940  return u.f32;
941  }
942  else
943  {
944  u.u32 = (uint32_t(s) << 31) | 0x7f800000u | (m << 13);
945  return u.f32;
946  }
947  }
948 
949  e += 127 - 15;
950  m <<= 13;
951  u.u32 = (uint32_t(s) << 31) | (e << 23) | m;
952  return u.f32;
953  }
954 
956  {
957  return m.c[col].id[row];
958  }
959 
961  {
962  return m.id[col];
963  }
964 
965  inline uint32_t scalar(uint32_t col = 0, uint32_t row = 0) const
966  {
967  return m.c[col].r[row].u32;
968  }
969 
970  inline uint16_t scalar_u16(uint32_t col = 0, uint32_t row = 0) const
971  {
972  return uint16_t(m.c[col].r[row].u32 & 0xffffu);
973  }
974 
975  inline float scalar_f16(uint32_t col = 0, uint32_t row = 0) const
976  {
977  return f16_to_f32(scalar_u16(col, row));
978  }
979 
980  inline float scalar_f32(uint32_t col = 0, uint32_t row = 0) const
981  {
982  return m.c[col].r[row].f32;
983  }
984 
985  inline int32_t scalar_i32(uint32_t col = 0, uint32_t row = 0) const
986  {
987  return m.c[col].r[row].i32;
988  }
989 
990  inline double scalar_f64(uint32_t col = 0, uint32_t row = 0) const
991  {
992  return m.c[col].r[row].f64;
993  }
994 
995  inline int64_t scalar_i64(uint32_t col = 0, uint32_t row = 0) const
996  {
997  return m.c[col].r[row].i64;
998  }
999 
1000  inline uint64_t scalar_u64(uint32_t col = 0, uint32_t row = 0) const
1001  {
1002  return m.c[col].r[row].u64;
1003  }
1004 
1005  inline const ConstantVector &vector() const
1006  {
1007  return m.c[0];
1008  }
1009 
1010  inline uint32_t vector_size() const
1011  {
1012  return m.c[0].vecsize;
1013  }
1014 
1015  inline uint32_t columns() const
1016  {
1017  return m.columns;
1018  }
1019 
1020  inline void make_null(const SPIRType &constant_type_)
1021  {
1022  m = {};
1023  m.columns = constant_type_.columns;
1024  for (auto &c : m.c)
1025  c.vecsize = constant_type_.vecsize;
1026  }
1027 
1028  explicit SPIRConstant(uint32_t constant_type_)
1029  : constant_type(constant_type_)
1030  {
1031  }
1032 
1033  SPIRConstant() = default;
1034 
1035  SPIRConstant(uint32_t constant_type_, const uint32_t *elements, uint32_t num_elements, bool specialized)
1036  : constant_type(constant_type_)
1037  , specialization(specialized)
1038  {
1039  subconstants.insert(end(subconstants), elements, elements + num_elements);
1040  specialization = specialized;
1041  }
1042 
1043  // Construct scalar (32-bit).
1044  SPIRConstant(uint32_t constant_type_, uint32_t v0, bool specialized)
1045  : constant_type(constant_type_)
1046  , specialization(specialized)
1047  {
1048  m.c[0].r[0].u32 = v0;
1049  m.c[0].vecsize = 1;
1050  m.columns = 1;
1051  }
1052 
1053  // Construct scalar (64-bit).
1054  SPIRConstant(uint32_t constant_type_, uint64_t v0, bool specialized)
1055  : constant_type(constant_type_)
1056  , specialization(specialized)
1057  {
1058  m.c[0].r[0].u64 = v0;
1059  m.c[0].vecsize = 1;
1060  m.columns = 1;
1061  }
1062 
1063  // Construct vectors and matrices.
1064  SPIRConstant(uint32_t constant_type_, const SPIRConstant *const *vector_elements, uint32_t num_elements,
1065  bool specialized)
1066  : constant_type(constant_type_)
1067  , specialization(specialized)
1068  {
1069  bool matrix = vector_elements[0]->m.c[0].vecsize > 1;
1070 
1071  if (matrix)
1072  {
1073  m.columns = num_elements;
1074 
1075  for (uint32_t i = 0; i < num_elements; i++)
1076  {
1077  m.c[i] = vector_elements[i]->m.c[0];
1078  if (vector_elements[i]->specialization)
1079  m.id[i] = vector_elements[i]->self;
1080  }
1081  }
1082  else
1083  {
1084  m.c[0].vecsize = num_elements;
1085  m.columns = 1;
1086 
1087  for (uint32_t i = 0; i < num_elements; i++)
1088  {
1089  m.c[0].r[i] = vector_elements[i]->m.c[0].r[0];
1090  if (vector_elements[i]->specialization)
1091  m.c[0].id[i] = vector_elements[i]->self;
1092  }
1093  }
1094  }
1095 
1098 
1099  // If this constant is a specialization constant (i.e. created with OpSpecConstant*).
1100  bool specialization = false;
1101  // If this constant is used as an array length which creates specialization restrictions on some backends.
1103 
1104  // If true, this is a LUT, and should always be declared in the outer scope.
1105  bool is_used_as_lut = false;
1106 
1107  // For composites which are constant arrays, etc.
1108  std::vector<uint32_t> subconstants;
1109 };
1110 
1111 class Variant
1112 {
1113 public:
1114  // MSVC 2013 workaround, we shouldn't need these constructors.
1115  Variant() = default;
1116  Variant(Variant &&other)
1117  {
1118  *this = std::move(other);
1119  }
1121  {
1122  if (this != &other)
1123  {
1124  holder = move(other.holder);
1125  type = other.type;
1126  other.type = TypeNone;
1127  }
1128  return *this;
1129  }
1130 
1131  void set(std::unique_ptr<IVariant> val, uint32_t new_type)
1132  {
1133  holder = std::move(val);
1134  if (!allow_type_rewrite && type != TypeNone && type != new_type)
1135  SPIRV_CROSS_THROW("Overwriting a variant with new type.");
1136  type = new_type;
1137  allow_type_rewrite = false;
1138  }
1139 
1140  template <typename T>
1141  T &get()
1142  {
1143  if (!holder)
1144  SPIRV_CROSS_THROW("nullptr");
1145  if (T::type != type)
1146  SPIRV_CROSS_THROW("Bad cast");
1147  return *static_cast<T *>(holder.get());
1148  }
1149 
1150  template <typename T>
1151  const T &get() const
1152  {
1153  if (!holder)
1154  SPIRV_CROSS_THROW("nullptr");
1155  if (T::type != type)
1156  SPIRV_CROSS_THROW("Bad cast");
1157  return *static_cast<const T *>(holder.get());
1158  }
1159 
1161  {
1162  return type;
1163  }
1165  {
1166  return holder ? holder->self : 0;
1167  }
1168  bool empty() const
1169  {
1170  return !holder;
1171  }
1172  void reset()
1173  {
1174  holder.reset();
1175  type = TypeNone;
1176  }
1177 
1179  {
1180  allow_type_rewrite = true;
1181  }
1182 
1183 private:
1184  std::unique_ptr<IVariant> holder;
1186  bool allow_type_rewrite = false;
1187 };
1188 
1189 template <typename T>
1191 {
1192  return var.get<T>();
1193 }
1194 
1195 template <typename T>
1196 const T &variant_get(const Variant &var)
1197 {
1198  return var.get<T>();
1199 }
1200 
1201 template <typename T, typename... P>
1202 T &variant_set(Variant &var, P &&... args)
1203 {
1204  auto uptr = std::unique_ptr<T>(new T(std::forward<P>(args)...));
1205  auto ptr = uptr.get();
1206  var.set(std::move(uptr), T::type);
1207  return *ptr;
1208 }
1209 
1210 struct Meta
1211 {
1212  struct Decoration
1213  {
1228  bool builtin = false;
1229  };
1230 
1232  std::vector<Decoration> members;
1234 
1235  std::unordered_map<uint32_t, uint32_t> decoration_word_offset;
1236 
1237  // Used when the parser has detected a candidate identifier which matches
1238  // known "magic" counter buffers as emitted by HLSL frontends.
1239  // We will need to match the identifiers by name later when reflecting resources.
1240  // We could use the regular alias later, but the alias will be mangled when parsing SPIR-V because the identifier
1241  // is not a valid identifier in any high-level language.
1244 
1245  // For SPV_GOOGLE_hlsl_functionality1, this avoids the workaround.
1247  // ID for the sibling counter buffer.
1249 };
1250 
1251 // A user callback that remaps the type of any variable.
1252 // var_name is the declared name of the variable.
1253 // name_of_type is the textual name of the type which will be used in the code unless written to by the callback.
1255  std::function<void(const SPIRType &type, const std::string &var_name, std::string &name_of_type)>;
1256 
1258 {
1259 public:
1261  {
1262  old = std::locale::global(std::locale::classic());
1263  }
1265  {
1266  std::locale::global(old);
1267  }
1268 
1269 private:
1270  std::locale old;
1271 };
1272 
1273 class Hasher
1274 {
1275 public:
1276  inline void u32(uint32_t value)
1277  {
1278  h = (h * 0x100000001b3ull) ^ value;
1279  }
1280 
1281  inline uint64_t get() const
1282  {
1283  return h;
1284  }
1285 
1286 private:
1287  uint64_t h = 0xcbf29ce484222325ull;
1288 };
1289 
1290 static inline bool type_is_floating_point(const SPIRType &type)
1291 {
1292  return type.basetype == SPIRType::Half || type.basetype == SPIRType::Float || type.basetype == SPIRType::Double;
1293 }
1294 } // namespace spirv_cross
1295 
1296 #endif
Definition: spirv_common.hpp:390
bool active
Definition: spirv_common.hpp:764
std::vector< uint32_t > local_variables
Definition: spirv_common.hpp:740
uint32_t default_block
Definition: spirv_common.hpp:631
void set(std::unique_ptr< IVariant > val, uint32_t new_type)
Definition: spirv_common.hpp:1131
uint32_t static_expression
Definition: spirv_common.hpp:833
Definition: spirv_common.hpp:302
Definition: spirv_common.hpp:418
GLuint const GLchar * name
Definition: glext.h:6671
void u32(uint32_t value)
Definition: spirv_common.hpp:1276
bool alias_global_variable
Definition: spirv_common.hpp:712
Extension ext
Definition: spirv_common.hpp:465
const GLvoid * ptr
Definition: nx_glsym.h:242
spv::StorageClass storage
Definition: spirv_common.hpp:820
Definition: spirv_common.hpp:333
uint32_t false_block
Definition: spirv_common.hpp:630
T & variant_get(Variant &var)
Definition: spirv_common.hpp:1190
spv::ExecutionModel model
Definition: spirv_common.hpp:494
Definition: spirv_common.hpp:1273
std::string merge(const std::vector< std::string > &list)
Definition: spirv_common.hpp:225
int64_t i64
Definition: spirv_common.hpp:869
Definition: spirv_common.hpp:283
void set(uint32_t bit)
Definition: spirv_common.hpp:114
char * strchr(const char *string, int c)
Definition: compat_ctype.c:102
bool empty() const
Definition: spirv_common.hpp:1168
Definition: spirv_common.hpp:1210
GLuint GLfloat * val
Definition: glext.h:7847
set set set set set set set macro pixldst1 op
Definition: pixman-arm-neon-asm.h:54
uint32_t expression_type
Definition: spirv_common.hpp:518
std::vector< uint32_t > dereference_chain
Definition: spirv_common.hpp:825
Definition: spirv.hpp:146
Definition: spirv_common.hpp:617
void make_null(const SPIRType &constant_type_)
Definition: spirv_common.hpp:1020
std::string join(Ts &&... ts)
Definition: spirv_common.hpp:218
std::string dynamic_index
Definition: spirv_common.hpp:794
#define SPIRV_CROSS_THROW(x)
Definition: spirv_common.hpp:68
uint32_t loaded_from
Definition: spirv_common.hpp:522
Definition: spirv_common.hpp:653
bool is_used_as_array_length
Definition: spirv_common.hpp:1102
Extension
Definition: spirv_common.hpp:450
bool immutable
Definition: spirv_common.hpp:800
bool immutable
Definition: spirv_common.hpp:528
std::vector< Instruction > ops
Definition: spirv_common.hpp:633
Definition: spirv_common.hpp:382
Definition: spirv_common.hpp:538
void add_local_variable(uint32_t id)
Definition: spirv_common.hpp:745
uint32_t specialization_constant_id(uint32_t col) const
Definition: spirv_common.hpp:960
std::string to_string(const T &val)
Definition: Common.h:45
#define T(x)
float scalar_f16(uint32_t col=0, uint32_t row=0) const
Definition: spirv_common.hpp:975
Definition: spirv_common.hpp:470
uint32_t set
Definition: spirv_common.hpp:1220
bool do_combined_parameters
Definition: spirv_common.hpp:766
std::vector< CombinedImageSamplerParameter > combined_parameters
Definition: spirv_common.hpp:743
StorageClass
Definition: spirv.hpp:137
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:8418
Definition: spirv_common.hpp:576
std::unique_ptr< IVariant > holder
Definition: spirv_common.hpp:1184
Definition: spirv_common.hpp:453
float f32
Definition: gctypes.h:43
SPIRUndef(uint32_t basetype_)
Definition: spirv_common.hpp:324
bool empty() const
Definition: spirv_common.hpp:203
std::vector< bool > array_size_literal
Definition: spirv_common.hpp:410
Definition: spirv_common.hpp:369
GLdouble GLdouble GLdouble r
Definition: glext.h:6406
void merge_and(const Bitset &other)
Definition: spirv_common.hpp:141
uint32_t combined_type
Definition: spirv_common.hpp:345
GLdouble GLdouble t
Definition: glext.h:6398
uint32_t continue_block
Definition: spirv_common.hpp:625
spv::StorageClass storage
Definition: spirv_common.hpp:792
Definition: spirv_common.hpp:571
Definition: spirv_common.hpp:314
spv::AccessQualifier access
Definition: spirv_common.hpp:427
#define P(a, b, c, d, k, s, t)
std::unordered_set< std::string > member_name_cache
Definition: spirv_common.hpp:440
bool need_transpose
Definition: spirv_common.hpp:532
bool compat_builtin
Definition: spirv_common.hpp:826
SPIRConstant(uint32_t constant_type_)
Definition: spirv_common.hpp:1028
GLenum GLuint id
Definition: glext.h:6233
uint32_t offset
Definition: spirv_common.hpp:289
bool row_major_matrix
Definition: spirv_common.hpp:799
uint32_t function_type
Definition: spirv_common.hpp:733
Definition: spirv_common.hpp:586
uint32_t get_type() const
Definition: spirv_common.hpp:1160
uint32_t columns() const
Definition: spirv_common.hpp:1015
void clear(uint32_t bit)
Definition: spirv_common.hpp:122
Definition: spirv_common.hpp:635
std::vector< uint32_t > blocks
Definition: spirv_common.hpp:742
ConstantVector c[4]
Definition: spirv_common.hpp:891
GLuint GLenum matrix
Definition: glext.h:10314
Definition: spirv_common.hpp:585
GLdouble s
Definition: glext.h:6390
static const struct @115 elements[]
uint64_t get_lower() const
Definition: spirv_common.hpp:130
uint32_t return_type
Definition: spirv_common.hpp:732
static bool type_is_floating_point(const SPIRType &type)
Definition: spirv_common.hpp:1290
GLsizei const GLvoid * pointer
Definition: glext.h:6488
GLdouble GLdouble z
Definition: glext.h:6514
Definition: spirv_common.hpp:380
uint32_t spec_id
Definition: spirv_common.hpp:1226
Definition: spirv_common.hpp:303
Definition: spirv_common.hpp:497
uint32_t get_id() const
Definition: spirv_common.hpp:1164
GLsizei const GLchar *const * string
Definition: glext.h:6699
uint32_t hlsl_magic_counter_buffer
Definition: spirv_common.hpp:1248
#define fprintf
Definition: file_stream_transforms.h:62
std::vector< Decoration > members
Definition: spirv_common.hpp:1232
uint32_t loop_dominator
Definition: spirv_common.hpp:669
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
std::vector< uint32_t > dependees
Definition: spirv_common.hpp:836
std::string convert_to_string(T &&t)
Definition: spirv_common.hpp:238
bool disable_block_optimization
Definition: spirv_common.hpp:662
uint32_t constant
Definition: spirv_common.hpp:490
bool builtin
Definition: spirv_common.hpp:1228
uint32_t self
Definition: spirv_common.hpp:297
Definition: spirv_common.hpp:567
Variant(Variant &&other)
Definition: spirv_common.hpp:1116
uint32_t vecsize
Definition: spirv_common.hpp:878
uint32_t basevariable
Definition: spirv_common.hpp:823
void for_each_bit(const Op &op) const
Definition: spirv_common.hpp:179
std::vector< uint32_t > member_types
Definition: spirv_common.hpp:416
SPIRVariable(uint32_t basetype_, spv::StorageClass storage_, uint32_t initializer_=0, uint32_t basevariable_=0)
Definition: spirv_common.hpp:811
std::string hlsl_semantic
Definition: spirv_common.hpp:1216
Definition: spirv_common.hpp:452
Definition: spirv_common.hpp:305
std::vector< Parameter > shadow_arguments
Definition: spirv_common.hpp:739
ClassicLocale()
Definition: spirv_common.hpp:1260
BaseType basetype
Definition: spirv_common.hpp:397
void reset()
Definition: spirv_common.hpp:1172
struct spirv_cross::SPIRType::ImageType image
Bitset flags
Definition: spirv_common.hpp:486
const GLubyte * c
Definition: glext.h:9812
uint32_t basetype
Definition: spirv_common.hpp:366
std::vector< uint32_t > subconstants
Definition: spirv_common.hpp:1108
uint32_t true_block
Definition: spirv_common.hpp:629
std::vector< uint32_t > loop_variables
Definition: spirv_common.hpp:678
uint32_t array_stride
Definition: spirv_common.hpp:1223
void join_helper(std::ostringstream &stream, T &&t)
Definition: spirv_common.hpp:84
std::unordered_set< uint32_t > higher
Definition: spirv_common.hpp:213
int32_t i32
Definition: spirv_common.hpp:865
uint32_t input_attachment
Definition: spirv_common.hpp:1225
Definition: spirv_common.hpp:593
uint32_t vecsize
Definition: spirv_common.hpp:399
GLint location
Definition: glext.h:6690
void reset()
Definition: spirv_common.hpp:135
uint32_t return_type
Definition: spirv_common.hpp:550
Definition: spirv_common.hpp:312
bool is_used_as_lut
Definition: spirv_common.hpp:1105
double f64
Definition: spirv_common.hpp:870
bool global_sampler
Definition: spirv_common.hpp:728
spv::Op opcode
Definition: spirv_common.hpp:364
Definition: spirv_common.hpp:583
bool allow_type_rewrite
Definition: spirv_common.hpp:1186
SPIRFunction(uint32_t return_type_, uint32_t function_type_)
Definition: spirv_common.hpp:693
float f32
Definition: spirv_common.hpp:866
uint64_t h
Definition: spirv_common.hpp:1287
Definition: spirv_common.hpp:584
std::unordered_map< uint32_t, uint32_t > decoration_word_offset
Definition: spirv_common.hpp:1235
GLenum type
Definition: glext.h:6233
T & variant_set(Variant &var, P &&... args)
Definition: spirv_common.hpp:1202
struct spirv_cross::SPIREntryPoint::@146 workgroup_size
Decoration decoration
Definition: spirv_common.hpp:1231
uint32_t dominator
Definition: spirv_common.hpp:845
spv::Dim dim
Definition: spirv_common.hpp:421
uint32_t type
Definition: spirv_common.hpp:420
CompilerError(const std::string &str)
Definition: spirv_common.hpp:62
bool global_image
Definition: spirv_common.hpp:727
uint32_t sampler
Definition: spirv_common.hpp:347
uint32_t base_expression
Definition: spirv_common.hpp:515
uint64_t u64
Definition: spirv_common.hpp:868
Definition: spirv_common.hpp:577
Definition: barrier.hpp:23
Merge
Definition: spirv_common.hpp:574
Definition: spirv_common.hpp:563
Definition: spirv_common.hpp:570
bool specialization
Definition: spirv_common.hpp:1100
Op
Definition: spirv.hpp:714
std::function< void(const SPIRType &type, const std::string &var_name, std::string &name_of_type)> VariableTypeRemapCallback
Definition: spirv_common.hpp:1255
Definition: spirv_common.hpp:592
spv::ImageFormat format
Definition: spirv_common.hpp:426
Definition: spirv_common.hpp:587
std::string expression
Definition: spirv_common.hpp:517
std::vector< std::pair< uint32_t, uint32_t > > declare_temporary
Definition: spirv_common.hpp:647
std::string hlsl_magic_counter_buffer_name
Definition: spirv_common.hpp:1242
virtual ~IVariant()=default
static float f16_to_f32(uint16_t u16_value)
Definition: spirv_common.hpp:904
bool remapped_variable
Definition: spirv_common.hpp:841
bool complex_continue
Definition: spirv_common.hpp:665
uint32_t u32
Definition: spirv_common.hpp:864
std::vector< uint32_t > expression_dependencies
Definition: spirv_common.hpp:535
Definition: spirv_common.hpp:315
#define fflush
Definition: file_stream_transforms.h:61
uint32_t matrix_stride
Definition: spirv_common.hpp:798
ConstantVector()
Definition: spirv_common.hpp:881
std::vector< uint32_t > interface_variables
Definition: spirv_common.hpp:484
bool depth
Definition: spirv_common.hpp:422
uint32_t write_count
Definition: spirv_common.hpp:704
SPIRConstantOp(uint32_t result_type, spv::Op op, const uint32_t *args, uint32_t length)
Definition: spirv_common.hpp:357
GLfloat v0
Definition: glext.h:6701
SPIRConstant(uint32_t constant_type_, const uint32_t *elements, uint32_t num_elements, bool specialized)
Definition: spirv_common.hpp:1035
bool hlsl_magic_counter_buffer_candidate
Definition: spirv_common.hpp:1243
void add_parameter(uint32_t parameter_type, uint32_t id, bool alias_global_variable=false)
Definition: spirv_common.hpp:750
uint32_t id
Definition: spirv_common.hpp:724
uint32_t type_alias
Definition: spirv_common.hpp:433
std::string alias
Definition: spirv_common.hpp:1214
static const unsigned char msg[]
Definition: ccm.c:375
bool operator!=(const Bitset &other) const
Definition: spirv_common.hpp:173
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:6305
Definition: spirv_common.hpp:602
int32_t static_index
Definition: spirv_common.hpp:795
uint32_t output_vertices
Definition: spirv_common.hpp:493
bool loop_variable_enable
Definition: spirv_common.hpp:851
Definition: spirv_common.hpp:313
Definition: spirv_common.hpp:566
Definition: spirv_common.hpp:873
GLint GLint GLint GLint GLint GLint y
Definition: glext.h:6295
Definition: spirv_common.hpp:381
Definition: spirv_common.hpp:387
Definition: spirv_common.hpp:304
uint32_t invocations
Definition: spirv_common.hpp:492
bool loop_variable
Definition: spirv_common.hpp:849
uint32_t basetype
Definition: spirv_common.hpp:791
uint32_t remapped_components
Definition: spirv_common.hpp:842
GLint GLint GLint GLint GLint x
Definition: glext.h:6295
bool deferred_declaration
Definition: spirv_common.hpp:839
void merge_or(const Bitset &other)
Definition: spirv_common.hpp:151
uint32_t binding
Definition: spirv_common.hpp:1221
GLenum GLenum GLvoid * row
Definition: glext.h:6316
AccessQualifier
Definition: spirv.hpp:325
dictionary args
Definition: test_shaders.py:20
const ConstantVector & vector() const
Definition: spirv_common.hpp:1005
std::vector< std::string > fixup_statements_out
Definition: spirv_common.hpp:758
std::vector< Parameter > arguments
Definition: spirv_common.hpp:734
int sprintf(char *s, const char *format,...)
Definition: compat_ctype.c:81
SPIRConstant(uint32_t constant_type_, uint64_t v0, bool specialized)
Definition: spirv_common.hpp:1054
Variant & operator=(Variant &&other)
Definition: spirv_common.hpp:1120
Definition: spirv_common.hpp:383
SPIRFunctionPrototype(uint32_t return_type_)
Definition: spirv_common.hpp:545
std::vector< uint32_t > invalidate_expressions
Definition: spirv_common.hpp:683
std::vector< Phi > phi_variables
Definition: spirv_common.hpp:643
uint32_t image
Definition: spirv_common.hpp:346
signed int int32_t
Definition: stdint.h:123
ExecutionModel
Definition: spirv.hpp:68
~ClassicLocale()
Definition: spirv_common.hpp:1264
std::vector< std::string > fixup_statements_in
Definition: spirv_common.hpp:762
uint32_t columns
Definition: spirv_common.hpp:400
Definition: spirv_common.hpp:569
Definition: spirv_common.hpp:318
bool ms
Definition: spirv_common.hpp:424
spv::StorageClass storage
Definition: spirv_common.hpp:414
#define SPIRV_CROSS_FLT_FMT
Definition: spirv_common.hpp:245
Definition: spirv_common.hpp:1257
Definition: spirv_common.hpp:457
Merge merge
Definition: spirv_common.hpp:621
uint32_t id[4]
Definition: spirv_common.hpp:877
std::string name
Definition: spirv_common.hpp:482
Definition: spirv_common.hpp:309
Hints hint
Definition: spirv_common.hpp:622
Constant r[4]
Definition: spirv_common.hpp:875
GLuint index
Definition: glext.h:6671
uint32_t id
Definition: spirv_common.hpp:702
uint32_t length
Definition: spirv_common.hpp:290
std::vector< uint32_t > array
Definition: spirv_common.hpp:403
std::vector< uint32_t > arguments
Definition: spirv_common.hpp:365
bool operator==(const Bitset &other) const
Definition: spirv_common.hpp:158
uint32_t merge_block
Definition: spirv_common.hpp:624
static int sort(lua_State *L)
Definition: ltablib.c:411
std::string orig_name
Definition: spirv_common.hpp:483
ConstantMatrix m
Definition: spirv_common.hpp:1097
const GLdouble * v
Definition: glext.h:6391
std::vector< Case > cases
Definition: spirv_common.hpp:658
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:11836
uint32_t local_variable
Definition: spirv_common.hpp:637
uint32_t sampled
Definition: spirv_common.hpp:425
Definition: spirv_common.hpp:307
u32 col
Definition: gx_regdef.h:5093
GLuint GLuint stream
Definition: glext.h:8189
bool get(uint32_t bit) const
Definition: spirv_common.hpp:106
Definition: spirv_common.hpp:803
Definition: spirv_common.hpp:385
Definition: spirv_common.hpp:443
uint32_t scalar(uint32_t col=0, uint32_t row=0) const
Definition: spirv_common.hpp:965
uint32_t block
Definition: spirv_common.hpp:656
uint32_t read_count
Definition: spirv_common.hpp:703
ConstantMatrix()
Definition: spirv_common.hpp:897
Definition: spirv_common.hpp:384
Definition: spirv_common.hpp:392
uint16_t op
Definition: spirv_common.hpp:287
Bitset(uint64_t lower_)
Definition: spirv_common.hpp:101
Definition: spirv_common.hpp:605
uint64_t lower
Definition: spirv_common.hpp:212
Definition: spirv_common.hpp:388
Definition: spirv_common.hpp:699
Terminator
Definition: spirv_common.hpp:561
GLint GLint GLsizei width
Definition: glext.h:6293
uint32_t constant_type
Definition: spirv_common.hpp:1096
std::vector< uint32_t > dominated_variables
Definition: spirv_common.hpp:673
SPIRConstant(uint32_t constant_type_, const SPIRConstant *const *vector_elements, uint32_t num_elements, bool specialized)
Definition: spirv_common.hpp:1064
uint16_t count
Definition: spirv_common.hpp:288
bool forwardable
Definition: spirv_common.hpp:837
Definition: spirv_common.hpp:306
uint32_t vector_size() const
Definition: spirv_common.hpp:1010
uint16_t scalar_u16(uint32_t col=0, uint32_t row=0) const
Definition: spirv_common.hpp:970
signed __int64 int64_t
Definition: stdint.h:135
Definition: spirv_common.hpp:308
Definition: spirv_common.hpp:393
uint32_t loaded_from
Definition: spirv_common.hpp:797
uint32_t basetype
Definition: spirv_common.hpp:328
GLenum condition
Definition: glext.h:10162
void set_allow_type_rewrite()
Definition: spirv_common.hpp:1178
bool statically_assigned
Definition: spirv_common.hpp:832
uint64_t get() const
Definition: spirv_common.hpp:1281
uint32_t decoration
Definition: spirv_common.hpp:821
uint32_t columns
Definition: spirv_common.hpp:894
Definition: spirv_common.hpp:97
std::string base
Definition: spirv_common.hpp:793
BaseType
Definition: spirv_common.hpp:376
Definition: spirv_common.hpp:1111
GLsizei const GLfloat * value
Definition: glext.h:6709
SPIREntryPoint(uint32_t self_, spv::ExecutionModel execution_model, const std::string &entry_name)
Definition: spirv_common.hpp:472
Definition: spirv_common.hpp:554
uint32_t basetype
Definition: spirv_common.hpp:819
uint64_t scalar_u64(uint32_t col=0, uint32_t row=0) const
Definition: spirv_common.hpp:1000
uint32_t value
Definition: spirv_common.hpp:655
std::locale old
Definition: spirv_common.hpp:1270
Definition: spirv_common.hpp:378
BuiltIn
Definition: spirv.hpp:402
Definition: Common.h:43
uint32_t image_id
Definition: spirv_common.hpp:725
Dim
Definition: spirv.hpp:154
uint32_t function_variable
Definition: spirv_common.hpp:639
Definition: spirv_common.hpp:863
static void expr(LexState *ls, expdesc *v)
Definition: lparser.c:1078
uint32_t matrix_stride
Definition: spirv_common.hpp:1224
Definition: spirv_common.hpp:386
uint32_t initializer
Definition: spirv_common.hpp:822
Definition: spirv_common.hpp:769
bool hlsl_is_magic_counter_buffer
Definition: spirv_common.hpp:1246
GLuint GLuint end
Definition: glext.h:6292
bool depth
Definition: spirv_common.hpp:729
SPIRConstant(uint32_t constant_type_, uint32_t v0, bool specialized)
Definition: spirv_common.hpp:1044
Definition: spirv_common.hpp:389
Terminator terminator
Definition: spirv_common.hpp:620
Definition: spirv_common.hpp:686
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:8390
static enum msg_hash_enums new_type
Definition: menu_displaylist.c:99
int64_t scalar_i64(uint32_t col=0, uint32_t row=0) const
Definition: spirv_common.hpp:995
spv::BuiltIn builtin_type
Definition: spirv_common.hpp:1218
std::string qualified_alias
Definition: spirv_common.hpp:1215
GLuint sampler
Definition: glext.h:7950
Definition: spirv_common.hpp:311
GLintptr offset
Definition: glext.h:6560
Definition: spirv_common.hpp:564
Definition: spirv_common.hpp:310
Definition: x_ctx.c:119
Bitset decoration_flags
Definition: spirv_common.hpp:1217
uint32_t parent_type
Definition: spirv_common.hpp:437
Definition: spirv_common.hpp:350
const T & get() const
Definition: spirv_common.hpp:1151
SPIRExtension(Extension ext_)
Definition: spirv_common.hpp:460
std::vector< std::pair< uint32_t, uint32_t > > potential_declare_temporary
Definition: spirv_common.hpp:651
Definition: spirv_common.hpp:578
Definition: spirv_common.hpp:391
uint32_t next_block
Definition: spirv_common.hpp:623
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
uint32_t type
Definition: spirv_common.hpp:701
Definition: spirv_common.hpp:294
unsigned short uint16_t
Definition: stdint.h:125
void * memset(void *b, int c, size_t len)
Definition: string.c:7
int32_t scalar_i32(uint32_t col=0, uint32_t row=0) const
Definition: spirv_common.hpp:985
ContinueBlockType
Definition: spirv_common.hpp:597
Definition: spirv_common.hpp:1212
unsigned __int64 uint64_t
Definition: stdint.h:136
bool arrayed
Definition: spirv_common.hpp:423
GLenum GLuint GLenum GLsizei length
Definition: glext.h:6233
uint32_t specialization_constant_id(uint32_t col, uint32_t row) const
Definition: spirv_common.hpp:955
Definition: spirv_common.hpp:379
T & get()
Definition: spirv_common.hpp:1141
Definition: spirv_common.hpp:612
unsigned int uint32_t
Definition: stdint.h:126
uint32_t parent
Definition: spirv_common.hpp:638
Definition: spirv_common.hpp:59
Types
Definition: spirv_common.hpp:300
const GLfloat * m
Definition: glext.h:11755
uint32_t self
Definition: spirv_common.hpp:481
SPIRAccessChain(uint32_t basetype_, spv::StorageClass storage_, std::string base_, std::string dynamic_index_, int32_t static_index_)
Definition: spirv_common.hpp:776
uint32_t type
Definition: spirv_common.hpp:1185
Instruction(const std::vector< uint32_t > &spirv, uint32_t &index)
Definition: spirv_common.hpp:889
SPIRFunction::Parameter * parameter
Definition: spirv_common.hpp:853
const char *const str
Definition: portlistingparse.c:18
uint32_t entry_block
Definition: spirv_common.hpp:741
bool flush_undeclared
Definition: spirv_common.hpp:765
ImageFormat
Definition: spirv.hpp:180
char * strcat(char *dest, const char *src)
Definition: compat_ctype.c:91
std::vector< uint32_t > parameter_types
Definition: spirv_common.hpp:551
SPIRExpression(std::string expr, uint32_t expression_type_, bool immutable_)
Definition: spirv_common.hpp:505
Definition: spirv_common.hpp:856
Definition: spirv_common.hpp:608
Method
Definition: spirv_common.hpp:590
uint32_t sampler_id
Definition: spirv_common.hpp:726
float scalar_f32(uint32_t col=0, uint32_t row=0) const
Definition: spirv_common.hpp:980
SPIRCombinedImageSampler(uint32_t type_, uint32_t image_, uint32_t sampler_)
Definition: spirv_common.hpp:339
double scalar_f64(uint32_t col=0, uint32_t row=0) const
Definition: spirv_common.hpp:990
bool phi_variable
Definition: spirv_common.hpp:840
Definition: spirv_common.hpp:599
uint32_t return_value
Definition: spirv_common.hpp:627