Skip to content

feat: Add Anti-Aliasing and Anisotropic Filtering support to options.ini#2375

Draft
githubawn wants to merge 2 commits intoTheSuperHackers:mainfrom
githubawn:feature/aa-af-settings
Draft

feat: Add Anti-Aliasing and Anisotropic Filtering support to options.ini#2375
githubawn wants to merge 2 commits intoTheSuperHackers:mainfrom
githubawn:feature/aa-af-settings

Conversation

@githubawn
Copy link

@githubawn githubawn commented Mar 2, 2026

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

@greptile-apps
Copy link

greptile-apps bot commented Mar 2, 2026

Greptile Summary

Adds native support for configurable Anti-Aliasing (0/2/4/8x MSAA) and Anisotropic Filtering via options.ini. Implementation adds new fields to GlobalData, exposes a setter for MultiSampleType in DX8Wrapper, and applies settings during display initialization.

Critical issues (already flagged):

  • MSAA type set without hardware capability check via IDirect3D8::CheckDeviceMultiSampleType, causing startup failure on unsupported hardware
  • MSAA configured before windowed mode determination, conflicting with DirectX 8's requirement that MSAA only works in fullscreen
  • Retry loop doesn't reset MultiSampleType to D3DMULTISAMPLE_NONE on failure, causing all retry attempts to fail with the same unsupported type

Minor issue:

  • Parse table column alignment inconsistency (already flagged)

Confidence Score: 0/5

  • Critical issues will cause startup failures on many systems; unsafe to merge without fixes
  • Score reflects three critical bugs in MSAA implementation that will cause the game to fail initialization on hardware that doesn't support the requested sample count or when using windowed mode with MSAA enabled. The retry loop cannot recover because MultiSampleType is never reset to D3DMULTISAMPLE_NONE.
  • Pay immediate attention to GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp - the MSAA issues must be fixed before merge

Important Files Changed

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

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +713 to +721
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);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +713 to 723
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 );
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@githubawn githubawn marked this pull request as draft March 2, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant