On a dynamic switching capable Mac, calling MTLCreateSystemDefaultDevice() in a Metal app is supposed to return the discrete GPU and have the system switch the display to being driven by the discrete GPU. As explained in the comment in MTLDevice.h above that method:
"On Mac OS X systems that support automatic graphics switching, calling this API to get a Metal device will cause the system to switch to the high power GPU. On other systems that support more than one GPU it will return the GPU that is associated with the main display."
However on my application I am not seeing this occur anymore. I've tested the app on a Catalina partition on the exact same machine and verified it would work properly on 10.15.7 but on any build of Big Sur I have tried so far, it hasn't worked.
I even tested this functionality using one of Apple's demo apps (can find it by searching for "Using Metal to Draw a View's Contents"). It is a very simple app that just draws a blue screen but when ran on Catalina, I verified that dynamic switching was occurring properly (Activity Monitor's energy section will list the app with a Yes in the Graphics Card column specifying that it requires a High Performance GPU). For an app running via Xcode, it will change Xcode to have a Yes in the Graphics Card column. Running the exact same demo on Big Sur no longer triggers that change.
Note: You have to make sure you are using a machine with the Automatic Graphics Switching option enabled in the battery settings of System Preferences and you can't be connected to an external display (this will force the system to use the discrete gpu).
Has anyone else seen this issue? And if so, has anyone managed to fix it? I wasn't able to find any mention of a new api or an api change that is needed for this. I have also tried using NSSupportsAutomaticGraphicsSwitching in the Info.plist of the app set to both YES or NO, just in case maybe the api was updated to listen to that flag for Metal, but it had no effect.
I have submitted a ticket for this using the Feedback Assistant app, but I wanted to see if any other developers have been having this issue as well or have found a solution.