Skip to content

refactor(ww3d2): Route shader and material state via Renderer - #3421

Open
bobtista wants to merge 5 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-shader-material
Open

bobtista wants to merge 5 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-shader-material

Conversation

@bobtista

@bobtista bobtista commented Oct 4, 2026 •

Copy link
Copy Markdown

Now Set_Shader, Set_Material and Apply_Render_State_Changes are on Renderer, and the remaining Invalidate_Cached_Render_States callers use the existing method. DX8Backend.cpp forwards each one to DX8Wrapper. This includes callers in the DX8 renderer classes, which are shared code and need the backend for anything other than DX8.

Many of these functions still set texture stage and render state through DX8Wrapper right after the routed calls. Those calls stay as they are.

Zero Hour save at 60 seconds on top, Generals shell map below. Before on the left, after on the right.

pr3421

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 →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

This change adds a static Renderer interface with a DX8 forwarding implementation. It removes the previous backend interface and migrates selected rendering operations across WW3D2, game rendering, and tools to Renderer. The render-to-texture setup also rejects multisampled targets and releases resources if switching to a render texture fails.

Changes

Renderer interface and lifecycle

Layer / File(s) Summary
Renderer contract, DX8 forwarding, and WW3D lifecycle
Core/Libraries/Source/WWVegas/WW3D2/Renderer.h, Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp, Core/Libraries/Source/WWVegas/WW3D2/Backend/*, Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h, Core/Libraries/Source/WWVegas/WW3D2/ww3d.*, Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt
Renderer defines rendering operations and forwards them to DX8Wrapper. WW3D delegates lifecycle, device queries, frame operations, and gamma handling to Renderer. The previous backend interface, factory, and accessor are removed.
WW3D2 and camera/render utilities
Core/Libraries/Source/WWVegas/WW3D2/*, Generals/Code/Libraries/Source/WWVegas/WW3D2/*, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/*
Selected material, shader, transform, viewport, lighting, and render-state operations use Renderer; texture, buffer, and draw operations remain on DX8Wrapper where noted.
Game rendering call sites
Core/GameEngineDevice/Source/W3DDevice/GameClient/*, Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/*, Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/*, GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/*
Terrain, water, scene, shadow, and other game rendering paths use Renderer for selected state, transform, format and stencil queries, clears, and lighting operations.
Application and tool call sites
Core/Tools/W3DView/*, GeneralsMD/Code/Tools/WorldBuilder/src/DrawObject.cpp
W3DView applies gamma through WW3D::Set_Gamma and uses Renderer for cursor setup. WorldBuilder uses Renderer for render state, material, shader, and transform operations.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Refactor

Suggested reviewers: cryotherenegade

Merge Risk: Minimal · previous review 50974

This refactor moves rendering calls behind a new Renderer interface, and initialization, shutdown, viewport and projection behavior match the previous code. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

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 names the main change: shader and material state are routed through the new Renderer interface in WW3D2. The raw summary confirms Renderer.h adds Set_Shader, Set_Material, and Apply_Render_S…
Description check Passed The description is related to the changeset. It states that Set_Shader, Set_Material, and Apply_Render_State_Changes move to Renderer, that DX8Backend.cpp forwards these calls to DX8Wrapper, and that …
Full details: Title check

Explanation

The title names the main change: shader and material state are routed through the new Renderer interface in WW3D2. The raw summary confirms Renderer.h adds Set_Shader, Set_Material, and Apply_Render_State_Changes, and that many GameClient and WW3D2 files switch from DX8Wrapper to Renderer. The title is specific and matches the changeset, though it omits the removal of the IRenderBackend layer and the Generals replication.

Full details: Description check

Explanation

The description is related to the changeset. It states that Set_Shader, Set_Material, and Apply_Render_State_Changes move to Renderer, that DX8Backend.cpp forwards these calls to DX8Wrapper, and that texture-stage and render-state calls stay on DX8Wrapper. It also includes build and test notes and a Generals replication checklist item. It matches the file summaries.

ℹ️ Recent review info

⚙️ Run configuration

  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: daf78e4e-749a-4d7c-9452-02bb319045cf
📥 Commits

Reviewing files that changed from the base of the PR and between 4afd60dfc3d3ea1c6f705ecc775f7f9c9e705703 and 50974fd3fed2b0ddc6d8e1523a24ff21f619bb3d.

📒 Files selected for processing (7)

  • Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Renderer.h
  • Core/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
  • Generals/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp
  • Generals/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/camera.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp

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

@bobtista
bobtista force-pushed the bobtista/refactor/route-shader-material branch from 49697d3 to 4afd60d Compare October 9, 2026 15:49
@bobtista bobtista changed the title refactor(ww3d2): Route shader and material state via IRenderBackend refactor(ww3d2): Route shader and material state via Renderer Oct 9, 2026
@bobtista
bobtista force-pushed the bobtista/refactor/route-shader-material branch 3 times, most recently from d0b9943 to 1fac15e Compare October 11, 2026 06:41
@bobtista
bobtista force-pushed the bobtista/refactor/route-shader-material branch 2 times, most recently from a2fa516 to 8c35ce1 Compare October 24, 2026 16:40
@bobtista
bobtista force-pushed the bobtista/refactor/route-shader-material branch from 8c35ce1 to f199b80 Compare October 28, 2026 18:06
@bobtista
bobtista force-pushed the bobtista/refactor/route-shader-material branch 2 times, most recently from a5d1f21 to 0131536 Compare November 14, 2026 12:17
@bobtista
bobtista force-pushed the bobtista/refactor/route-shader-material branch 2 times, most recently from 8217c3d to 2262bf0 Compare November 18, 2026 01:36
@bobtista
bobtista marked this pull request as ready for review November 18, 2026 20:57
@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The routing change reaches shared rendering paths in both games and their graphics tools.

The rendering changes appear sound, but the remaining brace-rule violation must be fixed before merging.

Findings

  1. P2 Conditional bodies remain inline. ▶

Summary

The PR routes shader, material, lighting, fog, and cached render state calls through Renderer while keeping the DX8 behavior unchanged.

  • Shared drawing code sends shader and material state through the renderer.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Games and tools] --> B[Renderer]
    C[Shared drawing code] --> B
    B --> D[DX8Backend]
    D --> E[DX8Wrapper]
    A -->|Texture and device state calls remain direct| E
Loading

Reviews (2) · Last reviewed commit: "refactor(ww3d2): Route shader and materi..." · Reviewed by Greptile

Comment on lines +389 to +390
if (material_changed) Renderer::Set_Material(material_array[tris[next_tri_idx].I]);
if (shader_changed) Renderer::Set_Shader(shader_array[next_tri_idx]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Conditional bodies remain inline. These two modified statements violate the repository rule that executable conditional bodies must start on a separate line. Move each Renderer call below its if, keeping the existing indentation and leaving out braces. This lets developers place separate breakpoints on the condition and the call.

Suggested change
if (material_changed) Renderer::Set_Material(material_array[tris[next_tri_idx].I]);
if (shader_changed) Renderer::Set_Shader(shader_array[next_tri_idx]);
if (material_changed)
Renderer::Set_Material(material_array[tris[next_tri_idx].I]);
if (shader_changed)
Renderer::Set_Shader(shader_array[next_tri_idx]);

Rule Used: Always place the body of if, else, else if, for, and while statements on a separate source line from the control-flow statement. Rules: - Never place an executable statement on the same line as its controlling condition or else keywo... (source)

Learned From
TheSuperHackers/GeneralsGameCode#2067

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@bobtista
bobtista force-pushed the bobtista/refactor/route-shader-material branch from 2262bf0 to 72d9435 Compare November 19, 2026 17:23
@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing Rendering Is Rendering related labels Nov 19, 2026
@xezon

xezon commented Nov 19, 2026

Copy link
Copy Markdown

This branch contains refactor(ww3d2): Route terrain particle shader and material state via Renderer

Is it meant to be here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing Rendering Is Rendering related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants