DXUTenum.h
上传用户:junlon
上传日期:2022-01-05
资源大小:39075k
文件大小:8k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. //--------------------------------------------------------------------------------------
  2. // File: DXUTEnum.h
  3. //
  4. // Enumerates D3D adapters, devices, modes, etc.
  5. //
  6. // Copyright (c) Microsoft Corporation. All rights reserved.
  7. //--------------------------------------------------------------------------------------
  8. #pragma once
  9. #ifndef DXUT_ENUM_H
  10. #define DXUT_ENUM_H
  11. //--------------------------------------------------------------------------------------
  12. // Forward declarations
  13. //--------------------------------------------------------------------------------------
  14. class CD3DEnumAdapterInfo;
  15. class CD3DEnumDeviceInfo;
  16. struct CD3DEnumDeviceSettingsCombo;
  17. struct CD3DEnumDSMSConflict;
  18. //--------------------------------------------------------------------------------------
  19. // Enumerates available Direct3D adapters, devices, modes, etc.
  20. // Use DXUTGetEnumeration() to access global instance
  21. //--------------------------------------------------------------------------------------
  22. class CD3DEnumeration
  23. {
  24. public:
  25.     // These should be called before Enumerate(). 
  26.     //
  27.     // Use these calls and the IsDeviceAcceptable to control the contents of 
  28.     // the enumeration object, which affects the device selection and the device settings dialog.
  29.     void SetRequirePostPixelShaderBlending( bool bRequire ) { m_bRequirePostPixelShaderBlending = bRequire; }
  30.     void SetResolutionMinMax( UINT nMinWidth, UINT nMinHeight, UINT nMaxWidth, UINT nMaxHeight );  
  31.     void SetRefreshMinMax( UINT nMin, UINT nMax );
  32.     void SetMultisampleQualityMax( UINT nMax );    
  33.     void GetPossibleVertexProcessingList( bool* pbSoftwareVP, bool* pbHardwareVP, bool* pbPureHarewareVP, bool* pbMixedVP );
  34.     void SetPossibleVertexProcessingList( bool bSoftwareVP, bool bHardwareVP, bool bPureHarewareVP, bool bMixedVP );
  35.     CGrowableArray<D3DFORMAT>* GetPossibleDepthStencilFormatList();   
  36.     CGrowableArray<D3DMULTISAMPLE_TYPE>* GetPossibleMultisampleTypeList();   
  37.     CGrowableArray<UINT>* GetPossiblePresentIntervalList();
  38.     void ResetPossibleDepthStencilFormats();
  39.     void ResetPossibleMultisampleTypeList();
  40.     void ResetPossiblePresentIntervalList();
  41.     // Call Enumerate() to enumerate available D3D adapters, devices, modes, etc.
  42.     HRESULT Enumerate( IDirect3D9* pD3D = NULL,
  43.                        LPDXUTCALLBACKISDEVICEACCEPTABLE IsDeviceAcceptableFunc = NULL,
  44.                        void* pIsDeviceAcceptableFuncUserContext = NULL );
  45.     // These should be called after Enumerate() is called
  46.     CGrowableArray<CD3DEnumAdapterInfo*>*   GetAdapterInfoList();  
  47.     CD3DEnumAdapterInfo*                    GetAdapterInfo( UINT AdapterOrdinal );  
  48.     CD3DEnumDeviceInfo*                     GetDeviceInfo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType );    
  49.     CD3DEnumDeviceSettingsCombo*            GetDeviceSettingsCombo( DXUTDeviceSettings* pDeviceSettings ) { return GetDeviceSettingsCombo( pDeviceSettings->AdapterOrdinal, pDeviceSettings->DeviceType, pDeviceSettings->AdapterFormat, pDeviceSettings->pp.BackBufferFormat, pDeviceSettings->pp.Windowed ); }
  50.     CD3DEnumDeviceSettingsCombo*            GetDeviceSettingsCombo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL Windowed );  
  51.     ~CD3DEnumeration();
  52. private:
  53.     friend CD3DEnumeration* DXUTGetEnumeration(); 
  54.     // Use DXUTGetEnumeration() to access global instance
  55.     CD3DEnumeration();
  56.     IDirect3D9* m_pD3D;                                    
  57.     LPDXUTCALLBACKISDEVICEACCEPTABLE m_IsDeviceAcceptableFunc;
  58.     void* m_pIsDeviceAcceptableFuncUserContext;
  59.     bool m_bRequirePostPixelShaderBlending;
  60.     CGrowableArray<D3DFORMAT> m_DepthStecilPossibleList;
  61.     CGrowableArray<D3DMULTISAMPLE_TYPE> m_MultiSampleTypeList;
  62.     CGrowableArray<UINT> m_PresentIntervalList;
  63.     bool m_bSoftwareVP;
  64.     bool m_bHardwareVP;
  65.     bool m_bPureHarewareVP;
  66.     bool m_bMixedVP;
  67.     UINT m_nMinWidth;
  68.     UINT m_nMaxWidth;
  69.     UINT m_nMinHeight;
  70.     UINT m_nMaxHeight;
  71.     UINT m_nRefreshMin;
  72.     UINT m_nRefreshMax;
  73.     UINT m_nMultisampleQualityMax;
  74.     // Array of CD3DEnumAdapterInfo* with unique AdapterOrdinals
  75.     CGrowableArray<CD3DEnumAdapterInfo*> m_AdapterInfoList;  
  76.     HRESULT EnumerateDevices( CD3DEnumAdapterInfo* pAdapterInfo, CGrowableArray<D3DFORMAT>* pAdapterFormatList );
  77.     HRESULT EnumerateDeviceCombos( CD3DEnumAdapterInfo* pAdapterInfo, CD3DEnumDeviceInfo* pDeviceInfo, CGrowableArray<D3DFORMAT>* pAdapterFormatList );
  78.     void BuildDepthStencilFormatList( CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  79.     void BuildMultiSampleTypeList( CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  80.     void BuildDSMSConflictList( CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  81.     void BuildPresentIntervalList( CD3DEnumDeviceInfo* pDeviceInfo, CD3DEnumDeviceSettingsCombo* pDeviceCombo );
  82.     void ClearAdapterInfoList();
  83. };
  84. CD3DEnumeration* DXUTGetEnumeration(); 
  85. //--------------------------------------------------------------------------------------
  86. // A class describing an adapter which contains a unique adapter ordinal 
  87. // that is installed on the system
  88. //--------------------------------------------------------------------------------------
  89. class CD3DEnumAdapterInfo
  90. {
  91. public:
  92.     ~CD3DEnumAdapterInfo();
  93.     UINT AdapterOrdinal;
  94.     D3DADAPTER_IDENTIFIER9 AdapterIdentifier;
  95.     WCHAR szUniqueDescription[256];
  96.     CGrowableArray<D3DDISPLAYMODE> displayModeList; // Array of supported D3DDISPLAYMODEs
  97.     CGrowableArray<CD3DEnumDeviceInfo*> deviceInfoList; // Array of CD3DEnumDeviceInfo* with unique supported DeviceTypes
  98. };
  99. //--------------------------------------------------------------------------------------
  100. // A class describing a Direct3D device that contains a 
  101. //       unique supported device type 
  102. //--------------------------------------------------------------------------------------
  103. class CD3DEnumDeviceInfo
  104. {
  105. public:
  106.     ~CD3DEnumDeviceInfo();
  107.     UINT AdapterOrdinal;
  108.     D3DDEVTYPE DeviceType;
  109.     D3DCAPS9 Caps;
  110.     // List of CD3DEnumDeviceSettingsCombo* with a unique set 
  111.     // of AdapterFormat, BackBufferFormat, and Windowed
  112.     CGrowableArray<CD3DEnumDeviceSettingsCombo*> deviceSettingsComboList; 
  113. };
  114. //--------------------------------------------------------------------------------------
  115. // A struct describing device settings that contains a unique combination of 
  116. // adapter format, back buffer format, and windowed that is compatible with a 
  117. // particular Direct3D device and the app.
  118. //--------------------------------------------------------------------------------------
  119. struct CD3DEnumDeviceSettingsCombo
  120. {
  121.     UINT AdapterOrdinal;
  122.     D3DDEVTYPE DeviceType;
  123.     D3DFORMAT AdapterFormat;
  124.     D3DFORMAT BackBufferFormat;
  125.     BOOL Windowed;
  126.     CGrowableArray<D3DFORMAT> depthStencilFormatList; // List of D3DFORMATs
  127.     CGrowableArray<D3DMULTISAMPLE_TYPE> multiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
  128.     CGrowableArray<DWORD> multiSampleQualityList; // List of number of quality levels for each multisample type
  129.     CGrowableArray<UINT> presentIntervalList; // List of D3DPRESENT flags
  130.     CGrowableArray<CD3DEnumDSMSConflict> DSMSConflictList; // List of CD3DEnumDSMSConflict
  131.     CD3DEnumAdapterInfo* pAdapterInfo;
  132.     CD3DEnumDeviceInfo* pDeviceInfo;
  133. };
  134. //--------------------------------------------------------------------------------------
  135. // A depth/stencil buffer format that is incompatible with a
  136. // multisample type.
  137. //--------------------------------------------------------------------------------------
  138. struct CD3DEnumDSMSConflict
  139. {
  140.     D3DFORMAT DSFormat;
  141.     D3DMULTISAMPLE_TYPE MSType;
  142. };
  143. #endif