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

@bobtista bobtista commented Nov 20, 2026 •

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.

The single-factor blend sets in river water, trapezoid water edge feathering and the force-multiply path in DX8TextureCategoryClass::Render now set both factors. The other factor is the one already applied by the preceding shader. Other 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 →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The PR expands Renderer with capability, state, buffer, draw, transform, blend, and render-target APIs, implements them in DX8Backend, and migrates rendering and capability checks across WW3D, game-client, and editor code. Existing conditions and draw arguments are generally retained; selected direct DX8 state operations remain.

Changes

Renderer interface migration

Layer / File(s) Summary
Renderer contract and DX8 backend
Core/Libraries/Source/Lib/Include/Lib/BaseFunctions.h, Core/Libraries/Source/WWVegas/WW3D2/Renderer.h, Core/Libraries/Source/WWVegas/WW3D2/Backend/DX8Backend.cpp
Renderer adds capability queries and rendering operations. DX8Backend forwards these operations to DX8Wrapper, maps blend values, and checks draw arguments with the added check_cast template.
Capability checks, texture formats, and transforms
Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp, Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp, Core/Libraries/Source/WWVegas/WW3D2/{statistics.cpp,mapper.cpp,matrixmapper.cpp,matpass.cpp,mesh.cpp,meshmdl.cpp,texture.cpp,textureloader.cpp,ww3dformat.cpp,texproject.cpp}, Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp, GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmatdesc.cpp
Capability checks and texture-format selection use Renderer APIs. Texture mappers submit transforms through Renderer, and render-target selection uses Renderer methods.
WW3D geometry and 2D rendering
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,render2d.cpp}
Geometry, mesh, particle, decal, line, dazzle, sorting, and 2D rendering paths route the changed state, buffer, and draw operations through Renderer. Sorting paths remain in place.
Terrain, effects, and water rendering
Core/GameEngineDevice/Source/W3DDevice/GameClient/{BaseHeightMap.cpp,FlatHeightMap.cpp,HeightMap.cpp,W3DDebugIcons.cpp,W3DScorch.cpp,W3DShaderManager.cpp,W3DSmudge.cpp,W3DSnow.cpp,W3DTerrainBackground.cpp,W3DTerrainParticles.cpp,W3DTerrainTracks.cpp,W3DTreeBuffer.cpp}, Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/*
Terrain, weather, effects, shader, shoreline, and water paths use Renderer for the changed rendering operations. Unchanged direct DX8 operations remain.
Generals game-client rendering
Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/{Shadow/*,W3DBibBuffer.cpp,W3DBridgeBuffer.cpp,W3DInGameUI.cpp,W3DRoadBuffer.cpp,W3DScene.cpp,W3DStatusCircle.cpp}, GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/{Shadow/*,W3DBibBuffer.cpp,W3DBridgeBuffer.cpp,W3DInGameUI.cpp,W3DRoadBuffer.cpp,W3DScene.cpp,W3DStatusCircle.cpp}
Shadow, bridge, road, bib, UI, scene, and status-circle paths use Renderer for the changed rendering operations. Existing draw branches and parameters remain.
WorldBuilder, preview, and debug updates
Generals/Code/Tools/WorldBuilder/src/{DrawObject.cpp,ObjectPreview.cpp}, GeneralsMD/Code/Tools/WorldBuilder/src/{DrawObject.cpp,ObjectPreview.cpp}, Core/Tools/W3DView/ScreenCursor.cpp, Core/Tools/Autorun/GameText.cpp
WorldBuilder drawing and preview paths and W3DView cursor rendering use Renderer. GameText.cpp clears existing debug macro definitions before defining DEBUG_LOG as a no-op.

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

Change: Refactor

Suggested reviewers: xezon, stephanmeesters

Merge Risk: Minimal · up to 9e9e3

This refactor routes rendering state, buffer, draw, capability and blend-state calls through Renderer, with the DX8 backend forwarding to the same underlying operations. No concrete behavior regression was established, and the previously raised concerns are narrow or unreachable in the inspected source. It looks safe to merge, with the usual build and replay validation.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: blend state from game code is routed through Renderer. The changeset adds Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op to Renderer.h and DX8Backend.cpp, …
Description check Passed The description is related to the changeset. It states that game-code blend state now routes through Renderer, names the added Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op methods, lists…
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 main change: blend state from game code is routed through Renderer. The changeset adds Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op to Renderer.h and DX8Backend.cpp, and the call sites in W3DScene, W3DStatusCircle and related water and texture code use them. The title is concise and specific, though the changeset also contains many non-blend routing changes.

Full details: Description check

Explanation

The description is related to the changeset. It states that game-code blend state now routes through Renderer, names the added Set_Alpha_Blend_Enable, Set_Blend_Factors and Set_Blend_Op methods, lists the routed call sites in W3DScene and W3DStatusCircle, and notes the water and force-multiply factor changes.

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: 5076b641-9616-4aca-929e-62e8f1896df6
Commits

Reviewing files that changed from the base of the PR and between 5028a80 and 9e9e3a4.

Files selected for processing: 39

  • 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/Water/W3DWater.cpp
  • Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp
  • Core/Libraries/Source/Lib/Include/Lib/BaseFunctions.h
  • 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/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/Autorun/GameText.cpp
  • Core/Tools/W3DView/ScreenCursor.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
  • 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

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

static void Apply_Render_State_Changes();

static void Set_Alpha_Blend_Enable(bool enable);
static void Set_Blend_Factors(RenderBlend src, RenderBlend dest);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are source and dest always set in pairs? There is no use case ever for setting just one?

@bobtista bobtista Nov 22, 2026 •

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.

Ok so yes and no. Yes for every site in this PR, both are set. Outside it, W3DWater river blending and the dx8renderer force-multiply path set only the source factor - but the other factor is known at both, so I changed them to set both. That's also how the modern backends take blend state, src and dest together (bgfx, D3D11+, Metal, Vulkan).

@bobtista
bobtista force-pushed the bobtista/refactor/route-blend-state branch from 5028a80 to 9e9e3a4 Compare November 22, 2026 14:24
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.

2 participants