|
GPU-SD
1.0.0
|
00001 00002 /* Copyright (c) 2011, Stefan Eilemann <eile@eyescale.ch> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #include "module.h" 00019 00020 #include <gpusd/gpuInfo.h> 00021 00022 //#include <AGL/agl.h> 00023 #include <Carbon/Carbon.h> 00024 00025 #include <deque> 00026 00027 #define MAX_GPUS 32 00028 00029 namespace gpusd 00030 { 00031 namespace cgl 00032 { 00033 namespace 00034 { 00035 Module* instance = 0; 00036 } 00037 00038 void Module::use() 00039 { 00040 if( !instance ) 00041 instance = new Module; 00042 } 00043 00044 GPUInfos Module::discoverGPUs_() const 00045 { 00046 GPUInfos result; 00047 CGDirectDisplayID displayIDs[MAX_GPUS]; 00048 CGDisplayCount nDisplays = 0; 00049 00050 if( CGGetOnlineDisplayList( MAX_GPUS, displayIDs, &nDisplays ) != 00051 kCGErrorSuccess ) 00052 { 00053 return result; 00054 } 00055 00056 const CGDirectDisplayID mainDisplayID = CGMainDisplayID(); 00057 std::deque< GPUInfo > infos; 00058 for( CGDisplayCount i = 0; i < nDisplays; ++i ) 00059 { 00060 GPUInfo info( "CGL" ); 00061 const CGRect displayRect = CGDisplayBounds( displayIDs[i] ); 00062 00063 info.device = i; 00064 info.pvp[0] = int32_t(displayRect.origin.x); 00065 info.pvp[1] = int32_t(displayRect.origin.y); 00066 info.pvp[2] = int32_t(displayRect.size.width); 00067 info.pvp[3] = int32_t(displayRect.size.height); 00068 00069 if( mainDisplayID == displayIDs[i] ) 00070 infos.push_front( info ); 00071 else 00072 infos.push_back( info ); 00073 } 00074 00075 result.resize( infos.size( )); 00076 std::copy( infos.begin(), infos.end(), result.begin( )); 00077 return result; 00078 } 00079 00080 } 00081 } 00082
1.0.0 by
1.7.5.1