Repository navigation
Conversation
4fc1b82 to
395a274
Compare
…memory or heat for smoothness, and a reset to the game's tested defaults; the launcher stores only choices that differ from the default; docs/settings.md explains every setting for players. settings.tsv gets a page column (main / advanced, parsed strictly by settings.py) and toggles that set other values than 1 / 0 (values <on>/<off>: DM_FPS_HOLD takes on / off, which the host reads; a 0 would have meant on). The first page keeps frame rate, render scale, console mode, language, the frame-rate counter and rumble; its last row, Advanced, opens Frame buffering (DM_PRESENT_SNAP, the profile's present_snap), Metal 4 pipelines (DM_PSO_MTL4, the profile's pso_mtl4), Pipeline prebuild (DM_PSO_PREBUILD; it runs once in the prepare step, so its note says the first start waits), Encode thread (DM_NVN_ENC_THREAD, on as the host on iOS), Hold frames when late (DM_FPS_HOLD, the profile's fps_hold, for games with a frame step) and the Performance HUD. Play stores a choice only when it differs from the game's default (a range compares as numbers) and removes a stored one that equals it, so a setting the player left alone follows a later build's tested defaults; Reset to tested defaults forgets the Advanced page's stored choices; Documents/env.txt still wins and is never stored. docs/settings.md (linked from README's Play section): each setting, when to change it and its cost, with diagrams of a frame with and without frame buffering, of when a pipeline is built (the prepare step, the one-time prebuild, hybrid stand-ins, background builds into the archive), and of the frame step with and without holds. Checked: dm/tools/tests pass (test_launcher_settings: pages, profile defaults for Breath of the Wild and Wonder, on / off values, the strict table format), dm/ios/tests pass (the new test_launcher_storage compiles Launcher.swift with launcher_storage_check.swift and runs it in a booted iOS Simulator, skipped without one: 10 checks of what is stored, Reset and the env file), docs_symptoms.py --check and test_docs pass, the iOS compile check (133 files) and build_smoke.py pass; the launcher drawn in an iPhone 17 Pro Max simulator (iOS 27) shows the first page with the Advanced row and the Advanced page with Breath of the Wild's defaults
… off by default): where the picture's rectangle on the screen is larger than the presented content, the present copies the content to the origin of a texture of its size, MTL4FXSpatialScaler (perceptual: the raw gamma-encoded bytes the present samples) scales it in the present's Metal 4 command buffer to the rectangle's size, and the present pass draws that 1:1, keeping letterbox, the lower-left origin and the drawable format. A scaler is made per content and output size and format, after the presents on the GPU finish and at most once every 30 presents; a size MetalFX refuses stays bilinear. DM_NVN_SHOT_OUT draws screenshots the same way (present_offscreen_m4). The present command buffer's GPU time is logged every 600 presents. For every game and graphics API (the Vulkan and GL layers present through the same path) Breath of the Wild, Zora's Domain, M2 Max fullscreen 2560x1440, the present's GPU time: handheld 1280x720 -> 2560x1440 0.74-1.32 ms against 0.07-0.11 ms bilinear; docked 1920x1080 -> 2560x1440 1.35 against 0.11 ms; offline 1280x720 -> 2868x1320 (iPhone 17 Pro Max) 0.40-1.17 ms against 0.04-0.07 ms. Frame times unchanged at 60 fps. Sharper edges, colours unchanged. Tests: t_present_crop 51 (new: scaler sizing, a MetalFX present with letterbox and sRGB bytes, also under MTL_DEBUG_LAYER), t_nvn 128, check_t_present_snap, iOS compile check
…Standard / MetalFX, Standard by default): a game rendering below the screen (Breath of the Wild handheld 1280x720, or docked 900p scaled to 1080p by the game) is scaled to the screen; MetalFX sharpens it as it scales, in either mode, on the iPhone and through env.txt in the Mac app. docs/settings.md explains it with a diagram; rendering at the screen's resolution stays the sharpest
… with MTL_HUD_ENABLED from DM_METAL_HUD on the Mac and the iPhone): with DM_PRESENT_UPSCALE=metalfx their exposure row, a temporal scaler's value the present's spatial scaler does not have, jumped every frame and the HUD flickered (Breath of the Wild in full screen on a Mac). An environment that sets the variable keeps its value
…of GPU time a frame on an iPhone 17 Pro Max, Breath of the Wild docked, against the game's 6-12 ms; with it, 60 fps docked lasted about 4 minutes from a cold start before thermal state serious, about 1 minute from a warm one), so Standard stays the choice for long sessions at 60 fps
395a274 to
aadcbf3
Compare
Scale the valid presented image with MetalFX's spatial scaler on the shared Metal 4 path, preserving crop, letterboxing, origin and gamma-encoded colours. Keep Standard as the default and fall back when scaling is unsupported. Use the same path for asynchronous whole-window captures and diagnostic screenshots, retaining resources until GPU completion. Bound scaler recreation during resizing and report presentation GPU time separately by scaling mode. Put all launcher settings on one screen with Game, Controls and Performance sections, inline menus and sliders, and a reset to tested defaults. Extract the settings model for native persistence tests, validate saved ranges, share HUD setup, and document the measured costs without claiming an iPhone baseline. Validated with Metal presentation, NVN and snapshot regressions; tool and iOS tests; the Mac host; and an unsigned iOS smoke build. No new device gameplay run. Co-authored-by: v0lumehi <[email protected]>
|
Thanks @v0lumehi — incorporated the MetalFX spatial upscaling work into main in c13ddcf, with your coauthor credit. MetalFX remains opt-in, shared by NVN, Vulkan and OpenGL, with Standard scaling as the default and fallback. The integration also makes whole-window captures use the same MetalFX path, retains capture resources until GPU completion, expands crop/origin/resize regression coverage, shares the HUD setup, and separates the launcher settings model for native persistence tests with saved-range validation. The launcher now uses one scrollable screen with Game, Controls and Performance sections, inline menus and sliders. Upscaling sits beside Console mode; Reset restores all launcher defaults while keeping env-file overrides. The performance documentation keeps the measurements in the game note and explicitly leaves the iPhone Standard baseline and thermal attribution unmeasured. Validation: 83 presentation checks with Metal validation, NVN and snapshot regressions, tool and iOS tests, the Mac host, and an unsigned iOS smoke build. No new device gameplay run was performed. Closing this PR because the implementation has been incorporated on main. Thanks for the implementation and the device measurements. |
…edds#215) Scale the valid presented image with MetalFX's spatial scaler on the shared Metal 4 path, preserving crop, letterboxing, origin and gamma-encoded colours. Keep Standard as the default and fall back when scaling is unsupported. Use the same path for asynchronous whole-window captures and diagnostic screenshots, retaining resources until GPU completion. Bound scaler recreation during resizing and report presentation GPU time separately by scaling mode. Put all launcher settings on one screen with Game, Controls and Performance sections, inline menus and sliders, and a reset to tested defaults. Extract the settings model for native persistence tests, validate saved ranges, share HUD setup, and document the measured costs without claiming an iPhone baseline. Validated with Metal presentation, NVN and snapshot regressions; tool and iOS tests; the Mac host; and an unsigned iOS smoke build. No new device gameplay run. Co-authored-by: v0lumehi <[email protected]>
…s never taken v0.3.1 reserved an eighth of RAM on every device of 12 GB or less, always, and above 15 % of the last 10 s stalled on memory took an eighth of the images back, working set or not, with a 16th pruned under the limit at every miss. On the Galaxy S24+ (MemTotal 11,203 MiB) that kept 1,400 MiB free while `some avg10` read 0.0 % the whole run: the images' limit was 812 MiB where the small rule leaves 1,700, the cache evicted textures the next frames asked for, and the scene fell to 0.8 fps. The reserve now follows what the device reports. Below 10 % it is a 32nd of RAM (at least 512 MiB); above it, on a device of 12 GB or less, the eighth arrives, which is the RAM rule's own cap on growth and no eviction of its own; it leaves under 3 % only with the reserve plus 256 MiB actually free, so a spike does not flap the limit. From 25 % the cache gives back an eighth of what is not the working set at each limit update, never under the working set or the floor. The working set is the image bytes used this frame and in the 8 before it. It is not only the target's floor: those images are left out of the candidates, and an eviction that would leave less than the working set is not made, because the candidates are in LRU order and a GPU-written image is held for 120 frames, so the oldest candidate can be one the scene used three frames ago. Between 15 % and 25 % nothing is given back: the system is reclaiming what it can, and taking the scene's own images costs more stall than it returns. DM_VK_IMG_PSI keeps the two policies it had. 1 is this one; 0 is the build before it, verbatim (the eighth permanent on the class, the 16th's margin, no working set, the GPU-written gate shut), so a player who sets it gets that behaviour, not a third shape. A pinned DM_VK_IMG_LIMIT_MB still replaces the limit, and with it the working set and the guard; DM_VK_IMG_RESERVE_MB=<MiB> pins the reserve. The GPU-written gate is the policy's own shrink mark, not a literal: it opens when the policy is pressed past DM_VK_IMG_PSI_SHRINK, and a tuned mark moves the limit and the gate together (seedds#215). t_android_texlimit runs the scene the S24+ measured: 500 textures of 4 MiB, 100 drawn a frame in a window sliding 50, so the last 8 frames touch 450 of them (1,800 MiB). v0.3.1's rule, re-derived there as limit_031, leaves a 1,672 MiB limit and a 1,567 MiB target under that working set: 14,634 evictions and 14,550 of the images re-uploaded within 8 frames of being evicted. The fix's reserve leaves 2,560 and 2,400: 500 uploads in all, one per texture, and none evicted.
MetalFX in the present (
DM_PRESENT_UPSCALE=metalfx, off by default)When a game renders smaller than the area it's shown in, the present scales it bilinearly. Breath of the Wild renders 1280×720 handheld, and 900p docked, which the game itself scales to 1080p. With this option, the present scales with MetalFX's spatial scaler instead:
MTL4FXSpatialScalerin the present's Metal 4 command buffer. The present pass then draws the result 1:1.DM_NVN_SHOT_OUT) go through the same path.Launcher and docs
env.txt.docs/settings.md: explains it with a diagram, says that rendering at the screen's resolution stays the sharpest, and gives the iPhone's cost (below).Metal HUD fix
With MetalFX on, the Metal HUD's MetalFX rows flickered. Their exposure value belongs to a temporal scaler, which the spatial scaler doesn't have, and it jumped every frame (BotW, full screen on a Mac).
DM_METAL_HUDnow also setsMTL_HUD_HIDE_METALFX_METRICS, on the Mac and the iPhone. An environment that sets the variable keeps its value.Measured: GPU time of the present command buffer
docs/settings.mdrecommends Standard for long sessions at 60 fps on an iPhone.Checked
t_present_crop(51 checks), including the new checks for scaler sizing and a MetalFX present with letterbox and sRGB bytes. It also passes underMTL_DEBUG_LAYER.t_present_snap(13 checks),t_nvn(152 checks).dmhostfor three profiles, the iOS compile check and the tool tests (includingtest_launcher_settings.pyandtest_launcher_storage.py) pass.