feat(runtime): the native window, for a graphics API that makes its own surface

win_native_window / win_native_instance hand a Vulkan swapchain what it is created on: the
HWND and module instance on Windows (VkWin32SurfaceCreateInfoKHR), the game's view on macOS.
Headless builds define both as null (weak on macOS, so a windowed link keeps cocoa.ll's), so
code that asks for them links everywhere and simply finds no window.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-15 10:42:19 +03:00
parent f97d54aa2a
commit 51d82063aa
4 changed files with 48 additions and 0 deletions

View file

@ -255,6 +255,21 @@ out:
ret void
}
; ---- the native window, for a graphics API that makes its own surface ------------------
; A Vulkan swapchain is created on the window itself (VkWin32SurfaceCreateInfoKHR takes the
; module instance and the HWND), not through a context this file attaches. Null before
; win_open has made the window; the same names are stubs returning null in a headless build.
define ptr @win_native_window() {
entry:
%h = load ptr, ptr @W_hwnd
ret ptr %h
}
define ptr @win_native_instance() {
entry:
%inst = call ptr @GetModuleHandleA(ptr null)
ret ptr %inst
}
; set (%on != 0) or clear a key's bit in the 256-bit held set
define void @win_held_bit(i32 %k, i32 %on) {
entry: