2023-08-02 04:36:07 +02:00
|
|
|
#include <metal_stdlib>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
2023-08-03 14:50:36 +02:00
|
|
|
// ------------------
|
|
|
|
// Simple Blit Shader
|
|
|
|
// ------------------
|
|
|
|
|
2023-08-03 01:56:59 +02:00
|
|
|
constant float2 quadVertices[] = {
|
|
|
|
float2(-1, -1),
|
|
|
|
float2(-1, 1),
|
|
|
|
float2( 1, 1),
|
|
|
|
float2(-1, -1),
|
|
|
|
float2( 1, 1),
|
|
|
|
float2( 1, -1)
|
2023-08-02 04:36:07 +02:00
|
|
|
};
|
|
|
|
|
2023-08-03 01:56:59 +02:00
|
|
|
struct CopyVertexOut {
|
|
|
|
float4 position [[position]];
|
|
|
|
float2 uv;
|
|
|
|
};
|
|
|
|
|
2023-08-03 14:48:41 +02:00
|
|
|
vertex CopyVertexOut vertexBlit(unsigned short vid [[vertex_id]]) {
|
2023-08-03 01:56:59 +02:00
|
|
|
float2 position = quadVertices[vid];
|
|
|
|
|
|
|
|
CopyVertexOut out;
|
|
|
|
|
|
|
|
out.position = float4(position, 0, 1);
|
2023-08-03 02:32:59 +02:00
|
|
|
out.position.y = -out.position.y;
|
2023-08-03 01:56:59 +02:00
|
|
|
out.uv = position * 0.5f + 0.5f;
|
|
|
|
|
|
|
|
return out;
|
2023-08-02 04:36:07 +02:00
|
|
|
}
|
|
|
|
|
2023-08-03 14:48:41 +02:00
|
|
|
fragment float4 fragmentBlit(CopyVertexOut in [[stage_in]],
|
2023-08-03 14:58:14 +02:00
|
|
|
texture2d<float, access::sample> texture [[texture(0)]],
|
|
|
|
sampler sampler [[sampler(0)]]) {
|
|
|
|
return texture.sample(sampler, in.uv);
|
2023-08-02 04:36:07 +02:00
|
|
|
}
|