Skip to content

Add Switch support on top of port-maintenance - #6

Open
Project516 wants to merge 22 commits into
Net64DD:main-nxfrom
Project516:port-maintenance-switch
Open

Project516 wants to merge 22 commits into
Net64DD:main-nxfrom
Project516:port-maintenance-switch

Conversation

@Project516

@Project516 Project516 commented Oct 8, 2026 •

Copy link
Copy Markdown

Adds Switch support on top of libultraship port-maintenance (base commit 60c9bb7), so ports that pin port-maintenance can build for Switch.

SpaghettiKart's Switch CI checks out main-nx over its pinned port-maintenance submodule and fails, because main-nx is based on libultraship main:

src/engine/editor/Editor.cpp:55:24: error: 'GetRawInstance' is not a member of 'Ship::Context'

HarbourMasters/SpaghettiKart#765 is the other half. It points SpaghettiKart's Switch job at this branch until this PR or #5 merges, then switches back to Net64DD/libultraship.

Changes:

  • Switch port code, CMake and ImGui patch, applied on port-maintenance.
  • Link ImGui to SDL2 and make the Switch SDL2 include path public, so dependents compile.
  • Merge main-nx to resolve conflicts. Both sides added the same Switch files, so conflicts keep the port-maintenance version (GetRawInstance, split Gui backends). The main-nx Switch behavior is all still there: the gyro input-block skip, no gamecontrollerdb.txt on Switch, and the keyboard rework. After the merge, the tree differs from the earlier tested head only in the README title.

This overlaps with #5, which also moves the Switch fork onto port-maintenance. If #5 lands and builds SpaghettiKart, close this one. As of 0ab8378, #5 still keeps the ImGui SDL2 include private and does not link SDL2, so the second change here may still be needed on top of it.

Testing: SpaghettiKart Switch CI passes against the merge commit ecbdf84 (Release and Debug): https://github.com/Project516/SpaghettiKart/actions/runs/39170416022. The same job against an earlier head of #5 (abb7e47) failed with fatal error: SDL2/SDL.h: No such file or directory in Fast3dGui.h (https://github.com/Project516/SpaghettiKart/actions/runs/37714300092), which the second change fixes.

Copilot AI and others added 21 commits May 4, 2026 00:00
* refactor: remove cross-layer includes from Ship namespace

- Remove unused consolevariablebridge.h include from MobileImpl.cpp
- Decouple Context.cpp from fast/debug/GfxDebugger.h by making
  InitGfxDebugger() accept a shared_ptr parameter (like InitWindow/InitControlDeck)
- Remove LUS::GfxDebuggerWindow instantiation from Gui.cpp (should be
  registered from the libultraship layer instead)
- Decouple Config.cpp from fast/backends/gfx_metal.h by using Window's
  available backends list for default fallback selection

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/cc9a3aa8-4ee7-48f2-aa6b-47c2832803a0

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* fix: add null checks for GfxDebugger parameter and Window in Config

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/cc9a3aa8-4ee7-48f2-aa6b-47c2832803a0

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* revert: restore Context.cpp/Context.h GfxDebugger changes to original state

Fast::GfxDebugger is still referenced in Context.h (forward declaration,
GetGfxDebugger return type, mGfxDebugger member), so the previous changes
did not actually decouple the ship layer from fast. Revert to original
InitGfxDebugger() with no parameters; will be addressed in the component
refactor instead.

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/72144527-4404-4a09-8ee6-97c61130d219

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* fix: remove extra blank lines in Config.cpp (clang-format)

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/b4b91158-e788-4d5a-8121-89f36b69cde8

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* fix: add WindowBackend::NONE and return it when no Window is available

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/3a67e462-03be-4cc7-ac96-b56ddbf5d78a

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* refactor: move WindowBackend enum to Fast namespace; use int32_t in ship::Window API

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/526c1d54-6cac-4d86-b948-c31d3abae19f

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* refactor: move all Fast3d ImGui backend dispatch to virtual methods on Window

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/22c50f87-dcd3-4c27-a1a0-cfa9c7a3145b

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* refactor: create Fast3dGui class and restore Window.Backend.Name config string

Addresses review feedback:
1. Move ImGui backend dispatch from Window virtuals to Gui virtuals with
   a new Fast3dGui subclass (extends Ship::Gui). This removes all
   Fast::WindowBackend references from Gui.cpp and places backend-specific
   ImGui logic in the Fast namespace where it belongs.
2. Restore the Window.Backend.Name config string by adding a virtual
   GetWindowBackendName() on Window, overridden in Fast3dWindow.
3. Fast3dWindow default constructors now use Fast3dGui instead of Ship::Gui.

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/314d6c8c-e74d-4055-9d11-b6194fffe3a1

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* style: fix clang-format-14 alignment issues

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/314d6c8c-e74d-4055-9d11-b6194fffe3a1

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* refactor: move WindowEvent to Fast namespace; HandleWindowEvents only on Fast3dGui

Fixes issue Kenix3#926 (ship including fast):
- WindowEvent was defined in Ship::Gui but only ever used in fast backends
  (gfx_sdl2.cpp, gfx_dxgi.cpp) and Fast3dGui. Moved to Fast::WindowEvent in
  include/fast/WindowEvent.h.
- HandleWindowEvents removed from Ship::Gui virtual interface; it is now a
  plain (non-virtual) method only on Fast3dGui.
