Skip to content

refactor(ww3d2): Route device and display queries via IRenderBackend - #3418

Draft
bobtista wants to merge 2 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-device-queries
Draft

bobtista wants to merge 2 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-device-queries

Conversation

@bobtista

@bobtista bobtista commented Oct 4, 2026 •

Copy link
Copy Markdown

Code outside DX8Wrapper reads the device, resolution, windowed state, stencil and back buffer format straight from DX8Wrapper.

Now these queries are const methods on IRenderBackend, and the WW3D wrappers and the remaining callers use them. DX8Backend becomes a friend of DX8Wrapper because the device queries are protected. The back buffer query is named Get_Back_Buffer_Format to match the rest of the interface.

Device creation, resolution changes, device reset, MSAA and the registry calls stay on DX8Wrapper. So does Get_Render_Device_Desc, because RenderDeviceDescClass exposes D3DCAPS8 and D3DADAPTER_IDENTIFIER8. Is_Initted stays as well, because every caller pairs it with Get_Current_Caps.

Todo:

  • Build win32, including W3DView and WorldBuilder
  • Load two skirmish saves and the shell map, open W3DView through its device dialog, and open WorldBuilder. Same result as main
  • Replicate to Generals

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c41c9e65-b801-4866-93f2-bdc93c0da7fc
📥 Commits

Reviewing files that changed from the base of the PR and between f8ba7eb and 9ef857e.

📒 Files selected for processing (19)
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.h
  • Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h
  • Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
  • Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
  • Core/Tools/W3DView/GammaDialog.cpp
  • Core/Tools/W3DView/MainFrm.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.


Walkthrough

The render backend interface now exposes render-device and display queries. DX8Backend forwards those queries to DX8Wrapper. WW3D, rendering code, and W3DView route selected queries and operations through the active backend or WW3D.

Changes

Render backend routing

Layer / File(s) Summary
Add backend query contract and DX8 forwarding
Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h, Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.*, Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.h
The interface adds render-device and display queries. DX8Backend forwards them to DX8Wrapper.
Route WW3D queries through the backend
Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
WW3D retrieves device, display, resolution, swap interval, and texture bit-depth values through the render backend.
Route viewport and scene operations through the backend
GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/{camera.cpp,render2d.cpp,scene.cpp}
Camera and 2D rendering submit viewports through the backend. The extra-pass scene path clears color through the backend.
Route game rendering operations through the backend
Core/GameEngineDevice/Source/W3DDevice/GameClient/*, GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/{Shadow/W3DVolumetricShadow.cpp,W3DScene.cpp}
Game rendering paths use the backend for buffer-format and stencil queries, clears, and gamma updates. Existing conditions and clear parameters remain unchanged.
Route W3DView gamma controls through WW3D
Core/Tools/W3DView/{GammaDialog.cpp,MainFrm.cpp}
W3DView applies gamma through WW3D. Existing values and clamping remain unchanged.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested reviewers: xezon

Merge Risk: ⚪ Minimal · up to 9ef85

No actionable issue is established in the changed rendering paths. The remaining smoke tests can proceed as normal validation.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 9ef85

The interface refactor preserves the inspected operations and their authority. No introduced security issue was established, but incomplete coverage and outstanding runtime validation limit confidence.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected operations affect the application’s rendering device and display state. Gamma’s existing fallback can affect the desktop display, but the refactor preserves that sink and its caller inputs rather than introducing broader authority.

Trust Boundaries and Controls

  • observed — The factory selects DX8Backend directly, with no attacker-controlled backend choice in the inspected path. WW3D creates and owns the backend during initialization and deletes it during shutdown. Routed callers therefore depend on the documented initialization-to-shutdown lifecycle.

Resilience and Maintainability Implications

  • observed — The adapters preserve existing containment controls: clear retains its render-thread assertion and stencil-surface check, while gamma retains its input bounds and display-context release. Routing adds no synchronization, transaction or interruption-recovery mechanism; those guarantees remain with the existing implementation.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: routing WW3D2 device and display queries through IRenderBackend.
Description check ✅ Passed The description explains the query-routing changes, retained DX8Wrapper responsibilities, and validation status. It is directly related to the changeset.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mirelle7 mirelle7 added Refactor Edits the code with insignificant behavior changes, is never user facing Rendering Is Rendering related labels Oct 5, 2026
@mirelle7 mirelle7 added this to the Multi platform support milestone Oct 5, 2026

@mirelle7 mirelle7 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good.

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 Rendering Is Rendering related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants