Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ if(_MMX_RASTER_IMPL_DEFAULT STREQUAL "NATIVE" AND MMX_RASTER_IMPL STREQUAL "NATI
set(_MMX_NATIVE_ROW_PLAN_DEFAULT ON)
endif()
option(MMX_NATIVE_ROW_PLAN "Prepare whole-view native row composition plans" ${_MMX_NATIVE_ROW_PLAN_DEFAULT})
option(MMX_NATIVE_BG_SPANS "Bind reconstructed background tiles and palettes per source span" OFF)
# Match the qualified native row-plan default; preserve explicit cache choices
# and the portable/reference defaults on other configurations.
option(MMX_NATIVE_BG_SPANS "Bind reconstructed background tiles and palettes per source span" ${_MMX_NATIVE_ROW_PLAN_DEFAULT})
set_property(SOURCE src/mmx_renderer_native.c tests/mmx_native_renderer_test.c
src/main.c tests/mmx_adaptive_state_test.c
APPEND PROPERTY COMPILE_DEFINITIONS
Expand Down
56 changes: 28 additions & 28 deletions docs/ROW_RENDER_PLAN.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Whole-view row rendering experiment
# Whole-view row rendering

`MMX_NATIVE_ROW_PLAN=ON` selects a prepared-row pipeline in the NATIVE custom
renderer. It defaults ON for the qualified Windows x64 NATIVE configuration;
other platforms retain their existing defaults. Explicit OFF selects the
existing NATIVE compositor, and the separate LLE renderer remains buildable.

Each captured line/view prepares its background pixel and private-color planes
before composition. The shared `snes/raster_plan.h` job resolves widened hardware
before composition. The shared `snes/raster_register_plan.h` job resolves widened hardware
windows, optional signed color-beam windows, enabled layers and native/margin
boundaries into at most eleven immutable spans. Composition selects main/sub
pixels with span masks rather than repeating window/enable decisions per pixel.

Scene-map reconstruction, native tile rows, palette/CHR ownership, sprite order,
color math, captured raster changes and guest execution remain authoritative.
This first experiment does not assume that reconstructed tiles or asset phases
are linear across every stage boundary. Map-binding spans are a separate possible
follow-up; this package does not implement them or GPU rendering.
The row planner does not assume that reconstructed tiles or asset phases
are linear across every stage boundary. R1 below additionally binds maps and
resources per source span. Rendering runs on the CPU.

The planner has no platform dependency, live PPU mutation, heap allocation or
persistent simulation state. The adapter uses bounded private row scratch;
Expand All @@ -30,23 +30,18 @@ rewind and fresh-process replay, and matched built-game A/B workloads. Per-game
CPU reductions and neutral results require recorded balanced samples; compilation
and component tests alone are not performance qualification.

Owning issue: `beads-8wg.2.161`; coordinating campaign: `beads-2wy8.1`. Bounded
raw receipts and source/binary/configuration identities are retained under
`G:/Temp/Codex/snesrecomp/full-view-20261027`. No original Xbox runtime or
cross-build netplay compatibility is claimed.

Five balanced A/B pairs per view on an Intel i5-4670 measured median process-CPU
reductions of 7.4% (custom 4:3), 9.6% (16:9) and 12.6% (32:9). The ordinary
stock-renderer workload was neutral/inconclusive. These are additional results
against the preceding optimized MMX build, not additive percentages or original
Xbox qualification. Raw samples, exact binary identities and settings are in
`campaign-results.json` beneath the evidence directory above.
against the preceding optimized MMX build.

## Reconstructed background source spans (R1)

`MMX_NATIVE_BG_SPANS=ON` additionally resolves full-view map tiles, source-row
planes and private CHR/palette bindings per source span. Its development default
remains OFF by owner direction. The old scalar
planes and private CHR/palette bindings per source span. New Windows x64 NATIVE
configurations default ON, matching the qualified row-plan default. Existing
cache selections and explicit OFF remain effective; other-platform and LLE
defaults retain their existing floor. The old scalar
`background()` remains the independent reference and handles per-pixel imported
menu art and the Rush ceiling; mosaic retains its existing path.

Expand All @@ -71,18 +66,23 @@ neutral/inconclusive; repeated OFF/ON, identical-binary and canonical-main
controls are retained. These results belong to this MMX title adapter and
package, not every SNES game; do not add percentages to the preceding row
package. Exact measured source is `ef821a32` (runtime code from `7e558267`).
Raw samples, source/runtime/binary identities, feature settings and size costs
are indexed in `campaign-results.json` under the task directory below.
Automated qualification is complete; combined owner playtest approval and
merge remain pending. No original Xbox or cross-build netplay claim is made.
The implementation was merged in [PR149](https://github.com/mstan/MegaManXSNESRecomp/pull/149).

Owner direction on 2026-10-28: finish this already-authorized title candidate,
then prioritize game-agnostic engine mechanisms. Reuse or elevate shared
operations with actual consumer validation; retain X1 scene and asset policy
here. X2/X3 already use the shared live PPU and a shared background provider,
so enabling this X1-specific build flag is not a direct port. Substantial
adoption belongs after the shared-engine burndown or is deferred.
X1 scene and asset policy stays in this adapter. X2/X3 already use the shared
live PPU and a shared background provider, so this X1-specific flag does not
enable source spans in those games.

Tracking: `beads-8wg.1.150`, roadmap
`beads-49cy`, campaign `beads-2wy8.1`. Evidence:
`G:/Temp/Codex/snesrecomp/background-spans-20261027/evidence`.
Current-main qualification on `e1a6a69e`, supported engine `00996306` and UI
`3f1d6f12` reused the guarded 4,200-frame Highway route. Three alternating
16:9 OFF/ON pairs reduced whole-process CPU by 11.09%, 21.33% and 20.76%.
Sampled 342x224 gameplay images were identical, including the margins, with
569,408 claimed native raster lines in both builds. Three stock controls were
mixed within substantial background-load variation; no stock speedup or
repeatable regression was established. These SDL3 dummy/software results
measure CPU work and do not establish GPU cost or a hardware FPS gain.
Adaptive Auto startup now reads the committed widescreen selection before
plugin activation and seeds a wide initial canvas. Fresh defaults produced a
1281x720 window and 342x224 gameplay; saved native and custom 800x600 choices
retained their window and field sizes. Fixed-aspect choices keep their existing
startup sizing policy. Existing captured fields, palette/tile owners and
current-build save/rewind/rollback formats remain unchanged.
22 changes: 22 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "mmx_default_config.h"
#include "mmx_netplay.h"
#include "mmx_startup.h"
#include "mod_runtime.h"
#include "mmx_coop_trace.h"
#include "mmx_coop.h"
#include "mmx_coop_view.h"
Expand Down Expand Up @@ -241,14 +242,35 @@ static void MmxViewport(int w, int h, int dw, int dh, SnesDisplayViewport *view)
else MmxDisplay_ComputeViewport(w, h, dw, dh,
SnesDisplayAspect_Clamp(g_config.display_aspect), g_config.ignore_aspect_ratio, false, view);
}
static bool s_initial_window_width = true;
static bool MmxStartupAdaptiveEnabled(void) {
#if SNESRECOMP_ENABLE_MODS
char aspect[16];
const char *package = "megaman-x.enhancement.widescreen";
/* The plan is committed before window creation; plugins activate later,
* after the machine exists. Query the admitted selection, not live flags. */
if (snes_mod_runtime_feature_option_value_c(package, "widescreen", "aspect",
aspect, sizeof(aspect)))
return snes_mod_runtime_feature_enabled_c(package, "widescreen") &&
!strcmp(aspect, "adaptive");
#endif
return g_config.widescreen && g_mmx_custom_aspect == MMX_ASPECT_ADAPTIVE;
}
static int MmxWindowWidth(int w) {
bool initial = s_initial_window_width;
s_initial_window_width = false;
if(MmxLocalSplit()) {
double aspect=!g_config.widescreen ? 5.0/4 :
g_mmx_custom_aspect==MMX_ASPECT_21_9 ? 21.0/9 :
g_mmx_custom_aspect==MMX_ASPECT_32_9 ? 32.0/9 :
g_mmx_custom_aspect==MMX_ASPECT_16_9 ? 16.0/9 : g_mmx_custom_view.aspect;
return (int)(2*aspect*MmxDisplay_GetWindowBaseHeight()+.5);
}
/* Adaptive starts with no field width until a window exists. Give a fresh
* Auto window a wide canvas; later resizes and saved choices stay authoritative. */
if (initial && !MMX_VARIANT_JP && !MmxNetplayActive() && w == 256 &&
!g_config.window_width && !g_config.window_height && MmxStartupAdaptiveEnabled())
return (int)(16.0 / 9 * MmxDisplay_GetWindowBaseHeight() + .5);
return MmxDisplay_GetWindowBaseWidth(w, SnesDisplayAspect_Clamp(MmxNetplayActive() ? 0 : g_config.display_aspect));
}

Expand Down
11 changes: 11 additions & 0 deletions tests/mmx_adaptive_state_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,17 @@ int main(int argc, char **argv) {
g_mmx_custom_aspect = MMX_ASPECT_ADAPTIVE;
}
g_config.display_aspect = kSnesDisplayAspect_Crt4x3;
check(MmxWindowWidth(256) == 427, "legacy adaptive Auto starts with a wide canvas");
check(MmxWindowWidth(256) == 320, "later native-width sizing keeps the selected geometry");
s_initial_window_width = true; g_config.widescreen = false;
check(MmxWindowWidth(256) == 320, "saved native choice keeps native startup sizing");
s_initial_window_width = true; g_config.widescreen = true;
g_config.window_width = 800; g_config.window_height = 600;
check(MmxWindowWidth(256) == 320, "saved custom window bypasses adaptive startup seeding");
g_config.window_width = g_config.window_height = 0;
s_initial_window_width = true; g_mmx_custom_aspect = MMX_ASPECT_16_9;
check(MmxWindowWidth(256) == 320, "saved fixed aspect keeps its startup sizing policy");
g_mmx_custom_aspect = MMX_ASPECT_ADAPTIVE; s_initial_window_width = true;
check(FindCmdForSdlKey(SDLK_F7, 0) == kKeys_SaveStateMenu &&
FindCmdForSdlKey(SDLK_F8, 0) == kKeys_Rewind &&
FindCmdForSdlKey(SDLK_F11, 0) == kKeys_Load + 6 &&
Expand Down
Loading