Cast uses of Layer and ViewportIndex to the expected type.
This commit is contained in:
parent
0e9ad14ba6
commit
ec857f6778
@ -18,7 +18,7 @@ vertex main0_out main0(main0_in in [[stage_in]])
|
|||||||
{
|
{
|
||||||
main0_out out = {};
|
main0_out out = {};
|
||||||
out.gl_Position = in.coord;
|
out.gl_Position = in.coord;
|
||||||
out.gl_Layer = int(in.coord.z);
|
out.gl_Layer = uint(int(in.coord.z));
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ vertex main0_out main0(main0_in in [[stage_in]])
|
|||||||
{
|
{
|
||||||
main0_out out = {};
|
main0_out out = {};
|
||||||
out.gl_Position = in.coord;
|
out.gl_Position = in.coord;
|
||||||
out.gl_ViewportIndex = int(in.coord.z);
|
out.gl_ViewportIndex = uint(int(in.coord.z));
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ vertex main0_out main0(main0_in in [[stage_in]])
|
|||||||
{
|
{
|
||||||
main0_out out = {};
|
main0_out out = {};
|
||||||
out.gl_Position = in.coord;
|
out.gl_Position = in.coord;
|
||||||
out.gl_Layer = int(in.coord.z);
|
out.gl_Layer = uint(int(in.coord.z));
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ vertex main0_out main0(main0_in in [[stage_in]])
|
|||||||
{
|
{
|
||||||
main0_out out = {};
|
main0_out out = {};
|
||||||
out.gl_Position = in.coord;
|
out.gl_Position = in.coord;
|
||||||
out.gl_ViewportIndex = int(in.coord.z);
|
out.gl_ViewportIndex = uint(int(in.coord.z));
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4714,6 +4714,8 @@ void CompilerMSL::bitcast_from_builtin_load(uint32_t source_id, std::string &exp
|
|||||||
case BuiltInLocalInvocationIndex:
|
case BuiltInLocalInvocationIndex:
|
||||||
case BuiltInWorkgroupSize:
|
case BuiltInWorkgroupSize:
|
||||||
case BuiltInNumWorkgroups:
|
case BuiltInNumWorkgroups:
|
||||||
|
case BuiltInLayer:
|
||||||
|
case BuiltInViewportIndex:
|
||||||
expected_type = SPIRType::UInt;
|
expected_type = SPIRType::UInt;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4725,9 +4727,31 @@ void CompilerMSL::bitcast_from_builtin_load(uint32_t source_id, std::string &exp
|
|||||||
expr = bitcast_expression(expr_type, expected_type, expr);
|
expr = bitcast_expression(expr_type, expected_type, expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MSL always declares output builtins with the SPIR-V type.
|
void CompilerMSL::bitcast_to_builtin_store(uint32_t target_id, std::string &expr, const SPIRType &expr_type)
|
||||||
void CompilerMSL::bitcast_to_builtin_store(uint32_t, std::string &, const SPIRType &)
|
|
||||||
{
|
{
|
||||||
|
// Only interested in standalone builtin variables.
|
||||||
|
if (!has_decoration(target_id, DecorationBuiltIn))
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto builtin = static_cast<BuiltIn>(get_decoration(target_id, DecorationBuiltIn));
|
||||||
|
auto expected_type = expr_type.basetype;
|
||||||
|
switch (builtin)
|
||||||
|
{
|
||||||
|
case BuiltInLayer:
|
||||||
|
case BuiltInViewportIndex:
|
||||||
|
expected_type = SPIRType::UInt;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expected_type != expr_type.basetype)
|
||||||
|
{
|
||||||
|
auto type = expr_type;
|
||||||
|
type.basetype = expected_type;
|
||||||
|
expr = bitcast_expression(type, expr_type.basetype, expr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CompilerMSL::to_initializer_expression(const SPIRVariable &var)
|
std::string CompilerMSL::to_initializer_expression(const SPIRVariable &var)
|
||||||
|
Loading…
Reference in New Issue
Block a user