Here is the answer by Calamity :
I think that for the specific task you’re requesting this feature (basically being able to perform resolution switching within a game for PSX and such platforms) there’s really no point in incorporating SwitchRes into RetroArch. As Hunterk is explaining it is a better idea to just assume that the modelines are already available to RetroArch in the first place.
So let’s consider the scenario where you have properly configured a system with two modelines such as 2560x240@60 and 2560x480i@60 (which is trivial to achieve in both Windows & Linux).
What you want the emulator to do is to be able to dynamically switch between both modelines, depending on the vertical resolution requested by the emulated hardware.
Without having the minimal knowledge of the internal details of RA, dynamic resolution switching may involve some refactoring of the DirectX full screen implementation. Basically you need to destroy the current device and create it again with the new resolution, with all the additional caution required if you’re running several threads for the video.
You also need to implement some logic for best mode picking, in case it’s not already included. This logic could operate on the whole mode list returned by the OS, or simply on an user defined mode list. I believe that like most emulators, RA only allows to specify a single resolution for full screen mode, by using the video_fullscreen_x & video_fullscreen_y options, so specifying an user mode list would involve implementing an array of these options.
A solution for not implementing that array would be using “resolution masks”, like this:
video_fullscreen_x = 2560
video_fullscreen_y = 0
Here “0” would be used like a wildcard. If “0” is already used to indicate the desktop resolution, another value could be used (“1”, or whatever).
Then, when the emulator detects a resolution switch request, it would decide which from the list of 2560x resolutions better fits the requested height.
As a note: a proper full screen configuration for any emulator should contain 3 values, not 2:
video_fullscreen_x = ?
video_fullscreen_y = ?
video_fullscreen_refresh = ?
That’s the only way to unambiguously target a certain video mode in the Windows OS.
Finally, answering Hunterk’s question, SwitchRes supports any emulator provided it takes command line options, it just launches the emulator with the specified options and performs a mode switch previously if specified, this is useful for emulators that are only capable of running at the desktop resolution. My understanding is that if the above or something similar was implemented then launching the games with SwitchRes wouldn’t be necessary.