Major reorg

This commit is contained in:
Zachary Levy
2026-04-30 18:49:38 -07:00
parent fd64bc01bf
commit 87d4c9a0b5
16 changed files with 2293 additions and 2259 deletions
@@ -52,7 +52,7 @@ struct Uniforms
float2 _pad0;
};
struct Backdrop_Primitive
struct Gaussian_Blur_Primitive
{
float4 bounds;
float4 radii;
@@ -61,7 +61,7 @@ struct Backdrop_Primitive
uint color;
};
struct Backdrop_Primitive_1
struct Gaussian_Blur_Primitive_1
{
float4 bounds;
float4 radii;
@@ -70,9 +70,9 @@ struct Backdrop_Primitive_1
uint color;
};
struct Backdrop_Primitives
struct Gaussian_Blur_Primitives
{
Backdrop_Primitive_1 primitives[1];
Gaussian_Blur_Primitive_1 primitives[1];
};
constant spvUnsafeArray<float2, 6> _97 = spvUnsafeArray<float2, 6>({ float2(0.0), float2(1.0, 0.0), float2(0.0, 1.0), float2(0.0, 1.0), float2(1.0, 0.0), float2(1.0) });
@@ -87,7 +87,7 @@ struct main0_out
float4 gl_Position [[position]];
};
vertex main0_out main0(constant Uniforms& _13 [[buffer(0)]], const device Backdrop_Primitives& _69 [[buffer(1)]], uint gl_VertexIndex [[vertex_id]], uint gl_InstanceIndex [[instance_id]])
vertex main0_out main0(constant Uniforms& _13 [[buffer(0)]], const device Gaussian_Blur_Primitives& _69 [[buffer(1)]], uint gl_VertexIndex [[vertex_id]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
if (_13.mode == 0u)
@@ -102,7 +102,7 @@ vertex main0_out main0(constant Uniforms& _13 [[buffer(0)]], const device Backdr
}
else
{
Backdrop_Primitive p;
Gaussian_Blur_Primitive p;
p.bounds = _69.primitives[int(gl_InstanceIndex)].bounds;
p.radii = _69.primitives[int(gl_InstanceIndex)].radii;
p.half_size = _69.primitives[int(gl_InstanceIndex)].half_size;
Binary file not shown.
+6 -6
View File
@@ -10,7 +10,7 @@ struct Uniforms
uint mode;
};
struct Base_2D_Primitive
struct Core_2D_Primitive
{
float4 bounds;
uint color;
@@ -23,7 +23,7 @@ struct Base_2D_Primitive
uint4 effects;
};
struct Base_2D_Primitive_1
struct Core_2D_Primitive_1
{
float4 bounds;
uint color;
@@ -36,9 +36,9 @@ struct Base_2D_Primitive_1
uint4 effects;
};
struct Base_2D_Primitives
struct Core_2D_Primitives
{
Base_2D_Primitive_1 primitives[1];
Core_2D_Primitive_1 primitives[1];
};
struct main0_out
@@ -60,7 +60,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 Base_2D_Primitives& _75 [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
vertex main0_out main0(main0_in in [[stage_in]], constant Uniforms& _12 [[buffer(0)]], const device Core_2D_Primitives& _75 [[buffer(1)]], uint gl_InstanceIndex [[instance_id]])
{
main0_out out = {};
if (_12.mode == 0u)
@@ -76,7 +76,7 @@ vertex main0_out main0(main0_in in [[stage_in]], constant Uniforms& _12 [[buffer
}
else
{
Base_2D_Primitive p;
Core_2D_Primitive p;
p.bounds = _75.primitives[int(gl_InstanceIndex)].bounds;
p.color = _75.primitives[int(gl_InstanceIndex)].color;
p.flags = _75.primitives[int(gl_InstanceIndex)].flags;
Binary file not shown.
+10 -10
View File
@@ -3,7 +3,7 @@
// Unified backdrop blur vertex shader.
// Handles both the 1D separable blur passes (fullscreen triangle, mode 0; used for
// BOTH the H-pass and V-pass) and the composite pass (instanced unit-quad over
// Backdrop_Primitive storage buffer, mode 1) for the second PSO of the backdrop bracket.
// Gaussian_Blur_Primitive storage buffer, mode 1) for the second PSO of the backdrop bracket.
// The first PSO (downsample) uses backdrop_fullscreen.vert.
//
// No vertex buffer for either mode. Mode 0 uses gl_VertexIndex 0..2 for a single
@@ -33,7 +33,7 @@ layout(location = 4) flat out float f_half_feather;
// --- Uniforms (set 1) ---
// Backdrop pipeline's own uniform block — distinct from the main pipeline's
// Vertex_Uniforms. `mode` selects between H-blur (0) and V-composite (1).
// Vertex_Uniforms_2D. `mode` selects between H-blur (0) and V-composite (1).
layout(set = 1, binding = 0) uniform Uniforms {
mat4 projection;
float dpi_scale;
@@ -41,18 +41,18 @@ layout(set = 1, binding = 0) uniform Uniforms {
vec2 _pad0;
};
// --- Backdrop primitive storage buffer (set 0) ---
// --- Gaussian blur primitive storage buffer (set 0) ---
// 48 bytes, std430-natural layout (no implicit padding). vec4 members are
// front-loaded so their 16-byte alignment is satisfied without holes; the
// vec2 and scalar tail packs tight to land the struct at a clean 48-byte
// stride (a multiple of 16, so the array stride needs no rounding either).
// Field semantics match the CPU-side Backdrop_Primitive declared in
// Field semantics match the CPU-side Gaussian_Blur_Primitive declared in
// levlib/draw/backdrop.odin; keep both in sync.
//
// Backdrop primitives are tint-only: outline is intentionally absent. Specialized
// Gaussian blur primitives are tint-only: outline is intentionally absent. Specialized
// edge effects (e.g. liquid-glass-style refraction outlines) would be a dedicated
// primitive type with its own pipeline rather than a flag bit here.
struct Backdrop_Primitive {
struct Gaussian_Blur_Primitive {
vec4 bounds; // 0-15: min_xy, max_xy (world-space)
vec4 radii; // 16-31: per-corner radii (physical px)
vec2 half_size; // 32-39: RRect half extents (physical px)
@@ -60,8 +60,8 @@ struct Backdrop_Primitive {
uint color; // 44-47: tint, packed RGBA u8x4
};
layout(std430, set = 0, binding = 0) readonly buffer Backdrop_Primitives {
Backdrop_Primitive primitives[];
layout(std430, set = 0, binding = 0) readonly buffer Gaussian_Blur_Primitives {
Gaussian_Blur_Primitive primitives[];
};
void main() {
@@ -82,8 +82,8 @@ void main() {
f_radii = vec4(0.0);
f_half_feather = 0.0;
} else {
// ---- Mode 1: V-composite instanced unit-quad over Backdrop_Primitive ----
Backdrop_Primitive p = primitives[gl_InstanceIndex];
// ---- Mode 1: V-composite instanced unit-quad over Gaussian_Blur_Primitive ----
Gaussian_Blur_Primitive p = primitives[gl_InstanceIndex];
// Unit-quad corners for TRIANGLELIST (2 triangles, 6 vertices):
// index 0 -> (0,0) index 3 -> (0,1)
+8 -8
View File
@@ -26,8 +26,8 @@
// working-texture coords (work_region_phys / factor), clamped to the texture bounds.
layout(set = 3, binding = 0) uniform Uniforms {
vec2 inv_source_size; // 1.0 / source_texture pixel dimensions
uint downsample_factor; // 1, 2, 4, 8, or 16
vec2 inv_source_size; // 1.0 / source_texture pixel dimensions
uint downsample_factor; // 1, 2, 4, 8, or 16
uint _pad0;
};
@@ -55,13 +55,13 @@ void main() {
// bilinear level), giving a 4-tap = 16-source-pixel uniform sample of the block.
float off = float(downsample_factor) * 0.25;
vec2 uv_tl = (src_block_center + vec2(-off, -off)) * inv_source_size;
vec2 uv_tr = (src_block_center + vec2( off, -off)) * inv_source_size;
vec2 uv_bl = (src_block_center + vec2(-off, off)) * inv_source_size;
vec2 uv_br = (src_block_center + vec2( off, off)) * inv_source_size;
vec2 uv_tr = (src_block_center + vec2(off, -off)) * inv_source_size;
vec2 uv_bl = (src_block_center + vec2(-off, off)) * inv_source_size;
vec2 uv_br = (src_block_center + vec2(off, off)) * inv_source_size;
vec4 c = texture(source_tex, uv_tl)
+ texture(source_tex, uv_tr)
+ texture(source_tex, uv_bl)
+ texture(source_tex, uv_br);
+ texture(source_tex, uv_tr)
+ texture(source_tex, uv_bl)
+ texture(source_tex, uv_br);
out_color = c * 0.25;
}
}
+6 -6
View File
@@ -23,10 +23,10 @@ layout(set = 1, binding = 0) uniform Uniforms {
};
// ---------- SDF primitive storage buffer ----------
// Mirrors the CPU-side Base_2D_Primitive in pipeline_2d_base.odin. Named with the
// pipeline prefix so a project-wide grep on the type name matches both the GLSL
// Mirrors the CPU-side Core_2D_Primitive in core_2d.odin. Named with the
// subsystem prefix so a project-wide grep on the type name matches both the GLSL
// declaration and the Odin declaration.
struct Base_2D_Primitive {
struct Core_2D_Primitive {
vec4 bounds; // 0-15
uint color; // 16-19
uint flags; // 20-23
@@ -38,8 +38,8 @@ struct Base_2D_Primitive {
uvec4 effects; // 80-95: gradient/outline parameters (read when .Gradient/.Outline)
};
layout(std430, set = 0, binding = 0) readonly buffer Base_2D_Primitives {
Base_2D_Primitive primitives[];
layout(std430, set = 0, binding = 0) readonly buffer Core_2D_Primitives {
Core_2D_Primitive primitives[];
};
// ---------- Entry point ----------
@@ -57,7 +57,7 @@ void main() {
gl_Position = projection * vec4(v_position * dpi_scale, 0.0, 1.0);
} else {
// ---- Mode 1: SDF instanced quads ----
Base_2D_Primitive p = primitives[gl_InstanceIndex];
Core_2D_Primitive p = primitives[gl_InstanceIndex];
vec2 corner = v_position; // unit quad corners: (0,0)-(1,1)
vec2 world_pos = mix(p.bounds.xy, p.bounds.zw, corner);