feat: Add Anti-Aliasing and Anisotropic Filtering support to options.ini#2375
feat: Add Anti-Aliasing and Anisotropic Filtering support to options.ini#2375githubawn wants to merge 2 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp | Added parse table entries and initialization; has column alignment issue (already flagged) |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp | Implements MSAA and anisotropic filtering but has critical MSAA issues (already flagged): no hardware check, set before windowed mode |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Initializes MultiSampleType static variable and applies it to present parameters; implementation is clean |
Last reviewed commit: c6158b8
| D3DMULTISAMPLE_TYPE msType = D3DMULTISAMPLE_NONE; | ||
| switch (TheGlobalData->m_antiAliasBoxValue) | ||
| { | ||
| case 1: msType = D3DMULTISAMPLE_2_SAMPLES; break; | ||
| case 2: msType = D3DMULTISAMPLE_4_SAMPLES; break; | ||
| case 3: msType = D3DMULTISAMPLE_8_SAMPLES; break; | ||
| default: msType = D3DMULTISAMPLE_NONE; break; | ||
| } | ||
| DX8Wrapper::Set_MultiSample_Type(msType); |
There was a problem hiding this comment.
No hardware capability check before setting MSAA type
DX8Wrapper::Set_MultiSample_Type(msType) is called unconditionally without first verifying the hardware supports the requested sample count via IDirect3D8::CheckDeviceMultiSampleType. On hardware that doesn't support (for example) 8× MSAA, this will cause every call to Set_Render_Device to fail. Critically, the three-attempt fallback retry loop below (attempts 0-2) only changes the resolution and bit-depth — it never resets MultiSampleType back to D3DMULTISAMPLE_NONE. This means all three attempts will fail with the same unsupported MSAA type, causing the game to abort with ERROR_INVALID_D3D on startup for any user whose hardware doesn't support their configured MSAA level.
The fix should reset MultiSampleType to D3DMULTISAMPLE_NONE inside the retry loop when device creation fails, or validate the sample count against D3DInterface->CheckDeviceMultiSampleType before using it.
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
Line: 713-721
Comment:
**No hardware capability check before setting MSAA type**
`DX8Wrapper::Set_MultiSample_Type(msType)` is called unconditionally without first verifying the hardware supports the requested sample count via `IDirect3D8::CheckDeviceMultiSampleType`. On hardware that doesn't support (for example) 8× MSAA, this will cause every call to `Set_Render_Device` to fail. Critically, the three-attempt fallback retry loop below (attempts 0-2) only changes the resolution and bit-depth — it never resets `MultiSampleType` back to `D3DMULTISAMPLE_NONE`. This means all three attempts will fail with the same unsupported MSAA type, causing the game to abort with `ERROR_INVALID_D3D` on startup for any user whose hardware doesn't support their configured MSAA level.
The fix should reset `MultiSampleType` to `D3DMULTISAMPLE_NONE` inside the retry loop when device creation fails, or validate the sample count against `D3DInterface->CheckDeviceMultiSampleType` before using it.
How can I resolve this? If you propose a fix, please make it concise.| D3DMULTISAMPLE_TYPE msType = D3DMULTISAMPLE_NONE; | ||
| switch (TheGlobalData->m_antiAliasBoxValue) | ||
| { | ||
| case 1: msType = D3DMULTISAMPLE_2_SAMPLES; break; | ||
| case 2: msType = D3DMULTISAMPLE_4_SAMPLES; break; | ||
| case 3: msType = D3DMULTISAMPLE_8_SAMPLES; break; | ||
| default: msType = D3DMULTISAMPLE_NONE; break; | ||
| } | ||
| DX8Wrapper::Set_MultiSample_Type(msType); | ||
|
|
||
| setWindowed( TheGlobalData->m_windowed ); |
There was a problem hiding this comment.
MSAA set before windowed mode is determined
DX8Wrapper::Set_MultiSample_Type(msType) is called before setWindowed(TheGlobalData->m_windowed). In DirectX 8, MSAA in windowed mode is unsupported on most hardware (the API requires full-screen exclusive mode for MultiSampleType != D3DMULTISAMPLE_NONE). Setting a non-zero MSAA type and then requesting a windowed device will almost certainly cause CreateDevice/Reset to return D3DERR_INVALIDCALL.
The MSAA type should either be forced to D3DMULTISAMPLE_NONE when windowed mode is active, or the windowed state must be resolved before the multisampling type is set.
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
Line: 713-723
Comment:
**MSAA set before windowed mode is determined**
`DX8Wrapper::Set_MultiSample_Type(msType)` is called before `setWindowed(TheGlobalData->m_windowed)`. In DirectX 8, MSAA in windowed mode is unsupported on most hardware (the API requires full-screen exclusive mode for `MultiSampleType != D3DMULTISAMPLE_NONE`). Setting a non-zero MSAA type and then requesting a windowed device will almost certainly cause `CreateDevice`/`Reset` to return `D3DERR_INVALIDCALL`.
The MSAA type should either be forced to `D3DMULTISAMPLE_NONE` when windowed mode is active, or the windowed state must be resolved before the multisampling type is set.
How can I resolve this? If you propose a fix, please make it concise.Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Follow-up to #2374, adding native support for AA/AF
this adds 2 new settings to options.ini
"AntiAliasing = " 0-1-2-3 (0-2-4-8)
AnisotropicFiltering = " yes / no
Not recommended to be merged before #2374 or #1073 is merged.
todo:
replicate to generals