OpenTPW

Optional upscaling — design#

Added on request on October 9, 2026. Status: M6-U1 implemented and smoke-tested on macOS arm64/Metal; Windows/D3D11 and Linux/Vulkan untested (see "Implementation status" below). This is an optional presentation improvement, not a replacement for full offline gameplay or original graphics fidelity. No new dependency has been added.

Implementation status (October 9, 2026)#

Implemented (M6-U1):

Real Retina hardware (October 9, 2026, MacBook Pro, built-in Liquid Retina XDR, 3024×1964, Metal): the Native smoke test passes with a 1280×720-point window drawn at 2560×1440 pixels via SDL_GetWindowSizeInPixels, exact BF4 text (maximum channel difference 0), Totem and neighbouring-cell picking, borderless fullscreen at 3024×1898 pixels and back, and no growth of owned GPU resources. The smoke test also passes with --upscale linear --render-scale 67, --upscale linear --render-scale 50 and --upscale nearest --render-scale 50. A visual comparison of the outputs showed Native clearly sharpest; Linear 67% is slightly soft, Linear 50% visibly blurred and Nearest 50% blocky (as intended). On this hardware Native is the recommended setting; upscaling is for GPUs that cannot hold the frame rate at native size. One run failed at the runtime-resize step after the window was enlarged externally (zoomed or tiled by macOS during the test); a rerun passed.

Higher-resolution textures are a separate, optional feature: TEXTURE-PACKS.md.

Not done / not proven:

Purpose and settings#

This concerns real-time upscaling of the 3D world. Offline AI texture upscaling, replacement of original assets, supersampling and frame generation are not covered here and are not added implicitly.

Fit in the current renderer#

source/OpenTPW/Client/Renderer.cs currently renders the world to a 4x-MSAA framebuffer, resolves it to ResolveColorTexture, blits with Device.LinearSampler to the swapchain, and then renders the editor/UI. content/shaders/blit.shader contains the fullscreen texture sampling. The render targets now use Screen.Size. That existing separation is the attachment point; no renderer rewrite is needed.

Desired order:

  1. Determine the output size from the actual swapchain/drawable pixels, separate from the logical window size and DPI. Choose the internal size from output size × render scale; round consistently, clamp to at least one pixel and to device limits.

  2. Render only the 3D world at that internal size. Keep the existing MSAA resolve intact; upscaling is not an antialiasing replacement, and MSAA is a separate setting.

  3. Resolve, scale to output size, and run only explicitly chosen sharpening. Native keeps the current pass without a new filter.

  4. Render text, menus, cursors and ImGui at output resolution. The UI is not passed through the world upscaler and stays sharp at lower world resolution.

Record the internal and output dimensions in one small render configuration; do not introduce a plugin framework for two sampler choices. Camera aspect follows the output aspect; rounding of internal dimensions must not stretch the image or shift picking. Input and picking stay in the existing logical screen coordinates, with explicit DPI conversion where needed; render scale must never become a second mouse scale factor.

Resize, fullscreen, DPI and scale changes replace targets and resource sets at a safe frame boundary. Dispose all own color and depth textures and views, not only the framebuffer object; retire old GPU resources only after their use has completed. When minimized or zero-sized, rendering pauses without zero-size GPU allocations. Allocation or capability failure gives a native fallback with a reason; if native also fails, a clear error follows, not endless retries or a black screen reported as success.

Settings must not affect tick rate, RNG, simulation state, save format or replay. GPU quality stays strictly outside the game core.

Staged algorithm choice#

StepChoiceGate / constraint
M6-U1Native, Linear, Nearest + fixed/custom scaleExisting Veldrid/shaders/samplers; qualify resize/DPI/input/resources first
M6-U2, optionalResearch spatial edge-aware upscaling, for example FSR 1 EASU/RCASProve source and license beforehand, pinned version, shader translation and actual Metal/D3D11/Vulkan costs; no automatic dependency addition
Later, separate decisionTemporal upscaling, for example FSR 2 or MetalFXInvestigate motion vectors, depth/jitter/history, camera-cut/reset and transparency/UI contracts first; the current renderer does not supply these inputs as an upscaling contract

A vendor name in this design is not an integration or support claim. MetalFX does not become the mandatory Mac route; a platform-specific extension must work alongside the portable baseline. DLSS/XeSS and other vendor integrations are not release requirements. Frame generation falls outside this slice.

Automatic or dynamic resolution only comes after GPU timing and fixed-scale proof: bounded scale, hysteresis, adjustment interval and an explicit target frame budget. No auto-scaling based on total frame time alone: a CPU or simulation bottleneck is not solved by fewer pixels. Do not claim a performance gain without measurement; filter overhead can be heavier than the savings at small resolutions.

Acceptance and evidence#

The current GPU smoke test reads the internal resolve texture and excludes UI. It is therefore only world-render evidence. For upscaling, add a capture of the final output after scaling and UI; do not call the existing capture an end-to-end upscaling/UI test.

Primary research sources#

Check the API, capabilities and license against the chosen pinned implementation before integration; this design deliberately does not choose an unproven newest vendor SDK.

Source: docs/UPSCALING-DESIGN.md in the project repository.