Skip to content

unify(w3ddisplay): Match Zero Hour texture bit depth in Generals - #3181

Open
Jaredl-Dev wants to merge 1 commit into
TheSuperHackers:mainfrom
Jaredl-Dev:fix/generals-controlbar-texture-discoloration
Open

unify(w3ddisplay): Match Zero Hour texture bit depth in Generals#3181
Jaredl-Dev wants to merge 1 commit into
TheSuperHackers:mainfrom
Jaredl-Dev:fix/generals-controlbar-texture-discoloration

Conversation

@Jaredl-Dev

@Jaredl-Dev Jaredl-Dev commented Aug 20, 2026

Copy link
Copy Markdown

This fixes the discolored control bar textures in Generals introduced by #726.

Issue

The Generals control bar displays visible discoloration and quantization across its background textures.

Discolored Generals control bar

Root cause

Before #726, Generals selected texture formats using the device bit depth, keeping the 32-bit control bar textures intact.

#726 made Generals honor WW3D::Get_Texture_Bitdepth(), matching Zero Hour. However, Generals still left the texture bit depth at its default value of 16. This caused the 32-bit control bar textures to be converted from A8R8G8B8 to A4R4G4B4, producing the visible discoloration.

Fix

Generals now explicitly sets the texture bit depth to 32 during W3DDisplay initialization, matching Zero Hour and restoring the effective pre-#726 rendering behavior.

Verification

Jaredl-Dev added a commit to Jaredl-Dev/GeneralsGameCode that referenced this pull request Aug 20, 2026
@Jaredl-Dev
Jaredl-Dev force-pushed the fix/generals-controlbar-texture-discoloration branch from c3bdf3f to 6d508d7 Compare August 20, 2026 19:32
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix Generals control bar discoloration by forcing 32-bit texture bitdepth

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Set Generals texture bit depth to 32 during W3DDisplay initialization.
• Prevent 32-bit UI textures from being quantized to 16-bit formats.
• Restore pre-#726 control bar rendering quality while keeping #726 behavior alignment.
Diagram

graph TD
  A["Generals client"] --> B["W3DDisplay::init()"] --> C["WW3D render config"] --> D["Set_Texture_Bitdepth(32)"] --> E["Texture format selection"] --> F["Control bar textures"]

  subgraph Legend
    direction LR
    _app["App/Client"] ~~~ _fn["Init function"] ~~~ _cfg["Engine setting"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Set WW3D default texture bit depth to 32 globally
  • ➕ Fixes any other callers that forget to set the bit depth
  • ➕ Centralizes the default to reduce per-game divergence
  • ➖ Riskier: may change behavior for other titles/modes expecting 16-bit default
  • ➖ Harder to reason about regressions outside Generals
2. Derive bit depth from device/backbuffer format (pre-#726 style)
  • ➕ Adapts automatically to runtime device capabilities
  • ➕ Avoids hardcoding and may better match legacy expectations
  • ➖ Reintroduces divergence from the post-[GEN] Bring texture related code in WW3D2 closer to Zero Hour #726 model that honors WW3D texture bit depth
  • ➖ More complex logic and potentially inconsistent results across devices
3. Expose as Generals config/INI option
  • ➕ Enables toggling for compatibility/performance testing without code changes
  • ➕ Makes the behavior explicit and documented
  • ➖ Adds surface area and support burden for a setting that should be deterministic
  • ➖ Still needs a safe default (likely 32)

Recommendation: The PR’s approach (explicitly setting texture bit depth to 32 in Generals’ W3DDisplay initialization) is the best tradeoff: it is minimally invasive, scoped to the affected game, and directly restores the intended 32-bit UI texture path without broad engine-wide side effects.

Files changed (1) +1 / -0

Bug fix (1) +1 / -0
W3DDisplay.cppForce 32-bit texture bit depth during Generals display init +1/-0

Force 32-bit texture bit depth during Generals display init

• Adds an explicit call to set WW3D texture bit depth to 32 as part of W3DDisplay initialization. This prevents 32-bit control bar textures from being converted to lower-precision 16-bit formats, eliminating visible quantization/discoloration introduced by the prior behavioral change.

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Informational

1. Undocumented magic bitdepth 🐞 Bug ⚙ Maintainability
Description
W3DDisplay::init hard-codes WW3D::Set_Texture_Bitdepth(32) without documenting that this is
required to prevent 32-bit UI textures being down-converted when the engine default texture depth is
16. This makes the line easy to “clean up” later and accidentally reintroduce the discoloration
regression.
Code

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp[779]

+		WW3D::Set_Texture_Bitdepth(32);
Evidence
The engine’s default texture bit depth is 16, and the texture format selection logic forces 16-bit
formats whenever Get_Texture_Bitdepth()==16 (even if the device is running at 32-bit). Without an
explanatory comment, the new hard-coded 32 looks arbitrary despite being required to avoid forced
16-bit conversion.

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp[771-782]
Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp[90-120]
Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp[339-352]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`WW3D::Set_Texture_Bitdepth(32)` is a critical behavioral override but is currently a bare magic number with no in-code explanation. Because WW3D defaults texture depth to 16, removing/altering this line can silently reintroduce 32-bit texture quantization/discoloration.

### Issue Context
- DX8Wrapper default texture depth is 16.
- The format selection path treats `Get_Texture_Bitdepth()==16` as a forced 16-bit pipeline even on 32-bit displays.

### Fix Focus Areas
- Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp[771-782]
- Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp[90-120]
- Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp[339-352]

### Suggested fix
Add a short comment next to the call explaining it prevents down-conversion of 32-bit UI/controlbar textures (engine default is 16), or replace `32` with a named constant local to W3DDisplay initialization (keeping it explicitly 32, not tied to display bit depth).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can copy the agent prompt from any finding and feed it to your IDE agent

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@stephanmeesters stephanmeesters left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggest rename PR to:

unify(w3ddisplay): Match Zero Hour texture bit depth in Generals

Fix appears to be wider than just the control bar.

@Jaredl-Dev Jaredl-Dev changed the title bugfix(controlbar): Prevent texture discoloration in Generals unify(w3ddisplay): Match Zero Hour texture bit depth in Generals Aug 21, 2026
@xezon xezon added Gen Relates to Generals Unify Unifies code between Generals and Zero Hour labels Aug 21, 2026
@xezon xezon added this to the Code foundation build up milestone Aug 21, 2026
@xezon

xezon commented Aug 21, 2026

Copy link
Copy Markdown

This change somehow cannot be merged. The Merge button is greyed out.

@Jaredl-Dev
Jaredl-Dev force-pushed the fix/generals-controlbar-texture-discoloration branch from 6d508d7 to e21b835 Compare August 21, 2026 21:06
@Jaredl-Dev

Jaredl-Dev commented Aug 21, 2026

Copy link
Copy Markdown
Author

@xezon I believe you can't merge this because the GeneralsMD CI gates appear to be stuck and won't run. I already force-pushed an amended commit with no changes, but they still got stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Unify Unifies code between Generals and Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants