Files
Verbatim/assets/shaders/cell.vert
T
Emil 6e9e90fb34 feat: Vulkan renderer with instanced rendering (Phase 4)
VulkanRenderer using ash 0.38 + winit:
- Instance with KHR_surface + xlib + wayland extensions
- Physical device selection (first GPU with graphics+present)
- Swapchain (FIFO present mode, B8G8R8A8_UNORM)
- Render pass with color attachment
- Graphics pipeline with instanced rendering:
  - Vertex buffer: unit quad (4 verts, 6 indices)
  - Instance buffer: 8000 CellInstance structs (32 bytes each)
  - 2 vertex bindings: per-vertex (quad pos) + per-instance (grid pos,
    atlas UV, fg/bg colors)
  - Push constants: screen size + cell size
- Glyph atlas: R8_UNORM texture, uploaded via staging buffer
  - fontdue rasterizes DejaVu Sans Mono at startup
  - Linear filtering sampler
- Descriptor set: combined image sampler for atlas
- 2 frames in flight with semaphores + fences
- Persistent mapped instance buffer (zero-copy per frame)

Shaders (pre-compiled SPIR-V):
- cell.vert: positions quad from instance data, maps to clip space
- cell.frag: samples atlas alpha, blends fg/bg

--mode vulkan: tries Vulkan, falls back to softbuffer window mode
109 tests, 0 failures
2026-06-21 00:34:01 +03:00

29 lines
734 B
GLSL

#version 450
layout(push_constant) uniform PC {
vec2 screen_size;
vec2 cell_size;
} pc;
layout(location = 0) in vec2 in_pos;
layout(location = 1) in vec2 in_grid;
layout(location = 2) in vec4 in_atlas;
layout(location = 3) in vec4 in_fg;
layout(location = 4) in vec4 in_bg;
layout(location = 0) out vec2 out_uv;
layout(location = 1) out vec4 out_fg;
layout(location = 2) out vec4 out_bg;
void main() {
vec2 pixel = in_grid * pc.cell_size + in_pos * pc.cell_size;
vec2 clip = vec2(
2.0 * pixel.x / pc.screen_size.x - 1.0,
1.0 - 2.0 * pixel.y / pc.screen_size.y
);
gl_Position = vec4(clip, 0.0, 1.0);
out_uv = in_atlas.xy + in_pos * in_atlas.zw;
out_fg = in_fg;
out_bg = in_bg;
}