DXUT11框架浅析(9)--DXUTDevice9




DXUT11框架浅析(9)--DXUTDevice9

 

 

 

         打开*\Microsoft DirectX SDK (June 2010)\Utilities\bin\x86\DXCapsViewer.exe。先查看为D3D9提供的Direct3D9Devices:

 DXUT11框架浅析(9)--DXUTDevice9_第1张图片



         这里展示本显卡所支持的D3D9的各种设备类型以及他们的详细性能参数。Direct3D9 主要是通过IDirect3D9 接口实现对设备性能的检测。DXUT11框架提供的DXUTDevice9正是对设备检测进行了封装。

 

 

1. 数据结构


1.1 显卡信息


class CD3D9EnumAdapterInfo

AdapterOrdinal 显卡的索引。

AdapterIdentifier 显卡信息描述,包括驱动程序,显卡描述、名称、版本等等。

szUniqueDescription 存了一份显卡描述,是上面AdapterIdentifier中的一项,存在外面,便于在CD3DSettingsDlg中使用。

displayModeList 显示模式(display mode)列表,显示模式主要包括宽度、高度、刷新频率和D3D颜色格式

deviceInfoList下面的CD3D9EnumDeviceInfo列表。

 

 

1.2 D3D设备信息


class CD3D9EnumDeviceInfo

AdapterOrdinal 依然保留了一份显卡的索引。

DeviceType 设备类型,主要有HAL和Reference两种类型。

Caps 硬件所能提供给Direct3D对象的性能。

deviceSettingsComboList 下面的CD3D9EnumDeviceSettingsCombo列表。

 

 

1.3 D3D设备组合设置


        指定显卡格式(adapter format),后置缓冲(backbuffer)格式,以及是否窗口化(windowed)三个参数后的一组兼容的设备设置。

struct CD3D9EnumDeviceSettingsCombo

AdapterOrdinal 指定的显卡索引。

DeviceType 指定的设备类型。

AdapterFormat 指定的显卡格式。

BackBufferFormat 指定的后置缓冲格式。

Windowed 指定是否窗口化还是全屏模式。

 

depthStencilFormatList深度/模版缓冲格式(depth/stencilbuffer format)列表。

multiSampleTypeList多采样类型(multisample type)列表。

multiSampleQualityList 多采样质量列表。

presentIntervalList 显示间隔列表。

DSMSConflictList 下面的CD3D9EnumDSMSConflict列表

 

pAdapterInfo 备份显卡信息便于枚举。

pDeviceInfo 备份设备信息便于枚举。

 

 

1.4 与多采样类型(multisample type)不兼容的深度/模版缓冲格式(depth/stencil buffer format)

struct CD3D9EnumDSMSConflict

DSFormat 深度/模版缓冲格式

MSType 多采样类型

 

上面几个数据结构用于存放设备性能,但是定义的有些冗余和混乱,但是至少管用。

 

 


2. 枚举实现


         枚举的主要逻辑在CD3D9Enumeration中实现,除了Set*/Get* 设置/读取属性之外,主要的枚举在Enumerate方法中实现,只看下主要逻辑。

 

2.1 首先遍历所有显卡

for( UINT adapterOrdinal= 0; adapterOrdinal < numAdapters; adapterOrdinal++)

 


2.2 根据允许的显卡格式(adapterformat),遍历出所有支持的显示模式(displaymode)

for( UINT iFormatList= 0; iFormatList < allowedAdapterFormatArrayCount;iFormatList++ )

 


2.3 进入EnumerateDevices开始枚举这个显卡的设备信息

根据允许的设备种类(device type)枚举设备性能

for( UINT iDeviceType= 0; iDeviceType < devTypeArrayCount; iDeviceType++)

 


2.4 IDirect3D9::GetDeviceCaps记录设备性能


2.5 进入EnumerateDeviceCombos开始枚举这个设备的组合设置

根据前面已遍历出的显卡格式(adapter format)和允许的后置缓冲格式(backbufferformat)遍历。

for(intiFormat= 0;iFormat <pAdapterFormatList->GetSize();iFormat++)

for( UINTiBackBufferFormat = 0; iBackBufferFormat < backBufferFormatArrayCount;iBackBufferFormat++ )

 

2.5.1 通过IDirect3D9::CheckDeviceType和IDirect3D9::CheckDeviceFormat检查与显卡格式兼容的后置缓冲格式。

 

2.5.2 遍历得到可用的深度/模版(depth/stencil)格式列表。

 

2.5.3 遍历得到可用的多采样种类(multisampletype)列表。

 

2.5.4 遍历得到与深度/模版格式冲突的多采样列表。

 

2.5.5 遍历得到可用的显示间隔列表。

 

 

 

参考资料

 

http://msdn.microsoft.com/en-us/library/windows/desktop/bb174300(v=vs.85).aspx

 

http://msdn.microsoft.com/en-us/library/windows/desktop/bb172585(v=vs.85).aspx

 

http://msdn.microsoft.com/en-us/library/windows/desktop/bb172558(v=vs.85).aspx

 

你可能感兴趣的:(DXUT11)