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/dx8caps.cpp | Large merge introducing Check_Driver_Version_Status(), new DX8Caps constructor, expanded Compute_Caps(), and vendor-specific hacks; contains a fall-through switch bug in Elsa OEM driver handling and single-line if statements violating style rules |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.h | Extends DX8Caps with new accessors (ZBias, anisotropic, cubemap, fog, multi-pass), new constructor, and replaces hwVPCaps/swVPCaps with a single unified Caps member; clean refactor with no apparent issues |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Major merge adding multi-stream vertex buffer support, improved device creation with 16-bit z-buffer fallback, OOM texture recovery, SHD init/shutdown hooks, and enhanced per-device enumeration filtering via DX8Caps |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h | Extends RenderStateStruct to use vertex_buffers[MAX_VERTEX_STREAMS] arrays, adds Set_Projection_Transform_With_Z_Bias(), updates RenderStateStruct constructor/destructor/operator= to handle multi-stream buffers correctly |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/shdlib.h | New stub header wrapping WWShade library macros behind USE_WWSHADE guard; no-ops all SHD_* macros when the library is absent; copyright attribution uses EA instead of TheSuperHackers for this newly-created community file |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp | Updated to use vertex_buffers[0] instead of single vertex_buffer, adds WWPROFILE instrumentation, promotes DEFAULT_SORTING_* globals to static, and removes obsolete commented-out code |
| Generals/Code/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt | Adds shdlib.h to the WW3D2 source list; minimal, correct change |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.cpp | Trivial brace alignment fix in Vendor_Specific_Hacks for the NVIDIA block; no functional change |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp | Cleans up a commented-out early-exit check and removes stale commented-out code in Registry_Load_Render_Device; no functional change |
| GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h | Removes commented-out lightsHash member and its initialiser; cosmetic-only cleanup |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[DX8Wrapper::Enumerate_Devices] --> B[GetDeviceCaps + GetAdapterIdentifier]
B --> C[DX8Caps constructor\ncaps + adapter_id]
C --> D[Compute_Caps]
D --> D1[Check_Driver_Version_Status]
D --> D2[Check_Texture_Format_Support]
D --> D3[Check_Shader_Support]
D --> D4[Vendor_Specific_Hacks]
D1 --> E{Is_Valid_Display_Format}
E -->|Invalid resolution| F[bits = 0, skip mode]
E -->|Valid resolution| G[Add to device description]
G --> H{Any valid resolutions?}
H -->|Yes| I[Add device to table]
H -->|No| J[Skip device]
K[DX8Wrapper::Create_Device] --> L{HW T&L?}
L -->|Yes| M[MIXED_VERTEXPROCESSING]
L -->|No| N[SOFTWARE_VERTEXPROCESSING]
M & N --> O[CreateDevice]
O -->|Fail: 16bit display + 32bit z-buf| P[Retry with D3DFMT_D16]
P --> Q{Success?}
Q -->|Yes| R[Device ready]
Q -->|No| S[Return false]
O -->|Success| R
R --> T[Do_Onetime_Device_Dependent_Inits]
T --> U[SHD_INIT]
T --> V[VertexMaterial init]
T --> W[BoxRenderObj init]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8caps.cpp
Line: 910-924
Comment:
**Fall-through makes `default:` always produce `DRIVER_STATUS_OK`**
Both the `egdad.dll` and `egliid.dll` switch statements have their `default:` case fall through directly into the matching `case N:` label because there is no `break` after the default assignment. As a result, any build version _other_ than 312 (or 172) first writes `DRIVER_STATUS_UNKNOWN` and then immediately overwrites it with `DRIVER_STATUS_OK`, so every unknown Elsa driver version is silently treated as known-good rather than unknown.
```cpp
// egdad.dll block (lines 909–914)
switch (DriverBuildVersion) {
default:
DriverVersionStatus=DRIVER_STATUS_UNKNOWN;
break; // ← add break here
case 312:
DriverVersionStatus=DRIVER_STATUS_OK;
}
```
```cpp
// egliid.dll block (lines 919–924)
switch (DriverBuildVersion) {
default:
DriverVersionStatus=DRIVER_STATUS_UNKNOWN;
break; // ← add break here
case 172:
DriverVersionStatus=DRIVER_STATUS_OK;
}
```
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:
**Wrong copyright owner for a newly-created community file**
`shdlib.h` is a new file added by the community (it was not present in the initial commit `3d0ee53`). Per the project copyright policy, only files that ship directly from the original EA source tree should retain `"Copyright YYYY Electronic Arts Inc."`. Newly created community files should use `"Copyright YYYY TheSuperHackers"` instead.
```suggestion
** Copyright 2025 TheSuperHackers
```
**Rule Used:** Files from the original EA source code (present in... ([source](https://app.greptile.com/review/custom-context?memory=078076ac-7c7f-4011-8c1c-51bcca514292))
**Learnt From**
[TheSuperHackers/GeneralsGameCode#2153](https://github.com/TheSuperHackers/GeneralsGameCode/pull/2153#discussion_r2714609291)
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/dx8caps.cpp
Line: 559
Comment:
**Statement body on same line as condition**
Newly added code should place the if-body on a separate line to allow precise debugger breakpoint placement. The same pattern also appears in `Is_Valid_Display_Format` at lines 996 and 998.
```suggestion
if (DriverDLL[0]=='3')
VendorId=VENDOR_3DFX;
```
Lines 996–998 similarly need splitting:
```cpp
if (MaxDisplayWidth==0 && MaxDisplayHeight==0)
return true;
if (width>MaxDisplayWidth || height>MaxDisplayHeight)
return false;
```
**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.Reviews (6): Last reviewed commit: "Additional commented out code cleanup" | 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 |
|
Needs a rebase |
90a2fc0 to
bf0c95f
Compare
bf0c95f to
f950660
Compare
Done |
| IDirect3DSurface8* depthbuffer; | ||
|
|
||
| _Get_D3D_Device8()->GetDepthStencilSurface(&depthbuffer); |
There was a problem hiding this comment.
Uninitialized pointer read if
GetDepthStencilSurface fails
depthbuffer is declared uninitialized. If GetDepthStencilSurface returns a failure HRESULT (e.g., device lost), the pointer is never written and the if (depthbuffer) check on the next few lines reads an indeterminate value — undefined behaviour. Initialise to nullptr to make the null-check safe in all paths.
| IDirect3DSurface8* depthbuffer; | |
| _Get_D3D_Device8()->GetDepthStencilSurface(&depthbuffer); | |
| IDirect3DSurface8* depthbuffer = nullptr; | |
| _Get_D3D_Device8()->GetDepthStencilSurface(&depthbuffer); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp
Line: 1795-1797
Comment:
**Uninitialized pointer read if `GetDepthStencilSurface` fails**
`depthbuffer` is declared uninitialized. If `GetDepthStencilSurface` returns a failure HRESULT (e.g., device lost), the pointer is never written and the `if (depthbuffer)` check on the next few lines reads an indeterminate value — undefined behaviour. Initialise to `nullptr` to make the null-check safe in all paths.
```suggestion
IDirect3DSurface8* depthbuffer = nullptr;
_Get_D3D_Device8()->GetDepthStencilSurface(&depthbuffer);
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Would be good to fix that.
Made an issue for this and other potential issues #2530
| return; | ||
| } | ||
| */ | ||
| // if (material==render_state.material) { |
There was a problem hiding this comment.
Why is this commented out now? do we not want this check?
There was a problem hiding this comment.
I think this was removed in ZH because a material can be modified potentially, and this check will not pick up on that. In the code above they tried using CRC to pick up on material changes apparently it didn't work. I think it's worth investigating later. I could add a todo note?
26e940a to
fc44175
Compare
Merged by hand using WinMerge.