Native OpenGL CPU renderer - 2026-10-16, Sol Medium

Status: VERIFIED in the workspace and installed F: folder.
The overall native PC port goal remains incomplete.

User controls
- Original game pause -> Options -> PC Settings -> page3/7.
- Graphics now has Anisotropic and Renderer rows. Renderer switches live
  between D3D11 and OPENGL CPU using touch, left/right, or confirm.
- D3D11 is the default. renderer=0/1 is persisted in sm64ds_pc.ini.
- OpenGL CPU requires the application-local renderers/mesa runtime. If absent,
  invalid, or unable to create the CPU context, D3D11 is restored and saved;
  OPENGL CPU UNAVAILABLE is displayed on the native Graphics page.
- CPU rendering can be slow at4K. This milestone does not claim60FPS software
  performance or independent120/240FPS game simulation.

Implementation
- port/ntr/gl_software.cpp and include/ntr/gl_software.h implement Mesa WGL
  context loading, GLSL shading, native-resolution rasterization and readback/
  GDI presentation. The driver is loaded by absolute executable-relative path.
  GALLIUM_DRIVER is scoped to context creation and GL_RENDERER must identify
  llvmpipe. No system driver installer or registry changes are used.
- GPU API dispatch selects the backend; original D3D11 is retained. Rendering
  uses shared GX geometry decoding, clipping, viewport mapping and texture
  identities. GL implements original pixel alpha, toon/highlight shading,
  opaque/translucent ordering, depth and polygon-ID shadow masks, texture
  addressing, anisotropic filtering, foreground, minimap and dual-screen views.
- GL uses a dedicated synchronous worker with an8MiB stack created after DS
  address reservations. The original1MiB main stack was insufficient for LLVM
  shader compilation in the raster test (0xc00000fd). A larger main-stack trial
  then prevented fixed IO reservation (error487); that trial was reverted.
- A16-bit float color target retains DS blend precision before8-bit readback.
  llvmpipe's byte-target alpha quantization differed by one color level from
  the existing exact blend checks. The shared test expectations were retained.
- Settings persistence, bounds, native menu labels/navigation, and visible
  failure notice use the existing settings architecture.
- Original src/ and include/ remain unchanged. Host changes are in port/.

Build and verification on exact current build
EXE SHA256 991F2F4D99836B9E17F11FABDF93C51695B66D0D4E66EB319B0D289C6B86C67B
MAP SHA256 C9981CD449D59D2C1E856E77779D82A0229B3AEE4BABED206A525819127293B4
- Native build succeeds.52/52 CTests PASS in36.36seconds.
- Existing smoke_gpu now also runs with --opengl as smoke_opengl_cpu. Both
  backends pass native4K mixed-pixel coverage, scalar parity, UV/depth/cutouts,
  clipping/culling, viewport, widescreen/menu projection, all address flags,
  toon/highlight, shadow IDs/depth-fail/overlap/reset, alpha/depth writes,
  foreground, pause, minimap, resize and all3 dual-screen layouts/engine swaps.
- Renderer selection/default bounds and saved/reloaded choice are checked.
- All3 linked native-data audits pass (minigame callbacks, actor/controller
  data, Rec Room). No generated callback/resource data repairs were required.

Actual game replays (build/run-opengl-renderer-check.ps1)
1. wanted:5300frames,exit0. Original title -> Rec Room -> Wanted -> pause PC
   Settings. Native Graphics row changes D3D11->OpenGL at3100; back/continue
   resumes Wanted at3700. Opens again; changes to D3D11 at4900 and back to GL
   at5100. Captures3250/3900/4950/5150 record the respective adapters. INI
   persists renderer=1. Selected screenshots under build/port/opengl-wanted-*.
2. stage:5000frames,exit0. Baseline castle route enters level1 as Yoshi with
   OpenGL CPU active.4180 screenshot is1280x720,696triangles. Native pause
   settings changes resolution through1920/2560 to3840x2160 at4580.4600
   settings screenshot is4K. Back to gameplay;4900 is3840x2160,698triangles,
   Yoshi and minimap visible. Both screenshots inspected. This does not
   diagnose the separate original-menu Adventure action crash.
3. restart:2400frames,exit0. New process loads the INI written by wanted,
   verifies llvmpipe on startup, and shows normal Wanted poster play at2200.
4. fallback:3100frames,exit0. Separate runtime intentionally has no Mesa DLLs.
   Startup restores D3D11, persists renderer=0 and displays OPENGL CPU
   UNAVAILABLE on the original pause menu. Screenshot3050 inspected.

Runtime provenance and setup
- Mesa26.2.4 x86 MSVC, reports LLVM23.1.2.
  https://github.com/pal1000/mesa-dist-win/releases/tag/26.2.4
  https://docs.mesa3d.org/drivers/llvmpipe.html
- Reproducible setup: port/tools/setup_mesa_runtime.ps1, then native build.
  The script pins and checks the release archive SHA256
  351FC8C8B695878FFB3EAA044B3EAD08672A48B1A045E3C3E3975811DF0F6695.
  CMake copies the available optional runtime to build/port/renderers/mesa
  and enables the OpenGL raster test. Missing dependencies are not fetched by
  game startup or CMake.
- opengl32.dll SHA256
  1EDBFBE0739D2F9514C741C084CEF81542520CBA57952FA2D9E2EE5FCDE9727C
- libgallium_wgl.dll SHA256
  D162A687FAFF907969CFC0CE7C8E7377E5C605870039E218E2FFDBAB6254FFB6
- Packaged notices include Mesa license texts, original license documentation,
  LLVM license/exception, distribution license, version/source references.
  Source archives are retained in build/mesa-runtime for reproducibility.

Packaging
F: rollback:
F:\AI Games\Mario 64 DS\native-checkpoints\native-checkpoint-2026-10-16-opengl-cpu\previous-install
Contains the preceding EXE/MAP/status/progress and main launcher. changed-source
is a partial host-source snapshot; the C: workspace remains authoritative.
The main launcher now selects the original menu; a separate Development Course
Picker launcher retains the old route. Both clear inherited automation flags.

Limits
Physical Xbox/mouse play, other minigames, all courses/actions, texture packs,
FSR/motion blur/render-distance/clothing/multiplayer and final release remain
incomplete or unverified. Existing PPU limitations (bitmap/mosaic/brightness,
3D window clipping) remain. Original2D art is scaled; AI texture art is pending.
Keep Sol Medium for the next engine/gameplay milestone. No model switch needed.


Installed verification completed
- F: EXE/MAP and both Mesa DLL hashes match the exact tested workspace files.
- Actual installed EXE with the F: ROM and application-local Mesa DLLs runs
  2400frames,exit0.2200 capture shows Wanted play and logs verified llvmpipe.
  Evidence: checkpoint/qa-installed/installed-opengl-2200.png and .log.
- F: ROM SHA256 remains CE5829AAA79F06C67140ED1F45CBCA738B0A9D0180538C8C1498472D859DB032.
  QA saves are isolated; prior INI absence is restored. Existing saves untouched.
- Installed main launcher opens the original game menu. The separate
  Play Mario 64 DS - Development Course Picker.cmd preserves the old route.
- Development preview EXE/MAP and runtime also updated. No game/test/build
  sessions remain. Goal active; stay on Sol Medium for engine/gameplay work.
