1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
// This code contains NVIDIA Confidential Information and is disclosed
// under the Mutual Non-Disclosure Agreement.
//
// Notice
// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
//
// NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
// expressly authorized by NVIDIA. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright � 2008- 2013 NVIDIA Corporation. All rights reserved.
//
// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
// rights in and to this software and related documentation and any modifications thereto.
// Any use, reproduction, disclosure or distribution of this software and related
// documentation without an express license agreement from NVIDIA Corporation is
// strictly prohibited.
//
//--------------------------------------------------------------------------------------
// File: DXUTEnum.h
//
// Enumerates D3D adapters, devices, modes, etc.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#ifndef DXUT_ENUM_H
#define DXUT_ENUM_H
//--------------------------------------------------------------------------------------
// Finding valid device settings
//--------------------------------------------------------------------------------------
enum DXUT_MATCH_TYPE
{
DXUTMT_IGNORE_INPUT = 0, // Use the closest valid value to a default
DXUTMT_PRESERVE_INPUT, // Use input without change, but may cause no valid device to be found
DXUTMT_CLOSEST_TO_INPUT // Use the closest valid value to the input
};
struct DXUTMatchOptions
{
DXUT_MATCH_TYPE eAPIVersion;
DXUT_MATCH_TYPE eAdapterOrdinal;
DXUT_MATCH_TYPE eOutput;
DXUT_MATCH_TYPE eDeviceType;
DXUT_MATCH_TYPE eWindowed;
DXUT_MATCH_TYPE eAdapterFormat;
DXUT_MATCH_TYPE eVertexProcessing;
DXUT_MATCH_TYPE eResolution;
DXUT_MATCH_TYPE eBackBufferFormat;
DXUT_MATCH_TYPE eBackBufferCount;
DXUT_MATCH_TYPE eMultiSample;
DXUT_MATCH_TYPE eSwapEffect;
DXUT_MATCH_TYPE eDepthFormat;
DXUT_MATCH_TYPE eStencilFormat;
DXUT_MATCH_TYPE ePresentFlags;
DXUT_MATCH_TYPE eRefreshRate;
DXUT_MATCH_TYPE ePresentInterval;
};
HRESULT WINAPI DXUTFindValidDeviceSettings( DXUTDeviceSettings* pOut, DXUTDeviceSettings* pIn = NULL,
DXUTMatchOptions* pMatchOptions = NULL );
//--------------------------------------------------------------------------------------
// Functions to get bit depth from formats
//--------------------------------------------------------------------------------------
HRESULT WINAPI DXUTGetD3D10AdapterDisplayMode( UINT AdapterOrdinal, UINT Output, DXGI_MODE_DESC* pModeDesc ); // TODO: refactor?
UINT WINAPI DXUTGetD3D9ColorChannelBits( D3DFORMAT fmt );
UINT WINAPI DXUTGetAlphaChannelBits( D3DFORMAT fmt );
UINT WINAPI DXUTGetStencilBits( D3DFORMAT fmt );
UINT WINAPI DXUTGetDepthBits( D3DFORMAT fmt );
UINT WINAPI DXUTGetDXGIColorChannelBits( DXGI_FORMAT fmt );
//--------------------------------------------------------------------------------------
// Forward declarations
//--------------------------------------------------------------------------------------
class CD3D9EnumAdapterInfo;
class CD3D9EnumDeviceInfo;
struct CD3D9EnumDeviceSettingsCombo;
struct CD3D9EnumDSMSConflict;
//--------------------------------------------------------------------------------------
// Optional memory create/destory functions. If not call, these will be called automatically
//--------------------------------------------------------------------------------------
HRESULT WINAPI DXUTCreateD3D9Enumeration();
HRESULT WINAPI DXUTCreateD3D10Enumeration();
void WINAPI DXUTDestroyD3D9Enumeration();
void WINAPI DXUTDestroyD3D10Enumeration();
//--------------------------------------------------------------------------------------
// Enumerates available Direct3D9 adapters, devices, modes, etc.
// Use DXUTGetD3D9Enumeration() to access global instance
//--------------------------------------------------------------------------------------
class CD3D9Enumeration
{
public:
// These should be called before Enumerate().
//
// Use these calls and the IsDeviceAcceptable to control the contents of
// the enumeration object, which affects the device selection and the device settings dialog.
void SetRequirePostPixelShaderBlending( bool bRequire )
{
m_bRequirePostPixelShaderBlending = bRequire;
}
void SetResolutionMinMax( UINT nMinWidth, UINT nMinHeight, UINT nMaxWidth, UINT nMaxHeight );
void SetRefreshMinMax( UINT nMin, UINT nMax );
void SetMultisampleQualityMax( UINT nMax );
void GetPossibleVertexProcessingList( bool* pbSoftwareVP, bool* pbHardwareVP,
bool* pbPureHarewareVP, bool* pbMixedVP );
void SetPossibleVertexProcessingList( bool bSoftwareVP, bool bHardwareVP, bool bPureHarewareVP,
bool bMixedVP );
CGrowableArray <D3DFORMAT>* GetPossibleDepthStencilFormatList();
CGrowableArray <D3DMULTISAMPLE_TYPE>* GetPossibleMultisampleTypeList();
CGrowableArray <UINT>* GetPossiblePresentIntervalList();
void ResetPossibleDepthStencilFormats();
void ResetPossibleMultisampleTypeList();
void ResetPossiblePresentIntervalList();
// Call Enumerate() to enumerate available D3D adapters, devices, modes, etc.
bool HasEnumerated()
{
return m_bHasEnumerated;
}
HRESULT Enumerate( LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE IsD3D9DeviceAcceptableFunc = NULL,
void* pIsD3D9DeviceAcceptableFuncUserContext = NULL );
// These should be called after Enumerate() is called
CGrowableArray <CD3D9EnumAdapterInfo*>* GetAdapterInfoList();
CD3D9EnumAdapterInfo* GetAdapterInfo( UINT AdapterOrdinal );
CD3D9EnumDeviceInfo* GetDeviceInfo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType );
CD3D9EnumDeviceSettingsCombo* GetDeviceSettingsCombo( DXUTD3D9DeviceSettings* pD3D9DeviceSettings )
{
return GetDeviceSettingsCombo( pD3D9DeviceSettings->AdapterOrdinal, pD3D9DeviceSettings->DeviceType,
pD3D9DeviceSettings->AdapterFormat, pD3D9DeviceSettings->pp.BackBufferFormat,
pD3D9DeviceSettings->pp.Windowed );
}
CD3D9EnumDeviceSettingsCombo* GetDeviceSettingsCombo( UINT AdapterOrdinal, D3DDEVTYPE DeviceType,
D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat,
BOOL Windowed );
~CD3D9Enumeration();
private:
friend HRESULT WINAPI DXUTCreateD3D9Enumeration();
// Use DXUTGetD3D9Enumeration() to access global instance
CD3D9Enumeration();
bool m_bHasEnumerated;
IDirect3D9* m_pD3D;
LPDXUTCALLBACKISD3D9DEVICEACCEPTABLE m_IsD3D9DeviceAcceptableFunc;
void* m_pIsD3D9DeviceAcceptableFuncUserContext;
bool m_bRequirePostPixelShaderBlending;
CGrowableArray <D3DFORMAT> m_DepthStencilPossibleList;
CGrowableArray <D3DMULTISAMPLE_TYPE> m_MultiSampleTypeList;
CGrowableArray <UINT> m_PresentIntervalList;
bool m_bSoftwareVP;
bool m_bHardwareVP;
bool m_bPureHarewareVP;
bool m_bMixedVP;
UINT m_nMinWidth;
UINT m_nMaxWidth;
UINT m_nMinHeight;
UINT m_nMaxHeight;
UINT m_nRefreshMin;
UINT m_nRefreshMax;
UINT m_nMultisampleQualityMax;
// Array of CD3D9EnumAdapterInfo* with unique AdapterOrdinals
CGrowableArray <CD3D9EnumAdapterInfo*> m_AdapterInfoList;
HRESULT EnumerateDevices( CD3D9EnumAdapterInfo* pAdapterInfo,
CGrowableArray <D3DFORMAT>* pAdapterFormatList );
HRESULT EnumerateDeviceCombos( CD3D9EnumAdapterInfo* pAdapterInfo,
CD3D9EnumDeviceInfo* pDeviceInfo,
CGrowableArray <D3DFORMAT>* pAdapterFormatList );
void BuildDepthStencilFormatList( CD3D9EnumDeviceSettingsCombo* pDeviceCombo );
void BuildMultiSampleTypeList( CD3D9EnumDeviceSettingsCombo* pDeviceCombo );
void BuildDSMSConflictList( CD3D9EnumDeviceSettingsCombo* pDeviceCombo );
void BuildPresentIntervalList( CD3D9EnumDeviceInfo* pDeviceInfo,
CD3D9EnumDeviceSettingsCombo* pDeviceCombo );
void ClearAdapterInfoList();
};
CD3D9Enumeration* WINAPI DXUTGetD3D9Enumeration( bool bForceEnumerate = false );
//--------------------------------------------------------------------------------------
// A class describing an adapter which contains a unique adapter ordinal
// that is installed on the system
//--------------------------------------------------------------------------------------
class CD3D9EnumAdapterInfo
{
public:
~CD3D9EnumAdapterInfo();
UINT AdapterOrdinal;
D3DADAPTER_IDENTIFIER9 AdapterIdentifier;
WCHAR szUniqueDescription[256];
CGrowableArray <D3DDISPLAYMODE> displayModeList; // Array of supported D3DDISPLAYMODEs
CGrowableArray <CD3D9EnumDeviceInfo*> deviceInfoList; // Array of CD3D9EnumDeviceInfo* with unique supported DeviceTypes
};
//--------------------------------------------------------------------------------------
// A class describing a Direct3D device that contains a
// unique supported device type
//--------------------------------------------------------------------------------------
class CD3D9EnumDeviceInfo
{
public:
~CD3D9EnumDeviceInfo();
UINT AdapterOrdinal;
D3DDEVTYPE DeviceType;
D3DCAPS9 Caps;
// List of CD3D9EnumDeviceSettingsCombo* with a unique set
// of AdapterFormat, BackBufferFormat, and Windowed
CGrowableArray <CD3D9EnumDeviceSettingsCombo*> deviceSettingsComboList;
};
//--------------------------------------------------------------------------------------
// A struct describing device settings that contains a unique combination of
// adapter format, back buffer format, and windowed that is compatible with a
// particular Direct3D device and the app.
//--------------------------------------------------------------------------------------
struct CD3D9EnumDeviceSettingsCombo
{
UINT AdapterOrdinal;
D3DDEVTYPE DeviceType;
D3DFORMAT AdapterFormat;
D3DFORMAT BackBufferFormat;
BOOL Windowed;
CGrowableArray <D3DFORMAT> depthStencilFormatList; // List of D3DFORMATs
CGrowableArray <D3DMULTISAMPLE_TYPE> multiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
CGrowableArray <DWORD> multiSampleQualityList; // List of number of quality levels for each multisample type
CGrowableArray <UINT> presentIntervalList; // List of D3DPRESENT flags
CGrowableArray <CD3D9EnumDSMSConflict> DSMSConflictList; // List of CD3D9EnumDSMSConflict
CD3D9EnumAdapterInfo* pAdapterInfo;
CD3D9EnumDeviceInfo* pDeviceInfo;
};
//--------------------------------------------------------------------------------------
// A depth/stencil buffer format that is incompatible with a
// multisample type.
//--------------------------------------------------------------------------------------
struct CD3D9EnumDSMSConflict
{
D3DFORMAT DSFormat;
D3DMULTISAMPLE_TYPE MSType;
};
//--------------------------------------------------------------------------------------
// Forward declarations
//--------------------------------------------------------------------------------------
class CD3D10EnumAdapterInfo;
class CD3D10EnumDeviceInfo;
class CD3D10EnumOutputInfo;
struct CD3D10EnumDeviceSettingsCombo;
//--------------------------------------------------------------------------------------
// Enumerates available Direct3D10 adapters, devices, modes, etc.
// Use DXUTGetD3D9Enumeration() to access global instance
//--------------------------------------------------------------------------------------
class CD3D10Enumeration
{
public:
// These should be called before Enumerate().
//
// Use these calls and the IsDeviceAcceptable to control the contents of
// the enumeration object, which affects the device selection and the device settings dialog.
void SetResolutionMinMax( UINT nMinWidth, UINT nMinHeight, UINT nMaxWidth, UINT nMaxHeight );
void SetRefreshMinMax( UINT nMin, UINT nMax );
void SetMultisampleQualityMax( UINT nMax );
CGrowableArray <D3DFORMAT>* GetPossibleDepthStencilFormatList();
void ResetPossibleDepthStencilFormats();
void SetEnumerateAllAdapterFormats( bool bEnumerateAllAdapterFormats, bool bEnumerateNow =
true );
// Call Enumerate() to enumerate available D3D10 adapters, devices, modes, etc.
bool HasEnumerated()
{
return m_bHasEnumerated;
}
HRESULT Enumerate( LPDXUTCALLBACKISD3D10DEVICEACCEPTABLE IsD3D10DeviceAcceptableFunc,
void* pIsD3D10DeviceAcceptableFuncUserContext );
// These should be called after Enumerate() is called
CGrowableArray <CD3D10EnumAdapterInfo*>* GetAdapterInfoList();
CD3D10EnumAdapterInfo* GetAdapterInfo( UINT AdapterOrdinal );
CD3D10EnumDeviceInfo* GetDeviceInfo( UINT AdapterOrdinal, D3D10_DRIVER_TYPE DeviceType );
CD3D10EnumOutputInfo* GetOutputInfo( UINT AdapterOrdinal, UINT Output );
CD3D10EnumDeviceSettingsCombo* GetDeviceSettingsCombo( DXUTD3D10DeviceSettings* pDeviceSettings )
{
return GetDeviceSettingsCombo( pDeviceSettings->AdapterOrdinal, pDeviceSettings->DriverType,
pDeviceSettings->Output, pDeviceSettings->sd.BufferDesc.Format,
pDeviceSettings->sd.Windowed );
}
CD3D10EnumDeviceSettingsCombo* GetDeviceSettingsCombo( UINT AdapterOrdinal, D3D10_DRIVER_TYPE DeviceType,
UINT Output, DXGI_FORMAT BackBufferFormat, BOOL Windowed );
~CD3D10Enumeration();
private:
friend HRESULT WINAPI DXUTCreateD3D10Enumeration();
// Use DXUTGetD3D10Enumeration() to access global instance
CD3D10Enumeration();
bool m_bHasEnumerated;
LPDXUTCALLBACKISD3D10DEVICEACCEPTABLE m_IsD3D10DeviceAcceptableFunc;
void* m_pIsD3D10DeviceAcceptableFuncUserContext;
CGrowableArray <DXGI_FORMAT> m_DepthStencilPossibleList;
UINT m_nMinWidth;
UINT m_nMaxWidth;
UINT m_nMinHeight;
UINT m_nMaxHeight;
UINT m_nRefreshMin;
UINT m_nRefreshMax;
UINT m_nMultisampleQualityMax;
bool m_bEnumerateAllAdapterFormats;
// Array of CD3D9EnumAdapterInfo* with unique AdapterOrdinals
CGrowableArray <CD3D10EnumAdapterInfo*> m_AdapterInfoList;
HRESULT EnumerateOutputs( CD3D10EnumAdapterInfo* pAdapterInfo );
HRESULT EnumerateDevices( CD3D10EnumAdapterInfo* pAdapterInfo );
HRESULT EnumerateDeviceCombos( IDXGIFactory* pFactory, CD3D10EnumAdapterInfo* pAdapterInfo );
HRESULT EnumerateDeviceCombosNoAdapter( CD3D10EnumAdapterInfo* pAdapterInfo );
HRESULT EnumerateDisplayModes( CD3D10EnumOutputInfo* pOutputInfo );
void BuildMultiSampleQualityList( DXGI_FORMAT fmt,
CD3D10EnumDeviceSettingsCombo* pDeviceCombo );
void ClearAdapterInfoList();
};
CD3D10Enumeration* WINAPI DXUTGetD3D10Enumeration( bool bForceEnumerate = false, bool EnumerateAllAdapterFormats =
false );
#define DXGI_MAX_DEVICE_IDENTIFIER_STRING 128
//--------------------------------------------------------------------------------------
// A class describing an adapter which contains a unique adapter ordinal
// that is installed on the system
//--------------------------------------------------------------------------------------
class CD3D10EnumAdapterInfo
{
const CD3D10EnumAdapterInfo& operator =( const CD3D10EnumAdapterInfo& rhs );
public:
~CD3D10EnumAdapterInfo();
UINT AdapterOrdinal;
DXGI_ADAPTER_DESC AdapterDesc;
WCHAR szUniqueDescription[DXGI_MAX_DEVICE_IDENTIFIER_STRING];
IDXGIAdapter* m_pAdapter;
CGrowableArray <CD3D10EnumOutputInfo*> outputInfoList; // Array of CD3D10EnumOutputInfo*
CGrowableArray <CD3D10EnumDeviceInfo*> deviceInfoList; // Array of CD3D10EnumDeviceInfo*
// List of CD3D10EnumDeviceSettingsCombo* with a unique set
// of BackBufferFormat, and Windowed
CGrowableArray <CD3D10EnumDeviceSettingsCombo*> deviceSettingsComboList;
};
class CD3D10EnumOutputInfo
{
const CD3D10EnumOutputInfo& operator =( const CD3D10EnumOutputInfo& rhs );
public:
~CD3D10EnumOutputInfo();
UINT AdapterOrdinal;
UINT Output;
IDXGIOutput* m_pOutput;
DXGI_OUTPUT_DESC Desc;
CGrowableArray <DXGI_MODE_DESC> displayModeList; // Array of supported D3DDISPLAYMODEs
};
//--------------------------------------------------------------------------------------
// A class describing a Direct3D10 device that contains a
// unique supported driver type
//--------------------------------------------------------------------------------------
class CD3D10EnumDeviceInfo
{
const CD3D10EnumDeviceInfo& operator =( const CD3D10EnumDeviceInfo& rhs );
public:
~CD3D10EnumDeviceInfo();
UINT AdapterOrdinal;
D3D10_DRIVER_TYPE DeviceType;
};
//--------------------------------------------------------------------------------------
// A struct describing device settings that contains a unique combination of
// adapter format, back buffer format, and windowed that is compatible with a
// particular Direct3D device and the app.
//--------------------------------------------------------------------------------------
struct CD3D10EnumDeviceSettingsCombo
{
UINT AdapterOrdinal;
D3D10_DRIVER_TYPE DeviceType;
DXGI_FORMAT BackBufferFormat;
BOOL Windowed;
UINT Output;
CGrowableArray <UINT> multiSampleCountList; // List of valid sampling counts (multisampling)
CGrowableArray <UINT> multiSampleQualityList; // List of number of quality levels for each multisample count
CD3D10EnumAdapterInfo* pAdapterInfo;
CD3D10EnumDeviceInfo* pDeviceInfo;
CD3D10EnumOutputInfo* pOutputInfo;
};
#endif
|