Skip to content

chore: Remove unused code in dx8wrapper#2504

Merged
xezon merged 8 commits intoTheSuperHackers:mainfrom
stephanmeesters:chore/dx8wrapper-cleanup
Mar 30, 2026
Merged

chore: Remove unused code in dx8wrapper#2504
xezon merged 8 commits intoTheSuperHackers:mainfrom
stephanmeesters:chore/dx8wrapper-cleanup

Conversation

@stephanmeesters
Copy link
Copy Markdown

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 30, 2026

Greptile Summary

This PR removes dead code from dx8wrapper in both the Generals and GeneralsMD codebases, continuing the cleanup work tracked in #2499. All removals are safe — no callers exist anywhere in the codebase for any of the deleted symbols.

Key removals:

  • Unused static members: old_world, old_view, old_prj (D3DMATRIX), Render_Info (RenderInfoClass*), and DesktopMode (D3DDISPLAYMODE) — all declared and initialised but never read or written after Init().
  • Dead functions: Validate_Device(), Peek_Light(), Is_Light_Enabled() (never called); Set_DX8_ZBias() (all call-sites were already commented out in dx8renderer.cpp).
  • Obfuscated helper: flimby() — its only call-site was commented out; the function itself depended on the now-removed empty macros prevVer / nextVer.
  • Redundant forward declarations in GeneralsMD: ZTextureClass and DX8Caps are both fully defined through existing #include directives (texture.h and dx8caps.h), making the declarations redundant.
  • Commented-out ZBias scaffolding in dx8renderer.cpp cleaned up along with the removed setter.

The ZBias member variable remains in the class and is still read by Set_Projection_Transform_With_Z_Bias, but since Set_DX8_ZBias was the only setter and all its callers were already commented out, ZBias was effectively always 0 prior to this PR — the behaviour is unchanged.

Confidence Score: 5/5

Safe to merge — pure dead code removal with no functional impact on either codebase.

Every removed symbol was verified to have zero callers or readers in the repository. The forward-declaration removals in GeneralsMD are safe because the types are fully defined through included headers. No new code is introduced, and no existing behaviour changes.

No files require special attention.

Important Files Changed

Filename Overview
Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h Removes unused static members (old_world/old_view/old_prj, Render_Info), dead declarations (Peek_Light, Is_Light_Enabled, Validate_Device), empty macros (prevVer/nextVer), and the obfuscated flimby() helper — all unreachable code.
Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp Removes static definitions for old_world/old_view/old_prj and Render_Info, their ZeroMemory initialisation in Init(), and the never-called Validate_Device() implementation.
GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h Same dead-code removals as the Generals counterpart, plus removal of the Set_DX8_ZBias inline, its declaration, and the now-redundant ZTextureClass/DX8Caps forward declarations (both types are already fully defined via texture.h / dx8caps.h includes).
GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp Removes same dead static members as Generals, plus the file-scope DesktopMode variable (declared but never read or written); all removals are safe.
GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp Removes already-commented-out ZBias calls and surrounding blank lines; no functional change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Removed["Removed Dead Code"]
        A["old_world / old_view / old_prj\n(D3DMATRIX static members)"]
        B["Render_Info\n(RenderInfoClass* static member)"]
        C["DesktopMode\n(D3DDISPLAYMODE, GeneralsMD only)"]
        D["Validate_Device()\n(never called)"]
        E["Peek_Light() / Is_Light_Enabled()\n(never called)"]
        F["Set_DX8_ZBias()\n(all call-sites commented out)"]
        G["flimby()\n(only call-site commented out)"]
        H["#define prevVer / nextVer\n(only used by flimby)"]
    end

    subgraph Retained["Retained (pre-existing dead state)"]
        I["ZBias member\n(always 0; read in Set_Projection_Transform_With_Z_Bias)"]
    end

    F -->|"was the only setter for"| I
    G -->|"depended on"| H
Loading

Reviews (3): Last reviewed commit: "chore(ww3d2): Remove unused Validate_Dev..." | Re-trigger Greptile

@stephanmeesters stephanmeesters changed the title chore(ww3d2): Remove dead code in dx8wrapper chore(ww3d2): Remove dead code in dx8wrapper, remove xbox define Mar 30, 2026
@stephanmeesters stephanmeesters changed the title chore(ww3d2): Remove dead code in dx8wrapper, remove xbox define chore(ww3d2): Remove dead code in dx8wrapper Mar 30, 2026
@stephanmeesters stephanmeesters force-pushed the chore/dx8wrapper-cleanup branch from 2e4b483 to 7142e33 Compare March 30, 2026 12:06
static unsigned Get_Last_Frame_Render_State_Changes();
static unsigned Get_Last_Frame_Texture_Stage_State_Changes();
static unsigned Get_Last_Frame_DX8_Calls();
static unsigned Get_Last_Frame_Draw_Calls();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This block was likely added for debugging purposes. Having insights to draw calls is generally a useful thing to have. Why do you want to remove it?

It does not make sense to remove this while keeping End_Statistics

Instead of removing, this could be simplified to return a statistics struct and therefore just be one function call.

Copy link
Copy Markdown
Author

@stephanmeesters stephanmeesters Mar 30, 2026

Choose a reason for hiding this comment

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

Might have nuked these a bit too quick on the basis of them being unused.

Get_Last_Frame_Draw_Calls has an equivalent in W3DDisplay and can be toggled with -displayDebug in the win32-debug profile.

I'll do the statistics struct in another PR. See #2507. Removed the commit from current PR

@xezon xezon added the Refactor Edits the code with insignificant behavior changes, is never user facing label Mar 30, 2026
@stephanmeesters stephanmeesters force-pushed the chore/dx8wrapper-cleanup branch from 7142e33 to bfa6e67 Compare March 30, 2026 19:12
@xezon xezon changed the title chore(ww3d2): Remove dead code in dx8wrapper chore(dx8wrapper): Remove unused code in dx8wrapper Mar 30, 2026
Copy link
Copy Markdown

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Taking out the trash

@xezon xezon changed the title chore(dx8wrapper): Remove unused code in dx8wrapper chore: Remove unused code in dx8wrapper Mar 30, 2026
@xezon xezon merged commit 90afd63 into TheSuperHackers:main Mar 30, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants