Skip to content

Vulkan DXGI and Wayland

buntatoes edited this page Nov 28, 2026 · 1 revision

Vulkan, DXGI, and Wayland

Vodka implements its graphics, presentation, and windowing stack natively in Zig under the Apache License 2.0 with zero dependency on libwayland-client or legacy X11/display drivers.


Dynamic Vulkan 1.4 Win64 <-> SysV ICD & WSI Bridge (vk_thunks.zig)

vulkan-1.dll calls are bridged inside libvodka_ntdll.so (vodka/src/ntdll/vk_thunks.zig) directly to the host Linux Vulkan loader (libvulkan.so.1, loaded dynamically via dlopen).

Capabilities

  • Vulkan 1.4 API Surface: Full Win64 (x86_64_win) <-> System V AMD64 (c) thunk layer covering VkInstance, VkPhysicalDevice, VkDevice, VkQueue, VkCommandPool, VkCommandBuffer, VkFence, binary and timeline VkSemaphore, VkDeviceMemory, VkBuffer, VkImage, VkImageView, VkSampler, VkShaderModule, VkDescriptorSetLayout/VkDescriptorPool/VkDescriptorSet, VkPipelineLayout, VkPipelineCache, VkRenderPass, VkFramebuffer, VkQueryPool, compute & graphics pipelines, Vulkan 1.3/1.4 Dynamic Rendering, Synchronization2 (vkQueueSubmit2), and vkGetInstanceProcAddr / vkGetDeviceProcAddr.
  • Dynamic Win32 -> Wayland WSI Translation: Intercepts VK_KHR_win32_surface (vkCreateWin32SurfaceKHR, VkWin32SurfaceCreateInfoKHR) and bridges Windows HWND targets dynamically onto native Wayland WSI (VK_KHR_wayland_surface) and swapchain presentation (VkSwapchainKHR, VkSurfaceCapabilitiesKHR, VkSurfaceFormatKHR, vkAcquireNextImageKHR, vkQueuePresentKHR).
  • DXVK / VKD3D Ready Boundary: Designed to execute both native Vulkan Windows applications and Direct3D-to-Vulkan translation layers cleanly through Vodka's PE64 loader.

Live SPIR-V GPU Verification Suite

Vodka ships four standalone cross-compiled PE64 Vulkan verification binaries executed directly on the host GPU:

PE64 Binary Verified GPU Pipeline Stage
vodka_vk_test.exe Instance creation, Vulkan 1.4 API version query, physical device & VRAM/heap enumeration, logical device & queue creation
vodka_vk_compute.exe Live SPIR-V compute shader dispatch on host GPU with storage buffer upload and host-visible DMA readback validation
vodka_vk_triangle.exe Live SPIR-V vertex + fragment 2D triangle graphics render pass into an offscreen RGBA8 image with pixel readback verification
vodka_vk_3d.exe Live SPIR-V 3D depth-buffered indexed mesh render: push-constant MVP matrix, per-vertex position/color attributes, 64x64 RGBA8 color attachment + D32_SFLOAT depth buffer, two overlapping indexed quads (near emerald drawn first, far magenta drawn second), verifying hardware depth-test rejection via readback

Live D3D11-over-Vulkan & DXGI Adapter Bridge (dxgi_crt_thunks.zig)

