• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Emulator Discussion and Support › Development Discussion v
« Previous 1 ... 17 18 19 20 21 ... 111 Next »

Some Metal API-related Questions
View New Posts | View Today's Posts

Pages (2): 1 2 Next »
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
Some Metal API-related Questions
04-19-2017, 05:47 AM
#1
zachrwolfe Offline
Junior Member
**
Posts: 11
Threads: 2
Joined: Apr 2017
Hi everyone,

I'm back. Already. With what I think might be a slightly shorter novel this time. I've been having some fun stumbling my way through Dolphin's video code, and decided to try to make a rudimentary Metal backend (just as a learning exercise, don't expect anything). Regrettably, I'm currently hung up on the most basic of things: drawing to Dolphin's window using Metal.

I've copied the Null backend, renamed all necessary stuff, linked the Metal and QuartzCore frameworks (unless that one was already linked, I can't remember), added a Metal entry to the APIList enum, added an instance of the backend to the g_available_video_backends vector in VideoBackendBase:TongueopulateList(), and then selected it in the UI.

From what I've gathered, it seems the recommended (or only) way to get realtime graphics on the screen with Metal is through a CAMetalLayer, either with a layer-backed view or a layer-hosted view. I have tried a number of ways to achieve this goal in Dolphin which I won't bore you all with the details of, but the most successful I've been so far is by directly creating a CAMetalLayer and passing it to Dolphin's window_handle (by reinterpret_cast-ing the handle to an NSView), then setting wantsLayer to true in VideoBackend::Initialize(). Also in Initialize(), I wrote some test code to draw a single triangle to the texture contained in the CAMetalLayer, which brings me to the "successful" part of this exercise. Although the screen is still plain black, I know that the Metal code is solid because when I stop emulation, I see the triangle perfectly rendered for a split second before the window gets destroyed/hidden.

So, anyone know what's going on? I've tried really hard to figure out the solution on my own, but I think I just need to be pointed in the right direction and I'll be off to the races.

Thanks again!
Find
Reply
04-19-2017, 03:50 PM
#2
degasus Offline
Developer
**********
Developers (Some Administrators and Super Moderators)
Posts: 1,828
Threads: 10
Joined: May 2012
I can't help with OSX plattform dependent code, but feel free to ignore dolphin's window handle and to just create a new window. This might be better for the thread localiness, as the window is created on another thread as the context, and we're using this context on another thread again ...
Find
Reply
04-20-2017, 06:12 AM
#3
zachrwolfe Offline
Junior Member
**
Posts: 11
Threads: 2
Joined: Apr 2017
(04-19-2017, 03:50 PM)degasus Wrote: I can't help with OSX plattform dependent code, but feel free to ignore dolphin's window handle and to just create a new window. This might be better for the thread localiness, as the window is created on another thread as the context, and we're using this context on another thread again ...

Thanks, degasus. I tried your idea of creating my own window, and it led to an interesting discovery - the window did not show up until stopping the emulation, at which point it stayed open until the app closes (well that part isn't interesting; I just hadn't destroyed the window yet). Moving the window creation code to Video_Prepare did the same thing. Printing to cout revealed both methods were being called at the correct times, though. So I was incredibly confused.

An hour of googling and testing stuff later, turns out macOS can sometimes be very particular about which thread you run UI code in. So, I tried running the code in the main thread and voila! It worked! Big Grin

And even better, my original code to render directly into dolphin's window handle also works perfectly when I run it on the main thread. Go freaking figure.

Thanks again degasus. You definitely helped point me in the right direction. I'm amazed at the dedication of the dolphin dev community.
Find
Reply
04-20-2017, 07:43 AM
#4
seoulgamer Offline
Junior Member
**
Posts: 38
Threads: 5
Joined: Sep 2015
I no longer use a Mac, but I used to have one as my daily machine. I can tell you that Mac owners will be immensely grateful if your Metal backend becomes useable. macOS is currently restricted to openGL 4.1/4.2 and performance isn't as good as it could be. Not to mention that newer Macs use AMD GPUs which have very poor openGL performance.

