2016-04-21 09:16:44 +02:00
|
|
|
#include <metal_texture>
|
|
|
|
|
|
|
|
using namespace metal;
|
|
|
|
|
2017-12-09 21:58:41 +01:00
|
|
|
struct SolidVertex
|
2016-04-21 09:16:44 +02:00
|
|
|
{
|
2017-12-09 21:58:41 +01:00
|
|
|
float4 position [[position]];
|
|
|
|
float pointSize [[point_size]];
|
|
|
|
};
|
|
|
|
|
|
|
|
vertex SolidVertex SDL_Solid_vertex(constant float2 *position [[buffer(0)]], uint vid [[vertex_id]])
|
|
|
|
{
|
|
|
|
SolidVertex v;
|
|
|
|
v.position = float4(position[vid].x, position[vid].y, 0.0f, 1.0f);
|
|
|
|
v.pointSize = 0.5f;
|
|
|
|
return v;
|
2016-04-21 09:16:44 +02:00
|
|
|
}
|
|
|
|
|
2017-12-09 21:58:41 +01:00
|
|
|
fragment float4 SDL_Solid_fragment(constant float4 &col [[buffer(0)]])
|
2016-04-21 09:16:44 +02:00
|
|
|
{
|
|
|
|
return col;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct CopyVertex
|
|
|
|
{
|
|
|
|
float4 position [[position]];
|
|
|
|
float2 texcoord;
|
|
|
|
};
|
|
|
|
|
|
|
|
vertex CopyVertex SDL_Copy_vertex(constant float2 *position [[buffer(0)]], constant float2 *texcoords [[buffer(1)]], uint vid [[vertex_id]])
|
|
|
|
{
|
2017-12-09 21:58:41 +01:00
|
|
|
CopyVertex v;
|
|
|
|
v.position = float4(position[vid].x, position[vid].y, 0.0f, 1.0f);
|
|
|
|
v.texcoord = texcoords[vid];
|
|
|
|
return v;
|
2016-04-21 09:16:44 +02:00
|
|
|
}
|
|
|
|
|
2017-12-10 00:00:41 +01:00
|
|
|
fragment float4 SDL_Copy_fragment_nearest(CopyVertex vert [[stage_in]], constant float4 &col [[buffer(0)]], texture2d<float> tex [[texture(0)]])
|
2016-04-21 09:16:44 +02:00
|
|
|
{
|
2017-12-10 00:00:41 +01:00
|
|
|
constexpr sampler s(coord::pixel, address::clamp_to_edge, filter::nearest);
|
|
|
|
return tex.sample(s, vert.texcoord) * col;
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment float4 SDL_Copy_fragment_linear(CopyVertex vert [[stage_in]], constant float4 &col [[buffer(0)]], texture2d<float> tex [[texture(0)]])
|
|
|
|
{
|
|
|
|
constexpr sampler s(coord::pixel, address::clamp_to_edge, filter::linear);
|
|
|
|
return tex.sample(s, vert.texcoord) * col;
|
2016-04-21 09:16:44 +02:00
|
|
|
}
|
|
|
|
|