unify(ww3d2): Merge dx8wrapper, dx8caps, shdlib#2499
unify(ww3d2): Merge dx8wrapper, dx8caps, shdlib#2499stephanmeesters wants to merge 12 commits intoTheSuperHackers:mainfrom
Conversation
0b27872 to
90a2fc0
Compare
|
| Filename | Overview |
|---|---|
| Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt | Adds shdlib.h to the WW3D2 source list; trivial one-line change with no issues. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/shdlib.h | New header providing no-op macros when USE_WWSHADE is not defined; has wrong product name ("Zero Hour" instead of "Generals") and a stale copyright year (2025 instead of 2026) in its prologue. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h | Adds new constructor overload, several capability accessors (ZBias, cubemap, multi-pass, fog), driver version status accessor, and log getters; collapses hwVPCaps/swVPCaps into a single Caps member. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.cpp | Major expansion: adds DXLOG/COMPACTLOG macros for diagnostic logging, a full Check_Driver_Version_Status() function with per-vendor/per-build blacklists, Is_Valid_Display_Format(), and extensive vendor-specific hacks (NVidia, ATI, 3DFX, PowerVR, S3, Matrox, VMware). |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h | Expands RenderStateStruct from single vertex_buffer to vertex_buffers[MAX_VERTEX_STREAMS], adds Set_DX8_ZBias/Set_Projection_Transform_With_Z_Bias inline implementations, and introduces the flimby hash function (dead code, call site is commented out). Minor style violations: for-loop bodies on the same line as conditions. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Large merge: multi-stream vertex buffer support, SHD_INIT/SHUTDOWN lifecycle hooks, smarter D3DERR_OUTOFVIDEOMEMORY recovery with asset invalidation, dynamic depth-stencil detection in Clear(), device enumeration improvements (filter zero-resolution devices), and fallback resolution logic in Registry_Load_Render_Device. Misleading swapped comments in Set_Any_Render_Device and minor if-body-on-same-line style violations. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp | Minor: adds commented-out ZBias calls between render passes and a blank line; no functional change. |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp | Updates vertex_buffer to vertex_buffers[0] accesses to match new multi-stream struct, adds WWPROFILE instrumentation in Flush(), includes wwprofile.h and algorithm, and removes dead commented-out Apply() calls. |
Sequence Diagram
sequenceDiagram
participant App
participant DX8Wrapper
participant DX8Caps
participant D3D as Direct3D8
App->>DX8Wrapper: Enumerate_Devices()
DX8Wrapper->>D3D: GetDeviceCaps(adapter, caps)
DX8Wrapper->>D3D: GetAdapterIdentifier(adapter, id)
DX8Wrapper->>DX8Caps: DX8Caps(d3d, caps, format, id)
DX8Caps->>DX8Caps: Compute_Caps()
DX8Caps->>DX8Caps: Check_Driver_Version_Status()
DX8Caps->>DX8Caps: Vendor_Specific_Hacks()
DX8Wrapper->>DX8Caps: Is_Valid_Display_Format(w, h, fmt)
DX8Caps-->>DX8Wrapper: valid?
DX8Wrapper-->>App: filtered RenderDeviceDescriptionTable
App->>DX8Wrapper: Set_Render_Device(dev, w, h, bits, windowed)
DX8Wrapper->>D3D: CreateDevice(...)
alt 16/32-bit depth mismatch
DX8Wrapper->>D3D: retry with D3DFMT_D16
end
DX8Wrapper->>DX8Wrapper: SHD_INIT
App->>DX8Wrapper: Set_Vertex_Buffer(vb, stream)
DX8Wrapper->>DX8Wrapper: update vertex_buffers[stream]
App->>DX8Wrapper: Clear(color, z, ...)
DX8Wrapper->>D3D: GetDepthStencilSurface()
D3D-->>DX8Wrapper: depthbuffer
DX8Wrapper->>DX8Wrapper: detect stencil from desc.Format
DX8Wrapper->>D3D: Clear(flags)
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Generals/Code/Libraries/Source/WWVegas/WW3D2/shdlib.h
Line: 2
Comment:
**Wrong product name for Generals/ directory**
This file is located in `Generals/Code/...`, but the GPL header uses `"Command & Conquer Generals Zero Hour(tm)"`. Per project convention, files in `Generals/` must use `"Command & Conquer Generals(tm)"`, while `"Generals Zero Hour(tm)"` is reserved for files under `GeneralsMD/`.
```suggestion
** Command & Conquer Generals(tm)
```
**Rule Used:** Files in the Generals/ directory should use "Comma... ([source](https://app.greptile.com/review/custom-context?memory=c6b666fd-7852-40bc-a9fe-5fe48cd58769))
**Learnt From**
[TheSuperHackers/GeneralsGameCode#2153](https://github.com/TheSuperHackers/GeneralsGameCode/pull/2153#discussion_r2714608924)
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: Generals/Code/Libraries/Source/WWVegas/WW3D2/shdlib.h
Line: 3
Comment:
**Copyright year 2025 is prior to current year (2026)**
The comment references year `2025`, which is behind the current year. Please update to `2026`.
```suggestion
** Copyright 2026 Electronic Arts Inc.
```
**Rule Used:** What: Flag newly created code comments that refere... ([source](https://app.greptile.com/review/custom-context?memory=fd72a556-4fd8-4db4-8b08-8e51516a64ad))
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
Line: 1396-1397
Comment:
**Loop bodies should be on separate lines from conditions**
Both `for` loop bodies are on the same line as their conditions. Per the project style rule, loop/condition bodies must be on the next line to allow precise debugger breakpoint placement. The same pattern also appears in the new code at:
- `dx8wrapper.cpp:499` — `if (render_state.vertex_buffers[i]) render_state.vertex_buffers[i]->Release_Engine_Ref();`
- `dx8wrapper.cpp:722` — same pattern, inside `Release_Device()`
- `dx8caps.cpp:559` — `if (DriverDLL[0]=='3') VendorId=VENDOR_3DFX;`
```suggestion
for (i=0;i<MAX_VERTEX_STREAMS;++i) {
vertex_buffers[i]=0;
}
for (i=0;i<MAX_TEXTURE_STAGES;++i) {
Textures[i]=0;
}
```
**Rule Used:** Always place if/else/for/while statement bodies on... ([source](https://app.greptile.com/review/custom-context?memory=16b9b669-b823-49be-ba5b-2bd30ff3ba6d))
**Learnt From**
[TheSuperHackers/GeneralsGameCode#2067](https://github.com/TheSuperHackers/GeneralsGameCode/pull/2067#discussion_r2706274626)
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
Line: 836-849
Comment:
**Comments are reversed relative to actual loop order**
The PR swapped the loop bodies (fullscreen now first, windowed second) but the comments came from the old code and were placed on the wrong loops:
- Line 836: `// Then fullscreen` — but this is the **first** loop tried (windowed=`0` → fullscreen). "Then" implies it's secondary.
- Line 844: `// Try windowed first` — but this is the **second** loop tried (windowed=`1` → windowed). "first" is now misleading.
The comments should reflect the new intent:
```suggestion
// Try fullscreen first
int dev_number = 0;
for (; dev_number < _RenderDeviceNameTable.Count(); dev_number++) {
if (Set_Render_Device(dev_number,-1,-1,-1,0,false)) {
return true;
}
}
// Then windowed as fallback
for (dev_number = 0; dev_number < _RenderDeviceNameTable.Count(); dev_number++) {
if (Set_Render_Device(dev_number,-1,-1,-1,1,false)) {
return true;
}
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (2): Last reviewed commit: "unify(dx8wrapper): Merge unnecessary for..." | Re-trigger Greptile
|
This could probably do with a prior chore PR to cleanup the dead code, commented out stuff and remove dead defines that are unused like the xbox related stuff. |
Sounds like a good idea, I’ll do that soon |
Merged by hand using WinMerge.
I didn't make any decision about dead code and merged that along too, noted in commit messages