I don't think the call to CGLSetVirtualScreen is actually needed to get the GPU to switch. That was found necessary a while ago for best performance, but according to a tool like gfxCardStatus, the thing which actually causes the discrete GPU to activate is the allocation of a CGLPixelFormatObj which says that it doesn't support offline renderers, thereby activating the discrete GPU.
CGDisplayRegisterReconfigurationCallback
InitializeOneOffForSandbox
InitializeOneOffForSandbox CGLChoosePixelFormat << empty CGLPixelFormatAttribute array
DisplayReconfigCallback flags=1d
DisplayReconfigCallback flags=1d
DisplayReconfigCallback flags=8476d
DisplayReconfigCallback gpu_changed=1 << switch to discrete GPU
GpuDataManagerImplPrivate::HandleGpuSwitch
GpuSwitchingManager::NotifyGpuSwitched
DisplayReconfigCallback flags=8736d
DisplayReconfigCallback gpu_changed=0
InitializeOneOffForSandbox CGLChoosePixelFormat success
DisplayReconfigCallback flags=1d
DisplayReconfigCallback flags=1d
DisplayReconfigCallback flags=8476d
DisplayReconfigCallback gpu_changed=1 << switch to integrated GPU (not sure what causes this)
GpuDataManagerImplPrivate::HandleGpuSwitch
GpuSwitchingManager::NotifyGpuSwitched
DisplayReconfigCallback flags=8736d
DisplayReconfigCallback gpu_changed=0
InitializeSwitchableGPUs << call SetSwitchableGPUsSupported
CGDisplayRegisterReconfigurationCallback
InitializeOneOffForSandbox
InitializeOneOffForSandbox CGLChoosePixelFormat << empty CGLPixelFormatAttribute array
DisplayReconfigCallback flags=1d
DisplayReconfigCallback flags=1d
DisplayReconfigCallback flags=8476d
DisplayReconfigCallback gpu_changed=1 << switch to discrete GPU
GpuDataManagerImplPrivate::HandleGpuSwitch
GpuSwitchingManager::NotifyGpuSwitched
DisplayReconfigCallback flags=8736d
DisplayReconfigCallback gpu_changed=0
InitializeOneOffForSandbox CGLChoosePixelFormat success
InitializeSwitchableGPUs << call SetSwitchableGPUsSupported
I don't know. You could try it and see if anything breaks.