[msl] fix splat namespace

This commit is contained in:
Dzmitry Malyshau 2021-05-08 22:07:13 -04:00
parent 350ceb383d
commit ba422f10f8
7 changed files with 8 additions and 8 deletions

View File

@ -1380,7 +1380,7 @@ impl<'a, W: Write> Writer<'a, W> {
write!(self.out, "{}", INDENT.repeat(indent))?;
}
for (index, member) in members.iter().enumerate() {
// TODO: handle builtin in better way
// TODO: handle builtin in better way
if let Some(Binding::BuiltIn(builtin)) = member.binding {
match builtin {
crate::BuiltIn::ClipDistance

View File

@ -775,7 +775,7 @@ impl<W: Write> Writer<W> {
let scalar = scalar_kind_string(scalar_kind);
let size = vector_size_str(size);
write!(self.out, "{}{}(", scalar, size)?;
write!(self.out, "{}::{}{}(", NAMESPACE, scalar, size)?;
self.put_expression(value, context, true)?;
write!(self.out, ")")?;
}

View File

@ -24,5 +24,5 @@ vertex fooOutput foo(
, device Bar& bar [[buffer(0)]]
, constant _mslBufferSizes& _buffer_sizes [[buffer(24)]]
) {
return fooOutput { static_cast<float4>(int4(type5 {bar.data[(1 + (_buffer_sizes.size0 - 64 - 4) / 4) - 1u], static_cast<int>(bar.matrix[3u].x), 3, 4, 5}.inner[vi])) };
return fooOutput { static_cast<float4>(metal::int4(type5 {bar.data[(1 + (_buffer_sizes.size0 - 64 - 4) / 4) - 1u], static_cast<int>(bar.matrix[3u].x), 3, 4, 5}.inner[vi])) };
}

View File

@ -79,10 +79,10 @@ kernel void main1(
}
}
if (cMassCount > 0) {
cMass = (cMass / float2(static_cast<float>(cMassCount))) - vPos;
cMass = (cMass / metal::float2(static_cast<float>(cMassCount))) - vPos;
}
if (cVelCount > 0) {
cVel = cVel / float2(static_cast<float>(cVelCount));
cVel = cVel / metal::float2(static_cast<float>(cVelCount));
}
vVel = ((vVel + (cMass * params.rule1Scale)) + (colVel * params.rule2Scale)) + (cVel * params.rule3Scale);
vVel = metal::normalize(vVel) * metal::clamp(metal::length(vVel), 0.0, 0.1);

View File

@ -28,5 +28,5 @@ vertex queriesOutput queries(
, metal::texture3d<float, metal::access::sample> image_3d [[user(fake0)]]
, metal::texture2d_ms<float, metal::access::read> image_aa [[user(fake0)]]
) {
return queriesOutput { float4(static_cast<float>((((((((((((((((((int(image_1d.get_width()) + int2(image_2d.get_width(), image_2d.get_height()).y) + int2(image_2d.get_width(1), image_2d.get_height(1)).y) + int2(image_2d_array.get_width(), image_2d_array.get_height()).y) + int2(image_2d_array.get_width(1), image_2d_array.get_height(1)).y) + int(image_2d_array.get_array_size())) + int3(image_cube.get_width()).y) + int3(image_cube.get_width(1)).y) + int3(image_cube_array.get_width()).y) + int3(image_cube_array.get_width(1)).y) + int(image_cube_array.get_array_size())) + int3(image_3d.get_width(), image_3d.get_height(), image_3d.get_depth()).z) + int3(image_3d.get_width(1), image_3d.get_height(1), image_3d.get_depth(1)).z) + int(image_aa.get_num_samples())) + int(image_2d.get_num_mip_levels())) + int(image_2d_array.get_num_mip_levels())) + int(image_3d.get_num_mip_levels())) + int(image_cube.get_num_mip_levels())) + int(image_cube_array.get_num_mip_levels()))) };
return queriesOutput { metal::float4(static_cast<float>((((((((((((((((((int(image_1d.get_width()) + int2(image_2d.get_width(), image_2d.get_height()).y) + int2(image_2d.get_width(1), image_2d.get_height(1)).y) + int2(image_2d_array.get_width(), image_2d_array.get_height()).y) + int2(image_2d_array.get_width(1), image_2d_array.get_height(1)).y) + int(image_2d_array.get_array_size())) + int3(image_cube.get_width()).y) + int3(image_cube.get_width(1)).y) + int3(image_cube_array.get_width()).y) + int3(image_cube_array.get_width(1)).y) + int(image_cube_array.get_array_size())) + int3(image_3d.get_width(), image_3d.get_height(), image_3d.get_depth()).z) + int3(image_3d.get_width(1), image_3d.get_height(1), image_3d.get_depth(1)).z) + int(image_aa.get_num_samples())) + int(image_2d.get_num_mip_levels())) + int(image_2d_array.get_num_mip_levels())) + int(image_3d.get_num_mip_levels())) + int(image_cube.get_num_mip_levels())) + int(image_cube_array.get_num_mip_levels()))) };
}

View File

@ -4,7 +4,7 @@
metal::float4 splat(
) {
return (((float2(1.0) + float2(2.0)) - float2(3.0)) / float2(4.0)).xyxy + static_cast<float4>(int4(5) % int4(2));
return (((metal::float2(1.0) + metal::float2(2.0)) - metal::float2(3.0)) / metal::float2(4.0)).xyxy + static_cast<float4>(metal::int4(5) % metal::int4(2));
}
int unary(

View File

@ -30,7 +30,7 @@ float fetch_shadow(
if (homogeneous_coords.w <= 0.0) {
return 1.0;
}
float _e26 = t_shadow.sample_compare(sampler_shadow, ((homogeneous_coords.xy * metal::float2(0.5, -0.5)) / float2(homogeneous_coords.w)) + metal::float2(0.5, 0.5), static_cast<int>(light_id), homogeneous_coords.z / homogeneous_coords.w);
float _e26 = t_shadow.sample_compare(sampler_shadow, ((homogeneous_coords.xy * metal::float2(0.5, -0.5)) / metal::float2(homogeneous_coords.w)) + metal::float2(0.5, 0.5), static_cast<int>(light_id), homogeneous_coords.z / homogeneous_coords.w);
return _e26;
}