Skip to content

refactor(ww3d2): Route Clear, Set_Viewport, Set_Gamma via IRenderBackend - #3417

Open
bobtista wants to merge 1 commit into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-clear-viewport-gamma
Open

bobtista wants to merge 1 commit into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-clear-viewport-gamma

Conversation

@bobtista

@bobtista bobtista commented Oct 4, 2026 •

Copy link
Copy Markdown

#2613 put Clear, Set_Viewport and Set_Gamma on IRenderBackend, but only WW3D calls them through it. The other callers still go to DX8Wrapper directly.

Now the remaining callers in Core and Zero Hour go through the backend. CameraClass::Apply and Render2DClass fill a RenderBackendViewport instead of a D3DVIEWPORT8. W3DView calls WW3D::Set_Gamma. W3DDisplay calls the backend directly because it passes uselimit = false, which WW3D::Set_Gamma cannot. The interface does not change. W3DProfilerFrameCapture keeps its two Set_Viewport calls because it drives the D3D device directly.

Todo:

  • Build win32 and vc6, including W3DView and WorldBuilder
  • Load two skirmish saves and the shell map, and open W3DView. 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: d9836b6d-ec7e-4880-8039-78a6dd2c0200
📥 Commits

Reviewing files that changed from the base of the PR and between f8ba7eb and 36a4d21.

📒 Files selected for processing (10)
  • 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/Tools/W3DView/GammaDialog.cpp
  • Core/Tools/W3DView/MainFrm.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; 3 remain after this review.


Walkthrough

Rendering code now routes viewport setup and clear operations through the active render backend. Gamma updates use render-backend or WW3D APIs. Existing viewport dimensions, clear parameters, and gamma arguments remain unchanged.

Changes

Render Backend Integration

Layer / File(s) Summary
Viewport setup
GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
Camera and 2D rendering now set viewports through the active render backend with RenderBackendViewport. The viewport bounds and depth values remain unchanged.
Render-target and scene clears
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp, Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp, Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp, GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp
Render-target, depth, reflection, and scene clears now use the active render backend. The existing clear arguments and clear branches remain unchanged.
Gamma updates
Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp, Core/Tools/W3DView/GammaDialog.cpp, Core/Tools/W3DView/MainFrm.cpp
Gamma updates now use the render backend or WW3D::Set_Gamma instead of DX8Wrapper::Set_Gamma. Existing arguments, scaling, and clamping remain unchanged.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Refactor

Suggested reviewers: xezon

Merge Risk: ⚪ Minimal · up to 36a4d

The rendering calls now use backend-facing APIs without a concrete regression identified in the supplied evidence. No established issue warrants delaying merge.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 36a4d

Existing rendering values and display restrictions are preserved, and no new security issue was established. Whether every caller remains within the rendering lifetime has not been fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected operations affect the existing rendering device's viewport and buffers, with gamma potentially affecting the desktop display. No expansion beyond these existing sinks is established by the dispatch substitutions.

Security Findings and Attack Paths

  • inferred — The inspected gamma path continues to consume values from the existing local dialog and invoke the same downstream gamma implementation. The comparison does not establish a newly reachable attacker-controlled entrypoint, authority gain, or control bypass; this is not an exhaustive security-coverage conclusion.

Trust Boundaries and Controls

  • observed — The game display still refuses gamma changes in windowed mode and preserves its explicit uselimit=false argument. The dialog's 1.0–3.0 value bounds and the wrapper's gamma, brightness, and contrast bounds remain in place.

Resilience and Maintainability Implications

  • inferred — The new dispatch relies on WW3D's active backend, created during initialization and deleted during shutdown. Forwarding preserves existing device operations and thread checks, but the inspected evidence does not establish dialog-event ordering or concurrent access during shutdown and reinitialization. This remains an unresolved lifetime comparison, not a verified vulnerability.
🚥 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 Clear, Set_Viewport, and Set_Gamma calls through IRenderBackend.
Description check ✅ Passed The description explains the follow-up to #2613 and identifies the callers routed through the backend, implementation details, and testing status.
  • 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.

@bobtista
bobtista marked this pull request as ready for review October 4, 2026 16:23
@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Routes rendering backend calls through a new abstraction layer.

The reviewed changes appear safe to merge; no actionable regression was identified.

Summary

The PR routes the changed Core and Zero Hour Clear, viewport, and gamma calls through IRenderBackend.

  • Camera and 2D rendering now construct RenderBackendViewport values.
  • W3DView gamma controls use WW3D::Set_Gamma; display gamma retains its explicit uselimit = false behavior.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Callers[Scenes, cameras, display, and tools] --> WW3D[WW3D backend access]
  WW3D --> Interface[IRenderBackend]
  Interface --> DX8[DX8Backend]
  DX8 --> Wrapper[DX8Wrapper]
  Wrapper --> Device[Direct3D device]
Loading

Reviews (1) · Last reviewed commit: "refactor(ww3d2): Route Clear, Set_Viewpo..."

@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.

This entire PR is logically structured. Had one NIT question about styling and I would love to have answers for these. But I don't think these NIT are a hard blocker. But could repeat in following PRs.

vp.y = (unsigned int)(Viewport.Min.Y * (float)height);
vp.width = (unsigned int)((Viewport.Max.X - Viewport.Min.X) * (float)width);
vp.height = (unsigned int)((Viewport.Max.Y - Viewport.Min.Y) * (float)height);
vp.min_z = ZBufferMin;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is maybe a Nit question. But does this belong there?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is a one-to-one swap of the old D3DVIEWPORT8 fill. Do you mean the struct should have a constructor, or that the viewport setup should live somewhere other than the camera? Or something else?

vp.MaxZ = 1;
DX8Wrapper::Set_Viewport(&vp);
RenderBackendViewport vp;
vp.x = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same as here. This is maybe a Nit question. But does this belong there? I do like this change. But not sure if this is a blocker.

@xezon xezon changed the title refactor(ww3d2): Route Clear, Set_Viewport, Set_Gamma via the backend refactor(ww3d2): Route Clear, Set_Viewport, Set_Gamma via IRenderBackend Oct 5, 2026

@xezon xezon 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.

@xezon xezon added Refactor Edits the code with insignificant behavior changes, is never user facing Rendering Is Rendering related labels Oct 5, 2026
@xezon xezon added this to the Linux support milestone Oct 5, 2026
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.

3 participants