My apologies for not being able to offer anything more than encouragement, but good luck all the same!
Find
Reply
04-20-2017, 08:10 AM
#5
zachrwolfe Offline
Junior Member
**
Posts: 11
Threads: 2
Joined: Apr 2017
(04-20-2017, 07:43 AM)seoulgamer Wrote: I no longer use a Mac, but I used to have one as my daily machine. I can tell you that Mac owners will be immensely grateful if your Metal backend becomes useable. macOS is currently restricted to openGL 4.1/4.2 and performance isn't as good as it could be. Not to mention that newer Macs use AMD GPUs which have very poor openGL performance.

My apologies for not being able to offer anything more than encouragement, but good luck all the same!

Thanks seoulgamer! I'm actually not even the target market for this type of thing either as although I use Macs daily for all of my work stuff, my main PC is a hackintosh I dualboot Windows on, so at any point I can switch to Windows within minutes and just use Vulkan if I so desire to play GC/Wii games. It'll be fun (if I ever get anywhere) to see if my Metal backend can get close to Vulkan's performance on Windows on the same hardware. Smile
Find
Reply
05-20-2017, 08:19 AM
#6
mstreurman Offline
Above and Beyond
*******
Posts: 1,243
Threads: 11
Joined: Nov 2015
I'm very curious if this is still in the works, since I have a few friends with Mac's that are dying to try out a few of their old GC games on their machine without having to worry about buggy OpenGL
Check my profile for up to date specs.
Find
Reply
05-20-2017, 08:37 AM
#7
KHg8m3r Offline
Doesn't sleep, just Dolphin and Robots
*******
Posts: 5,687
Threads: 4
Joined: Sep 2013
OpenGL isn't buggy, it's that Apple doesn't support the new versions so Dolphin has to use the slower, older OpenGL commands or even off-load some things to the CPU to render, making it slower.
All-in-all though, the games should run fine assuming they can run the games at 100%
Find
Reply
05-20-2017, 08:55 AM
#8
zachrwolfe Offline
Junior Member
**
Posts: 11
Threads: 2
Joined: Apr 2017
(05-20-2017, 08:19 AM)mstreurman Wrote: I'm very curious if this is still in the works, since I have a few friends with Mac's that are dying to try out a few of their old GC games on their machine without having to worry about buggy OpenGL
Still inching away at it when I have time. Smile Extremely little progress so far, though. Been spending most of my time reading code from the other backends and VideoCommon. Tell your friends to hold out a few years or use OGL, lol
Find
Reply
06-02-2017, 05:00 AM
#9
ddnava Offline
Junior Member
**
Posts: 16
Threads: 2
Joined: Jan 2016
(05-20-2017, 08:55 AM)zachrwolfe Wrote: Tell your friends to hold out a few years or use OGL, lol


It would be amazing if you complete the Metal backend
I'm a Mac user (And although I can boot on Windows, my main SO is MacOS) and the Mac version of Dolphin hasn't received love in the recent years. Having this backend will for sure revive it. As it is now, most Mac users install Windows to use Dolphin as it performs really bad on MacOS, so not even Mac users (like me) give it any love. Having a competent backend on MacOS will make it finally usable
Find
Reply
06-02-2017, 07:12 AM
#10
degasus Offline
Developer
**********
Developers (Some Administrators and Super Moderators)
Posts: 1,828
Threads: 10
Joined: May 2012
(06-02-2017, 05:00 AM)ddnava Wrote: so not even Mac users (like me) give it any love
Feel free to just help him: https://github.com/zachrwolfe/dolphin/tree/master/Source/Core/VideoBackends/Metal
Find
Reply
« Next Oldest | Next Newest »
Pages (2): 1 2 Next »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma

Linear Mode
Threaded Mode