platformVideoInfo.cpp 3.4 KB

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