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> </ActionContent>
</BreakpointActionProxy> </BreakpointActionProxy>
</Actions> </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> </BreakpointContent>
</BreakpointProxy> </BreakpointProxy>
<BreakpointProxy <BreakpointProxy

View File

@ -24,15 +24,7 @@ struct ContentView: View {
DispatchQueue.main.async { DispatchQueue.main.async {
SDL_SetMainReady() SDL_SetMainReady()
SDL_iPhoneSetEventPump(SDL_TRUE) 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 { var body: some View {
ZStack { ZStack {
if let gameUrl, emulationStarted { if let gameUrl, emulationStarted {
VulkanSDLViewRepresentable { displayid in VulkanSDLViewRepresentable { // displayid in
DispatchQueue.main.async { let config = RyujinxEmulator.Configuration(
inputPath: gameUrl.path,
gameUrl.startAccessingSecurityScopedResource() mainThread: mainThread,
graphicsBackend: "Vulkan",
let config = RyujinxEmulator.Configuration( additionalArgs: [
inputPath: gameUrl.path, //"--display-id", String(displayid),
mainThread: mainThread, // "--fullscreen", "true"
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 { struct VulkanSDLViewRepresentable: UIViewRepresentable {
let configure: (Uint32) -> Void let configure: () -> Void
func makeUIView(context: Context) -> VulkanSDLView { func makeUIView(context: Context) -> VulkanSDLView {
configure()
let view = VulkanSDLView(frame: .zero) let view = VulkanSDLView(frame: .zero)
DispatchQueue.main.async { [self] in
configure(SDL_GetWindowID(view.sdlWindow))
}
return view return view
} }
@ -56,14 +56,7 @@ class VulkanSDLView: UIView {
// Create an SDL window with Metal support // Create an SDL window with Metal support
DispatchQueue.main.async { [self] in DispatchQueue.main.async { [self] in
sdlWindow = SDL_CreateWindow( sdlWindow = SDL_GetWindowFromID(1)
"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
)
} }
@ -81,11 +74,11 @@ class VulkanSDLView: UIView {
} }
} }
if let metalLayerPointer = SDL_Metal_GetLayer(metalView) { DispatchQueue.main.async { [self] in
let metalLayer = Unmanaged<CAMetalLayer>.fromOpaque(metalLayerPointer).takeUnretainedValue() if let metalLayerPointer = SDL_Metal_GetLayer(metalView) {
metalLayer.device = MTLCreateSystemDefaultDevice() let metalLayer = Unmanaged<CAMetalLayer>.fromOpaque(metalLayerPointer).takeUnretainedValue()
metalLayer.pixelFormat = .bgra8Unorm metalLayer.device = MTLCreateSystemDefaultDevice()
DispatchQueue.main.async { [self] in // metalLayer.pixelFormat = .bgra8Unorm
layer.addSublayer(metalLayer) layer.addSublayer(metalLayer)
} }
} }

View File

@ -185,10 +185,10 @@ namespace Ryujinx.Headless.SDL2
FullscreenFlag = SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP; 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}\""); 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) 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. // As we don't need this to fire in either case we can test for fullscreen.
if (!IsFullscreen && !IsExclusiveFullscreen) if (!IsFullscreen && !IsExclusiveFullscreen)
{ {
// Width = evnt.window.data1; Width = evnt.window.data1;
// Height = evnt.window.data2; Height = evnt.window.data2;
// Renderer?.Window.SetSize(Width, Height); Renderer?.Window.SetSize(Width, Height);
// MouseDriver.SetClientSize(Width, Height); // MouseDriver.SetClientSize(Width, Height);
// if (Renderer != null && Renderer.Window != null) // if (Renderer != null && Renderer.Window != null)
// { // {