SDL and Vulkan

Hi there,

I began to write a piece of code to initialize Vulkan within SDL.I guess I currently am on the correct way, but I have a link error I don’t understand.

I wrote (proud of me :D) something like that :

#define VK_USE_PLATFORM_XLIB_KHR
#define VK_PROTOTYPES
#include <vulkan/vulkan.h>
...
            VkXlibSurfaceCreateInfoKHR xLib;
            xLib.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
            xLib.pNext = nullptr;
            xLib.flags = 0;
            xLib.dpy = info.info.x11.display;
            xLib.window = info.info.x11.window;
            vkCreateXlibSurfaceKHR(mInstance, &xLib, nullptr, &mSurfaceKHR);

I got the error undefined reference to “vkCreateXlibSurfaceKHR”.

I don’t have this problem using XCB, but, SDL doesn’t use XCB :D.

So, there is a bug or just a tip I don’t find ^^ ?
Thank you all,and sorry for english…

Hello!

Did you make sure to define the preprocessor macro VK_USE_PLATFORM_XLIB_KHR? Defining that should resolve your undefined reference error. Also make sure to capitalize the “V” in “vkCreateXlibSurfaceKHR()”. :~)

My bad! I see you already defined that macro! Just try fixing the spelling then. :slight_smile:

Perhaps this particular platform is not staticaly linkable (by compiler or in the loader vulkan.lib). In some examples I seen those particular functions specificaly to be loaded beforehand with vkGetInstanceProcAddr() and vkGetDeviceProcAddr() - I suggest you try that.

And AFAIK there is no use of VK_PROTOTYPES (only VK_NO_PROTOTYPES).

Hello :).
Finally I decided to switch to GLFW.
Apparently, xLib is not managed yet ^^.

Folks,

See LunarXchange issue #424:

There is code in the loader to support the Xlib WSI surface extension; however it is conditionally compiled (by default out) and not tested. The version of the loader in the SDK is built without Xlib support so that is the problem. You can build the loader yourself with Xlib supported from the Github open source project until support is added to the SDK : https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers

Note: The extension is reported supported because the driver reports it supports the extension. Probably, the loader should filter out driver reported instance extensions that it doesn’t support. Device extensions don’t need loader support but instance extensions do.

[QUOTE=KarenGhavam;39923]Folks,

See LunarXchange issue #424:

There is code in the loader to support the Xlib WSI surface extension; however it is conditionally compiled (by default out) and not tested. The version of the loader in the SDK is built without Xlib support so that is the problem. You can build the loader yourself with Xlib supported from the Github open source project until support is added to the SDK : https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers

Note: The extension is reported supported because the driver reports it supports the extension. Probably, the loader should filter out driver reported instance extensions that it doesn’t support. Device extensions don’t need loader support but instance extensions do.[/QUOTE]

Actually you can just load the extension entry points yourself

vkCreateXlibSurfaceKHR = vkGetInstanceProcAddress(instance, "vkCreateXlibSurfaceKHR");

and then use that.

^ Said so too. But the LunarXchange issue #424 actually claims that doesn’t help either.

qnoper: Good choice - always better not to reinvent the wheel. Didn’t know they support Vulkan already… does it work?

The infrastructure is still a WIP so such problems will arise. I would note that the spec guarantees statically linkable WSI:
C.14:

The Khronos-provided Vulkan API loader for Android, Linux, and Windows exports functions for all core Vulkan API and WSI extension commands.

So it should in time work without explicit function loading. Also do note the version included in LunarG SDK is outdated behind the Khronos github master (could be already fixed).

*[STRIKE]could be[/STRIKE] is already fixed: https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/commit/b2ec2fd78b71a44a1bfbbab56eb8e18c30d8a959