Outputs: Vulkan too, for --game-window and the iOS TV mode

The SDL game window gets its Vulkan surface the same way the main window
does, so it should work on Linux too. Windows and OpenGL aren't done.
EmuScreen asks the draw context for the output's size, which follows a
recreated Vulkan swapchain.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-22 20:11:36 +02:00
1 parent 8e8cf5dbb4
commit 76d0d37941
4 files changed
+33 -23

No files matched your search

+27 -15
View File
@@ -1447,29 +1447,41 @@ static SDL_Window *g_gameWindow = nullptr;
static int g_gameOutputId = 0;
static void CreateGameWindow() {
Draw::SwapchainDesc desc{};
desc.tag = "GameWindow";
const GPUBackend backend = (GPUBackend)g_Config.iGPUBackend;
if (backend == GPUBackend::VULKAN) {
g_gameWindow = SDL_CreateWindow("PPSSPP game", 960, 544, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
WindowDesc windowDesc{};
std::string error;
if (g_gameWindow && !DetermineVulkanWindowSystem(g_gameWindow, &windowDesc, &error)) {
fprintf(stderr, "Can't use the game window: %s\n", error.c_str());
SDL_DestroyWindow(g_gameWindow);
g_gameWindow = nullptr;
return;
}
desc.winsys = windowDesc.winsys;
desc.data1 = windowDesc.data1;
desc.data2 = windowDesc.data2;
#if PPSSPP_PLATFORM(MAC)
if (g_Config.iGPUBackend != (int)GPUBackend::METAL) {
fprintf(stderr, "--game-window needs --graphics=metal\n");
} else if (backend == GPUBackend::METAL) {
g_gameWindow = SDL_CreateWindow("PPSSPP game", 960, 544, SDL_WINDOW_METAL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
if (g_gameWindow) {
desc.winsys = WINDOWSYSTEM_METAL_EXT;
desc.data1 = SDL_Metal_GetLayer(SDL_Metal_CreateView(g_gameWindow));
}
#endif
} else {
// TODO: Windows (D3D11) and OpenGL.
fprintf(stderr, "--game-window needs Vulkan, or Metal on Mac\n");
return;
}
g_gameWindow = SDL_CreateWindow("PPSSPP game", 960, 544, SDL_WINDOW_METAL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
if (!g_gameWindow) {
fprintf(stderr, "Error creating the game window: %s\n", SDL_GetError());
return;
}
SDL_MetalView metalView = SDL_Metal_CreateView(g_gameWindow);
int width = 0, height = 0;
SDL_GetWindowSizeInPixels(g_gameWindow, &width, &height);
Draw::SwapchainDesc desc{};
desc.winsys = WINDOWSYSTEM_METAL_EXT;
desc.data1 = SDL_Metal_GetLayer(metalView);
desc.width = width;
desc.height = height;
desc.tag = "GameWindow";
SDL_GetWindowSizeInPixels(g_gameWindow, &desc.width, &desc.height);
g_gameOutputId = Native_AddOutput(OutputRole::Game, desc);
#else
fprintf(stderr, "--game-window is only implemented on Mac (Metal)\n");
#endif
}
// Returns true if the event was for the game window, and has been handled. Keys still go to the emulator.
+1 -2
View File
@@ -1683,8 +1683,7 @@ void EmuScreen::UpdateGameOutput() {
return;
}
OutputParams params;
params.pixelWidth = output->swapchain->Width();
params.pixelHeight = output->swapchain->Height();
screenManager()->getDrawContext()->GetFramebufferDimensions(output->swapchain, &params.pixelWidth, &params.pixelHeight);
params.orientation = params.pixelHeight > params.pixelWidth * 1.1f ? DeviceOrientation::Portrait : DeviceOrientation::Landscape;
gameOutputOrientation_ = params.orientation;
gpu->SetPresentationOutput(&params);
+3 -3
View File
@@ -111,9 +111,9 @@ static bool g_launched = false;
if (!self.windowScene || self.window) {
return;
}
// Only Metal can present to a second display so far. Without a window, iOS mirrors the phone.
if (g_Config.iGPUBackend != (int)GPUBackend::METAL) {
INFO_LOG(Log::G3D, "External display: mirroring, as the backend isn't Metal");
// Without a window, iOS mirrors the phone.
if (g_Config.iGPUBackend != (int)GPUBackend::METAL && g_Config.iGPUBackend != (int)GPUBackend::VULKAN) {
INFO_LOG(Log::G3D, "External display: mirroring, as the backend can't present to it");
return;
}
#if !TARGET_OS_TV
+2 -3
View File
@@ -648,10 +648,9 @@ static int GetPickerRequestId(id picker) {
#if !PPSSPP_PLATFORM(TVOS) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 270000
// From iOS 27, an external display scene only goes to apps that register for one like this. Earlier
// versions go by the Info.plist role instead. Only Metal can show the game there so far, and without
// the scene, iOS mirrors the phone.
// versions go by the Info.plist role instead. Without the scene, iOS mirrors the phone.
if (@available(iOS 27.0, *)) {
if (g_Config.iGPUBackend == (int)GPUBackend::METAL) {
if (g_Config.iGPUBackend == (int)GPUBackend::METAL || g_Config.iGPUBackend == (int)GPUBackend::VULKAN) {
UISceneConfiguration *sceneConfiguration = [UISceneConfiguration new];
sceneConfiguration.delegateClass = [ExternalDisplaySceneDelegate class];
self.externalDisplayRegistration = [self registerSceneAccessory:[UISceneAccessory externalNonInteractiveSceneAccessoryWithConfiguration:sceneConfiguration]];