blurrypiano / littleVulkanEngine

Code repo for video tutorial series teaching Vulkan and computer graphics
MIT License
810 stars 147 forks source link

GLFW cannot find vulkan/vulkan.h on macOS #35

Open junglie85 opened 2 years ago

junglie85 commented 2 years ago

Vulkan does not link for me on macOS with target_link_libraries(${PROJECT_NAME} glfw ${Vulkan_LIBRARIES}) CMakeLists.txt#L105.

If I amend the target_link_libraries to include Vulkan::Vulkan, it works fine.

ccmake -GNinja .. finds the Vulkan library okay:

Vulkan_GLSLANG_VALIDATOR_EXECU   /Users/junglie85/VulkanSDK/1.2.182.0/macOS/bin/glslangValidator                         
Vulkan_GLSLC_EXECUTABLE          /Users/junglie85/VulkanSDK/1.2.182.0/macOS/bin/glslc                                    
Vulkan_INCLUDE_DIR               /Users/junglie85/VulkanSDK/1.2.182.0/macOS/include                                      
Vulkan_LIBRARY                   /Users/junglie85/VulkanSDK/1.2.182.0/macOS/lib/libvulkan.dylib 

I'm on an M1 MacBook Pro, which I've found can have some slight oddities, but not sure why linking fails in this case.

¯_(ツ)_/¯

Trynera commented 2 years ago

M1 Chips don't support Vulkan. They only support Apple's own Metal API and OpenGL!

Trynera commented 2 years ago

M1 Chips don't support Vulkan. They only support Apple's own Metal API and OpenGL!

btw MoltenVK exists but isn't official by Khronos or Apple

Edit: MoltenVK is apperantly by the The Brenwill Workshop Ltd. and the Khronos Group, idk why I said it wasn't by the Khronos Group

truedat101 commented 4 months ago

It sure feels like something you can install on your mac: https://vulkan.lunarg.com/doc/sdk/1.3.275.0/mac/release_notes.html

==========
VULKANINFO
==========

Vulkan Instance Version: 1.3.268

Instance Extensions: count = 15
===============================
    VK_EXT_debug_report                    : extension revision 10
    VK_EXT_debug_utils                     : extension revision 2
    VK_EXT_metal_surface                   : extension revision 1
    VK_EXT_surface_maintenance1            : extension revision 1
    VK_EXT_swapchain_colorspace            : extension revision 4
    VK_KHR_device_group_creation           : extension revision 1
    VK_KHR_external_fence_capabilities     : extension revision 1
    VK_KHR_external_memory_capabilities    : extension revision 1
    VK_KHR_external_semaphore_capabilities : extension revision 1
    VK_KHR_get_physical_device_properties2 : extension revision 2
    VK_KHR_get_surface_capabilities2       : extension revision 1
    VK_KHR_portability_enumeration         : extension revision 1
    VK_KHR_surface                         : extension revision 25
    VK_LUNARG_direct_driver_loading        : extension revision 1
    VK_MVK_macos_surface                   : extension revision 3

Layers: count = 5
=================
VK_LAYER_KHRONOS_profiles (Khronos Profiles layer) Vulkan version 1.3.268, layer version 1:
    Layer Extensions: count = 0
    Devices: count = 1
        GPU id = 0 (Apple M2)
        Layer-Device Extensions: count = 1
            VK_EXT_tooling_info : extension revision 1

VK_LAYER_KHRONOS_shader_object (Khronos Shader object layer) Vulkan version 1.3.268, layer version 1:
    Layer Extensions: count = 0
    Devices: count = 1
        GPU id = 0 (Apple M2)
truedat101 commented 4 months ago

There are enough little oddities with mac that good cmakefiles should include an if (UNIX AND NOT APPLE) , and then provide the APPLE case if needed. Since the SDK will install in a weird place , you will need to tell it where to find the SDK ... let's say ~/VULKAN_SDK/version/here

and then provide the necessary mods to the UNIX if statement to add_target_includes.

Trynera commented 3 months ago

@truedat101 idk if you were answering me, but MoltenVK (afaik) used to be smth that was unofficial not by the Khronos Group directly. I mentioned MoltenVK without saying you can't use it, and what you're talking about is exactly that. It's a layer for vulkan and not actually some type of support you can install for your hardware! Vulkan is a spec and Apple's M series chips do not support Vulkan directly, so they have to resort to translation like, the before mentioned, MoltenVK