17 #ifndef SPIRV_CROSS_MSL_HPP 18 #define SPIRV_CROSS_MSL_HPP 25 #include <unordered_map> 26 #include <unordered_set> 182 return (major * 10000) + (minor * 100) + patch;
242 CompilerMSL(std::vector<uint32_t>
spirv, std::vector<MSLVertexAttr> *p_vtx_attrs =
nullptr,
243 std::vector<MSLResourceBinding> *p_res_bindings =
nullptr);
256 std::string compile(std::vector<MSLVertexAttr> *p_vtx_attrs, std::vector<MSLResourceBinding> *p_res_bindings);
291 bool has_array_offsets,
bool has_offset,
bool has_grad,
bool has_dref,
393 : compiler(compiler_)
402 bool suppress_missing_prototypes =
false;
403 bool uses_atomics =
false;
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)
Definition: spirv_msl.hpp:215
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
Definition: spirv_msl.hpp:217
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)
Definition: spirv_msl.hpp:229
std::unordered_map< uint32_t, uint32_t > result_types
Definition: spirv_msl.hpp:401
Definition: disassemble.cpp:50
Definition: spirv_msl.hpp:390
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
Definition: spirv_msl.hpp:106
std::set< std::string > pragma_lines
Definition: spirv_msl.hpp:370
Definition: spirv_msl.hpp:88
std::string get_argument_address_space(const SPIRVariable &argument)
Definition: spirv_msl.hpp:413
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)
Definition: spirv_msl.hpp:216
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
Definition: spirv_msl.hpp:85
Definition: spirv_msl.hpp:224
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
Definition: spirv_msl.hpp:218
GLint GLvoid * img
Definition: glext.h:6388
bool skip_argument(uint32_t id) const override
Definition: spirv_msl.hpp:71
Definition: spirv_msl.hpp:416
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)
Definition: spirv_msl.hpp:417
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
Definition: spirv_msl.hpp:414
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
Definition: spirv_msl.hpp:220
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:98
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
Definition: spirv_msl.hpp:78
Definition: spirv_msl.hpp:226
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
Definition: spirv_msl.hpp:415
Definition: spirv_msl.hpp:225
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
Definition: spirv_msl.hpp:219
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
Definition: spirv_msl.hpp:227
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
Definition: spirv_msl.hpp:96
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
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: spirv_msl.hpp:97
Definition: spirv_msl.hpp:105
Definition: spirv_msl.hpp:214
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
Definition: spirv_msl.hpp:99
Definition: spirv_msl.hpp:223
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
Definition: spirv_msl.hpp:107
MSLSamplerFilter mag_filter
Definition: spirv_msl.hpp:114
Definition: spirv_msl.hpp:95
Definition: spirv_msl.hpp:100
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
Definition: spirv_msl.hpp:228
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
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
Definition: spirv_msl.hpp:221
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
Definition: spirv_msl.hpp:86
#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
Definition: spirv_msl.hpp:222
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
Definition: spirv_msl.hpp:84
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
Definition: spirv_msl.hpp:93
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