Sheet 9/10 — Driver · Software Vulkan
mzVolk
A software implementation of Vulkan. No GPU required.
| Layer | Driver · Software Vulkan |
|---|---|
| Language | C99 · SSE |
| Targets | Linux x86_64 · Linux arm32 · Windows · macOS arm64 · macOS x86_64 (Rosetta) · mzOS2 (freestanding) |
| Depends on | mzJIT |
| Used by | mzVKI |
| Organization | ZeunO8 |
| Source | Private alpha — opens with a change order on this site’s log |
General notes
mzVolk implements the Vulkan graphics API entirely in software, in pure C99. It speaks the standard ICD (Installable Client Driver) interface, so the Vulkan loader discovers and loads it exactly like a hardware driver — but every stage of the pipeline, from command-buffer recording to pixels on screen, runs on the CPU.
A draw call flows through per-vertex shading (via mzJIT), primitive assembly, full-frustum clipping, perspective divide, and a depth-tested, perspective-correct scanline rasterizer with blending, scissor, face culling, and texture sampling through combined image samplers — plus an SSE path on x86_64 that shades four pixel lanes at a time through JIT-compiled fragment shaders, and optional parallel rasterization that splits the framebuffer into row bands across worker threads (MZV_THREADS), each with its own shader executor. Presentation lands via XPutImage on X11, GDI on Windows, or an IOSurface-pooled NSView on macOS (VK_MVK_macos_surface). Each test ships with a twin that runs the identical logic on the platform’s real driver for A/B validation.
The project kept an honest, public list of what was not implemented yet — and burned it down in public. The v0.4 → v0.60 release run cleared the entire rasterizer section item by item — depth and stencil testing, the full blend matrix, scissor and culling, perspective-correct interpolation, indexed and instanced draws with multi-binding, per-instance-rate vertex input, strip/fan/line/point topologies, descriptor-backed uniform buffers, full-frustum clipping — hardened the API layer with thread-safe serialized queue submission, honest fences, and loud failures, then crossed off the big ones: textures (samplers, cube maps, arrays, and formats sampled in JIT-compiled shaders), compute pipelines (dispatch, shared memory, storage images), and — the last honest-list item — multisampling, done end-to-end by supersampling and resolving through vkCmdResolveImage, with polygon fill/line/point modes alongside. The honest list, as of v0.60, is empty.
Bill of materials — what’s in the box
- Standard Vulkan ICD — loaded by the real Vulkan loader as "mzVolk [CPU]"
- Runs freestanding on mzOS2 — vk* on the microZeus kernel, no host OS, no GPU (interpreter-only for now; JIT path is a later phase)
- Full command-buffer recording state machine, including secondary command buffers (vkCmdExecuteCommands)
- Scanline rasterizer with SSE 4-pixel fragment lanes on x86_64, NEON interpolation + pixel pack on aarch64; parallel row-band rasterization across threads (MZV_THREADS)
- Depth + stencil testing (D32_S8, dynamic stencil state, gl_FragDepth), full blend factor/op matrix + colorWriteMask, scissor + culling, perspective-correct interpolation, full-frustum clipping
- Multiple render targets: subpass color attachments beyond the first
- Multisampling (MSAA) end-to-end via supersample + vkCmdResolveImage; polygon fill/line/point modes
- Textures: samplers + combined image sampler descriptors sampled inside JIT-compiled shaders — mip chains, textureLod, texelFetch/textureSize, sRGB decode, LOD range + bias, full per-axis address modes, R8/RG8/R16F/RGBA16F formats, cube maps + 2D array textures
- Staging copies: vkCmdCopyBuffer, vkCmdCopyBufferToImage, vkCmdCopyImage
- Query pools and events alongside honest fences and serialized queue submission
- Compute pipelines: vkCmdDispatch with storage-buffer writes, honored workgroup local sizes, shared memory + barriers via phased dispatch, storage images (imageLoad/imageStore)
- Indexed, instanced, and indirect draws (vkCmdDrawIndirect / DispatchIndirect), strip/fan/line/point topologies, multi-binding + per-instance-rate + non-float32 vertex input; descriptor-backed uniform buffers with dynamic offsets, buffer views + texel buffers
- Shader execution through mzJIT: interpreter or native JIT code
- 14 pixel-exact regression modes with A/B twins against real hardware drivers
- Presentation on X11, Windows (GDI), and macOS (Cocoa / IOSurface pool)
- ≈2400 fps gradient quad, ≈620 fps per-fragment UBO shader (640×480, arm64 MacBook)