Skip to content

feat(ww3d2): add IRenderBackend Interface#2613

Open
bobtista wants to merge 4 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/feat/render-backend-interface-skeleton
Open

feat(ww3d2): add IRenderBackend Interface#2613
bobtista wants to merge 4 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/feat/render-backend-interface-skeleton

Conversation

@bobtista
Copy link
Copy Markdown

@bobtista bobtista commented Apr 17, 2026

Summary

First PR in a planned multi-step refactor introducing an IRenderBackend interface in WW3D2. This PR adds only the scaffolding — interface, adapter, lifecycle wiring, and one isolated proof-of-concept call site. zero behavior change. The DX8 path remains the only renderer; g_renderBackend is constructed as a DX8Backend that forwards every method to the existing DX8Wrapper static facade.

What this PR adds

  • IRenderBackend.h — abstract interface covering the W3D-facing subset of DX8Wrapper's public API. Only high-level methods (those taking ShaderClass/TextureBaseClass/Matrix4x4/etc.) are virtualized. D3D8-typed low-level methods stay on DX8Wrapper as DX8Backend-specific escape hatches — see the doc for the rationale.
  • DX8Backend.{h,cpp} — concrete adapter that forwards every virtual method to the existing DX8Wrapper:: static functions. Pure forwarding, no new rendering logic.
  • RenderBackend.{h,cpp} — exposes the global IRenderBackend* g_renderBackend. Init_Render_Backend() constructs new DX8Backend() from DX8Wrapper::Do_Onetime_Device_Dependent_Inits(); Shutdown_Render_Backend() tears it down from DX8Wrapper::Do_Onetime_Device_Dependent_Shutdowns().

Test plan

  • Windows CI builds pass
  • Game launches and runs a Skirmish round identically (no visual / behavioral difference)

@bobtista bobtista changed the title feat(ww3d2): add IRenderBackend skeleton (Phase 1, DX8 default) feat(ww3d2): add IRenderBackend Interface Apr 17, 2026
@bobtista bobtista force-pushed the bobtista/feat/render-backend-interface-skeleton branch 2 times, most recently from 5e014bf to e648a3e Compare April 17, 2026 23:43
@TheSuperHackers TheSuperHackers deleted a comment from greptile-apps Bot Apr 17, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 17, 2026

Greptile Summary

This PR introduces the IRenderBackend abstract interface, the DX8Backend concrete forwarding adapter, and the RenderBackend lifecycle owner as Phase 1 scaffolding for a multi-backend rendering refactor. Zero behavior changes: DX8Backend is a pure trampoline to the existing DX8Wrapper static API, and the global g_renderBackend is wired into the existing Do_Onetime_Device_Dependent_Inits/Shutdowns lifecycle hooks. The design choices (C++98 compatibility, TransformKind values mirroring D3DTS constants, opaque unsigned long shader handles) are all explicitly documented in the interface header.

Confidence Score: 5/5

Safe to merge — pure scaffolding with no behavior changes, correct lifecycle ordering, and thorough inline documentation.

All new files are clean, rule-compliant, and follow existing project conventions. No P0 or P1 findings. The interface design choices (C++98 compat, D3D-mirrored TransformKind values, opaque shader handles) are all intentional and well-documented. Lifecycle wiring into DX8Wrapper is minimal and correct.

No files require special attention.

Important Files Changed

Filename Overview
Core/Libraries/Source/WWVegas/WW3D2/IRenderBackend.h New abstract interface; clean forward-declaration strategy, documented C++98 constraints, #pragma once, GPL header, and nullptr-based destructor all correct.
Core/Libraries/Source/WWVegas/WW3D2/DX8Backend.h Concrete adapter declaration; correctly inherits IRenderBackend, uses #pragma once, and mirrors the interface with virtual for C++98 compatibility.
Core/Libraries/Source/WWVegas/WW3D2/DX8Backend.cpp Pure one-line trampolines to DX8Wrapper statics; Set_Viewport correctly converts RenderBackendViewport fields (types match D3DVIEWPORT8 exactly), shader handle casts to DWORD are safe on Windows.
Core/Libraries/Source/WWVegas/WW3D2/RenderBackend.h Minimal accessor header; extern IRenderBackend * g_renderBackend declaration and two lifecycle function prototypes are correct, #pragma once and GPL header present.
Core/Libraries/Source/WWVegas/WW3D2/RenderBackend.cpp Lifecycle management is correct; double-init guard and null-check on shutdown are both sound, nullptr used throughout.
Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp Adds Init_Render_Backend() at end of Do_Onetime_Device_Dependent_Inits and Shutdown_Render_Backend() at top of Do_Onetime_Device_Dependent_Shutdowns; ordering is correct to ensure backend is torn down before D3D device release.
Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt Adds all five new source/header files to WW3D2_SRC in alphabetically consistent positions.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class IRenderBackend {
        <<abstract>>
        +Is_Device_Lost() bool
        +Has_Stencil() bool
        +Get_Back_Buffer_Format() WW3DFormat
        +Begin_Scene() void
        +End_Scene(flip_frame) void
        +Clear(...) void
        +Set_Viewport(viewport) void
        +Set_Shader(shader) void
        +Set_Texture(stage, texture) void
        +Set_Transform(kind, m) void
        +Set_Light(index, light) void
        +Draw_Triangles(...) void
        +Set_Vertex_Shader(vs) void
        +Create_Render_Target(...) TextureClass*
        +~IRenderBackend() void
    }

    class DX8Backend {
        +DX8Backend()
        +~DX8Backend()
        ... all IRenderBackend methods
    }

    class DX8Wrapper {
        <<static facade>>
        +Do_Onetime_Device_Dependent_Inits()$
        +Do_Onetime_Device_Dependent_Shutdowns()$
    }

    class RenderBackend {
        <<global owner>>
        +g_renderBackend IRenderBackend*
        +Init_Render_Backend() void
        +Shutdown_Render_Backend() void
    }

    IRenderBackend <|-- DX8Backend : implements
    DX8Backend --> DX8Wrapper : forwards all calls
    RenderBackend --> DX8Backend : constructs / owns
    DX8Wrapper --> RenderBackend : Init/Shutdown calls
Loading

Reviews (3): Last reviewed commit: "fix(ww3d2): Update copyright headers to ..." | Re-trigger Greptile

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