Skip to content

refactor(ww3d2): Route blend state via Renderer - #3705

Draft
bobtista wants to merge 19 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-blend-state
Draft

bobtista wants to merge 19 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/refactor/route-blend-state

Conversation

@bobtista

Copy link
Copy Markdown

Follow up for #2613
Merge after #3700

This change routes the blend state set by game code through Renderer.

Renderer gets Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op. Source and destination factors are set in one call. The backend translates RenderBlend and RenderBlendOp to the D3D8 values explicitly.

Routed call sites are the stenciled player color pass in W3DScene and the script fade in W3DStatusCircle. The calls and values are the same as before.

Blend states in the shader manager, terrain, water and shadows are left for the effect pass changes. ShaderClass::Apply stays in WW3D2.

Golden Replay #1 is pixel identical to #3700 at 120, 150 and 180 seconds.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request expands the Renderer interface, adds DX8Backend implementations, and migrates rendering operations and capability checks from DX8Wrapper to Renderer across WW3D, game-client, and tool code. Existing rendering conditions, arguments, and selected direct DX8 operations remain.

Changes

Renderer interface and backend

Layer / File(s) Summary
Renderer contract and DX8 backend
Core/Libraries/Source/WWVegas/WW3D2/Renderer.h, Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
Renderer adds capability queries and methods for render targets, render state, buffers, drawing, texture transforms, lights, and fog. DX8Backend forwards these operations to DX8Wrapper and maps blend values.
Capability checks and render targets
Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp, Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp, Core/Libraries/Source/WWVegas/WW3D2/{texture*,textureloader.cpp,ww3dformat.cpp,meshmdl.cpp,statistics.cpp,meshmatdesc.cpp}, Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp, Generals*/Code/Tools/WorldBuilder/src/ObjectPreview.cpp
Texture-format and feature checks now call Renderer. Render-target setup and restoration in texture projection and WorldBuilder previews now use Renderer. Existing format fallback sequences remain.
WW3D rendering and scene paths
Core/Libraries/Source/WWVegas/WW3D2/*, Generals/Code/Libraries/Source/WWVegas/WW3D2/{dazzle.cpp,decalmsh.cpp}, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/{dazzle.cpp,decalmsh.cpp,linegrp.cpp,scene.cpp}
Geometry, material, mapper, decal, particle, and scene paths use Renderer for applicable state, buffer, and draw operations. Existing sorting paths remain in place.
Terrain, weather, and water rendering
Core/GameEngineDevice/Source/W3DDevice/GameClient/{BaseHeightMap.cpp,FlatHeightMap.cpp,HeightMap.cpp,W3D*.cpp,Water/*}
Terrain, weather, shoreline, and water paths use Renderer for supported state, buffer, texture, and draw operations. Direct DX8 operations that were not changed remain.
Game-client effects and scene rendering
Generals*/Code/GameEngineDevice/Source/W3DDevice/GameClient/{Shadow/*,W3D*.cpp}
Shadow, bridge, road, bib, status-circle, UI, and scene paths use Renderer for the changed rendering operations. Existing draw branches and arguments remain.
Editor and view rendering
Core/Tools/W3DView/ScreenCursor.cpp, Generals*/Code/Tools/WorldBuilder/src/{DrawObject.cpp,ObjectPreview.cpp}
WorldBuilder drawing and preview paths, plus W3DView cursor rendering, use Renderer for applicable state, buffer, render-target, and draw operations.

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

Change: Refactor

Suggested reviewers: xezon, stephanmeesters

Merge Risk: Minimal · up to e5b39

This refactor routes rendering state, buffer, draw, and capability calls through Renderer while keeping the same arguments and conditions. No concrete regression was found, and the author reports pixel-identical replay output. The change appears safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the refactor that routes blend state through Renderer. The changeset adds Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op to Renderer, along with the RenderBlend and RenderB…
Description check Passed The description states that the PR routes game-code blend state through Renderer. It names the new Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op methods and the affected call sites in W3D…
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.
Full details: Title check

Explanation

The title names the refactor that routes blend state through Renderer. The changeset adds Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op to Renderer, along with the RenderBlend and RenderBlendOp enums. The title is specific and matches the main change, although the raw summary also covers many unrelated Renderer routing changes.

Full details: Description check

Explanation

The description states that the PR routes game-code blend state through Renderer. It names the new Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op methods and the affected call sites in W3DScene and W3DStatusCircle. It is on-topic and specific to the changeset.

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e3bc493f-d4fa-4405-a23f-70d33fbe6df3
Commits

Reviewing files that changed from the base of the PR and between 1f876ba and e5b390b.

Files selected for processing: 71

  • Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp
  • 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/W3DDebugIcons.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DScorch.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainParticles.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/Renderer.h
  • Core/Libraries/Source/WWVegas/WW3D2/boxrobj.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h
  • Core/Libraries/Source/WWVegas/WW3D2/dx8renderer.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/line3d.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/mapper.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/matpass.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/matrixmapper.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/mesh.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/texture.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/textureloader.cpp
  • Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp
  • Core/Tools/W3DView/ScreenCursor.cpp
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBibBuffer.cpp
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp
  • Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DStatusCircle.cpp
  • Generals/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp
  • Generals/Code/Libraries/Source/WWVegas/WW3D2/decalmsh.cpp
  • Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp
  • Generals/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
  • Generals/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp
  • Generals/Code/Tools/WorldBuilder/src/DrawObject.cpp
  • Generals/Code/Tools/WorldBuilder/src/ObjectPreview.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBibBuffer.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DRoadBuffer.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp
  • GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DStatusCircle.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dazzle.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/decalmsh.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/linegrp.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/render2d.cpp
  • GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/scene.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/DrawObject.cpp
  • GeneralsMD/Code/Tools/WorldBuilder/src/ObjectPreview.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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant