Skip to content

unify(ww3d2): Merge dx8fvf, dx8indexbuffer, dx8vertexbuffer#2690

Merged
xezon merged 9 commits intoTheSuperHackers:mainfrom
stephanmeesters:unify/remaining-dx8-files
May 7, 2026
Merged

unify(ww3d2): Merge dx8fvf, dx8indexbuffer, dx8vertexbuffer#2690
xezon merged 9 commits intoTheSuperHackers:mainfrom
stephanmeesters:unify/remaining-dx8-files

Conversation

@stephanmeesters
Copy link
Copy Markdown

This merges the remaining files starting with dx8.

  • (gen) Failed vertex and index buffer creation now frees old unused textures, flushes the mesh cache, and retries before treating the failure as fatal.
  • (gen) Vertex and index buffers now force software processing when hardware Transform and Lighting support is unavailable.
  • (gen) Renderer memory logging was added around vertex and index buffer allocations.
  • (zh) Dynamic vertex-buffer debug logging was re-enabled.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 6, 2026

Greptile Summary

This PR merges the remaining dx8-prefixed renderer files (dx8fvf, dx8indexbuffer, dx8vertexbuffer) between the Generals and GeneralsMD trees, bringing both codebases to the same revision. The core functional changes are a two-attempt allocation strategy for vertex and index buffers (releasing stale textures and flushing the mesh cache before retrying), software-processing enforcement when hardware T&L is absent, and WWMEMLOG instrumentation throughout.

  • Retry logic (dx8indexbuffer.cpp, dx8vertexbuffer.cpp): On an initial allocation failure, TextureClass::Invalidate_Old_Unused_Textures(5000) and WW3D::_Invalidate_Mesh_Cache() are called before a second CreateIndexBuffer/CreateVertexBuffer attempt; persistent failure is treated as fatal via DX8_ErrorCode.
  • Software T&L fallback: A Support_TnL() guard was added to both index and vertex buffer constructors to force D3DUSAGE_SOFTWAREPROCESSING on hardware that lacks transform-and-lighting support.
  • Logging/cleanup (GeneralsMD/dx8vertexbuffer.cpp): The duplicate software-processing guard was removed and the previously commented-out VERTEX_BUFFER_LOG debug block was re-enabled.

Confidence Score: 5/5

The change is safe to merge; both allocation paths use raw device calls that allow the retry logic to execute correctly, and the fallback to DX8_ErrorCode on persistent failure is intentional and consistent with existing patterns.

The retry-and-fallback logic mirrors the pre-existing vertex buffer pattern and both first/second attempts use direct _Get_D3D_Device8() calls instead of asserting macros, so the retry path is reachable in all build configurations. The only finding is a copy-paste archive path in a comment block in dx8fvf.cpp, which has no runtime impact.

No files require special attention; the comment-level archive path mismatch in dx8fvf.cpp is the only item worth a second look.

Important Files Changed

Filename Overview
Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8fvf.cpp Westwood archive header block added; $Archive path incorrectly reads dx8fvf.h instead of dx8fvf.cpp (copy-paste from the header file).
Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.cpp Added TnL software-processing guard, two-attempt index buffer creation with texture/mesh-cache release on first failure, and WWMEMLOG instrumentation in three allocation sites.
Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.cpp Retry logic updated to release old textures before flushing mesh cache; WWMEMLOG added to constructors and dynamic-buffer allocators; minor debug-log string fixes.
Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.h Header-block metadata updated to reflect the Kenny Mitchell revision; no functional changes.
GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.cpp One-line comment fix: 'Vertex buffer creation failed' corrected to 'Index buffer creation failed' in the retry block.
GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.cpp Duplicate TnL software-processing guard removed; dynamic vertex-buffer debug logging re-enabled by removing surrounding block comments.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Create Index/Vertex Buffer] --> B{Support_TnL?}
    B -- No --> C[Add D3DUSAGE_SOFTWAREPROCESSING]
    B -- Yes --> D[Use current usage_flags]
    C --> D
    D --> E[First CreateBuffer attempt\nraw device call]
    E --> F{SUCCEEDED?}
    F -- Yes --> G[Return success]
    F -- No --> H[WWDEBUG_SAY: creation failed]
    H --> I[Invalidate_Old_Unused_Textures\n5000ms threshold]
    I --> J[_Invalidate_Mesh_Cache]
    J --> K[Second CreateBuffer attempt]
    K --> L{SUCCEEDED?}
    L -- Yes --> M[WWDEBUG_SAY: creation successful / Return]
    L -- No --> N[DX8_ErrorCode - fatal]
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8fvf.cpp:25
The `$Archive` path in the newly added Westwood header block references `dx8fvf.h` instead of `dx8fvf.cpp`. This looks like a copy-paste from the header file's comment block. All other header blocks in this codebase correctly identify the source file.

```suggestion
 *                     $Archive:: /Commando/Code/ww3d2/dx8fvf.cpp                             $*
```

Reviews (3): Last reviewed commit: "Revert createindexbuffer handling to how..." | Re-trigger Greptile

Comment thread Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.cpp Outdated
Comment thread GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.cpp Outdated
@xezon xezon added Gen Relates to Generals ZH Relates to Zero Hour Unify Unifies code between Generals and Zero Hour labels May 7, 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.

It all makes sense.

@xezon xezon merged commit f936bdb into TheSuperHackers:main May 7, 2026
17 checks passed
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 ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants