Ryujinx/src/Ryujinx.Graphics.Metal/HelperShadersSource.metal

41 lines
865 B
Metal
Raw Normal View History

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]],
texture2d<float> tex) {
2023-08-03 01:56:59 +02:00
constexpr sampler sam(min_filter::nearest, mag_filter::nearest, mip_filter::none);
2023-08-03 03:18:28 +02:00
return tex.sample(sam, in.uv).xyzw;
2023-08-02 04:36:07 +02:00
}