[msl] fix constant array initialization

This commit is contained in:
Dzmitry Malyshau
2021-03-30 00:30:42 -04:00
committed by Dzmitry Malyshau
parent 057fa336a8
commit baccfc68f5
2 changed files with 3 additions and 7 deletions

View File

@@ -1189,17 +1189,13 @@ impl<W: Write> Writer<W> {
crate::ConstantInner::Composite { ty, ref components } => {
let name = &self.names[&NameKey::Constant(handle)];
let ty_name = &self.names[&NameKey::Type(ty)];
write!(
self.out,
"constexpr constant {} {} = {}(",
ty_name, name, ty_name
)?;
write!(self.out, "constexpr constant {} {} = {{", ty_name, name,)?;
for (i, &sub_handle) in components.iter().enumerate() {
let separator = if i != 0 { ", " } else { "" };
let sub_name = &self.names[&NameKey::Constant(sub_handle)];
write!(self.out, "{}{}", separator, sub_name)?;
}
writeln!(self.out, ");")?;
writeln!(self.out, "}};")?;
}
}
}

View File

@@ -34,7 +34,7 @@ typedef uint type6;
typedef float type7;
typedef metal::float2 type8;
typedef metal::float3 type9;
constexpr constant type9 c_ambient = type9(const_0_05f, const_0_05f, const_0_05f);
constexpr constant type9 c_ambient = {const_0_05f, const_0_05f, const_0_05f};
type7 fetch_shadow(
type6 light_id,
type2 homogeneous_coords,