Merge branch 'master' into master

This commit is contained in:
aerofly 2018-12-22 21:39:54 +01:00 committed by GitHub
commit 2fdee5c2e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -243,7 +243,7 @@ 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]; }

View File

@ -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
#if MVK_MACOS
//on mac OS, the wrong GPU will drive the screen (graphics switching will not occur)