diff --git a/spirv_msl.cpp b/spirv_msl.cpp index 9313df7f..b60a0f9f 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -54,6 +54,10 @@ string CompilerMSL::compile(MSLConfiguration &msl_cfg, vector *p_ // Remember the input parameters msl_config = msl_cfg; + // Set main function name if it was explicitly set + if (!msl_config.entry_point_name.empty()) + set_name(entry_point, msl_config.entry_point_name); + vtx_attrs_by_location.clear(); if (p_vtx_attrs) for (auto &va : *p_vtx_attrs) @@ -1270,13 +1274,6 @@ string CompilerMSL::clean_func_name(string func_name) return (iter != func_name_overrides.end()) ? iter->second : func_name; } -void CompilerMSL::set_entry_point_name(string func_name) -{ - if (func_name.find("main") == std::string::npos) - func_name += "_main"; - meta.at(entry_point).decoration.alias = func_name; -} - // Returns a string containing a comma-delimited list of args for the entry point function string CompilerMSL::entry_point_args(bool append_comma) { diff --git a/spirv_msl.hpp b/spirv_msl.hpp index 9e73c061..a2bf7ace 100644 --- a/spirv_msl.hpp +++ b/spirv_msl.hpp @@ -29,10 +29,10 @@ namespace spirv_cross // Options for compiling to Metal Shading Language struct MSLConfiguration { - uint32_t vtx_attr_stage_in_binding = 0; bool flip_vert_y = false; bool flip_frag_y = false; bool is_rendering_points = false; + std::string entry_point_name; }; // Defines MSL characteristics of a vertex attribute at a particular location. @@ -93,8 +93,6 @@ public: // Compiles the SPIR-V code into Metal Shading Language using default configuration parameters. std::string compile() override; - void set_entry_point_name(std::string func_name); - protected: void emit_instruction(const Instruction &instr) override; void emit_glsl_op(uint32_t result_type, uint32_t result_id, uint32_t op, const uint32_t *args,