platformVideoInfo.cpp
Engine/source/platform/platformVideoInfo.cpp
Public Defines
define
_QUERY_MASK_HELPER(querytype, outstringaddr) querySuccessFlags |= ( _queryProperty( querytype, adapterNum, outstringaddr ) ? 1 << querytype : 0 )
Detailed Description
Public Defines
_QUERY_MASK_HELPER(querytype, outstringaddr) querySuccessFlags |= ( _queryProperty( querytype, adapterNum, outstringaddr ) ? 1 << querytype : 0 )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "platform/platformVideoInfo.h" 25#include "core/strings/stringFunctions.h" 26 27//------------------------------------------------------------------------------ 28 29PlatformVideoInfo::PlatformVideoInfo() 30{ 31 VECTOR_SET_ASSOCIATION( mAdapters ); 32} 33 34//------------------------------------------------------------------------------ 35 36PlatformVideoInfo::~PlatformVideoInfo() 37{ 38 39} 40 41//------------------------------------------------------------------------------ 42 43 44bool PlatformVideoInfo::profileAdapters() 45{ 46 // Initialize the child class 47 if( !_initialize() ) 48 return false; 49 50 mAdapters.clear(); 51 52 // Query the number of adapters 53 String tempString; 54 55 if( !_queryProperty( PVI_NumAdapters, 0, &tempString ) ) 56 { 57 // Not all platforms may support PVI_NumAdapters. We will assume that there 58 // is one adapter. This was the behavior before PVI_NumAdapters was implemented. 59 mAdapters.increment( 1 ); 60 } 61 else 62 { 63 mAdapters.increment( dAtoi( tempString ) ); 64 } 65 66 U32 adapterNum = 0; 67 for( Vector<PVIAdapter>::iterator itr = mAdapters.begin(); itr != mAdapters.end(); itr++ ) 68 { 69 PVIAdapter &adapter = *itr; 70 71 72 U32 querySuccessFlags = U32_MAX; 73 AssertFatal( PVI_QueryCount < sizeof( querySuccessFlags ) * 8, "Not enough bits in query success mask." ); 74 querySuccessFlags -= ( ( 1 << PVI_QueryCount ) - 1 ); 75 76 // Fill in adapter information 77#define _QUERY_MASK_HELPER( querytype, outstringaddr ) \ 78 querySuccessFlags |= ( _queryProperty( querytype, adapterNum, outstringaddr ) ? 1 << querytype : 0 ) 79 80 _QUERY_MASK_HELPER( PVI_NumDevices, &tempString ); 81 adapter.numDevices = dAtoi( tempString ); 82 83 _QUERY_MASK_HELPER( PVI_VRAM, &tempString ); 84 adapter.vram = dAtoi( tempString ); 85 86 _QUERY_MASK_HELPER( PVI_Description, &adapter.description ); 87 _QUERY_MASK_HELPER( PVI_Name, &adapter.name ); 88 _QUERY_MASK_HELPER( PVI_ChipSet, &adapter.chipSet ); 89 _QUERY_MASK_HELPER( PVI_DriverVersion, &adapter.driverVersion ); 90 91#undef _QUERY_MASK_HELPER 92 93 // Test flags here for success 94 95 ++adapterNum; 96 } 97 98 return true; 99} 100 101//------------------------------------------------------------------------------ 102 103const PlatformVideoInfo::PVIAdapter &PlatformVideoInfo::getAdapterInformation( const U32 adapterIndex ) const 104{ 105 AssertFatal( adapterIndex < mAdapters.size(), "Not that many adapters" ); 106 return mAdapters[adapterIndex]; 107} 108