source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/Standalone/Explosion [DirectX]/Common/DXUTenum.h @ 3255

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