Merge pull request #420 from mlfarrell/bugfix/default-device-graphics-switching-macos
If user requests system default device curing vkCreateDevice, call …
This commit is contained in:
commit
a01b99514e
@ -243,7 +243,9 @@ public:
|
||||
|
||||
/** Returns the underlying Metal device. */
|
||||
inline id<MTLDevice> getMTLDevice() { return _mtlDevice; }
|
||||
|
||||
|
||||
/*** Replaces the underlying Metal device .*/
|
||||
inline void replaceMTLDevice(id<MTLDevice> mtlDevice) { [_mtlDevice autorelease]; _mtlDevice = [mtlDevice retain]; }
|
||||
|
||||
#pragma mark Construction
|
||||
|
||||
|
@ -1761,6 +1761,20 @@ uint32_t MVKDevice::expandVisibilityResultMTLBuffer(uint32_t queryCount) {
|
||||
MVKDevice::MVKDevice(MVKPhysicalDevice* physicalDevice, const VkDeviceCreateInfo* pCreateInfo) {
|
||||
|
||||
initPerformanceTracking();
|
||||
|
||||
#if MVK_MACOS
|
||||
//on mac OS, the wrong GPU will drive the screen (graphics switching will not occur)
|
||||
//unless we call this specific MTLCreateSystemDefaultDevice method to create the metal device
|
||||
id<MTLDevice> device = physicalDevice->getMTLDevice();
|
||||
if (!device.headless && !device.lowPower) {
|
||||
id<MTLDevice> sysDefaultDevice = MTLCreateSystemDefaultDevice();
|
||||
|
||||
//lets be 100% sure this is the device the user asked for
|
||||
if (sysDefaultDevice.registryID == device.registryID) {
|
||||
physicalDevice->replaceMTLDevice(sysDefaultDevice);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
_physicalDevice = physicalDevice;
|
||||
_pMVKConfig = _physicalDevice->_mvkInstance->getMoltenVKConfiguration();
|
||||
|
Loading…
x
Reference in New Issue
Block a user