Files
wgpu/tests/out/msl/interface.msl
T
6035b07b78 [wgsl-in] Implement module-level scoping.
Fixes #1745: Support out-of-order module scope declarations in WGSL
Fixes #1044: Forbid local variable shadowing in WGSL
Fixes #2076: [wgsl-in] no error for duplicated type definition
Fixes #2071: Global item does not support 'const'
Fixes #2105: [wgsl-in] Type aliases for a vecN<T> doesn't work when constructing vec from a single argument
Fixes #1775: Referencing a function without a return type yields an unknown identifier error.
Fixes #2089: Error span reported on the declaration of a variable instead of its use
Fixes #1996: [wgsl-in] Confusing error: "expected unsigned/signed integer literal, found '1'"

Separate parsing from lowering by generating an AST, which desugars as
much as possible down to something like Naga IR. The AST is then used
to resolve identifiers while lowering to Naga IR.

Co-authored-by: Teodor Tanasoaia <28601907+teoxoy@users.noreply.github.com>
Co-authored-by: Jim Blandy <jimb@red-bean.com>
2023-01-12 09:37:08 -08:00

101 lines
2.7 KiB
Plaintext

// language: metal2.1
#include <metal_stdlib>
#include <simd/simd.h>
using metal::uint;
struct VertexOutput {
metal::float4 position;
float _varying;
};
struct FragmentOutput {
float depth;
uint sample_mask;
float color;
};
struct type_4 {
uint inner[1];
};
struct Input1_ {
uint index;
};
struct Input2_ {
uint index;
};
struct vertex_Input {
uint color [[attribute(10)]];
};
struct vertex_Output {
metal::float4 position [[position, invariant]];
float _varying [[user(loc1), center_perspective]];
float _point_size [[point_size]];
};
vertex vertex_Output vertex_(
vertex_Input varyings [[stage_in]]
, uint vertex_index [[vertex_id]]
, uint instance_index [[instance_id]]
) {
const auto color = varyings.color;
uint tmp = (vertex_index + instance_index) + color;
const auto _tmp = VertexOutput {metal::float4(1.0), static_cast<float>(tmp)};
return vertex_Output { _tmp.position, _tmp._varying, 1.0 };
}
struct fragment_Input {
float _varying [[user(loc1), center_perspective]];
};
struct fragment_Output {
float depth [[depth(any)]];
uint sample_mask [[sample_mask]];
float color [[color(0)]];
};
fragment fragment_Output fragment_(
fragment_Input varyings_1 [[stage_in]]
, metal::float4 position [[position]]
, bool front_facing [[front_facing]]
, uint sample_index [[sample_id]]
, uint sample_mask [[sample_mask]]
) {
const VertexOutput in = { position, varyings_1._varying };
uint mask = sample_mask & (1u << sample_index);
float color_1 = front_facing ? 1.0 : 0.0;
const auto _tmp = FragmentOutput {in._varying, mask, color_1};
return fragment_Output { _tmp.depth, _tmp.sample_mask, _tmp.color };
}
struct compute_Input {
};
kernel void compute_(
metal::uint3 global_id [[thread_position_in_grid]]
, metal::uint3 local_id [[thread_position_in_threadgroup]]
, uint local_index [[thread_index_in_threadgroup]]
, metal::uint3 wg_id [[threadgroup_position_in_grid]]
, metal::uint3 num_wgs [[threadgroups_per_grid]]
, threadgroup type_4& output
) {
output.inner[0] = (((global_id.x + local_id.x) + local_index) + wg_id.x) + num_wgs.x;
return;
}
struct vertex_two_structsInput {
};
struct vertex_two_structsOutput {
metal::float4 member_3 [[position, invariant]];
float _point_size [[point_size]];
};
vertex vertex_two_structsOutput vertex_two_structs(
uint index_1 [[vertex_id]]
, uint index_2 [[instance_id]]
) {
const Input1_ in1_ = { index_1 };
const Input2_ in2_ = { index_2 };
uint index = {};
index = 2u;
uint _e8 = index;
return vertex_two_structsOutput { metal::float4(static_cast<float>(in1_.index), static_cast<float>(in2_.index), static_cast<float>(_e8), 0.0), 1.0 };
}