Set function name

This commit is contained in:
Polona Caserman 2016-12-21 11:22:31 +01:00 committed by Robert Konrad
parent 989563ad3f
commit 5de757621c
2 changed files with 8 additions and 1 deletions

View File

@ -1385,10 +1385,14 @@ string CompilerMSL::func_type_decl(SPIRType &type)
// Ensures the function name is not "main", which is illegal in MSL
string CompilerMSL::clean_func_name(string func_name)
{
static std::string _clean_msl_main_func_name = "mmain";
if (_clean_msl_main_func_name.empty()) _clean_msl_main_func_name = "mmain";
return (func_name == "main") ? _clean_msl_main_func_name : func_name;
}
void CompilerMSL::set_func_name(std::string func_name) {
_clean_msl_main_func_name = 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)
{

View File

@ -94,6 +94,8 @@ public:
// Compiles the SPIR-V code into Metal Shading Language using default configuration parameters.
std::string compile() override;
void set_func_name(std::string func_name);
protected:
void emit_instruction(const Instruction &instr) override;
@ -129,6 +131,7 @@ protected:
void emit_function_declarations();
std::string func_type_decl(SPIRType &type);
std::string _clean_msl_main_func_name;
std::string clean_func_name(std::string func_name);
std::string entry_point_args(bool append_comma);
std::string get_entry_point_name();