Lines 25-31
Link Here
|
25 |
#include "SDL_x11video.h" |
25 |
#include "SDL_x11video.h" |
26 |
#include "SDL_assert.h" |
26 |
#include "SDL_assert.h" |
27 |
|
27 |
|
28 |
#include "SDL_loadso.h" |
|
|
29 |
#include "SDL_x11vulkan.h" |
28 |
#include "SDL_x11vulkan.h" |
30 |
|
29 |
|
31 |
#include <X11/Xlib.h> |
30 |
#include <X11/Xlib.h> |
Lines 43-64
Link Here
|
43 |
SDL_bool hasSurfaceExtension = SDL_FALSE; |
42 |
SDL_bool hasSurfaceExtension = SDL_FALSE; |
44 |
SDL_bool hasXlibSurfaceExtension = SDL_FALSE; |
43 |
SDL_bool hasXlibSurfaceExtension = SDL_FALSE; |
45 |
SDL_bool hasXCBSurfaceExtension = SDL_FALSE; |
44 |
SDL_bool hasXCBSurfaceExtension = SDL_FALSE; |
46 |
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; |
|
|
47 |
Uint32 i; |
45 |
Uint32 i; |
48 |
if(_this->vulkan_config.loader_handle) |
46 |
if(_this->vulkan_config.vkGetInstanceProcAddr) |
49 |
return SDL_SetError("Vulkan already loaded"); |
47 |
return SDL_SetError("Vulkan already loaded"); |
50 |
|
48 |
|
51 |
/* Load the Vulkan loader library */ |
49 |
/* Load the Vulkan loader library */ |
52 |
if(!path) |
|
|
53 |
path = SDL_getenv("SDL_VULKAN_LIBRARY"); |
54 |
if(!path) |
55 |
path = "libvulkan.so.1"; |
56 |
_this->vulkan_config.loader_handle = SDL_LoadObject(path); |
57 |
if(!_this->vulkan_config.loader_handle) |
58 |
return -1; |
59 |
SDL_strlcpy(_this->vulkan_config.loader_path, path, SDL_arraysize(_this->vulkan_config.loader_path)); |
60 |
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( |
61 |
_this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); |
62 |
if(!vkGetInstanceProcAddr) |
50 |
if(!vkGetInstanceProcAddr) |
63 |
goto fail; |
51 |
goto fail; |
64 |
_this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; |
52 |
_this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; |
Lines 93-139
Link Here
|
93 |
{ |
81 |
{ |
94 |
videoData->vulkan_xlib_xcb_library = NULL; |
82 |
videoData->vulkan_xlib_xcb_library = NULL; |
95 |
} |
83 |
} |
96 |
else if(!hasXCBSurfaceExtension) |
84 |
else |
97 |
{ |
85 |
{ |
98 |
SDL_SetError("Installed Vulkan doesn't implement either the " |
86 |
SDL_SetError("Installed Vulkan doesn't implement either the " |
99 |
VK_KHR_XCB_SURFACE_EXTENSION_NAME "extension or the " |
87 |
VK_KHR_XCB_SURFACE_EXTENSION_NAME "extension or the " |
100 |
VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension"); |
88 |
VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension"); |
101 |
goto fail; |
89 |
goto fail; |
102 |
} |
90 |
} |
103 |
else |
|
|
104 |
{ |
105 |
const char *libX11XCBLibraryName = SDL_getenv("SDL_X11_XCB_LIBRARY"); |
106 |
if(!libX11XCBLibraryName) |
107 |
libX11XCBLibraryName = "libX11-xcb.so"; |
108 |
videoData->vulkan_xlib_xcb_library = SDL_LoadObject(libX11XCBLibraryName); |
109 |
if(!videoData->vulkan_xlib_xcb_library) |
110 |
goto fail; |
111 |
videoData->vulkan_XGetXCBConnection = |
112 |
SDL_LoadFunction(videoData->vulkan_xlib_xcb_library, "XGetXCBConnection"); |
113 |
if(!videoData->vulkan_XGetXCBConnection) |
114 |
{ |
115 |
SDL_UnloadObject(videoData->vulkan_xlib_xcb_library); |
116 |
goto fail; |
117 |
} |
118 |
} |
119 |
return 0; |
91 |
return 0; |
120 |
|
92 |
|
121 |
fail: |
93 |
fail: |
122 |
SDL_UnloadObject(_this->vulkan_config.loader_handle); |
94 |
_this->vulkan_config.vkGetInstanceProcAddr = NULL; |
123 |
_this->vulkan_config.loader_handle = NULL; |
|
|
124 |
return -1; |
95 |
return -1; |
125 |
} |
96 |
} |
126 |
|
97 |
|
127 |
void X11_Vulkan_UnloadLibrary(_THIS) |
98 |
void X11_Vulkan_UnloadLibrary(_THIS) |
128 |
{ |
99 |
{ |
129 |
SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata; |
100 |
SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata; |
130 |
if(_this->vulkan_config.loader_handle) |
|
|
131 |
{ |
132 |
if(videoData->vulkan_xlib_xcb_library) |
133 |
SDL_UnloadObject(videoData->vulkan_xlib_xcb_library); |
134 |
SDL_UnloadObject(_this->vulkan_config.loader_handle); |
135 |
_this->vulkan_config.loader_handle = NULL; |
136 |
} |
137 |
} |
101 |
} |
138 |
|
102 |
|
139 |
SDL_bool X11_Vulkan_GetInstanceExtensions(_THIS, |
103 |
SDL_bool X11_Vulkan_GetInstanceExtensions(_THIS, |
Lines 142-148
Link Here
|
142 |
const char **names) |
106 |
const char **names) |
143 |
{ |
107 |
{ |
144 |
SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata; |
108 |
SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata; |
145 |
if(!_this->vulkan_config.loader_handle) |
109 |
if(!_this->vulkan_config.vkGetInstanceProcAddr) |
146 |
{ |
110 |
{ |
147 |
SDL_SetError("Vulkan is not loaded"); |
111 |
SDL_SetError("Vulkan is not loaded"); |
148 |
return SDL_FALSE; |
112 |
return SDL_FALSE; |
Lines 173-179
Link Here
|
173 |
SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata; |
137 |
SDL_VideoData *videoData = (SDL_VideoData *)_this->driverdata; |
174 |
SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata; |
138 |
SDL_WindowData *windowData = (SDL_WindowData *)window->driverdata; |
175 |
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; |
139 |
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; |
176 |
if(!_this->vulkan_config.loader_handle) |
140 |
if(!_this->vulkan_config.vkGetInstanceProcAddr) |
177 |
{ |
141 |
{ |
178 |
SDL_SetError("Vulkan is not loaded"); |
142 |
SDL_SetError("Vulkan is not loaded"); |
179 |
return SDL_FALSE; |
143 |
return SDL_FALSE; |