gfx-rs / portability

Vulkan Portability Implementation
Mozilla Public License 2.0
384 stars 25 forks source link

Questions: supports creating a dynamic library ".dylib" on Macos? VKD3D support? #136

Closed oscarbg closed 6 years ago

oscarbg commented 6 years ago

Hi, so basically I'm asking if we can use precompiled apps using MotenVK (Vulkan MacOS SDK) and even point the Vulkan ICD file on Macos to this dylib instead of MoltenVK.dylib? also then copying your dylib to Dota2 folder and renaming to &replacing the included Dota2 MoltenVK dylib should allow easy testing of Vulkan portability on Dota2, right? finally I even compiled VKD3D on MacOS now that supports MoltenVK and his included samples and they work using MoltenVK.. as said would like to test VKD3D+ your portability project to see if plays nice like MoltenVK on simple or not so simple projects: also VKD3D "vkd3d can now run the World of Warcraft: Battle for Azeroth DX12 renderer on top of Vulkan!" let's see what is needed to run on Mac (MoltenVK and portability) from: https://twitter.com/Plagman2/status/1032532014442852353 "vkd3d can now run the World of Warcraft: Battle for Azeroth DX12 renderer on top of Vulkan! Here's a few screenshots of it running on Wine, thanks to the hard work of the graphics guys over at CodeWeavers, Józef and Henri."

kvark commented 6 years ago

Hi @oscarbg ! Thanks for chiming in :)

if we can use precompiled apps using MotenVK (Vulkan MacOS SDK) and even point the Vulkan ICD file on Macos to this dylib instead of MoltenVK.dylib?

We currently have 2 build targets:

  1. libportability is a dynamic library that exposes Vulkan entry points. It should be usable as a drop-in replacement for MoltenVK.
  2. libportability_icd is a dynamic library exposing only ICD interface, so that's what you'd point to for the Vulkan loader

We recently started attaching the pre-compiled binaries to some of the PRs, e.g. see a link in #128 description. We haven't still figured out a good process for producing and storing those binaries. This is an open topic. Most likely we'll have a dedicated repository that is contributed to by various CI scripts (per platform).

also then copying your dylib to Dota2 folder and renaming to &replacing the included Dota2 MoltenVK dylib should allow easy testing of Vulkan portability on Dota2, right?

Yes, that's one way. Another is creating a symlink libMoltenVK.dylib -> libportability.dylib and then setting DYLD_LIBRARY_PATH for running Dota2. We've been testing it constantly, even published some benchmarks.

finally I even compiled VKD3D on MacOS now that supports MoltenVK and his included samples and they work using MoltenVK..

This is great! We'll start testing it once we have the capability (in terms of engineering resources) to do so. This is technically covered by "Wine" section of #125, but I'd welcome more specific issues to be made (even a generic tracker for VK3D stuff), perhaps with technical discussion on the findings.

oscarbg commented 6 years ago

Hi @kvark! Thanks to you and all other people for your great work on this project! I had already read briefly the Dota2 running on "portability" but thought must build project for myself and also that wasn't a dynamic library and ICD complying.. so thanks for informative answer it helps a lot as a quickstart to do "some experiments" with this library.. will test soon.. in the meanwhile I share some "simple experiments" I did with MoltenVK (mostly run OK) and will test with portability but maybe is good if you are aware so also can keep an eye: (I don't want to overload list of https://github.com/gfx-rs/portability/issues/125 so I put here but can put there if you want too..) I want to comment I do some Vulkan tests using Wine for Macos compiled with Vulkan support as they still don't support Vulkan in his Wine Macos prebuilt binaries on winehq.. first: I hope, is portability plays nicely with Wine Vulkan on Macos by replacing libMoltenVK with libportability.. I mean it can run simple cube.exe sample from Windows Vulkan SDK.. second: I see you a trying to get it working a lot of emulators RPCS3,Xenia and Dolphin which will be awesome.. I think you can add to the list PPSSPP.. supports Vulkan and I think is an easier emulator (from graphics side) to support than the others.. to run PPSSPP I test Win binary using Wine for Macos compiled with Vulkan support (as they still don't support MacOS builds?).. results are there: https://github.com/KhronosGroup/MoltenVK/issues/204 seems will require code changes as first blocking issue is that it requires VK_FORMAT_B4G4R4A4_UNORM_PACK16 VkQuake runs nice on Macos now they fixed "swizzling" issues also as I reported: see for complete history: https://github.com/Novum/vkQuake/issues/132 also note vkQuake runs ok via MoltenVK compiling natively on Macos and also using Wine with vkquake precompiled Win binaries (https://github.com/Novum/vkQuake/releases) this is nice as the "swizzle" fix is not platform dependent as RPCS3 is:https://github.com/RPCS3/rpcs3/commit/c6e35706a3a47368713939ad06afcd5eb04212eb https://github.com/SaschaWillems/Vulkan support natively Macos and a lot run on MoltenVK (there is a list somewhere of expected running samples inside the project, can find it if you want) and they seem to run equally well via Wine on Win binary builds.. as you know these samples are good as they exercise things not implemented on MotenVK like tesselation support, geometry shaders (how big the hack to support it will be not being in Metal?) https://github.com/SaschaWillems/Vulkan-glTF-PBR also works nice (the windows executable) to finish just point the heavy weights and long term/ultimate wishes to run: DXVK: I posted my findings there altough we are very far from supporting it.. https://github.com/KhronosGroup/MoltenVK/issues/203 the lastest advancement there seems (posted at the bottom of the issue) from https://github.com/iain-benson/MoltenVK/tree/dx11 *as you point also (https://github.com/gfx-rs/portability/issues/125) running Wolfenstein II and Doom will be awesome.. I posted my findings running these two games as answer on (https://github.com/KhronosGroup/MoltenVK/issues/204) lots of "does not map to a valid MTLPixelFormat.": [MoltenVK ERROR] VK_ERROR_FORMAT_NOT_SUPPORTED: VkImageView format VK_FORMAT_B10G11R11_UFLOAT_PACK32 and swizzle (VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ONE) does not map to a valid MTLPixelFormat. as @billhollings points:

Almost all of these format issues have to do with texture swizzling. Unfortunately...Metal does not support assigning a swizzle to a texture...which is why MoltenVK is reporting errors.

Unfortunately...there is currently no way (short of elaborate run-time shader mods) to provide this functionality under Metal.

sadly with no source access supporting these games seems to require "elaborate run-time shader mods"..

thats all I wanted to say.. :-)

kvark commented 6 years ago

I don't want to overload list of #125 so I put here but can put there if you want too

Essentially, all your findings belong there, just in a more condensed form (as I updated now).

first: I hope, is portability plays nicely with Wine Vulkan on Macos by replacing libMoltenVK with libportability.. I mean it can run simple cube.exe sample from Windows Vulkan SDK..

Yes, that should work.

I think you can add to the list PPSSPP.. supports Vulkan and I think is an easier emulator

Thank you for the suggestion! I think there is much less need for it, given that they can run with OpenGL on Mac, unlike RPCS3.

https://github.com/SaschaWillems/Vulkan support natively Macos and a lot run on MoltenVK (there is a list somewhere of expected running samples inside the project, can find it if you want) and they seem to run equally well via Wine on Win binary builds..

Those should be working, although I haven't got a moment to test them.

sadly with no source access supporting these games seems to require "elaborate run-time shader mods"..

Yes, such shader mods are not trivial at all, and can't be prioritized given that the group will list the lack of swizzles as an explicit limitation...

oscarbg commented 6 years ago

Hi @kvark, thanks for adding my testing list to #125.. I would do some testing now with your latest binaries posted for RPCS3 & Dolphin.. hope somebody already has notified Apple Metal devs of current swizzle limitations in Metal API and they are supportive in willing to implementing it for projects like this to succeed in running unmodified apps via Wine.. Closing now.. will keep an eye for VKD3D improvements.. and hoping the best for this project.. :-)