-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
12,642 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# X11/X.h | ||
struct Window <: AbstractJuliaSDT end | ||
struct VisualID <: AbstractJuliaSDT end | ||
# X11/Xlib.h | ||
struct Display <: AbstractJuliaSIT end | ||
# X11/Xrandr.h | ||
struct RROutput <: AbstractJuliaSIT end | ||
# xcb.h | ||
struct xcb_connection_t <: AbstractJuliaSIT end | ||
struct xcb_window_t <: AbstractJuliaSIT end | ||
struct xcb_visualid_t <: AbstractJuliaSIT end | ||
# Wayland | ||
struct wl_display <: AbstractJuliaSIT end | ||
struct wl_surface <: AbstractJuliaSIT end | ||
# Mir | ||
struct MirConnection <: AbstractJuliaSIT end | ||
struct MirSurface <: AbstractJuliaSIT end | ||
# Android | ||
struct ANativeWindow <: AbstractJuliaSIT end | ||
# Windows | ||
struct HINSTANCE <: AbstractJuliaSIT end | ||
struct HWND <: AbstractJuliaSIT end | ||
struct HMONITOR <: AbstractJuliaSIT end | ||
struct HANDLE <: AbstractJuliaSIT end | ||
struct DWORD <: AbstractJuliaSIT end | ||
struct LPCWSTR <: AbstractJuliaSIT end | ||
struct SECURITY_ATTRIBUTES <: AbstractJuliaSIT end | ||
# DirectFB | ||
struct IDirectFB <: AbstractJuliaSIT end | ||
struct IDirectFBSurface <: AbstractJuliaSIT end | ||
# Zircon | ||
struct zx_handle_t <: AbstractJuliaSIT end | ||
# GGP C | ||
struct GgpStreamDescriptor <: AbstractJuliaSIT end | ||
struct GgpFrameToken <: AbstractJuliaSIT end | ||
|
||
add_definition(Dict( | ||
:Window => Window(), | ||
:VisualID => VisualID(), | ||
:Display => Display(), | ||
:RROutput => RROutput(), | ||
:xcb_connection_t => xcb_connection_t(), | ||
:xcb_window_t => xcb_window_t(), | ||
:xcb_visualid_t => xcb_visualid_t(), | ||
:wl_display => wl_display(), | ||
:wl_surface => wl_surface(), | ||
:MirConnection => MirConnection(), | ||
:MirSurface => MirSurface(), | ||
:ANativeWindow => ANativeWindow(), | ||
:HINSTANCE => HINSTANCE(), | ||
:HWND => HWND(), | ||
:HMONITOR => HMONITOR(), | ||
:HANDLE => HANDLE(), | ||
:DWORD => DWORD(), | ||
:LPCWSTR => LPCWSTR(), | ||
:SECURITY_ATTRIBUTES => SECURITY_ATTRIBUTES(), | ||
:IDirectFB => IDirectFB(), | ||
:IDirectFBSurface => IDirectFBSurface(), | ||
:zx_handle_t => zx_handle_t(), | ||
:GgpStreamDescriptor => GgpStreamDescriptor(), | ||
:GgpFrameToken => GgpFrameToken(), | ||
)) | ||
|
||
Generators.translate(::Window, options=Dict()) = :Window | ||
Generators.translate(::VisualID, options=Dict()) = :VisualID | ||
Generators.translate(::Display, options=Dict()) = :Display | ||
Generators.translate(::RROutput, options=Dict()) = :RROutput | ||
Generators.translate(::xcb_connection_t, options=Dict()) = :xcb_connection_t | ||
Generators.translate(::xcb_window_t, options=Dict()) = :xcb_window_t | ||
Generators.translate(::xcb_visualid_t, options=Dict()) = :xcb_visualid_t | ||
Generators.translate(::wl_display, options=Dict()) = :wl_display | ||
Generators.translate(::wl_surface, options=Dict()) = :wl_surface | ||
Generators.translate(::MirConnection, options=Dict()) = :MirConnection | ||
Generators.translate(::MirSurface, options=Dict()) = :MirSurface | ||
Generators.translate(::ANativeWindow, options=Dict()) = :ANativeWindow | ||
Generators.translate(::HINSTANCE, options=Dict()) = :HINSTANCE | ||
Generators.translate(::HWND, options=Dict()) = :HWND | ||
Generators.translate(::HMONITOR, options=Dict()) = :HMONITOR | ||
Generators.translate(::HANDLE, options=Dict()) = :HANDLE | ||
Generators.translate(::DWORD, options=Dict()) = :DWORD | ||
Generators.translate(::LPCWSTR, options=Dict()) = :LPCWSTR | ||
Generators.translate(::SECURITY_ATTRIBUTES, options=Dict()) = :SECURITY_ATTRIBUTES | ||
Generators.translate(::IDirectFB, options=Dict()) = :IDirectFB | ||
Generators.translate(::IDirectFBSurface, options=Dict()) = :IDirectFBSurface | ||
Generators.translate(::zx_handle_t, options=Dict()) = :zx_handle_t | ||
Generators.translate(::GgpStreamDescriptor, options=Dict()) = :GgpStreamDescriptor | ||
Generators.translate(::GgpFrameToken, options=Dict()) = :GgpFrameToken |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[general] | ||
library_name = "libvulkan" | ||
|
||
output_file_path = "./src/LibVulkan.jl" | ||
|
||
module_name = "LibVulkan" | ||
|
||
export_symbol_prefixes = ["VK_", "Vk", "vk"] | ||
|
||
prologue_file_path = "./gen/prologue.jl" | ||
epilogue_file_path = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using Libdl: Libdl | ||
|
||
@static if !isempty(get(ENV, "JULIA_VULKAN_LIBNAME", "")) | ||
const libvulkan = ENV["JULIA_VULKAN_LIBNAME"] | ||
elseif Sys.iswindows() | ||
const libvulkan = "vulkan-1.dll" | ||
elseif Sys.isapple() | ||
const libvulkan = "libvulkan.dylib" | ||
elseif Sys.islinux() | ||
const libvulkan = "libvulkan.so.1" | ||
else | ||
const libvulkan = "libvulkan" | ||
end | ||
|
||
const libvulkan_handle = Ref{Ptr{Cvoid}}(0) | ||
|
||
function __init__() | ||
libname = Libdl.find_library(libvulkan) | ||
if isempty(libname) | ||
error(""" | ||
Failed to retrieve a valid Vulkan library called '$libvulkan'. | ||
If you configure the `JULIA_VULKAN_LIBNAME` environment variable before precompiling | ||
VulkanCore, it will be used instead of '$libvulkan'. You may also manually add search | ||
paths by appending them to Lidbl.DL_LOAD_PATH, but note that this may have repercussions | ||
beyond this package. | ||
""") | ||
end | ||
return libvulkan_handle[] = Libdl.dlopen(libname) | ||
end | ||
|
||
#### External definitions | ||
|
||
# X11/X.h | ||
const Window = Culong | ||
const VisualID = Culong | ||
# X11/Xlib.h | ||
const Display = Cvoid # opaque struct | ||
# X11/Xrandr.h | ||
const RROutput = UInt32 | ||
# xcb.h | ||
const xcb_connection_t = Cvoid # opaque struct | ||
const xcb_window_t = UInt32 | ||
const xcb_visualid_t = UInt32 | ||
# Wayland | ||
const wl_display = Cvoid # opaque struct | ||
const wl_surface = Cvoid # opaque struct | ||
# Mir | ||
const MirConnection = Cvoid # opaque struct | ||
const MirSurface = Cvoid # opaque struct | ||
# Android | ||
const ANativeWindow = Cvoid # opaque struct | ||
# Windows | ||
const HINSTANCE = Ptr{Cvoid} | ||
const HWND = Ptr{Cvoid} | ||
const HMONITOR = Ptr{Cvoid} | ||
const HANDLE = HMONITOR | ||
const DWORD = UInt32 | ||
const LPCWSTR = UInt16 | ||
const SECURITY_ATTRIBUTES = Cvoid # opaque struct | ||
# DirectFB | ||
const IDirectFB = Cvoid # opaque struct | ||
const IDirectFBSurface = Cvoid # opaque struct | ||
# Zircon | ||
const zx_handle_t = UInt32 | ||
# GGP C | ||
const GgpStreamDescriptor = UInt32 | ||
const GgpFrameToken = UInt32 | ||
|
||
# TODO: Clang.jl should support this kinda macros | ||
VK_MAKE_VERSION(major, minor, patch) = (Cuint(major) << 22) | (Cuint(minor) << 12) | patch | ||
|
||
VK_VERSION_MAJOR(version) = Cuint(version) >> 22 | ||
VK_VERSION_MINOR(version) = (Cuint(version) >> 12) & 0x3ff | ||
VK_VERSION_PATCH(version) = Cuint(version) & 0xfff | ||
|
||
const VK_API_VERSION_1_0 = VK_MAKE_VERSION(1, 0, 0) | ||
const VK_API_VERSION_1_1 = VK_MAKE_VERSION(1, 1, 0) | ||
const VK_API_VERSION_1_2 = VK_MAKE_VERSION(1, 2, 0) |
Oops, something went wrong.