vblanco20-1 / vulkan-guide

Introductory guide to vulkan.
https://vkguide.dev/
MIT License
940 stars 213 forks source link

Mac OS #77

Open matt328 opened 2 years ago

matt328 commented 2 years ago

Has anyone tried running this code on Mac OS? It works fine up until switching from vertices hard coded in the shader to vertex buffers. After this change, I don't get any validation warnings or errors, just nothing is rendered on the screen. It's really hard to debug on Mac, and of course it works just fine on Windows. Compiling with clang on both platforms if that matters.

I'm unable to get the chapter 3 code to run as-is on Mac OS, I get tons of linker errors coming from SDL. My own code that isn't working has some some minor differences from the code in this repo, mainly using vcpkg instead of vendoring everything.

I also have other examples of vertex buffers working on Mac OS, just there are a lot of differences, eg not using vkbootstrap or vulkan-memory-allocator.

I think the only way to debug vulkan on Mac OS is to install Xcode, but I can't for the life of me seem to free up enough disk space to allow Xcode to install.

MHDtA-dev commented 1 year ago

The same thing. I thought maybe I did something wrong, but my code is almost identical to the code of the tutorial. After I switched to the Vertex Buffer Object, the image disappeared. I don't know how to fix it.

MHDtA-dev commented 1 year ago

I solved this by completely abandoning the VulkanMemoryAllocator library. I created the buffer manually and the render appeared.

rje commented 1 year ago

Having a similar issue here - ch3 code works fine on windows and linux, but on macos I only see the strobing clear color

Edit: reading through the moltenvk docs, I noticed the following:

On macOS versions prior to macOS 10.15.6, native host-coherent image device memory is not available. Because of this, changes made to VkImage VK_MEMORY_PROPERTY_HOST_COHERENT_BIT device memory by the CPU or GPU will not be available to the GPU or CPU, respectively, until the memory is flushed or unmapped by the application.

Now, I am running a later OS version (13.2.1), and this is for a vertex buffer and not a a VkImage, But I tried adding the following after each vmaUnmapMemory() call:

vmaFlushAllocation(allocator, <allocation variable>, 0, VK_WHOLE_SIZE);

And sure enough, that resolved the issue.