0001: //-----------------------------------------------------------------------------
0002: // File: D3DEnumeration.h
0003: //
0004: // Desc: Enumerates D3D adapters, devices, modes, etc.
0005: //-----------------------------------------------------------------------------
0006: 
0007: #ifndef D3DENUM_H
0008: #define D3DENUM_H
0009: 
0010: //-----------------------------------------------------------------------------
0011: // Name: enum VertexProcessingType
0012: // Desc: Enumeration of all possible D3D vertex processing types.
0013: //-----------------------------------------------------------------------------
0014: enum VertexProcessingType
0015: {
0016:     SOFTWARE_VP,
0017:     MIXED_VP,
0018:     HARDWARE_VP,
0019:     PURE_HARDWARE_VP
0020: };
0021: 
0022: 
0023: //-----------------------------------------------------------------------------
0024: // Name: struct D3DAdapterInfo
0025: // Desc: Info about a display adapter.
0026: //-----------------------------------------------------------------------------
0027: struct D3DAdapterInfo
0028: {
0029:     int AdapterOrdinal;
0030:     D3DADAPTER_IDENTIFIER9 AdapterIdentifier;
0031:     CArrayList* pDisplayModeList; // List of D3DDISPLAYMODEs
0032:     CArrayList* pDeviceInfoList; // List of D3DDeviceInfo pointers
0033:     ~D3DAdapterInfo( void );
0034: };
0035: 
0036: 
0037: //-----------------------------------------------------------------------------
0038: // Name: struct D3DDeviceInfo
0039: // Desc: Info about a D3D device, including a list of D3DDeviceCombos (see below) 
0040: //       that work with the device.
0041: //-----------------------------------------------------------------------------
0042: struct D3DDeviceInfo
0043: {
0044:     int AdapterOrdinal;
0045:     D3DDEVTYPE DevType;
0046:     D3DCAPS9 Caps;
0047:     CArrayList* pDeviceComboList; // List of D3DDeviceCombo pointers
0048:     ~D3DDeviceInfo( void );
0049: };
0050: 
0051: 
0052: //-----------------------------------------------------------------------------
0053: // Name: struct D3DDSMSConflict
0054: // Desc: A depth/stencil buffer format that is incompatible with a
0055: //       multisample type.
0056: //-----------------------------------------------------------------------------
0057: struct D3DDSMSConflict
0058: {
0059:     D3DFORMAT DSFormat;
0060:     D3DMULTISAMPLE_TYPE MSType;
0061: };
0062: 
0063: 
0064: //-----------------------------------------------------------------------------
0065: // Name: struct D3DDeviceCombo
0066: // Desc: A combination of adapter format, back buffer format, and windowed/fullscreen 
0067: //       that is compatible with a particular D3D device (and the app).
0068: //-----------------------------------------------------------------------------
0069: struct D3DDeviceCombo
0070: {
0071:     int AdapterOrdinal;
0072:     D3DDEVTYPE DevType;
0073:     D3DFORMAT AdapterFormat;
0074:     D3DFORMAT BackBufferFormat;
0075:     bool IsWindowed;
0076:     CArrayList* pDepthStencilFormatList; // List of D3DFORMATs
0077:     CArrayList* pMultiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
0078:     CArrayList* pMultiSampleQualityList; // List of DWORDs (number of quality 
0079:                                          // levels for each multisample type)
0080:     CArrayList* pDSMSConflictList; // List of D3DDSMSConflicts
0081:     CArrayList* pVertexProcessingTypeList; // List of VertexProcessingTypes
0082:     CArrayList* pPresentIntervalList; // List of D3DPRESENT_INTERVALs
0083: 
0084:     ~D3DDeviceCombo( void );
0085: };
0086: 
0087: 
0088: typedef bool(* CONFIRMDEVICECALLBACK)( D3DCAPS9* pCaps, 
0089:     VertexProcessingType vertexProcessingType, D3DFORMAT backBufferFormat );
0090: 
0091: 
0092: //-----------------------------------------------------------------------------
0093: // Name: class CD3DEnumeration
0094: // Desc: Enumerates available D3D adapters, devices, modes, etc.
0095: //-----------------------------------------------------------------------------
0096: class CD3DEnumeration
0097: {
0098: private:
0099:     IDirect3D9* m_pD3D;
0100: 
0101: private:
0102:     HRESULT EnumerateDevices( D3DAdapterInfo* pAdapterInfo, CArrayList* pAdapterFormatList );
0103:     HRESULT EnumerateDeviceCombos( D3DDeviceInfo* pDeviceInfo, CArrayList* pAdapterFormatList );
0104:     void BuildDepthStencilFormatList( D3DDeviceCombo* pDeviceCombo );
0105:     void BuildMultiSampleTypeList( D3DDeviceCombo* pDeviceCombo );
0106:     void BuildDSMSConflictList( D3DDeviceCombo* pDeviceCombo );
0107:     void BuildVertexProcessingTypeList( D3DDeviceInfo* pDeviceInfo, D3DDeviceCombo* pDeviceCombo );
0108:     void BuildPresentIntervalList( D3DDeviceInfo* pDeviceInfo, D3DDeviceCombo* pDeviceCombo );
0109: 
0110: public:
0111:     CArrayList* m_pAdapterInfoList;
0112:     // The following variables can be used to limit what modes, formats, 
0113:     // etc. are enumerated.  Set them to the values you want before calling
0114:     // Enumerate().
0115:     CONFIRMDEVICECALLBACK ConfirmDeviceCallback;
0116:     UINT AppMinFullscreenWidth;
0117:     UINT AppMinFullscreenHeight;
0118:     UINT AppMinColorChannelBits; // min color bits per channel in adapter format
0119:     UINT AppMinAlphaChannelBits; // min alpha bits per pixel in back buffer format
0120:     UINT AppMinDepthBits;
0121:     UINT AppMinStencilBits;
0122:     bool AppUsesDepthBuffer;
0123:     bool AppUsesMixedVP; // whether app can take advantage of mixed vp mode
0124:     bool AppRequiresWindowed;
0125:     bool AppRequiresFullscreen;
0126:     CArrayList* m_pAllowedAdapterFormatList; // list of D3DFORMATs
0127: 
0128:     CD3DEnumeration();
0129:     ~CD3DEnumeration();
0130:     void SetD3D(IDirect3D9* pD3D) { m_pD3D = pD3D; }
0131:     HRESULT Enumerate();
0132: };
0133: 
0134: #endif
0135: