mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
46 lines
1.2 KiB
Plaintext
46 lines
1.2 KiB
Plaintext
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
constexpr constant float c_scale = 1.2;
|
|
struct VertexOutput {
|
|
metal::float2 uv;
|
|
metal::float4 position;
|
|
};
|
|
|
|
struct main1Input {
|
|
metal::float2 pos [[attribute(0)]];
|
|
metal::float2 uv1 [[attribute(1)]];
|
|
};
|
|
struct main1Output {
|
|
metal::float2 uv [[user(loc0), center_perspective]];
|
|
metal::float4 position [[position]];
|
|
};
|
|
vertex main1Output main1(
|
|
main1Input varyings [[stage_in]]
|
|
) {
|
|
const auto pos = varyings.pos;
|
|
const auto uv1 = varyings.uv1;
|
|
const auto _tmp = VertexOutput {uv1, metal::float4(c_scale * pos, 0.0, 1.0)};
|
|
return main1Output { _tmp.uv, _tmp.position };
|
|
}
|
|
|
|
|
|
struct main2Input {
|
|
metal::float2 uv2 [[user(loc0), center_perspective]];
|
|
};
|
|
struct main2Output {
|
|
metal::float4 member1 [[color(0)]];
|
|
};
|
|
fragment main2Output main2(
|
|
main2Input varyings1 [[stage_in]]
|
|
, metal::texture2d<float, metal::access::sample> u_texture [[user(fake0)]]
|
|
, metal::sampler u_sampler [[user(fake0)]]
|
|
) {
|
|
const auto uv2 = varyings1.uv2;
|
|
metal::float4 _e4 = u_texture.sample(u_sampler, uv2);
|
|
if (_e4.w == 0.0) {
|
|
metal::discard_fragment();
|
|
}
|
|
return main2Output { _e4.w * _e4 };
|
|
}
|