From 98967aad7454a1b25e9230b696e4c949d4ac7e27 Mon Sep 17 00:00:00 2001 From: fleandro <3987005+flga@users.noreply.github.com> Date: Tue, 31 Dec 2024 02:44:42 +0000 Subject: [PATCH] vendor:vulkan Use vendor:x11/xlib types when available --- .../vulkan/_gen/create_vulkan_odin_wrapper.py | 18 +++++++++++++++--- vendor/vulkan/structs.odin | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py b/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py index a0154328b..b8d7b9464 100644 --- a/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py +++ b/vendor/vulkan/_gen/create_vulkan_odin_wrapper.py @@ -58,7 +58,6 @@ OPAQUE_STRUCTS = """ wl_surface :: struct {} // Opaque struct defined by Wayland wl_display :: struct {} // Opaque struct defined by Wayland xcb_connection_t :: struct {} // Opaque struct defined by xcb -XlibDisplay :: struct {} // Opaque struct defined by Xlib IOSurfaceRef :: struct {} // Opaque struct defined by Apple’s CoreGraphics framework """ @@ -901,6 +900,10 @@ import "core:c" import win32 "core:sys/windows" _ :: win32 + +import "vendor:x11/xlib" +_ :: xlib + when ODIN_OS == .Windows { \tHINSTANCE :: win32.HINSTANCE \tHWND :: win32.HWND @@ -926,10 +929,19 @@ when ODIN_OS == .Windows { \t} } +// We want to use `vendor:x11/xlib` types so we need to match their build constraints. +when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD { +\tXlibDisplay :: xlib.Display +\tXlibWindow :: xlib.Window +\tXlibVisualID :: xlib.VisualID +} else { +\tXlibDisplay :: struct {} // Opaque struct defined by Xlib +\tXlibWindow :: c.ulong +\tXlibVisualID :: c.ulong +} + xcb_visualid_t :: u32 xcb_window_t :: u32 -XlibWindow :: uint -XlibVisualID :: uint CAMetalLayer :: struct {} MTLBuffer_id :: rawptr diff --git a/vendor/vulkan/structs.odin b/vendor/vulkan/structs.odin index b8ed60d22..3bab29f4e 100644 --- a/vendor/vulkan/structs.odin +++ b/vendor/vulkan/structs.odin @@ -7,6 +7,10 @@ import "core:c" import win32 "core:sys/windows" _ :: win32 + +import "vendor:x11/xlib" +_ :: xlib + when ODIN_OS == .Windows { HINSTANCE :: win32.HINSTANCE HWND :: win32.HWND @@ -32,10 +36,19 @@ when ODIN_OS == .Windows { } } +// We want to use `vendor:x11/xlib` types so we need to match their build constraints. +when ODIN_OS == .Linux || ODIN_OS == .FreeBSD || ODIN_OS == .OpenBSD { + XlibDisplay :: xlib.Display + XlibWindow :: xlib.Window + XlibVisualID :: xlib.VisualID +} else { + XlibDisplay :: struct {} // Opaque struct defined by Xlib + XlibWindow :: c.ulong + XlibVisualID :: c.ulong +} + xcb_visualid_t :: u32 xcb_window_t :: u32 -XlibWindow :: uint -XlibVisualID :: uint CAMetalLayer :: struct {} MTLBuffer_id :: rawptr @@ -9776,7 +9789,6 @@ VideoEncodeH265ReferenceInfo :: struct { wl_surface :: struct {} // Opaque struct defined by Wayland wl_display :: struct {} // Opaque struct defined by Wayland xcb_connection_t :: struct {} // Opaque struct defined by xcb -XlibDisplay :: struct {} // Opaque struct defined by Xlib IOSurfaceRef :: struct {} // Opaque struct defined by Apple’s CoreGraphics framework // Aliases PhysicalDeviceVariablePointerFeatures :: PhysicalDeviceVariablePointersFeatures