Let Ryujinx make the window

This commit is contained in:
stossy11 2024-11-02 22:33:54 +11:00
parent 02901a5a14
commit 18b9baa943
5 changed files with 59 additions and 49 deletions

View File

@ -27,6 +27,36 @@
</ActionContent>
</BreakpointActionProxy>
</Actions>
<Locations>
<Location
uuid = "C2C839C6-26A1-468A-9479-A00FD57EA17C - e09e330dd17da5b1"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "MeloNX.RyujinxEmulator.startWithRunLoop(config: MeloNX.RyujinxEmulator.Configuration) throws -&gt; ()"
moduleName = "MeloNX.debug.dylib"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/stossy11/MeloNX/MeloNX-XC/MeloNX/Core/Ryujinx.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "111"
endingLineNumber = "111">
</Location>
<Location
uuid = "C2C839C6-26A1-468A-9479-A00FD57EA17C - a8ffb78cb80274ea"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #2 @Sendable () -&gt; () in MeloNX.RyujinxEmulator.startWithRunLoop(config: MeloNX.RyujinxEmulator.Configuration) throws -&gt; ()"
moduleName = "MeloNX.debug.dylib"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/stossy11/MeloNX/MeloNX-XC/MeloNX/Core/Ryujinx.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "112"
endingLineNumber = "112">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy

View File

@ -25,14 +25,6 @@ struct ContentView: View {
SDL_SetMainReady()
SDL_iPhoneSetEventPump(SDL_TRUE)
if SDL_Init(SDL_INIT_VIDEO) < 0 {
fatalError("Unable to initialize SDL: \(String(cString: SDL_GetError()))")
}
if SDL_Vulkan_LoadLibrary(nil) != 0 {
fatalError("Failed to load Vulkan library: \(String(cString: SDL_GetError()))")
}
}
}
@ -40,24 +32,19 @@ struct ContentView: View {
var body: some View {
ZStack {
if let gameUrl, emulationStarted {
VulkanSDLViewRepresentable { displayid in
DispatchQueue.main.async {
gameUrl.startAccessingSecurityScopedResource()
let config = RyujinxEmulator.Configuration(
inputPath: gameUrl.path,
mainThread: mainThread,
graphicsBackend: "Vulkan",
additionalArgs: [
"--display-id", String(displayid),
"--fullscreen", "true"
]
)
VulkanSDLViewRepresentable { // displayid in
let config = RyujinxEmulator.Configuration(
inputPath: gameUrl.path,
mainThread: mainThread,
graphicsBackend: "Vulkan",
additionalArgs: [
//"--display-id", String(displayid),
// "--fullscreen", "true"
]
)
showVirtualController(url: gameUrl, ryuconfig: config)
}
showVirtualController(url: gameUrl, ryuconfig: config)
}
}

View File

@ -15,12 +15,12 @@ import SDL2
struct VulkanSDLViewRepresentable: UIViewRepresentable {
let configure: (Uint32) -> Void
let configure: () -> Void
func makeUIView(context: Context) -> VulkanSDLView {
configure()
let view = VulkanSDLView(frame: .zero)
DispatchQueue.main.async { [self] in
configure(SDL_GetWindowID(view.sdlWindow))
}
return view
}
@ -56,14 +56,7 @@ class VulkanSDLView: UIView {
// Create an SDL window with Metal support
DispatchQueue.main.async { [self] in
sdlWindow = SDL_CreateWindow(
"Ryujinx",
Int32(SDL_WINDOWPOS_CENTERED_MASK),
Int32(SDL_WINDOWPOS_CENTERED_MASK),
Int32(frame.width),
Int32(frame.height),
SDL_WINDOW_SHOWN.rawValue | SDL_WINDOW_ALLOW_HIGHDPI.rawValue | SDL_WINDOW_VULKAN.rawValue
)
sdlWindow = SDL_GetWindowFromID(1)
}
@ -81,11 +74,11 @@ class VulkanSDLView: UIView {
}
}
if let metalLayerPointer = SDL_Metal_GetLayer(metalView) {
let metalLayer = Unmanaged<CAMetalLayer>.fromOpaque(metalLayerPointer).takeUnretainedValue()
metalLayer.device = MTLCreateSystemDefaultDevice()
metalLayer.pixelFormat = .bgra8Unorm
DispatchQueue.main.async { [self] in
DispatchQueue.main.async { [self] in
if let metalLayerPointer = SDL_Metal_GetLayer(metalView) {
let metalLayer = Unmanaged<CAMetalLayer>.fromOpaque(metalLayerPointer).takeUnretainedValue()
metalLayer.device = MTLCreateSystemDefaultDevice()
// metalLayer.pixelFormat = .bgra8Unorm
layer.addSublayer(metalLayer)
}
}

View File

@ -185,10 +185,10 @@ namespace Ryujinx.Headless.SDL2
FullscreenFlag = SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP;
}
WindowHandle = SDL_GetWindowFromID(1);
WindowHandle = SDL_CreateWindow($"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}", SDL_WINDOWPOS_CENTERED_DISPLAY(DisplayId), SDL_WINDOWPOS_CENTERED_DISPLAY(DisplayId), Width, Height, DefaultFlags | FullscreenFlag | GetWindowFlags());
Logger.Info?.Print(LogClass.Gpu, $"DisplayID: \"{WindowHandle}\"");
//SDL_CreateWindow($"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}", SDL_WINDOWPOS_CENTERED_DISPLAY(DisplayId), SDL_WINDOWPOS_CENTERED_DISPLAY(DisplayId), Width, Height, DefaultFlags | FullscreenFlag | GetWindowFlags());
// SDL_CreateWindow($"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}", SDL_WINDOWPOS_CENTERED_DISPLAY(DisplayId), SDL_WINDOWPOS_CENTERED_DISPLAY(DisplayId), Width, Height, DefaultFlags | FullscreenFlag | GetWindowFlags());
if (WindowHandle == IntPtr.Zero)
{
@ -217,9 +217,9 @@ namespace Ryujinx.Headless.SDL2
// As we don't need this to fire in either case we can test for fullscreen.
if (!IsFullscreen && !IsExclusiveFullscreen)
{
// Width = evnt.window.data1;
// Height = evnt.window.data2;
// Renderer?.Window.SetSize(Width, Height);
Width = evnt.window.data1;
Height = evnt.window.data2;
Renderer?.Window.SetSize(Width, Height);
// MouseDriver.SetClientSize(Width, Height);
// if (Renderer != null && Renderer.Window != null)
// {