hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.38k stars 2.19k forks source link

Does ppsspp support gbm backend +vulkan? #16899

Closed zack-huangzihan closed 1 year ago

zack-huangzihan commented 1 year ago

Game or games this happens in

games

What area of the game / PPSSPP

In the code: https://github.com/hrydgard/ppsspp/blob/ceb4186d0ffc26091bb3fc25a1e71bce15b8902d/SDL/SDLVulkanGraphicsContext.cpp

We can see that there is some support for the back end: WINDOWSYSTEM_WAYLAND WINDOWSYSTEM_XLIB WINDOWSYSTEM_XCB WINDOWSYSTEM_METAL_EXT and so on, Can gbm+vulkan render?

Here's how I changed it:

diff --git a/SDL/SDLVulkanGraphicsContext.cpp b/SDL/SDLVulkanGraphicsContext.cpp
index 433f35b03..e08c30578 100644
--- a/SDL/SDLVulkanGraphicsContext.cpp
+++ b/SDL/SDLVulkanGraphicsContext.cpp
@@ -105,8 +105,9 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode,      
 #endif
 #endif
        default:
-               fprintf(stderr, "Vulkan subsystem %d not supported\n", sys_info.subsystem);
-               exit(1);
+               vulkan_->InitSurface(WINDOWSYSTEM_DISPLAY, nullptr, nullptr);
+               //fprintf(stderr, "Vulkan subsystem %d not supported\n", sys_info.subsystem);
+               //exit(1);
                break;
        }

But it can't work. Do you have any advice for me?

What should happen

On a lot of embedded linux platforms, probably most of the way to use kms, hopefully can support

Logs

No response

Platform

Linux / BSD

Mobile phone model or graphics card

arm mali

PPSSPP version affected

latest

Last working version

No response

Graphics backend (3D API)

Vulkan

Checklist

hrydgard commented 1 year ago

GBM = https://www.reddit.com/r/linuxquestions/comments/ss4vhj/whats_the_gbm_api/ ?

I guess this hasn't been worked on yet, no. Feel free to help out.

zack-huangzihan commented 1 year ago

Maybe my description is not correct enough. Can kms+vulkan be implemented?

As shown in the code above:

vulkan_->InitSurface(WINDOWSYSTEM_DISPLAY, nullptr, nullptr);
Common/GPU/Vulkan/VulkanContext.h:

enum WindowSystem {
#ifdef _WIN32
        WINDOWSYSTEM_WIN32,
#endif
#ifdef __ANDROID__
        WINDOWSYSTEM_ANDROID,
#endif
#ifdef VK_USE_PLATFORM_METAL_EXT
        WINDOWSYSTEM_METAL_EXT,
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
        WINDOWSYSTEM_XLIB,
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
        WINDOWSYSTEM_XCB,
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
        WINDOWSYSTEM_WAYLAND,
#endif
#ifdef VK_USE_PLATFORM_DISPLAY_KHR
        WINDOWSYSTEM_DISPLAY,
#endif
};

Is there any reason why only WINDOWSYSTEM_DISPLAY is not called? I only found similar apps here: libretro/LibretroVulkanContext.cpp

#ifdef _WIN32
        vk->InitSurface(WINDOWSYSTEM_WIN32, nullptr, nullptr);
#elif defined(__ANDROID__)
        vk->InitSurface(WINDOWSYSTEM_ANDROID, nullptr, nullptr);
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
        vk->InitSurface(WINDOWSYSTEM_XLIB, nullptr, nullptr);
#elif defined(VK_USE_PLATFORM_XCB_KHR)
        vk->InitSurface(WINDOWSYSTEM_XCB, nullptr, nullptr);
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
        vk->InitSurface(WINDOWSYSTEM_WAYLAND, nullptr, nullptr);
#elif defined(VK_USE_PLATFORM_DISPLAY_KHR)
        vk->InitSurface(WINDOWSYSTEM_DISPLAY, nullptr, nullptr);
#endif

But it looks like and SDLVulkanGraphicsContext.cpp call is not the same?

amverweij commented 1 year ago

I would like to see this support too. The libretro core works perfectly well on gbm/kms. However standalone ppsspp is supposed to be more efficient. I believe there is an earlier attempt to implement this here:

https://github.com/hrydgard/ppsspp/pull/14758

The initial comments suggest the work isn't complete yet.

zack-huangzihan commented 1 year ago

hello, all @hrydgard @amverweij @vanfanel I'm so glad I realized this thing! The implementation here is referenced:https://github.com/vanfanel/ppsspp For the call to vulkan interface in kms on the arm linux system, I changed the changes inside to the form of dlopen,Let me explain how this code works:

First of all, in linux system, vulkan implementation is not open in the source code provided by gpu manufacturers, they use a hook called "vulkan loader", used to parse the ***.so of different manufacturers,It's usually "libvulkan.so",So I need to read it with dlopen needed to sign, and then in "SDL/SDLVulkanGraphicsContext CPP" add a WINDOWSYSTEM_DISPLAY implementation.

These implementations are in Common/GPU/Vulkan/VulkanContext.cpp

YKS@NSH$GM100({C8CNE~{E

B4SN0@VP({_Q999 @N{}Q@K

Both ui and game rendering worked well, so I submitted my code:

https://github.com/hrydgard/ppsspp/pull/16921

hrydgard commented 1 year ago

Thank you @zack-huangzihan for implementing this windowsystem initialization.

Can we consider this closed now?

zack-huangzihan commented 1 year ago

ok