feat(options): Implement game options for texture filter mode, anisotropy and MSAA selection#2482
Open
Mauller wants to merge 2 commits intoTheSuperHackers:mainfrom
Open
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/Common/OptionPreferences.cpp | Adds getAntiAliasing(), getTextureFilterMode(), getTextureAnisotropyLevel() — logic is sound except for an inconsistent == guard in getAntiAliasing() that should be <=. |
| Core/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp | _Init_Filters now takes an explicit anisotropy_level argument and forwards it to _Set_Max_Anisotropy instead of hardcoding 2X. Correct. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp | Adds Set_Anisotropy_level() with correct ≤-based clamping and a new AnisotropyLevel static; Set_Texture_Filter() now passes the stored anisotropy level through. No issues. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.h | MultiSampleModeEnum values are now explicitly assigned (0, 2, 4, 8) to match the INI values; new Set/Get_Anisotropy_level API added. Clean. |
| GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp | Anti-aliasing saving/loading now correctly converts between combo-box position and MSAA sample count. Two always-true val >= 0 guards in the texture filter / anisotropy blocks. |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp | Applies MSAA mode from global data before device creation, then reads back the GPU-accepted mode afterwards and applies texture filter + anisotropy level. Post-init read-back pattern is sound. |
Sequence Diagram
sequenceDiagram
participant INI as Options.ini
participant OP as OptionPreferences
participant GD as GlobalData
participant W3DD as W3DDisplay::init()
participant WW3D as WW3D
participant TF as TextureFilterClass
INI->>OP: load("Options.ini")
OP->>GD: getAntiAliasing() → m_antiAliasLevel
OP->>GD: getTextureFilterMode() → m_textureFilteringMode
OP->>GD: getTextureAnisotropyLevel() → m_textureAnisotropyLevel
GD->>W3DD: m_antiAliasLevel
W3DD->>WW3D: Set_MSAA_Mode(m_antiAliasLevel)
W3DD->>WW3D: Set_Render_Device(...)
WW3D-->>W3DD: Get_MSAA_Mode() [GPU-clamped]
W3DD->>GD: m_antiAliasLevel ← GPU-accepted value
W3DD->>WW3D: Set_Texture_Filter(m_textureFilteringMode)
WW3D->>TF: _Init_Filters(TextureFilter, AnisotropyLevel)
W3DD->>WW3D: Set_Anisotropy_level(m_textureAnisotropyLevel)
WW3D->>TF: _Set_Max_Anisotropy(level)
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Core/GameEngine/Source/Common/OptionPreferences.cpp
Line: 79-80
Comment:
**No-op branch, inconsistent with the `<=` pattern**
The first `if` branch is a no-op — it reads `if (level == MULTISAMPLE_MODE_NONE) level = MULTISAMPLE_MODE_NONE`, which assigns the same value it just tested for. It works correctly only because `UnsignedInt` can never be less than zero, but it is inconsistent with every other range-clamp in the file (including `getTextureAnisotropyLevel()` and `Set_Anisotropy_level()`), all of which use `<=`. Prefer `<=` here for clarity and uniformity:
```suggestion
if (level <= WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE)
level = WW3D::MultiSampleModeEnum::MULTISAMPLE_MODE_NONE;
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
Line: 586
Comment:
**`val >= 0` is an always-true condition**
`val` is declared as `Int`, and both `getTextureFilterMode()` and `getTextureAnisotropyLevel()` always return a small, bounded `UnsignedInt` (0–4 and 2/4/8/16 respectively), so this guard is never false. The same always-true pattern appears at line 616 in the anisotropy block. If the intent is simply to guard against a null `TheGlobalData`, the condition should reflect that directly:
```suggestion
if (TheGlobalData)
```
The same applies to the matching check at line 616.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "feat(options): Imple..."
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
Show resolved
Hide resolved
120d3db to
cfff7d1
Compare
Author
|
Generals is currently broken till i replicate across due to changes in initaialising the texture filtering |
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp
Outdated
Show resolved
Hide resolved
cfff7d1 to
915e548
Compare
915e548 to
53085fc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge By Rebase
Closes: #2474
Closes: #2375
This PR implements options for allowing the enablement of MSAA and the selection of different texture filtering modes and setting the anisotropic filtering level.
The following options are added for anti aliasing
AntiAliasing = 0, 2, 4, 8
The numbers relate to the MSAA sample level and Zero disables MSAA.
TextureFilter = None, Point, Bilinear, Trilinear, Anisotropic
Self explanatory, just choose one and see how the game looks
AnisotropyLevel = 2, 4, 8, 16
The anisotropy level only comes into play when Anisotropic filtering is set. 2 is also the minimum value.
Generals is broken untill the changes are replicated due to changes in texture filter init.