kondrak / vkQuake2

id Software's Quake 2 v3.21 with mission packs and Vulkan support (Windows, Linux, macOS, FreeBSD, Raspberry Pi 4)
GNU General Public License v2.0
899 stars 89 forks source link

RPI4 with Raspberry Pi OS 64-bit #106

Closed leggazoid closed 4 years ago

leggazoid commented 4 years ago

I get the following error when compiling on RPI4 with aarch64:

Makefile:39: *** "Unsupported ARCH: aarch64". Stop.

Thank you for your code!

kondrak commented 4 years ago

I have no way of checking this, since I don't own a RPi4 - looking through PRs I see that 32bit build should work at the very least. @infapi00 are there any specific instructions for building on RPi4? Is 64bit supported by the driver?

kondrak commented 4 years ago

Generally, it seems that it should be relatively easy to make it compile if we look at this: https://github.com/kondrak/vkQuake2/pull/97 - it might be only a matter of adding proper arch ifdef and updating the Makefile.

Still, I cannot confirm this first hand, so @leggazoid if you feel like playing around, you might be able to verify if it compiles and runs fine 🙂

infapi00 commented 4 years ago

@kondrak hi.

@infapi00 are there any specific instructions for building on RPi4?

Not really, it was really easy to build. I needed to update the vulkan libraries as vkQuake2 uses stuff more recent that those included with Raspbian (don't know which version comes with aarch64), and I needed to build the validation layers in order to run a debug build of vkQuake2. So the only really specific stuff I needed to do is #97. So as you already mentioned, I think that getting it built to 64-bit would be easy, just use that commit as reference.

The only workaround I needed to do is that when running vkQuake2 it doesn't find libatomic, so I needed to run it like this: LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1 ./quake2

I never had time to find why that was needed though.

Is 64bit supported by the driver?

There are some people that are testing the driver on 64-bit and getting some stuff done. We are even getting reports of some specific failures and even some fixes, that is nice. But the main development is focused on 32-bit. Our idea is getting the 32-bit driver working (targetting vulkan 1.0 CTS passing), and then decide on next step (there are several options, like 64-bit, performance, etc).

leggazoid commented 4 years ago

It didn't compile with the following added:

linux/Makefile

else ifeq ($(KERNEL_ARCH),aarch64) ARCH=aarch64 RPMARCH=aarch64

linux/sys_linux.c

elif defined aarch64

    const char *gamename = "gameaarch64.so";

I am not a programmer, just guessing what needs added to make aarch64 compile. Any help would be welcomed.

infapi00 commented 4 years ago

It didn't compile with the following added:

Could you share all the error output?

I am not a programmer, just guessing what needs added to make aarch64 compile. Any help would be welcomed.

FWIW, when I wrote #97 I also needed to tweak all the final names used, but I used the error output to guide me. It would be really helpful if you share the full output.

leggazoid commented 4 years ago

~/Public/vkQuake2/linux $ make make targets BUILDDIR=debugaarch64 CFLAGS="-I/usr/local/include -Dstricmp=strcasecmp -D_GNU_SOURCE -Wno-format-truncation -Wno-unused-result -g -D_DEBUG" make[1]: Entering directory '/home/pi/Public/vkQuake2/linux' gcc -I/usr/local/include -Dstricmp=strcasecmp -D_GNU_SOURCE -Wno-format-truncation -Wno-unused-result -g -D_DEBUG -o debugaarch64/quake2 debugaarch64/client/cl_cin.o debugaarch64/client/cl_ents.o debugaarch64/client/cl_fx.o debugaarch64/client/cl_input.o debugaarch64/client/cl_inv.o debugaarch64/client/cl_main.o debugaarch64/client/cl_newfx.o debugaarch64/client/cl_parse.o debugaarch64/client/cl_pred.o debugaarch64/client/cl_tent.o debugaarch64/client/cl_scrn.o debugaarch64/client/cl_view.o debugaarch64/client/console.o debugaarch64/client/keys.o debugaarch64/client/menu.o debugaarch64/client/snd_dma.o debugaarch64/client/snd_mem.o debugaarch64/client/snd_miniaudio.o debugaarch64/client/snd_mix.o debugaarch64/client/qmenu.o debugaarch64/client/m_flash.o debugaarch64/client/cmd.o debugaarch64/client/cmodel.o debugaarch64/client/common.o debugaarch64/client/crc.o debugaarch64/client/cvar.o debugaarch64/client/files.o debugaarch64/client/md4.o debugaarch64/client/net_chan.o debugaarch64/client/sv_ccmds.o debugaarch64/client/sv_ents.o debugaarch64/client/sv_game.o debugaarch64/client/sv_init.o debugaarch64/client/sv_main.o debugaarch64/client/sv_send.o debugaarch64/client/sv_user.o debugaarch64/client/sv_world.o debugaarch64/client/cd_linux.o debugaarch64/client/q_shlinux.o debugaarch64/client/vid_menu.o debugaarch64/client/vid_so.o debugaarch64/client/snd_alsa.o debugaarch64/client/sys_linux.o debugaarch64/client/glob.o debugaarch64/client/net_udp.o debugaarch64/client/q_shared.o debugaarch64/client/pmove.o debugaarch64/client/snd_mixa.o -L/usr/local/lib -ldl -lm -lasound -lpthread gcc -I/usr/local/include -Dstricmp=strcasecmp -D_GNU_SOURCE -Wno-format-truncation -Wno-unused-result -g -D_DEBUG -o debugaarch64/q2ded debugaarch64/ded/cmd.o debugaarch64/ded/cmodel.o debugaarch64/ded/common.o debugaarch64/ded/crc.o debugaarch64/ded/cvar.o debugaarch64/ded/files.o debugaarch64/ded/md4.o debugaarch64/ded/net_chan.o debugaarch64/ded/sv_ccmds.o debugaarch64/ded/sv_ents.o debugaarch64/ded/sv_game.o debugaarch64/ded/sv_init.o debugaarch64/ded/sv_main.o debugaarch64/ded/sv_send.o debugaarch64/ded/sv_user.o debugaarch64/ded/sv_world.o debugaarch64/ded/q_shlinux.o debugaarch64/ded/sys_linux.o debugaarch64/ded/glob.o debugaarch64/ded/net_udp.o debugaarch64/ded/q_shared.o debugaarch64/ded/pmove.o debugaarch64/ded/cl_null.o debugaarch64/ded/cd_null.o -L/usr/local/lib -ldl -lm -lasound -lpthread gcc -I/usr/local/include -Dstricmp=strcasecmp -D_GNU_SOURCE -Wno-format-truncation -Wno-unused-result -g -D_DEBUG -fPIC -std=c99 -I/include -o debugaarch64/ref_vk/vk_common.o -c ../ref_vk/vk_common.c ../ref_vk/vk_common.c: In function ‘QVk_BeginFrame’: ../ref_vk/vk_common.c:1959:124: error: ‘VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT’ undeclared (first use in this function) if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || result == VK_ERROR_SURFACE_LOST_KHR || result == VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT) ^~~~~~~~~~~~ ../ref_vk/vk_common.c:1959:124: note: each undeclared identifier is reported only once for each function it appears in ../ref_vk/vk_common.c: In function ‘QVk_EndFrame’: ../ref_vk/vk_common.c:2057:64: error: ‘VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT’ undeclared (first use in this function) renderResult == VK_ERROR_SURFACE_LOST_KHR || renderResult == VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT) ^~~~~~~~~~~~ ../ref_vk/vk_common.c: In function ‘QVk_GetError’: ../ref_vk/vk_common.c:2422:24: error: ‘VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT’ undeclared (first use in this function)

define ERRSTR(r) case VK ##r: return "VK"#r

                    ^~~

../ref_vk/vk_common.c:2449:3: note: in expansion of macro ‘ERRSTR’ ERRSTR(ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT); ^~ make[1]: [Makefile:1839: debugaarch64/ref_vk/vk_common.o] Error 1 make[1]: Leaving directory '/home/pi/Public/vkQuake2/linux' make: [Makefile:149: build_debug] Error 2

infapi00 commented 4 years ago

Thanks for the log. Those doesn't seem like errors coming from the Makefile. It seems that on your system you don't have an updated version of the vulkan headers. Quoting myself:

I needed to update the vulkan libraries as vkQuake2 uses stuff more recent that those included with Raspbian (don't know which version comes with aarch64)

In any case, that means that the compilation started, so it seems that you go on the right direction. FWIW, I personally built and installed the vulkan headers from here: https://github.com/KhronosGroup/Vulkan-Headers

leggazoid commented 4 years ago

I installed the header files and compiled quake2.

Can't init Vulkan message as follows:

~/Public/vkQuake2/linux/debugaarch64 $ ./quake2 couldn't exec default.cfg couldn't exec config.cfg Console initialized.

------- sound initialization ------- Setting up ALSA driver ..... Low Performance 11KHz. sound sampling rate: 11025

------- Loading ref_vk.so ------- LoadLibrary("/home/pi/Public/vkQuake2/linux/debugaarch64/ref_vk.so") ref_vk version: Vulkan (vkQuake2 v1.5.1) Initializing Vulkan display ...setting mode 11: 1920 1080 Using XFree86-VidModeExtension Version 2.2 Enabled extensions: VK_KHR_surface VK_KHR_xlib_surface VK_EXT_debug_utils QVk_Init(): Could not create Vulkan instance: VK_ERROR_LAYER_NOT_PRESENT ref_vk::R_Init() - could not initialize Vulkan! Received signal 11, exiting...

leggazoid commented 4 years ago

Tried the following, same error:

export VK_ICD_FILENAMES=/home/pi/local-install/share/vulkan/icd.d/broadcom_icd.aarch64.json

infapi00 commented 4 years ago

export VK_ICD_FILENAMES=/home/pi/local-install/share/vulkan/icd.d/broadcom_icd.aarch64.json

Two things: could you confirm that is exactly the name of the icd file generated (a find would be enough).

Also, before going to compile vkQuake2, have you tried some simpler demos? From the comments on this blog post that I wrote: https://blogs.igalia.com/apinheiro/2020/06/v3dv-quick-guide-to-build-and-run-some-demos/

I know that there are some people that got those demos to work on aarch64 (but with different distros). Just to check if there is something more general on your environment to fix.

Having said so, and as you were able to update the Makefile and get the build done, Im not sure if it makes sense to keep this as an vkQuake2 issue, when it seems more like a "setting the aarch64 environment" issue. But I would let @kondrak to decide about that.

leggazoid commented 4 years ago

I tried demos that worked from link getting betwwen 150-200fps on most.

find /home/pi/local-install/share/vulkan/icd.d/broadcom_icd.aarch64.json /home/pi/local-install/share/vulkan/icd.d/broadcom_icd.aarch64.json

pi@rpi64:~ $ ls -lh /home/pi/local-install/share/vulkan/icd.d/broadcom_icd.aarch64.json -rw-r--r-- 1 pi pi 167 Aug 14 11:02 /home/pi/local-install/share/vulkan/icd.d/broadcom_icd.aarch64.json pi@rpi64:~ $ cat /home/pi/local-install/share/vulkan/icd.d/broadcom_icd.aarch64.json { "ICD": { "api_version": "1.1.102", "library_path": "/home/pi/local-install/lib/libvulkan_broadcom.so" }, "file_format_version": "1.0.0" }pi@rpi64:~ $ ls -lh /home/pi/local-install/lib/libvulkan_broadcom.so -rwxr-xr-x 1 pi pi 15M Aug 14 11:06 /home/pi/local-install/lib/libvulkan_broadcom.so

leggazoid commented 4 years ago

If the demos run does that mean the Vulcan SDK is installed correctly?

The Vulkan SDK may not be installed correctly?

Thanks for the help. I will revisit this when raspberry pi os 64bit is out of beta.

infapi00 commented 4 years ago

If the demos run does that mean the Vulcan SDK is installed correctly?

In general yes.

The Vulkan SDK may not be installed correctly?

It is not needed a full SDK to run vulkan applications

Thanks for the help. I will revisit this when raspberry pi os 64bit is out of beta.

As you prefer, but again, it is worth to note that the last issues you are facing doesn't seem related with the driver being on beta, but on your environment.

Just one last thing. Now that you confirmed that the demos are working, I took a new look to your last error log with vkQuake2:

Enabled extensions: VK_KHR_surface VK_KHR_xlib_surface VK_EXT_debug_utils QVk_Init(): Could not create Vulkan instance: VK_ERROR_LAYER_NOT_PRESENT

Have you installed the vulkan validation layers as mentioned? Debug build use them as default. One way to confirm if that is the problem is build vkQuake in release mode. Instead of "make" use "make release", and try again with the new binary.

leggazoid commented 4 years ago

The "make -j4 release" command worked!

Thanks for all the help.

A question for @kondrak, Can the makefile and sys_linux.c changes be added for aarch64?

This issue may be closed.

kondrak commented 4 years ago

@leggazoid try the latest master branch, it should work fine now. Regarding debug build - yes, they use validation layers by default but it should still be possible to launch the game by running ./quake2 +set vk_validation 0 to disable them if necessary. Good to hear that game works fine!