- gfx_sdl2 and gfx_dxgi now dynamic_cast the Gui to Fast3dGui with SPDLOG_ERROR
  error handling before dispatching window events.

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/c2e05218-2994-4bc0-ad73-a2ca0dff25ec

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Move window backend persistence from Config to Window

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/4cb4a129-b887-4a82-8512-8383cff2fcba

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Add SetCurrentDimensions and GetPrimaryMonitorRect to Window/Fast3dWindow (PR Kenix3#785)

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/4cb4a129-b887-4a82-8512-8383cff2fcba

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Push texture cache and Interpreter from Gui down to Fast3dGui

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/4cb4a129-b887-4a82-8512-8383cff2fcba

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Move audio backend persistence from Config to Audio

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/18622f13-a54b-4445-bcd2-7c786d413f81

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Fix migration save, throttle one-time log warnings in SDL2/DXGI backends

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/18622f13-a54b-4445-bcd2-7c786d413f81

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Move GetCurrentAudioChannelsSetting from Config to Audio; move GfxDebugger from Context to Fast3dWindow/Interpreter

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/b347a7d2-c361-44bf-a8fd-fadb3548368e

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Fix Gui.cpp missing GuiTexture.h include; fix GfxDebuggerWindow texture method calls; apply clang-format

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/b347a7d2-c361-44bf-a8fd-fadb3548368e

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Fix clang-format-14 formatting issues in interpreter.cpp and Gui.h

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/3af3f34e-fb61-46b9-afe8-22d4b972a116

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Move InputEditorWindow to libultraship layer (namespace LUS); remove auto-registration from Gui

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/aeb70820-2942-4146-b30a-578c94c0e96d

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Move GuiWindowInitData from Ship::Gui to Fast::Fast3dGui; fix Input Editor null dereference

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/c7448a65-b6af-4808-b92b-05d6a3b80b05

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Fix CI: add Ship:: qualifiers to InputEditorWindow (no using namespace)

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/d5c2b6d8-024a-4809-930d-c35733dd795d

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Fix CI: qualify remaining unqualified Ship:: types in InputEditorWindow

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/5f67d2e4-1fb8-4c76-98f3-aa034a32be9c

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Fix CI: qualify Ship::Mobile in Fast3dGui.cpp for Android/iOS builds

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/9812efcb-d1fc-4831-8ed1-db3ecad52b68

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>
* Add fixedAspect flag

* clang pls

* oops, I had the silly thing in reverse

* change fixedApect to forceFixedAspect

* clang
* Fix some of context and window

* Fix spdlog exit crash

* Fix debug and windows build

* Fix d3d again

* format

* Some comments
…nix3#1118)

* Skip some clamps and stride calculations for replacement textures

* Fix for 4k texture packs

* Add a solution for select linesizebytes

* Add runtime texture synth support
CallEvent() runs for every event fired in a source port. The gated block here normally runs unconditionally inside that. Every event call does a hash-map lookup and a possible insert, plus bookkeeping.

In production, the event debugger is a high cost. The debugger wouldn't usually be used by consumers, and developers testing Release builds can just as easily disable the preprocessor gate.
…3#1151)

A tile masked to NxM only addresses 2^mask texels, but some display lists
load a larger block than the tile addresses (e.g. a 32x32 tile fed a 32x128
block). fast3d sized the texture from the loaded block, so UV normalization
used the wrong dimensions and the surface stretched.

Clamp a masked axis back to its 2^mask wrap period. Only trust the mask when
its period is at least the SetTileSize region, so a stale mask left by a
framebuffer blit (which reuses a tile without a fresh SetTile) is ignored and
the framebuffer isn't shrunk and tiled across the screen.

This restores the pre-Kenix3#1090 clamp for the masked-WRAP over-load case without
re-breaking the window-scroll textures Kenix3#1090 was protecting.
* Bind imgui's gamepad backend to the controller libultraship is using (Kenix3#1112)

* Bind imgui's gamepad backend to the controllers libultraship is using

* Update Fast3dGui.cpp

* popmatrix xml

* fix broken stuff from branch change

---------

Co-authored-by: Jeod <47716344+JeodC@users.noreply.github.com>
…enix3#1112) (Kenix3#1138)

* Bind imgui's gamepad backend to the controllers libultraship is using
* Adds Palette4bpp support for ImGui loading.

* Add nullptr to gfxdebugger

* tidy changes

* tidy v2

* tidy v3
…enix3#1143)

LoadBlock can record entire image as single line, so 256x256 texture becomes 65536x1 upload.
If that exceeds GPU maximum texture size Metal crashes.
When upload width is too wide, reshape. If buffer holds full image,
use image's real dimensions; otherwise use tile-derived line size & height

See page 8 of https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
…enix3#1167)

It discards all audio, so reporting 0 made the producer spin feeding it
forever and starve the gfx thread. Return the desired buffered count, as
the header already documents.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…Kenix3#1141)

New RDP command (0x4a, 5 Gfx) carrying tile coordinate endpoints as floats,
evaluated at draw time against the new Interpreter::mInterpolationT factor set by the port per rendered frame.
Unlike G_SETTILESIZE_INTERP's per-frame index scheme,
display list size no longer scales with the interpolation frame count
* Add ImGui FileBrowserWindow as a fallback file dialog

* Downgrade errors to warnings
Kenix3#1118 made HD replacement textures clamp their sampled size to the tile
region. The texture refactor duplicated that clamp across the per-format
import paths and GfxSpTri1, all fed by GetTileSizeFromCoordinates. For a
tile with no size set (lrs <= uls) the +4 formula yields a phantom 1-texel
region, so the clamp shrinks the texture to 1 texel and the upscaled image
tiles across the primitive -- most visible on the CI8 eyes of adult Zelda /
Sheik, which load via segment with an unset tile size.

Return 0 for an undefined region so every clamp (all guarded on size > 0)
skips it. Pyramid-like and explicit G_TX_CLAMP paths are unchanged.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.