Try / Tempest

API abstraction layer for 3D graphics, UI and sound. Written in C++17 with Vulkan, DX12 and Metal support.
MIT License
86 stars 25 forks source link

Compiling on Raspberry Pi 4 #16

Closed ip0p closed 1 year ago

ip0p commented 3 years ago

Hey! Cool stuff you have here! :D I'm trying to compile on a pi4 just for fun. Is this actually possible? It had problems with sse2 before compiling squish but I just removed the commands. Currently I'm stuck at this. Coming from C# and still learning C++. Maybe you can help and try to describe what it means.

[ 55%] Building CXX object lib/MoltenTempest/Engine/CMakeFiles/MoltenTempest.dir/gapi/vulkan/vcommandbuffer.cpp.o /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp: In member function ‘void Tempest::Detail::VCommandBuffer::changeLayout(VkImage, VkFormat, VkImageLayout, VkImageLayout, uint32_t, bool)’: /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:395:10: error: ‘VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL’ was not declared in this scope case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:395:10: note: suggested alternative: ‘VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL’ case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:396:10: error: ‘VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL’ was not declared in this scope case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:396:10: note: suggested alternative: ‘VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL’ case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:397:10: error: ‘VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL’ was not declared in this scope case VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:397:10: note: suggested alternative: ‘VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL’ case VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:398:10: error: ‘VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL’ was not declared in this scope case VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:398:10: note: suggested alternative: ‘VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL’ case VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:447:10: error: ‘VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL’ was not declared in this scope case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:447:10: note: suggested alternative: ‘VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL’ case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:448:10: error: ‘VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL’ was not declared in this scope case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:448:10: note: suggested alternative: ‘VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL’ case VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:449:10: error: ‘VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL’ was not declared in this scope case VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:449:10: note: suggested alternative: ‘VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL’ case VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:450:10: error: ‘VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL’ was not declared in this scope case VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/pi/OpenGothic/lib/MoltenTempest/Engine/gapi/vulkan/vcommandbuffer.cpp:450:10: note: suggested alternative: ‘VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL’ case VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL make[2]: *** [lib/MoltenTempest/Engine/CMakeFiles/MoltenTempest.dir/build.make:585: lib/MoltenTempest/Engine/CMakeFiles/MoltenTempest.dir/gapi/vulkan/vcommandbuffer.cpp.o] Fehler 1 make[1]: *** [CMakeFiles/Makefile2:1059: lib/MoltenTempest/Engine/CMakeFiles/MoltenTempest.dir/all] Fehler 2 make: *** [Makefile:130: all] Fehler 2

Try commented 3 years ago

Hello, @ip0p ! This compilation error man that there is no definition VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL in scope. Most likely it because of old Vulkan-SDK version. My version is 1.2.148.1 - try this one or newer.

I'm trying to compile on a pi4 just for fun. Is this actually possible?

May be, but no one ever tried :)

ip0p commented 3 years ago

I got it compiling when I changed the mentioned variables with the suggested alternative. Doesnt seem right but didnt gave me errors. But when I tried to run it just said no validation layer found and aborted. What does that mean? Is there a way to get a more detailed log? I also found out there seems to be sdk 1.1 installed. For the newer SDK version I didn't find an arm version. Vulkan on rpi4 itself seems to be experimental/wip at the moment.

ip0p commented 3 years ago

Update: I had set VK_ICD_FILENAMES=/home/pi/local-install/share/vulkan/icd.d/broadcom_icd.armv7l.json to make vulkan to work. Now the changelayout method is still my enemy. Commenting out was not a good solution and now it crashes there. This is how far I come now: `VulkanApi: no validation layers available VulkanApi: start init VulkanApi: create instance VulkanApi: create instance done VulkanApi: start init done vk: error: v3dv_GetPhysicalDeviceProperties2: ignored VkStructureType 1000212000:VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT

WARNING: v3dv is neither a complete nor a conformant Vulkan implementation. Testing use only. VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new Info: Couldn't load VDF-Archive /home/pi/Documents/Gothic II/Data/$Templates$/SPLASH.BMP: unsupported Info: Couldn't load VDF-Archive /home/pi/Documents/Gothic II/Data/$Templates$/MSSDS3D.M3D: unsupported Info: Couldn't load VDF-Archive /home/pi/Documents/Gothic II/Data/$Templates$/ZGAMEPAD.DLL: unsupported Info: Couldn't load VDF-Archive /home/pi/Documents/Gothic II/Data/$Templates$/ZACTIVATECTRL.DLL: unsupported Info: Couldn't load VDF-Archive /home/pi/Documents/Gothic II/Data/$Templates$/ZBINKFIX.DLL: unsupported Info: Couldn't load VDF-Archive /home/pi/Documents/Gothic II/Data/$Templates$/ZMOUSEFIX.DLL: unsupported vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000072002:VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO

GPU = V3D 4.2 Depth format = 10 Shadow format = 4 VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new VulkanApi: changelayout method VulkanApi: switch old VulkanApi: switch new Abgebrochen `

