Skip to content

Commit 42673ff

Browse files
committed
feat(dx8wrapper): Add check for MSAA support before device creation
1 parent e44f0a5 commit 42673ff

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,6 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int
10271027
_PresentParameters.BackBufferHeight = ResolutionHeight;
10281028
_PresentParameters.BackBufferCount = IsWindowed ? 1 : 2;
10291029

1030-
_PresentParameters.MultiSampleType = MultiSampleAntiAliasing;
10311030
//I changed this to discard all the time (even when full-screen) since that the most efficient. 07-16-03 MW:
10321031
_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;//IsWindowed ? D3DSWAPEFFECT_DISCARD : D3DSWAPEFFECT_FLIP; // Shouldn't this be D3DSWAPEFFECT_FLIP?
10331032
_PresentParameters.hDeviceWindow = _Hwnd;
@@ -1100,6 +1099,29 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int
11001099
&_PresentParameters.BackBufferFormat,&_PresentParameters.AutoDepthStencilFormat);
11011100
}
11021101

1102+
/*
1103+
** Check the devices support for the requested MSAA mode then setup the multi sample type
1104+
*/
1105+
if (MultiSampleAntiAliasing > DEFAULT_MSAA) {
1106+
1107+
HRESULT hr = D3DInterface->CheckDeviceMultiSampleType(
1108+
CurRenderDevice,
1109+
D3DDEVTYPE_HAL,
1110+
DisplayFormat,
1111+
IsWindowed,
1112+
MultiSampleAntiAliasing
1113+
);
1114+
1115+
if (FAILED(hr)) {
1116+
// IF we fail then disable MSAA entirely.
1117+
// External code needs to get the set MSAA mode after device creation
1118+
WWDEBUG_SAY(("Requested MSAA Mode Not Supported"));
1119+
MultiSampleAntiAliasing = DEFAULT_MSAA;
1120+
}
1121+
}
1122+
1123+
_PresentParameters.MultiSampleType = MultiSampleAntiAliasing;
1124+
11031125
/*
11041126
** Time to actually create the device.
11051127
*/

0 commit comments

Comments
 (0)