refactor(ww3d2): Simplify dx8wrapper's frame statistics with struct#2507
Merged
xezon merged 8 commits intoTheSuperHackers:mainfrom Apr 1, 2026
Merged
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h | Introduces DX8FrameStatistics struct and replaces 9 individual protected static counters + extern global with a single static struct member; replaces 10 per-field getter declarations with Get_Last_Frame_Statistics() and adds Increment_DX8_CallCount() public helper for macro use. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Defines and zero-initializes the new static FrameStatistics/LastFrameStatistics globals; simplifies Reset_Statistics, Begin_Statistics, End_Statistics; removes 10 per-field getter definitions; replaces number_of_DX8_calls++ with DX8_RECORD_DX8_CALLS() at 5 call sites. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h | Mirror of the Generals header change — identical DX8FrameStatistics struct, macro rewrites, and API surface updates for the Zero Hour expansion. |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Mirror of the Generals .cpp change with one additional DX8_RECORD_DX8_CALLS() substitution in Clear() that exists only in the Zero Hour version. |
Sequence Diagram
sequenceDiagram
participant Caller as External caller / DX8CALL macro
participant DX8W as DX8Wrapper (public API)
participant FS as FrameStatistics (protected static)
participant LFS as LastFrameStatistics (file-static)
Note over Caller,LFS: Per-frame lifecycle
Caller->>DX8W: Begin_Statistics()
DX8W->>FS: FrameStatistics = DX8FrameStatistics() (zero-init)
loop Each D3D call via DX8CALL / DX8_RECORD_*
Caller->>DX8W: Increment_DX8_CallCount()
DX8W->>FS: dx8_calls++
Caller->>DX8W: DX8_RECORD_MATRIX_CHANGE()
DX8W->>FS: matrix_changes++
end
Caller->>DX8W: End_Statistics()
DX8W->>LFS: LastFrameStatistics = FrameStatistics
Caller->>DX8W: Get_Last_Frame_Statistics()
DX8W-->>Caller: const DX8FrameStatistics& (read-only snapshot)
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
Line: 130-131
Comment:
**Macros reference unqualified `FrameStatistics` — context-dependent correctness**
`DX8_RECORD_DX8_CALLS()` and the other `DX8_RECORD_*` macros expand bare `FrameStatistics.xxx++`. In the old code the individual counters (e.g. `matrix_changes`) were also unqualified in macros and used only inside `DX8Wrapper` member functions, so the same scoping constraint already existed. A grep confirms all current call sites remain inside `DX8Wrapper` member functions. This is not a regression, but it is worth noting that if any of these macros are ever invoked from a non-member context the compiler will silently fail to find `FrameStatistics`, turning a policy violation into a build error rather than a subtle bug.
How can I resolve this? If you propose a fix, please make it concise.Reviews (8): Last reviewed commit: "Replicate in Generals" | Re-trigger Greptile
xezon
reviewed
Mar 30, 2026
cd67862 to
c706cd3
Compare
c706cd3 to
e2ff87c
Compare
Caball009
reviewed
Mar 31, 2026
xezon
reviewed
Apr 1, 2026
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.
Todo