2024-09-28 19:03:01 -04:00

30 lines
697 B
Metal

#include <metal_stdlib>
using namespace metal;
struct CopyVertexOut {
float4 position [[position]];
float2 uv;
};
struct Textures
{
texture2d_ms<uint, access::read> texture;
};
struct FragmentOut {
uint stencil [[stencil]];
};
fragment FragmentOut fragmentMain(CopyVertexOut in [[stage_in]],
constant Textures &textures [[buffer(22)]],
uint sample_id [[sample_id]]) {
FragmentOut out;
uint2 tex_size = uint2(textures.texture.get_width(), textures.texture.get_height());
uint2 tex_coord = uint2(in.uv * float2(tex_size));
out.stencil = textures.texture.read(tex_coord, sample_id).r;
return out;
}