Vodka's dxgi.dll and d3d11.dll connect to a live Vulkan-backed bridge inside libvodka_ntdll.so (vodka/src/ntdll/dxgi_crt_thunks.zig):

  • Live Adapter Enumeration: Queries the host Vulkan ICD (vkEnumeratePhysicalDevices, vkGetPhysicalDeviceProperties, vkGetPhysicalDeviceMemoryProperties) to populate real DXGI_ADAPTER_DESC / DXGI_ADAPTER_DESC1 records — including UTF-16 GPU Description, PCI VendorId, DeviceId, device-local DedicatedVideoMemory, and AdapterLuid.
  • D3D11-over-Vulkan COM Vtables: Provides Win64-ABI-compatible COM interfaces for IDXGIFactory / IDXGIFactory1, IDXGIAdapter / IDXGIAdapter1, IDXGISwapChain, ID3D11Device (D3D_FEATURE_LEVEL_11_1), and ID3D11DeviceContext.
  • GDI DIB Software Rasterizer: Accompanies the graphics bridge alongside gdi_raster.zig for 2D DIB/BitBlt rendering onto Wayland shared-memory surfaces.
  • Complete 66-Module Graphics & Imaging Stack: Paired with Vodka's cross-compiled DirectX 8–12 (vodkad3d, d3d8–d3d12, ddraw, d3dx*, d3dcompiler*, dxbc_compiler.zig), OpenGL (opengl32, glu32), Direct2D (d2d1), DirectWrite (dwrite), Windows Imaging Component (windowscodecs), and GDI+ (gdiplus) modules across all three Windows architectures.
  • Live Verification: Exercised end-to-end by vodka_dxgi_d3d11_test.exe and vodka_phase4_gfx_test.exe.

Pure-Zig Wayland Display Driver (libvodkawayland.so & vodka-wayland)

Vodka's Wayland driver (vodka/src/wayland/) is a zero-dependency pure-Zig implementation speaking the Linux Wayland binary wire protocol directly over AF_UNIX.

Wire Protocol & Core Modules

Module Responsibility
wire.zig Direct AF_UNIX stream socket transport (WAYLAND_DISPLAY / XDG_RUNTIME_DIR), sendmsg/recvmsg with SCM_RIGHTS FD passing, message framing (MessageBuilder, MessageReader, 8-byte Wayland headers)
protocol.zig Registry global discovery (wl_display, wl_registry, wl_compositor, wl_shm, xdg_wm_base, wp_fractional_scale_manager_v1, wp_viewporter, zwlr_data_control_manager_v1), xdg_wm_base.ping/pong keepalive
display.zig & display_config.zig Multi-monitor wl_output topology, logical/physical geometry, scale factors, and Win32 DisplayConfig / EnumDisplaySettings mapping
window.zig & gui_bridge.zig xdg_surface / xdg_toplevel lifecycle, HWND-to-surface table, resize/configure negotiation, Win32 CreateWindowEx / ShowWindow / message pump bridge
shm.zig & surface_pool.zig memfd_create-backed wl_shm_pool and multi-buffered SHM swapchain pool with damage tracking and buffer release recycling
clipboard.zig Wayland wl_data_device / zwlr_data_control_v1 clipboard selection and drag-and-drop (DnD) MIME-type negotiation
pointer_constraints.zig zwp_pointer_constraints_v1 (pointer lock/confine) and zwp_relative_pointer_manager_v1 for 3D games and camera look
xkb.zig XKB keymap parsing, modifier masks, dead-key composition, and Linux evdev/XKB-to-Win32 virtual-key (VK_*) / scancode translation
cursor.zig wp_cursor_shape_v1 system cursor shapes plus custom ARGB cursor surfaces
input.zig Pointer, keyboard, touch, and evdev input event routing to Win32 WM_* queues
vulkan.zig Native Wayland surface handle interop for dynamic Vulkan WSI (VK_KHR_wayland_surface)
unixlib.zig Shared-library entry point (libvodkawayland.so) exporting vodka_unix_call_funcs and vodka_unix_call_wow64_funcs (init, read_events, init_clipboard)

Compositor Diagnostics (vodka-wayland)

Running ./zig-out/bin/vodka-wayland connects to the active Wayland compositor, executes a wl_display.get_registry + wl_display.sync roundtrip, and prints a concise summary of advertised globals (wl_compositor, xdg_wm_base, wp_fractional_scale_manager_v1, wp_viewporter).

Clone this wiki locally