forked from QianMo/GPU-Gems-Book-Source-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d3denumeration.h
134 lines (115 loc) · 4.89 KB
/
d3denumeration.h
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
//-----------------------------------------------------------------------------
// File: D3DEnumeration.h
//
// Desc: Enumerates D3D adapters, devices, modes, etc.
//-----------------------------------------------------------------------------
#ifndef D3DENUM_H
#define D3DENUM_H
//-----------------------------------------------------------------------------
// Name: enum VertexProcessingType
// Desc: Enumeration of all possible D3D vertex processing types.
//-----------------------------------------------------------------------------
enum VertexProcessingType
{
SOFTWARE_VP,
MIXED_VP,
HARDWARE_VP,
PURE_HARDWARE_VP
};
//-----------------------------------------------------------------------------
// Name: struct D3DAdapterInfo
// Desc: Info about a display adapter.
//-----------------------------------------------------------------------------
struct D3DAdapterInfo
{
int AdapterOrdinal;
D3DADAPTER_IDENTIFIER9 AdapterIdentifier;
CArrayList* pDisplayModeList; // List of D3DDISPLAYMODEs
CArrayList* pDeviceInfoList; // List of D3DDeviceInfo pointers
~D3DAdapterInfo( void );
};
//-----------------------------------------------------------------------------
// Name: struct D3DDeviceInfo
// Desc: Info about a D3D device, including a list of D3DDeviceCombos (see below)
// that work with the device.
//-----------------------------------------------------------------------------
struct D3DDeviceInfo
{
int AdapterOrdinal;
D3DDEVTYPE DevType;
D3DCAPS9 Caps;
CArrayList* pDeviceComboList; // List of D3DDeviceCombo pointers
~D3DDeviceInfo( void );
};
//-----------------------------------------------------------------------------
// Name: struct D3DDSMSConflict
// Desc: A depth/stencil buffer format that is incompatible with a
// multisample type.
//-----------------------------------------------------------------------------
struct D3DDSMSConflict
{
D3DFORMAT DSFormat;
D3DMULTISAMPLE_TYPE MSType;
};
//-----------------------------------------------------------------------------
// Name: struct D3DDeviceCombo
// Desc: A combination of adapter format, back buffer format, and windowed/fullscreen
// that is compatible with a particular D3D device (and the app).
//-----------------------------------------------------------------------------
struct D3DDeviceCombo
{
int AdapterOrdinal;
D3DDEVTYPE DevType;
D3DFORMAT AdapterFormat;
D3DFORMAT BackBufferFormat;
bool IsWindowed;
CArrayList* pDepthStencilFormatList; // List of D3DFORMATs
CArrayList* pMultiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
CArrayList* pMultiSampleQualityList; // List of DWORDs (number of quality
// levels for each multisample type)
CArrayList* pDSMSConflictList; // List of D3DDSMSConflicts
CArrayList* pVertexProcessingTypeList; // List of VertexProcessingTypes
CArrayList* pPresentIntervalList; // List of D3DPRESENT_INTERVALs
~D3DDeviceCombo( void );
};
typedef bool(* CONFIRMDEVICECALLBACK)( D3DCAPS9* pCaps,
VertexProcessingType vertexProcessingType, D3DFORMAT backBufferFormat );
//-----------------------------------------------------------------------------
// Name: class CD3DEnumeration
// Desc: Enumerates available D3D adapters, devices, modes, etc.
//-----------------------------------------------------------------------------
class CD3DEnumeration
{
private:
IDirect3D9* m_pD3D;
private:
HRESULT EnumerateDevices( D3DAdapterInfo* pAdapterInfo, CArrayList* pAdapterFormatList );
HRESULT EnumerateDeviceCombos( D3DDeviceInfo* pDeviceInfo, CArrayList* pAdapterFormatList );
void BuildDepthStencilFormatList( D3DDeviceCombo* pDeviceCombo );
void BuildMultiSampleTypeList( D3DDeviceCombo* pDeviceCombo );
void BuildDSMSConflictList( D3DDeviceCombo* pDeviceCombo );
void BuildVertexProcessingTypeList( D3DDeviceInfo* pDeviceInfo, D3DDeviceCombo* pDeviceCombo );
void BuildPresentIntervalList( D3DDeviceInfo* pDeviceInfo, D3DDeviceCombo* pDeviceCombo );
public:
CArrayList* m_pAdapterInfoList;
// The following variables can be used to limit what modes, formats,
// etc. are enumerated. Set them to the values you want before calling
// Enumerate().
CONFIRMDEVICECALLBACK ConfirmDeviceCallback;
UINT AppMinFullscreenWidth;
UINT AppMinFullscreenHeight;
UINT AppMinColorChannelBits; // min color bits per channel in adapter format
UINT AppMinAlphaChannelBits; // min alpha bits per pixel in back buffer format
UINT AppMinDepthBits;
UINT AppMinStencilBits;
bool AppUsesDepthBuffer;
bool AppUsesMixedVP; // whether app can take advantage of mixed vp mode
bool AppRequiresWindowed;
bool AppRequiresFullscreen;
CArrayList* m_pAllowedAdapterFormatList; // list of D3DFORMATs
CD3DEnumeration();
~CD3DEnumeration();
void SetD3D(IDirect3D9* pD3D) { m_pD3D = pD3D; }
HRESULT Enumerate();
};
#endif