RetroArch
spirv_msl.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2018 The Brenwill Workshop Ltd.
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_MSL_HPP
18 #define SPIRV_CROSS_MSL_HPP
19 
20 #include "spirv_glsl.hpp"
21 #include <stdint.h>
22 #include <limits>
23 #include <map>
24 #include <set>
25 #include <unordered_map>
26 #include <unordered_set>
27 #include <vector>
28 
29 namespace spirv_cross
30 {
31 
32 // Defines MSL characteristics of a vertex attribute at a particular location.
33 // The used_by_shader flag is set to true during compilation of SPIR-V to MSL
34 // if the shader makes use of this vertex attribute.
36 {
41  bool per_instance = false;
42  bool used_by_shader = false;
43 };
44 
45 // Matches the binding index of a MSL resource for a binding within a descriptor set.
46 // Taken together, the stage, desc_set and binding combine to form a reference to a resource
47 // descriptor used in a particular shading stage. Generally, only one of the buffer, texture,
48 // or sampler elements will be populated. The used_by_shader flag is set to true during
49 // compilation of SPIR-V to MSL if the shader makes use of this vertex attribute.
51 {
55 
59 
60  bool used_by_shader = false;
61 };
62 
64 {
67 };
68 
70 {
73 };
74 
76 {
80 };
81 
83 {
89 };
90 
92 {
101 };
102 
104 {
108 };
109 
111 {
121  float lod_clamp_min = 0.0f;
122  float lod_clamp_max = 1000.0f;
123  int max_anisotropy = 1;
124 
125  bool compare_enable = false;
126  bool lod_clamp_enable = false;
127  bool anisotropy_enable = false;
128 };
129 
130 // Tracks the type ID and member index of a struct member
132 
133 // Special constant used in a MSLResourceBinding desc_set
134 // element to indicate the bindings for the push constants.
135 static const uint32_t kPushConstDescSet = ((uint32_t)-1);
136 
137 // Special constant used in a MSLResourceBinding binding
138 // element to indicate the bindings for the push constants.
139 static const uint32_t kPushConstBinding = 0;
140 
141 // Decompiles SPIR-V to Metal Shading Language
142 class CompilerMSL : public CompilerGLSL
143 {
144 public:
145  // Options for compiling to Metal Shading Language
146  struct Options
147  {
148  typedef enum
149  {
152  } Platform;
153 
156  uint32_t texel_buffer_texture_width = 4096; // Width of 2D Metal textures used as 1D texel buffers
159 
160  bool is_ios()
161  {
162  return platform == iOS;
163  }
164 
165  bool is_macos()
166  {
167  return platform == macOS;
168  }
169 
170  void set_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0)
171  {
172  msl_version = make_msl_version(major, minor, patch);
173  }
174 
175  bool supports_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0)
176  {
177  return msl_version >= make_msl_version(major, minor, patch);
178  }
179 
180  static uint32_t make_msl_version(uint32_t major, uint32_t minor = 0, uint32_t patch = 0)
181  {
182  return (major * 10000) + (minor * 100) + patch;
183  }
184  };
185 
186  SPIRV_CROSS_DEPRECATED("CompilerMSL::get_options() is obsolete, use get_msl_options() instead.")
187  const Options &get_options() const
188  {
189  return msl_options;
190  }
191 
192  const Options &get_msl_options() const
193  {
194  return msl_options;
195  }
196 
197  SPIRV_CROSS_DEPRECATED("CompilerMSL::set_options() is obsolete, use set_msl_options() instead.")
198  void set_options(Options &opts)
199  {
200  msl_options = opts;
201  }
202 
203  void set_msl_options(const Options &opts)
204  {
205  msl_options = opts;
206  }
207 
208  // An enum of SPIR-V functions that are implemented in additional
209  // source code that is added to the shader if necessary.
211  {
230  };
231 
232  // Constructs an instance to compile the SPIR-V code into Metal Shading Language,
233  // using the configuration parameters, if provided:
234  // - p_vtx_attrs is an optional list of vertex attribute bindings used to match
235  // vertex content locations to MSL attributes. If vertex attributes are provided,
236  // the compiler will set the used_by_shader flag to true in any vertex attribute
237  // actually used by the MSL code.
238  // - p_res_bindings is a list of resource bindings to indicate the MSL buffer,
239  // texture or sampler index to use for a particular SPIR-V description set
240  // and binding. If resource bindings are provided, the compiler will set the
241  // used_by_shader flag to true in any resource binding actually used by the MSL code.
242  CompilerMSL(std::vector<uint32_t> spirv, std::vector<MSLVertexAttr> *p_vtx_attrs = nullptr,
243  std::vector<MSLResourceBinding> *p_res_bindings = nullptr);
244 
245  // Alternate constructor avoiding use of std::vectors.
246  CompilerMSL(const uint32_t *ir, size_t word_count, MSLVertexAttr *p_vtx_attrs = nullptr, size_t vtx_attrs_count = 0,
247  MSLResourceBinding *p_res_bindings = nullptr, size_t res_bindings_count = 0);
248 
249  // Compiles the SPIR-V code into Metal Shading Language.
250  std::string compile() override;
251 
252  // Compiles the SPIR-V code into Metal Shading Language, overriding configuration parameters.
253  // Any of the parameters here may be null to indicate that the configuration provided in the
254  // constructor should be used. They are not declared as optional to avoid a conflict with the
255  // inherited and overridden zero-parameter compile() function.
256  std::string compile(std::vector<MSLVertexAttr> *p_vtx_attrs, std::vector<MSLResourceBinding> *p_res_bindings);
257 
258  // This legacy method is deprecated.
260  SPIRV_CROSS_DEPRECATED("Please use get_msl_options() and set_msl_options() instead.")
261  std::string compile(MSLConfiguration &msl_cfg, std::vector<MSLVertexAttr> *p_vtx_attrs = nullptr,
262  std::vector<MSLResourceBinding> *p_res_bindings = nullptr);
263 
264  // Remap a sampler with ID to a constexpr sampler.
265  // Older iOS targets must use constexpr samplers in certain cases (PCF),
266  // so a static sampler must be used.
267  // The sampler will not consume a binding, but be declared in the entry point as a constexpr sampler.
268  // This can be used on both combined image/samplers (sampler2D) or standalone samplers.
269  // The remapped sampler must not be an array of samplers.
271 
272 protected:
273  void emit_instruction(const Instruction &instr) override;
274  void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args,
275  uint32_t count) override;
276  void emit_header() override;
277  void emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) override;
278  void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override;
279  void emit_fixup() override;
281  const std::string &qualifier = "", uint32_t base_offset = 0) override;
282  std::string type_to_glsl(const SPIRType &type, uint32_t id = 0) override;
283  std::string image_type_glsl(const SPIRType &type, uint32_t id = 0) override;
284  std::string sampler_type(const SPIRType &type);
285  std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override;
286  std::string constant_expression(const SPIRConstant &c) override;
287  size_t get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const override;
288  std::string to_func_call_arg(uint32_t id) override;
289  std::string to_name(uint32_t id, bool allow_alias = true) const override;
290  std::string to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj,
291  bool has_array_offsets, bool has_offset, bool has_grad, bool has_dref,
292  uint32_t lod) override;
293  std::string to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj,
294  uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x,
296  uint32_t comp, uint32_t sample, bool *p_forward) override;
297  std::string to_initializer_expression(const SPIRVariable &var) override;
298  std::string unpack_expression_type(std::string expr_str, const SPIRType &type) override;
299  std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type) override;
300  bool skip_argument(uint32_t id) const override;
301  std::string to_qualifiers_glsl(uint32_t id) override;
302  void replace_illegal_names() override;
303  void declare_undefined_values() override;
305  bool is_non_native_row_major_matrix(uint32_t id) override;
307  std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type, bool is_packed) override;
308 
309  void preprocess_op_codes();
313  void mark_packable_structs();
315 
317  void extract_global_variables_from_function(uint32_t func_id, std::set<uint32_t> &added_arg_ids,
318  std::unordered_set<uint32_t> &global_var_ids,
319  std::unordered_set<uint32_t> &processed_func_ids);
323 
324  void emit_custom_functions();
325  void emit_resources();
327  void emit_interface_block(uint32_t ib_var_id);
329  bool maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs);
331 
332  std::string func_type_decl(SPIRType &type);
333  std::string entry_point_args(bool append_comma);
335  std::string ensure_valid_name(std::string name, std::string pfx);
336  std::string to_sampler_expression(uint32_t id);
339  std::string built_in_func_arg(spv::BuiltIn builtin, bool prefix_comma);
341  std::string argument_decl(const SPIRFunction::Parameter &arg);
342  std::string round_fp_tex_coords(std::string tex_coords, bool coord_is_fp);
343  uint32_t get_metal_resource_index(SPIRVariable &var, SPIRType::BaseType basetype);
346  std::string to_component_argument(uint32_t id);
347  void align_struct(SPIRType &ib_type);
348  bool is_member_packable(SPIRType &ib_type, uint32_t index);
351  void emit_atomic_func_op(uint32_t result_type, uint32_t result_id, const char *op, uint32_t mem_order_1,
352  uint32_t mem_order_2, bool has_mem_order_2, uint32_t op0, uint32_t op1 = 0,
353  bool op1_is_pointer = false, uint32_t op2 = 0);
354  const char *get_memory_order(uint32_t spv_mem_sem);
355  void add_pragma_line(const std::string &line);
356  void add_typedef_line(const std::string &line);
357  void emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem);
358  void emit_array_copy(const std::string &lhs, uint32_t rhs_id) override;
360  void emit_entry_point_declarations() override;
362 
363  void bitcast_to_builtin_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type) override;
364  void bitcast_from_builtin_load(uint32_t source_id, std::string &expr, const SPIRType &expr_type) override;
365 
370  std::set<std::string> pragma_lines;
381  std::string stage_in_var_name = "in";
383  std::string stage_uniform_var_name = "uniforms";
384  std::string sampler_name_suffix = "Smplr";
386 
388 
389  // OpcodeHandler that handles several MSL preprocessing operations.
390  struct OpCodePreprocessor : OpcodeHandler
391  {
393  : compiler(compiler_)
394  {
395  }
396 
397  bool handle(spv::Op opcode, const uint32_t *args, uint32_t length) override;
398  CompilerMSL::SPVFuncImpl get_spv_func_impl(spv::Op opcode, const uint32_t *args);
399 
401  std::unordered_map<uint32_t, uint32_t> result_types;
402  bool suppress_missing_prototypes = false;
403  bool uses_atomics = false;
404  };
405 
406  // Sorts the members of a SPIRType and associated Meta info based on a settable sorting
407  // aspect, which defines which aspect of the struct members will be used to sort them.
408  // Regardless of the sorting aspect, built-in members always appear at the end of the struct.
410  {
412  {
418  };
419 
420  void sort();
421  bool operator()(uint32_t mbr_idx1, uint32_t mbr_idx2);
423 
427  };
428 };
429 } // namespace spirv_cross
430 
431 #endif
uint32_t stage_uniforms_var_id
Definition: spirv_msl.hpp:377
Definition: spirv_msl.hpp:151
Definition: spirv_msl.hpp:35
std::string round_fp_tex_coords(std::string tex_coords, bool coord_is_fp)
uint32_t builtin_frag_coord_id
Definition: spirv_msl.hpp:361
SPIRV_CROSS_DEPRECATED("CompilerMSL::get_options() is obsolete, use get_msl_options() instead.") const Options &get_options() const
Definition: spirv_msl.hpp:186
GLuint const GLchar * name
Definition: glext.h:6671
std::string convert_row_major_matrix(std::string exp_str, const SPIRType &exp_type, bool is_packed) override
std::set< SPVFuncImpl > spv_function_implementations
Definition: spirv_msl.hpp:367
bool needs_instance_idx_arg
Definition: spirv_msl.hpp:379
void set_msl_version(uint32_t major, uint32_t minor=0, uint32_t patch=0)
Definition: spirv_msl.hpp:170
void align_struct(SPIRType &ib_type)
Definition: spirv_msl.cpp:944
void emit_sampled_image_op(uint32_t result_type, uint32_t result_id, uint32_t image_id, uint32_t samp_id) override
Definition: spirv_common.hpp:283
Definition: spirv_msl.hpp:150
#define const
Definition: zconf.h:217
std::string member_attribute_qualifier(const SPIRType &type, uint32_t index)
void emit_entry_point_declarations() override
Definition: spirv_msl.cpp:126
Definition: spirv_glsl.hpp:56
Definition: spirv_common.hpp:1210
set set set set set set set macro pixldst1 op
Definition: pixman-arm-neon-asm.h:54
std::string argument_decl(const SPIRFunction::Parameter &arg)
uint32_t binding
Definition: spirv_msl.hpp:54
std::unordered_map< MSLStructMemberKey, uint32_t > struct_member_padding
Definition: spirv_msl.hpp:369
void declare_constant_arrays()
Definition: spirv_msl.cpp:1407
void emit_atomic_func_op(uint32_t result_type, uint32_t result_id, const char *op, uint32_t mem_order_1, uint32_t mem_order_2, bool has_mem_order_2, uint32_t op0, uint32_t op1=0, bool op1_is_pointer=false, uint32_t op2=0)
std::unordered_map< uint32_t, uint32_t > result_types
Definition: spirv_msl.hpp:401
Definition: disassemble.cpp:50
uint32_t add_interface_block(spv::StorageClass storage)
Definition: spirv_msl.cpp:645
Definition: spirv_msl.hpp:110
MSLSamplerBorderColor
Definition: spirv_msl.hpp:103
Platform platform
Definition: spirv_msl.hpp:154
MSLSamplerCompareFunc compare_func
Definition: spirv_msl.hpp:119
StorageClass
Definition: spirv.hpp:137
void emit_specialization_constants()
Definition: spirv_msl.cpp:1481
Meta & meta
Definition: spirv_msl.hpp:425
void add_typedef_line(const std::string &line)
Definition: spirv_msl.cpp:1083
SPIRV_CROSS_DEPRECATED("Please use get_msl_options() and set_msl_options() instead.") std void remap_constexpr_sampler(uint32_t id, const MSLConstexprSampler &sampler)
Options msl_options
Definition: spirv_msl.hpp:366
Definition: spirv_common.hpp:369
GLdouble GLdouble t
Definition: glext.h:6398
void preprocess_op_codes()
Definition: spirv_msl.cpp:366
Definition: spirv_msl.hpp:66
uint32_t msl_buffer
Definition: spirv_msl.hpp:56
std::set< std::string > pragma_lines
Definition: spirv_msl.hpp:370
std::string get_argument_address_space(const SPIRVariable &argument)
Definition: spirv_msl.hpp:79
void emit_resources()
Definition: spirv_msl.cpp:1435
std::string to_function_name(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, bool has_array_offsets, bool has_offset, bool has_grad, bool has_dref, uint32_t lod) override
bool is_non_native_row_major_matrix(uint32_t id) override
MSLSamplerFilter
Definition: spirv_msl.hpp:69
MSLSamplerMipFilter
Definition: spirv_msl.hpp:75
MemberSorter(SPIRType &t, Meta &m, SortAspect sa)
Definition: spirv_msl.hpp:146
struct passwd out
Definition: missing_libc_functions.c:51
CompilerMSL & compiler
Definition: spirv_msl.hpp:400
std::vector< uint32_t > vars_needing_early_declaration
Definition: spirv_msl.hpp:372
GLsizei const GLchar *const * string
Definition: glext.h:6699
MSLSamplerAddress r_address
Definition: spirv_msl.hpp:118
Definition: spirv_msl.hpp:50
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
std::string entry_point_args(bool append_comma)
std::string to_qualifiers_glsl(uint32_t id) override
bool lod_clamp_enable
Definition: spirv_msl.hpp:126
void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args, uint32_t count) override
uint32_t stage_out_var_id
Definition: spirv_msl.hpp:376
void emit_fixup() override
const GLubyte * c
Definition: glext.h:9812
Platform
Definition: spirv_msl.hpp:148
uint32_t msl_buffer
Definition: spirv_msl.hpp:38
uint64_t MSLStructMemberKey
Definition: spirv_msl.hpp:131
GLuint GLuint GLsizei count
Definition: glext.h:6292
void declare_undefined_values() override
Definition: spirv_msl.cpp:1389
std::string stage_out_var_name
Definition: spirv_msl.hpp:382
std::string to_sampler_expression(uint32_t id)
Definition: spirv_msl.hpp:213
GLint lod
Definition: glext.h:8462
GLint location
Definition: glext.h:6690
GLint GLvoid * img
Definition: glext.h:6388
bool skip_argument(uint32_t id) const override
Definition: spirv_msl.hpp:71
bool is_ios()
Definition: spirv_msl.hpp:160
std::string sampler_type(const SPIRType &type)
bool resolve_specialized_array_lengths
Definition: spirv_msl.hpp:158
uint32_t stage_in_var_id
Definition: spirv_msl.hpp:375
const char * get_memory_order(uint32_t spv_mem_sem)
const Options & get_msl_options() const
Definition: spirv_msl.hpp:192
GLenum type
Definition: glext.h:6233
uint32_t get_metal_resource_index(SPIRVariable &var, SPIRType::BaseType basetype)
bool operator()(uint32_t mbr_idx1, uint32_t mbr_idx2)
std::string stage_in_var_name
Definition: spirv_msl.hpp:381
std::string func_type_decl(SPIRType &type)
Definition: barrier.hpp:23
spv::Op previous_instruction_opcode
Definition: spirv_msl.hpp:385
Op
Definition: spirv.hpp:714
void emit_array_copy(const std::string &lhs, uint32_t rhs_id) override
static uint32_t make_msl_version(uint32_t major, uint32_t minor=0, uint32_t patch=0)
Definition: spirv_msl.hpp:180
std::string stage_uniform_var_name
Definition: spirv_msl.hpp:383
OpCodePreprocessor(CompilerMSL &compiler_)
Definition: spirv_msl.hpp:392
bool used_by_shader
Definition: spirv_msl.hpp:60
void set_msl_options(const Options &opts)
Definition: spirv_msl.hpp:203
GLuint coord
Definition: glext.h:10418
bool supports_msl_version(uint32_t major, uint32_t minor=0, uint32_t patch=0)
Definition: spirv_msl.hpp:175
static const uint32_t kPushConstBinding
Definition: spirv_msl.hpp:139
GLenum func
Definition: glext.h:6668
size_t get_declared_struct_member_size(const SPIRType &struct_type, uint32_t index) const override
bool enable_point_size_builtin
Definition: spirv_msl.hpp:157
void localize_global_variables()
Definition: spirv_msl.cpp:383
std::string builtin_type_decl(spv::BuiltIn builtin)
MSLStructMemberKey get_struct_member_key(uint32_t type_id, uint32_t index)
Definition: spirv_msl.cpp:1035
MSLSamplerFilter min_filter
Definition: spirv_msl.hpp:113
Definition: spirv_msl.hpp:77
SortAspect
Definition: spirv_msl.hpp:411
static const GLfloat tex_coords[]
Definition: gl.c:105
spv::ExecutionModel stage
Definition: spirv_msl.hpp:52
void emit_barrier(uint32_t id_exe_scope, uint32_t id_mem_scope, uint32_t id_mem_sem)
Definition: spirv_msl.hpp:94
uint32_t texel_buffer_texture_width
Definition: spirv_msl.hpp:156
CompilerMSL(std::vector< uint32_t > spirv, std::vector< MSLVertexAttr > *p_vtx_attrs=nullptr, std::vector< MSLResourceBinding > *p_res_bindings=nullptr)
Definition: spirv_msl.cpp:30
std::vector< MSLResourceBinding * > resource_bindings
Definition: spirv_msl.hpp:373
Options MSLConfiguration
Definition: spirv_msl.hpp:259
GLfloat bias
Definition: glext.h:8812
uint32_t msl_offset
Definition: spirv_msl.hpp:39
std::string compile() override
Definition: spirv_msl.cpp:253
void bitcast_from_builtin_load(uint32_t source_id, std::string &expr, const SPIRType &expr_type) override
bool used_by_shader
Definition: spirv_msl.hpp:42
bool is_macos()
Definition: spirv_msl.hpp:165
uint32_t msl_stride
Definition: spirv_msl.hpp:40
std::string to_func_call_arg(uint32_t id) override
std::string qual_pos_var_name
Definition: spirv_msl.hpp:380
void build_implicit_builtins()
Definition: spirv_msl.cpp:56
size_t get_declared_struct_member_alignment(const SPIRType &struct_type, uint32_t index) const
GLuint in
Definition: glext.h:10523
uint32_t msl_sampler
Definition: spirv_msl.hpp:58
std::string sampler_name_suffix
Definition: spirv_msl.hpp:384
bool maybe_emit_input_struct_assignment(uint32_t id_lhs, uint32_t id_rhs)
MSLResourceBinding next_metal_resource_index
Definition: spirv_msl.hpp:374
dictionary args
Definition: test_shaders.py:20
static const uint32_t kPushConstDescSet
Definition: spirv_msl.hpp:135
bool anisotropy_enable
Definition: spirv_msl.hpp:127
T & set(uint32_t id, P &&... args)
Definition: spirv_cross.hpp:530
std::string built_in_func_arg(spv::BuiltIn builtin, bool prefix_comma)
Definition: spirv_msl.hpp:72
void add_convert_row_major_matrix_function(uint32_t cols, uint32_t rows)
ExecutionModel
Definition: spirv.hpp:68
float lod_clamp_max
Definition: spirv_msl.hpp:122
uint32_t desc_set
Definition: spirv_msl.hpp:53
std::string ensure_valid_name(std::string name, std::string pfx)
std::set< std::string > typedef_lines
Definition: spirv_msl.hpp:371
std::string builtin_qualifier(spv::BuiltIn builtin)
GLuint index
Definition: glext.h:6671
void add_pragma_line(const std::string &line)
Definition: spirv_msl.cpp:1076
std::unordered_map< uint32_t, std::set< uint32_t > > function_global_vars
Definition: spirv_msl.hpp:316
argument_type
Definition: query.c:50
void mark_location_as_used_by_shader(uint32_t location, spv::StorageClass storage)
Definition: spirv_msl.cpp:634
Definition: spirv_msl.hpp:212
Definition: query.c:71
void mark_packable_structs()
Definition: spirv_msl.cpp:582
void extract_global_variables_from_function(uint32_t func_id, std::set< uint32_t > &added_arg_ids, std::unordered_set< uint32_t > &global_var_ids, std::unordered_set< uint32_t > &processed_func_ids)
Definition: ibxm.h:14
bool maybe_emit_array_assignment(uint32_t id_lhs, uint32_t id_rhs)
std::string image_type_glsl(const SPIRType &type, uint32_t id=0) override
Definition: spirv_common.hpp:803
void extract_global_variables_from_functions()
Definition: spirv_msl.cpp:418
void emit_instruction(const Instruction &instr) override
MSLSamplerMipFilter mip_filter
Definition: spirv_msl.hpp:115
int max_anisotropy
Definition: spirv_msl.hpp:123
MSLSamplerAddress t_address
Definition: spirv_msl.hpp:117
std::string to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x, uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, uint32_t comp, uint32_t sample, bool *p_forward) override
std::string to_component_argument(uint32_t id)
uint32_t msl_version
Definition: spirv_msl.hpp:155
Definition: spirv_msl.hpp:65
SPIRV_CROSS_DEPRECATED("CompilerMSL::set_options() is obsolete, use set_msl_options() instead.") void set_options(Options &opts)
Definition: spirv_msl.hpp:197
MSLSamplerFilter mag_filter
Definition: spirv_msl.hpp:114
void mark_as_packable(SPIRType &type)
Definition: spirv_msl.cpp:604
Definition: spirv_common.hpp:97
std::string to_initializer_expression(const SPIRVariable &var) override
std::vector< uint32_t > spirv
Definition: spirv_cross.hpp:514
std::string builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage) override
std::string bitcast_glsl_op(const SPIRType &result_type, const SPIRType &argument_type) override
MSLSamplerAddress s_address
Definition: spirv_msl.hpp:116
bool per_instance
Definition: spirv_msl.hpp:41
Unknown compiler Device disconnected from port File already exists Saving to backup buffer Got connection No arguments supplied and no menu builtin
Definition: msg_hash_eo.h:34
uint32_t ensure_correct_builtin_type(uint32_t type_id, spv::BuiltIn builtin)
Definition: spirv_msl.cpp:913
Definition: spirv_msl.hpp:142
MSLSamplerAddress
Definition: spirv_msl.hpp:82
std::string to_name(uint32_t id, bool allow_alias=true) const override
std::string constant_expression(const SPIRConstant &c) override
BuiltIn
Definition: spirv.hpp:402
Definition: Common.h:43
static void expr(LexState *ls, expdesc *v)
Definition: lparser.c:1078
bool member_is_non_native_row_major_matrix(const SPIRType &type, uint32_t index) override
MSLSamplerCompareFunc
Definition: spirv_msl.hpp:91
uint32_t get_ordered_member_location(uint32_t type_id, uint32_t index)
void emit_function_prototype(SPIRFunction &func, const Bitset &return_flags) override
std::string unpack_expression_type(std::string expr_str, const SPIRType &type) override
Definition: spirv_msl.cpp:1045
bool needs_vertex_idx_arg
Definition: spirv_msl.hpp:378
void emit_header() override
Definition: spirv_msl.cpp:1051
Definition: spirv.hpp:715
#define false
Definition: ordinals.h:83
MSLSamplerCoord
Definition: spirv_msl.hpp:63
Definition: spirv_msl.hpp:409
Definition: spirv_common.hpp:686
std::string to_qualified_member_name(const SPIRType &type, uint32_t index)
SPIRType & type
Definition: spirv_msl.hpp:424
GLuint sampler
Definition: glext.h:7950
void resolve_specialized_array_lengths()
Definition: spirv_msl.cpp:403
std::unordered_map< uint32_t, MSLConstexprSampler > constexpr_samplers
Definition: spirv_msl.hpp:387
GLintptr offset
Definition: glext.h:6560
#define true
Definition: ordinals.h:82
MSLSamplerBorderColor border_color
Definition: spirv_msl.hpp:120
void bitcast_to_builtin_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type) override
SortAspect sort_aspect
Definition: spirv_msl.hpp:426
void emit_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, const std::string &qualifier="", uint32_t base_offset=0) override
float lod_clamp_min
Definition: spirv_msl.hpp:121
bool compare_enable
Definition: spirv_msl.hpp:125
unsigned __int64 uint64_t
Definition: stdint.h:136
GLenum GLuint GLenum GLsizei length
Definition: glext.h:6233
unsigned int uint32_t
Definition: stdint.h:126
const GLfloat * m
Definition: glext.h:11755
SPVFuncImpl
Definition: spirv_msl.hpp:210
void replace_illegal_names() override
void emit_interface_block(uint32_t ib_var_id)
std::string type_to_glsl(const SPIRType &type, uint32_t id=0) override
uint32_t msl_texture
Definition: spirv_msl.hpp:57
void emit_custom_functions()
Definition: spirv_msl.cpp:1091
bool is_member_packable(SPIRType &ib_type, uint32_t index)
Definition: spirv_msl.cpp:988
Definition: spirv_common.hpp:856
std::unordered_map< uint32_t, MSLVertexAttr * > vtx_attrs_by_location
Definition: spirv_msl.hpp:368
Definition: spirv_msl.hpp:87