mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-02 19:35:46 +00:00
chore: SDL3 (ryubing/ryujinx!207)
See merge request ryubing/ryujinx!207
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Input.HLE;
|
||||
using Ryujinx.SDL2.Common;
|
||||
using Ryujinx.SDL3.Common;
|
||||
using System;
|
||||
using SDL;
|
||||
using static SDL.SDL3;
|
||||
using System.Runtime.InteropServices;
|
||||
using static SDL2.SDL;
|
||||
|
||||
namespace Ryujinx.Headless
|
||||
{
|
||||
@@ -39,18 +40,15 @@ namespace Ryujinx.Headless
|
||||
}
|
||||
}
|
||||
|
||||
private static void BasicInvoke(Action action)
|
||||
public unsafe nint CreateWindowSurface(nint instance)
|
||||
{
|
||||
action();
|
||||
}
|
||||
|
||||
public nint CreateWindowSurface(nint instance)
|
||||
{
|
||||
ulong surfaceHandle = 0;
|
||||
VkSurfaceKHR_T surface = new();
|
||||
VkSurfaceKHR_T* surfaceHandle = &surface;
|
||||
VkSurfaceKHR_T** surfaceHandleHandle = &surfaceHandle;
|
||||
|
||||
void CreateSurface()
|
||||
{
|
||||
if (SDL_Vulkan_CreateSurface(WindowHandle, instance, out surfaceHandle) == SDL_bool.SDL_FALSE)
|
||||
if (!SDL_Vulkan_CreateSurface(WindowHandle, (VkInstance_T*)instance, null, surfaceHandleHandle))
|
||||
{
|
||||
string errorMessage = $"SDL_Vulkan_CreateSurface failed with error \"{SDL_GetError()}\"";
|
||||
|
||||
@@ -60,9 +58,9 @@ namespace Ryujinx.Headless
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL2Driver.MainThreadDispatcher != null)
|
||||
if (SDL3Driver.MainThreadDispatcher != null)
|
||||
{
|
||||
SDL2Driver.MainThreadDispatcher(CreateSurface);
|
||||
SDL3Driver.MainThreadDispatcher(CreateSurface);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -72,32 +70,22 @@ namespace Ryujinx.Headless
|
||||
return (nint)surfaceHandle;
|
||||
}
|
||||
|
||||
public unsafe string[] GetRequiredInstanceExtensions()
|
||||
public unsafe static string[] GetRequiredInstanceExtensions()
|
||||
{
|
||||
if (SDL_Vulkan_GetInstanceExtensions(WindowHandle, out uint extensionsCount, nint.Zero) == SDL_bool.SDL_TRUE)
|
||||
{
|
||||
nint[] rawExtensions = new nint[(int)extensionsCount];
|
||||
string[] extensions = new string[(int)extensionsCount];
|
||||
uint extensionCount = 0;
|
||||
byte** extensions = SDL_Vulkan_GetInstanceExtensions(&extensionCount);
|
||||
if (extensionCount == 0) {
|
||||
string errorMessage = $"SDL_Vulkan_GetInstanceExtensions failed with error \"{SDL_GetError()}\"";
|
||||
|
||||
fixed (nint* rawExtensionsPtr = rawExtensions)
|
||||
{
|
||||
if (SDL_Vulkan_GetInstanceExtensions(WindowHandle, out extensionsCount, (nint)rawExtensionsPtr) == SDL_bool.SDL_TRUE)
|
||||
{
|
||||
for (int i = 0; i < extensions.Length; i++)
|
||||
{
|
||||
extensions[i] = Marshal.PtrToStringUTF8(rawExtensions[i]);
|
||||
}
|
||||
Logger.Error?.Print(LogClass.Application, errorMessage);
|
||||
|
||||
return extensions;
|
||||
}
|
||||
}
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
string errorMessage = $"SDL_Vulkan_GetInstanceExtensions failed with error \"{SDL_GetError()}\"";
|
||||
|
||||
Logger.Error?.Print(LogClass.Application, errorMessage);
|
||||
|
||||
throw new Exception(errorMessage);
|
||||
string[] extensionArr = new string[extensionCount];
|
||||
for (int i = 0; i < extensionCount; i++) {
|
||||
extensionArr[i] = Marshal.PtrToStringUTF8((nint)extensions[i]);
|
||||
}
|
||||
return extensionArr;
|
||||
}
|
||||
|
||||
protected override void FinalizeWindowRenderer()
|
||||
|
||||
Reference in New Issue
Block a user