CompilerMSL fix func_call_arg() cast error when not passed SPIRVariable type.

CompilerGLSL allow retrieval of partial source if an error occurs.
This commit is contained in:
Bill Hollings 2016-11-27 12:34:04 -05:00
parent 9075262787
commit c5c073699e
3 changed files with 20 additions and 6 deletions

View File

@ -289,6 +289,11 @@ string CompilerGLSL::compile()
return buffer->str();
}
std::string CompilerGLSL::get_partial_source()
{
return buffer->str();
}
void CompilerGLSL::emit_header()
{
auto &execution = get_entry_point();

View File

@ -115,8 +115,13 @@ public:
{
options = opts;
}
std::string compile() override;
// Returns the current string held in the conversion buffer. Useful for
// capturing what has been converted so far when compile() throws an error.
std::string get_partial_source();
// Adds a line to be added right after #version in GLSL backend.
// This is useful for enabling custom extensions which are outside the scope of SPIRV-Cross.
// This can be combined with variable remapping.

View File

@ -1118,11 +1118,15 @@ string CompilerMSL::to_func_call_arg(uint32_t id)
{
string arg_str = CompilerGLSL::to_func_call_arg(id);
// Manufacture automatic sampler arg for SampledImage texture.
auto &var = get<SPIRVariable>(id);
auto &type = get<SPIRType>(var.basetype);
if (type.basetype == SPIRType::SampledImage)
arg_str += ", " + to_sampler_expression(id);
// Manufacture automatic sampler arg if the arg is a SampledImage texture.
Variant &id_v = ids[id];
if (id_v.get_type() == TypeVariable)
{
auto &var = id_v.get<SPIRVariable>();
auto &type = get<SPIRType>(var.basetype);
if (type.basetype == SPIRType::SampledImage)
arg_str += ", " + to_sampler_expression(id);
}
return arg_str;
}