|
//
// DXDevEnum.h
//
// Enumerates DirectX devices and modes
// Based on MS SDK DXUTEnum class
//
#ifndef __DXDEVENUM_H_
#define __DXDEVENUM_H_
#include "..\..\collections\Array.h"
namespace ZGraphics
{
class DXEnumAdapterInfo;
class DXEnumDeviceInfo;
struct DXEnumDeviceSettingsCombo;
struct DXEnumDSMSConflict;
class DXDevEnum
{
public:
DXDevEnum();
// 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.
HRESULT Enumerate( IDirect3D9* pD3D = NULL,
LPDXUTCALLBACKISDEVICEACCEPTABLE IsDeviceAcceptableFunc = NULL );
// These should be called after Enumerate() is called
Array<DXEnumAdapterInfo *> * GetAdapterInfoList();
DXEnumAdapterInfo * GetAdapterInfo(UINT AdapterOrdinal);
DXEnumDeviceInfo * GetDeviceInfo(UINT AdapterOrdinal, D3DDEVTYPE DeviceType);
DXEnumDeviceSettingsCombo * GetDeviceSettingsCombo(DXDeviceSettings * pDeviceSettings )
{
return GetDeviceSettingsCombo( pDeviceSettings->AdapterOrdinal, pDeviceSettings->DeviceType, pDeviceSettings->AdapterFormat, pDeviceSettings->pp.BackBufferFormat, pDeviceSettings->pp.Windowed);
}
DXEnumDeviceSettingsCombo * GetDeviceSettingsCombo(UINT AdapterOrdinal, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL Windowed);
private:
// Use DXGetEnumeration() to access global instance
DXDevEnum();
IDirect3D9 * m_pD3D;
LPDXUTCALLBACKISDEVICEACCEPTABLE m_IsDeviceAcceptableFunc;
bool m_bRequirePostPixelShaderBlending;
Array<D3DFORMAT> m_DepthStecilPossibleList;
Array<D3DMULTISAMPLE_TYPE> m_MultiSampleTypeList;
Array<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 CD3DEnumAdapterInfo* with unique AdapterOrdinals
Array<CD3DEnumAdapterInfo *> m_AdapterInfoList;
HRESULT EnumerateDevices(DXEnumAdapterInfo * pAdapterInfo, Array<D3DFORMAT> * pAdapterFormatList);
HRESULT EnumerateDeviceCombos(DXEnumAdapterInfo * pAdapterInfo, DXEnumDeviceInfo * pDeviceInfo, Array<D3DFORMAT> * pAdapterFormatList);
void BuildDepthStencilFormatList(DXEnumDeviceSettingsCombo * pDeviceCombo);
void BuildMultiSampleTypeList(DXEnumDeviceSettingsCombo * pDeviceCombo);
void BuildDSMSConflictList(DXEnumDeviceSettingsCombo * pDeviceCombo);
void BuildPresentIntervalList(DXEnumDeviceInfo * pDeviceInfo, DXEnumDeviceSettingsCombo * pDeviceCombo);
void ClearAdapterInfoList();
};
DXEnumeration * DXGetEnumeration();
//--------------------------------------------------------------------------------------
// A class describing an adapter which contains a unique adapter ordinal
// that is installed on the system
//--------------------------------------------------------------------------------------
class DXEnumAdapterInfo
{
public:
~DXEnumAdapterInfo();
UINT m_AdapterOrdinal;
D3DADAPTER_IDENTIFIER9 m_AdapterIdentifier;
WCHAR m_wszUniqueDescription[256];
Array<D3DDISPLAYMODE> m_displayModeList; // Array of supported D3DDISPLAYMODEs
Array<DXEnumDeviceInfo *> m_deviceInfoList; // Array of DXEnumDeviceInfo* with unique supported DeviceTypes
};
//--------------------------------------------------------------------------------------
// A class describing a Direct3D device that contains a
// unique supported device type
//--------------------------------------------------------------------------------------
class DXEnumDeviceInfo
{
public:
~DXEnumDeviceInfo();
UINT m_AdapterOrdinal;
D3DDEVTYPE m_DeviceType;
D3DCAPS9 m_DevCaps;
// List of DXEnumDeviceSettingsCombo* with a unique set
// of AdapterFormat, BackBufferFormat, and Windowed
Array<DXEnumDeviceSettingsCombo *> m_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 DXEnumDeviceSettingsCombo
{
UINT AdapterOrdinal;
D3DDEVTYPE DeviceType;
D3DFORMAT AdapterFormat;
D3DFORMAT BackBufferFormat;
BOOL Windowed;
Array<D3DFORMAT> depthStencilFormatList; // List of D3DFORMATs
Array<D3DMULTISAMPLE_TYPE> multiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
Array<DWORD> multiSampleQualityList; // List of number of quality levels for each multisample type
Array<UINT> presentIntervalList; // List of D3DPRESENT flags
Array<CD3DEnumDSMSConflict> DSMSConflictList; // List of CD3DEnumDSMSConflict
DXEnumAdapterInfo * pAdapterInfo;
DXEnumDeviceInfo * pDeviceInfo;
};
//--------------------------------------------------------------------------------------
// A depth/stencil buffer format that is incompatible with a
// multisample type.
//--------------------------------------------------------------------------------------
struct DXEnumDSMSConflict
{
D3DFORMAT DSFormat;
D3DMULTISAMPLE_TYPE MSType;
};
} /* namespace ZGraphics */
#endif /* __DXDEVENUM_H_ */
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a senior software developer currently doing contract work for Microsoft. My educational background is in electrical engineering and I hold a masters degree from the University of Washington. I have experience in hardware and systems design but have done primarily software development for the last two decades. I have worked for various small companies as well as start-up companies, and have worked as a full time employee SDE at Microsoft Corporation.