draw-improvements (#17)
Major rework to draw rendering system. We are making a SDF first rendering system with tesselated stuff only as a fallback strategy for specific situations where SDF is particularly poorly suited Co-authored-by: Zachary Levy <zachary@sunforge.is> Reviewed-on: #17
This commit was merged in pull request #17.
This commit is contained in:
@@ -14,24 +14,24 @@ struct Primitive
|
||||
{
|
||||
float4 bounds;
|
||||
uint color;
|
||||
uint kind_flags;
|
||||
float rotation;
|
||||
uint flags;
|
||||
uint rotation_sc;
|
||||
float _pad;
|
||||
float4 params;
|
||||
float4 params2;
|
||||
float4 uv_rect;
|
||||
uint4 uv_or_effects;
|
||||
};
|
||||
|
||||
struct Primitive_1
|
||||
{
|
||||
float4 bounds;
|
||||
uint color;
|
||||
uint kind_flags;
|
||||
float rotation;
|
||||
uint flags;
|
||||
uint rotation_sc;
|
||||
float _pad;
|
||||
float4 params;
|
||||
float4 params2;
|
||||
float4 uv_rect;
|
||||
uint4 uv_or_effects;
|
||||
};
|
||||
|
||||
struct Primitives
|
||||
@@ -45,9 +45,9 @@ struct main0_out
|
||||
float2 f_local_or_uv [[user(locn1)]];
|
||||
float4 f_params [[user(locn2)]];
|
||||
float4 f_params2 [[user(locn3)]];
|
||||
uint f_kind_flags [[user(locn4)]];
|
||||
float f_rotation [[user(locn5)]];
|
||||
float4 f_uv_rect [[user(locn6)]];
|
||||
uint f_flags [[user(locn4)]];
|
||||
uint f_rotation_sc [[user(locn5)]];
|
||||
uint4 f_uv_or_effects [[user(locn6)]];
|
||||
float4 gl_Position [[position]];
|
||||
};
|
||||
|
||||
@@ -58,7 +58,7 @@ struct main0_in
|
||||
float4 v_color [[attribute(2)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant Uniforms& _12 [[buffer(0)]], const device Primitives& _74 [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
|
||||
vertex main0_out main0(main0_in in [[stage_in]], constant Uniforms& _12 [[buffer(0)]], const device Primitives& _75 [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
|
||||
{
|
||||
main0_out out = {};
|
||||
if (_12.mode == 0u)
|
||||
@@ -67,22 +67,22 @@ vertex main0_out main0(main0_in in [[stage_in]], constant Uniforms& _12 [[buffer
|
||||
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.f_rotation = 0.0;
|
||||
out.f_uv_rect = float4(0.0, 0.0, 1.0, 1.0);
|
||||
out.f_flags = 0u;
|
||||
out.f_rotation_sc = 0u;
|
||||
out.f_uv_or_effects = uint4(0u);
|
||||
out.gl_Position = _12.projection * float4(in.v_position * _12.dpi_scale, 0.0, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Primitive p;
|
||||
p.bounds = _74.primitives[int(gl_InstanceIndex)].bounds;
|
||||
p.color = _74.primitives[int(gl_InstanceIndex)].color;
|
||||
p.kind_flags = _74.primitives[int(gl_InstanceIndex)].kind_flags;
|
||||
p.rotation = _74.primitives[int(gl_InstanceIndex)].rotation;
|
||||
p._pad = _74.primitives[int(gl_InstanceIndex)]._pad;
|
||||
p.params = _74.primitives[int(gl_InstanceIndex)].params;
|
||||
p.params2 = _74.primitives[int(gl_InstanceIndex)].params2;
|
||||
p.uv_rect = _74.primitives[int(gl_InstanceIndex)].uv_rect;
|
||||
p.bounds = _75.primitives[int(gl_InstanceIndex)].bounds;
|
||||
p.color = _75.primitives[int(gl_InstanceIndex)].color;
|
||||
p.flags = _75.primitives[int(gl_InstanceIndex)].flags;
|
||||
p.rotation_sc = _75.primitives[int(gl_InstanceIndex)].rotation_sc;
|
||||
p._pad = _75.primitives[int(gl_InstanceIndex)]._pad;
|
||||
p.params = _75.primitives[int(gl_InstanceIndex)].params;
|
||||
p.params2 = _75.primitives[int(gl_InstanceIndex)].params2;
|
||||
p.uv_or_effects = _75.primitives[int(gl_InstanceIndex)].uv_or_effects;
|
||||
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;
|
||||
@@ -90,10 +90,11 @@ vertex main0_out main0(main0_in in [[stage_in]], constant Uniforms& _12 [[buffer
|
||||
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.f_rotation = p.rotation;
|
||||
out.f_uv_rect = p.uv_rect;
|
||||
out.f_flags = p.flags;
|
||||
out.f_rotation_sc = p.rotation_sc;
|
||||
out.f_uv_or_effects = p.uv_or_effects;
|
||||
out.gl_Position = _12.projection * float4(world_pos * _12.dpi_scale, 0.0, 1.0);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user