Initial draw package
This commit is contained in:
88
draw/shaders/generated/base_2d.vert.metal
Normal file
88
draw/shaders/generated/base_2d.vert.metal
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct Uniforms
|
||||
{
|
||||
float4x4 projection;
|
||||
float dpi_scale;
|
||||
uint mode;
|
||||
};
|
||||
|
||||
struct Primitive
|
||||
{
|
||||
float4 bounds;
|
||||
uint color;
|
||||
uint kind_flags;
|
||||
float2 _pad;
|
||||
float4 params;
|
||||
float4 params2;
|
||||
};
|
||||
|
||||
struct Primitive_1
|
||||
{
|
||||
float4 bounds;
|
||||
uint color;
|
||||
uint kind_flags;
|
||||
float2 _pad;
|
||||
float4 params;
|
||||
float4 params2;
|
||||
};
|
||||
|
||||
struct Primitives
|
||||
{
|
||||
Primitive_1 primitives[1];
|
||||
};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 f_color [[user(locn0)]];
|
||||
float2 f_local_or_uv [[user(locn1)]];
|
||||
float4 f_params [[user(locn2)]];
|
||||
float4 f_params2 [[user(locn3)]];
|
||||
uint f_kind_flags [[user(locn4)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float2 v_position [[attribute(0)]];
|
||||
float2 v_uv [[attribute(1)]];
|
||||
float4 v_color [[attribute(2)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant Uniforms& _12 [[buffer(0)]], const device Primitives& _70 [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
|
||||
{
|
||||
main0_out out = {};
|
||||
if (_12.mode == 0u)
|
||||
{
|
||||
out.f_color = in.v_color;
|
||||
out.f_local_or_uv = in.v_uv;
|
||||
out.f_params = float4(0.0);
|
||||
out.f_params2 = float4(0.0);
|
||||
out.f_kind_flags = 0u;
|
||||
out.gl_Position = _12.projection * float4(in.v_position * _12.dpi_scale, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Primitive p;
|
||||
p.bounds = _70.primitives[int(gl_InstanceIndex)].bounds;
|
||||
p.color = _70.primitives[int(gl_InstanceIndex)].color;
|
||||
p.kind_flags = _70.primitives[int(gl_InstanceIndex)].kind_flags;
|
||||
p._pad = _70.primitives[int(gl_InstanceIndex)]._pad;
|
||||
p.params = _70.primitives[int(gl_InstanceIndex)].params;
|
||||
p.params2 = _70.primitives[int(gl_InstanceIndex)].params2;
|
||||
float2 corner = in.v_position;
|
||||
float2 world_pos = mix(p.bounds.xy, p.bounds.zw, corner);
|
||||
float2 center = (p.bounds.xy + p.bounds.zw) * 0.5;
|
||||
out.f_color = unpack_unorm4x8_to_float(p.color);
|
||||
out.f_local_or_uv = (world_pos - center) * _12.dpi_scale;
|
||||
out.f_params = p.params;
|
||||
out.f_params2 = p.params2;
|
||||
out.f_kind_flags = p.kind_flags;
|
||||
out.gl_Position = _12.projection * float4(world_pos * _12.dpi_scale, 0.0, 1.0);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user