platformVideoInfo.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. {
  44. // Not all platforms may support PVI_NumAdapters. We will assume that there
  45. // is one adapter. This was the behavior before PVI_NumAdapters was implemented.
  46. mAdapters.increment( 1 );
  47. }
  48. else
  49. {
  50. mAdapters.increment( dAtoi( tempString ) );
  51. }
  52. U32 adapterNum = 0;
  53. for( Vector<PVIAdapter>::iterator itr = mAdapters.begin(); itr != mAdapters.end(); itr++ )
  54. {
  55. PVIAdapter &adapter = *itr;
  56. U32 querySuccessFlags = U32_MAX;
  57. AssertFatal( PVI_QueryCount < sizeof( querySuccessFlags ) * 8, "Not enough bits in query success mask." );
  58. querySuccessFlags -= ( ( 1 << PVI_QueryCount ) - 1 );
  59. // Fill in adapter information
  60. #define _QUERY_MASK_HELPER( querytype, outstringaddr ) \
  61. querySuccessFlags |= ( _queryProperty( querytype, adapterNum, outstringaddr ) ? 1 << querytype : 0 )
  62. _QUERY_MASK_HELPER( PVI_NumDevices, &tempString );
  63. adapter.numDevices = dAtoi( tempString );
  64. _QUERY_MASK_HELPER( PVI_VRAM, &tempString );
  65. adapter.vram = dAtoi( tempString );
  66. _QUERY_MASK_HELPER( PVI_Description, &adapter.description );
  67. _QUERY_MASK_HELPER( PVI_Name, &adapter.name );
  68. _QUERY_MASK_HELPER( PVI_ChipSet, &adapter.chipSet );
  69. _QUERY_MASK_HELPER( PVI_DriverVersion, &adapter.driverVersion );
  70. #undef _QUERY_MASK_HELPER
  71. // Test flags here for success
  72. ++adapterNum;
  73. }
  74. return true;
  75. }
  76. //------------------------------------------------------------------------------
  77. const PlatformVideoInfo::PVIAdapter &PlatformVideoInfo::getAdapterInformation( const U32 adapterIndex ) const
  78. {
  79. AssertFatal( adapterIndex < mAdapters.size(), "Not that many adapters" );
  80. return mAdapters[adapterIndex];
  81. }