mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 06:34:36 +00:00
GFX now handles non-default adapters
The GFX (DirectX) pipeline did not respect the choice of adapter and always went for the default one. Normally this isn't an issue unless you wish to target a particular adapter and display device combination. This has been corrected. The GFX initialize functions now attempt to find the best adapter that matches a given display device (i.e. monitor) if one has been passed in. To aid with choosing a display device some new monitor enumeration methods have been added to the platform window manager. These methods have been exposed to the Canvas.
This commit is contained in:
parent
1ed1a41256
commit
0d77cdc270
18 changed files with 282 additions and 45 deletions
|
|
@ -120,7 +120,7 @@ GFXFormat GFXPCD3D9Device::selectSupportedFormat(GFXTextureProfile *profile,
|
|||
usage |= D3DUSAGE_QUERY_FILTER;
|
||||
|
||||
D3DDISPLAYMODE mode;
|
||||
D3D9Assert(mD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &mode), "Unable to get adapter mode.");
|
||||
D3D9Assert(mD3D->GetAdapterDisplayMode(mAdapterIndex, &mode), "Unable to get adapter mode.");
|
||||
|
||||
D3DRESOURCETYPE type;
|
||||
if(texture)
|
||||
|
|
@ -130,7 +130,7 @@ GFXFormat GFXPCD3D9Device::selectSupportedFormat(GFXTextureProfile *profile,
|
|||
|
||||
for(U32 i=0; i<formats.size(); i++)
|
||||
{
|
||||
if(mD3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, mode.Format,
|
||||
if(mD3D->CheckDeviceFormat(mAdapterIndex, D3DDEVTYPE_HAL, mode.Format,
|
||||
usage, type, GFXD3D9TextureFormat[formats[i]]) == D3D_OK)
|
||||
return formats[i];
|
||||
}
|
||||
|
|
@ -259,9 +259,12 @@ void GFXPCD3D9Device::enumerateAdapters( Vector<GFXAdapter*> &adapterList )
|
|||
D3DADAPTER_IDENTIFIER9 temp;
|
||||
d3d9->GetAdapterIdentifier( adapterIndex, NULL, &temp ); // The NULL is the flags which deal with WHQL
|
||||
|
||||
dStrcpy( toAdd->mName, temp.Description );
|
||||
dStrncpy(toAdd->mName, temp.Description, GFXAdapter::MaxAdapterNameLen);
|
||||
dStrncat(toAdd->mName, " (D3D9)", GFXAdapter::MaxAdapterNameLen);
|
||||
|
||||
// And the output display device name
|
||||
dStrncpy(toAdd->mOutputName, temp.DeviceName, GFXAdapter::MaxAdapterNameLen);
|
||||
|
||||
// Video mode enumeration.
|
||||
Vector<D3DFORMAT> formats( __FILE__, __LINE__ );
|
||||
formats.push_back( D3DFMT_R5G6B5 ); // D3DFMT_R5G6B5 - 16bit format
|
||||
|
|
@ -303,10 +306,10 @@ void GFXPCD3D9Device::enumerateVideoModes()
|
|||
|
||||
for( S32 i = 0; i < formats.size(); i++ )
|
||||
{
|
||||
for( U32 j = 0; j < mD3D->GetAdapterModeCount( D3DADAPTER_DEFAULT, formats[i] ); j++ )
|
||||
for( U32 j = 0; j < mD3D->GetAdapterModeCount( mAdapterIndex, formats[i] ); j++ )
|
||||
{
|
||||
D3DDISPLAYMODE mode;
|
||||
mD3D->EnumAdapterModes( D3DADAPTER_DEFAULT, formats[i], j, &mode );
|
||||
mD3D->EnumAdapterModes( mAdapterIndex, formats[i], j, &mode );
|
||||
|
||||
GFXVideoMode toAdd;
|
||||
|
||||
|
|
@ -392,7 +395,7 @@ void GFXPCD3D9Device::init( const GFXVideoMode &mode, PlatformWindow *window /*
|
|||
deviceFlags |= D3DCREATE_PUREDEVICE;
|
||||
#endif
|
||||
|
||||
hres = createDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, winHwnd, deviceFlags, &d3dpp);
|
||||
hres = createDevice( mAdapterIndex, D3DDEVTYPE_HAL, winHwnd, deviceFlags, &d3dpp);
|
||||
|
||||
if (FAILED(hres) && hres != D3DERR_OUTOFVIDEOMEMORY)
|
||||
{
|
||||
|
|
@ -403,7 +406,7 @@ void GFXPCD3D9Device::init( const GFXVideoMode &mode, PlatformWindow *window /*
|
|||
// try mixed mode
|
||||
deviceFlags &= (~D3DCREATE_HARDWARE_VERTEXPROCESSING);
|
||||
deviceFlags |= D3DCREATE_MIXED_VERTEXPROCESSING;
|
||||
hres = createDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
|
||||
hres = createDevice( mAdapterIndex, D3DDEVTYPE_HAL,
|
||||
winHwnd, deviceFlags,
|
||||
&d3dpp);
|
||||
|
||||
|
|
@ -413,7 +416,7 @@ void GFXPCD3D9Device::init( const GFXVideoMode &mode, PlatformWindow *window /*
|
|||
Con::errorf(" Failed to create mixed mode device, trying software device");
|
||||
deviceFlags &= (~D3DCREATE_MIXED_VERTEXPROCESSING);
|
||||
deviceFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||
hres = createDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
|
||||
hres = createDevice( mAdapterIndex, D3DDEVTYPE_HAL,
|
||||
winHwnd, deviceFlags,
|
||||
&d3dpp);
|
||||
|
||||
|
|
@ -446,7 +449,7 @@ void GFXPCD3D9Device::init( const GFXVideoMode &mode, PlatformWindow *window /*
|
|||
Con::printf(" Cur. D3DDevice ref count=%d", mD3DDevice->AddRef() - 1);
|
||||
mD3DDevice->Release();
|
||||
|
||||
mTextureManager = new GFXD3D9TextureManager( mD3DDevice );
|
||||
mTextureManager = new GFXD3D9TextureManager( mD3DDevice, mAdapterIndex );
|
||||
|
||||
// Now reacquire all the resources we trashed earlier
|
||||
reacquireDefaultPoolResources();
|
||||
|
|
@ -510,7 +513,7 @@ void GFXPCD3D9Device::init( const GFXVideoMode &mode, PlatformWindow *window /*
|
|||
|
||||
Con::printf( " Using Direct3D9Ex: %s", isD3D9Ex() ? "Yes" : "No" );
|
||||
|
||||
mCardProfiler = new GFXD3D9CardProfiler();
|
||||
mCardProfiler = new GFXD3D9CardProfiler(mAdapterIndex);
|
||||
mCardProfiler->init();
|
||||
|
||||
gScreenShot = new ScreenShotD3D;
|
||||
|
|
@ -956,7 +959,7 @@ void GFXPCD3D9Device::_validateMultisampleParams(D3DFORMAT format, D3DMULTISAMPL
|
|||
if (aatype != D3DMULTISAMPLE_NONE)
|
||||
{
|
||||
DWORD MaxSampleQualities;
|
||||
mD3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, format, FALSE, D3DMULTISAMPLE_NONMASKABLE, &MaxSampleQualities);
|
||||
mD3D->CheckDeviceMultiSampleType(mAdapterIndex, D3DDEVTYPE_HAL, format, FALSE, D3DMULTISAMPLE_NONMASKABLE, &MaxSampleQualities);
|
||||
aatype = D3DMULTISAMPLE_NONMASKABLE;
|
||||
aalevel = getMin((U32)aalevel, (U32)MaxSampleQualities-1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue