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:
opulateList(), 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!
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:

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!