New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glfwVulkanSupported returning 0 on OSX (With MoltenVK) #1073

Closed
mtesseracttech opened this Issue Sep 11, 2017 · 8 comments

Comments

Projects
None yet
3 participants
@mtesseracttech

mtesseracttech commented Sep 11, 2017

I am not 100% sure if this belongs here, if not, my apologies. Because I am not sure where else to take this.

A little context:
I am trying to develop a rendering engine using Vulkan and GLFW. At the same time I am learning how to use CMake (so possibly the error may lie there) and multiplatform development.
I am trying to make the engine buildable on both OSX and Windows, and thus far that seemed to work out (libraries are detected, both on windows and OSX, and it compiled).
Now to the problem: When I try to run glfwVulkanSupported on OSX, it returns 0. I am not sure what causes this, because there are available vulkan extensions when I call vkEnumerateInstanceExtensionProperties
I get the following output:

VK_MVK_moltenvk
VK_KHR_swapchain
VK_KHR_surface
VK_MVK_macos_surface

but when I call glfwGetRequiredInstanceExtensions(&glfwExtensionCount)
I get 0x0 back.

So would this be some kind of linking problem or something else? I have used a strategy to get things running that I describe in this file:
https://github.com/mtesseracttech/VulkanEngine/blob/master/Setup%20Readme.txt

The biggest thing I can think of is that the includes are not linked in the proper way, I am not sure how to get around this though, because with the way the FindVulkan.cmake file was on your repo, it would not detect the headers. (it tried to look inside of the .framework file, but never seemed to actually find the headers, so I hardcoded a path as stated in the Setup Readme)

@mtesseracttech

This comment has been minimized.

mtesseracttech commented Sep 11, 2017

I was thinking about it and my best guess is at that the FindVulkan.cmake in GLFW is not detecting MoltenVK just like it wouldn't find MoltenVK in my application itself. Maybe that is why it is not seeing Vulkan at all.
I have to add to that that there is no official way to install MoltenVK in, except for adding it to an existing project (Which I'd rather not do, since that would take away from the multiplatform aspect of it and it requires Xcode, which I don't use in favor of CLion (to streamline things))
That is why I went with putting MoltenVK.framework in /usr/local/lib/ and by extension for putting the contents of MoltenVK.framework/headers in /usr/local/inc/MoltenVK.

@Shimmen

This comment has been minimized.

Shimmen commented Sep 11, 2017

From looking at your CMakeLists.txt I can see that the following message should be printed when configuring CMake if Vulkan was successfully found: "Found Vulkan, Including and Linking now". Does that message show up? In CLion you can open up the CMake tab in the bottom and press the reload button to force a reload of the CMake list files. From that tab you can also look at the CMake variable cache: there you should be able to see some values for your variables like VULKAN_INCLUDE_DIR etc.

This might help you debug the problem a bit at least!

@mtesseracttech

This comment has been minimized.

mtesseracttech commented Sep 11, 2017

Yes, they do show up. The reason I manually define VULKAN_INCLUDE_DIR in the FindVulkan.cmake for OSX is because it was not picking up the /headers folder located inside of MoltenVK.framework, even though it was finding the .framework file.

@elmindreda

This comment has been minimized.

Member

elmindreda commented Sep 12, 2017

@mtesseracttech What commit of GLFW are you using?

@mtesseracttech

This comment has been minimized.

mtesseracttech commented Sep 12, 2017

@elmindreda what exactly do you mean? On OSX I use the version that is downloaded by default by Homebrew, which is 3.2.1 as far as I know.

@elmindreda

This comment has been minimized.

Member

elmindreda commented Sep 12, 2017

@mtesseracttech Ah, that explains it then. GLFW added support for MoltenVK after 3.2.1. Uninstall the Homebrew version and build and install from this repo instead.

@mtesseracttech

This comment has been minimized.

mtesseracttech commented Sep 12, 2017

@elmindreda Thanks! It seems to be fine now. The best technique to do that right now if you work with homebrew would be to do the following (for people that might run into this in the near future):

brew install cmake //If this hasn't been done yet
brew uninstall glfw
brew install glfw --HEAD

That will build and install the most recent version.

I am getting a nice output of:

Is Vulkan supported? Yes
Available Vulkan Extensions: 4
	VK_MVK_moltenvk
	VK_KHR_swapchain
	VK_KHR_surface
	VK_MVK_macos_surface
GLFW required extensions:
	VK_KHR_surface
	VK_MVK_macos_surface

@elmindreda elmindreda added the question label Sep 12, 2017

@elmindreda

This comment has been minimized.

Member

elmindreda commented Oct 2, 2017

From what I understand this issue has been resolved so I'm closing it. If not, please re-open it at any time.

@elmindreda elmindreda closed this Oct 2, 2017

@elmindreda elmindreda added this to the None milestone Oct 2, 2017

@elmindreda elmindreda self-assigned this Oct 2, 2017

@elmindreda elmindreda added support and removed question labels Oct 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment