suijingfeng / vkQuake3

Its based on ioq3,I add a vulkan based modular render back end which originally from https://github.com/kennyalive/Quake-III-Arena-Kenny-Edition
GNU General Public License v2.0
98 stars 28 forks source link

Complies on macOS (10.14.6 Mojave) - but, Couldn't create a window / could not load Vulkan subsystem #10

Closed danieleftodi closed 4 years ago

danieleftodi commented 4 years ago

So, I'm trying to get it working under macOS ... it compiles and runs very well with opengl renderer ... but when I switch to

\cl_renderer vulkan
\vid_restart

Here is my crash log:

ioq3 1.36_GIT_70143de7-2020-04-05 macosx-x86_64 Jul  5 2020
SSE instruction set enabled
----- FS_Startup -----
We are looking in the current search path:
/Users/home-dir/Library/Application Support/Quake3/baseq3
./baseq3
./baseq3/xcsv_bq3hi-res.pk3 (1204 files)
./baseq3/pak8.pk3 (9 files)
./baseq3/pak7.pk3 (4 files)
./baseq3/pak6.pk3 (64 files)
./baseq3/pak5.pk3 (7 files)
./baseq3/pak4.pk3 (272 files)
./baseq3/pak3.pk3 (4 files)
./baseq3/pak2.pk3 (148 files)
./baseq3/pak1.pk3 (26 files)
./baseq3/pak0.pk3 (3539 files)

----------------------
5277 files in pk3 files
execing default.cfg
execing q3config.cfg
couldn't exec autoexec.cfg
Hunk_Clear: reset the hunk ok
----- Client Initialization -----
----- Initializing Renderer ----
Trying to load "renderer_vulkan_x86_64.dylib" from "."...
-------------------------------
QKEY found.
----- Client Initialization Complete -----
----- R_Init -----
 backend state cleared.
--- R_glConfigInit() ---
...Creating window (using SDL2)...
Video is not initialized before, so initial it.
 SDL using driver "cocoa"
...VKimp_SetMode()...
bpp 32  SDL_PIXELFORMAT_ARGB8888    2560 x 1440, refresh_rate: 60Hz
MODE: -2, 2560 x 1440, refresh rate: 60hz
^3 Couldn't create a window
Setting r_mode=-2, r_fullscreen=1 failed, falling back on r_mode=3
...VKimp_SetMode()...
bpp 32  SDL_PIXELFORMAT_ARGB8888    2560 x 1440, refresh_rate: 60Hz
MODE: 3, 640 x 480, refresh rate: 60hz
^3 Couldn't create a window
----- Client Shutdown (Client fatal crashed: VKimp_Init() - could not load Vulkan subsystem) -----
RE_Shutdown( 1 )
tty]Segmentation fault: 11
suijingfeng commented 4 years ago

Sorry,as far as I know, vulkan is not supported by Apple. can you try moltenvk ( https://moltengl.com/moltenvk/ ), but i am not familiar with it. and i don't have a mac, so i can't reproduce this problem. only windows and linux are tested, i can't help in your case, sorry.

tolnaiz commented 4 years ago

There is https://github.com/gfx-rs/portability which is quite similar to moltenvk, and in theory, it can run vkquake3. Sadly I had no success with either one of them, probably because I'm a complete noob in static/dynamic linking.

Let me know if you have any results.

danieleftodi commented 4 years ago

@suijingfeng & @tolnaiz ... TL:DR .... I got it working 🥳 ... I'll shortly make a patch available ...

Sorry, as far as I know, vulkan is not supported by Apple.

That is a bit ... "not quite of a correct statement" 🙃😉 ... like OpenGL, Vulkan and Metal are "just a specification" ... it's not Apple, nor Microsoft nor Linux-developers that have to write the code to add a specification support into a gfx cards driver ... it's the manufacturers (AMD, Nvidia, Intel ... etc etc) ...

Like The Cherno explains in his OpenGL crash course on youtube - Welcome to OpenGL ...

The question is: has AMD, Nvidia, et. al added Vulkan API specification support into the macOS driver that they provide to Apple? ... they've done so for Microsoft and their Linux drivers ... (or just make one available for us to download and install ourselves?) ... I don't know ...

Though we know AMD has added Metal API specification into their gfx drivers for macOS ... and that is why (IMHO) MoltenVK has come about ... to create a translation layer for Vulkan API --to-the--> Metal API ... *yay all of us*

Though, IMHO, all gfx manufacturers (yeah, Apple too, with their own Apple Silicon chips) should add Vulkan API specification to their drivers, and make them available... so developers can try to code once, and support many 🙏🏻 ... so we can once and for all say farewell to OpenGL 😉

R.I.P OpenGL...

can you try moltenvk ( https://moltengl.com/moltenvk/ ), but i am not familiar with it.

TL:DR ... that is what I've done ... sort of ... or didn't have to do at all...

After RTFM-ing and some more debugging it turns out that it was the SDL2 Library that is either to old and/or was compiled without Vulkan API support (for macOS...) ...

...VKimp_SetMode()...
 bpp 32 SDL_PIXELFORMAT_ARGB8888    2560 x 1440, refresh_rate: 60Hz
 MODE: 3, 640 x 480, refresh rate: 60hz
^3 Couldn't create a window: Vulkan support is either not configured in SDL or not available in video driver
----- Client Shutdown (Client fatal crashed: VKimp_Init() - could not load Vulkan subsystem: Vulkan support is either not configured in SDL or not available in video driver) -----

so I updated the SDL2 Lib to 2.0.12 and it works 👍🏻

...Creating window (using SDL2)...
 Found SDL version 2.0.12
 Video is not initialized before, so initial it.
 SDL using driver "cocoa"

...VKimp_SetMode()...
 bpp 32 SDL_PIXELFORMAT_ARGB8888    2560 x 1440, refresh_rate: 60Hz
 MODE: -2, 2560 x 1440, refresh rate: 60hz
 Available modes: '2560x1440 2048x1152 1600x1200 1600x900 1344x1008 1344x756 1280x960 1280x720 1024x768 1024x576 800x600 640x480'
 Loading vulkan instance functions 
 *** Vulkan Initialization ***
 Get instance proc address. (using SDL2)
 Creating instance: vk.instance
--- Total 10 instance extensions. --- 
--- Vulkan create instance success! ---

There is https://github.com/gfx-rs/portability which is quite similar to moltenvk, and in theory, it can run vkquake3. Sadly I had no success with either one of them, probably because I'm a complete noob in static/dynamic linking.

@tolnaiz : ... the great news is that since 2018 Valve has made sure MoltenVK becomes Open Source and that it gets incorporated into the official Vulkan SDK maintained by the Khronos Group...

And SDL2 also supports Vulkan ... meaning, one doesn't have to do much to have Vulkan support on all platforms SDL2 Lib has support for ... just make sure to compile the SDL2 library with Vulkan support, and not run an old SDL2 lib that doesn't support it (say older then some-time-in-2018-when-SDL2-added-support-for-it?...)

tolnaiz commented 4 years ago

It's indeed working with a newer SDL. Which also solves some assumably mac specific bugs (handling hidpi mode and mouse wheel problems).

danieleftodi commented 4 years ago

Pull request: https://github.com/suijingfeng/vkQuake3/pull/11

danieleftodi commented 4 years ago

@tolnaiz

btw, do you have the same issue? https://github.com/suijingfeng/vkQuake3/issues/12

(yeah, let's continue this talk in that issue ...)

danieleftodi commented 4 years ago

This [Fix] is merged, closing issue.