Major rendering updates

This commit is contained in:
Zachary Levy
2026-04-22 14:49:37 -07:00
parent 37da2ea068
commit e1938f1c42
15 changed files with 1770 additions and 1736 deletions

View File

@@ -6,13 +6,13 @@ layout(location = 1) in vec2 v_uv;
layout(location = 2) in vec4 v_color;
// ---------- Outputs to fragment shader ----------
layout(location = 0) out vec4 f_color;
layout(location = 0) out mediump vec4 f_color;
layout(location = 1) out vec2 f_local_or_uv;
layout(location = 2) out vec4 f_params;
layout(location = 3) out vec4 f_params2;
layout(location = 4) flat out uint f_kind_flags;
layout(location = 5) flat out float f_rotation;
layout(location = 6) flat out vec4 f_uv_rect;
layout(location = 4) flat out uint f_flags;
layout(location = 5) flat out uint f_rotation_sc;
layout(location = 6) flat out uvec4 f_uv_or_effects;
// ---------- Uniforms (single block — avoids spirv-cross reordering on Metal) ----------
layout(set = 1, binding = 0) uniform Uniforms {
@@ -23,14 +23,14 @@ layout(set = 1, binding = 0) uniform Uniforms {
// ---------- SDF primitive storage buffer ----------
struct Primitive {
vec4 bounds; // 0-15: min_x, min_y, max_x, max_y
uint color; // 16-19: packed u8x4 (unpack with unpackUnorm4x8)
uint kind_flags; // 20-23: kind | (flags << 8)
float rotation; // 24-27: shader self-rotation in radians
float _pad; // 28-31: alignment padding
vec4 params; // 32-47: shape params part 1
vec4 params2; // 48-63: shape params part 2
vec4 uv_rect; // 64-79: u_min, v_min, u_max, v_max
vec4 bounds; // 0-15
uint color; // 16-19
uint flags; // 20-23
uint rotation_sc; // 24-27: packed f16 pair (sin, cos)
float _pad; // 28-31
vec4 params; // 32-47
vec4 params2; // 48-63
uvec4 uv_or_effects; // 64-79
};
layout(std430, set = 0, binding = 0) readonly buffer Primitives {
@@ -45,9 +45,9 @@ void main() {
f_local_or_uv = v_uv;
f_params = vec4(0.0);
f_params2 = vec4(0.0);
f_kind_flags = 0u;
f_rotation = 0.0;
f_uv_rect = vec4(0.0, 0.0, 1.0, 1.0);
f_flags = 0u;
f_rotation_sc = 0u;
f_uv_or_effects = uvec4(0);
gl_Position = projection * vec4(v_position * dpi_scale, 0.0, 1.0);
} else {
@@ -62,9 +62,9 @@ void main() {
f_local_or_uv = (world_pos - center) * dpi_scale; // shape-centered physical pixels
f_params = p.params;
f_params2 = p.params2;
f_kind_flags = p.kind_flags;
f_rotation = p.rotation;
f_uv_rect = p.uv_rect;
f_flags = p.flags;
f_rotation_sc = p.rotation_sc;
f_uv_or_effects = p.uv_or_effects;
gl_Position = projection * vec4(world_pos * dpi_scale, 0.0, 1.0);
}