diff --git a/runtime/native/cocoa.ll b/runtime/native/cocoa.ll index 5a417a88..930bed8c 100644 --- a/runtime/native/cocoa.ll +++ b/runtime/native/cocoa.ll @@ -1670,3 +1670,16 @@ go: out: ret void } + +; ---- the native window, for a graphics API that makes its own surface ------------------ +; win32.ll's contract: on macOS the view the game draws in (a Metal-backed layer would hang +; off it); there is no module instance to hand over, so that one is null. +define ptr @win_native_window() { +entry: + %v = load ptr, ptr @W_view + ret ptr %v +} +define ptr @win_native_instance() { +entry: + ret ptr null +} diff --git a/runtime/native/gl.ll b/runtime/native/gl.ll index 74fbca7c..c8aeabe1 100644 --- a/runtime/native/gl.ll +++ b/runtime/native/gl.ll @@ -366,3 +366,13 @@ entry: %t = add i64 %m, %us ret i64 %t } + +; headless on macOS: no window, so nothing for a graphics API to make a surface on +define weak ptr @win_native_window() { +entry: + ret ptr null +} +define weak ptr @win_native_instance() { +entry: + ret ptr null +} diff --git a/runtime/native/gl_win_nowin.ll b/runtime/native/gl_win_nowin.ll index 84cf2f49..4b442a84 100644 --- a/runtime/native/gl_win_nowin.ll +++ b/runtime/native/gl_win_nowin.ll @@ -42,3 +42,13 @@ define void @win_toggle_fullscreen() { entry: ret void } + +; headless: no window, so nothing for a graphics API to make a surface on (win32.ll has the real ones) +define ptr @win_native_window() { +entry: + ret ptr null +} +define ptr @win_native_instance() { +entry: + ret ptr null +} diff --git a/runtime/native/win32.ll b/runtime/native/win32.ll index e7296d60..a383d26e 100644 --- a/runtime/native/win32.ll +++ b/runtime/native/win32.ll @@ -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: