Fixed use of adapter and device type for all d3d9 calls.

This commit is contained in:
bkaradzic 2012-05-30 22:01:16 -07:00
parent 7e90a27790
commit b0eea140b3

View File

@ -153,8 +153,8 @@ namespace bgfx
BGFX_FATAL(m_d3d9, bgfx::Fatal::D3D9_UnableToCreateInterface, "Unable to create Direct3D."); BGFX_FATAL(m_d3d9, bgfx::Fatal::D3D9_UnableToCreateInterface, "Unable to create Direct3D.");
uint32_t adapter = D3DADAPTER_DEFAULT; m_adapter = D3DADAPTER_DEFAULT;
D3DDEVTYPE deviceType = D3DDEVTYPE_HAL; m_deviceType = D3DDEVTYPE_HAL;
uint32_t adapterCount = m_d3d9->GetAdapterCount(); uint32_t adapterCount = m_d3d9->GetAdapterCount();
for (uint32_t ii = 0; ii < adapterCount; ++ii) for (uint32_t ii = 0; ii < adapterCount; ++ii)
@ -176,8 +176,8 @@ namespace bgfx
#if BGFX_CONFIG_DEBUG_PERFHUD #if BGFX_CONFIG_DEBUG_PERFHUD
if (0 != strstr(identifier.Description, "PerfHUD") ) if (0 != strstr(identifier.Description, "PerfHUD") )
{ {
adapter = ii; m_adapter = ii;
deviceType = D3DDEVTYPE_REF; m_deviceType = D3DDEVTYPE_REF;
} }
#endif // BGFX_CONFIG_DEBUG_PERFHUD #endif // BGFX_CONFIG_DEBUG_PERFHUD
} }
@ -192,8 +192,8 @@ namespace bgfx
for (uint32_t ii = 0; ii < countof(behaviorFlags) && NULL == m_device; ++ii) for (uint32_t ii = 0; ii < countof(behaviorFlags) && NULL == m_device; ++ii)
{ {
#if BGFX_CONFIG_RENDERER_DIRECT3D_EX #if BGFX_CONFIG_RENDERER_DIRECT3D_EX
DX_CHECK(m_d3d9->CreateDeviceEx(adapter DX_CHECK(m_d3d9->CreateDeviceEx(m_adapter
, deviceType , m_deviceType
, g_bgfxHwnd , g_bgfxHwnd
, behaviorFlags[ii] , behaviorFlags[ii]
, &m_params , &m_params
@ -201,8 +201,8 @@ namespace bgfx
, &m_device , &m_device
) ); ) );
#else #else
DX_CHECK(m_d3d9->CreateDevice(adapter DX_CHECK(m_d3d9->CreateDevice(m_adapter
, deviceType , m_deviceType
, g_bgfxHwnd , g_bgfxHwnd
, behaviorFlags[ii] , behaviorFlags[ii]
, &m_params , &m_params
@ -237,11 +237,11 @@ namespace bgfx
BX_TRACE("Max fragment shader 2.0 instr. slots: %d", m_caps.PS20Caps.NumInstructionSlots); BX_TRACE("Max fragment shader 2.0 instr. slots: %d", m_caps.PS20Caps.NumInstructionSlots);
BX_TRACE("Max fragment shader 3.0 instr. slots: %d", m_caps.MaxPixelShader30InstructionSlots); BX_TRACE("Max fragment shader 3.0 instr. slots: %d", m_caps.MaxPixelShader30InstructionSlots);
m_fmtNULL = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_NULL) ); m_fmtNULL = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter, m_deviceType, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_NULL) );
m_fmtDF16 = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF16) ); m_fmtDF16 = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter, m_deviceType, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF16) );
m_fmtDF24 = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF24) ); m_fmtDF24 = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter, m_deviceType, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF24) );
m_fmtINTZ = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_INTZ) ); m_fmtINTZ = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter, m_deviceType, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_INTZ) );
m_fmtRAWZ = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_RAWZ) ); m_fmtRAWZ = SUCCEEDED(m_d3d9->CheckDeviceFormat(m_adapter, m_deviceType, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_RAWZ) );
m_fmtDepth = D3DFMT_D24S8; m_fmtDepth = D3DFMT_D24S8;
@ -263,8 +263,8 @@ namespace bgfx
} }
BX_TRACE("Creating device"); BX_TRACE("Creating device");
DX_CHECK(m_d3d9->CreateDevice(D3DADAPTER_DEFAULT DX_CHECK(m_d3d9->CreateDevice(m_adapter
, D3DDEVTYPE_HAL , m_deviceType
, NULL , NULL
, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES , D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_BUFFER_2_FRAMES
, &m_params , &m_params
@ -322,8 +322,8 @@ namespace bgfx
m_params.PresentationInterval = !!(m_flags&BGFX_RESET_VSYNC) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; m_params.PresentationInterval = !!(m_flags&BGFX_RESET_VSYNC) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
D3DMULTISAMPLE_TYPE msaa = s_msaa[(m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT]; D3DMULTISAMPLE_TYPE msaa = s_msaa[(m_flags&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT];
HRESULT hr = m_d3d9->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT HRESULT hr = m_d3d9->CheckDeviceMultiSampleType(m_adapter
, D3DDEVTYPE_HAL , m_deviceType
, m_params.BackBufferFormat , m_params.BackBufferFormat
, m_params.Windowed , m_params.Windowed
, msaa , msaa
@ -540,6 +540,8 @@ namespace bgfx
IDirect3DSurface9* m_backBufferDepthStencil; IDirect3DSurface9* m_backBufferDepthStencil;
HMODULE m_d3d9dll; HMODULE m_d3d9dll;
uint32_t m_adapter;
D3DDEVTYPE m_deviceType;
D3DPRESENT_PARAMETERS m_params; D3DPRESENT_PARAMETERS m_params;
uint32_t m_flags; uint32_t m_flags;