Manage variable names in an unordered map
This commit is contained in:
Родитель
1c63357577
Коммит
91ccd21fc9
|
@ -23,14 +23,13 @@ using namespace spv;
|
|||
using namespace spirv_cross;
|
||||
using namespace std;
|
||||
|
||||
static const std::vector<std::string> reserved_names = {"kernel", "bias"};
|
||||
|
||||
CompilerMSL::CompilerMSL(vector<uint32_t> spirv_)
|
||||
: CompilerGLSL(move(spirv_))
|
||||
{
|
||||
options.vertex.fixup_clipspace = false;
|
||||
|
||||
populate_func_name_overrides();
|
||||
populate_var_name_overrides();
|
||||
}
|
||||
|
||||
// Populate the collection of function names that need to be overridden
|
||||
|
@ -40,6 +39,12 @@ void CompilerMSL::populate_func_name_overrides()
|
|||
func_name_overrides["saturate"] = "saturate0";
|
||||
}
|
||||
|
||||
void CompilerMSL::populate_var_name_overrides()
|
||||
{
|
||||
var_name_overrides["kernel"] = "kernel0";
|
||||
var_name_overrides["bias"] = "bias0";
|
||||
}
|
||||
|
||||
string CompilerMSL::compile(MSLConfiguration &msl_cfg, vector<MSLVertexAttr> *p_vtx_attrs,
|
||||
std::vector<MSLResourceBinding> *p_res_bindings)
|
||||
{
|
||||
|
@ -1458,13 +1463,10 @@ string CompilerMSL::ensure_valid_name(string name, string pfx)
|
|||
{
|
||||
return join(pfx, name);
|
||||
}
|
||||
else if (std::find(reserved_names.begin(), reserved_names.end(), name) != reserved_names.end())
|
||||
{
|
||||
return join(pfx, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
auto iter = var_name_overrides.find(name);
|
||||
return (iter != var_name_overrides.end()) ? iter->second : name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,6 +136,7 @@ protected:
|
|||
void emit_function_prototype(SPIRFunction &func, bool is_decl);
|
||||
void emit_function_declarations();
|
||||
void populate_func_name_overrides();
|
||||
void populate_var_name_overrides();
|
||||
|
||||
std::string func_type_decl(SPIRType &type);
|
||||
std::string clean_func_name(std::string func_name) override;
|
||||
|
@ -156,6 +157,7 @@ protected:
|
|||
|
||||
MSLConfiguration msl_config;
|
||||
std::unordered_map<std::string, std::string> func_name_overrides;
|
||||
std::unordered_map<std::string, std::string> var_name_overrides;
|
||||
std::set<uint32_t> custom_function_ops;
|
||||
std::unordered_map<uint32_t, MSLVertexAttr *> vtx_attrs_by_location;
|
||||
std::vector<MSLResourceBinding *> resource_bindings;
|
||||
|
|
Загрузка…
Ссылка в новой задаче