Skip to content

Commit 609d888

Browse files
committedMar 27, 2018
vulkan-docs-v1.1.70 : introducing Vulkan version 1.1 and ErupteD breaking changes. See README.md
1 parent ab0a34f commit 609d888

13 files changed

+8779
-8337
lines changed
 

‎README.md

+75-100
Large diffs are not rendered by default.

‎_dub.json

+4-74
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,10 @@
11
{
2-
"name" : "erupted",
3-
"description" : "Auto-generated D bindings for Vulkan",
4-
"copyright" : "Copyright 2015-2016 The Khronos Group Inc.; Copyright 2016, Alex Parrill, Peter Particle",
2+
"name" : "erupted"
3+
"description" : "Auto-generated D bindings for Vulkan"
4+
"copyright" : "Copyright 2015-2016 The Khronos Group Inc.; Copyright 2016 Alex Parrill; Copyright 2018 Peter Particle"
55
"authors" : [ "Alex Parrill", "Peter Particle" ],
6-
"targetType" : "library",
6+
"targetType" : "sourceLibrary",
77
"license" : "BSD 2-clause",
8-
"configurations" : [
9-
{
10-
"name" : "default",
11-
},
12-
13-
{
14-
"name" : "with-derelict-loader",
15-
"versions" : [ "ERUPTED_FROM_DERELICT" ],
16-
"dependencies" : {
17-
"derelict-util" : "~>2.0.4"
18-
},
19-
},
20-
21-
{
22-
"name" : "dub-platform-xlib",
23-
"versions" : [ "VK_USE_PLATFORM_XLIB_KHR" ],
24-
"dependencies" : {
25-
"xlib-d" : "~>0.1.1"
26-
}
27-
},
28-
29-
{
30-
"name" : "dub-platform-xcb",
31-
"versions" : [ "VK_USE_PLATFORM_XCB_KHR" ],
32-
"dependencies" : {
33-
"xcb-d" : "~>2.1.0"
34-
},
35-
},
36-
37-
{
38-
"name" : "dub-platform-wayland",
39-
"versions" : [ "VK_USE_PLATFORM_WAYLAND_KHR" ],
40-
"dependencies" : {
41-
"wayland:client" : "~>0.1.0"
42-
}
43-
},
44-
45-
{
46-
"name" : "dub-platform-xlib-derelict-loader",
47-
"versions" : [ "VK_USE_PLATFORM_XLIB_KHR", "ERUPTED_FROM_DERELICT" ],
48-
"dependencies" : {
49-
"xlib-d" : "~>0.1.1",
50-
"derelict-util" : "~>2.0.4"
51-
}
52-
},
53-
54-
{
55-
"name" : "dub-platform-xcb-derelict-loader",
56-
"versions" : [ "VK_USE_PLATFORM_XCB_KHR", "ERUPTED_FROM_DERELICT" ],
57-
"dependencies" : {
58-
"xcb-d" : "~>2.1.0",
59-
"derelict-util" : "~>2.0.4"
60-
},
61-
},
62-
63-
{
64-
"name" : "dub-platform-wayland-derelict-loader",
65-
"versions" : [ "VK_USE_PLATFORM_WAYLAND_KHR", "ERUPTED_FROM_DERELICT" ],
66-
"dependencies" : {
67-
"wayland:client" : "~>0.1.0",
68-
"derelict-util" : "~>2.0.4"
69-
}
70-
},
71-
],
728

739
"subPackages" : [
7410
{
@@ -79,9 +15,6 @@
7915
"dependencies" : {
8016
"erupted" : { "path": "." }
8117
},
82-
"subConfigurations" : {
83-
"erupted" : "with-derelict-loader"
84-
}
8518
},
8619
{
8720
"name" : "layers",
@@ -90,9 +23,6 @@
9023
"sourceFiles" : [ "examples/layers.d" ],
9124
"dependencies" : {
9225
"erupted" : { "path": "." }
93-
},
94-
"subConfigurations" : {
95-
"erupted": "with-derelict-loader"
9626
}
9727
}
9828
]

‎dub.sdl

+16-66
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,24 @@
1-
name "erupted"
2-
description "Auto-generated D bindings for Vulkan"
3-
copyright "Copyright 2015-2016 The Khronos Group Inc.; Copyright 2016 Alex Parrill Peter Particle"
4-
authors "Alex Parrill" "Peter Particle"
5-
targetType "sourceLibrary"
6-
license "BSD 2-clause"
7-
8-
// load vulkan vkGetInstanceProcAddr manually os specific or with glfw or similar
9-
configuration "default"
10-
11-
// load vulkan vkGetInstanceProcAddr with derelict
12-
configuration "with-derelict-loader" {
13-
versions "ERUPTED_FROM_DERELICT"
14-
dependency "derelict-util" version = "~>2.0.4"
15-
}
16-
17-
// enable xlib specific functionality
18-
configuration "dub-platform-xlib" {
19-
versions "VK_USE_PLATFORM_XLIB_KHR"
20-
dependency "xlib-d" version = "~>0.1.1"
21-
}
22-
23-
// enable xcb specific functionality
24-
configuration "dub-platform-xcb" {
25-
versions "VK_USE_PLATFORM_XCB_KHR"
26-
dependency "xcb-d" version = "~>2.1.0"
27-
}
28-
29-
// enable wayland specific functionality
30-
configuration "dub-platform-wayland" {
31-
versions "VK_USE_PLATFORM_WAYLAND_KHR"
32-
dependency "wayland:client" version = "~>0.1.0"
33-
}
34-
35-
// enable xlib specific functionality load vkGetInstanceProcAddr with derelict
36-
configuration "dub-platform-xlib-derelict-loader" {
37-
versions "VK_USE_PLATFORM_XLIB_KHR" "ERUPTED_FROM_DERELICT"
38-
dependency "xlib-d" version = "~>0.1.1"
39-
dependency "derelict-util" version = "~>2.0.4"
40-
}
41-
42-
// enable xcb specific functionality load vkGetInstanceProcAddr with derelict
43-
configuration "dub-platform-xcb-derelict-loader" {
44-
versions "VK_USE_PLATFORM_XCB_KHR" "ERUPTED_FROM_DERELICT"
45-
dependency "xcb-d" version = "~>2.1.0"
46-
dependency "derelict-util" version = "~>2.0.4"
47-
}
48-
49-
// enable wayland specific functionality load vkGetInstanceProcAddr with derelict
50-
configuration "dub-platform-wayland-derelict-loader" {
51-
versions "VK_USE_PLATFORM_WAYLAND_KHR" "ERUPTED_FROM_DERELICT"
52-
dependency "wayland:client" version = "~>0.1.0"
53-
dependency "derelict-util" version = "~>2.0.4"
54-
}
1+
name "erupted"
2+
description "Auto-generated D bindings for Vulkan"
3+
copyright "Copyright 2015-2016 The Khronos Group Inc.; Copyright 2016 Alex Parrill; Copyright 2018 Peter Particle"
4+
authors "Alex Parrill" "Peter Particle"
5+
targetType "sourceLibrary"
6+
license "BSD 2-clause"
557

568
// example how to initialize a logical device
579
subPackage {
58-
name "devices"
59-
description "Simple Vulkan example"
60-
targetType "executable"
61-
sourceFiles "examples/devices.d"
62-
dependency "erupted" path = "."
63-
subConfiguration "erupted" "with-derelict-loader"
10+
name "devices"
11+
description "Simple Vulkan example"
12+
targetType "executable"
13+
sourceFiles "examples/devices.d"
14+
dependency "erupted" path = "."
6415
}
6516

6617
// example how query and enable layers
6718
subPackage {
68-
name "layers"
69-
description "Simple Vulkan example"
70-
targetType "executable"
71-
sourceFiles "examples/layers.d"
72-
dependency "erupted" path = "."
73-
subConfiguration "erupted" "with-derelict-loader"
19+
name "layers"
20+
description "Simple Vulkan example"
21+
targetType "executable"
22+
sourceFiles "examples/layers.d"
23+
dependency "erupted" path = "."
7424
}

‎examples/platform/vulkan_wayland.d

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module vulkan_wayland;
2+
3+
// to your projects dub.sdl add:
4+
// dependency "wayland:client" version = "~>0.1.0"
5+
public import wayland.native.client;
6+
import erupted.platform_extensions;
7+
8+
// the mixed in code requires structs wl_display and wl_surface
9+
// the later one is named differently in the dependency
10+
// and we need t alias its name:
11+
alias wl_surface = wl_proxy;
12+
13+
// mixin platform code
14+
// drop VK_ prefix of extensions and/or platform protections
15+
mixin Platform_Extensions!USE_PLATFORM_WAYLAND_KHR;

‎examples/platform/vulkan_windows.d

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module vulkan_windows;
2+
3+
// this module is in druntime
4+
// no need for an external dependency
5+
public import core.sys.windows.windows;
6+
import erupted.platform_extensions;
7+
8+
// mixin platform code
9+
// drop VK_ prefix of extensions and/or platform protections
10+
mixin Platform_Extensions!USE_PLATFORM_WIN32_KHR;

‎examples/platform/vulkan_xcb.d

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module vulkan_xcb;
2+
3+
// to your projects dub.sdl add:
4+
// dependency "xcb-d" version = "~>2.1.0"
5+
public import xcb.xcb;
6+
import erupted.platform_extensions;
7+
8+
// mixin platform code
9+
// drop VK_ prefix of extensions and/or platform protections
10+
mixin Platform_Extensions!USE_PLATFORM_XCB_KHR;

‎examples/platform/vulkan_xlib.d

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module vulkan_xlib;
2+
3+
// to your projects dub.sdl add:
4+
// dependency "xlib-d" version = "~>0.1.1"
5+
public import X11.Xlib;
6+
import erupted.platform_extensions;
7+
8+
// mixin platform code
9+
// drop VK_ prefix of extensions and/or platform protections
10+
mixin Platform_Extensions!USE_PLATFORM_XLIB_KHR;

‎source/erupted/dispatch_device.d

+854
Large diffs are not rendered by default.

‎source/erupted/functions.d

+1,256-2,599
Large diffs are not rendered by default.

‎source/erupted/package.d

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* Dlang vulkan types and function definitions package
3+
*
4+
* Copyright: Copyright 2015-2016 The Khronos Group Inc.; Copyright 2016 Alex Parrill, Peter Particle.
5+
* License: $(https://opensource.org/licenses/MIT, MIT License).
6+
* Authors: Copyright 2016 Alex Parrill, Peter Particle
7+
*/
18
module erupted;
29
public import erupted.types;
310
public import erupted.functions;

‎source/erupted/platform_extensions.d

+832
Large diffs are not rendered by default.

‎source/erupted/types.d

+5,571-5,498
Large diffs are not rendered by default.

‎source/erupted/vulkan_lib_loader.d

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* Dlang vulkan lib loader retrieving vkGetInstanceProcAddr for windows and posix systems
3+
*
4+
* Copyright: Copyright 2015-2016 The Khronos Group Inc.; Copyright 2016 Alex Parrill, Peter Particle.
5+
* License: $(https://opensource.org/licenses/MIT, MIT License).
6+
* Authors: Copyright 2016 Alex Parrill, Peter Particle
7+
*/
8+
module erupted.vulkan_lib_loader;
9+
10+
import erupted.functions;
11+
import core.stdc.stdio : fprintf, stderr, FILE;
12+
13+
nothrow @nogc:
14+
15+
16+
/// private helper functions for windows platform
17+
version( Windows ) {
18+
private:
19+
import core.sys.windows.windows;
20+
HMODULE vulkan_lib = null;
21+
auto loadLib() { return LoadLibrary( "vulkan-1.dll" ); }
22+
auto freeLib() { return FreeLibrary( vulkan_lib ) != 0; }
23+
auto loadSym() { return cast( PFN_vkGetInstanceProcAddr )GetProcAddress( vulkan_lib, "vkGetInstanceProcAddr" ); }
24+
void logLibError( FILE* log_stream, const( char )* message ) {
25+
fprintf( log_stream, "%svulkan-1.dll! Error code: 0x%x\n", message, GetLastError());
26+
}
27+
}
28+
29+
30+
/// private helper functions for posix platforms
31+
version( Posix ) {
32+
private:
33+
import core.sys.posix.dlfcn : dlerror, dlopen, dlclose, dlsym, RTLD_LAZY, RTLD_LOCAL;
34+
void* vulkan_lib = null;
35+
auto loadLib() { return dlopen( "libvulkan.so.1", RTLD_LAZY | RTLD_LOCAL ); }
36+
auto freeLib() { return dlclose( vulkan_lib ) == 0; }
37+
auto loadSym() { return cast( PFN_vkGetInstanceProcAddr )dlsym( vulkan_lib, "vkGetInstanceProcAddr" ); }
38+
void logLibError( FILE* log_stream, const( char )* message ) {
39+
fprintf( log_stream, "%slibvulkan.so.1! Error: %s\n", message, dlerror );
40+
}
41+
}
42+
43+
44+
/// tries to load the platform vulkan dynamic link library
45+
/// the library handle / pointer is stored privately in this module
46+
/// errors are reported to a specifiable stream which is standard error by default
47+
/// Params:
48+
/// log_stream = file stream to receive error messages, default stderr
49+
/// Returns: true if the vulkan lib could be loaded, false otherwise
50+
bool loadVulkanLib( FILE* log_stream = stderr ) {
51+
vulkan_lib = loadLib;
52+
if( !vulkan_lib ) {
53+
logLibError( log_stream, "Could not load " );
54+
return false;
55+
} else {
56+
return true;
57+
}
58+
}
59+
60+
61+
/// tries to load the vkGetInstanceProcAddr function from the module private lib handle / pointer
62+
/// if the lib was not loaded so far loadVulkanLib is called
63+
/// errors are reported to a specifiable stream which is standard error by default
64+
/// Params:
65+
/// log_stream = file stream to receive error messages, default stderr
66+
/// Returns: vkGetInstanceProcAddr if it could be loaded from the lib, null otherwise
67+
PFN_vkGetInstanceProcAddr loadGetInstanceProcAddr( FILE* log_stream = stderr ) {
68+
if( !vulkan_lib && !loadVulkanLib( log_stream )) {
69+
fprintf( log_stream, "Cannot not retrieve vkGetInstanceProcAddr as vulkan lib is not loaded!" );
70+
return null;
71+
}
72+
auto getInstanceProcAddr = loadSym;
73+
if( !getInstanceProcAddr )
74+
logLibError( log_stream, "Could not retrieve vkGetInstanceProcAddr from " );
75+
return getInstanceProcAddr;
76+
}
77+
78+
79+
/// tries to free / unload the previously loaded platform vulkan lib
80+
/// errors are reported to a specifiable stream which is standard error by default
81+
/// Params:
82+
/// log_stream = file stream to receive error messages, default stderr
83+
/// Returns: true if the vulkan lib could be freed, false otherwise
84+
bool freeVulkanLib( FILE* log_stream = stderr ) {
85+
if( !vulkan_lib ) {
86+
fprintf( log_stream, "Cannot free vulkan lib as it is not loaded!" );
87+
return false;
88+
} else if( freeLib ) {
89+
logLibError( log_stream, "Could not unload " );
90+
return false;
91+
} else {
92+
return true;
93+
}
94+
}
95+
96+
97+
/// Combines loadVulkanLib, loadGetInstanceProcAddr and loadGlobalLevelFunctions( PFN_vkGetInstanceProcAddr )
98+
/// from module erupted.functions. If this function succeeds the function vkGetInstanceProcAddr
99+
/// from module erupted.functions can be used freely. Moreover the required functions to initialize a
100+
/// vulkan instance a vkEnumerateInstanceExtensionProperties, vkEnumerateInstanceLayerProperties and vkCreateInstance
101+
/// are available as well. To get all the other functions an vulkan instance must be created and with it
102+
/// loadInstanceLevelFunctions be called from either erupted.functions or through a custom tailored module
103+
/// with mixed in extensions through the erupted.platform.mixin_extensions mechanism.
104+
/// Additional device based functions can then be loaded with loadDeviceLevelFunctions passing in the instance or
105+
/// with creating a vulkan device beforehand and calling the same function with it.
106+
///
107+
/// Note: as this function indirectly calls loadVulkanLib loading the vulkan lib, freeVulkanLib should be called
108+
/// at some point in the process to cleanly free / unload the lib
109+
/// all errors during vulkan lib loading and vkGetInstanceProcAddr retrieving are reported to log_stream, default stderr
110+
/// log_stream = file stream to receive error messages, default stderr
111+
/// Returns: true if the vulkan lib could be freed, false otherwise
112+
bool loadGlobalLevelFunctions( FILE* log_stream = stderr ) {
113+
auto getInstanceProcAddr = loadGetInstanceProcAddr( log_stream );
114+
if( !getInstanceProcAddr ) return false;
115+
erupted.functions.loadGlobalLevelFunctions( getInstanceProcAddr );
116+
return true;
117+
}
118+
119+

0 commit comments

Comments
 (0)
Please sign in to comment.