Try commented 3 years ago

Actually from this log it's hard to say what exactly is going on. I can only bring light to a few things:

Commenting out was not a good solution and now it crashes there.

Commenting VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL is ok - this layout is never used in opengothic.

vk: error: v3dv_AllocateMemory: ignored VkStructureType 1000127001:VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO

It seem like your issue not in barriers(or at least not only in barriers), but in gpu memory allocation. Looks like v3dv driver exposed a "VK_KHR_dedicated_allocation" extension to use, but it's not actually finished. Possible workaround: modify VDevice::createLogicalDevice and make set props.hasDedicatedAlloc; to false there.

At this point I want to recommend to run test-suite(MoltenTempest/Tests/tests) at first to see how simple content works.

ip0p commented 3 years ago

Hey! Here are the good news: I fixed the not declared errors in vcommandbuffer.cpp by copying the header files from the newest sdk to my /usr/lib. (Don't know if this is right but it compiled after that) I also setup VS Code on the pi to be able to better debug. Found out that in renderer.cpp changing the gbufDepth TextureFormat to RG8 actually made the game start! (Why?) Coming to the bad news: After a few seconds (1-3) playing epic gothic music it just crashes. :( Don't know if its caused by the audio part or something else. Currently I'm out of ideas how to debug this. Maybe you have a hint... Screenshot 2020-10-16 213744

Try commented 3 years ago

RG8 actually made the game start! (Why?)

The better question is why RG16 failed. Most likely RG16 it s UnsupportedTextureFormat exception:

Attachment Device::attachment(TextureFormat frm, const uint32_t w, const uint32_t h, const bool mips) {
  if(!devProps.hasSamplerFormat(frm) && !devProps.hasAttachFormat(frm))
    throw std::system_error(Tempest::GraphicsErrc::UnsupportedTextureFormat);
  ...
  }

Anyway, RG8 is not a good replacement: spec requires each gbuffer texture must have same byte-length. In this case: RGBA8 will do in short term.

About crashes in general: Without crash-reason and stacktrace it's difficult to make a good advice. I'm not sure about VS-code, but since error handling is exceptions-bases, it would be a good idea to add break-point on any thrown exception, if it's possible in vs-code.

PS While writing this answer I noticed that crash-logging is not completer on non-windows platforms:

// crashlog.cpp
void CrashLog::dumpStack(const char *sig) {
#ifdef __WINDOWS__   // <-- don't remember why it's disabled on other platforms :(
...
#endif
  }
ip0p commented 3 years ago

I tried to add break points everywhere in crashlog.cpp. Nothing. Also added some additional SIGs. (Still c++ noob so blindly testing stuff). Found out SIGABRT is double defined there btw. But signalHandler and terminateHandler never got called. Also checked system logs nothing. Maybe its something wrong in my setup but I have the feeling that somehow the X-Server force closes the app or something like that. But all of that is still guessing... 😅 Could it be that the graphics ram is running full or something like this? It's just so strange that it shows the menu I can do stuff, also the intro is playing from start to end(maybe interesting!) and just closes after a random amount of seconds.

Try commented 3 years ago

I can do stuff, also the intro is playing from start to end(maybe interesting!)

Actually it's very cool! Move from 'doesn't compiling' to working menu is very nice progress 👍

just closes after a random amount of seconds.

Closes, while game at loading screen and never reaches the game-play itself, right? So current ideas of what might it be:

ip0p commented 3 years ago

Closes, while game at loading screen and never reaches the game-play itself, right?

Actually it crashes when idle in menu. Also with nomenu flag after few seconds. Maybe it could be from the audio side. 🤔

Thanks for your feedback! I will check this things when I have time in the evening.

Nindaleth commented 1 year ago

@ip0p Did you find a bit of time for re-trying this on RPi4? The CrashLog::DumpStack is now implemented for Linux so there should be better traces.

Nindaleth commented 1 year ago

I guess this is no longer an issue as others post in-game screenshots from RPi4 (Try/OpenGothic#121)