diff --git a/docs/development.md b/docs/development.md index cdff13f..9f88a2b 100644 --- a/docs/development.md +++ b/docs/development.md @@ -103,6 +103,7 @@ screen. It costs some GPU time on cards that cull quickly, so it is off unless s | `HOS_AUDIO=0` | No sound device is opened (the mixer still runs); `scripts/run-vk.ps1` sets it unless `-Sound` | | `HOS_AUDIO_AUX=0` | (Triforce, 11-24) The game's Aux effects are accepted and passed through, as before: the mix they are on plays as it came. The default runs them: each 5 ms frame the mix's sent buffers go to the game's own effect code as whole frames (`ReadAuxSendBuffer`) and what it hands back (`WriteAuxReturnBuffer`) takes their place, silence when it has handed nothing back in time. Passed through, an effect's send was heard as one more dry source and the effect itself never. `HOS_AUDIO_EFFECTS=0` leaves them out too (`host/nn_audio.c` "Aux", `tests/test_audio_aux.py`) | | `HOS_AUDIO_EFFECTS=0` | The game's plain reverb, delay and biquad filter effects on its mixes and its splitter destinations' biquad filters are accepted and left out, as before they were emulated (the sound unfiltered and at full level: the "Volcano eruption audio bugged" ticket); the I3DL2 reverb still runs. By default they run on the mix buffers in the order the game added them (`host/nn_audio.c` "mix effects"; `tests/test_audio_mix_effects.py`) | +| `HOS_MENU_SOUND_SETTINGS_NAVIGATE=`, `HOS_MENU_SOUND_SETTINGS_SELECT`, `HOS_MENU_SOUND_SETTINGS_BACK`, `HOS_MENU_SOUND_MODS_NAVIGATE`, `HOS_MENU_SOUND_MODS_SELECT`, `HOS_MENU_SOUND_MODS_BACK`, `HOS_MENU_SOUND_PAUSE_BACK`, `HOS_MENU_SOUND_SETTINGS_ON`, `HOS_MENU_SOUND_SETTINGS_OFF` | (Triforce, 11-25) Another of the game's interface sounds for one of the settings' own: moving, choosing and going back on the Triforce settings tabs and on the Mods screen, and the step back to the pause menu's System list (out of the Mods screen opened from it, and Cancel or B on Quit's dialog). The value is a sound's bare name, the file `Sound/Resource/Stream/.bwav` of the game's files without its folder and `.bwav`: `HOS_MENU_SOUND_SETTINGS_NAVIGATE=SE_Sys_Cursor00` is the in-game menu's tick again. Letters, digits and `_` only, 64 at most; any other value is left out, and a name the game's files do not have (or a file that is not a sound) leaves that one its own sound, each with a `menu sounds:` line in the log, as has every one that is set. Not set, they are the system menu's (the title screen's): `SE_Sys_SysMenu_Cursor00` for the two Navigate, `SE_Sys_SysMenu_DecideL00` for the settings' Select (the title's Continue's) and `SE_Sys_SysMenu_DecideS00` for the Mods screen's, `SE_Sys_SysMenu_Cansel00` for the three Back, and for a toggle switched On (`SETTINGS_ON`) the small decide, Off (`SETTINGS_OFF`) the cancel (in 0.8.3 and before, the in-game menu's `SE_Sys_Cursor00`, `SE_Sys_Do00` and `SE_Sys_Cancel00`). Read once, when the sounds are; `triforce_env.txt` takes them (`host/menu_sound.c` `roles`, `gpu/vk/menu_sound_events.h` `sound_for`; `tests/test_menu_sound_roles.py`) | | `HOS_LANGUAGE=` | The game's language for this run, a code from `language.txt` | | `HOS_OUTPUT_RES=<0..8>`, `HOS_OUTPUT_SIZE=x`, `HOS_HANDHELD=1`, `HOS_ASPECT=` | Over the options file: the output resolution (as `output_res` below), Custom's size (as `output_width` and `output_height`), the handheld profile, and the picture's shape whatever the Output resolution and the Ultrawide row say (a ratio, width over height: 2.3889 is 3440x1440's; the picture is the output's height in that shape, kept to 3840x2160's pixels). The Insert menu shows `HOS_OUTPUT_SIZE` and `HOS_ASPECT` in the rows they set, which then have nothing to choose | | `HOS_WIDE_UI=0\|1`, `HOS_WIDE_UI_LOG=`, `HOS_HUD_MAX_RATIO=` | (Triforce) The HUD's layout on a picture wider than 16:9 (`host/hos_wide_ui.c`, ozwaldorf's pane planner): with the Display tab's HUD position at Screen edges the HUD's side panes move out to the screen's edges, planned at each present from the panes as the game places them (`nx2/oot_wide.py` `UI_SITES`), so the row changes at once; with Menu sides at Extended the menus' side panes too. Middle, the default, plans nothing. Not on a picture narrower than 16:9. `HOS_WIDE_UI=0`: off, and Screen edges moves the HUD's panes as the layouts load (`host/prompts.c` `build_layouts`), as before; `=1`: Screen edges whatever the row. `HOS_WIDE_UI_LOG=` logs the first n changes of the plan, each root layout and the plan's time; `HOS_HUD_MAX_RATIO` (12:5 by default, 0 none) is the widest the HUD's sides go | @@ -137,6 +138,7 @@ screen. It costs some GPU time on cards that cull quickly, so it is off unless s | `HOS_GUEST_MEMFD=0`, `=1` | (Linux) The guest window as a memfd's, its pages handed to the GPU as dma-bufs (udmabuf), where `/dev/udmabuf` can be opened: amdgpu checks every page of a host-pointer import again at each submission, 15-45 ms a submission in Kokiri. (Triforce, 11-21) Also where udmabuf's `size_limit_mb` cannot be read (Flatpak and other sandboxes hide `/sys/module`): its default, 64 MB, is assumed and the log says so; only a limit that reads 0 keeps the window anonymous. The log's `mem: the guest window is a memfd's` line. `=0`: anonymous memory, host-pointer imports; `=1`: the memfd all the same | | `HOS_MEM_TRACE=1` | (Triforce, lab) Logs every address region and page call of the game with its size and caller (`memtrace:` lines; a region's with its call stack) and every `QueryMemoryInfo` answer | | `RX_VK_WB_EXCL_CLIP=0` | (Triforce, 11-22; on by default with `RX_VK_CAP_ONLY_GPU=1`) A written binding is copied back to guest memory whole at the submission's end, as in 0.6.0. By default the parts of it in memory the capture leaves out (heap memory between the game's pools inside an imported chunk) are not: the collection does not stamp the CPU's writes there, so the mirror's bytes there are stale, and the write-back diff copied them over the game's newer ones. A pointer table's bare entry (its 64-byte head marked written, `gpu/vk/vk_draw.cpp`) did so over a heap block 0x18 past its base: the 0.6.0 crashes at area changes in guest 0x803b44e0 (a block header of 0x9ed00000001 or 0x1aa88000013fe), 0x80a30a00 and 0x80a31030 (`gpu/vk/wb_excl_clip.h`, `gpu/vk/vk_memory.cpp` `gpu_buffer_bind`; `tests/test_wb_excl_clip.py`). The first 20 clipped write-backs are logged (`vk: write-back of ... not copied back`) | +| `RX_VK_CAP_EXCL_GAP=0`, `=check` | (Triforce, 11-26, the GPU audit's C09; on by default with `RX_VK_CAP_ONLY_GPU=1` or `2`) `=0`: the check that counts the replay's reads, texture uploads and buffer bindings reaching into memory the capture leaves out (`cap_excl_note`) searches the left-out ranges at every question, as before. By default a thread keeps the last 8 gaps between left-out ranges its searches found and answers a question wholly inside one of them without a search; a question across a gap's edge is searched, and the gaps are dropped whenever the ranges change (`gpu/vk/capgap.h`, `gpu/vk/vk_memory.cpp` `cap_excl_hit_gap`; `tests/test_capgap.py`). Why: the search ran first thing in every `gpu_buffer_bind` over 2,400-3,650 ranges on the lab PC, 2.3% of the Presentation Thread's own time at Lake Hylia and 2.6% in the Market, for a count that is nearly always not raised; about 0.1 ms a frame expected at Lake Hylia, measured on v0.8.4 at the end of this row. The same answers and the same count; the write-back's clip (`RX_VK_WB_EXCL_CLIP`) and `RX_VK_CAP_ONLY_GPU=2`'s page count keep the plain search. `=check`: both at every question, the search's answer used and the differences counted and the first 20 logged. Any other value: the memo, as unset, and logged. The lab's knob `nocapgap` (`RX_VK_LAB_AB`) is `=0` in its phases (a thread asks it again only when the phase moves, not at every question). The log's `capture (RX_VK_CAP_ONLY_GPU` line every 10 s carries `left-out checks in all from the gap memo N, searched M, differing D (RX_VK_CAP_EXCL_GAP)` (totals since the start; N and M count only the memo's questions, none with `=0` or in `nocapgap`'s phases, and up to 255 a thread are not yet added; D is 0 unless `=check` finds a difference). Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.121 ± 0.051 ms a frame (1.6% fps), measured while the knobs `nocapgap` and `nobindspan` were still asked at every left-out check and every binding that may use a span, string compares that every knob's phases paid and the phases without a knob did not, so the figure is likely somewhat high (by an estimated 0.03-0.09 ms). The check run (all four scenes, every rider checked at once): 82,900,725 left-out checks answered from the memo, 0 differing | | `HOS_FPS_STEADY=0`, `=1`, `=2` | (Triforce, off by default: the Frame pacing row's two Steady values, over them) 1 any rate, 2 steps of the display's refresh: the game's frames paced to a period this PC holds in the scene, never shorter than the Game frame rate cap's (`host/pace_steady.h`, `host/nn_vi.c` `steady_period`). The rate is chosen by probes (`pace_steady_probed`): 32 frames at the cap, unpaced, the last 24 of them measured, at the start, 2 s after a load, at least every 12 s, and when a quarter of the last 64 frames ran late (2 s after the last probe at the soonest, twice that each time a probe changes nothing, up to 12 s); the rate becomes the first the last three probes' 90th percentile fits in with 2% to spare where that is slower, or the first it fits in with 5% to spare where that is faster. A frame paced slower does more work (the lab's Market: 11.6 ms unpaced, 15.5 ms paced at 55 fps), so the frames' own measure as they run chased the rate down; frames late now only bring a probe on, and the rate is never under what a probe shows the PC holds. `HOS_FPS_STEADY_PROBE=0`: no probes, the rule below as before. Without probes: what a frame took is its present interval less the longest of the pacing's waits in it (the acquire's, on the presenting thread or another, and the present's hold), and what it needed the interval less all of them (OoT's main thread and Presentation Thread take turns; where the waits add up to the whole interval, the longest: `pace_steady_measure`); a quarter of the last 64 frames that took more than the period lowers it at once to the first rate their 90th percentile fits in with 2% to spare, and once it has held 3 s since a raise (6 s since a lowering, doubled for each lowering within 30 s of a raise, up to 120 s, and back to 6 s at a load) it rises to the fastest rate the 90th percentile of what the last 512 frames needed fits in with 5% to spare (one rate at a time where the game acquires on another thread). A frame that took over 2.5 times the median of the last 64 (hitches among them), a present interval over 250 ms, and the frames of the 2 s after such a load (the scene is not its measure yet) are left out; the first lowering after a load waits for 128 frames of the new scene and takes their 90th percentile. The acquire's wait starts the frames a period apart (the steady step then gives the game the period as its time step) and the present holds each picture of the game's to the period after the last, less a 64th of it (`gpu/vk/present_smooth.h` `present_smooth_paced_at`, with or without the Frame pacing row; not with frame generation). Another limiter holding the frames (RivaTuner, Reflex) puts the cap back while it does. `vi: steady frame rate:` lines at each change say what the frames needed, and every 5 s what the rule was given (what the frames took and needed at p50 and p90, the present interval's p50, the waits a frame by kind, the frames kept and left out by reason, how many of the last 64 kept were late, and the probes and what the last three took unpaced); the `vk: frame pacing` line counts the present's holds | | `HOS_FPS_STEADY_PROBE=0` | (Triforce, with `HOS_FPS_STEADY` or the Steady frame rate row) No unpaced probes: the rate by the frames' own measure as they run, as before test31 (`host/pace_steady.h` `pace_steady_probed`, `host/nn_vi.c` `steady_period`); the frames' work grows when they are paced slower, and that rule slides down | | `HOS_PACE_SPIN=0`, `HOS_PACE_SPIN=` | (Triforce) The game's own frame wait on the high-resolution timer for the whole wait, as before, which wakes up to about 0.5 ms after the frame's time. By default the timer takes the wait up to 0.6 ms before the frame's time and the rest is yielded away on the clock, so the frame starts on its time (`host/pace_wait.h`, `host/nn_vi.c` `pace_sleep`); a number is another margin. Every 5 s in which frames waited a `vi: frame waits` line says how long after their time the waits ended, on average and at most | @@ -160,7 +162,7 @@ screen. It costs some GPU time on cards that cull quickly, so it is off unless s | `HOS_INPUT_EXCLUSIVE`, `HOS_INPUT_BACKGROUND`, `HOS_INPUT_SCRIPT_BACKGROUND` (set) | As above; the last lets every device count while the window is behind another one | | `HOS_INPUT_RECORD=` | (Triforce; unset: off) An input recording (`host/input_movie.c`, the format in `host/input_movie.h`): what the game is given each game frame, after every device and filter (the controller word and sticks, the flight and free camera cheats' inputs, the gyroscope, the native mouse camera's turns, the menu mouse's choices, the Debug tools' actions and rows), with Link's position and the camera's state as fingerprints. From the frame after Link's first update; `HOS_INPUT_FROM=boot`: from the game's first read. `HOS_INPUT_ROUTE=1`: no guest words or addresses in it (`HOS_INPUT_SAVE=` noted in its header) | | `HOS_INPUT_PLAY=` | (Triforce; unset: off) A recording given back in place of the player's devices, the script and the bridge, from the same point, then the player's input again; the log says where Link or the camera first left it, and its end how many updates did. With `HOS_INPUT_RECORD` (another file) the replay is recorded too. `HOS_INPUT_SYNC=` (1; 0: never) puts the camera and Link back every n-th update where they left it, while Link is within `HOS_INPUT_SYNC_MAX` metres (1); past that the replay has diverged. Exact only at the 60 cap with `HOS_REALTIME_STEP=0`, `HOS_FIXED_TIME`, the same save and settings. A run that records or plays from its start has no movie pacing (`host/nn_vi.c`). The control bridge starts and stops either at run time (`triforce_ctl.py record` / `play`) | -| `RX_VK_MENU_SCRIPT=:,...` | Timed Insert menu keys: `INS`, `UP`, `DOWN`, `LEFT`, `RIGHT`, `ESC`, `ENTER`, `TABL`, `TABR` | +| `RX_VK_MENU_SCRIPT=:,...` | Timed Insert menu keys: `INS`, `UP`, `DOWN`, `LEFT`, `RIGHT`, `ESC`, `ENTER`, `TABL`, `TABR`, and `APPLY` (the options' Apply, as its key) | | `RX_VK_UI_PROMPTS=pad` or `keys` | The menu's button prompts for a controller or the keys, whatever was used last (screenshots) | | `RX_VK_UI_GAME_FONT=0` | The menu, the counter and the start-up screen in the included Libertinus, not the game's own font | @@ -195,9 +197,11 @@ case-sensitive, and an unknown one is ignored. | `HOS_FPS_LOG` (set), `HOS_PRESENT_TRACE=` | The game's frame limiter, VRR flags and nominal rate every 300 presents; a CSV line per game present | | `RX_VK_FRAME_LOG=` | A CSV line per present: frame, seconds, frame time in ms | | `RX_VK_FRAME_TRACE=1` | A line a frame in `triforce_frames.csv` beside the game (the lab's scenarios keep it as `frames.csv`): present to present, the waits for shaders and pipelines, the uploads, and the replay's parts (`memsync_ms` ... `tex_lookup_ms`: the draws' parts are sampled and summed over every thread that records). (Triforce, wp20, `gpu/vk/frame_trace.h`) Then each frame split as the stall line splits a long one: `replay_ms` (the submits and the present phase), `present_ms`, `dispatch_ms`, `qsubmit_ms`, `par_wait_ms` (the replay thread's waits for its helpers' segments), `outside_ms` (the frame less the replay and the present: the game's own update), `game_wait_ms` (the game's fence waits), `captures_ms` (the captures at its submits), `wb_wait_ms` and `wb_held_ms` (the waits for write-backs, and their part after the writer's recording was done: `RX_VK_WB_WAIT_REC`), `qs_bg_ms` (the queue submits beside a background import), `gpu_waits_ms` ((Triforce, 11-22, the performance audit's SYNC-27) every thread's time in calls that block on the GPU, `RX_VK_GPU_WAITS` below). `python -I scripts/frame_rank.py ` ranks what made the frames over the 99th percentile and over 1.5x the median by these, per window (the Market, the tour's stays, the loads) | +| `HOS_BENCH_PAN=` | (Triforce, 11-26; measurement only; `host/hos_bench.c`) The benchmark's camera turn (`HOS_BENCHMARK=`, with `HOS_BENCH_SECONDS` a scene, 15 unset, and `HOS_BENCH_SCENES` the scenes, below): the right stick's push in percent instead of 35. `0`: the camera holds still in every scene, so an in-run A/B (`RX_VK_LAB_AB`) compares its phases on one view per scene (the turn takes about 18 s at Camera speed 100 and the game's default Camera sensitivity, so 300-present phases otherwise land on different views and their spread hides gains of a few tenths of a millisecond). The phases are counted in presents, not scenes: give each scene many phases (`HOS_BENCH_SECONDS=300`, as the `RX_VK_CHUNK` row's runs) and leave out the phases that hold a teleport, which the frame trace does not mark. `HOS_BENCH_SCENES=:,...` picks the scenes by the teleport actions of `host/hos_main.c` (1000 and up, in the order of `oot_destinations`: `1002:Kakariko` is Kakariko Village, which the `RX_VK_CHUNK` row's runs had in place of Kokiri Forest); unset: Hyrule Field, the Market, Kokiri Forest and Lake Hylia. Camera speed (the Controls tab, `HOS_CAMERA_SPEED`) and the game's Camera sensitivity scale the turn, and the game's own dead zone still applies, so a small push may hold the camera as `0` does. The leading number counts (`35%` is 35), rounded up to a whole unit of the stick's 32767, so `35` is exactly the push unset. Unset or empty: 35, as before; not a number (`nan` too) or outside 0-100: 35, and the log says so. When it is set, the log's `benchmark: HOS_BENCH_PAN=` line at the start says the push in force and the results have `"pan"` (its percent). Compare runs with the same value and the same Camera speed only | | `RX_VK_SETTLE_GATE=1`, `=2` | (Triforce, 11-22, off by default; the performance audit's SYNC-29, after Source A's; `gpu/vk/settle_gate.h`) A CPU read that lets the stopped queues whose waits are met go on (the readback's look, which `RX_VK_RB_SETTLE=1` turns on, and the two looks made for a range a texture may be in) takes the order's lock whenever a queue is stopped, and that lock is held through whole replays and presents. With the gate a site looks only while a queue is stopped **and** the CPU has signalled an event since the last finished look, or a stopped queue waits on an event whose value is read from guest memory; any other met wait was met by a signal in the stream, and the thread that replayed it looked before it let the lock go. `1`: the readback's look; `2`: the texture sites' too (new ground: those looks order the exposure meter's readback, so `2` needs the lab's flicker count). Unset or `0`: every look as before. The `RX_VK_LAB_AB` knobs `settlegate` and `texgate` are `1` and `2` in their phases (`rbsettle+settlegate` is the pair the audit asks for). The 3000-readback line and the texture catch-ups' 300-call line count the looks made and skipped | | `RX_VK_READBACK_LATE=[,]`, `RX_VK_LOG_READBACK_RANGES=1` | (Triforce, 11-22, the performance audit's SYNC-19, after Source A's; `gpu/vk/readback_late.h`) Ranges the CPU reads back **without** the wait for their write-back, from what guest memory holds (the last write-back made): a rule is a size in hex (`3980`: every range of 0x3980 bytes, the culling camera block Source A reads late by default) or `newest` (a range whose writer is the newest submission handed out: the game cannot have waited for it). **Unset: no rule**, every readback waits as before, until the lab has run it where the waits are long (a handheld, an AMD iGPU, a weak discrete card); `=0`: none either. The `RX_VK_LAB_AB` knob `rblate` is `3980` in its phases. A late read hands the game the frame before's values, and when the CPU resets a range read late the pending write-back lands over its reset (the exposure meter's flashes): `newest` can catch that meter, so it is never a default. `RX_VK_LOG_READBACK_RANGES=1`: with every 3000-readback line, the 12 ranges that waited longest (readbacks, waits, ms, how often their writer was the newest submission, how often read late), to find such ranges on other hardware; nothing is noted without it | | `RX_VK_WB_WAIT_REC=1`, `=2` | (Triforce, off by default; the handoff's §12.9, `gpu/vk/wb_rec_wait.h`) A wait for a write-back still on the GPU (a capture's late pages on the game's submitting thread, a read or binding of a page put off) ends once the recording its submission was finished in is done on the GPU, not when the submissions' timeline reaches it: that timeline is held below any submission stopped at an event wait, and the lab's Market had 20-46 ms waits of the game's thread with the GPU 4 submissions behind. Whatever the switch, the wait for the recording comes first and the rest is counted: the stall line's `N of them X ms after their writer's recording was done`, the `late:` line's `ms of the wait after the recording that finished it was done`, the frame trace's `wb_held_ms`. Off: the captures' late-page wait orders something not known yet (`RX_VK_LATE_NEW`), so it is tried with the lab's flicker count first. (Triforce, 11-22, the performance audit's SYNC-122, after Source B's) The reads' side: a readback whose write-back is not recorded yet waited on the submissions' timeline with no bound and no second look; it is counted now (the 3000-readback line's second line), and the stall line names the held part by caller (takes, reads, binds, readbacks). The variable is a mode: `1` as above, and such a readback waits in 1 ms slices, looks its writer's recording up between them and ends with it; `2` is the check, where no wait ends earlier and the readback's slices count the part after the recording was done (what `1` would not have waited); unset, `0` or any other text: off, one wait as before. The check of the pages a later write-back changes (the audit's SYNC-101) is not built. `RX_VK_TL_REC=1` and the lab knob `tlrec` ended a capture's wait at a submission's first part, before its burst's write-backs were recorded: they now end it at the recording the submission was finished in, as `=1` here does; `RX_VK_TL_REC=2` keeps the old lookup | +| `RX_VK_RB_REC_END=0` | (Triforce, 11-27; `gpu/vk/wb_rec_wait.h` `readback_wait`, `tests/test_readback_rec_end.py`) A CPU readback of GPU results waits for the **last** part of the recording that writes it back. A recording made in parts (`RX_VK_CHUNK`'s counted parts, 240 draws on NVIDIA's driver, or Threaded rendering's pass-end parts) writes back at each part's end, all under the recording's one value, and the readback's wait looked that value up in a table that keeps the first part (`RX_VK_REC_LAST`, off, keeps a later one only when the value comes again). A read that came between the first part's submit and the last one's got what guest memory held then: OoT's exposure meter read as 0 where the GPU's sum was still to come, then the sum landed over the CPU's next 0 and the next frame added to it. In a still view the picture flashed brighter for a frame and stepped down: 3 times at Hyrule Field in a four-scene held-camera benchmark run (`HOS_BENCH_PAN=0`), on v0.8.4 too. Now the readback looks up the newest part submitted and whether it ended the recording: an ended recording's last part is waited for; one that goes on, the part found (the old wait), then 1 ms slices of the submissions' timeline between looks until it ends or the timeline reaches the value. A value not recorded yet goes to the fallback as before. `RX_VK_LOG_READBACK_ZERO=1` now says the writer's recording's first part, newest part and the recordings done at a zero read; the 3000-readback line counts the reads that waited past a part. Measured on an RTX 5090 (held camera): the meter's zero reads after a wait went from 0-10 a run to 0 in 4 runs, and Hyrule Field's flashes from 3 a run to 0. The rule waits 350-550 times a run, 2-5 ms each, on the game's worker threads, nearly all at a scene's load and in its first seconds. Frame rate unchanged (144.5 against 143.2 fps, 3 runs each); Hyrule Field's p99 frame time 9-13% higher. Waiting only for the part that wrote the range would be cheaper (not done). The rule's branches stay out of `invalidate` and submit_recording's registration, so that the renderer's play profile still matches them. `0`: the first part, as before | | `RX_VK_LATE_QUEUE=1` or `0` | (Triforce, 11-20; 11-23) A capture's late pages (pages a submission still on the GPU writes back: OoT's exposure meter and the per-frame pools) waited for at the queue's next submit, not at the capture's take (`gpu/vk/vk_memory.cpp` `late_queue_on`). Unset: at the queue, except while the replay's submits are held (`RX_VK_BATCH`, on by default with Mesa's RADV): there a held submit applies no fix, the fixes wait for the batch's flush and copy guest memory the game has written again for its next frame, and the replay reads those slots live meanwhile: the lighting and exposure flicker on Linux AMD from 50-90 s into play in v0.7.0. `1`: at the queue with held submits too (v0.7.0 as shipped); `0`: at the take on every driver, as before 11-20. The log says `vk: late pages' wait ...` when it is first asked and when the answer changes | | `RX_VK_LATE_INLINE=1` | (Triforce, 11-22, the performance audit's MEM-80, after Source B's; `gpu/vk/late_inline.h`; **off unless set**, not yet run in the game) A late page (one the CPU wrote while a submission still on the GPU writes it back) is waited for and taken again by default (`RX_VK_LATE_QUEUE`: at the queue's next submit). `RX_VK_LATE_NEW=1` (knob `latenew`) turns four no-wait rules on, each of which brought brightness steps back at the Castle Town save. This turns on the partial rule alone (knob `lateinline`): a page only part of which a submission on the GPU writes back has its other parts synced from the capture, no wait; pages of pools with no mirror, texture storage, pages written back whole and pages whose write-backs' ranges are not known are waited for as by default. The partial rule, here and under `RX_VK_LATE_NEW`, now asks which ranges are still on the GPU against the progress the capture read before its copies, not a second read at the take: a write-back done between the two counts as in flight, and its range is not synced from the older copy. `RX_VK_LOG_LATE` shows the pages waited for | | `RX_VK_PASS_TIMING=1` or `2` | GPU time per pass (2: per program too), logged every 600 presents | @@ -210,6 +214,14 @@ case-sensitive, and an unknown one is ignored. ### The GPU +The figures of the renderer changes measured on v0.8.4 on 11-27 against their lab knob's neighbouring phases +(`RX_VK_DESC_UBO_ONLY`, `RX_VK_PICK_WIDE`, `RX_VK_TPL_TABLE`, `RX_VK_BAKE_SCAN`, `RX_VK_CPU_WORDS_SEEN`, +`RX_VK_CAPTURE_PUSH_KEEP`, `RX_VK_BIND_SPAN` and `RX_VK_CAP_UNION_SHARED` below, `RX_VK_CAP_EXCL_GAP` under Running a +test) were taken while the knobs `nocapgap` and `nobindspan` were still asked at every left-out check and every binding +that may use a span (up to about 14,000 and 7,500 a frame), string compares of a few ns each that every knob's phases +paid and the phases without a knob did not. Each of those figures is likely somewhat high, by an estimated 0.03-0.09 ms +a frame; the two knobs are now asked once a phase and once a submission. + | Switch | What it does | |---|---| | `RX_VK_VALIDATION` (set) | The Khronos validation layer | @@ -225,8 +237,8 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_NO_SPILLING_RATE=1` | (Triforce, the performance audit's PIPE-55, after Source A's; Linux build only) The Linux build sets `shader_spilling_rate=2` in its environment before the Vulkan instance is made (`gpu/vk/mesa_spilling.h`, `gpu/vk/vk_main.cpp` `create_instance`), unless the player has set that variable. Only Mesa's Intel shader compiler reads it: a program whose registers do not fit is built in fewer, larger steps (Source A, an Iris Xe: one compute program not built after 20 minutes and 13 GB, 32 s and 1.7 GB at rate 2). `=1` sets nothing, so the driver keeps its own rate. On Mesa's Intel driver the log has `vk: Mesa's Intel compiler spills at rate ...`. The Windows build sets nothing: under Proton, add `shader_spilling_rate=2` to the launch options. Not run on an Intel GPU here | | `RX_VK_DRIVER_FAULTS=0` or `2` | (Triforce, 11-22, the performance audit's PIPE-57, after Source A's; `gpu/vk/driver_faults.h`) On AMD's own Windows driver only (`VK_DRIVER_ID_AMD_PROPRIETARY`), unless `0`: a program whose pipeline build faulted inside the driver is not asked of the driver again this run, and its key is appended to `triforce_driver_faults.txt` beside the executable (one line: vendor, driver version, program) by the fault's handler, before a fault during the start's shader work restarts the game, so the next start with that driver skips it instead of faulting again (`vk: driver faults: N programs ... kept out of it`; delete the file to try them again, another driver version ignores its lines). And one build of a program is inside the driver at a time: a second waits outside it, a probe of the caches is told a compile is required. `2`: on every driver (the lab's); `0`: nowhere. On other drivers nothing of it runs (`gpu/vk/vk_draw.cpp` `fault_quarantine`, `build_graphics`, `guarded_graphics`) | | `RX_VK_PASS_BARRIER=game` or `full` | The barrier a draw pass starts with (`gpu/vk/pass_barrier.h`). `game`: a pass right after another, with nothing recorded between (no barrier of the game's, no copy, clear, uniform update or dispatch), waits for the earlier work in its fragment stages only, so its vertex, task and mesh work may overlap the earlier pass's fragments; a pass the replay itself split off for a hazard (`a pass of its own` in the log) and `RX_VK_BARRIER_EVERY_DRAW`'s keep a full one. (Triforce, P4) "Nothing recorded between" is the command buffer's own count (`RX_VK_BARRIER_CONTEXT`), so beside the Replay helper threads too. `full`: a full barrier at every pass start, as before. Unset: `game` with NVIDIA's driver, `full` on every other card. The log's `vk: pass barriers:` line says which, and the frame statistics' `pass starts ordered in their fragment stages only` how many a frame | -| `RX_VK_CHUNK=` | (Triforce, 11-22, the performance audit's SYNC-66, after Source B's; `gpu/vk/barrier_rules.h` `part_draws`) How many draws and dispatches a part of a long submission has in a serial replay: the GPU starts on the first part while the rest is recorded, and each split costs a queue submit, two full barriers and the part's bookkeeping (about 27 a frame at 120). Unset: the driver's default, **120 on every driver** until the lab has measured one (Source B cuts at 128 where the GPU idles while the CPU records and at 4096 on desktop drivers); `0`: whole submissions, never split; `120`: today's size whatever a later default says. The size was read once into a static: now the `RX_VK_LAB_AB` knob `chunk:` changes it in its phases while the variable is unset (`RX_VK_LAB_AB=chunk:480,chunk:240` with `RX_VK_PARALLEL=0`). The log's first `vk: a submission's parts:` line says the size in force and the driver's default | -| `RX_VK_SPLIT_BARRIER=pass` or `full` | (Triforce) A long submission goes to the GPU in parts of 120 draws and dispatches (`RX_VK_CHUNK`); `gpu/vk/barrier_rules.h`. `pass`: a pass open at a part's split goes on in the next part, begun again with the same targets behind a barrier of its attachments' outputs alone and with what its draws sampled and wrote, so the GPU does not drain between two draws of one of the game's passes; where the part's end records anything (its uniform updates, its write-backs) or an event's write is held, the full barriers as before. A parallel replay's segments are not split into parts: each begins and ends with a full barrier, so nothing goes on across a segment's edge. `full`: a full barrier at each part's end and the next one's start, as before. Unset: `full` on every card ((Triforce, 11-22, SYNC-66) this row said `pass` with NVIDIA's driver; `pass` has been off unless set since 11-16, when the lab's Market showed no gain from it: `barrier_rules.h` `split_in_pass`). The log's `vk: a submission's parts:` lines say which and, every 3,600 splits, how many went on in their pass and how many of those parts had uploads (whose own full barriers order them after the part before all the same) | +| `RX_VK_CHUNK=` | (Triforce, 11-22, the performance audit's SYNC-66, after Source B's; `gpu/vk/barrier_rules.h` `part_draws`) How many draws and dispatches a part of a long submission has in a serial replay: the GPU starts on the first part while the rest is recorded, and each split costs a queue submit, two full barriers and the part's bookkeeping (about 27 a frame at 120). Unset: the driver's default, **240 on NVIDIA's driver** (its driver id, `VK_DRIVER_ID_NVIDIA_PROPRIETARY`, on Windows and Linux; 11-26, measured on v0.8.3: RTX 5090 at 2560 x 1440, the benchmark's four scenes with the camera held, `RX_VK_PARALLEL=0`, the knob `chunk:240` against 120 in neighbouring phases: 0.37, 0.18, 0.21 and 0.08 ms off the frame at Lake Hylia, the Market, Hyrule Field and Kakariko, +0.8 to +3.1% fps; on v0.8.4 (11-27, the same way, 300 s a scene): 0.55 ± 0.20 ms at Lake Hylia (6.3% fps), 0.42 ± 0.03 ms in the Market (5.1%), 0.26 ± 0.06 ms at Kakariko (3.5%), and at Hyrule Field, the fastest scene (183 fps), 120 was 0.05 ± 0.03 ms faster (0.9%); with this PC's default helpers 0.05 to 0.06 ms (0.8%, at Lake Hylia not significant); with the GPU slowed to about half busy (`RX_VK_SIM_GPU_SLOW=8`) 0.45 ± 0.06 ms at Lake Hylia (5.2%); 480 was mixed and 960 lost about 1.2 ms everywhere, the write-backs the game waits for starting too late; fewer cuts change which occlusion counts arrive in time, fewer straddling a split and some finishing later, and a count is written only when whole, so none is ever hidden; measured only on that RTX 5090 desktop, with the replay thread alone but for the default helpers' figure: 4-core and laptop PCs, NVIDIA's Linux driver and capped frame rates are not measured) and **120 on every other driver** (NVK, Dozen and Venus on an NVIDIA card too) until the lab has measured one (Source B cuts at 128 where the GPU idles while the CPU records and at 4096 on desktop drivers); `0`: whole submissions, never split; `120`: the size before, whatever the default says (on NVIDIA's driver too). The size, its default and the knob apply where parts are cut by count: with Threaded rendering off (the default) or `RX_VK_PART_PASS_END=0`. With Threaded rendering on and `RX_VK_PART_PASS_END` unset, a part ends where the game ends its render pass, from 120 draws (the first part from 32) to 512 (the log's `vk: a submission's parts end where the game has ended its render pass` line), and neither default is read: leave `RX_VK_CHUNK` unset there, because any value turns those parts off: a number above 0, 120 too, cuts every n draws wherever that falls, inside the game's passes too, and any other value (0, empty, negative) gives whole submissions (`RX_VK_PART_PASS_END=1` gives those parts on any run, and the variable is then read only in the knob's phases). The size was read once into a static: now the `RX_VK_LAB_AB` knob `chunk:` changes it in its phases while the variable is unset (`RX_VK_LAB_AB=chunk:120,chunk:480` with `RX_VK_PARALLEL=0` and Threaded rendering off; with Threaded rendering's parts on, the knob's phases are counted and the phases between end at the game's passes, so add `RX_VK_PART_PASS_END=0` to compare sizes). The log's first `vk: a submission's parts:` line says the size in force and the driver's default, and when Threaded rendering's parts decide instead | +| `RX_VK_SPLIT_BARRIER=pass` or `full` | (Triforce) A long submission goes to the GPU in parts (`RX_VK_CHUNK`: 240 draws and dispatches on NVIDIA's driver, 120 on every other); `gpu/vk/barrier_rules.h`. `pass`: a pass open at a part's split goes on in the next part, begun again with the same targets behind a barrier of its attachments' outputs alone and with what its draws sampled and wrote, so the GPU does not drain between two draws of one of the game's passes; where the part's end records anything (its uniform updates, its write-backs) or an event's write is held, the full barriers as before. A parallel replay's segments are not split into parts: each begins and ends with a full barrier, so nothing goes on across a segment's edge. `full`: a full barrier at each part's end and the next one's start, as before. Unset: `full` on every card ((Triforce, 11-22, SYNC-66) this row said `pass` with NVIDIA's driver; `pass` has been off unless set since 11-16, when the lab's Market showed no gain from it: `barrier_rules.h` `split_in_pass`). The log's `vk: a submission's parts:` lines say which and, every 3,600 splits, how many went on in their pass and how many of those parts had uploads (whose own full barriers order them after the part before all the same) | | `RX_VK_GPU_WAITS=0` | (Triforce, 11-22, the performance audit's SYNC-27; on by default; not yet run in the game) The host's calls that block on the GPU are made without being timed, as before. By default each is timed where it is wrapped (`gpu/vk/vk_work.h`, `gpu/vk/gpu_wait_kinds.h`) and summed by kind: `vkWaitForFences` and `vkWaitSemaphores` with a timeout above 0 (fences, timelines), `vkQueueWaitIdle` and `vkDeviceWaitIdle` (idle), `vkGetQueryPoolResults` with the wait bit (queries). Polls count nothing, a wait inside a wait counts once, and the low-latency sleep's wait is left out as pacing. After each 120-present line the log has `vk: host waits for the GPU: ... ms a frame (fences, timelines, idle, queries; all threads)`, which counts what that line's "GPU-bound wait" (the recording slots' waits alone) does not, and the frame trace has `gpu_waits_ms`. The cost is two clock reads a blocking wait. The `RX_VK_LAB_AB` knob `nogpuwaits` turns the count off in its phases | | `RX_VK_ORDER_WAKE=1` | (Triforce, 11-22, the performance audit's SYNC-59; off unless set; not yet run in the game) A queue stopped at a wait for an event goes on when a submit finds the wait met. A signal of the CPU's (`nvnEventSignal`) wakes no one: the stop waits for the order thread's next `Sleep(1)`, or a game thread's wait yields up to 3 ms and then forces it. With the switch (`gpu/vk/vk_replay.cpp` `sync_watch`, `event_signal_queued`) the order thread waits on an auto-reset event, 1 ms at most, which the signal sets while a queue is stopped: one `SetEvent`, no lock and no replay on the signalling thread. And a game thread's wait for stopped work that sees a signal pending lets the queues whose waits are met go on first, as `sync_settle` does; nothing is forced. The order line counts the wakes and those that let work on: under about one a second, leave it off. The `RX_VK_LAB_AB` knob `orderwake` turns it on in its phases | | `RX_VK_RELEASE_QUEUE=1` | (Triforce, 11-22, the performance audit's MEM-85, after Source B's idea; `gpu/vk/release_queue.h`; **off unless set**, not yet run in the game) Without the replay thread (`RX_VK_ASYNC` unset), a texture or program the game finalizes is let go by its own thread: held for the replaying thread only while a queue is stopped at a wait (PR 430), otherwise after `sync_drain` and the replay's lock, which a replay holds through whole submissions. With this on, every such release goes to a list the replaying thread applies at the start of the next submission's replay or present when no queue is stopped (after the stopped work otherwise, as PR 430's); a texture's release counts the game's writes from the write generation of its call, so writes after the call are still uploaded. The `RX_VK_ASYNC` job path is not changed. The `RX_VK_LAB_AB` knob `relq` turns it on in its phases. On in every run, a count: every 600 releases a `vk: releases` line when one of them waited 0.5 ms or more for the replay or its order (how many, the time in all, the longest) or went to the list. Not built: the entry's `rel_wait_ms` column in frames.csv | @@ -329,7 +341,9 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_VIEW_KEEP=0` | Any texture's end (an eviction, a dead render target let go, a texture made BC3 from BC1, the compaction moving one) makes every texture look of every recording thread stale, and each is resolved anew when next met (the slot, the cache, the view, under the parallel replay's lock), as before. By default a thread that finds the destroy generation moved keeps the looks of the textures whose views did not go: those are noted by their creation number before the generation moves (`gpu/vk/view_keep.h`, `vk_draw.cpp` `texture_view_of`); never a look of no texture or no view, nor a flat texture's 3D copy. More than 1024 gone since a thread's last pass: all resolved anew. The log's `vk: texture looks kept` lines count them, the stall line the views resolved anew. After NX2navi's `tex_gen_undo` | | `RX_VK_DESC_KEEP=0` or `check` | The per-binding reuse of a draw's descriptors (`gpu/vk/desc_keep.h`, on by default): a draw that builds its descriptors takes, for each sampled texture, user uniform buffer, stage's constants and read-only storage buffer, what the program's last draw on that thread resolved it to, while everything it was resolved from is the same: the texture's handle, its slot's registration, the samplers', no texture destroyed or made again, no texture left for later and the same submission; the buffer's address and size, no inline uniform update, no pool moved or mirror made, the same recording. `0`: every descriptor resolved, as before (so also with `RX_VK_NO_DESC_REUSE`, `RX_VK_SAMPLER_CACHE=0` and the descriptor diagnostics). `check`: every descriptor resolved too, and one that comes out otherwise than what was kept for the same inputs is counted and logged (`vk: descriptor reuse check`): the way to try the rules. The frame statistics' `a frame's descriptors` line says how many were resolved and taken, how many pushes were whole, of the changed bindings or of nothing, and how many sets were written, through a template, or bound again | | `RX_VK_DESC_SIG=0` or `check` | The whole-draw skip by the signature of a draw's descriptor inputs (`gpu/vk/desc_sig.h`, on by default with the per-binding reuse): a draw whose bindings moved, of the program whose descriptors its last draw pushed in that command buffer, first reads what each of them is resolved from (a texture's handle and its slot's version, a user uniform buffer's address and size, a read-only storage buffer's address and size words, a driver bank's stage generation) and the stamps the per-binding reuse gives each kind; when that equals the signature the pushed descriptors were built from, and their build kept every one, the build and the push are left out (a build would take each of them again and push nothing). Push programs only, of the kinds the per-binding reuse keeps: not those with storage buffers they write, tables, texel buffers or storage images, not the mesh fallback or RenoDX's. `0`: built, as before. `check`: built too, and one that comes out otherwise than what is pushed is counted and logged (`vk: descriptor signature check`). The frame statistics' `a frame's descriptor signatures` line says how many draws read theirs and how many were kept whole | +| `RX_VK_DESC_UBO_ONLY=0` or `check` | (Triforce, 11-26; `gpu/vk/uboonly.h`, on by default) A draw keeps the last descriptors only while nothing at all was bound anew, and every changed uniform buffer bind counts, so the next draw of the same program with one per-object uniform buffer of its own ran the whole `build_descriptors`: every texture handle read and looked for among the kept results, every storage buffer's words, the banks' cache, the writes (about 2,100 builds a frame at Lake Hylia, 1,600 to 1,700 of them pushing 1.5 descriptors each, on the thread the frame waits for). By default such a draw resolves its user uniform buffers alone (c3 to c18, each through `kept_uniform` as a whole build does) and leaves the rest of the thread's last build as it is, only where a whole build would take every other descriptor from what was kept: the program this thread built and bound last (a dispatch's build in between ends it), no texture, sampler, image or storage buffer bound to its stages since (`tex_gen`, `ssbo_gen`), the per-binding reuse's stamps what they were before that build (the recording, the bind stamp, the samplers', the destroy and dummy generations, the texture epoch), every other descriptor's result kept and no slot of its textures registered anew (walked once after a whole build, and again after a registration), and a program whose other descriptors no uniform buffer can move: the kinds of descriptor the signature skip keeps (no written storage buffer, table, texel buffer, storage image, turf list, run-time pointer, nor the miss binding; not compute, the mesh fallback or RenoDX's), but only stages 0 to 4 (no task or mesh stage) and set programs as well as push ones, and no texture handle or storage buffer address read through a handle program or from c3 on (the program's plan is made once a program a thread, and again after another program took its slot). Not for a draw that may not leave textures for later, a dump, or the upscaler's second recording; off with `RX_VK_DESC_KEEP=0` or `check`, `RX_VK_DESC_SIG=1` or `check` (the signature skip, off by default), `RX_VK_BANK_GEN_OFF`, and where uniform buffers are snapshots (`RX_VK_UB_SNAPSHOT`; by default every Intel GPU, and any other integrated GPU whose pools have no VRAM mirror). A stamp that moves while the uniform buffers resolve (a mirror made) makes the whole build follow. `0`: every such draw builds whole, as before. `check`: built both ways and compared descriptor for descriptor and sampled texture for sampled texture, a difference counted and logged (`vk: uniform-buffer-only build check`), the whole build used. Since every such draw then ends in a whole build, `check` tries the rule only right after a whole build, never over a build of the uniform buffers alone as the default mode chains them; that state is tried by `tests/test_uboonly.py` alone. Each compared draw resolves its user uniform buffers twice, so a `check` run's descriptor counts and stream use are neither mode's. Any other value: on (told once). The lab's knob `nouboonly` (`RX_VK_LAB_AB`) is `0` in its phases. The frame statistics' `a frame's uniform-buffer-only builds` line says how many of a frame's builds resolved their uniform buffers alone, and for the next draws of the last program that did not, why: the program's kind, a texture or storage buffer bound, a stamp moved or a result not kept; in `check` none counts as resolved alone (each was built whole), and the line says how many were compared and how many differed. Such builds count among `a frame's descriptors` builds, but only their uniform buffers count as resolved or taken there. Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.176 ± 0.069 ms (2.3% fps); with the replay alone at the Market 0.125 ± 0.073 ms (1.6%), at Hyrule Field 0.027 ± 0.022 ms (not significant). The check run (all four scenes, every rider checked at once): 5,319,517 builds made both ways, 0 different | | `RX_VK_DESC_COUNTS=0` | (Triforce, 11-22, the performance audit's DESC-22, after Source A's; `gpu/vk/desc_counts.h`) `build_descriptors` walks the program's stages at every build to sum its buffers, images and texel views, as before. The default keeps the three sums packed on the program (`Program::desc_n`, 10 bits each, in the padding after `ready` so that `sizeof(Program)`, which the shader caches' stamp holds, stays what it is): stored at the program's first build once it is translated, read at every later one. A program with more than 1023 of a kind walks at every build. A build that went by kept counts and had one of its three vectors move is made again, walked, and that program walks from then on (one log line). The lab's knob `descwalk` (`RX_VK_LAB_AB`) is this switch in its phases | +| `RX_VK_PICK_WIDE=0` or `check` | (Triforce, 11-26, the GPU audit's C02; `gpu/vk/pickwide.h`, `gpu/vk/vk_shader.cpp` `program_for_wide`; measured on v0.8.4 at the end of this row) `=0`: a graphics draw's program is `program_for`'s alone, as before: its pair of last picks, which compares `ub_generation()` and so misses after every inline uniform update, and on a miss the inputs' hash, the picks' table, every answer's handle read and, where one differs, all of them read again with their types compared. The default asks a memo of the recording thread's own first (16 sets of 2 by the program object's serial, one entry a program object, vertex inputs and colour types): an entry stands as the pair does and, for a program whose answers are all handles in c2 of their own stages (`answer_stage_mask`, from its descriptors), across uniform updates too, since c2 is served from the bound textures alone; an entry whose textures moved is asked in one pass over its answers (each handle read once, a slot seen and checked at its version not asked again, the others' types compared canonically, an unbound slot taking any: `still_valid`'s verdict); anything else is `program_for`, whose program is only noted there (its inputs and a pointer: no answer read) and kept once a pass, at those inputs' next draw, finds it of the bound textures' types, so a program drawn once before its entry is replaced costs only the memo's find and the note. Mesh and compute picks are `program_for`'s, and `program_for`'s own line (`vk: program picks: N kept ... of N`) then counts only the picks that come to it. The one known way to another program than with `=0`, both of the bound textures' types: `program_for` empties a thread's picks past 65536 keys and takes the first fitting variant in the list's order, where the memo keeps the one it has (two can fit when an answer is unbound). The memo stands in front of `program_for` and not in it because `program_for` is in the translation stamp: no token of the stamp changes, so no shader cache starts again. `RX_VK_PICK_BIND_GEN` (set to anything, as `program_for` reads it): an entry stands only while nothing at all was bound and no uniform updated, the pair's old rule. `RX_VK_DEFERRED_LATE` (likewise): an entry stands on its stages' textures, but not past a uniform update. The switch is read as a number: `check` (exactly) is the check, a number other than 0 the default, and `0` or any other word (`on`, `Check` and an empty value included) `=0`, logged. `=check`: a draw the memo answers is asked of `program_for` too, whose program is drawn (the others are `program_for`'s alone); the differences are counted, and of them the memo's programs not of the bound textures' types (a wrong variant is NaN on screen), the first 20 logged, and a difference reaches the line's totals at once, with every count its thread held; `program_for` being asked at every draw there, its pair and its picks move as with `=0`, so `check` tries the memo's answers and not the state of the default mode, where `program_for` is asked seldom. The lab's knob `nopickwide` (`RX_VK_LAB_AB`) is `=0` in its phases (a thread's memo is cleared at each change). The line "vk: a frame: ... draws kept their neighbour's descriptors ...; N program picks by the wide memo (N past a uniform update), N by one pass over their answers (N of them a noted program's first, N types compared), N by program_for (N of its programs not of the textures at their next draw, in all)" counts them a frame, with check mode's totals behind; "by program_for" near the memo's count says a stretch of the frame draws more programs than the memo holds, or one program object with three or more sets of vertex inputs or colour types in turn: the memo's set is by the program object's serial alone, so those take one set's two ways in turn and none of them ever gets a memo answer. With `=0` and in the `nopickwide` phases nothing is counted, so the line's picks are 0 there but for what a thread held from the phase before. Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.130 ± 0.056 ms (1.7% fps). The check run (all four scenes, every rider checked at once): 7,902,642 picks compared, 0 differences | | `RX_VK_PROF_ALL=1` (the dispatch's pick clock) | (Triforce, 11-22, the performance audit's DESC-30, after Source A's and Source B's) Every profiling scope timed, and with it the clock pair around each compute dispatch's program pick, as before. Unset, the pick's time for the stall line is the change of the thread's exactly timed nanoseconds across the pick (its slow path is timed by `PROF_EXACT`), so a pick the memo answers reads no clock. DESC-30 has no switch of its own, the results being the same: besides the pick, `taau_key` answers from its list parsed once (it wrote the key out and walked the list as text several times a dispatch), `RX_VK_LOG_PUSH` formats its key only when set, the first-pipeline clock is read only when there is one to make, and `texture_frame` fills `RX_VK_LOG_BAKED`'s list only for that switch (read once) and finds its largest textures by a partial sort. The lab's knob `diagold` (`RX_VK_LAB_AB`) puts all of it back in its phases (`gpu/vk/vk_draw.cpp` `dispatch`, `taau_key`, `dispatch_diag_old`; `gpu/vk/vk_texture.cpp` `texture_frame`) | | `RX_VK_LAB_AB=e_draw:`, `e_dispatch:`, `d_present_after:` | (Triforce, 11-22, the performance audit's REPLAY-51, after Source B's; lab knobs of the in-run A/B, `gpu/vk/lab_ab.h`, nothing without the variable) The `d_` knobs wait once a frame; `e_draw` and `e_dispatch` wait the knob's nanoseconds at every draw or dispatch, first in `draw()` and `dispatch()` so the profiles leave it out, on whichever thread records, and count each wait. The frame's change against the time spun says how much of that path is on the frame's critical path (200 ns at about 3,050 draws a frame is 0.6 ms of work). A phase's end logs `vk: lab A/B: phase e_draw: over:` with its waits and ms a second. `d_present_after` is `d_present`'s control: the same wait just after the present's `drain(0)`, where `d_present` is just before it. Pin `RX_VK_PARALLEL` with the `e_` knobs (the log warns otherwise): Automatic moves draws between threads. Off: one relaxed load a draw. `tests/test_lab_ab_each.py` | | `HOS_OOT_SHADOW_STEP=` | (Triforce, 11-21, the performance audit's GAME-05) The game gives each nearby character or object a square depth shadow map sized by its size on screen, 384 to 1,920 a side, so while anything moves each frame asks for depth textures of sides not seen before. The one read of the side is rounded up to a multiple of `` (a power of two up to 256; 64 when not set): 25 sizes, which come round again, so the render targets' pool serves them. A map gets at most 63 more texels a side; its projection does not change. `0` or `1`: the game's own side, as before (`host/oot_shadow_step.h`, `host/oot_shadow_step.c`, `nx2/oot_patches.py` `patch_shadow_step`) | @@ -340,6 +354,7 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_TEX_WARM_LIST=1` or `2` | (Triforce, 11-22, the performance audit's TEX-23, after Source A's; off unless set, and only with `RX_VK_TEX_WARM=1`) The textures made ahead by a list of what was drawn (`gpu/vk/tex_warm.h`). Every registered slot made ahead needs the 40% rule, and on an 8 GB card that rule stops the warming at once. With the switch, a BC or ASTC texture a draw uses within 90 s of the game making it is learnt: its shape and eight 64-byte samples of its bytes, at its storage's address. The list is kept beside the game as `triforce_textures_drawn.bin` (32,768 at most; saved every 300 presents when it changed; a file cut short or of another version is not read). At a light frame the ripe slots the list names are made while the textures and 256 MB more fit their budget and the render targets' pool is not being given back; `1`: the others after them, by the 40% rule, once no noted slot is left ripe; `2`: the listed alone. The look itself learns nothing. "vk: textures made ahead by the list" counts listed, unlisted, learnt and no-room. Unset or `0`: every registered slot as above. Not measured: lab proof first (the entry's own default is `1`). `tests/test_tex_warm_list.py` | | `HOS_MEM_LIMIT=1` or `` | (the lab's) The game's memory held to what it is told it has, as the console holds it. The game is told 9809 MB, but nothing was refused until the PC's own commit ran out, and it holds 11.7 GB by its own count in a fresh Market and 13.5 GB after a tour (the `mem: census` line), with its GPU heap within 15 MB of full and its texture compaction running every frame. `1`: `AllocateMemoryPages` and `MapPhysicalMemory` are refused past the 9809 MB, and `UsedMemorySize` is the game's count; a number above 1: refused past that many MB. Unset or 0: as before. What the game does when refused is what the lab is to find out. `host/hos_mem.c`, `tests/test_mem_limit.py` Refused, the game asks again thousands of times, each ask a region taken and freed; a region of the game's own freed with none of its pages in it is no longer discarded (`hos_region_discard_needed`), and the regions it frees with pages in them are discarded with the thread's virtual core given up. Those two were the stutter when walking with the limit on: in a three-area lab run the game's own part of the frame was over 8 ms in 24% of the frames before and in 0.3% after (as without the limit), 63.8 fps to 100.0. **`=1` does not fit this build:** the heap takes 6.9 GB of the 9.8 and an area's resources need 4.7 GB and more, so a save's load can starve and stay on its loading screen for good (the owner's, 2026-11-20, read with the hang watch's stacks: the game at 9,807 MB, its load threads idle). Use a size in MB: `12800` loaded and played four areas without reaching it. | | `RX_VK_DESC_SET_KEEP=0`, `RX_VK_DESC_TEMPLATE=0` | A program over the driver's push limit (32 descriptors on NVIDIA's, AMD's and Intel's drivers) has a set written for each draw that builds its descriptors. By default a set whose descriptors are all as those of the last one written for that layout in the recording is bound again instead, while no texture was destroyed or made again and no pool moved, and a set written is written through the program's descriptor update template (Vulkan 1.1). (Triforce, after NX2navi's `desc_template`) A program within the push limit has its descriptors pushed whole (in a new command buffer, or after another program at its bind point) through a push descriptor template of its own (`vkCmdPushDescriptorSetWithTemplateKHR`, one a program and bind point, from the same entries and packed array as a set's), not with the write structs the driver walks one by one; a push of the changed bindings only keeps its write structs. The frame statistics' `a frame's descriptors` line counts the pushes made through it. With `RX_VK_RECORDER` the packet copies the packed array (`gpu/vk/vk_recorder.h`). `RX_VK_DESC_SET_KEEP=0`: a new set each time; `RX_VK_DESC_TEMPLATE=0`: sets written and pushes made with the write structs; both as before | +| `RX_VK_TPL_TABLE=0` or `2` (`check`) | (Triforce, 11-26, the GPU audit's C31, its part (a); `gpu/vk/tpltable.h`, `gpu/vk/vk_draw.cpp` `set_template`, `push_template`) A program's update template and push templates are kept in maps by the program behind one mutex (`tpl_mu`), and each thread had 8 entries a kind of template in front of them (one table for sets, one for each bind point's pushes), by the program's address. A frame pushes the descriptors of far more than 8 programs (335 to 535 sets pushed in full a frame, each through its template), so most lookups took the mutex and searched a `std::unordered_map`: 0.8% of the Presentation Thread's time at Lake Hylia and 1.1% in the Market (about 0.07 and 0.06 ms a frame; expected back, with the lock pair, 0.08 to 0.11 ms at the lake and 0.06 to 0.08 ms in the Market; measured on v0.8.4 at the end of this row), and the replay's helper threads met on the one mutex. By default each thread that looks templates up has a table of 512 sets of 2 entries (16 KB, one for the three kinds of template) by a multiplicative hash of the program's address and the kind, made at its first lookup and freed when the thread ends (none with `RX_VK_TPL_TABLE=0`, nor with `RX_VK_DESC_TEMPLATE=0`, which makes no templates). An entry is what the 8 held, and what is found is checked the same way before it is used (the template's layout is still the program's); a miss is the locked path as before. Only where a template is found changes, not which template or what is pushed. A set keeps its two keys first in, first out, so a set that three or more of a frame's keys fall in misses on each of them every frame: in a play test's frame statistics, the lines of 400 lookups a frame or more still took the lock on about 10% of them (21% at worst). More ways or another hash are a change of their own, to be measured. The table is beside the program, not on it (`sizeof(Program)` is in the shader caches' stamp). `RX_VK_TPL_TABLE=0`: the 8 entries, as before; `RX_VK_TPL_TABLE=2` or `check`: the check, every template found in the table also asked of the map under the lock (so every lookup takes it) and the differences counted; the table's template is still the one used. Another value is read by its leading number, as `atoi` reads it: 2 (as in `02` or `+2`) is the check, 0 the 8 entries when the value starts with 0 (as in `00`), anything else the table, as by default; any value other than `1` or empty is logged once, with what it gives. The lab's knob `notpltable` (`RX_VK_LAB_AB`) is the 8 entries in its phases. The frame statistics' `a frame's descriptor templates` line counts the lookups, how many of them missed the table and took the lock, and the check's result, labelled by the switch (not by the lab's phase). Tests: `tests/test_tpltable.py`, `tests/test_desc_sets.py`. Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.192 ± 0.090 ms (2.6% fps). The check run (all four scenes, every rider checked at once): 4,618,250 templates checked against the map, 0 different | | `RX_VK_CREATE_NEW_MS=` | While the hold is on, a sampled texture seen for the first time once the frame's makes took this long (8), or its uploads their budget, is not made yet (`vk_texture.cpp` `create_later`): the draw samples the dummy, the frame is held, the next frame makes it. The frame's first make always goes; never a dispatch's. `0`: made at once, as before (a texture left for later was made all the same). The stall line counts the textures made, their time, those not made yet, and the images made | | `RX_VK_UNSWIZZLE_MT_MB=` | A block-linear level unswizzled on the CPU is split over several threads (a thread for each 2 MB, 8 at most) from this size (4); `16`: from 16 MB, as before | | `RX_VK_PROGRAM_READAHEAD=` | After a draw reads a program from the program cache itself, or takes one read ahead, workers read the next `n` programs (32) and keep them made for the draws that come to them, 512 at most (`gpu/vk/program_readahead.h`). `0`: none, as before. The log's `vk: programs from the cache` lines and the stall line count them | @@ -379,6 +394,7 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_PREDICT_CHECK=0`, `=2` | (Triforce, 11-22, the performance audit's PIPE-68, after Source B's and Source A's; `gpu/vk/predict_check.h`) On unless `0`. The predicted pipelines are built once for the driver's own cache and a record says which programs are done; a driver can lose them all the same (NVIDIA's cache cap, a cleared cache folder, AMD's Windows driver keeping a third). At a start whose record says all are built, the builder's idle thread, after its delay and only while the frame shown is a light one, samples up to 12 of them spread over the plan: each built for the driver's cache alone and timed, then once more as the warm reference; cold is a first build over 4 times the second and 3 ms more, and the sample ends once its majority is decided. Cold: the record is removed, so they are all built again behind the game at light frames, and `.predicted.check` takes a strike for these shaders and this driver; cold again after that, the log says this driver does not keep them and no later start checks. Warm: the strike is forgotten. `2`: checked at every start, a recorded stop too. Also counted: the builds in play of programs the plan predicts that took over 20 ms (`vk: predicted pipelines: N builds in play of predicted programs took over 20 ms`, at most every 10 s while it grows). `0`: neither the check nor the counter, as before (`gpu/vk/vk_draw.cpp` `predict_check_cold`, `predict_background`, `predicted_play_build`) | | `RX_VK_PREDICT_TYPES=1` or `0` | (Triforce, 11-22, the performance audit's PIPE-44, after Source A's; `gpu/vk/predict_types.h`) Unset: each predicted pipeline is built once for its program, by its key as play keys it (two predicted layouts that differ only in what is dynamic, a stride, gave the same pipeline twice): the same pipelines, fewer builds. `1`: that, and the plan drops a predicted vertex layout whose attributes definitely differ from the program's vertex inputs (an integer input against a float attribute, or the other signedness, read from the vertex module's SPIR-V; scaled formats count as integers): such a pipeline is invalid. Off by default because it changes which pipelines are built, and it applies to a plan made after it is set (a plan is made once for the shaders). `0`: every predicted pipeline built, as before. The predicted lines say how many were left out as built already, how many programs the programs' file did not lend, the notes of variants it has no shaders for and the layouts that did not fit (`gpu/vk/vk_predict.cpp` `predict_pipelines`, `gpu/vk/vk_draw.cpp` `predict_first`) | | `RX_VK_DRAWN_PAGE_MAP=0` | (Triforce, 11-21, the performance audit's TEX-21) A texture in a virtual pool is checked through its mapping, 64 KB a page, and its page map was recorded at its first check: one the GPU drew first had none, so once the game finalized it the first check took its whole storage as mapped since and uploaded it from memory over what the GPU drew (HUD labels and render targets blank after an area change, up to 15 MB an upload). The map is recorded at the first draw that says who drew it, and the later check gives only the pages mapped anew or written by the CPU. Not for a write that gives no reason (a clear, the movie upscaler). The log counts them. `0`: at the first check, as before (`gpu/vk/drawn_page_map.h`, `vk_texture.cpp` `texture_written`) | +| `RX_VK_BAKE_SCAN=all` (or `0`), `=check` | (Triforce, 11-26, the GPU audit's C36) The bake write-back (a texture the GPU drew in one frame, such as a terrain tile's normal map, gets its texels written into the game's memory) looked for its textures by walking the whole texture cache every fourth present, a dozen tests a texture: 1.1% of the Presentation Thread at Lake Hylia and 0.9% at the Market (about 0.35 / 0.2 ms on each fourth present), for a walk that finds nothing where the recordings write them back themselves. The textures it can take (drawn in one frame, their texels not in the memory yet) are now listed where they become so (`texture_written`, and the step's two lost copies; a destroyed one leaves the list in `forget_gpu`), and the step asks the rest of its test (four presents old, sampled lately, not released nor only cleared, small, in the guest window, with an image whose format can be copied out) of the listed ones only; a listed texture stays listed until it is written back, drawn in a second frame, its contents dropped or destroyed. Under the step's caps (24 textures, 8 MB) the oldest listed go first, where the walk took the hash map's order, and one no step can take (more than 8 MB of storage) is passed over, where the walk stops at it as before; so the same textures are taken, but for those the walk does not reach behind such a one. Default: the list. `all` or `0`: the walk of the whole cache, and no list, as before (with `RX_VK_BAKE_WRITEBACK=0` there is no list either); `check`: the walk of the whole cache, and every armed texture the list does not hold is counted and logged, each once (must be 0). Lab knob `nobakescan` (`RX_VK_LAB_AB`): the whole cache in its phases. A line of its own every 600 presents counts it: "the bake write-back's scan: by the list at N steps (N listed textures looked at; the cache held N at those steps), ... armed and not listed ...: 0" (`gpu/vk/bakescan.h`, `vk_texture.cpp` `bake_writeback_step`). Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.145 ± 0.062 ms (1.9% fps). The check run (all four scenes, every rider checked at once): 0 armed textures not listed | | `RX_VK_DEAD_SUM=0`, `RX_VK_DEAD_POOL_NOW=0`, `RX_VK_DEAD_MIN_UNUSED=3` | (Triforce, 11-21, the performance audit's TEX-30) The frame's transient render targets, drawn over from another start: the other targets' parts over one are added up, each byte once, so one covered at its head by one target and at its tail by another, each under an eighth, is let go too (it was kept for good); it is dead after 1 unused present, not 3; and its image goes to the render targets' pool in the pass that lets it go, once the GPU is done with it, not at the next present. `RX_VK_DEAD_SUM=0`: judged one by one; `RX_VK_DEAD_POOL_NOW=0`: pooled at the next present; `RX_VK_DEAD_MIN_UNUSED=3`: three presents: each as before (`gpu/vk/target_overlap.h` `ShiftedOver`, `vk_texture.cpp` `texture_sweep`) | | `RX_VK_ASTC_REUSE=2` | (Triforce, 11-21, the performance audit's TEX-14, its first step; off when not set) When the game comes back to an area it makes its textures again, mostly at other addresses, and the same ASTC blocks are decoded and encoded again while the image made of them the first time may still be in VRAM. With `2` a new ASTC texture's blocks are hashed at its first upload (128 bits), the textures the game finalizes that were uploaded from memory and never drawn into are listed, and each new texture with a listed one's blocks and shape is counted: the log's `decoded ASTC used again` line says how many MB of images a copy would have stood in for, and what the hashing cost. Every texture is decoded as before. The copy itself is not built: the walk it was measured on would have reused 0 to 11 MB, and the audit asks for 500 MB on a tour before it is (`gpu/vk/astc_reuse.h`, `vk_texture.cpp` `reuse_upload`) | | `RX_VK_KEEP_OBSOLETE=1` | (Triforce, 11-21, the performance audit's TEX-43) A texture the GPU drew in one frame is kept after the game finalizes it, for being made again over that storage and sampled undrawn (the terrain's tiles; `RX_VK_KEEP_FINALIZED_MB`). One of 32 KB or more, in no virtual pool, whose storage the CPU has written three quarters of since the release holds nothing that memory holds any more: the sweep lets it go whatever the budget says, where only a draw over it did, and the game's own writes kept each for good (about 200 render target images an hour in players' logs). The log counts them. `1`: kept, as before (`gpu/vk/finalized_obsolete.h`, `vk_texture.cpp` `texture_sweep`) | @@ -393,6 +409,7 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_NO_WRITEBACK` (set) | GPU writes to mirrored pools are not copied back to guest memory (an experiment, for A/B) | | `RX_VK_MSYNC_PASS=0`, `=1` | (Triforce, 11-21, the performance audit's MEM-48) A mirror sync's pages that come from a capture's buffer go to the pool's VRAM mirror by the write-back diff's compute pass, one dispatch a sync, where they were copy regions of a page or a few each (700 to 1,300 a frame, each read over PCIe after the one before). A run not in whole words, a GPU without subgroup votes in compute and a sync whose chunk table finds no room keep the copies; a mirror written twice in one upload command buffer, once by the pass, gets a full barrier between. On for NVIDIA when not set; `1`: on every GPU; `0`: copy regions, as before. The log's `mirror syncs' pass (600 submits)` line counts dispatches, chunks, fallbacks and barriers; `RX_VK_LAB_AB=nomsyncpass` is the in-run comparison (`gpu/vk/msync_pass.h`, `vk_memory.cpp` `msync_pass_add`, `msync_pass_flush`) | | `RX_VK_WB_FORGET_SORT=1` | (Triforce, 11-21, the performance audit's MEM-61) At the end of each part with write-backs the write-back diff clears, for every page written since, the bit that says its pool's shadow knows the page. The three lists of such pages (the game's writes, the collection's, the replay's) were sorted first, thousands of pages a part, only so that the pool found for one page serves the next; the bits and the counts do not depend on the order, and the lists hold ascending runs as they come. They are no longer sorted. The log's `forgetting the written pages took` line gives the time. `1`: sorted, as before (`vk_memory.cpp` `shadows_forget_written`) | +| `RX_VK_CPU_WORDS_SEEN=0`, `=check` | (Triforce, 11-26; on by default; measured on v0.8.4 at the end of this row) Every word of a counter report the replay writes into guest memory is noted again each time (`gpu/vk/vk_memory.cpp` `memory_cpu_owned`), as before: pushed, then sorted and searched for in both sets of such words at the next part's end with write-backs (`cpu_words_merge`), where the same words of every frame are found and dropped (1.6% of the Presentation Thread at Lake Hylia, 2.5% at the Market on v0.8.3). Without it a table of the words the sets hold answers at the note (`gpu/vk/cpuwordsseen.h`), and a word held already is not pushed. An entry is the word's whole address and the sets' generation, and the table forgets where the sets are cleared (past 65,536 words), so it never calls a word known that the sets do not hold: such a word would be copied over by a mirror's write-back, the one-frame dark flashes of 11-07. The sets and the write-backs' cut runs are the same (`tests/test_cpuwordsseen.py`). `RX_VK_CPU_WORDS_SEEN=check` notes every word as before and looks each word the table knows up in the sets. Any other value: the table, as unset, and logged. The log's `mirror syncs (600 submits)` line ends with `report words: N asked of the table, N known to it and not noted again (noted all the same with =check), the sets forgotten N times, N check mismatches since the start (RX_VK_CPU_WORDS_SEEN)` (the first three since the line before; nothing is asked of the table with `=0` or in the knob's phases). Without mirrors (`wb_notes_off`: Intel's integrated GPUs, `RX_VK_MIRROR=0`) or with `RX_VK_WB_REPORTS` set no report word is noted: the switch is not read or logged and the four counts stay 0. The `RX_VK_LAB_AB` knob `nowordsseen` notes every word again in its phases. Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.106 ± 0.048 ms (1.4% fps), measured while the knobs `nocapgap` and `nobindspan` were still asked at every left-out check and every binding that may use a span, string compares that every knob's phases paid and the phases without a knob did not, so the figure is likely somewhat high (by an estimated 0.03-0.09 ms). The check run (all four scenes, every rider checked at once): 158,588 report words noted, 0 check mismatches | | `RX_VK_WB_DIFF=0` | Write-backs copy every byte again instead of only what changed against a VRAM shadow (the diff is on by default; v2.0.9 and v2.0.10 had it off, issue 1161) | | `RX_VK_LAZY_WB=1`, `=2` or `=0` | The lazy write-back for one run, over the Debug tab's Lazy write-back row (`lazy_write-back=1`; on by default since options_version 5; `docs/lazy-writeback.md`, `gpu/vk/wb_lazy_state.h`): a whole page of what shaders write into a mirrored pool that the CPU leaves alone is no longer copied back at every submission; its page has no access, and whoever touches it (the game's code or the host's, by a fault; a host call that hands it to the kernel; the GPU through the import) has it copied down first. Windows only. On AMD's driver the row alone leaves it off, as NX2navi did after games ended in play there; `=1` turns it on anyway. `=2` is the self-check: every copy is still made, the pages are protected and paid as if not, and each payment compares what it would have copied with guest memory: a `MISMATCH at guest` line is a page it would have got wrong. The log says `vk: lazy write-back on` (or why off) at the start, and every 600 submits `vk: lazy write-back (600 submits)`: the MB not copied, the pages owed, the pages paid by a fault, a host call, a GPU read, a mirror given up and a recording's submit, the payments and their time, and what failed | | `RX_VK_LAZY_PAYERS=<1..4>` | (Triforce, 4 by default; `=1` as before) How many of the lazy write-back's payments copy at once (`gpu/vk/wb_lazy_payers.h`, NX2navi's `wb_lazy_unlocked`). A payment's copy goes onto the queue after everything submitted so far and its thread waits for it (0.5 to 3 ms each in the owner's sessions, up to 21 ms at a load); with one at a time, a second thread that touched another owed page, or the replay giving a mirror up, waited for the first one's copy to come back before its own went onto the queue. Each payment holds a slot of its own (a command buffer and a fence); the pages of two payments are never the same ones (`gpu/vk/wb_lazy_state.h`), and each copy still goes onto the one queue after everything before it. The 600-submit line `vk: lazy write-back (600 submits)` ends with the payments that waited for a free slot and the most slots in use at once | @@ -401,18 +418,20 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_N64=<0..2>`, `RX_VK_N64_LINES=`, `RX_VK_N64_LOD=`, `RX_VK_N64_TV=0\|1`, `RX_VK_N64_MASK=<0..4>`, `RX_VK_N64_FPS=` | (Triforce) N64 Classic for one run, over the Insert menu's N64 Classic row and its Remembered page (`gpu/vk/n64_rules.h`, `gpu/vk/vk_n64.cpp`): 1 Faithful, 2 Remembered (its page's values), 0 off; unset, the row (F7 turns it on and off, but not while the switch is set). Its 3D pass takes every gameplay upscale network's place (`shaders/n64_3d.comp`): the 3D on a grid of 240 lines (480 for Remembered) as wide as the picture's shape, each grid pixel the mean of its footprint, Faithful's at 15-bit colour with the ordered dither, then out to the picture's size, linear along each line and hard between lines. While it draws, DLSS, FSR 3.1 and FSR 4 step aside (the game's own as far as they are concerned) and the game's SMAA is left out (`RX_VK_AA` still goes over that); not on a RenoDX run's RGBA16F scene. `RX_VK_N64_LINES` sets the grid's lines. (Step 3) The texture blur: the scene's tiled material textures sampled that many mip levels coarser (Faithful +2.5, Remembered +1.5, never past the card's `maxSamplerLodBias`), on the upscalers' scene-only path (not the shadow maps, the HUD or the output's passes); `RX_VK_N64_LOD=` over the preset's, `0` none. (Step 4) The TV at the window, in the filter's place at the window's own pixels, HUD and all (the FPS counter is drawn after it; the options' own screens go under it, below): the screen's curve, the composite colour bleed, the beam across 240 TV lines (wider where bright), the mask (Auto: the slot mask on a picture placed 1440 lines tall or more, none below), the glow from the picture at 1/8, the vignette; not on HDR Native's PQ picture, nor under DLSS frame generation, nor with `RX_VK_UPSCALE=0`. `RX_VK_N64_TV=0` leaves it out, `RX_VK_N64_MASK=<0..4>` (Auto, none, aperture grille, slot mask, shadow mask) picks the mask. (Step 7) The frame rate: Faithful 20, Remembered its page's Frame rate row; the renderer tells the host once a present (`HOS_OPT_N64_FPS`), which paces the game at it from the next frame, no restart (`host/n64_pace.h`, `host/nn_vi.c` `n64_pace_decide`): never above the Frame rate cap, never under 15, not while a movie plays, game time real time. `RX_VK_N64_FPS=` over both presets (0 the cap's); `HOS_N64_PACE=0` keeps the cap's whatever the renderer says. The log says `vi: N64 Classic: frames paced at` at each change. (Step 8) At F7 or a change of the row, half a second of the TV switching off and on (the picture squashed to a bright line, then a dot, and opened again), the 3D, the TV and the frame rate changing at its middle (`n64_tick` once a present); not on HDR Native's picture nor under DLSS frame generation (the choice at once there), and not at a start. `RX_VK_N64_TV_ANIM=0`: the choice at once. (11-22) The options' own screens (the open menu, our tabs over the game's Options screen, the Mods entry) are drawn into a layer of the picture's place that the TV lays over the picture before its steps, so they bend, scan and bleed as the game's own screens under them (`vk_menu.cpp` `menu_tv_layer`, `vk_imgui.cpp` `record_layer`), and the glow's 1/8 copy is made again with them over the picture (else it blurred the game's own panes through their plates); the FPS counter, the notice and benchmark mode's panel stay over it, flat; with HDR on the options stay over it too (their pictures are in HDR10's codes, not the SDR picture's). The mouse is taken through the TV's curve to where the options and the game's own menus were drawn (`n64_rules.h` `screen_point`, `vk_n64.h` `n64_screen_point`; the game's through the renderer's `screen_point`). `RX_VK_N64_TV_MENU=0`: the options over the TV, flat, as before. The log says `vk: N64 Classic:` at its first grid and each new size | | `HOS_EVIL_HD=0`, `=1`, `HOS_EVIL_HD_DIST=<1..4>` | (Triforce, Evil HD) Over the Graphics tab's Evil HD row (`evil_hd`, off unless chosen): on or off for one run, and how far its render distance goes, a factor from 1 to 4 (4 when not set; `1`: the game's distances, as before, with the row on). It draws the foliage farther: the grass and undergrowth (40 and 60 m as shipped), flowers and stones (35 m), the low trees of the distance (135 m) and their shadows (40 m), with the fades between the trees' levels, the factor times as far. They are the defaults of the game's foliage LOD settings (`game::foliage::ResLodSetting`, eight floats at main+0x3eefd38 that the game's parameter code reads by address when an area loads); `host/evil_hd.c` writes them each time the factor changes, after checking they are this game's. The foliage system builds an area's distances from them once a run, the first time it enters it, so the row applies from the start of a run (the menu asks to restart; a change mid-run reaches only the areas not visited yet). Seen 11-24 (headless, 1920x1080, Hyrule Field from the Market's drawbridge at noon): at 4x the grass tufts and small plants cover the meadows out to the ranch and up the hills, where off they stop at about 40 to 60 m; at 2.5x part of the way; with all eight at 0.5 m the ivy and grass by the Lost Woods bridge go. Cost there, uncapped on an RTX 5090 PC whose frame the CPU limits (20 s each): off 147 and 128 fps, 2.5x 128, 4x 124 and 123, about 0.8 ms a frame at 4x, the draws the same (about 2100). Areas whose data sets their own (the Graveyard, Zora's River and Domain, Hyrule Castle's flowers, Kokiri Forest handheld) keep theirs. Draw only, and not changed: the camera's far plane (25 km in play, near 0.1 m: not what limits the view; 1000 m is the title screen's camera), the model LOD coefficient (`game::gfx::ModelLodParam`: at 0.05 no visible change), the actors' presence radius (`DisplayRadius`, which creates and deletes them) and their update radius (`CalcRadius`). The log's `evil hd:` line says each change (`host/evil_hd.h`, `tests/test_evil_hd.py`) | | `RX_VK_STUB_SAME_SIZE=0` | (Triforce, 11-22, the performance audit's GPUWORK-21, after Source B's and Source A's; `gpu/vk/stub_same_size.h`) On unless `0`. A gameplay upscale network that cannot run (left out or not translated: `RX_VK_NO_F16`, a card or driver that cannot build it) is stood in for by its input drawn into its output (`gpu/vk/vk_draw.cpp` `upscale_stub`) also where the two are one size: `9dc98871eb7fc101`, the network of Render resolution 100%, was declined as "no larger than its input" and skipped whole, a black 3D under the HUD. Both gameplay networks now take the typed upscale first (it reads the scene's shared-exponent picture and undoes the network's square-root encoding; it was the 3/4 network's alone), then the blit, which warns of wrong colours for both, then nothing. The picture is the upscaler Off's: softer, none of the network's anti-aliasing. Only where the network cannot run. `0`: the decline, and the 3/4 network alone in the typed upscale, as before. `RX_VK_NO_UPSCALE_STUB=1` still turns the whole stub off; `RX_VK_FORCE_UPSCALE_STUB=2` sends every network through it, for a look | +| `RX_VK_WIDE_UPSCALE=0` | (Triforce, 11-26; `gpu/vk/vk_draw.cpp` `wide_upscale`) On unless `0`. With RenoDX's RGBA16F scene and the game's own upscaler, the gameplay upscale below 100% (the 3/4 network at 75% and Auto, the networks of the other shares where they are left out) is drawn by the stand-in's pass, which squares the network's input (the square root of the scene colour) back, into an R11G11B10F image and from there into the picture. Without it the 3/4 network drew a black 3D and the plain blit of the others a 3D veiled in white. `0`: as before | | `RX_VK_DLSS=0/1/2`, `RX_VK_DLSS_PRESET=`, `RX_VK_DLSS_LOG=1`, `RX_VK_REFLEX`, `RX_VK_REFLEX_LOG=1`, `RX_VK_ANTILAG=0/1` | NVIDIA DLSS and Reflex, and AMD Anti-Lag 2, for one run (`=-` on Reflex or Anti-Lag 2: its extensions not even enabled): the readme's NVIDIA DLSS section. `RX_VK_DLSS_TRACE=` logs one frame's large draws every that many frames, `RX_VK_DLSS_DEBUG=motion` shows the motion vectors, `=alternate` the game's own upscale every other frame | | `RX_VK_FSR4=0/1/2`, `RX_VK_FSR_DIR=` | AMD FSR 4 for one run (0 never, 1 FSR 4, 2 its Native AA), and another folder for AMD's DLLs (not from `hookshot_env.txt`): the readme's AMD FSR 4 section. `RX_VK_FSR4=1/2` and `RX_VK_DLSS=1/2` go over the Upscaler row, a saved FSR 3.1 too where the engine they ask for runs; `RX_VK_FSR=1` goes over them (one upscaler at a time; `=2`: FSR 3.1 as its Native AA, the 3D at full size). The DLSS trace and debug switches above apply to FSR 4 too, on the frame chain they share | | `RX_VK_XESS=0/1/2`, `RX_VK_XESS_DIR=` | Intel XeSS Super Resolution for one run (`gpu/vk/vk_xess.cpp`, Windows only): 0 never (Intel's `libxess.dll` not even loaded), 1 Intel XeSS, 2 its Native AA, over the Upscaler row as `RX_VK_FSR4` is (DLSS before FSR 4 before XeSS); and another folder for `libxess.dll` (else beside the executable, then the game folder). The DLL is the player's, from Intel's XeSS SDK: Triforce builds only against Intel's MIT API headers (`third_party/xess`), never links, ships or downloads it. With it there, the instance and the device are made with what XeSS asks for (a device refused with them is made again without, XeSS off for the run) | | `RX_VK_FSR4_DRS=1`, `RX_VK_FSR4_AUTO_EXPOSURE=0` | (Triforce) AMD FSR 4's context as before, for comparing (`gpu/vk/vk_fsr4.cpp` `make_context`, `gpu/vk/temporal_rules.h` `plan_context`): `RX_VK_FSR4_DRS=1` one context with FSR's dynamic-resolution flag for every render size from the start, where a fixed Render resolution otherwise gets a context of its own size without it (and the game's dynamic resolution one with it once the size first changes); `RX_VK_FSR4_AUTO_EXPOSURE=0` its HDR contexts (Upscale before bloom, or an RGBA16F picture with RenoDX's HDR Native) without FSR's auto exposure. A creation or evaluation of DLSS or FSR 4 that fails leaves the game's upscale for 2 s and is tried again; the fourth failure in a row turns that engine off (the Upscaler row then shows Game and says so) until the row is set again | | `RX_VK_SHARPEN_3D=0`, `RX_VK_FSR3_BOOST=0`, `RX_VK_UPSCALE_LOD_BIAS=0/` | (Triforce) For comparing with before (`gpu/vk/sharpen_rules.h`): the Sharpness row sharpens the 3D before the HUD with DLSS, DLAA, FSR 3.1 and FSR 4 (FSR 3.1's own RCAS, FSR 4's own sharpening, FSR 3.1's RCAS pass over DLSS's picture) and then nothing at the window; `RX_VK_SHARPEN_3D=0` the finished picture at the window for every upscaler, the HUD with it, as before. `RX_VK_FSR3_BOOST=0` FSR 3.1's sharpness the row's alone, without the share towards the most below three quarters of the output's width. `RX_VK_UPSCALE_LOD_BIAS=0` no texture LOD bias while DLSS or FSR scales the 3D with jitter (unset: log2(render / output) - 0.5 in quarters of a level, so -1.5 at Performance, -1 at Quality and -0.5 at the Native AAs, on the wrapping, mipmapped textures of the draws into the scene at the upscaler's render size (or, in the frame the dynamic resolution steps, at the size the scene's camera is drawn at), never the shadow maps, captures, other passes or dispatches; the log says `vk: texture LOD bias` at each change); a negative number, such as `RX_VK_UPSCALE_LOD_BIAS=-1` or `=-1.5`, that bias (-3 at most) in the same draws and only while an upscaler with jitter runs, for trying other values (the log says it once at the start) | +| `RX_VK_DLSS_BLENDED_MOTION=1` | (Triforce, 11-26) For comparing with before (`gpu/vk/vk_draw.cpp` `own_motion`): draws that blend over the scene (fireflies, glows, fog cards) are given a motion of their own for DLSS, FSR 3.1 and FSR 4, as before. Off by default: they keep the camera's motion, as the reactive mask expects (`gpu/vk/reactive_policy.h`); with their own, FSR 4 drew white rings and trails round the fireflies of Kokiri Forest (the owner's capture of the white lines). | | `RX_VK_FSR4_MODEL=auto/lite` (or `0/1`) | Over the Graphics tab's FSR 4 model row for one run: Auto lets AMD's library pick the network for this GPU (as before), Lite forces its INT8 Lite network (`ffxProvider_FSR4Lite_Int8`). Only for the one upscaler library whose layout is known, FSR SDK 2.4's `amd_fidelityfx_upscaler_vk.dll` by its SHA-256 (`gpu/vk/fsr4_models.cpp` `kKnown`, the hash `scripts/fsr_sdk.py` pins): it is loaded from its full path before AMD's loader asks for it, and its providers' IsSupported answers are hooked in this process; any other file is neither loaded nor scanned, and the row is not shown. The row shows on AMD GPUs with FSR 4 as the Upscaler. A Lite context AMD refuses, or whose dispatch fails, is Auto for the rest of the run (the log says so) | | `RX_VK_FSR4_STANDIN=1` | Where AMD's library lists no FSR 4 model for the GPU (another maker's GPU, or a Radeon AMD names none for) and the Lite provider is hooked (`RX_VK_FSR4_MODEL` above), the list is asked again with Lite answering: FSR 4 is then offered and every context runs INT8 Lite, with AMD's own shaders (the log: `INT8 Lite stands in`). Off unless set: FSR 4 stays off on such a GPU, as before | | `RX_VK_FSR4_TUNE=1`, `RX_VK_FSR4_UNROLL=0` | AMD FSR 4's passes tuned as AMD's library makes them, on AMD GPUs (off unless set): the network's layers run 64 lanes wide, the weight tables the layers and the postpass copy into per-thread arrays are read from a tail of the library's storage buffer, and the small layers with weight tables are unrolled, built one at a time in the background (`gpu/vk/fsr4_tune.h`, `vk_fsr4.cpp`). Measured 8.97 -> 4.04 ms on an RX 6700 XT at 720p -> 1440p, bit for bit AMD's output on Adrenalin 26.10.1 (other drivers: the same maths, not necessarily the same bits). Where the library binds its buffer without the tail, or destroys it, AMD's own shaders are bound for that context and the log says so (`AMD's own shaders in place of the tuned ones`). `RX_VK_FSR4_UNROLL=0`: all of that but the unrolling. Frame generation's library is never tuned | | `RX_VK_FSR4_FG=0/1/4` | AMD's frame generation, the Frame generation row's AMD FSR (`gpu/vk/vk_fsr4.cpp` `fsr4fg`): 0 never in this run (`RX_VK_FSR4=0` too, which keeps AMD's library unloaded); 1, as without it, the newest frame generation AMD's library lists for the card, FSR 4's where listed (RX 9000), else FSR 3.1's (3.1.6 on RX 6000 and 7000), the row naming it ("AMD FSR (3.1.6)") and the log the version in use; 4 FSR 4's alone, as before (FG-1) | | `TRIFORCE_MENU_AHEAD=0` | (Triforce) What the options' rows ask of NVIDIA's and AMD's libraries (whether DLSS, FSR 4 and FSR 4's frame generation run here: NGX's start, AMD's loader) asked at the options' open on the presenting thread, as before, and not once on a thread of its own as soon as the game runs (`gpu/vk/vk_menu.cpp` `menu_ahead`; its log line says how long each took). For comparing: the first open waited about 2 s for them in test11 | | `RX_VK_AA=<0..3>`, `RX_VK_AA_KEEP=1` | The anti-aliasing for one run, over the Insert menu's Anti-aliasing row: 0 the game's own SMAA, 1 none, 2 FXAA, 3 SMAA at its Ultra preset in its place (`gpu/vk/aa_rows.h`, `gpu/vk/vk_aa.cpp`). Unset, the row decides; with DLSS, DLAA or FSR drawing from the tone mapped picture (Upscale before bloom off) the game's SMAA is left out (none: they want jittered frames no other anti-aliasing has been over), and before the bloom it runs as the game's; the switch goes over both, for an A/B (`RX_VK_AA=0`: the game's SMAA under the upscaler). The game's SMAA is three compute programs known by their keys (game build `e0f3ccfa`): with another choice in effect its composition is replaced and its edge and weight passes are left out, and `RX_VK_AA_KEEP=1` keeps those two running. The log says `vk: aa:` when a composition is first replaced, why one was left to the game, and when none was found for a minute | -| `RX_VK_THREADED=0`, `=1`, `=auto` | (Triforce; **off by default**, the Debug tab's Threaded rendering row, Off, On or Auto, which this goes over for the run) The renderer's threads as one design (`gpu/vk/threaded_rendering.h`), each piece one Triforce has, driven from here: the replay on its thread (`RX_VK_ASYNC=1`), the recorder thread (`RX_VK_RECORDER=thread`) handed a part at a time (`RX_VK_RECORDER_PARTS`), a submission's parts ending where the game ends its render pass (`RX_VK_PART_MIN`, `RX_VK_PART_FIRST`, `RX_VK_PART_MAX`), the present thread (`RX_VK_PRESENT_THREAD`) asking for the next image right after each present (`RX_VK_ACQUIRE_AHEAD`). Each of those switches, when set, still goes over it. Auto: on from 4 physical cores in the process's affinity; with no buffer-pool mirrors the recorder thread alone from 6; off with `RX_VK_CAPTURE=0`, `RX_VK_LOW_SPEC`, `RX_VK_DUMP` or `RX_VK_BENCH`. `=0` (or the row Off): everything as before. The log's `vk: Threaded rendering:` line says what this run took. The lab's A/B is `RX_VK_THREADED=0` against `=1` | +| `RX_VK_THREADED=0`, `=1`, `=auto` | (Triforce; **off by default**, the Debug tab's Threaded rendering row, Off, On or Auto, which this goes over for the run) The renderer's threads as one design (`gpu/vk/threaded_rendering.h`), each piece one Triforce has, driven from here: the replay on its thread (`RX_VK_ASYNC=1`), the recorder thread (`RX_VK_RECORDER=thread`; since 11-27 not handed a part at a time, `RX_VK_RECORDER_PARTS` below), a submission's parts ending where the game ends its render pass (`RX_VK_PART_MIN`, `RX_VK_PART_FIRST`, `RX_VK_PART_MAX`), the present thread (`RX_VK_PRESENT_THREAD`) asking for the next image right after each present (`RX_VK_ACQUIRE_AHEAD`). Each of those switches, when set, still goes over it. Auto: on from 4 physical cores in the process's affinity; with no buffer-pool mirrors the recorder thread alone from 6; off with `RX_VK_CAPTURE=0`, `RX_VK_LOW_SPEC`, `RX_VK_DUMP` or `RX_VK_BENCH`. `=0` (or the row Off): everything as before. The log's `vk: Threaded rendering:` line says what this run took. The lab's A/B is `RX_VK_THREADED=0` against `=1` | | `RX_VK_ASYNC=1` | The replay on a thread of its own instead of the game's submitting thread (off by default). The game still presents only once the GPU has run its frame, so nothing is released early. (Triforce, `gpu/vk/async_rules.h`; not yet run in the game) With it on, each with a switch of its own to put it back: a signal of the CPU's takes its capture on the game's thread only when a submission handed over before it may still wait for that event, which the host tells at the submit (`RX_VK_ASYNC_EVENT_NOTES=0`: at every signal while the thread has work, as before; the `vk: the replay thread: ... signals of the CPU's` line counts both); the submit's capture shares its copies with the copy helpers and has them all made before the hand-over (`RX_VK_ASYNC_CAPTURE_BEHIND=0`: every copy on the game's thread); the game's submit keeps its virtual core for the hand-over (`HOS_ASYNC_KEEP_CORE=0`: given up and taken again); the game's present poll waits for the replay thread asleep and looks at its event between yields only once the GPU has the frame (`HOS_PRESENT_POLL=0`: the game's own sleeps); a present runs the jobs behind it until the frame's stopped work has gone on and then makes go only what was already stopped at the present before (`RX_VK_PRESENT_DRAIN=1`: every present forces every stopped queue past its wait, as before; `=0`: none does; `RX_VK_PRESENT_WAIT_MS`, 8: how long it runs the jobs behind); and the thread looks for its next job for 100 µs before it sleeps (`RX_VK_ASYNC_SPIN_US=<0..1000>`). Still open, and why it stays off: after a ten-area tour the player's character is drawn black for one frame, 0 to 3 times a minute at the Market (`gpu/vk/async_rules.h` has what the lab ruled out). Two diagnostics for it: `RX_VK_LOG_READBACK_ZERO=1` logs each readback of GPU results that is all 0 where it was not at its readback before, and `RX_VK_REGION_TRAP=1` (with `RX_VK_PASS_TRACE=1` and the frame log) logs the passes of the last frames and writes their render conditions to `region_cond_.txt` when the picture's bottom middle goes dark for a frame, eight times a run. `RX_VK_ASYNC_FORCED=1`: the thread as it was before 11-14, every catch-up forcing | | `RX_VK_OCC_QUERY=0`, `RX_VK_OCC_QUERY_SKIP=[,...]`, `RX_VK_OCC_COND=0`, `RX_VK_OCC_LOG_COND=1`, `RX_VK_OCC_GATE=0` | (on by default since 11-17: +2.7 to +4.6% fps in every scene measured, 10-12% fewer draws, no flicker added; `RX_VK_OCC_QUERY=0` turns it off) The game's samples-passed reports (which objects show; a count of 0 is not drawn) get their real counts: the replay still writes each report as it passes it with 4096 (`RX_VK_OCC_FIXED`, everything visible), and the draws from its reset are counted by Vulkan occlusion queries (precise where the card has them); once the GPU is done with the recording that holds them the count is written into the report's record over the 4096, as NX2navi writes it at completion. The done recordings are found with one look at the recordings' timeline (nothing waits) as a game's fence wait ends (the game reads its counts after it), at each recording's begin and each present, at the latest when the recording's slot comes round. The game's report records rotate (a ring: an address is another object's at its next report), so a count is written only while its report is still the newest at its address, and only when it is whole (every query available, no draw left out, reset and report in one recording, read back within 8 presents); otherwise the record keeps its 4096. The game also predicates draws and clears on these words (render conditions), decided as NX2navi decides them: a word whose newest report is a samples-passed one whose count is still to come is unknown and the condition renders; a word whose count was written (or for which none comes) is read from memory as before, where a written 0 skips the draws and clears it gates. A count goes in only over the value the replay left in the word (a compare-and-write: never over the game's CPU re-arming the record), and a record rewritten in the stream after its report (a small buffer clear, a report of another counter type) gets no count. A parallel replay's segments signal the recordings' timeline and are sealed as they are submitted, so their counts are written too. The count word is written as the replay writes a report (`guest_cpu_write`, and the word kept out of the mirrors' write-backs). With hostQueryReset (Vulkan 1.2) a recording's queries are reset on the CPU once read, only those it used. `RX_VK_OCC_QUERY_SKIP`: report addresses that keep the fixed answer (the log's `occlusion query sites` lines list the first 64 addresses with their counts). The log's `occlusion queries` line every 600 presents: the reports, how many were counted whole and why not, the counts written at completion (and of them 0), those not written and why (lost, superseded by a later report at the address, late, a render condition's), the mean latency in presents and how many were written after the next present, where the done recordings were found, and the render conditions on samples-passed words (rendered because a count was pending, rendered or skipped from a written count, from memory with no count to come, as before in the knob's off phases) with the draws and clears they skipped. `RX_VK_OCC_COND=0`: a condition on a samples-passed word always renders (the counts are still written), to tell the counts from the skips. `RX_VK_OCC_LOG_COND=1`: one such condition in 499 logged (300 lines), with both words, their sources (pending, written, memory) and the present. (11-22) `RX_VK_OCC_GATE=0` turns off (on by default since its lab A/B: no fps lost at the Market): a count over a draw that a written count's condition left out (between the reset and its report) is the skip's 0, not the object's, and a condition on it renders; the count is still written for the game's CPU. Why: the game's CPU reads a count after its frame wait and draws a hidden object's proxy instead of the object, but most counts land after it has read the 4096, so it goes on drawing the object under the condition, the condition reads the skip's 0 and the object stays hidden (tickets 11-21: items and trees in the Forest Temple, black interiors; `RX_VK_OCC_QUERY=0` showed them). The line's second half counts these counts (counted whole, written, of them 0), the conditions that read one and those the switch rendered, on or off. Cost with it on: a hidden object under such a condition is drawn every other frame instead of never. Lab: the knob `occq` in `RX_VK_LAB_AB` runs the queries the whole run and writes the counts of the reports made in its phases (`gpu/vk/occ_answer.h`, `vk_replay.cpp` "occlusion queries") | | `RX_VK_OCC_DEPTH_ONLY=1` | (Triforce, 11-22, the performance audit's GPUWORK-01, after Source A's; off unless set) Only the occlusion windows whose draws write no colour are counted. The game's occlusion tests draw depth only, but a query here opens at a window's first draw in the pass and stays open to the report or the pass's end, so it can enclose draws that write colour, and a query's end waits for the work it encloses. With the switch, a window's first draw that writes a colour target gives its count up: the open query ends before that draw, no query begins again until the next reset, and the report is incomplete, so its record keeps the 4096 placeholder and what it gates is drawn. Fewer objects are culled with it (Source A: 4% fewer for 0.25 ms of GPU time), never one missing; whether that pays here is for a measurement to say, which is why it is off. The lab's knob `occdepth` (`RX_VK_LAB_AB`) is the switch in its phases. Counted either way, in a third `vk: occlusion queries` line every 600 presents: the counting windows that met a colour draw, the colour draws recorded under an open query, the counts given up and the reports kept 4096 for it (`gpu/vk/occ_answer.h` `Counter::colour_draw`; `gpu/vk/vk_replay.cpp` `occ_draw_colour`; `gpu/vk/vk_draw.cpp` `draw`) | @@ -422,11 +441,14 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_WAIT_HOLD_PAUSE_US=` | (Triforce, 11-22, the performance audit's THREAD-11, after Source B's; off unless set, not measured here) A wait of the game's for a fence whose work is stopped at an event's wait holds up to `RX_VK_WAIT_HOLD_US` (3 ms) for another queue to let it on before it forces it, looking again and again: a flush, the timeline's value, the order lock to ask whether the stopped work is still needed, and a yield of the processor. With `` (2 is Source B's; 1000 at most) a gap of PAUSEs that long stands between two looks instead of the yield, and the order lock is taken only when one of its sections has left since the waiter last asked, which is the only time its answer can change; the fence's own value is still read at every look, and the bound and the forced drain stay. Source B measured 59.2 to 59.9 fps and a 1% low of 40.0 to 42.1 with such a gap on a loop that runs far more often than this one (about 15 holds a second here). `0` or not set: as before. Either way the `vk: queues ordered by their events` report is followed by a `vk: fence waits held for stopped work` line: the holds, their looks, the time held, the takes of the order lock and how the holds ended (`gpu/vk/wait_hold.h`, `gpu/vk/vk_replay.cpp` `wait`) | | `RX_VK_WAIT_HOLD_PAUSE_US=` | (Triforce, 11-22, the performance audit's THREAD-11, after Source B's; off unless set, not measured here) A wait of the game's for a fence whose work is stopped at an event's wait holds up to `RX_VK_WAIT_HOLD_US` (3 ms) for another queue to let it on before it forces it, looking again and again: a flush, the timeline's value, the order lock to ask whether the stopped work is still needed, and a yield of the processor. With `` (2 is Source B's; 1000 at most) a gap of PAUSEs that long stands between two looks instead of the yield, and the order lock is taken only when one of its sections has left since the waiter last asked, which is the only time its answer can change, or while a signal of the CPU's (`nvnEventSignal` without the replay thread) is queued and no section has acted on it yet; the fence's own value is still read at every look, and the bound and the forced drain stay. Source B measured 59.2 to 59.9 fps and a 1% low of 40.0 to 42.1 with such a gap on a loop that runs far more often than this one (about 15 holds a second here). `0` or not set: as before. Either way the `vk: queues ordered by their events` report is followed by a `vk: fence waits held for stopped work` line: the holds, their looks, the time held, the takes of the order lock and how the holds ended (`gpu/vk/wait_hold.h`, `gpu/vk/vk_replay.cpp` `wait`) | | `RX_VK_INDEX_REBASE=0` | (Triforce, 11-21, the performance audit's DESC-12) A direct indexed draw binds its index buffer at offset 0 and gives its offset as the draw's first index, so draws at different offsets of one buffer bind it once: bound at each draw's own offset, nearly every indexed draw called `vkCmdBindIndexBuffer`. Only where the offset is a whole number of indices; indirect indexed draws are as before. `RX_VK_PROF_FINE=1` counts the index binds looked up and those made. `0`: every draw binds at its own offset (`gpu/vk/index_rebase.h`, `vk_draw.cpp` `draw`, `bind_index`) | +| `RX_VK_CAPTURE_PUSH_KEEP=0` or `check` | (Triforce, 11-26, the GPU audit's C15; `gpu/vk/capturepushkeep.h`, on by default) A plain draw's capture push (`vk_draw.cpp` `push_capture`: the 16 bytes that say where its vertex stage stores its positions, zeros when the draw is given no slot) is left out while its command buffer is known to hold zeros there for the program's push stages. With no temporal upscaler's chain asking for positions every draw pushed the same zeros: a `vkCmdPushConstants` a plain draw, about 2,000 a frame at Lake Hylia (1.7% of the Presentation Thread's samples there), each a packet for the recorder too. Only zeros are kept: a draw that is given a slot always pushes, and so does the first one without a slot after it. What is kept is the command buffer's own (`cmd_work.h` `CmdWork::cap`) and is forgotten centrally, never by a list of call sites, since an address left there would be written through: by every `vkBeginCommandBuffer`, every `vkCmdPushConstants` and every `vkCmdBindPipeline` of the renderer (`vk_work.h`'s macros) and every library's own recording into a command buffer (the recorder's `B_DIRECT` boundary); only the program path's own bind of a program with the same push stages takes it back, when the draw state was not reset before it. A program's whole push block (`push_constants`, zeros in those 16 bytes) marks them held after its push. `0`: pushed before every such draw, as before. `check`: pushed before every draw too, and the pushes the rule would have left out are counted, with those over bytes that a model of the pushes does not have as zeros (`vk: capture push check` lines name the first eight). The model and the rule are fed by the same `vk_work.h` calls, so that count is 0 by construction for every push and bind `vk_work.h` sees: it compares what `full_pushed` and `pushed` claim with the bytes pushed through `vk_work.h`, ignores binds, and is no evidence that a library's recording or a call past `vk_work.h` is covered. Those are held by the `B_DIRECT` boundary before each library call (`tests/test_recorder_sync.py`) and by the scan for calls past the macros in `tests/test_capturepushkeep.py`. Any other value: on (told once). The lab's knob `nocappush` (`RX_VK_LAB_AB`) pushes before every draw in its phases. `0` and the knob's phases still note every push and bind, so neither is v0.8.4's cost, and the measurement below is against the knob's phases, not against v0.8.4. The frame statistics' `a frame's capture pushes` line counts the pushes kept and made a frame (with the replay's helper threads those two counts can miss a few, as the frame statistics' other counts in `vk_draw.cpp` do; the check's must-be-0 count is exact). Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.195 ± 0.060 ms (2.6% fps). The check run (all four scenes, every rider checked at once): every push kept by the rule made too, 0 of them different (0 by construction, as above) | | `RX_VK_RECORDER_OWN=0` | (Triforce, 11-21, the performance audit's REPLAY-04) With the recorder thread, a recording slot's descriptor pools are reset, its extra pools destroyed and its grown streams given back in `draw_begin_recording`, after the recording's first packets, as before: each is a boundary the replay waits at until the recorder has run what came before. The default makes that reset in `begin_recording` right after the slot's command pools are reset, where the recorder has nothing held. The 120-present line `a frame's recorder thread` counts the replay's waits (`gpu/vk/vk_draw.cpp` `draw_slot_reset`, `vk_replay.cpp` `begin_recording`) | | `RX_VK_DESC_POOL_GROW=0`, `RX_VK_DESC_POOL_DIV=<1..32>`, `RX_VK_STREAM_MB=` | (Triforce, 11-22, the performance audit's DESC-33, after Source A's; `gpu/vk/desc_pool_grow.h`) Each recording slot (48 at most) keeps a descriptor pool for the programs over the push limit, and the driver may keep host memory for all of it 48 times. A slot's pool is made at half size (4096 sets, 16384 uniform buffers and sampled images, and so on) and made whole (8192 sets) at the slot's first reset after a recording ran out of it; a recording that runs out gets a whole extra pool on the spot, as it always did. `RX_VK_DESC_POOL_GROW=0`: whole pools from the start, as before. `RX_VK_DESC_POOL_DIV=` divides both sizes by n. `RX_VK_STREAM_MB=` is the size of each slot's first upload stream (2 by default; a recording that needs more is moved to a bigger one, kept for the slot's next 120 recordings; 24 with `RX_VK_STREAM_GROW_OFF=1`, which skips draws instead). Every 3000 recordings the log's two "the recording streams" lines say the most one recording held of its stream, how many slots are still at half, how many were made whole, the extra pools made, and the most sets and descriptors of each type one recording took: what a smaller default is judged by (the stream's stays 2 MB until those numbers are read in play) (`gpu/vk/vk_draw.cpp` `make_pool`, `slot_reset_locked`, `draw_begin_recording`) | | `RX_VK_CAP_SPARE_FIT=0`, `RX_VK_CAP_STEP_MB=` | (Triforce, 11-22, the performance audit's MEM-33; the first on by default, the second off unless set; not yet run in the game) `RX_VK_CAP_SPARE_FIT=0`: a capture with no spare buffer makes its own with the spares' lock held, takes any spare that fits, and a spare made ahead is made once, as before. Without it (`gpu/vk/cap_spare.h`, `gpu/vk/vk_memory.cpp` `cap_buf_get`) the buffer is made with the lock let go, so the replay's take does not wait behind a submitting thread's allocation to give a buffer back; where spares are not capped at 32 MB a capture leaves alone a spare of 32 MB or more that is over twice its size class, for the load that wants it; the spare a capture of a class of 32 MB or more takes is made again on a worker; a spare is made ahead only if it fits what spares may hold together with the ones held and being made, and a buffer given back counts the ones being made; when the allocation fails, any spare that fits, then the exact size. `RX_VK_CAP_STEP_MB=`: where spares are capped at 32 MB (a card of 6.5 GB or less), a capture over 16 and up to 32 MB gets a buffer in steps of n MB, not the whole 32 MB (Source A: 4; its worst frames were worse in two pairs, so off here). The 600-take line counts the buffers made on a submitting thread and their ms | | `RX_VK_MIRROR_PIECE_IDLE=` | (Triforce, 11-22, the performance audit's MEM-26, its first step only; off unless set; not yet run in the game) A mirror in pieces keeps a piece's memory until the whole mirror goes, also where no game pool is left in its import. Giving such pieces back is NOT ported (the unbind and the free must wait for the GPU and for the bind timeline). What it would find is counted (`gpu/vk/piece_idle.h`): every 1200 submissions, after the `mirrors in pieces` line, the MB of pieces no game pool covers; with this switch each binding given a mirror in pieces also notes the submission in its pieces, and the line says how many of those MB no binding reached for that many submissions (600 is the wait the release would use). Under about 100 MB at the end of a tour on a 6 GB card (`RX_VK_TEST_CARD_MB=6144`) the release is not worth porting | +| `RX_VK_BIND_SPAN=0` or `check` | (Triforce, 11-26, the GPU pass on v0.8.3, C08; `gpu/vk/bindspan.h`; on by default; measured on v0.8.4 at the end of this row) Every buffer a draw binds goes through `gpu_buffer_bind`; a read binding its memo does not know (a per-draw uniform range is new at every draw) took the lock-free path each time: the thread's pool table, the pool's fields, an add on `Pool::binds`, the resident pieces' walk of a mirror in pieces, to find the mirror the binding before it in the same pool found (`gpu_buffer_bind` was 9.2% of the Presentation Thread's samples at Lake Hylia, 4.5% self). By default a thread keeps eight spans of guest addresses, each filled by a binding that path just gave the mirror: the pool, or with a mirror in pieces the run of resident pieces around the binding. A later read binding inside one is given the mirror at the same offset while the key stands: the bindings' stamp (a pool leaving, a mirror made or freed, a piece taken out of a mirror, the next submission), the pool table's generation, the thread's segment of a parallel replay, the recording and the times imports were left overlapping (below). The memo is asked first and written at a hit as before. Never from a span, the whole path as before: written bindings, bindings outside a submission's uploads or without mirrors, and with `RX_VK_LOG_MIRROR_USE`, `RX_VK_MIRROR_HEAT` or `RX_VK_MIRROR_PIECE_IDLE` set (each acts at every binding). No span either for an import made beside the imports it overlaps (`pool_lookup`'s plan to take them in would pass 1 GB) or for those imports: a page then has two imports, its bindings go by the page, and a span of either would answer for the other's pages too (`Pool::left_overlapping`). A span's hits are added to `Pool::binds` (a logged average) when the span is replaced, and dropped when the pool table changed. `=0`: no spans, as before. `=check`: every hit is also resolved the whole way, the whole way's result is returned and the differences are counted and the first 20 logged with the span and its key; a checked hit is counted as checked, not as answered from a span. Any other value: spans, as unset, and logged. The lab's knob `nobindspan` (`RX_VK_LAB_AB`) is `=0` in its phases (read once a submission, not at every binding). Every 600 submissions, with mirrors: `vk: bind spans (600 submits): read bindings answered from a span, the whole way past the memo, spans filled`, with `=check` also `checked against the whole way so far , differed`. Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.099 ± 0.056 ms (1.3% fps), measured while the knobs `nocapgap` and `nobindspan` were still asked at every left-out check and every binding that may use a span, string compares that every knob's phases paid and the phases without a knob did not, so the figure is likely somewhat high (by an estimated 0.03-0.09 ms). The check run (all four scenes, every rider checked at once): 31,196,849 span hits resolved the whole way too, 0 different | | `RX_VK_RANGE_WALK=0` | (Triforce, 11-22, the performance audit's MEM-42; on by default; not yet run in the game) The capture and collection loops (`gpu/vk/vk_memory.cpp` `memory_collect_written`, `capture_make`'s staging and behind loops, `take_capture`'s loops over the texture storage's ranges) ask of every page whether it lies in a sorted range list with a binary search, as before. Without it each loop has a cursor that only moves forward (`gpu/vk/range_walk.h`), one pass over the ranges for the loop; an address below the last one asked searches again, so any order gives the search's answers (`tests/test_range_walk.py` compares them). The `RX_VK_LAB_AB` knob `norangewalk` searches in its phases | +| `RX_VK_CAP_UNION_SHARED=0`, `=check` | (Triforce, 11-26, the GPU audit's C22; on by default; measured on v0.8.4 at the end of this row) `=0`: each caller of the captures' range lists builds its own union of them, as before. The captures take the pages of the mirrored imports (clipped to the game's pools, `RX_VK_CAP_ONLY_GPU`), the texture storage and the small pools; `capture_make` (a submit's capture) and `capture_ranges_merged` (the replay's collection) each kept their union behind a version of their own, so the Presentation thread, which does both in the plain mode (with threaded rendering the game's submitting thread does one and the replay thread the other), built it twice at every change of a list: three sorts over ~4400 ranges, two clips, and the left-out ranges published again, which has every thread copy them again (profiled at the Market: `capture_union_locked` 2.2% of that thread). By default (`gpu/vk/capunion.h`, `gpu/vk/vk_memory.cpp` `capture_union_take_locked`) the union is built once each time a list changes (`cap_ranges_ver`, under `cap_ranges_mu`) and copied by the callers into their own lists, the left-out ranges are published at that one build, the sorts are merges of the runs that arrive sorted (each run is asked, and sorted when it is not), and the pool table's look (`refresh_pool_ranges_locked`) no longer makes its map of the pools' first captures unless `RX_VK_CAPTURE_EAGER` reads it. The lists are the same vectors as before (`tests/test_capunion.py` compares them over random lists with `RX_VK_CAP_ONLY_GPU` 0, 1 and 2). `=check`: the lists are built both ways, the old ones used, and a reused union is compared with one built again (the first captures' map is skipped as by default: without `RX_VK_CAPTURE_EAGER` it changes no list); the differences are counted and the first 20 logged (0 expected). The `RX_VK_LAB_AB` knob `nocapunion` builds as before in its phases. Counted in the log's "capture (RX_VK_CAP_ONLY_GPU" line every 10 s ("the captures' union of the lists (RX_VK_CAP_UNION_SHARED=M): built N times, copied from one built N, built by a caller for itself N, runs that had to be sorted N, check differences N", M being 1, 0 or check; the first four over the last 10 s, the check differences since the start; not printed with `RX_VK_CAP_ONLY_GPU=0`). Any other value of the switch: one union a version, as unset, and logged. Expected: about 0.05 ms a frame at Lake Hylia and 0.08 ms at the Market, from the profiles' shares, before the measurement below. Measured on v0.8.4 (11-27; RTX 5090, 2560 x 1440, the camera held at Kakariko Village for 300 s with the replay thread alone, `RX_VK_PARALLEL=0`; the knob's phases against their neighbours, 95% interval): 0.227 ± 0.066 ms (3.0% fps), measured while the knobs `nocapgap` and `nobindspan` were still asked at every left-out check and every binding that may use a span, string compares that every knob's phases paid and the phases without a knob did not, so the figure is likely somewhat high (by an estimated 0.03-0.09 ms). The check run (all four scenes, every rider checked at once): 0 differences between a reused union and one built again | | `RX_VK_TABLE_STREAM=0` | (Triforce, 11-22, the performance audit's SYNC-04; on by default; not yet run in the game) The guest page table's changes of a recording (the table the shaders' pointers go through, `gpu/vk/vk_memory.cpp` `memory_table_flush`) are flushed as before: a (page, value) pair for every page changed, all of them sorted, the last of each page kept: 16 bytes a page and a sort on the recording thread, a few ms when a pool of hundreds of MB is imported ahead or merged. Without it the changes are streamed (`gpu/vk/table_stream.h`): runs in page order and apart are appended one after the other, any other set is swept by page with the newest change owning each page, through one reused batch of 8,192 entries. The transfers are the same ones in the same order (`tests/test_page_table_stream.py` compares the two, entry for entry). A flush over 1 ms is logged with its pages, changes and transfers (the first 16) | | `RX_VK_CAPTURE_BEHIND=0` | (Triforce, on by default; `=0` as before) The submit-time capture (`gpu/vk/vk_memory.cpp` `capture_make`) takes the write marks on the game's submitting thread and copies there only the pages read at once (the late pages and the texture storage); the rest of its copies, in parts of 32 pages, go to the capture's copy helpers while that thread replays the submission (`gpu/vk/capture_behind.h`). A read of a page as submitted copies its part itself when no helper has taken it yet, or waits for the helper; every part is done and flushed before a recording is submitted and before the thread goes back to the game. Only with the replay on the submitting thread (not `RX_VK_ASYNC=1`), with copy helpers (`RX_VK_CAPTURE_THREADS`, not `RX_VK_LOW_SPEC`), at least 128 pages behind and at most 512 ahead (a scene's load: copied whole as before). At the Market the old copy was ~0.25 ms of each submit's ~0.35 ms capture, six submits a frame. The 120-present line `a frame's captures at the game's submits` gives their time on the game's threads (the scan, the copies made there, and the copies behind made or waited for by the replay), the MB copied and behind, and who copied the parts; the stall line names the captures when they took 1 ms or more | | `RX_VK_CAP_FREE_ASYNC=0` | (Triforce, on by default; `=0` as before) A retired capture buffer the spares cannot keep (past 12 buffers or 768 MB, 32 MB on a card of 6.5 GB or less) is destroyed on a thread of its own (`gpu/vk/vk_memory.cpp` `cap_buf_free`, `destroy_buffer_later`), not in the capture's take on the replay's thread with its locks held: freeing a 64-256 MB host-cached buffer makes the driver unmap and release every page, the `retires` part of a `vk: slow capture take` line. Only buffers the GPU is done with get there; the memory comes back a moment later. The 600-take line counts the buffers and MB handed over. With no thread to be had they are destroyed where they were retired | @@ -434,7 +456,7 @@ case-sensitive, and an unknown one is ignored. | `RX_VK_PARALLEL_BACKOFF=0` | The tuner's trials as before: one every 1,800 presents after one that kept the way, each with 104 frames the other way. With the back-off (the default, `gpu/vk/replay_threads.h` `Tuner`) each trial that keeps the way, the other way longer than both of its own parts, puts the next one off twice as long (3,600, 7,200, then 14,400 presents at most; a margin of 10% or more counts twice), one too close to tell keeps the old interval (the first such one after a change of scene or way: 900 presents), and once the way has held so the other way is tried for 64 frames, not 104; a short trial that finds the other way shorter changes nothing itself, a full trial follows at once. The next trial comes early (900 presents after the last one at the soonest, never while the rule says no trial) when the scene clearly changes: two windows of 120 frames in a row whose draws moved by a quarter (200 at least) or whose replay or GPU time moved by 30% (1 ms at least) from the first window after the way was set, or a trial whose first and last parts did. In the lab's steady Market a trial came every ~2,090 presents, each ~100 frames 1.9 ms longer; the trial lines now end with when the next may come, and `parallel replay, the scene changed` says when one was brought forward | | `RX_VK_TUNER_SETTLED=0` | The tuner's rule judges every window and a trial the scene changed under decides, as before. With settled scenes only (the default, `gpu/vk/replay_threads.h` `Tuner`, after Kaefergeneral's #dev-fixes post: on his 5900X and RTX 3090 the rule turned the helper threads on in an area's load and the first trial after the arrival kept them, and Automatic was 6 to 10% slower than Off) the rule judges a window of 120 frames only if the one before it describes the same scene (its draws within a quarter, 200 at least, its replay and GPU times within 30%, 1 ms at least: the back-off's test), so a load's window and the first after it get no verdict and the rule's "on" comes a window after a scene settles; a trial whose first and last parts moved so changes nothing, either way, and the next comes 120 presents after a window like the one before it, not 900 or more later. The trial's line says so (`the scene changed under it`), and `parallel replay, the scene settled` when the next is set. Between trials the scene is calm while two windows in a row of the way in use describe one scene: a trial due waits for a calm scene (900 presents at most), none begins where nothing is cut (a loading screen), and after a trial the scene moved under the next is never more than 900 presents late. The rule's "on" holds only for the scene it judged: the first window that moved from the first with the helper threads on takes them back off (`the rule's "on" withdrawn`), and the rule judges the new scene; and the rule's "on" needs three windows in a row, each within those margins of the first of them (an arrival whose texture load comes down a little each window passes two alike, not three) | | `RX_VK_RECORDER=thread`, `=defer`, `=sync`, `=off` | (unset: `thread` on an NVIDIA GPU with 12 logical processors or more, and on an AMD GPU with 6 physical cores or more in the process's affinity but for AMD's Windows driver for RX 5000 and RX 6000 (`gpu/vk/recorder_auto.h`); else off. The log's `vk: recorder thread on/off by default` line says which rule applied; `RX_VK_LAB_AB=norec` makes the calls directly in its phases, to measure it) `thread`: the replay thread's `vkCmd*` calls packed with copies of their arguments into a ring and made by a recorder thread of their own, in order (`gpu/vk/vk_recorder.h`); the replay thread waits for it at every command buffer begin, end and reset, submit, wait, readback and destruction. Beside the Replay helper threads too (no longer refused with `RX_VK_PARALLEL`): a parallel replay's segments make their calls themselves, after the ring has been run (`segments_begin`), and the recorder is idle while they record. With it on, the frame statistics' `a frame's recorder thread` line says how many of the replay's calls it made a frame and in how long, and how long the replay thread waited for it; what it saves is the replay time line's `commands` with it against without it. `defer` and `sync` are its test steps (held and run on the same thread). `RX_VK_RECORDER_RING_MB` (8), `RX_VK_RECORDER_SPIN_US`, `RX_VK_RECORDER_STATS=0`, `RX_VK_RECORDER_POISON=1`, `RX_VK_RECORDER_PIN` (`next`, `sibling` or a mask) | -| `RX_VK_RECORDER_PARTS=0`, `=1`; `RX_VK_RECORDER_IDLE=wait` | (Triforce; unset: on with Threaded rendering (`RX_VK_THREADED`), so **off by default**) The recorder thread handed a part at a time (`gpu/vk/vk_recorder.h` `post_part`, `gpu/vk/vk_replay.cpp` `part_submit`): the replay publishes a part's packets at its end (256 KB chunks of a long one) and puts the part's two `vkEndCommandBuffer` and its queue submit into the ring as one more packet, which the recorder makes in order, so the replay goes on into the next part at once; a slot's reuse waits for its own part, a fence or timeline wait for the parts handed over (at most its own time), a thread about to take the queue's lock for them first (`QueueMutex`, `gpu/vk/vk_internal.h`), and a holder of a queue lock never for a recorder waiting for that lock; the recorder waits on its ring between batches (WaitOnAddress). Not for a recording with upload pieces or with the lazy write-back (made on the replay's thread, as before). A `vk: recorder, by part` line with the stats line. `=1`: with any recorder thread; `=0`: as before. `RX_VK_RECORDER_IDLE=wait` (opt-in): the recorder waits on its ring after a 20 µs spin without the hand-off too | +| `RX_VK_RECORDER_PARTS=0`, `=1`; `RX_VK_RECORDER_IDLE=wait` | (Triforce; **off unless `=1`**. Threaded rendering turned it on until 11-27: with it the 3D was drawn with wrong textures on an RX 7900 XT, black characters and white leaves, in v0.8.3 too, and without it the picture was right at Off's frame rate. The fault in the hand-off is not found yet) The recorder thread handed a part at a time (`gpu/vk/vk_recorder.h` `post_part`, `gpu/vk/vk_replay.cpp` `part_submit`): the replay publishes a part's packets at its end (256 KB chunks of a long one) and puts the part's two `vkEndCommandBuffer` and its queue submit into the ring as one more packet, which the recorder makes in order, so the replay goes on into the next part at once; a slot's reuse waits for its own part, a fence or timeline wait for the parts handed over (at most its own time), a thread about to take the queue's lock for them first (`QueueMutex`, `gpu/vk/vk_internal.h`), and a holder of a queue lock never for a recorder waiting for that lock; the recorder waits on its ring between batches (WaitOnAddress). Not for a recording with upload pieces or with the lazy write-back (made on the replay's thread, as before). A `vk: recorder, by part` line with the stats line. `=1`: with any recorder thread; `=0`: as before. `RX_VK_RECORDER_IDLE=wait` (opt-in): the recorder waits on its ring after a 20 µs spin without the hand-off too | | `RX_VK_REPLAY_PRIO=0` or `1` | (Triforce, on by default, after NX2navi's `recorder_prio`; `=0` as before) A thread runs at the highest priority while it replays the game's frames (the submitting thread's replay and its capture, the present, the stopped work the order thread lets on: `gpu/vk/vk_replay.cpp` `ReplayPin`) and gets its own priority back after, so the game's code it runs between replays keeps the game's priority; the core kept for the replay is kept from the game's threads only, and the helper threads and the capture's copy helpers (above normal) outranked a replay at the game's priority there. A thread at that priority or above already is left alone. The replay thread of `RX_VK_ASYNC=1` and the recorder thread of `RX_VK_RECORDER=thread` take the level for good. `=1`: above normal. The log's `vk: a thread that replays runs at` line says which (`gpu/vk/replay_prio.h`) | | `RX_VK_REPLAY_PIN_SOFT=0`, `=2` | (Triforce, 11-22, the performance audit's THREAD-09, after Source A's; Windows) A thread is pinned while it replays to the core the host keeps for the replay, and that core is kept from the game's threads, not from other programs': where another program's high-priority thread holds it, the pinned replay waits for it, ready to run (Source A, a 6+8-core hybrid processor with an overlay service at priority 15: 14 to 37 frames over 40 ms in a 40 s run, none with this). Not set: on a processor with cores of more than one kind the pin is soft: the thread may run on the reserved core and on the fastest-kind cores among its own processors, the reserved core's last logical processor is its ideal one, and the core it is on when the pin starts is left out so that it moves at once; its affinity and ideal processor come back after the replay. The replay thread of `RX_VK_ASYNC=1` gets the same processors for good. A processor of one kind of core keeps the strict pin, and nothing changes there. `0`: the reserved core alone everywhere, as before; `2`: soft everywhere (the lab; the knob `pinsoft` of `RX_VK_LAB_AB` does it by phases). A thread of another program that wakes on the core every millisecond moves the replay again and again (Source A: 54.3 against 44.6 fps, one run each): `0` is for that. The log's `vk: a replay's pin is` line says which (`gpu/vk/replay_pin.h`, `gpu/vk/vk_replay.cpp` `ReplayPin`, `replay_pin_soft`) | | `HOS_VCORES=0`, `HOS_CORES=<1..8>`, `HOS_RESERVE_CORE=0` | No virtual cores; the cores the game sees (6); no core kept for the replay (one is, with 8 or more logical processors) | @@ -457,6 +479,7 @@ case-sensitive, and an unknown one is ignored. | `A64_SUB_V=1`, `A64_SUB_V=ovf` | (Triforce; read when the game is translated, and in the lift key; off by default) The translator writes a flag-setting subtraction's V flag (SUBS, CMP, CCMP) from the bits of its operands and result, and the game's signed conditions (LT, GE, GT, LE) read it against N: seven to nine host instructions a compare, which the compiler does not fold. `1` writes V as N xor (a < b, signed), the same bit for every operand, which the compiler folds to one host compare and jump. It adds a `<` to every function that compares, and the hot pieces' recorded profile is matched to a function by a count of such things: record a new profile with it. `ovf` writes V as the compiler's own overflow test of the subtraction (`__builtin_sub_overflow`): five instructions a signed compare, and the recorded profile still matches. `nx2/cmpflags.py`; `tests/test_cmpflags.py` runs both forms against the translator's text. | | `RX_MARK_BITMAP=1` (build), `HOS_MARK_BITMAP_ALL=1` (run) | (Triforce; read by `nx2/build.py`: a full rebuild; off by default) Every store of the translated game also marks its memory page, so that the renderer finds what the game changed; the renderer reads only the marks of the pages the GPU can reach, and most stores are to other memory. With `RX_MARK_BITMAP=1` a store marks only when its first byte is on a page whose bit is set in a bitmap (`host/mark_bitmap.c`): the pages of every GPU mapping and native pool, and the page before each, set when the mapping is made and never cleared. A mark missed is stale data drawn, so compare pictures before shipping it. In such a build `HOS_MARK_BITMAP_ALL=1` sets every bit at the start, so every store marks as before (the control of an A/B). `tests/test_mark_bitmap.py`. | | `A64_FASTFP=1`, `=hot`, `=check`; `A64_FASTFP_MIN=`, `A64_FASTFP_STORES=0`, `A64_FASTFP_VMOVES=0` (lift); `HOS_NO_FASTFP=1` (run) | (Triforce; read when the game is translated, and in the lift key; off by default) Fast float regions (`nx2/fastfp.py`). Each single-precision float op of the translated game carries its own exactness tests, about 25 instructions around one SSE op. With `A64_FASTFP=1` a straight run of instructions holding at least `A64_FASTFP_MIN` (8) such ops is written twice: a fast copy of plain SSE ops between one MXCSR clear and one read, and the exact copy as before, which runs instead, with the run's registers put back, when the fast copy raised an invalid, denormal or underflow flag. A run may hold guest stores (made after the check passed; `A64_FASTFP_STORES=0`: a store ends a run) and the vector moves of `nx2/fastvec.py` (`A64_FASTFP_VMOVES=0`: they end a run). `hot`: only the hot functions. `check`: both copies every time, the exact one's result kept and the two compared (`fastfp check:` lines in the log). A function that holds an address the game's patches name gets no region, and the lift stops if a patch changes a function that has one. In a build lifted with it, `HOS_NO_FASTFP=1` runs the exact copies only. It changes the text of every function with a region (3,651 of them, 268 of the 849 hot ones in the supported game): record a new profile for the hot pieces with it. `tests/test_fastfp_override.py`, `test_fastfp_regions.py`, `test_fastfp_fma.py`. | +| `A64_LOCAL_FLAGS=0` | (Triforce, 11-23, the fps pass's LX-2, after NX2navi 0.11.0-rc4's `recomp/flags.py`; read when the game is translated, and in the lift key; on by default) A lifted function keeps N, Z, C and V in locals (`nx2/local_flags.py`, the kit's `A64_LOCAL_FLAGS`): read from the context once at its start and written back only where control leaves other than by a call or a return (a tail call, an indirect jump, an SVC, a trap), as the AAPCS64 leaves the flags undefined across calls and returns. Before, every flag a later instruction read was a byte stored into the context at each compare, which the compiler must keep. `0`: the flags in the context, as before (the game is translated again once); any other value keeps them as locals, and the lift prints which form it wrote (`flags: ...`). With the kit's `A64_PACKED_FLAGS` set as well the lift stops: that experiment writes the four flags into the context in one store, which the locals do not see. A scalar FCMP's fast path is lifted in the control flow the shipped hot profile was made from (`local_flags.profile_form`: the flags from the fast compare, then the exact one under `if (!_fk)`): clang finds a hot function's profile entry by a hash of its control flow, and the kit's own code form (`if (_fk) ... else ...`) left 652 of v0.8.4's 1384 hot functions, 17.7% of the profile's entry counts, built without theirs (11-27). The shipped hot profile has no records of the helpers this form calls (`a64_fcmp32k`, `a64_fcmp64k`), so their branches are built without its counts until the profile is recorded again with the switch on. `tests/test_local_flags.py` runs six functions (one float and hot) lifted both ways from the same states and compares clang's control-flow hash of each; `nx2/test_leaf.py` lifts with it. On v0.8.3 (11-23, 2560 x 1440, the Market after the save's load, the last 40 s of each run, nine runs a side interleaved over three batches, built with the shipped hot profile made without it): 139.4 -> 141.3 fps (+1.3%), the time a frame spends outside the replay 2.10 -> 1.98 ms; in the last batch, with the threads' times, 139.3 -> 142.3 fps (+2.1%, every run with it above every run without), and the game's workers and main thread 31.9 -> 30.4 ms of CPU a frame (-4.4%); on v0.8.4 (11-27, RTX 5090, 2560 x 1440, with the profile form; against the branch's riders and part size): the four benchmark scenes with the camera held, six runs a side in ABBA order, 150.0 -> 150.7 fps (+0.5%, not significant: the replay binds this PC's frame, p50 and p99 the same); with the camera turning as shipped, four runs against three, +0.8%; the Market held for 40 s, four runs a side in ABBA order with the threads' times, 139.9 -> 141.8 fps (+1.3%), the game's workers and main thread 23.6 -> 22.5 ms of CPU a frame (-4.6%) and all the process's threads 43.9 -> 42.5 ms (-3.1%, every run with it below every run without). The kit's own FCMP form, its hot functions without their profile, measured about 2% slower than the profile form | | `HOS_HEAP_COMMIT=1` | (Triforce, 11-21, the performance audit's MEM-09) On Windows the game's heap (~6.9 GB asked for at its start) is left reserved and committed as it is touched, 64 KB at a first touch, by the handler that commits pages nothing handed out; committed whole, all of it counted against RAM plus the page file, touched or not. A fault another thread's commit answered is tried again, a commit refused at Windows' commit limit is tried again for 5 s, and a file read or write reads each page of its buffer once before the kernel's call, which faults nothing in. The log says `heap: left reserved` and counts the heap's first touches. `1`: all of it committed at the start, as before; so it is in large pages (`HOS_LARGE_PAGES`) and on Linux (`host/heap_commit.h`, `mkw_glue.c` `commit_on_touch`, `hos_mem.c` `SetMemoryHeapSize`) | | `RX_VK_DMABUF_NVIDIA=1`, `RX_VK_NO_DMABUF=1`, `RX_VK_DMABUF_PIECE_MB=` | (Linux) Where the game's memory is a memfd, each pool of it is offered to the driver as a dma-buf made by udmabuf, larger pools as several of at most udmabuf's limit bound into one sparse buffer; the log's `vk: guest memory as dma-bufs:` line says yes or why not. `RX_VK_NO_DMABUF=1`: host-pointer imports only. `RX_VK_DMABUF_PIECE_MB=`: pieces of at most n MB. (Triforce, 11-22, the performance audit's OS-08, after Source A's; not yet run on Linux) NVIDIA's proprietary driver refuses every such dma-buf and the pool ends as a host-pointer import anyway, after a refused import each (up to 198 ms for one during a load) and a kernel message at each start: with that driver none is offered, `/dev/udmabuf` is not opened, and the line says `no (NVIDIA's driver refuses them: host pointers)` (`gpu/vk/dmabuf_gate.h`). NVK and RADV keep their dma-bufs. `RX_VK_DMABUF_NVIDIA=1`: offered to NVIDIA's driver too, as before | | `HOS_COMMIT_WAIT_MS=` | (Triforce, 11-22, the performance audit's OS-04, after Source A's and Source B's; 5000 unless set) How long a refusal at Windows' commit limit (RAM and the page file full, error 1455) is waited out, tried again every 50 ms: such a refusal often ends in moments, as a page file set to grow grows or commit is given back. The game's own commits waited so already (the row above); now the host's own tables do too (a failed allocation there ended the game at once: `host/host_alloc.h`, `hos_xmalloc` in `host/mkw_glue.c`), and the renderer's failed `new`, which was an uncaught `std::bad_alloc`: its new handler sleeps 50 ms and lets the allocation be tried again, up to this long a thread, but only while the system has less than 4 GiB of commit left (a `new` refused with more free is not the limit's and throws at once), and not for the few allocations that have their own answer to a refusal (`gpu/vk/new_wait.h`, `gpu/vk/vk_main.cpp` `new_refused`). The log has `refused ... made after N ms` for the first rescues. `0`: no wait anywhere, a refusal fails at once; 60000 at most | @@ -482,6 +505,7 @@ case-sensitive, and an unknown one is ignored. | `HOS_VCORE_SPIN_US=`, `HOS_VCORE_SPIN_MAX=` | (Triforce, on by default; `HOS_VCORE_SPIN_US=0` as before) A game thread that waits for a virtual core it asked a holder to give up spins for it, up to 250 us, before it sleeps (`host/hos_thread.c` `vc_spin`, after NX2navi's `core_take`): the holder gives the core up at its next checkpoint, mostly within microseconds, and the waiter then runs without an OS wake. Who gets a core does not change, only how soon. At most `HOS_VCORE_SPIN_MAX` threads spin at once and the rest sleep at once: by default a quarter of the logical processors beyond 8, at most 4 (none with 8 or fewer, 1 with 12, 2 with 16). The `vcores:` line (every 5 s) counts the waits that ended in the spin and those that slept, the time spun, the spins left out for the cap, and how soon a granted core ran after a spin and after a sleep; the start's `vcores: a waiter spins up to` line says what is in effect. A yield with no thread waiting for a core takes no lock (NX2navi's yield fast path) | | `HOS_VIDEO_ACQUIRE_TRIES=1`, `HOS_VIDEO_KEEP_CORE=1` | (Triforce, on by default; each `=1` as before) A movie's Acquire (`host/nn_video.c` `dec_acquire`) waits for a picture up to 100 ms by the clock, and not at all after a Stop or Flush with nothing submitted since: the old wait, 50 sleeps of 2 ms that each took 4-5 ms on Windows, ran out only after ~250 ms once a movie had stopped, a frame that long at every load from the title. It also decodes without the calling thread's virtual core, taken back only after the decoder's lock is let go, so other game threads run meanwhile. `HOS_VIDEO_ACQUIRE_TRIES=1`: the 50 sleeps; `HOS_VIDEO_KEEP_CORE=1`: the core held throughout | | `HOS_VCORE_WIDE=1` | (Triforce, 11-22, the performance audit's GAME-22, after Source B's; off unless set, never measured there or here) A game thread whose core mask names two or more cores takes any free virtual core, not only those. Source B's reason: the game's two main threads may run on two of three cores only, where per-core job workers of better priority preempt them while the other cores stand idle. A thread with a one-core mask, which guards the game's lock-free per-core data, or with no mask, stays where it was; no two threads ever run under one core number either way. The risk is the one `HOS_VCORE_ANY=1` (every thread on any core, which crashed) has, for fewer threads: a thread that reads its core number, blocks and goes on under another. The log's `vcores: ... asks for ideal core ... and core mask` lines name every thread whose mask has two or more cores (all masks when the switch is set to anything): with no such line the switch changes nothing (`host/hos_thread.c` `vc_allowed`, `core_mask_note`) | +| `HOS_VIDEO_DECODE_AHEAD=0`, `=<2..14>` | (Triforce, on by default; `=0` as before) A movie's pictures are decoded ahead of the game by a host thread of the decoder's own (`host/nn_video.c` `decode_ahead_main`: not a game thread, so no virtual core and no guest memory; normal priority), which keeps 12 pictures queued, so `Acquire...DecoderOutputBuffer` takes a picture that is there instead of decoding it in the call (3-13 ms each for the title screen's 1080p AV1 movie, single ones 80-200 ms, and up to 728 ms in one call when the catch-up decoded several: the movie stuttered wherever a scene loads over it). `=<2..14>`: that many pictures ahead; a 1080p picture is 3.1 MB as NV12 (Media Foundation's; six are ~19 MB) and 11.4 MB with the RGBA libavcodec's pictures are kept with. The decoder's lock is not held across a decode, so a submit, an acquire and a flush never wait for one behind it; a flush waits for the decode in flight and throws away what it gives, the close ends the thread first; a full queue makes the thread wait, it never drops a picture; the catch-up skips queued pictures only and decodes nothing in the call. An acquire still waits when no picture is queued and one is on its way. `=0`: no such thread, the pictures are decoded in the call. The log's `video: N pictures taken` line says which, how many acquires found their picture ready and how many waited for it, and the longest wait; the `video: AV1 decoder` line at the start says so too. `tests/test_video_decode_ahead.py` | | `RX_VK_HELPER_SPIN_US=` | (Triforce, on by default; `=0` as before) The parallel replay's spins (`gpu/vk/helper_spin.h`, after NX2navi's replay workers): a helper thread with no segment to record spins up to 100 us for the next before it sleeps, and the replay thread spins as long for a segment a helper records before it sleeps for it. The frame statistics' `its spins` line, after the parallel replay's parts, says how often each ended in the spin or slept and the time spun | | `HOS_X3D=0` | (Windows) The game's threads and the replay's core are not kept on the die with the largest L3 cache. By default they are (the replay's core only where one is kept there: `HOS_RESERVE_CORE`), on a processor whose L3 caches differ in size and whose largest serves 8 or more cores (AMD's two-die X3D parts: a 7950X3D's or 9950X3D's 3D V-Cache die; `host/hos_x3d.h`), and the log's `cpu: logical processors ... share the largest L3 cache` line says so. On every other processor nothing changes and the log has no such line | | `HOS_X3D=0` | (Windows) The game's threads and the replay's core are not kept on the die with the largest L3 cache. By default they are, on a processor whose L3 caches differ in size and whose largest serves 8 or more cores (AMD's two-die X3D parts: a 7950X3D's or 9950X3D's 3D V-Cache die; `host/hos_x3d.h`), and the log's `cpu: logical processors ... share the largest L3 cache` line says so. On every other processor nothing changes and the log has no such line | @@ -515,12 +539,15 @@ A build reads and writes tens of gigabytes. When the game folder or the build fi | `HOOKSHOT_MINGW=`, `HOOKSHOT_MSVC=1` | The llvm-mingw to build with; the Visual Studio route instead | | `HOOKSHOT_WORK_LOCK=0` | (Triforce, 11-22, the performance audit's IO-47) `make_game.py` takes no lock on its work folder, as before. By default it holds an OS lock on `/make_game.lock` for as long as it runs (`msvcrt.locking` on Windows, `flock` elsewhere), taken after an earlier build left running is stopped and before the stale objects go: a second build on the same folder stops at once with the first one's process id instead of compiling the same objects again and racing on the staged game folder, which nothing prevented on Linux (two builders, a builder beside the launcher, `--cli`). The lock ends with its process, so a build that crashed never blocks the next; an error other than "held by another" is said and the build runs without the lock (`nx2/make_game.py` `lock_work`) | | `HOOKSHOT_SINGLE_INSTANCE=0` | (Triforce) Hookshot Builder takes no lock on its build tools, as before. By default a second builder for the same tools folder (`builder/HookshotBuilder/Instance.cs`, named after `Tools.Root`), its `--cli` included, waits up to 5 s for one that is ending, then says so and ends: two of them built into one work folder and stopped each other's build. Triforce Setup has its own lock (`setup/Guard.cs` `Instance`) | +| `TRIFORCE_OOTRR_EXE=` | (Triforce, 11-25) The launcher's Randomizer page runs this program as OOTRR, in place of the pinned release it downloads into `randomizer\ootrr\` (`launcher/Logic/Randomizer/Ootrr.cs`): a developer's own build of OOTRR, or a test's stand-in (`LogicTests` copies itself in as `ootrr.exe`). Taken only in a test run (`TRIFORCE_TEST_ROOT`), a local build (version `dev`) or with `TRIFORCE_DEV=1`, as it runs any program | +| `TRIFORCE_OOTRR_URL=` | (Triforce, 11-25) Where the Randomizer page downloads OOTRR's release file from, in place of its GitHub release (a test's own server). The file must still have the size and SHA-256 that `Ootrr.cs` pins. Moving to another OOTRR release means changing `Ootrr.Version` and the pinned files' size and hash (from its `SHA256SUMS.txt`; `gh attestation verify --repo ootrando/ootrr`) | +| `OOTRR_E2E=\|` | (Triforce, 11-25) `LogicTests` runs the real OOTRR against a built game folder's `romfs` (read in place through a junction; seeds are written only in the test's own folder): every OOTRR preset either builds or is refused by the check before Make, and a seed's settings string reads back as its settings. Skipped without it | | `TRIFORCE_LEGACY_PATHS=1` | (Triforce) Triforce Setup keeps .NET Framework's legacy path checks, which refuse paths of 260 characters and more whatever its manifest says (an exe csc builds is taken as written for .NET 4.0). By default `setup/Setup.cs` `Main` sets the two switches 4.6.2 defaults to (`Switch.System.IO.UseLegacyPathHandling`, `Switch.System.IO.BlockLongPaths`) before any path is used, so that with Windows' own LongPathsEnabled on Setup reads and writes deep paths | | `HOOKSHOT_SEGMENT_HEAP=0` | (Triforce, Windows; on by default since 11-22: the lab's play A/B, 81.4 against 80.6 fps) The exe's manifest asks for Windows' segment heap (`heapType SegmentHeap`, Windows 10 2004 and newer) for the whole process, its DLLs and the graphics driver too, in place of the NT heap, whose lock AMD's driver's compile threads waited on through the shader preparation (`nx2/win_manifest.py`, `tests/test_segment_heap.py`). The heap is fixed when the process starts: a build with it and one without are the two arms. `0`: the NT heap, as before. The log's `the shaders' preparation runs on` line names the process heap (`segment` or `NT`) | | `RX_CPM=`, `WGPU_NATIVE=` | The CPM cache (Vulkan and SPIR-V headers, VMA, FFmpeg) and wgpu-native | | `RX_TARGET=windows` | On Linux: the Windows game, with llvm-mingw's Linux build in `HOOKSHOT_MINGW` | | `RX_RELEASE=1` | A release build (`make_game.py` sets it): no console window, the shaders prepared before the title | -| `RX_VK_PGO=gen`, `=`, `=0`; `RX_VK_PGO_FILE=` | (Triforce, 11-21, the performance audit's LIFT-10) A play profile for the renderer's own code (`gpu/vk/*.cpp`; not the vendored recompiler, ImGui or zstd). `gen`: a build whose renderer counts its branches; run it with `RX_VK_PGO_FILE=`, make `.reset` once the scene to record is loaded and `.dump` at its end, then `llvm-profdata merge -o work\triforce_vk.profdata `. ``: built with that profile (its contents are in the object keys, its path is not). Not set: `make_game.py` passes `work\triforce_vk.profdata` when the tools have one and the compiler can read it; `0`: none. A profile from another version of the renderer is taken function by function, the changed ones built without it. Record it again for each release, and compare against `RX_VK_PGO=0` before shipping one (`nx2/build.py` `vk_pgo_flags`, `host/pgo_rt.c`) | +| `RX_VK_PGO=gen`, `=`, `=0`; `RX_VK_PGO_FILE=` | (Triforce, 11-21, the performance audit's LIFT-10) A play profile for the renderer's own code (`gpu/vk/*.cpp`; not the vendored recompiler, ImGui or zstd). `gen`: a build whose renderer counts its branches; run it with `RX_VK_PGO_FILE=`, make `.reset` once the scene to record is loaded and `.dump` at its end, then `llvm-profdata merge -o work\triforce_vk.profdata `. ``: built with that profile (its contents are in the object keys, its path is not). Not set: `make_game.py` passes `work\triforce_vk.profdata` when the tools have one and the compiler can read it; `0`: none. A profile from another version of the renderer is taken function by function, the changed ones built without it. Record it again for each release, and compare against `RX_VK_PGO=0` before shipping one (`nx2/build.py` `vk_pgo_flags`, `host/pgo_rt.c`). (11-27, measured on v0.8.4) A change to a hot function is enough: the GPU pass's replay riders change `draw()`, `memory_cpu_owned` and `rec::boundary`, so v0.8.4's profile no longer matches them and they are built at plain -O2. Built so, that branch (the riders, the part size and LX-2) measured +0.1% fps against v0.8.4 (the four benchmark scenes, camera held, four runs a side); with a profile recorded on it the same way as v0.8.4's, +1.7% (p99 frame time 8-14% lower either way). The build hides the mismatch (`-Wno-profile-instr-out-of-date`): compiling a renderer file with `-fprofile-instr-use=` and that warning on says how many of its functions the profile no longer matches | | `RX_PGO=gen` or `RX_PGO=` | The hot code counting its branches for a profile, or built with one (`make_game.py` passes the shipped profile) | | `A64_HOT_STICKY=0` | (Triforce, 11-22, the performance audit's LIFT-30, after Source A's; read when the game is translated, and in the lift key) `nx2/split_hot.py` deals the hot functions out afresh and gives every hot piece code_hot.c's whole preamble, as before. By default `\image\hot_pieces.txt` keeps each hot function's piece: the next translation leaves the functions it knows where they were and puts a new one in the piece it shares the most calls with, else in the cheapest, unless that makes the costliest piece more than 1.15 times a fresh split's (then the split is the fresh one); and each piece keeps only the declarations of `f_` and `hos_` names it uses. An update that changes a few hot functions then compiles one or two hot pieces of about ten MB again, not up to eight. The functions' text is the same either way, and the hot profile goes by function name, so it fits both. The file is not in the lift key (`tests/test_sticky_hot_pieces.py`) | | `RX_COLD_OPT=O2` or `=`, `RX_COLD_PART_MB=` | (Triforce, 11-22, the performance audit's LIFT-17, after Source A's; opt-in) The hot pieces are compiled at -O2 with the play profile and every other lifted chunk at -O1. `RX_COLD_OPT=O2`: every other lifted chunk at -O2 too; `=`: only the chunks the file lists, one file name a line (`code_012.c`). Unset, empty or `O1`: as before. Each -O2 chunk is compiled as parts of `RX_COLD_PART_MB` MB by the lift's own estimate (6 when unset; `0`: no cut), cut only where a function begins and written under `/split` with a key file a chunk, so a second build writes nothing (`nx2/cold_parts.py`, `tests/test_chunk_parts.py`): -O2's time grows with the square of a function's size. The lifted files themselves are not touched. Source A's figures: +4.4% and +5.5% fps where the game's update bounds the frame, for about twice the lifted compile's processor time (23 minutes against 5 without the cut); not built or measured with this game. The names begin with `RX_`, so setting them translates the game again once | diff --git a/gpu/vk/bakescan.h b/gpu/vk/bakescan.h new file mode 100644 index 0000000..34e85cc --- /dev/null +++ b/gpu/vk/bakescan.h @@ -0,0 +1,126 @@ +// (Triforce, 11-26, the GPU audit's C36) The bake write-back's scan walks a list, not the whole texture cache. +// +// bake_writeback_step (vk_texture.cpp) puts into the game's memory the texels of a texture the GPU drew in one frame and the +// game still samples (the terrain's normal maps). Every fourth present it walked every texture of the cache with a dozen +// tests each to find them: 1.1% of the Presentation Thread at Lake Hylia, 0.9% at the Market (about 0.35 / 0.2 ms on each +// fourth present), for a walk that finds nothing where the recordings that drew them write them back themselves ("by the +// CPU: 0" on the card this was measured on). +// Here: the textures the step can ever take are kept in a list, and the step walks that. +// +// The walk's test in two halves, unchanged together: +// - armed(): what does not pass with time. The GPU's contents began and ended in one frame (first_written == +// last_written), and are not in the memory or on their way (wb_written != last_written). These four fields can make a +// texture armed in three places only, and each tells the list (List::note): texture_written, and the two places of the +// step that put wb_written back to 0 (a copy lost, or finalized or drawn again while it was under way). Their other +// writes (wb_written = last_written for a write-back under way, gpu_written = false) only disarm it, and a step drops it. +// - ripe(): what does pass with time, or is another's to change: four presents old, sampled in the last four, not +// released, not only cleared, small, in the guest window. Asked again at each step for each listed texture. A listed one +// stays listed while it is armed, however long it is not ripe: one not sampled for a hundred presents is taken when it +// is sampled again, as the walk took it. +// A texture leaves the list when a step finds it armed no more (written back, drawn in a second frame, its contents +// dropped: any way back is through a place that tells the list), or when it is destroyed (forget_gpu: the list holds +// pointers). The caps of a step are the walk's (room()); when they bite, the list takes the oldest listed first where the +// walk took whatever the hash map gave first, and the rest four presents on, as before. One no step can ever take (more +// than a step's 8 MB of storage, small in texels) is passed over in the list, where it would stop every newer one for as +// long as it is armed; the walk of the whole cache stops at it, as before, and does not reach those behind it in the hash +// map's order while it is ripe. So the same textures are taken, in another order, but for those: the list takes them. +// +// RX_VK_BAKE_SCAN=all (or 0): the walk of the whole cache, and no list, as before. =check: the walk of the whole cache, +// and every texture of it that is armed and not listed is counted and logged, each once (must be 0: one would have been +// missed by the list). The lab knob nobakescan (RX_VK_LAB_AB) walks the whole cache in its phases. The list is kept +// (kept()) by default, with =check and under the knob, whose phases go back to it; not with =all, nor with +// RX_VK_BAKE_WRITEBACK=0, where there is no step: nothing reads it there. +// The count is in a line of its own every 600 presents ("vk: the bake write-back's scan: ..."). +// +// The rule alone: tests/test_bakescan.py compiles it against the walk's own test over a script of events. +#pragma once +#include +#include +#include +#include +#include +#include + +namespace bakescan { + +enum Mode { kList, kAll, kCheck }; + +/// RX_VK_BAKE_SCAN: "all" (or 0) the whole cache, "check" the whole cache and the list's misses counted, else the list +inline Mode mode_of(const char* asked) { + if (!asked || !*asked) return kList; + if (!std::strcmp(asked, "all") || !std::strcmp(asked, "0")) return kAll; + if (!std::strcmp(asked, "check")) return kCheck; + return kList; +} + +/// What time alone does not change: drawn by the GPU in one frame, its texels not in the game's memory nor on their way +constexpr bool armed(bool gpu_written, uint64_t first_written, uint64_t last_written, uint64_t wb_written) { + return gpu_written && first_written && first_written == last_written && wb_written != last_written; +} + +/// The rest of the walk's test (but the image and its format, which the step asks itself): still the game's, drawn four +/// presents ago or more, sampled in the last four, small, in the guest window +constexpr bool ripe(bool released, bool only_cleared, uint64_t last_written, uint64_t last_frame, uint64_t bytes, uint64_t gpu, + uint64_t frame_no) { + return !released && !only_cleared && !(frame_no < last_written + 4) && !(frame_no - last_frame > 4) && !(bytes > (4ull << 20)) && + !(gpu >= (1ull << 39)); +} + +/// A step's caps: 24 textures and 8 MB; one more of guest_size bytes fits (room(0, 0, guest_size) false: no step can take it) +constexpr bool room(size_t items, uint64_t bytes, uint64_t guest_size) { + return !(items >= 24 || bytes + guest_size > (8ull << 20)); +} + +/// Whether the list is kept: only where something reads it, the write-back on (RX_VK_BAKE_WRITEBACK) and RX_VK_BAKE_SCAN +/// not "all". =check asks it, and the knob's phases go back to it +constexpr bool kept(bool writeback_on, Mode m) { return writeback_on && m != kAll; } + +/// The armed textures. T has gpu_written, first_written, last_written, wb_written and a bool wb_listed of the list's own. +/// note() from whichever thread writes those fields (where kept()); forget() before a listed texture is freed; settle() at +/// a step. +template +struct List { + std::mutex mu; + std::vector items; + std::atomic added{0}; + + static bool armed_now(const T& t) { return armed(t.gpu_written, t.first_written, t.last_written, t.wb_written); } + + /// After a write of the fields armed() reads: listed if it is armed now (once) + void note(T* t) { + if (!armed_now(*t) || t->wb_listed) return; + std::lock_guard lk(mu); + if (t->wb_listed) return; + t->wb_listed = true; + items.push_back(t); + added.fetch_add(1, std::memory_order_relaxed); + } + /// The texture goes: its pointer is not kept + void forget(T* t) { + if (!t->wb_listed) return; + std::lock_guard lk(mu); + for (size_t i = 0; i < items.size(); i++) + if (items[i] == t) { + items.erase(items.begin() + (ptrdiff_t)i); + break; + } + t->wb_listed = false; + } + /// A step: those armed no more leave; the rest, oldest listed first, into out (the step's own copy) + void settle(std::vector& out) { + std::lock_guard lk(mu); + size_t n = 0; + for (T* t : items) { + if (armed_now(*t)) items[n++] = t; + else t->wb_listed = false; + } + items.resize(n); + out.assign(items.begin(), items.end()); + } + size_t size() { + std::lock_guard lk(mu); + return items.size(); + } +}; + +} // namespace bakescan diff --git a/gpu/vk/barrier_rules.h b/gpu/vk/barrier_rules.h index a87d50c..127b1e5 100644 --- a/gpu/vk/barrier_rules.h +++ b/gpu/vk/barrier_rules.h @@ -11,9 +11,9 @@ // after the work before its signal, and a wait's work after the work before the signal it waits for. A signal is no barrier on // the console: the work after it in the same queue is not ordered after the work before it. // -// 1. A part's split (RX_VK_SPLIT_BARRIER; vk_replay.cpp maybe_split). A long submission goes to the GPU in parts of 120 draws and -// dispatches (RX_VK_CHUNK) so that the GPU starts early. Each part ended its pass with a full barrier, and the next began with -// another: the GPU drained between two draws of one of the game's passes, about 27 times a frame. With the rule the open pass +// 1. A part's split (RX_VK_SPLIT_BARRIER; vk_replay.cpp maybe_split). A long submission goes to the GPU in parts (RX_VK_CHUNK, +// part_draws below) so that the GPU starts early. Each part ended its pass with a full barrier, and the next began with +// another: the GPU drained between two draws of one of the game's passes, ~27 times a frame at 120. With the rule the open pass // goes on in the next part: the part ends it, and the next begins it again with the same targets behind a barrier of the // attachments' outputs alone (colour output and the depth and stencil tests, their writes before their reads and writes), and // keeps what the pass's draws sampled and wrote, so that draw_hazards ends the pass where it would have without the split. That @@ -108,22 +108,40 @@ inline bool split_start_full(bool carry, bool recorded_between) { } /// ((Triforce, 11-22, the performance audit's SYNC-66, after Source B's) RX_VK_CHUNK: how many draws and dispatches a part of a -/// long submission has (vk_replay.cpp maybe_split). 120 on every card since the parts were made: the GPU starts early, and each +/// long submission has (vk_replay.cpp maybe_split). 120 on every card until 11-26 (below): the GPU starts early, and each /// split costs a queue submit, two full barriers and the part's bookkeeping, about 27 times a frame in a serial replay. Source B -/// cuts at 128 where the GPU idles while the CPU records and at 4096 on desktop drivers; what pays here is not measured on any -/// driver, so the default by driver is 120 for each until the lab picks one (S1 and S2 with RX_VK_PARALLEL=0 and the lab knob -/// chunk:). vendor: the card's PCI vendor; radv: Mesa's RADV +/// cuts at 128 where the GPU idles while the CPU records and at 4096 on desktop drivers. +/// ((Triforce, 11-26) The lab picked NVIDIA's: 240 (kPartDrawsNvidia). On an RTX 5090 at 2560 x 1440, uncapped, the +/// benchmark's four scenes with the camera held (HOS_BENCH_PAN=0) and RX_VK_PARALLEL=0, 300-present phases of the knob +/// chunk: against 120 beside them, on v0.8.3: 240 took 0.37, 0.18, 0.21 and 0.08 ms off the frame (Lake Hylia, the +/// Market, Hyrule Field, Kakariko: +3.1, +1.9, +2.5, +0.8% fps; the replay's time 0.15-0.48 ms less, the host's waits for +/// the GPU no longer), 480 was mixed (Hyrule Field 0.43 ms worse) and 960 lost 1.2 ms everywhere (the write-backs the game +/// waits for start too late on the GPU). On v0.8.4 Hyrule Field went the other way (120 faster by 0.05 ms), and with the +/// PC's default helper threads the gain was 0.05 to 0.06 ms (docs/development.md's RX_VK_CHUNK row). Measured on that one +/// desktop only. Fewer cuts change which occlusion counts arrive in time (fewer straddle a split and are lost, some finish +/// later); a count is written only when whole (occ_answer.h: an unknown count keeps the visible placeholder, never 0), so +/// none is ever hidden. NVIDIA's driver is the device's driver id (VK_DRIVER_ID_NVIDIA_PROPRIETARY, one id on Windows and +/// Linux), not the card's vendor: NVK, Dozen and Venus on an NVIDIA card, and every other driver (AMD, Intel, RADV and the +/// Deck), keep 120 until the lab has measured them. These sizes apply where parts are cut by count: Threaded rendering off +/// (and RX_VK_PART_PASS_END not 1, which gives the pass-end parts on any run), or RX_VK_PART_PASS_END=0. With Threaded +/// rendering on and RX_VK_PART_PASS_END unset a part ends where the game ends its render pass and neither size is read +/// (vk_replay.cpp pass_end_parts); any RX_VK_CHUNK turns those parts off, so leave it unset there. Where parts are counted, +/// RX_VK_CHUNK=120 is the old size on NVIDIA's driver too, and the knob chunk:120 compares it inside a run; with the pass-end +/// parts on, the knob's phases are counted and the phases between end at the game's passes, so the knob compares those two. +/// driver_id: the device's VkDriverId (dev.driver_id; 0 not known) constexpr int64_t kPartDraws = 120; -inline int64_t part_draws_default(uint32_t vendor, bool radv) { - (void)vendor, (void)radv; - return kPartDraws; +constexpr int64_t kPartDrawsNvidia = 240; +constexpr uint32_t kDriverNvidiaProprietary = 4; // (VK_DRIVER_ID_NVIDIA_PROPRIETARY; tests/test_chunk_default.py checks it) +inline int64_t part_draws_default(uint32_t driver_id) { + return driver_id == kDriverNvidiaProprietary ? kPartDrawsNvidia : kPartDraws; } /// The size in force: RX_VK_CHUNK's number when the variable is set (0 or less: whole submissions, never split); else /// knob_or_default, the lab knob chunk:'s number in its phases and the driver's default outside them inline int64_t part_draws(bool env_set, int64_t env_value, int64_t knob_or_default) { return env_set ? env_value : knob_or_default; } -/// As the size was read before: the variable's number, 120 unset +/// As the size was read before: the variable's number, 120 unset (since 11-26 the unset size on NVIDIA's driver is +/// kPartDrawsNvidia: part_draws_default) inline int64_t part_draws_before(const char* env) { return env ? std::atoll(env) : 120; } /// RX_VK_EVENT_BARRIER: "late" the rule on any card; "full" (or any other value) as before; unset or empty: with the pass barrier's diff --git a/gpu/vk/bindspan.h b/gpu/vk/bindspan.h new file mode 100644 index 0000000..16097c7 --- /dev/null +++ b/gpu/vk/bindspan.h @@ -0,0 +1,175 @@ +// A read binding answered from a span of its pool's mirror this thread already resolved (no game, no GPU: a rule; +// vk_memory.cpp gpu_buffer_bind). +// +// (Triforce, 11-26, the GPU pass on v0.8.3, C08.) Every buffer a draw binds goes through gpu_buffer_bind: the uniform +// buffers of each stage, the vertex streams, the index buffer, indirect arguments. A read binding the memo does not know +// (a per-draw uniform range is new at every draw) takes the lock-free path: the thread's pool table (256 KB, by 64 KB +// page), the pool's bounds, a write of Pool::last_value, a lock-prefixed add on Pool::binds, the mirror's state, the +// submission and the segment it was synced in, and a walk of the resident bits of a mirror in pieces. All of that only +// to find again what the binding before it in the same pool found: this mirror, at guest - pool.lo. gpu_buffer_bind +// was 9.2% of the Presentation Thread's samples at Lake Hylia (4.5% self), 10.0% / 4.7% at the Market. +// +// So the thread keeps a few spans (kSpans): [lo, hi) of guest addresses whose read bindings are given `buffer` at +// guest - base, each filled by a binding that path just gave the mirror. A later binding inside one is answered by two +// compares, while everything the answer depended on still stands: +// - the key: gpu_bind_stamp() (pools leaving, a mirror made or dropped, a piece taken out of a mirror, the next +// submission: what the memo trusts), pools_gen itself (the Pool pointer), the thread's texture_segment() (a pool is +// synced for a segment and those after it: equal, not later, since a worker can be handed an earlier one) and +// mem_rec_value (the path raises Pool::last_value to it: a span filled under the same value has done so), and +// pools_overlap_gen (imports left overlapping, below). One key for the whole set: a change of it empties the set; +// - what is read at every binding, not kept: mirror_upload (false between a submission's end and the next one's +// start, where the path gives the import; the stamp does not move there), and the cases that never use a span +// (eligible, below); +// - the span's bounds: the pool's, or for a mirror in pieces the run of resident pieces around the binding that +// filled it (resident_run): a resident bit is only ever cleared together with a move of pools_gen. +// Imports are kept apart, but where pool_lookup's plan to take in the imports a binding's range overlaps would pass +// 1 GB, the new import is made beside them: a page then has two imports, and a binding of it gets the one its +// thread's per-page slot or pool_of gives. A span of either import would answer for the other's pages too, so neither +// gets one (Pool::left_overlapping, pools_flag_overlapping), and pools_overlap_gen moves so that a span filled before +// is not asked again; their bindings take the whole path as before. +// The memo is asked first and is written at a hit as before, so it holds what it held: a hit changes neither what a +// later binding is given nor Pool::last_value, only when Pool::binds is added to (the hits are counted on the span and +// folded into the pool when the span is replaced or the key moves, and dropped when pools_gen moved, the pool being +// possibly gone; binds is a logged average, "approximate"). +// +// Never from a span, the whole path as before (eligible): a written binding, a binding of no bytes, outside a +// submission's uploads or without mirrors, RX_VK_LOG_MIRROR_USE (every binding is noted), RX_VK_MIRROR_HEAT (every +// binding adds its bytes to the pool's heat, which chooses the mirrors) and RX_VK_MIRROR_PIECE_IDLE (every binding +// stamps its pieces). cap_excl_note, the translation of an address at or above 1 TB and late_deferred_bound run ahead +// of the span at every binding. +// +// RX_VK_BIND_SPAN=0: no spans, as before. =check: a hit is also resolved the whole way, the two results compared and +// the differences counted (the first 20 logged with the span and its key); the whole way's result is the one +// returned (cap_excl_note is not asked again for it), and the hit is counted as checked, not as answered from a span. +// Any other value, empty included: spans, as unset (logged when not 1 or empty). The lab's knob "nobindspan" is =0 in +// its phases (read once a submission, memory_begin_submission). The count is in the log every 600 submissions, with +// mirrors: "vk: bind spans (600 submits): ...". +#pragma once +#include +#include +#include + +namespace mkwvk::bindspan { + +inline constexpr int kSpans = 8; // a draw's bindings alternate between a handful of pools +inline constexpr uint64_t kRunMost = 16; // pieces a fill looks at on each side of its binding (4 MB of 256 KB pieces: a fill is a miss's cost) + +inline constexpr uint64_t kTakeAt = 256; // span questions a thread counts by itself before its counts go to the shared sums + +enum Mode : int { kOff = 0, kOn = 1, kCheck = 2 }; + +/// RX_VK_BIND_SPAN: not set, "" or any other value: on; "0": off; "check": both ways, compared +inline int mode(const char* env) { + if (!env || !*env) return kOn; + if (!std::strcmp(env, "check")) return kCheck; + return env[0] == '0' && !env[1] ? kOff : kOn; +} + +/// Whether this binding may be answered from a span, or fill one (see the list above). mirrors_uploading: mirrors are +/// on and a submission's uploads are being recorded +constexpr bool eligible(bool written, uint64_t size, bool mirrors_uploading, bool use_logged, bool heat_on, bool piece_idle_on) { + return !written && size != 0 && mirrors_uploading && !use_logged && !heat_on && !piece_idle_on; +} + +/// What the answer depends on that a span cannot see change (all five equal, or the set is empty) +struct Key { + uint64_t stamp = 0, pools_gen = 0, segment = 0, rec_value = 0, overlaps = 0; + constexpr bool operator==(const Key& o) const { + return stamp == o.stamp && pools_gen == o.pools_gen && segment == o.segment && rec_value == o.rec_value && + overlaps == o.overlaps; + } +}; + +/// [guest, guest + size) lies in [lo, hi), without a wrap-around for a huge size (as gpu_buffer_bind's pool test) +constexpr bool inside(uint64_t lo, uint64_t hi, uint64_t guest, uint64_t size) { + return size != 0 && guest >= lo && guest <= hi && size <= hi - guest; +} + +/// A mirror in pieces: the run of resident pieces [*i0, *i1] around the pieces [a, b] a binding was just found +/// resident in (bits: a bit a piece, read without the lock; n: the pool's pieces), at most kRunMost further each way +inline void resident_run(const uint64_t* bits, uint64_t n, uint64_t a, uint64_t b, uint64_t* i0, uint64_t* i1) { + const auto set = [&](uint64_t i) { return (__atomic_load_n(&bits[i >> 6], __ATOMIC_RELAXED) >> (i & 63)) & 1; }; + uint64_t lo = a, hi = b; + for (uint64_t k = 0; k < kRunMost && lo > 0 && set(lo - 1); k++) lo--; + for (uint64_t k = 0; k < kRunMost && hi + 1 < n && set(hi + 1); k++) hi++; + *i0 = lo, *i1 = hi; +} + +/// A pool's span for a binding of [off, off + size) of it (size != 0) that was just given its mirror: the whole pool +/// [pool_lo, pool_hi), or with a mirror in pieces (bits != nullptr, a piece 1 << shift bytes) the resident run around it +inline void bounds(uint64_t pool_lo, uint64_t pool_hi, uint64_t off, uint64_t size, const uint64_t* bits, uint64_t bit_words, + uint32_t shift, uint64_t* lo, uint64_t* hi) { + *lo = pool_lo, *hi = pool_hi; + if (!bits) return; + const uint64_t piece = 1ull << shift; + const uint64_t n = (pool_hi - pool_lo + piece - 1) >> shift; + const uint64_t a = off >> shift, b = (off + size - 1) >> shift; + if (b >= n || b >= bit_words * 64) { // (not a range of its pieces: the binding alone) + *lo = pool_lo + off, *hi = pool_lo + off + size; + return; + } + uint64_t i0 = a, i1 = b; + resident_run(bits, n < bit_words * 64 ? n : bit_words * 64, a, b, &i0, &i1); + *lo = pool_lo + (i0 << shift); + const uint64_t end = pool_lo + ((i1 + 1) << shift); + *hi = end < pool_hi ? end : pool_hi; +} + +/// A thread's spans. Buf: the mirror's buffer handle; PoolPtr: the pool, for the fold of its counted hits +template +struct Set { + struct Span { + uint64_t lo = 0, hi = 0, base = 0; // (guest addresses; base: the pool's lo, the buffer's offset 0) + Buf buffer{}; + PoolPtr pool{}; + uint32_t pending = 0; // (hits not yet added to the pool's bindings) + }; + Key key{}; + Span spans[kSpans]; + int n = 0, last = 0, next = 0; // (in use; the one hit last, asked first; the one replaced next) + uint64_t hits = 0, misses = 0, fills = 0; // (the thread's own, taken for the status line's sums now and then: take_counts) + + /// The span holding this read binding under this key, its hit counted; nullptr: the whole path + Span* find(const Key& k, uint64_t guest, uint64_t size) { + if (n && k == key) { + if (inside(spans[last].lo, spans[last].hi, guest, size)) return hits++, spans[last].pending++, &spans[last]; + for (int i = 0; i < n; i++) + if (inside(spans[i].lo, spans[i].hi, guest, size)) return last = i, hits++, spans[i].pending++, &spans[i]; + } + misses++; + return nullptr; + } + /// A binding the whole path just gave the pool's mirror: [lo, hi) of it is a span under this key (k.pools_gen is + /// the table's generation now). fold(pool, hits): the counted hits of a span that goes, called only while the + /// generation its pool was found under still stands + template + void fill(const Key& k, uint64_t lo, uint64_t hi, uint64_t base, Buf buffer, PoolPtr pool, Fold&& fold) { + if (!(k == key)) { + const bool pools_stand = k.pools_gen == key.pools_gen; + for (int i = 0; i < n; i++) { + if (spans[i].pending && pools_stand) fold(spans[i].pool, spans[i].pending); + spans[i].pending = 0; // (folded, or dropped: the pool may be gone) + } + key = k, n = 0, last = 0, next = 0; + } + int at = -1; + for (int i = 0; i < n && at < 0; i++) // (the same part of its pool again, wider or moved: not a second span) + if (spans[i].pool == pool && lo < spans[i].hi && spans[i].lo < hi) at = i; + if (at < 0) at = n < kSpans ? n++ : (next = (next + 1) % kSpans); + Span& s = spans[at]; + if (s.pending) fold(s.pool, s.pending); // (a span of this key: its pool was found under this generation) + s = Span{lo, hi, base, buffer, pool, 0}; + last = at, fills++; + } + /// (=check) the hit s is resolved the whole way too, which adds to the pool's bindings itself: neither counted as a + /// span's answer nor folded + void checked(Span* s) { hits--, s->pending--; } + /// The thread's counts since they were last taken, once they are worth an add on the shared sums (kTakeAt questions) + bool take_counts(uint64_t* h, uint64_t* m, uint64_t* f) { + if (hits + misses < kTakeAt) return false; + *h = hits, *m = misses, *f = fills, hits = misses = fills = 0; + return true; + } +}; + +} // namespace mkwvk::bindspan diff --git a/gpu/vk/built_check.h b/gpu/vk/built_check.h index 0e0c022..f30f7e5 100644 --- a/gpu/vk/built_check.h +++ b/gpu/vk/built_check.h @@ -80,10 +80,13 @@ inline Tally tally(const std::vector& probes) { } enum class Verdict { Unknown, Warm, Cold }; -/// Under kAnswers answers nothing; half of them or more cold: cold +/// Under kAnswers answers nothing; a fifth of them or more cold: cold. ((Triforce, 11-27) It was half: a player's RTX 5090 +/// (Linux) had 13 of 30 asked missing, the precompile went by its record, and those pipelines were compiled in play (65 ms +/// at the first Deku Nut). Caches that keep what they were given answer 0 missing: 183 lab starts and every player log of +/// 11-26 said "0 of 30" or "0 of 25", and a loss was 12 to 30 of 30) inline Verdict verdict(const Tally& t) { if (t.got < kAnswers) return Verdict::Unknown; - return t.cold * 2 >= t.got ? Verdict::Cold : Verdict::Warm; + return t.cold * 5 >= t.got ? Verdict::Cold : Verdict::Warm; } /// k places spread over n, the first at seed's place in the first step: each start asks other pipelines diff --git a/gpu/vk/capgap.h b/gpu/vk/capgap.h new file mode 100644 index 0000000..b2786fc --- /dev/null +++ b/gpu/vk/capgap.h @@ -0,0 +1,118 @@ +// ((Triforce, 11-26, the GPU audit's C09) The left-out ranges' check answered from the gaps it found before (no game, no +// GPU: a rule; vk_memory.cpp cap_excl_note -> cap_excl_hit_gap). +// +// What it does: with RX_VK_CAP_ONLY_GPU=1 (the default) or 2 every buffer binding, every replay read as submitted and every +// texture upload asks whether its bytes reach into the memory the capture leaves out (cap_excl_note: a count and the +// first 20 log lines, nothing else). The answer was a binary search at every question over the thread's copy of the +// left-out ranges, 2,400-3,650 of them on this PC (about 12 steps over a 38-58 KB list): cap_excl_hit was 2.3% of the +// Presentation Thread's own time at Lake Hylia and 2.6% in the Market, for an answer that is "no" nearly always. A draw's +// bindings walk rings inside a few pools, so a question nearly always falls into a gap between two neighbouring +// left-out ranges that an earlier question already found. The memo keeps the last 8 such gaps a thread; a question +// wholly inside one of them is answered "no" after a few compares, any other question is searched as before, and a +// search that says "no" keeps the gap it found. +// +// Why it is the same answer: the ranges are sorted by their start and none ends before it starts. A search for [lo, hi) +// that does not find lo inside a range finds the range before lo (ends at or before lo) and the range after it (starts +// past lo); the gap is [the one's end, the other's start), 0 and ~0 at the list's ends. For any [lo', hi') with +// gap_lo <= lo' < hi' <= gap_hi the search lands between the same two ranges and says "no". A question that crosses a +// gap's edge, an empty or wrapped one, and the questions after the list changed, until the memo has found gaps again +// (the caller clears the memo with its copy of the list, at every cap_excl_ver change), go to the search. Only searches +// that said "no" are kept, so the questions that do reach into the ranges do not push the gaps out; a question inside a +// kept gap is not searched, so its gap is not kept twice, but an empty or wrapped one is searched and can keep a gap +// the memo holds already. +// +// Only the count's question goes by the memo. The write-back's clip (gpu_buffer_bind, wb_excl_clip.h) and +// RX_VK_CAP_ONLY_GPU=2's page count keep cap_excl_hit's plain search. +// +// The switch: RX_VK_CAP_EXCL_GAP (not set or 1: the memo; 0: the search at every question, as before; check: both at +// every question, the search's answer used and the differences counted, the first 20 logged). The lab's knob "nocapgap" +// is 0 in its phases (asked again only when the phase moves). The count: the log's "capture (RX_VK_CAP_ONLY_GPU" line +// every 10 s carries "left-out checks in all from the gap memo N, searched M, differing D (RX_VK_CAP_EXCL_GAP)": +// totals since the start, which leave out the questions asked with =0 and in the knob's phases.) +#pragma once +#include +#include +#include +#include +#include + +namespace mkwvk::capgap { + +using Range = std::pair; + +enum Mode { kOff = 0, kOn = 1, kCheck = 2 }; + +/// RX_VK_CAP_EXCL_GAP: not set, "" or anything else: on; "0": off; "check": both and compared +inline Mode mode(const char* env) { + if (!env || !env[0]) return kOn; + if (env[0] == '0' && !env[1]) return kOff; + if (!std::strcmp(env, "check")) return kCheck; + return kOn; +} + +/// Whether a question goes by the memo: the switch not 0, and not in the lab's "nocapgap" phases +inline bool use(Mode m, bool lab_off) { + return m != kOff && !lab_off; +} + +inline constexpr int kGaps = 8; + +/// A thread's kept gaps: [lo[k], hi[k]) holds no byte of a left-out range. An unused entry has lo > hi and holds nothing +struct Memo { + uint64_t lo[kGaps], hi[kGaps]; + uint32_t last = 0, next = 0; // (the entry that answered last, asked first; the entry the next gap replaces) + Memo() { clear(); } + void clear() { + for (int k = 0; k < kGaps; k++) lo[k] = 1, hi[k] = 0; + last = next = 0; + } +}; + +/// The search, as vk_memory.cpp's ranges_hit: whether [lo, hi) reaches into one of v's ranges (sorted by start). Where lo +/// is in none of them, the gap around lo in *gap_lo, *gap_hi; where it is in one, *gap_lo > *gap_hi +inline bool search(const std::vector& v, uint64_t lo, uint64_t hi, uint64_t* gap_lo, uint64_t* gap_hi) { + auto it = std::upper_bound(v.begin(), v.end(), std::make_pair(lo, ~uint64_t(0))); + *gap_lo = 1, *gap_hi = 0; + if (it != v.begin() && lo < std::prev(it)->second) return true; + *gap_lo = it != v.begin() ? std::prev(it)->second : 0; + *gap_hi = it != v.end() ? it->first : ~uint64_t(0); + return it != v.end() && it->first < hi; +} + +/// Whether [lo, hi) is wholly inside one of the kept gaps (the answer is then "no"): never for an empty or wrapped one +inline bool inside(Memo& m, uint64_t lo, uint64_t hi) { + if (hi <= lo) return false; + const uint32_t l = m.last; + if (m.lo[l] <= lo && hi <= m.hi[l]) return true; + for (uint32_t k = 0; k < (uint32_t)kGaps; k++) + if (m.lo[k] <= lo && hi <= m.hi[k]) { + m.last = k; + return true; + } + return false; +} + +/// A gap found by a search that said "no", kept over the oldest +inline void keep(Memo& m, uint64_t gap_lo, uint64_t gap_hi) { + if (gap_lo >= gap_hi) return; + const uint32_t k = m.next; + m.lo[k] = gap_lo, m.hi[k] = gap_hi; + m.last = k; + m.next = (k + 1) % (uint32_t)kGaps; +} + +/// Whether [lo, hi) reaches into one of v's ranges: by the memo, else by the search (*searched set). The memo must have +/// been cleared since v last changed +inline bool hit(Memo& m, const std::vector& v, uint64_t lo, uint64_t hi, bool* searched) { + if (inside(m, lo, hi)) { + *searched = false; + return false; + } + *searched = true; + uint64_t gap_lo, gap_hi; + const bool r = search(v, lo, hi, &gap_lo, &gap_hi); + if (!r) keep(m, gap_lo, gap_hi); + return r; +} + +} // namespace mkwvk::capgap diff --git a/gpu/vk/capturepushkeep.h b/gpu/vk/capturepushkeep.h new file mode 100644 index 0000000..2506d74 --- /dev/null +++ b/gpu/vk/capturepushkeep.h @@ -0,0 +1,121 @@ +// (Triforce, 11-26, the GPU audit's C15) A plain draw's capture push left out while its command buffer holds zeros there. +// +// push_capture (vk_draw.cpp) pushes 16 bytes before every plain draw of every program whose vertex stage captures its +// positions (every plain vertex stage): where the stage stores them (an address, a first, a count), zeros when the draw is +// given no slot. Without a temporal upscaler's chain asking for positions no draw is given one, so every draw pushed the +// same zeros: a vkCmdPushConstants a draw (about 2,000 a frame at Lake Hylia, 1.7% of the Presentation Thread's samples +// there), each a packet for the recorder thread as well. Push constants stay on a command buffer until something pushes +// over them or binds a pipeline whose layout has another block, so the zeros are pushed once and kept. +// +// What is kept is one word a command buffer (cmd_work.h CmdWork::cap): the push stages of the layouts whose capture bytes +// are known to hold zeros, 0 for "not known". Only zeros are ever kept: a draw that is given a slot always pushes, and so +// does the first draw without one after it. A stale address there would be written through by the next draw's vertex stage +// (another draw's slot at best, a lost device at worst), so what forgets is central and errs towards pushing: +// - every vkBeginCommandBuffer of the renderer (cmd_work.h work_begun: a handle recorded again holds nothing); +// - every vkCmdPushConstants of the renderer, whatever its layout, stages and range (vk_work.h's macro: the compute +// passes recorded between draws push over the same bytes of the command buffer; the draw's own pushes go through it +// too and note what they left after); +// - every vkCmdBindPipeline of the renderer (vk_work.h's macro). The program path's own bind in draw() goes through it +// too, and takes back what was held before it only for a program with the same push stages (every program's layout +// has the one range {its stages, 0, the block's size}, so equal stages are layouts compatible for push constants: the +// strict reading of the specification, nothing a driver is trusted with beyond it), and never when the draw state was +// reset before it (last_pipeline cleared: something was recorded that these hooks may not have seen, a library's pass); +// - every recording a library makes into a command buffer itself, past those macros (Dear ImGui's overlays, NGX's, FFX's +// and XeSS's passes): each is announced by the recorder's boundary(B_DIRECT) (vk_recorder.h; tests/test_recorder_sync.py +// holds every such call to it), which moves direct_gen, and what any command buffer holds from before is void; +// - a command buffer the table has no room for (CmdWork::known false) never keeps. +// A program's whole block (push_constants) has zeros in the capture's bytes and is noted as such after its push. +// +// RX_VK_CAPTURE_PUSH_KEEP=0: pushed before every such draw, as before (every push and bind is still noted, so this is +// not v0.8.4's cost). =check: pushed before every draw too, and each push the rule would have left out is counted, and +// counted as differing when shadow_zero does not have the bytes as zeros. shadow_zero follows the pushes that vk_work.h's +// macro sees (a push covering the 16 bytes sets it by their value, one covering a part of them clears it, one beside them +// leaves it, a begin clears it): the rule is fed by the same calls, so the count is 0 by construction for every push and +// bind vk_work.h sees. It compares what full_pushed and pushed claim with the bytes pushed through vk_work.h, and nothing +// more: it ignores binds (program_bound is not checked by it), and a 0 is no evidence that a library's recording or a +// call past vk_work.h is covered. Those are held by the B_DIRECT boundary before each library call +// (tests/test_recorder_sync.py) and by the scan for calls past the macros in tests/test_capturepushkeep.py. Any other +// value (not 0, 1 or check) keeps, as by default, and is told once. The lab's knob nocappush (RX_VK_LAB_AB) pushes before +// every draw in its phases. +// The frame statistics' "a frame's capture pushes" line counts the pushes kept and made. +// +// The rule alone, no Vulkan: tests/test_capturepushkeep.py compiles it. +#pragma once +#include +#include +#include + +namespace capturepushkeep { + +/// The capture's bytes in a program's push block (push_capture pins them to the shader back end's CAPTURE_PUSH_OFFSET) +constexpr uint32_t kOffset = 88, kSize = 16; + +/// The switch's value: kept unless it is 0 or check +enum Mode { OFF = 0, KEEP = 1, CHECK = 2 }; +inline Mode mode_of(const char* asked) { + if (asked && !std::strcmp(asked, "0")) return OFF; + if (asked && !std::strcmp(asked, "check")) return CHECK; + return KEEP; +} + +/// Moved by every recording made into a command buffer past vk_work.h's macros (a library's: the recorder's B_DIRECT +/// boundary), any thread's, any command buffer's: a few a frame at most +inline std::atomic direct_gen{0}; +inline void direct_recorded() { direct_gen.fetch_add(1, std::memory_order_relaxed); } + +/// One command buffer's +struct State { + uint32_t zero_stages = 0; // (the push stages whose layouts' capture bytes hold zeros; 0: not known) + uint32_t gen = 0; // (direct_gen when zero_stages was set) + uint8_t shadow_zero = 0; // (check mode's model: 1 when the last pushes over the bytes left them all zeros) +}; + +inline bool all_zero(const uint8_t* data) { + uint64_t a, b; + std::memcpy(&a, data, 8), std::memcpy(&b, data + 8, 8); + return (a | b) == 0; +} + +/// The command buffer begun: nothing is held +inline void begun(State& s) { s.zero_stages = 0, s.shadow_zero = 0; } + +/// Any push constants recorded into it (before the call): forgotten, whatever the layout, the stages and the range. The +/// model: the bytes are zeros only by a push that covers all 16 of them with zeros +inline void any_push(State& s, uint32_t offset, uint32_t size, const void* values) { + s.zero_stages = 0; + const uint64_t end = (uint64_t)offset + size; + if (offset >= kOffset + kSize || end <= kOffset) return; // (beside the bytes) + s.shadow_zero = values && offset <= kOffset && end >= kOffset + kSize && + all_zero(static_cast(values) + (kOffset - offset)); +} + +/// Any pipeline bound, at any bind point (before the call): forgotten +inline void any_bind(State& s) { s.zero_stages = 0; } + +/// The program path bound a program's pipeline (after its any_bind; held: zero_stages as it was before the bind): held +/// again only for the same push stages, and not across a draw state reset +inline void program_bound(State& s, uint32_t held, uint32_t stages, bool from_reset) { + s.zero_stages = !from_reset && held == stages ? held : 0; +} + +/// A program's whole block was pushed, zeros in the capture's bytes (after its any_push) +inline void full_pushed(State& s, uint32_t stages) { + s.zero_stages = stages, s.gen = direct_gen.load(std::memory_order_relaxed); +} + +/// Whether a draw's capture push (data, 16 bytes) may be left out: only zeros, over zeros known to be held for these stages, +/// with no library's recording since they were pushed +inline bool keep(const State& s, bool known, uint32_t stages, const uint8_t* data) { + return known && stages != 0 && s.zero_stages == stages && s.gen == direct_gen.load(std::memory_order_relaxed) && all_zero(data); +} + +/// The draw's capture push was made (after its any_push): zeros are held from here, anything else is not +inline void pushed(State& s, uint32_t stages, const uint8_t* data) { + s.zero_stages = all_zero(data) ? stages : 0, s.gen = direct_gen.load(std::memory_order_relaxed); +} + +/// Check mode, at a push keep() would have left out: whether the model does not have zeros there (false by construction +/// while every push and bind goes through vk_work.h: what pushed and full_pushed claim is checked, not the bind rule) +inline bool check_differs(const State& s) { return !s.shadow_zero; } + +} // namespace capturepushkeep diff --git a/gpu/vk/capunion.h b/gpu/vk/capunion.h new file mode 100644 index 0000000..4e05573 --- /dev/null +++ b/gpu/vk/capunion.h @@ -0,0 +1,152 @@ +// ((Triforce, 11-26, the GPU audit's C22) One union of the captures' range lists for every caller, each time a list changes +// (vk_memory.cpp capture_union_take_locked, refresh_pool_ranges_locked; RX_VK_CAP_UNION_SHARED, on; =0: as before; =check: +// both ways, the differences counted; the lab knob nocapunion: as before in its phases). +// +// The captures' range lists are four: three whose pages the captures take (the mirrored imports, clipped to the game's +// pools with RX_VK_CAP_ONLY_GPU=1; the texture storage; the small pools) and what the clip leaves out, which they do not +// take, published for the replay's checks. capture_make (a submit's capture) and capture_ranges_merged (the replay's +// collection) each kept a union of their own behind a version of their own, so a thread that does both, the game's +// Presentation thread in the plain mode, built it twice at every change of a list: three sorts over ~4400 ranges, two +// clips, and the left-out ranges published again, which has every thread copy them again at its next question +// (cap_excl_hit, cap_excl_hit_gap with its gap memo, cap_excl_page, cap_excl_kept). Profiled at the Market: +// capture_union_locked 2.2% of that thread's time, the sorts under it 2%; how often the lists change there is not measured +// (the capture's 10 s line counts the builds now). +// +// What changes, and what does not: +// - The union is built once a version of the lists (cap_ranges_ver, which every writer of a list moves under cap_ranges_mu, +// where the union is kept too): get(). A caller still copies it into its own thread's list behind its own version: the +// callers read their list after the lock is given back. The left-out ranges are published at that one build; between two +// builds of one version nothing else can change them (cap_pool_born_now edits them and moves the version at once). +// - The sorts are merges of runs: every list arrives sorted (the imports from an ordered map, the pools merged, the texture +// storage merged, a clip's parts in its input's order), so a sort of two or three of them end to end is a merge. Each +// run is asked whether it is sorted, and sorted when it is not (counted), so nothing is assumed: sort_runs gives what +// std::sort gives (pairs of integers: equal ones are the same), and the join is ranges_merged's. build() is +// capture_union_locked with those. +// - The pool table's look kept a map from each small pool's start to the capture that saw it first, made again at every +// look (a find and an insert a pool), which only RX_VK_CAPTURE_EAGER reads (off unless set): first_seen_needed(). +// The lists decide which pages a capture takes, and a wrong one is stale pages in a mirror (a grey world, the ground's mist +// gone for a frame): they must be the same vectors as before. tests/test_capunion.py compares them over random lists; +// =check compares them in the game.) +#pragma once + +#include +#include +#include +#include +#include + +namespace capunion { + +using Range = std::pair; +using Ranges = std::vector; + +/// The switch: RX_VK_CAP_UNION_SHARED (nullptr or "": not set, on; "0": as before; "check": both ways, compared) +enum Mode { OFF = 0, ON = 1, CHECK = 2 }; +inline int mode(const char* env) { + if (!env || !*env) return ON; + if (!strcmp(env, "check")) return CHECK; + return env[0] == '0' && !env[1] ? OFF : ON; +} +/// Whether the shared union and the runs are used now (knob: the lab knob nocapunion in one of its phases) +inline bool shared(int mode, bool knob) { return mode != OFF && !knob; } +/// Whether the pool table's look keeps each small pool's first capture: RX_VK_CAPTURE_EAGER's count reads it and nothing +/// else does (shared_now false: kept as before) +inline bool first_seen_needed(uint64_t eager_captures, bool shared_now) { return eager_captures != 0 || !shared_now; } + +/// v sorted: the ranges that overlap or touch joined, in place (ranges_merged's loop) +inline void join(Ranges& v) { + size_t m = 0; + for (size_t i = 0; i < v.size(); i++) { + if (m && v[i].first <= v[m - 1].second) v[m - 1].second = std::max(v[m - 1].second, v[i].second); + else v[m++] = v[i]; + } + v.resize(m); +} +/// v sorted as std::sort sorts it, where v is three runs end to end, [0, cut1) [cut1, cut2) [cut2, size) (a cut past the +/// end or before the other is brought in): a run that is not sorted is sorted (counted in *sorts), then the runs are merged +inline void sort_runs(Ranges& v, size_t cut1, size_t cut2, uint64_t* sorts) { + const size_t n = v.size(), c1 = std::min(cut1, n), c2 = std::min(std::max(cut2, c1), n); + const size_t at[4] = {0, c1, c2, n}; + for (int i = 0; i < 3; i++) { + if (std::is_sorted(v.begin() + at[i], v.begin() + at[i + 1])) continue; + std::sort(v.begin() + at[i], v.begin() + at[i + 1]); + if (sorts) ++*sorts; + } + // (runs already in order end to end are left alone) + if (c1 > 0 && c1 < c2 && v[c1] < v[c1 - 1]) std::inplace_merge(v.begin(), v.begin() + c1, v.begin() + c2); + if (c2 > 0 && c2 < n && v[c2] < v[c2 - 1]) std::inplace_merge(v.begin(), v.begin() + c2, v.end()); +} +/// ranges_merged of v, where v is three runs (sort_runs) +inline Ranges merged_runs(Ranges v, size_t cut1, size_t cut2, uint64_t* sorts) { + sort_runs(v, cut1, cut2, sorts); + join(v); + return v; +} +/// a and b sorted and merged: a's parts inside b (in = true) or outside it (vk_memory.cpp's ranges_clip) +inline Ranges clip(const Ranges& a, const Ranges& b, bool in) { + Ranges out; + size_t j = 0; + for (const auto& r : a) { + uint64_t at = r.first; + while (j < b.size() && b[j].second <= at) j++; + for (size_t k = j; k < b.size() && b[k].first < r.second; k++) { + const uint64_t lo = std::max(at, b[k].first), hi = std::min(r.second, b[k].second); + if (!in && lo > at) out.push_back({at, lo}); + if (in && lo < hi) out.push_back({lo, hi}); + at = std::max(at, hi); + } + if (!in && at < r.second) out.push_back({at, r.second}); + } + return out; +} + +struct Built { + Ranges uni; // (the captures' ranges) + Ranges excl; // (the imports' parts outside every pool and texture storage: written only when excl_made) + bool excl_made = false; // (only_gpu 1 or 2: the left-out ranges are to be published) +}; +/// capture_union_locked: the imports (clipped to the pools with only_gpu 1), the texture storage and the small pools, their +/// union sorted and merged; with only_gpu 1 or 2 the imports' parts outside pools and tex too. sorts: the runs that did not +/// arrive sorted, added +inline void build(const Ranges& imports, const Ranges& pools, const Ranges& tex, const Ranges& small_pools, int only_gpu, Built& out, + uint64_t* sorts) { + Ranges imp = imports; + out.excl_made = false; + if (only_gpu) { + const size_t whole = imp.size(); // (one run) + imp = merged_runs(std::move(imp), whole, whole, sorts); + Ranges keep; + keep.reserve(pools.size() + tex.size()); + keep = pools; + keep.insert(keep.end(), tex.begin(), tex.end()); + const size_t all = keep.size(); + keep = merged_runs(std::move(keep), pools.size(), all, sorts); + out.excl = clip(imp, keep, false); + out.excl_made = true; + if (only_gpu == 1) imp = clip(imp, pools, true); + } + const size_t cut1 = imp.size(), cut2 = cut1 + tex.size(); + imp.reserve(cut2 + small_pools.size()); + imp.insert(imp.end(), tex.begin(), tex.end()); + imp.insert(imp.end(), small_pools.begin(), small_pools.end()); + sort_runs(imp, cut1, cut2, sorts); + join(imp); + out.uni = std::move(imp); +} + +/// The union kept for every caller (under the lists' lock), and the version of the lists it was built at (0: none yet; the +/// lists' version starts at 1) +struct Shared { + uint64_t ver = 0; + Ranges uni; +}; +/// The union at the lists' version ver: make(uni) builds it when the kept one is of another version (*built says which) +template +inline const Ranges& get(Shared& s, uint64_t ver, Make&& make, bool* built) { + const bool stale = s.ver != ver; + if (stale) make(s.uni), s.ver = ver; + if (built) *built = stale; + return s.uni; +} + +} // namespace capunion diff --git a/gpu/vk/cmd_work.h b/gpu/vk/cmd_work.h index 7dcee54..e9bacdd 100644 --- a/gpu/vk/cmd_work.h +++ b/gpu/vk/cmd_work.h @@ -25,6 +25,8 @@ #include #include +#include "capturepushkeep.h" // ((Triforce, 11-26, C15) the capture push a command buffer holds: CmdWork::cap) + namespace mkwvk { extern std::atomic work_epoch; // (vk_texture.cpp: RX_VK_BARRIER_CONTEXT=0's count, every thread's commands) @@ -52,6 +54,9 @@ struct CmdWork { uint64_t pass_end_at = UINT64_MAX; // (right after its last draw pass ended, unless the replay split that pass for a hazard) uint64_t dispatch_at = UINT64_MAX; // (right after its last dispatch: RX_VK_DISPATCH_BARRIER) bool known = true; // (false: the stand-in for a command buffer the table had no room for, never right after anything) + // ((Triforce, 11-26, C15) capturepushkeep.h: the zeros the plain draws' capture push left on it, told of every push and + // bind by vk_work.h's macros and started afresh by work_begun; not a count, no barrier rule reads it) + capturepushkeep::State cap; }; /// The table: a slot a command buffer, taken at its first command or begin by whichever thread comes first and kept for good (the @@ -62,7 +67,7 @@ struct alignas(64) CmdWorkSlot { // (a cache line each: two threads recording CmdWork w; }; inline CmdWorkSlot cmd_work_slots[kCmdWorkSlots]; -inline thread_local CmdWork cmd_work_none{0, UINT64_MAX, UINT64_MAX, UINT64_MAX, false}; // (vk_texture.cpp full_barrier tells it once) +inline thread_local CmdWork cmd_work_none{0, UINT64_MAX, UINT64_MAX, UINT64_MAX, false, {}}; // (vk_texture.cpp full_barrier tells it once) inline CmdWork* cmd_work_find(VkCommandBuffer cmd) { if (cmd == VK_NULL_HANDLE) return &cmd_work_none; const size_t h = (size_t)(((uint64_t)(uintptr_t)cmd * 0x9E3779B97F4A7C15ull) >> 54); // (10 bits: kCmdWorkSlots) @@ -109,6 +114,7 @@ inline VkCommandBuffer work_begun(VkCommandBuffer cmd) { CmdWork& w = cmd_work(cmd); w.n++; w.barrier_at = w.pass_end_at = w.dispatch_at = UINT64_MAX; + capturepushkeep::begun(w.cap); // ((Triforce, 11-26, C15) push constants are undefined in a new recording) return cmd; } /// A submit to the queue (vkQueueSubmit2), any thread's diff --git a/gpu/vk/cpuwordsseen.h b/gpu/vk/cpuwordsseen.h new file mode 100644 index 0000000..a833da0 --- /dev/null +++ b/gpu/vk/cpuwordsseen.h @@ -0,0 +1,99 @@ +// (Triforce, 11-26) A report word the sets hold already is not noted again: the words memory_cpu_owned was given before, +// answered from a table at the note. +// +// The replay writes every counter report into guest memory on the CPU and notes its two words (vk_memory.cpp +// memory_cpu_owned), so that a mirror's write-back leaves them out (the one-frame dark flashes of 11-07). The same report +// words come every frame, and each was pushed onto cpu_words_new again, then sorted, made unique and searched for in both +// sets at the next part's end with write-backs (cpu_words_merge), only to be found there and dropped: 1.6% of the +// Presentation Thread at Lake Hylia and 2.5% at the Market on v0.8.3 (the sort, the two binary searches a word). +// +// The table says of a word "it is in cpu_words, cpu_words_recent or cpu_words_new": such a word is not pushed again, and +// the sets end up the same, since the merge would have dropped it. What makes that exact: +// - an entry holds the WHOLE address and the sets' generation, and both are compared. Two words that share an entry +// push each other out, and the one pushed out is noted again as before (the merge drops it): a shared entry costs a +// push, never a word. A hash alone would call a word known that the sets do not hold, the write-back would copy the +// mirror's stale word over it, and the dark flashes would be back; +// - a word is marked only when it is pushed, and words leave the sets in one place only, memory_cpu_owned's clear of +// both past 65,536 words: forget() is called there, in the same statement, and makes every entry stale at once; +// - all of it under cpu_words_mu, like the sets. +// The clear comes at the same note as before: it needs more than 65,536 different words held, and what the sizes add up +// to is never less than that with or without the repeats. Which of the two sets a word is in can differ for a while +// (the merges come at other times); the two together, and so the cut runs, do not (tests/test_cpuwordsseen.py runs the +// notes and the cuts with the table off, on and checking, against a std::set). +// +// The switch: RX_VK_CPU_WORDS_SEEN=0 notes every word again, as before; =check notes every word as before and looks each +// word the table calls known up in the sets (a word held nowhere is a mismatch, counted in the mirror syncs' status +// line); any other value is on, as unset, and logged when not 1. The lab knob nowordsseen (RX_VK_LAB_AB) notes every +// word again in its phases; the table stays right through them, since a word noted past it is only one more the table +// does not know. Without mirrors (wb_notes_off: Intel's integrated GPUs, RX_VK_MIRROR=0) or with RX_VK_WB_REPORTS set +// no report word is noted: the switch is not read or logged and the four counts stay 0. +#pragma once +#include +#include +#include +#include +#include +#include +#include + +namespace cpu_words_seen { + +enum Mode { OFF = 0, ON = 1, CHECK_BOTH = 2 }; + +/// RX_VK_CPU_WORDS_SEEN's value: not set, "" or any other value is on, "0" is off, "check" checks +inline int mode(const char* env) { + if (!env || !*env) return ON; + if (!strcmp(env, "check")) return CHECK_BOTH; + return env[0] == '0' && !env[1] ? OFF : ON; +} +/// The mode of one note: the lab knob nowordsseen turns the table off in its phases +inline int mode_now(int env, bool knob) { return knob ? OFF : env; } + +// (the sets hold up to 65,536 words: twice that in entries, 2 MB of zeroes until a word is marked, so that few words +// share one. A frame's report words touch a cache line of it each: a few hundred KB for a few thousand words) +constexpr int kSlotBits = 17; +constexpr size_t kSlots = size_t(1) << kSlotBits; + +struct Table { + struct Entry { + uint64_t word, stamp; // (the word's whole address; the generation it was marked in, plus one: 0 is no word) + }; + Entry e[kSlots]; + uint64_t forgets = 0; // (the sets' generation: how often they were cleared) + // (for the status line, read without the lock: written only under cpu_words_mu, so a load and a store do) + std::atomic st_noted{0}, st_known{0}, st_forgets{0}, st_mismatch{0}; + + static void count(std::atomic& c) { c.store(c.load(std::memory_order_relaxed) + 1, std::memory_order_relaxed); } + /// The entry of a word (words are 8 bytes apart) + static size_t slot(uint64_t word) { return (size_t)(((word >> 3) * 0x9E3779B97F4A7C15ull) >> (64 - kSlotBits)); } + /// The word was marked since the last forget() and nothing has taken its entry + bool known(uint64_t word) const { + const Entry& x = e[slot(word)]; + return x.stamp == forgets + 1 && x.word == word; + } + void mark(uint64_t word) { e[slot(word)] = {word, forgets + 1}; } + /// The sets were cleared: no word is known any more + void forget() { forgets++, count(st_forgets); } +}; + +/// (check) The word is in one of the sets, or noted since the last merge +inline bool held(uint64_t word, const std::vector& big, const std::vector& recent, const std::vector& noted) { + return std::binary_search(big.begin(), big.end(), word) || std::binary_search(recent.begin(), recent.end(), word) || + std::find(noted.begin(), noted.end(), word) != noted.end(); +} + +/// One word of a note: whether to push it onto the words noted since the last merge (holding the sets' lock). +/// Off: always, the table untouched. On: unless the table knows it; a word pushed is marked. Checking: always, as +/// before, and a word the table knows must be held (big and recent: the two sorted sets; noted: since the last merge) +inline bool push(Table& t, int mode, uint64_t word, const std::vector& big, const std::vector& recent, + const std::vector& noted) { + if (mode == OFF) return true; + Table::count(t.st_noted); + if (!t.known(word)) return t.mark(word), true; + Table::count(t.st_known); + if (mode == ON) return false; + if (!held(word, big, recent, noted)) Table::count(t.st_mismatch); + return true; +} + +} // namespace cpu_words_seen diff --git a/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 9d43290..9ee430e 100644 --- a/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/gpu/vk/eden/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -1555,7 +1555,9 @@ void EmitContext::DefineGlobalMemoryFunctions(const Info& info) { // the wall of trees in the sky. The culling's compute programs, with hundreds of global loads, keep the helper // (NVIDIA took 41 s on one inlined, above) static const bool gm_inline{!getenv("EDEN_NX2_GM_INLINE") || getenv("EDEN_NX2_GM_INLINE")[0] != '0'}; - const bool inline_here{gm_inline && (stage == Stage::Task || stage == Stage::Mesh || + // ((11-28) lab: EDEN_NX2_GM_INLINE=2 inlines them in every stage, for the Jabu-Jabu bars' fragment program a9b0170b) + static const bool gm_inline_all{gm_inline && getenv("EDEN_NX2_GM_INLINE") && getenv("EDEN_NX2_GM_INLINE")[0] == '2'}; + const bool inline_here{gm_inline_all || gm_inline && (stage == Stage::Task || stage == Stage::Mesh || (shift == 4 && runtime_info.inline_global_128_loads))}; const Id func_id{OpFunction(type, inline_here ? spv::FunctionControlMask::Inline : spv::FunctionControlMask::DontInline, function_type)}; diff --git a/gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp b/gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp index 0402c36..1509a38 100644 --- a/gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp +++ b/gpu/vk/eden/shader_recompiler/ir_opt/global_memory_to_storage_buffer_pass.cpp @@ -1668,7 +1668,17 @@ void GlobalMemoryToStorageBufferPass(Environment& env, IR::Program& program, return; } // (hookshot) - static const bool no_mesh{std::getenv("RX_VK_FOLLOW_MESH") == nullptr}; + // ((Triforce, 11-28) the task and mesh stages too, by default: RX_VK_FOLLOW_MESH=0, the compute stage alone, as before. + // Jabu-Jabu's tentacle bars (mesh a9b0170bd5986fd6) light each vertex from a probe grid: a chunk header, then a cell + // record read through a pointer loaded from storage buffer 1. Its second vertex batch's reads were tracked to storage + // buffer 2's descriptor (c0+0x790) and read another buffer there: every probe "invalid", no ambient, the black patches + // with teal edges the bars always had (Navi's light, a pass of its own, still showed them). The first batch's reads went + // to the run-time search and were right. Left to it, as compute's are, the bars are whole. Off on 11-07 because the leaves + // went missing; the search has covered whole pools and the page table since) + static const bool no_mesh{[] { + const char* const e{std::getenv("RX_VK_FOLLOW_MESH")}; + return e && *e && std::atoi(e) == 0; + }()}; g_follow_stage = program.stage == Stage::Compute || (!no_mesh && (program.stage == Stage::Task || program.stage == Stage::Mesh)); // (geometry stages only: with the fragment stage too, the sky drew black rectangles and the lighting went too bright at the castle) g_graphics_stage = program.stage != Stage::Compute && program.stage != Stage::Fragment; diff --git a/gpu/vk/menu_i18n.h b/gpu/vk/menu_i18n.h index e9ebd40..83de93c 100644 --- a/gpu/vk/menu_i18n.h +++ b/gpu/vk/menu_i18n.h @@ -52,6 +52,10 @@ inline constexpr Entry kpt_BR[] = { {"Always on.", "Sempre ligado."}, {"Amount", "Quantidade"}, {"Apply", "Aplicar"}, + {"Apply ", "Aplicar "}, + {"Apply Now", "Aplicar agora"}, + {"Apply Settings", "Aplicar configurações"}, + {"Apply needed: ", "Requer aplicar: "}, {"As On, and the graphics card's clocks are kept up as well.", "Como Ligado, e os clocks da GPU também ficam altos."}, {"As the stick", "Como o analógico"}, {"Aspect ratio", "Proporção de tela"}, @@ -320,6 +324,7 @@ inline constexpr Entry kpt_BR[] = { {"Swaps up and down for the mouse.", "Troca cima e baixo no mouse."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Controles Switch Pro e controles no modo Switch, DualSense e DualShock 4. O valor diz se o controle conectado tem giroscópio."}, {"Switch age", "Trocar idade"}, + {"Takes effect after Apply", "Vale após aplicar"}, {"Takes effect after a restart", "Vale após reiniciar"}, {"Teleport", "Teleporte"}, {"Teleport Link to the marked position in the current scene.", "Teleporta Link para a posição marcada na cena atual."}, @@ -330,6 +335,7 @@ inline constexpr Entry kpt_BR[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "A ordem do Switch: A à direita, B embaixo, X em cima, Y à esquerda."}, {"The best dedicated GPU.", "A melhor GPU dedicada."}, {"The brightest highlights: set it to your display's peak brightness.", "Os realces mais brilhantes com HDR ligado: ajuste para o brilho máximo da sua tela."}, + {"The game goes on where it is. The picture may pause for a moment.", "O jogo continua de onde está. A imagem pode parar por um instante."}, {"The game hears silence.", "O jogo ouve silêncio."}, {"The game lowers it when the GPU is busy, and FSR follows.", "O jogo a reduz quando a GPU está ocupada, e o FSR acompanha."}, {"The game lowers it when the GPU is busy.", "O jogo a reduz quando a GPU está ocupada."}, @@ -372,7 +378,7 @@ inline constexpr Entry kpt_BR[] = { {"View", "Exibir"}, {"Waiting for the gameplay scene", "Aguardando a cena do jogo"}, {"Warm", "Quente"}, - {"What draws the 3D up to the Output resolution.", "O que escala o 3D até a Resolução de saída."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "O que escala o 3D até a Resolução de saída. Vale após aplicar."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "O que a ocarina ouve quando a opção de microfone do jogo está ligada (tocando um instrumento ou cantarolando)."}, {"Whether the controller plays the game while another window has the focus.", "Se o controle joga enquanto outra janela está em foco."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Qual botão frontal é qual. Atribuir um você mesmo na página Controles deixa em Personalizado."}, @@ -411,6 +417,10 @@ inline constexpr Entry kes_419[] = { {"Always on.", "Siempre activado."}, {"Amount", "Cantidad"}, {"Apply", "Aplicar"}, + {"Apply ", "¿Aplicar "}, + {"Apply Now", "Aplicar ahora"}, + {"Apply Settings", "Aplicar configuración"}, + {"Apply needed: ", "Requiere aplicar: "}, {"As On, and the graphics card's clocks are kept up as well.", "Como Activado, y además se mantienen altas las frecuencias de la GPU."}, {"As the stick", "Como la palanca"}, {"Aspect ratio", "Relación de aspecto"}, @@ -684,6 +694,7 @@ inline constexpr Entry kes_419[] = { {"Swaps up and down for the mouse.", "Intercambia arriba y abajo en el mouse."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Controles Pro de Switch y controles en modo Switch, DualSense y DualShock 4. El valor indica si el control conectado tiene giroscopio."}, {"Switch age", "Cambiar edad"}, + {"Takes effect after Apply", "Se aplica con Aplicar"}, {"Takes effect after a restart", "Se aplica tras reiniciar"}, {"Teleport", "Teletransporte"}, {"Teleport Link to the marked position in the current scene.", "Teletransporta a Link a la posición marcada en la escena actual."}, @@ -694,6 +705,7 @@ inline constexpr Entry kes_419[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "El orden de Switch: A a la derecha, B abajo, X arriba, Y a la izquierda."}, {"The best dedicated GPU.", "La mejor GPU dedicada."}, {"The brightest highlights: set it to your display's peak brightness.", "Las luces más brillantes con HDR activado: ajústalo al brillo máximo de tu pantalla."}, + {"The game goes on where it is. The picture may pause for a moment.", "El juego sigue donde está. La imagen puede detenerse un momento."}, {"The game hears silence.", "El juego oye silencio."}, {"The game lowers it when the GPU is busy, and FSR follows.", "El juego la baja cuando la GPU está ocupada, y FSR la sigue."}, {"The game lowers it when the GPU is busy.", "El juego la baja cuando la GPU está ocupada."}, @@ -736,7 +748,7 @@ inline constexpr Entry kes_419[] = { {"View", "Vista"}, {"Waiting for the gameplay scene", "Esperando la escena del juego"}, {"Warm", "Cálido"}, - {"What draws the 3D up to the Output resolution.", "Lo que escala el 3D hasta la Resolución de salida."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "Lo que escala el 3D hasta la Resolución de salida. Se aplica con Aplicar."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "Lo que oye la ocarina cuando la opción de micrófono del juego está activada (tocando un instrumento o tarareando)."}, {"Whether the controller plays the game while another window has the focus.", "Si el control maneja el juego mientras otra ventana tiene el foco."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Qué botón frontal es cada uno. Asignar uno tú mismo en la página Controles lo cambia a Personalizado."}, @@ -775,6 +787,10 @@ inline constexpr Entry kes[] = { {"Always on.", "Siempre activado."}, {"Amount", "Cantidad"}, {"Apply", "Aplicar"}, + {"Apply ", "¿Aplicar "}, + {"Apply Now", "Aplicar ahora"}, + {"Apply Settings", "Aplicar ajustes"}, + {"Apply needed: ", "Requiere aplicar: "}, {"As On, and the graphics card's clocks are kept up as well.", "Como Activado, y además se mantienen altas las frecuencias de la GPU."}, {"As the stick", "Como el joystick"}, {"Aspect ratio", "Relación de aspecto"}, @@ -1050,6 +1066,7 @@ inline constexpr Entry kes[] = { {"Swaps up and down for the mouse.", "Intercambia arriba y abajo en el ratón."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Mandos Pro de Switch y mandos en modo Switch, DualSense y DualShock 4. El valor indica si el mando conectado tiene giroscopio."}, {"Switch age", "Cambiar edad"}, + {"Takes effect after Apply", "Se aplica con Aplicar"}, {"Takes effect after a restart", "Se aplica tras reiniciar"}, {"Teleport", "Teletransporte"}, {"Teleport Link to the marked position in the current scene.", "Teletransporta a Link a la posición marcada en la escena actual."}, @@ -1060,6 +1077,7 @@ inline constexpr Entry kes[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "El orden de Switch: A a la derecha, B abajo, X arriba, Y a la izquierda."}, {"The best dedicated GPU.", "La mejor GPU dedicada."}, {"The brightest highlights: set it to your display's peak brightness.", "Las luces más brillantes con HDR activado: ajústalo al brillo máximo de tu pantalla."}, + {"The game goes on where it is. The picture may pause for a moment.", "El juego sigue donde está. La imagen puede detenerse un momento."}, {"The game hears silence.", "El juego oye silencio."}, {"The game lowers it when the GPU is busy, and FSR follows.", "El juego la baja cuando la GPU está ocupada, y FSR la sigue."}, {"The game lowers it when the GPU is busy.", "El juego la baja cuando la GPU está ocupada."}, @@ -1102,7 +1120,7 @@ inline constexpr Entry kes[] = { {"View", "Vista"}, {"Waiting for the gameplay scene", "Esperando la escena del juego"}, {"Warm", "Cálido"}, - {"What draws the 3D up to the Output resolution.", "Lo que escala el 3D hasta la Resolución de salida."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "Lo que escala el 3D hasta la Resolución de salida. Se aplica con Aplicar."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "Lo que oye la ocarina cuando la opción de micrófono del juego está activada (tocando un instrumento o tarareando)."}, {"Whether the controller plays the game while another window has the focus.", "Si el mando controla el juego mientras otra ventana tiene el foco."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Qué botón frontal es cada uno. Asignar uno tú mismo en la página Controles lo cambia a Personalizado."}, @@ -1141,6 +1159,10 @@ inline constexpr Entry kfr[] = { {"Always on.", "Toujours activé."}, {"Amount", "Quantité"}, {"Apply", "Appliquer"}, + {"Apply ", "Appliquer "}, + {"Apply Now", "Appliquer"}, + {"Apply Settings", "Appliquer les réglages"}, + {"Apply needed: ", "À appliquer : "}, {"As On, and the graphics card's clocks are kept up as well.", "Comme Activé, et les fréquences du GPU restent élevées aussi."}, {"As the stick", "Comme le stick"}, {"Aspect ratio", "Format d'image"}, @@ -1412,6 +1434,7 @@ inline constexpr Entry kfr[] = { {"Swaps up and down for the mouse.", "Inverse le haut et le bas pour la souris."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Manettes Switch Pro et manettes en mode Switch, DualSense et DualShock 4. La valeur indique si la manette connectée a un gyroscope."}, {"Switch age", "Changer d'âge"}, + {"Takes effect after Apply", "Prend effet après Appliquer"}, {"Takes effect after a restart", "Prend effet après un redémarrage"}, {"Teleport", "Téléporter"}, {"Teleport Link to the marked position in the current scene.", "Téléporte Link à la position marquée dans la scène actuelle."}, @@ -1422,6 +1445,7 @@ inline constexpr Entry kfr[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "L'ordre de la Switch : A à droite, B en bas, X en haut, Y à gauche."}, {"The best dedicated GPU.", "Le meilleur GPU dédié."}, {"The brightest highlights: set it to your display's peak brightness.", "Les hautes lumières les plus vives avec le HDR activé : réglez-la sur la luminosité maximale de votre écran."}, + {"The game goes on where it is. The picture may pause for a moment.", "Le jeu continue là où il est. L'image peut se figer un instant."}, {"The game hears silence.", "Le jeu n'entend que du silence."}, {"The game lowers it when the GPU is busy, and FSR follows.", "Le jeu la baisse quand le GPU est occupé, et le FSR suit."}, {"The game lowers it when the GPU is busy.", "Le jeu la baisse quand le GPU est occupé."}, @@ -1463,7 +1487,7 @@ inline constexpr Entry kfr[] = { {"View", "Affichage"}, {"Waiting for the gameplay scene", "En attente de la scène de jeu"}, {"Warm", "Chaud"}, - {"What draws the 3D up to the Output resolution.", "Ce qui met la 3D à l'échelle de la Résolution de sortie."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "Ce qui met la 3D à l'échelle de la Résolution de sortie. Prend effet après Appliquer."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "Ce que l'ocarina entend quand l'option micro du jeu est activée (en jouant d'un instrument ou en fredonnant)."}, {"Whether the controller plays the game while another window has the focus.", "Si la manette contrôle le jeu quand une autre fenêtre a le focus."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Quel bouton de façade est lequel. En assigner un vous-même sur la page Commandes passe en Personnalisé."}, @@ -1502,6 +1526,10 @@ inline constexpr Entry kde[] = { {"Always on.", "Immer an."}, {"Amount", "Menge"}, {"Apply", "Anwenden"}, + {"Apply ", "Anwenden: "}, + {"Apply Now", "Jetzt anwenden"}, + {"Apply Settings", "Einstellungen anwenden"}, + {"Apply needed: ", "Anwenden nötig: "}, {"As On, and the graphics card's clocks are kept up as well.", "Wie An, zusätzlich bleiben die GPU-Takte hoch."}, {"As the stick", "Wie der Stick"}, {"Aspect ratio", "Seitenverhältnis"}, @@ -1772,6 +1800,7 @@ inline constexpr Entry kde[] = { {"Swaps up and down for the mouse.", "Tauscht oben und unten für die Maus."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Switch Pro Controller und Pads im Switch-Modus, DualSense und DualShock 4. Der Wert zeigt, ob das verbundene Pad ein Gyroskop hat."}, {"Switch age", "Alter wechseln"}, + {"Takes effect after Apply", "Gilt nach dem Anwenden"}, {"Takes effect after a restart", "Gilt nach einem Neustart"}, {"Teleport Link to the marked position in the current scene.", "Teleportiert Link zur markierten Position in der aktuellen Szene."}, {"Testing tools: no-clip flight, a free camera, teleport, Link's age, the inventory, the clock, heart protection and movement speed. Off puts flight, the free camera and heart protection away and Link back to his own speed.", "Testwerkzeuge: No-Clip-Flug, freie Kamera, Teleport, Links Alter, Inventar, Uhr, Herzschutz und Bewegungstempo. Aus beendet Flug, freie Kamera und Herzschutz und setzt Link auf sein eigenes Tempo zurück."}, @@ -1781,6 +1810,7 @@ inline constexpr Entry kde[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "Die Anordnung der Switch: A rechts, B unten, X oben, Y links."}, {"The best dedicated GPU.", "Die beste dedizierte GPU."}, {"The brightest highlights: set it to your display's peak brightness.", "Die hellsten Spitzlichter mit HDR: auf die Spitzenhelligkeit des Displays einstellen."}, + {"The game goes on where it is. The picture may pause for a moment.", "Das Spiel läuft dort weiter, wo es ist. Das Bild kann kurz stocken."}, {"The game hears silence.", "Das Spiel hört Stille."}, {"The game lowers it when the GPU is busy, and FSR follows.", "Das Spiel senkt sie, wenn die GPU ausgelastet ist, und FSR folgt."}, {"The game lowers it when the GPU is busy.", "Das Spiel senkt sie, wenn die GPU ausgelastet ist."}, @@ -1823,7 +1853,7 @@ inline constexpr Entry kde[] = { {"View", "Ansicht"}, {"Waiting for the gameplay scene", "Warten auf die Spielszene"}, {"Warm", "Warm"}, - {"What draws the 3D up to the Output resolution.", "Was das 3D-Bild auf die Ausgabeauflösung hochskaliert."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "Was das 3D-Bild auf die Ausgabeauflösung hochskaliert. Gilt nach dem Anwenden."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "Was die Okarina hört, wenn die Mikrofon-Option des Spiels an ist (ein Instrument spielen oder summen)."}, {"Whether the controller plays the game while another window has the focus.", "Ob der Controller das Spiel steuert, während ein anderes Fenster den Fokus hat."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Welche Haupttaste welche ist. Eine selbst auf der Seite Steuerung zu belegen, stellt auf Eigene um."}, @@ -1862,6 +1892,10 @@ inline constexpr Entry kit[] = { {"Always on.", "Sempre attivo."}, {"Amount", "Quantità"}, {"Apply", "Applica"}, + {"Apply ", "Applicare "}, + {"Apply Now", "Applica ora"}, + {"Apply Settings", "Applica impostazioni"}, + {"Apply needed: ", "Da applicare: "}, {"As On, and the graphics card's clocks are kept up as well.", "Come Attivo, e in più le frequenze della GPU restano alte."}, {"As the stick", "Come la levetta"}, {"Aspect ratio", "Proporzioni"}, @@ -2131,6 +2165,7 @@ inline constexpr Entry kit[] = { {"Swaps up and down for the mouse.", "Scambia su e giù per il mouse."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Controller Pro di Switch e controller in modalità Switch, DualSense e DualShock 4. Il valore indica se il controller collegato ha un giroscopio."}, {"Switch age", "Cambia età"}, + {"Takes effect after Apply", "Si applica con Applica"}, {"Takes effect after a restart", "Si applica dopo un riavvio"}, {"Teleport", "Teletrasporto"}, {"Teleport Link to the marked position in the current scene.", "Teletrasporta Link alla posizione segnata nella scena attuale."}, @@ -2141,6 +2176,7 @@ inline constexpr Entry kit[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "L'ordine di Switch: A a destra, B in basso, X in alto, Y a sinistra."}, {"The best dedicated GPU.", "La migliore GPU dedicata."}, {"The brightest highlights: set it to your display's peak brightness.", "Le luci più intense con HDR attivo: impostalo sulla luminosità di picco del tuo schermo."}, + {"The game goes on where it is. The picture may pause for a moment.", "Il gioco continua da dove si trova. L'immagine può fermarsi per un attimo."}, {"The game hears silence.", "Il gioco sente silenzio."}, {"The game lowers it when the GPU is busy, and FSR follows.", "Il gioco la abbassa quando la GPU è occupata, e FSR si adegua."}, {"The game lowers it when the GPU is busy.", "Il gioco la abbassa quando la GPU è occupata."}, @@ -2183,7 +2219,7 @@ inline constexpr Entry kit[] = { {"View", "Visualizza"}, {"Waiting for the gameplay scene", "In attesa della scena di gioco"}, {"Warm", "Caldo"}, - {"What draws the 3D up to the Output resolution.", "Ciò che scala il 3D fino alla Risoluzione di uscita."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "Ciò che scala il 3D fino alla Risoluzione di uscita. Si applica con Applica."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "Ciò che sente l'ocarina quando l'opzione microfono del gioco è attiva (suonando uno strumento o canticchiando)."}, {"Whether the controller plays the game while another window has the focus.", "Se il controller comanda il gioco mentre un'altra finestra ha il focus."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Quale pulsante frontale è quale. Assegnarne uno tu stesso nella pagina Comandi lo rende Personalizzato."}, @@ -2222,6 +2258,10 @@ inline constexpr Entry knl[] = { {"Always on.", "Altijd aan."}, {"Amount", "Aantal"}, {"Apply", "Toepassen"}, + {"Apply ", "Toepassen: "}, + {"Apply Now", "Nu toepassen"}, + {"Apply Settings", "Instellingen toepassen"}, + {"Apply needed: ", "Toepassen nodig: "}, {"As On, and the graphics card's clocks are kept up as well.", "Zoals Aan, en de kloksnelheden van de GPU blijven ook hoog."}, {"As the stick", "Als de stick"}, {"Aspect ratio", "Beeldverhouding"}, @@ -2487,6 +2527,7 @@ inline constexpr Entry knl[] = { {"Swaps up and down for the mouse.", "Wisselt omhoog en omlaag voor de muis."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Switch Pro-controllers en pads in Switch-modus, DualSense en DualShock 4. De waarde geeft aan of de verbonden pad een gyroscoop heeft."}, {"Switch age", "Leeftijd wisselen"}, + {"Takes effect after Apply", "Geldt na Toepassen"}, {"Takes effect after a restart", "Geldt na een herstart"}, {"Teleport Link to the marked position in the current scene.", "Teleporteert Link naar de gemarkeerde positie in de huidige scène."}, {"Testing tools: no-clip flight, a free camera, teleport, Link's age, the inventory, the clock, heart protection and movement speed. Off puts flight, the free camera and heart protection away and Link back to his own speed.", "Testtools: no-clip-vlucht, een vrije camera, teleport, de leeftijd van Link, de inventaris, de klok, hartbescherming en bewegingssnelheid. Uit zet de vlucht, de vrije camera en de hartbescherming uit en geeft Link zijn eigen snelheid terug."}, @@ -2496,6 +2537,7 @@ inline constexpr Entry knl[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "De volgorde van de Switch: A rechts, B onderaan, X bovenaan, Y links."}, {"The best dedicated GPU.", "De beste dedicated GPU."}, {"The brightest highlights: set it to your display's peak brightness.", "De helderste hooglichten met HDR aan: stel dit in op de piekhelderheid van je scherm."}, + {"The game goes on where it is. The picture may pause for a moment.", "Het spel gaat verder waar het is. Het beeld kan even stilstaan."}, {"The game hears silence.", "Het spel hoort stilte."}, {"The game lowers it when the GPU is busy, and FSR follows.", "Het spel verlaagt die als de GPU druk is, en FSR volgt."}, {"The game lowers it when the GPU is busy.", "Het spel verlaagt die als de GPU druk is."}, @@ -2538,7 +2580,7 @@ inline constexpr Entry knl[] = { {"View", "Weergave"}, {"Waiting for the gameplay scene", "Wachten op de spelscène"}, {"Warm", "Warm"}, - {"What draws the 3D up to the Output resolution.", "Wat het 3D-beeld opschaalt naar de Uitvoerresolutie."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "Wat het 3D-beeld opschaalt naar de Uitvoerresolutie. Geldt na Toepassen."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "Wat de ocarina hoort als de microfoonoptie van het spel aan staat (een instrument bespelen of neuriën)."}, {"Whether the controller plays the game while another window has the focus.", "Of de controller het spel bestuurt terwijl een ander venster de focus heeft."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Welke frontknop welke is. Er zelf een toewijzen op de pagina Besturing maakt het Aangepast."}, @@ -2579,6 +2621,10 @@ inline constexpr Entry kpl[] = { {"Always on.", "Zawsze włączone."}, {"Amount", "Ilość"}, {"Apply", "Zastosuj"}, + {"Apply ", "Zastosować: "}, + {"Apply Now", "Zastosuj teraz"}, + {"Apply Settings", "Zastosuj ustawienia"}, + {"Apply needed: ", "Wymaga zastosowania: "}, {"As On, and the graphics card's clocks are kept up as well.", "Jak Wł., a do tego taktowanie GPU pozostaje wysokie."}, {"As the stick", "Jak gałka"}, {"Aspect ratio", "Proporcje obrazu"}, @@ -2848,6 +2894,7 @@ inline constexpr Entry kpl[] = { {"Swaps up and down for the mouse.", "Zamienia górę i dół dla myszy."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Kontrolery Switch Pro i pady w trybie Switch, DualSense i DualShock 4. Wartość pokazuje, czy podłączony pad ma żyroskop."}, {"Switch age", "Zmień wiek"}, + {"Takes effect after Apply", "Zadziała po zastosowaniu"}, {"Takes effect after a restart", "Zadziała po restarcie"}, {"Teleport Link to the marked position in the current scene.", "Teleportuje Linka do zaznaczonej pozycji w bieżącej scenie."}, {"Testing tools: no-clip flight, a free camera, teleport, Link's age, the inventory, the clock, heart protection and movement speed. Off puts flight, the free camera and heart protection away and Link back to his own speed.", "Narzędzia testowe: lot no-clip, wolna kamera, teleport, wiek Linka, ekwipunek, zegar, ochrona serc i szybkość ruchu. Wył. wyłącza lot, wolną kamerę i ochronę serc oraz przywraca Linkowi jego własną szybkość."}, @@ -2857,6 +2904,7 @@ inline constexpr Entry kpl[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "Układ Switcha: A po prawej, B na dole, X na górze, Y po lewej."}, {"The best dedicated GPU.", "Najlepsze dedykowane GPU."}, {"The brightest highlights: set it to your display's peak brightness.", "Najjaśniejsze miejsca obrazu przy włączonym HDR: ustaw na szczytową jasność ekranu."}, + {"The game goes on where it is. The picture may pause for a moment.", "Gra toczy się dalej tam, gdzie jest. Obraz może na chwilę się zatrzymać."}, {"The game hears silence.", "Gra słyszy ciszę."}, {"The game lowers it when the GPU is busy, and FSR follows.", "Gra obniża ją, gdy GPU jest obciążone, a FSR się dostosowuje."}, {"The game lowers it when the GPU is busy.", "Gra obniża ją, gdy GPU jest obciążone."}, @@ -2899,7 +2947,7 @@ inline constexpr Entry kpl[] = { {"View", "Widok"}, {"Waiting for the gameplay scene", "Oczekiwanie na scenę gry"}, {"Warm", "Ciepły"}, - {"What draws the 3D up to the Output resolution.", "Co skaluje obraz 3D do Rozdzielczości wyjścia."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "Co skaluje obraz 3D do Rozdzielczości wyjścia. Zadziała po zastosowaniu."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "Co słyszy okaryna, gdy opcja mikrofonu w grze jest włączona (gra na instrumencie lub nucenie)."}, {"Whether the controller plays the game while another window has the focus.", "Czy kontroler steruje grą, gdy aktywne jest inne okno."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Który przycisk akcji jest którym. Własne przypisanie na stronie Sterowanie zmienia to na Własne."}, @@ -2940,6 +2988,10 @@ inline constexpr Entry kru[] = { {"Always on.", "Всегда включено."}, {"Amount", "Кол-во"}, {"Apply", "Применить"}, + {"Apply ", "Применить: "}, + {"Apply Now", "Применить"}, + {"Apply Settings", "Применить настройки"}, + {"Apply needed: ", "Нужно применить: "}, {"As On, and the graphics card's clocks are kept up as well.", "Как «Вкл.», и частоты GPU тоже остаются высокими."}, {"As the stick", "Как стик"}, {"Aspect ratio", "Соотношение сторон"}, @@ -3215,6 +3267,7 @@ inline constexpr Entry kru[] = { {"Swaps up and down for the mouse.", "Меняет местами верх и низ для мыши."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Контроллеры Switch Pro и геймпады в режиме Switch, DualSense и DualShock 4. Значение показывает, есть ли у подключённого геймпада гироскоп."}, {"Switch age", "Сменить возраст"}, + {"Takes effect after Apply", "Применится после «Применить»"}, {"Takes effect after a restart", "Применится после перезапуска"}, {"Teleport", "Телепорт"}, {"Teleport Link to the marked position in the current scene.", "Телепортирует Линка в отмеченную точку текущей сцены."}, @@ -3225,6 +3278,7 @@ inline constexpr Entry kru[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "Порядок Switch: A справа, B внизу, X вверху, Y слева."}, {"The best dedicated GPU.", "Лучший дискретный GPU."}, {"The brightest highlights: set it to your display's peak brightness.", "Самые яркие блики при включённом HDR: установите пиковую яркость вашего дисплея."}, + {"The game goes on where it is. The picture may pause for a moment.", "Игра продолжится с того же места. Изображение может на мгновение замереть."}, {"The game hears silence.", "Игра слышит тишину."}, {"The game lowers it when the GPU is busy, and FSR follows.", "Игра снижает его, когда GPU загружен, и FSR подстраивается."}, {"The game lowers it when the GPU is busy.", "Игра снижает его, когда GPU загружен."}, @@ -3270,7 +3324,7 @@ inline constexpr Entry kru[] = { {"View", "Просмотр"}, {"Waiting for the gameplay scene", "Ожидание игровой сцены"}, {"Warm", "Тёплый"}, - {"What draws the 3D up to the Output resolution.", "Что масштабирует 3D до «Разрешения вывода»."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "Что масштабирует 3D до «Разрешения вывода». Применится после «Применить»."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "Что слышит окарина, когда в игре включена опция микрофона (игра на инструменте или напевание)."}, {"Whether the controller plays the game while another window has the focus.", "Управляет ли контроллер игрой, когда в фокусе другое окно."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "Какая лицевая кнопка где. Своё назначение на странице «Управление» переключает на «Свой»."}, @@ -3310,6 +3364,10 @@ inline constexpr Entry kja[] = { {"Always on.", "常にオンです。"}, {"Amount", "数"}, {"Apply", "実行"}, + {"Apply ", "反映: "}, + {"Apply Now", "今すぐ反映"}, + {"Apply Settings", "設定を反映"}, + {"Apply needed: ", "反映が必要: "}, {"As On, and the graphics card's clocks are kept up as well.", "オンと同じで、さらにGPUのクロックを高く保ちます。"}, {"As the stick", "スティック式"}, {"Aspect ratio", "アスペクト比"}, @@ -3584,6 +3642,7 @@ inline constexpr Entry kja[] = { {"Swaps up and down for the mouse.", "マウスの上下を入れ替えます。"}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Switch Proコントローラー、Switchモードのコントローラー、DualSense、DualShock 4に対応しています。値には、接続中のコントローラーにジャイロがあるかどうかが表示されます。"}, {"Switch age", "年齢切り替え"}, + {"Takes effect after Apply", "「実行」で反映されます"}, {"Takes effect after a restart", "再起動後に反映されます"}, {"Teleport", "テレポート"}, {"Teleport Link to the marked position in the current scene.", "今のシーンで記録した位置に、リンクをテレポートします。"}, @@ -3594,6 +3653,7 @@ inline constexpr Entry kja[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "Switchと同じ配置です。Aが右、Bが下、Xが上、Yが左です。"}, {"The best dedicated GPU.", "最も高性能な専用GPUを使います。"}, {"The brightest highlights: set it to your display's peak brightness.", "HDRがオンのときの、最も明るいハイライトの明るさです。ディスプレイのピーク輝度に合わせてください。"}, + {"The game goes on where it is. The picture may pause for a moment.", "ゲームはそのまま続きます。画面が一瞬止まることがあります。"}, {"The game hears silence.", "ゲームには無音が入力されます。"}, {"The game lowers it when the GPU is busy, and FSR follows.", "GPUの負荷が高いときはゲームが解像度を下げ、FSRもそれに合わせます。"}, {"The game lowers it when the GPU is busy.", "GPUの負荷が高いときは、ゲームが解像度を下げます。"}, @@ -3636,7 +3696,7 @@ inline constexpr Entry kja[] = { {"View", "ビュー"}, {"Waiting for the gameplay scene", "ゲーム画面を待機中"}, {"Warm", "暖色"}, - {"What draws the 3D up to the Output resolution.", "3Dを出力解像度まで拡大する方法です。"}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "3Dを出力解像度まで拡大する方法です。「実行」で反映されます。"}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "ゲームのマイク設定がオンのときに、オカリナが聞き取る音です(楽器の演奏や鼻歌)。"}, {"Whether the controller plays the game while another window has the focus.", "ほかのウィンドウがアクティブなときも、コントローラーでゲームを操作するかどうかです。"}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "各ボタンの配置です。「操作設定」ページで自分で割り当てると、カスタムになります。"}, @@ -3676,6 +3736,10 @@ inline constexpr Entry kko[] = { {"Always on.", "항상 켜집니다."}, {"Amount", "수량"}, {"Apply", "적용"}, + {"Apply ", "적용할까요: "}, + {"Apply Now", "지금 적용"}, + {"Apply Settings", "설정 적용"}, + {"Apply needed: ", "적용 필요: "}, {"As On, and the graphics card's clocks are kept up as well.", "켬과 같으며, GPU 클럭도 높게 유지합니다."}, {"As the stick", "스틱처럼"}, {"Aspect ratio", "화면 비율"}, @@ -3951,6 +4015,7 @@ inline constexpr Entry kko[] = { {"Swaps up and down for the mouse.", "마우스의 상하를 바꿉니다."}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "Switch Pro 컨트롤러, Switch 모드의 패드, DualSense, DualShock 4를 지원합니다. 값은 연결된 패드에 자이로스코프가 있는지 보여 줍니다."}, {"Switch age", "나이 전환"}, + {"Takes effect after Apply", "적용 후 반영됩니다"}, {"Takes effect after a restart", "재시작 후 적용"}, {"Teleport", "순간이동"}, {"Teleport Link to the marked position in the current scene.", "현재 장면에서 표시한 위치로 링크를 순간이동시킵니다."}, @@ -3961,6 +4026,7 @@ inline constexpr Entry kko[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "Switch 배치: A는 오른쪽, B는 아래, X는 위, Y는 왼쪽입니다."}, {"The best dedicated GPU.", "가장 좋은 외장 GPU입니다."}, {"The brightest highlights: set it to your display's peak brightness.", "HDR이 켜져 있을 때 가장 밝은 하이라이트입니다. 디스플레이의 최대 밝기로 설정하세요."}, + {"The game goes on where it is. The picture may pause for a moment.", "게임은 그대로 이어집니다. 화면이 잠시 멈출 수 있습니다."}, {"The game hears silence.", "게임에는 아무 소리도 들어가지 않습니다."}, {"The game lowers it when the GPU is busy, and FSR follows.", "GPU가 바쁘면 게임이 해상도를 낮추고 FSR이 따라갑니다."}, {"The game lowers it when the GPU is busy.", "GPU가 바쁘면 게임이 해상도를 낮춥니다."}, @@ -4006,7 +4072,7 @@ inline constexpr Entry kko[] = { {"View", "보기"}, {"Waiting for the gameplay scene", "게임 장면 대기 중"}, {"Warm", "따뜻한 색감"}, - {"What draws the 3D up to the Output resolution.", "3D를 출력 해상도까지 확대하는 방식입니다."}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "3D를 출력 해상도까지 확대하는 방식입니다. 적용 후 반영됩니다."}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "게임의 마이크 옵션이 켜져 있을 때 오카리나가 듣는 소리입니다(악기 연주나 허밍)."}, {"Whether the controller plays the game while another window has the focus.", "다른 창에 포커스가 있을 때도 컨트롤러로 게임을 조작할지 정합니다."}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "각 페이스 버튼의 배치입니다. 조작 페이지에서 직접 지정하면 사용자 지정이 됩니다."}, @@ -4045,6 +4111,10 @@ inline constexpr Entry kzh_Hans[] = { {"Always on.", "始终开启。"}, {"Amount", "数量"}, {"Apply", "执行"}, + {"Apply ", "应用 "}, + {"Apply Now", "立即应用"}, + {"Apply Settings", "应用设置"}, + {"Apply needed: ", "需要应用: "}, {"As On, and the graphics card's clocks are kept up as well.", "与“开启”相同,并让GPU保持高频率。"}, {"As the stick", "同摇杆"}, {"Aspect ratio", "宽高比"}, @@ -4319,6 +4389,7 @@ inline constexpr Entry kzh_Hans[] = { {"Swaps up and down for the mouse.", "交换鼠标的上下方向。"}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "支持Switch Pro手柄、Switch模式下的手柄、DualSense和DualShock 4。该值显示已连接的手柄是否有陀螺仪。"}, {"Switch age", "切换年龄"}, + {"Takes effect after Apply", "执行后生效"}, {"Takes effect after a restart", "重启后生效"}, {"Teleport", "传送"}, {"Teleport Link to the marked position in the current scene.", "将林克传送到当前场景中标记的位置。"}, @@ -4329,6 +4400,7 @@ inline constexpr Entry kzh_Hans[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "Switch的布局:A在右,B在下,X在上,Y在左。"}, {"The best dedicated GPU.", "性能最好的独立显卡。"}, {"The brightest highlights: set it to your display's peak brightness.", "开启HDR时最亮高光的亮度:请设为显示器的峰值亮度。"}, + {"The game goes on where it is. The picture may pause for a moment.", "游戏会从当前位置继续。画面可能会短暂停顿。"}, {"The game hears silence.", "游戏只会收到静音。"}, {"The game lowers it when the GPU is busy, and FSR follows.", "GPU繁忙时游戏会降低分辨率,FSR随之调整。"}, {"The game lowers it when the GPU is busy.", "GPU繁忙时游戏会降低分辨率。"}, @@ -4371,7 +4443,7 @@ inline constexpr Entry kzh_Hans[] = { {"View", "视图"}, {"Waiting for the gameplay scene", "正在等待游戏场景"}, {"Warm", "暖色"}, - {"What draws the 3D up to the Output resolution.", "将3D画面放大到输出分辨率的方式。"}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "将3D画面放大到输出分辨率的方式。执行后生效。"}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "游戏的麦克风选项开启时,陶笛听到的声音(演奏乐器或哼唱)。"}, {"Whether the controller plays the game while another window has the focus.", "其他窗口处于焦点时,手柄是否仍可操作游戏。"}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "各正面按键的对应方式。在“按键设置”页面自行绑定后会变为“自定义”。"}, @@ -4410,6 +4482,10 @@ inline constexpr Entry kzh_Hant[] = { {"Always on.", "始終開啟。"}, {"Amount", "數量"}, {"Apply", "執行"}, + {"Apply ", "套用 "}, + {"Apply Now", "立即套用"}, + {"Apply Settings", "套用設定"}, + {"Apply needed: ", "需要套用: "}, {"As On, and the graphics card's clocks are kept up as well.", "與「開啟」相同,並讓GPU維持高時脈。"}, {"As the stick", "同搖桿"}, {"Aspect ratio", "長寬比"}, @@ -4684,6 +4760,7 @@ inline constexpr Entry kzh_Hant[] = { {"Swaps up and down for the mouse.", "交換滑鼠的上下方向。"}, {"Switch Pro controllers and pads in Switch mode, DualSense and DualShock 4. The value says whether the connected pad has a gyroscope.", "支援Switch Pro控制器、Switch模式下的控制器、DualSense和DualShock 4。此值顯示已連接的控制器是否有陀螺儀。"}, {"Switch age", "切換年齡"}, + {"Takes effect after Apply", "執行後生效"}, {"Takes effect after a restart", "重新啟動後生效"}, {"Teleport", "傳送"}, {"Teleport Link to the marked position in the current scene.", "將林克傳送到目前場景中標記的位置。"}, @@ -4694,6 +4771,7 @@ inline constexpr Entry kzh_Hant[] = { {"The Switch's order: A on the right, B at the bottom, X at the top, Y on the left.", "Switch的配置:A在右,B在下,X在上,Y在左。"}, {"The best dedicated GPU.", "效能最佳的獨立顯示卡。"}, {"The brightest highlights: set it to your display's peak brightness.", "開啟HDR時最亮亮部的亮度:請設為顯示器的峰值亮度。"}, + {"The game goes on where it is. The picture may pause for a moment.", "遊戲會從目前位置繼續。畫面可能會短暫停頓。"}, {"The game hears silence.", "遊戲只會收到靜音。"}, {"The game lowers it when the GPU is busy, and FSR follows.", "GPU忙碌時遊戲會降低解析度,FSR隨之調整。"}, {"The game lowers it when the GPU is busy.", "GPU忙碌時遊戲會降低解析度。"}, @@ -4736,7 +4814,7 @@ inline constexpr Entry kzh_Hant[] = { {"View", "檢視"}, {"Waiting for the gameplay scene", "正在等待遊戲場景"}, {"Warm", "暖色"}, - {"What draws the 3D up to the Output resolution.", "將3D畫面放大到輸出解析度的方式。"}, + {"What draws the 3D up to the Output resolution. Takes effect after Apply.", "將3D畫面放大到輸出解析度的方式。執行後生效。"}, {"What the ocarina hears when the game's microphone option is on (playing an instrument, or humming).", "遊戲的麥克風選項開啟時,陶笛聽到的聲音(演奏樂器或哼唱)。"}, {"Whether the controller plays the game while another window has the focus.", "其他視窗為作用中時,控制器是否仍可操作遊戲。"}, {"Which face button is which. Binding one yourself on the Controls page makes it Custom.", "各正面按鍵的對應方式。在「按鍵設定」頁面自行綁定後會變為「自訂」。"}, diff --git a/gpu/vk/menu_sound_events.h b/gpu/vk/menu_sound_events.h index 1ade5d0..3f3a540 100644 --- a/gpu/vk/menu_sound_events.h +++ b/gpu/vk/menu_sound_events.h @@ -28,7 +28,16 @@ constexpr int kNone = 0, kOpen = 1, kClose = 2, kCursor = 3, kDecide = 4, kCance // ((Triforce) and the Mods screen's and entry's own, which sound_of never names: the fanfare of a mod installed, and the // system menu's cursor and "decide" of the game's lists the Mods entry is under. (11-19) The queue took the seven above // only and dropped these without a word: moving onto Mods, A on it, Quit's dialog and the fanfare were silent) -constexpr int kFanfare = 8, kSysCursor = 9, kSysDecide = 10, kLast = kSysDecide; +constexpr int kFanfare = 8, kSysCursor = 9, kSysDecide = 10; +// ((Triforce, 11-25) the owner: "The SFX are incorrect. They should be using the title screen's SFX instead of the in-game +// Menu SFX." Whose cursor, decide and cancel it is, a sound each (host/menu_sound.c has their files, the system menu's unless +// the environment names others): the settings' tabs', the Mods screen's, and the step back to the pause menu's System list +// (out of the Mods screen opened from it; Cancel and B on Quit's dialog). kCursor, kDecide and kCancel stay what sound_of +// names, the in-game menu's sounds that nothing asks for by itself any more: sound_for says whose it is) +constexpr int kSettingsNavigate = 11, kSettingsSelect = 12, kSettingsBack = 13, kModsNavigate = 14, kModsSelect = 15, + kModsBack = 16, kPauseBack = 17; +// ((Triforce, 11-25) the owner, in the lab: "In the display, the on and off SFX are incorrect ... let me pick the correct SFX for the on and off selection for the settings". A toggle of the settings' tabs switched On, and switched Off: toggle_sound) +constexpr int kSettingsOn = 18, kSettingsOff = 19, kLast = kSettingsOff; // (State::page: the tabs' rows, a page over them, and the restart question, whose two buttons L and R choose between) constexpr int kPageRows = 0, kPageAsk = 5; @@ -48,6 +57,7 @@ struct State { int cursor = 0; // the row, card, cell or button chosen int mode = kModeNone; int64_t value = 0; // what the chosen row is set to + bool toggle = false; // ((Triforce) the chosen row is a toggle, On or Off (its value 1 or 0): toggle_sound bool operator==(const State&) const = default; }; @@ -100,6 +110,26 @@ inline int sound_of(const State& b, const State& a, const Input& in) { return kNone; } +/// ((Triforce, 11-25) The sound asked for, for one sound_of named: its cursor, decide and cancel are the settings' tabs' own +/// or, with `mods` (the tick found the Mods screen shown), the Mods screen's; a cancel there that goes back to the pause +/// menu's System list (`to_pause`) is that list's step back. The others (open, close, the tabs' moves, none) as they are +inline int sound_for(int sound, bool mods, bool to_pause) { + if (sound == kCursor) return mods ? kModsNavigate : kSettingsNavigate; + if (sound == kDecide) return mods ? kModsSelect : kSettingsSelect; + if (sound == kCancel) return !mods ? kSettingsBack : to_pause ? kPauseBack : kModsBack; + return sound; +} + +/// ((Triforce, 11-25) The settings' toggle switched: the sound for one sound_for named, from what the tick did. A press +/// that is the settings' Select or Navigate (A, a click, Left or Right) and left the same toggle row chosen with another +/// value is the toggle's On, or its Off, by its value now; any other sound as it is +inline int toggle_sound(int sound, const State& b, const State& a) { + if (sound != kSettingsSelect && sound != kSettingsNavigate) return sound; + if (!b.toggle || !a.toggle || !b.open || !a.open || a.page != b.page || a.tab != b.tab || a.cursor != b.cursor) return sound; + if (a.value == b.value) return sound; + return a.value ? kSettingsOn : kSettingsOff; +} + constexpr int kQueue = 16; constexpr int64_t kStaleNs = 250000000; // (a quarter second) diff --git a/gpu/vk/pickwide.h b/gpu/vk/pickwide.h new file mode 100644 index 0000000..40b6c14 --- /dev/null +++ b/gpu/vk/pickwide.h @@ -0,0 +1,255 @@ +// A draw's program by a wider memo in front of program_for (no game, no GPU: a rule; vk_shader.cpp program_for_wide, +// vk_draw.cpp draw and dry_draw_program). +// +// (Triforce, 11-26, the GPU audit's C02.) program_for (vk_shader.cpp) answers a graphics draw from its pair of last picks +// when nothing was bound and no uniform was updated since, or, bound anew, when the textures of the stages its answers +// are read from stand (NvnState::tex_gen); it compares ub_generation() all the same, which moves at every inline uniform +// update, and holds two programs. A draw that misses takes the full pick: the inputs' hash (18 multiplies, and one more +// with the serial for the key), the picks' table, every answer's handle read (answer_handles), and where a handle +// differs every handle read a second time with the type of each compared (still_valid), then the pair written. About 7% +// of the Presentation Thread at Lake Hylia. +// +// The memo here stands in front of that, a thread's own, 16 sets of 2 by the program object's serial, one entry a +// program object and vertex inputs and colour types (the picks' key, compared whole, with the program's stage words): +// - an entry stands (stands) as the pair does, and for a program whose answers are all handles in c2 of their own +// stages (answer_stage_mask, from the program's descriptors, not by name) across uniform updates too: c2 is served +// from the bound textures, samplers and images alone (vk_shader.cpp stage_cbuf_word, vk_bank.cpp driver_bank_word), +// never from uniform memory, and the full pick does not read ub_generation either. A handle program (it reads +// uniform memory) or another bank keeps the pair's rule. The textures' registrations (registrations_generation) +// stay in the rule: a slot registered anew moves it. +// - an entry of the same inputs that does not stand is asked in ONE pass over its answers (one_pass): each handle +// read once; a slot with the id and version it was last seen with, and checked then, is not asked again (what a +// slot answers is fixed for a version: vk_shader.cpp texture_answer keeps it so); any other bound slot's type is +// compared with the variant's, canonical on both sides; an unbound slot takes any. That is still_valid's verdict, +// answer for answer. All of them of the variant's types: the entry's program, and nothing else is read. +// - anything else is program_for, unchanged, and its program only NOTED here (note: the inputs and the pointer; no +// answer read, no type compared, no mask taken). A noted entry does not stand. At its next sight it is asked in one +// pass, every answer (found: its mask taken and the generations stamped, it is kept from there as above); not of +// the bound textures' types then (a program a translation finished under the pick, or textures bound since), it is +// dropped and the draw is program_for's. So a program drawn once before its entry is replaced (more programs in a +// stretch of the frame than the memo holds, three serials in one set) costs the find and the note on top of program_for, +// and one drawn twice or more pays at its second draw the one pass it would have paid at its first. The set is by +// the serial alone: one program object drawn with three or more sets of vertex inputs or colour types in turn in one +// stretch takes its set's two ways in turn and never gets a memo answer ("by program_for" in the frame line shows +// it). +// So the memo returns a program only where it is the last one program_for gave these inputs on this thread AND it is of +// the bound textures' types, which is when the full pick returns its own kept program. What it leaves out is the hash, +// the table, the second walk and the pair. +// +// What the rule stands on: +// - NvnState::bind_gen and tex_gen are one lineage a queue state, bumped the same in the dry pass and in a worker's +// replay of a segment (vk_replay.cpp replay: bind program, uniform and storage buffers, textures, samplers, images, +// pools, push constants; use_queue_state rebases them at a switch). An entry lives far longer than the pair's did +// (that died at every uniform update), so a bump of either that depended on the mode, or a write to s.tex / s.samp / +// s.img without tex_gen's bump, would let an entry stand over other textures. +// - A handle program (mask ~0) stands only by the pair's first rule (bind_gen and ub_generation(), a thread's own +// count, as they were: nothing bound, no uniform updated since), so only at the next draw of the same program object: +// binding another program and this one again moves bind_gen. Its other draws are answered by one pass instead of the +// full pick. +// Where it can differ from RX_VK_PICK_WIDE=0, both programs being of the bound textures' types: program_for empties a +// thread's picks when they pass 65536 keys and then takes the first variant of those types in the list's order; the +// memo keeps the one it has. With an answer unbound (it takes any type) or types that are one canonically, two variants +// can both be of the bound textures' types, and the program and its pipeline are then another variant of the same +// shaders for the same textures. RX_VK_PICK_WIDE=check counts it as a difference that is not a wrong variant. +// +// Why in front and not in program_for: program_for, its pair and the picks are in the translation stamp (nx2/build.py +// translation_text, program_carry.h), and a token changed there starts every player's program and pipeline caches +// again at the update. program_for_wide is in a part of vk_shader.cpp outside the stamp and changes no token inside. +// +// RX_VK_PICK_WIDE=0: program_for alone, as before (its pair and the two walks). =check: a draw the memo answers is asked +// of program_for too, whose program is drawn (the others are program_for's alone), and the draws where the memo would +// have given another program are counted, and of those the ones whose program is not of the bound textures' types (a +// wrong variant samples a float texture as integers: NaN, the yellow scene). Check mode calls program_for at every draw, +// so its pair and its picks' handles move as with =0 and not as in the default, where program_for is called seldom: it +// tries the memo's answers, not that state. The lab's knob "nopickwide" (RX_VK_LAB_AB) is =0 in its phases. +// RX_VK_PICK_BIND_GEN (set to anything, as program_for reads it): an entry stands only while nothing at all was bound +// and no uniform updated, the pair's old rule. RX_VK_DEFERRED_LATE (likewise; binds read from the game's arrays at the +// replay: a generation is then no proof of what is bound, and the uniform updates' count is what told two passes apart): +// an entry stands on its stages' textures, but not past a uniform update. +#pragma once +#include +#include +#include +#include +#include + +namespace mkwvk::pickwide { + +inline constexpr int kStages = 8; // NvnState::tex_gen's stages (vk_state.h kNvnStages: the hook asserts it) +inline constexpr int kSets = 16, kWays = 2; // the memo: by the program object's serial +inline constexpr uint32_t kNotC2 = ~0u; // answer_stage_mask's "not all in c2 of their own stages" +inline constexpr uint32_t kSlotBits = 0xFFFFF; // a handle's texture slot (answer_handles' id) + +enum class Mode { Off, On, Check }; + +/// RX_VK_PICK_WIDE: unset or a number other than 0, on; check (exactly), both asked and compared; 0 or any other word +/// (on, Check, empty), off (logged) +inline Mode mode(const char* env) { + if (!env) return Mode::On; + if (!std::strcmp(env, "check")) return Mode::Check; + return std::atoi(env) != 0 ? Mode::On : Mode::Off; +} + +/// The mode of this phase: off in the lab's "nopickwide" phases +constexpr Mode in_phase(Mode env, bool lab_off) { + return lab_off ? Mode::Off : env; +} + +struct Rules { + bool by_tex; // an entry stands on its stages' textures across other binds (off: RX_VK_PICK_BIND_GEN) + bool free_ub; // and across uniform updates (off: RX_VK_PICK_BIND_GEN, RX_VK_DEFERRED_LATE) +}; +constexpr Rules rules(bool pick_bind_gen, bool deferred_late) { + return {!pick_bind_gen, !pick_bind_gen && !deferred_late}; +} + +/// What a draw is picked by, now +struct Now { + uint64_t serial, sig; // the program object's serial and its stage words (prog_stage_sig) + uint64_t bind, reg, ub; // NvnState::bind_gen, registrations_generation(), ub_generation() + int nvattr; + const uint32_t* vattr; // [16] + const uint8_t* ct; // [8] + const uint64_t* tex_gen; // [kStages] +}; + +/// A program kept for its inputs, with what it was last found valid at +struct Entry { + const void* p = nullptr; // (the Program; null: nothing kept) + bool walked = false; // (false: only noted, program_for's last for these inputs; its answers not asked yet) + uint64_t serial = 0, sig = 0, bind = 0, reg = 0, ub = 0; + int nvattr = 0; + uint32_t vattr[16]{}; + uint8_t ct[8]{}; + uint32_t amask = kNotC2; // (answer_stage_mask of p) + uint64_t tex_gen[kStages]{}; // (the stages' tex_gen it was last found valid at) + std::vector stamps; // (an answer: its slot's id and version when last walked) + std::vector ok; // (an answer: that slot, at that version, was bound and of the variant's type) + std::vector canon; // (an answer: the variant's type, canonical: the hook's) +}; + +/// Whether the entry is of these inputs: the picks' key compared whole, and the program object's stage words +inline bool same_inputs(const Entry& e, const Now& n) { + if (!e.p || e.serial != n.serial || e.sig != n.sig || e.nvattr != n.nvattr) return false; + return !std::memcmp(e.vattr, n.vattr, sizeof e.vattr) && !std::memcmp(e.ct, n.ct, sizeof e.ct); +} + +enum class Stand { + No, // walk its answers (or pick in full) + Bound, // nothing bound, nothing updated since: the pair's first rule + Textures, // bound anew, its answers' stages' textures as they were: the pair's second rule + PastUpdate, // and a uniform updated since, which its answers do not read: this memo's +}; + +/// Whether the entry's program stands for the draw without a look at its answers +inline Stand stands(const Entry& e, const Now& n, Rules r) { + if (!same_inputs(e, n) || !e.walked || e.reg != n.reg) return Stand::No; + const bool ub_same = e.ub == n.ub; + if (e.bind == n.bind && ub_same) return Stand::Bound; + if (!r.by_tex || e.amask == kNotC2) return Stand::No; + if (!ub_same && !r.free_ub) return Stand::No; + for (int k = 0; k < kStages; k++) + if ((e.amask >> k & 1) && e.tex_gen[k] != n.tex_gen[k]) return Stand::No; + return ub_same ? Stand::Textures : Stand::PastUpdate; +} + +struct Walk { + uint32_t answers = 0, moved = 0, checked = 0; // (walked; with another slot or version than last; type compared) +}; + +/// One pass over the entry's n answers: read(i) the handle answer i reads now, version(id) its slot's version, +/// check(i, handle) whether that bound texture is of the variant's type for answer i. True: every bound answer is of the +/// variant's type (still_valid's verdict). False: one is not, and the entry is not to be used as it is (drop or take anew) +template +bool one_pass(Entry& e, size_t n, Read&& read, Version&& version, Check&& check, Walk* walk = nullptr) { + if (e.stamps.size() != 2 * n || e.ok.size() != n) e.stamps.assign(2 * n, ~0u), e.ok.assign(n, 0); + Walk w; + bool good = true; + for (size_t i = 0; i < n && good; i++) { + const uint32_t h = read(i), id = h & kSlotBits, ver = version(id); + uint32_t* const st = &e.stamps[2 * i]; + w.answers++; + if (st[0] != id || st[1] != ver) st[0] = id, st[1] = ver, e.ok[i] = 0, w.moved++; + if (!h || e.ok[i]) continue; // (unbound: takes any. Checked at this slot and version: stands) + w.checked++; + if (check(i, h)) e.ok[i] = 1; + else good = false; + } + if (walk) *walk = w; + return good; +} + +/// The next pass over the entry asks every answer +inline void fresh(Entry& e) { + e.stamps.clear(), e.ok.clear(); +} + +/// The entry found valid now: it stands from here +inline void restamp(Entry& e, const Now& n) { + e.bind = n.bind, e.reg = n.reg, e.ub = n.ub; + std::memcpy(e.tex_gen, n.tex_gen, sizeof e.tex_gen); +} + +/// The entry notes the program program_for gave these inputs: nothing of it is read. It does not stand (stands) until +/// one pass has found it of the bound textures' types (found), at its next sight +inline void note(Entry& e, const Now& n, const void* p) { + e.p = p, e.walked = false, e.serial = n.serial, e.sig = n.sig, e.nvattr = n.nvattr, e.amask = kNotC2; + std::memcpy(e.vattr, n.vattr, sizeof e.vattr); + std::memcpy(e.ct, n.ct, sizeof e.ct); + fresh(e); +} + +/// A noted entry's first pass found it valid: kept with its answers' stages (answer_stage_mask), it stands from here +inline void found(Entry& e, const Now& n, uint32_t amask) { + e.amask = amask, e.walked = true; + restamp(e, n); +} + +/// Noted and found at once (the tests' shorthand: the hook notes at one draw and finds at the next) +inline void take(Entry& e, const Now& n, const void* p, uint32_t amask) { + note(e, n, p); + found(e, n, amask); +} + +inline void drop(Entry& e) { + e.p = nullptr; +} + +struct Table { + Entry e[kSets][kWays]; + uint8_t next[kSets]{}; // (the way a new program takes: the one not used last) +}; +static_assert(kSets == 16 && kWays == 2, "set_of and next go by 16 sets of 2"); + +constexpr unsigned set_of(uint64_t serial) { + return (unsigned)((serial * 0x9E3779B97F4A7C15ull) >> 60); +} + +/// The entry of these inputs (there is at most one: place), or none +inline Entry* find(Table& t, const Now& n) { + const unsigned set = set_of(n.serial); + for (int w = 0; w < kWays; w++) + if (same_inputs(t.e[set][w], n)) { + t.next[set] = (uint8_t)(1 - w); + return &t.e[set][w]; + } + return nullptr; +} + +/// Where a program for these inputs is kept: the entry of the same inputs, else an empty way, else the set's way not used last +inline Entry& place(Table& t, const Now& n) { + if (Entry* e = find(t, n)) return *e; + const unsigned set = set_of(n.serial); + int w = t.next[set]; + for (int k = 0; k < kWays; k++) + if (!t.e[set][k].p) w = k; + t.next[set] = (uint8_t)(1 - w); + return t.e[set][w]; +} + +inline void clear(Table& t) { + for (auto& set : t.e) + for (Entry& e : set) drop(e); +} + +} // namespace mkwvk::pickwide diff --git a/gpu/vk/shaders/evil_ao.comp b/gpu/vk/shaders/evil_ao.comp index bef7155..824da33 100644 --- a/gpu/vk/shaders/evil_ao.comp +++ b/gpu/vk/shaders/evil_ao.comp @@ -23,6 +23,16 @@ layout(push_constant) uniform Push { vec4 k; // (radius in world units, strength, the distance it is gone by, flags: 1 the depth runs the other way, 2 show) } pc; +// ((Triforce, 11-27) a value that is a number: its exponent's bits not all set (not Inf, not NaN), tested by its bits so that +// no compiler takes it for always true. A ROG Ally X (Radeon 890M, AMD's driver) showed black blots and whole black frames +// with Evil HD: the game's picture there can hold a NaN pixel (its B10G11R11 target keeps them), and min, max and clamp of a +// NaN stay NaN on AMD's hardware, where NVIDIA's give the other operand: the occlusion and the shafts of every pixel that +// sampled it were NaN, which aa_pack_rgb9e5 writes as black. Every colour taken in and every result is cleaned) +bool evil_finite(float v) { return (floatBitsToUint(v) & 0x7f800000u) != 0x7f800000u; } +vec3 evil_clean(vec3 c) { + return vec3(evil_finite(c.r) ? max(c.r, 0.0) : 0.0, evil_finite(c.g) ? max(c.g, 0.0) : 0.0, evil_finite(c.b) ? max(c.b, 0.0) : 0.0); +} + const int kSamples = 12; const float kTurns = 7.0; // (the spiral's turns over the samples: no two on one line) @@ -50,7 +60,13 @@ void main() { const vec3 l = view_at(c - ivec2(1, 0)), r = view_at(c + ivec2(1, 0)), d = view_at(c - ivec2(0, 1)), u = view_at(c + ivec2(0, 1)); const vec3 dx = abs(r.z - p.z) < abs(p.z - l.z) ? r - p : p - l; const vec3 dy = abs(u.z - p.z) < abs(p.z - d.z) ? u - p : p - d; + // (a surface a pixel thin in front of the sky: its neighbours' distances near b / 1e-7, their cross product past a float's + // range, and its normal no number: left open) vec3 n = normalize(cross(dx, dy)); + if (!evil_finite(n.x) || !evil_finite(n.y) || !evil_finite(n.z)) { + imageStore(ao_out, c, vec4(0.0, 0.0, 0.0, 1.0)); + return; + } if (dot(n, -p) < 0.0) n = -n; // (how rough the depth is here: its second difference across and down, as a share of the distance. A wall, a floor or // the inside of a corner is smooth; grass, leaves and hair are rough at every pixel, and their own blades would darken @@ -73,13 +89,13 @@ void main() { // fog (or a room the game keeps dark) makes it nearly flat: the creases the occlusion finds there are ones the fog hides, and // drawn over it they showed the rock through a foggy cave. Where the picture is that flat the occlusion fades out const vec3 luma_w = vec3(0.2126, 0.7152, 0.0722); - float lo = dot(texelFetch(src, c, 0).rgb, luma_w), hi = lo; + float lo = dot(evil_clean(texelFetch(src, c, 0).rgb), luma_w), hi = lo; for (int i = 0; i < kSamples; i++) { const float t = (float(i) + 0.5) / float(kSamples); const float angle = 6.2831853 * (t * kTurns + noise); const vec2 offset = vec2(cos(angle), sin(angle)) * (px * t); const ivec2 q = c + ivec2(round(offset)); - const vec3 seen = texelFetch(src, clamp(q, ivec2(0), pc.size - 1), 0).rgb; + const vec3 seen = evil_clean(texelFetch(src, clamp(q, ivec2(0), pc.size - 1), 0).rgb); const float y = dot(seen, luma_w); lo = min(lo, y), hi = max(hi, y); const vec3 v = view_at(q) - p; @@ -92,6 +108,7 @@ void main() { // grey against the open ground between them (lab 11-23); a corner's walls are tens of centimetres away and count) const float near_share = smoothstep(0.15 * radius, 0.4 * radius, sqrt(vv)); const float w = clamp((cosine - 0.25) / 0.75, 0.0, 1.0) * clamp(1.0 - vv / r2, 0.0, 1.0) * near_share; + if (!evil_finite(w)) continue; occluded += w; bounce += w * seen; } @@ -104,5 +121,5 @@ void main() { ao = mix(ao, 1.0, smoothstep(0.6 * far, far, p.z)); ao = mix(1.0, ao, smooth_here * not_flat); const float keep = smooth_here * not_flat * (1.0 - smoothstep(0.6 * far, far, p.z)); - imageStore(ao_out, c, vec4(bounce / float(kSamples) * keep, ao)); + imageStore(ao_out, c, vec4(evil_clean(bounce / float(kSamples) * keep), evil_finite(ao) ? ao : 1.0)); } diff --git a/gpu/vk/shaders/evil_ao_apply.comp b/gpu/vk/shaders/evil_ao_apply.comp index 0d0f30a..a72f4d4 100644 --- a/gpu/vk/shaders/evil_ao_apply.comp +++ b/gpu/vk/shaders/evil_ao_apply.comp @@ -23,6 +23,16 @@ layout(push_constant) uniform Push { #include "aa_common.glsl" +// ((Triforce, 11-27) a value that is a number: its exponent's bits not all set (not Inf, not NaN), tested by its bits so that +// no compiler takes it for always true. A ROG Ally X (Radeon 890M, AMD's driver) showed black blots and whole black frames +// with Evil HD: the game's picture there can hold a NaN pixel (its B10G11R11 target keeps them), and min, max and clamp of a +// NaN stay NaN on AMD's hardware, where NVIDIA's give the other operand: the occlusion and the shafts of every pixel that +// sampled it were NaN, which aa_pack_rgb9e5 writes as black. Every colour taken in and every result is cleaned) +bool evil_finite(float v) { return (floatBitsToUint(v) & 0x7f800000u) != 0x7f800000u; } +vec3 evil_clean(vec3 c) { + return vec3(evil_finite(c.r) ? max(c.r, 0.0) : 0.0, evil_finite(c.g) ? max(c.g, 0.0) : 0.0, evil_finite(c.b) ? max(c.b, 0.0) : 0.0); +} + float distance_at(ivec2 p) { float d = texelFetch(depth_tex, clamp(p, ivec2(0), pc.size - 1), 0).r; if ((int(pc.k.w) & 1) != 0) d = 1.0 - d; @@ -44,11 +54,13 @@ void main() { const ivec2 q = clamp(c + ivec2(x, y), ivec2(0), pc.size - 1); const float w = exp(-abs(distance_at(q) - z) / max(0.03 * z, 1e-4)); const vec4 a = texelFetch(ao_tex, q, 0); - sum += w * a.a; - bounce += w * a.rgb; + if (!evil_finite(w)) continue; + sum += w * (evil_finite(a.a) ? a.a : 1.0); + bounce += w * evil_clean(a.rgb); weight += w; } - const float ao = weight > 0.0 ? sum / weight : 1.0; + float ao = weight > 0.0 ? sum / weight : 1.0; + if (!evil_finite(ao)) ao = 1.0; bounce = weight > 0.0 ? bounce / weight : vec3(0.0); if ((int(pc.k.w) & 2) != 0) { // (RX_VK_EVIL_AO_SHOW=1, the lab's: the occlusion alone, white open, black closed) imageStore(dst, c, uvec4(aa_pack_rgb9e5(vec3(sqrt(ao))), 0u, 0u, 0u)); @@ -59,6 +71,7 @@ void main() { const float luma = dot(e * e, vec3(0.2126, 0.7152, 0.0722)); const float kept = mix(ao, 1.0, 0.5 * smoothstep(0.5, 1.0, luma)); // (the bounce: the light around, on this surface's colour; the occluded part of the pixel is what it lights) - const vec3 lin = e * e * kept + bounce * e * e * pc.bounce_strength * (1.0 - kept + 0.25); + const vec3 lin = evil_clean(e * e * kept + bounce * e * e * pc.bounce_strength * (1.0 - kept + 0.25)); + if (!evil_finite(lin.r + lin.g + lin.b)) return; imageStore(dst, c, uvec4(aa_pack_rgb9e5(sqrt(lin)), 0u, 0u, 0u)); } diff --git a/gpu/vk/shaders/evil_ao_apply_comp_spv.h b/gpu/vk/shaders/evil_ao_apply_comp_spv.h index bf9908f..af79445 100644 --- a/gpu/vk/shaders/evil_ao_apply_comp_spv.h +++ b/gpu/vk/shaders/evil_ao_apply_comp_spv.h @@ -1,298 +1,364 @@ -// evil_ao_apply.comp + aa_common.glsl sha256 ce62e57b06fe55d9cb50e73a5546af49a6559c6b9ee569617ed605455dcac9a4 (tests/test_evil_hd.py --write: glslangValidator -V --target-env vulkan1.2 --vn EVIL_AO_APPLY_COMP_SPV) +// evil_ao_apply.comp + aa_common.glsl sha256 5cfe44b07c0ec4ed5d523f05e0909f536882f00e8432e9af3ebb1582168d4d0c (tests/test_evil_hd.py --write: glslangValidator -V --target-env vulkan1.2 --vn EVIL_AO_APPLY_COMP_SPV) // 1116.6.0 #pragma once const uint32_t EVIL_AO_APPLY_COMP_SPV[] = { - 0x07230203,0x00010500,0x0008000b,0x0000019d,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010500,0x0008000b,0x000001fb,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x000a000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x00000087,0x00000090,0x000000cd, - 0x0000011a,0x00000151,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008,0x00000001, + 0x000a000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x000000bd,0x000000c6,0x00000103, + 0x00000150,0x0000019f,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008,0x00000001, 0x00030003,0x00000002,0x000001c2,0x000a0004,0x475f4c47,0x4c474f4f,0x70635f45,0x74735f70, 0x5f656c79,0x656e696c,0x7269645f,0x69746365,0x00006576,0x00080004,0x475f4c47,0x4c474f4f, 0x6e695f45,0x64756c63,0x69645f65,0x74636572,0x00657669,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00070005,0x0000000a,0x635f6161,0x6e6e6168,0x395f6c65,0x66283565,0x00003b31, 0x00030005,0x00000009,0x00000076,0x00070005,0x00000011,0x705f6161,0x5f6b6361,0x39626772, - 0x76283565,0x003b3366,0x00030005,0x00000010,0x00000063,0x00070005,0x00000018,0x74736964, - 0x65636e61,0x2874615f,0x3b326976,0x00000000,0x00030005,0x00000017,0x00000070,0x00070005, - 0x0000001d,0x61706e75,0x725f6b63,0x65396267,0x31752835,0x0000003b,0x00030005,0x0000001c, - 0x00000077,0x00030005,0x0000002d,0x00000072,0x00040005,0x0000002e,0x61726170,0x0000006d, - 0x00030005,0x00000033,0x00000067,0x00040005,0x00000034,0x61726170,0x0000006d,0x00030005, - 0x00000039,0x00000062,0x00040005,0x0000003a,0x61726170,0x0000006d,0x00030005,0x0000003f, - 0x0000006d,0x00030005,0x00000045,0x00000065,0x00040005,0x0000004f,0x6c616373,0x00000065, - 0x00030005,0x00000083,0x00000064,0x00050005,0x00000087,0x74706564,0x65745f68,0x00000078, - 0x00040005,0x0000008e,0x68737550,0x00000000,0x00040006,0x0000008e,0x00000000,0x00766e69, - 0x00050006,0x0000008e,0x00000001,0x657a6973,0x00000000,0x00040006,0x0000008e,0x00000002, - 0x006d6163,0x00040006,0x0000008e,0x00000003,0x0000006b,0x00070006,0x0000008e,0x00000004, - 0x6e756f62,0x735f6563,0x6e657274,0x00687467,0x00030005,0x00000090,0x00006370,0x00040005, - 0x000000b3,0x6c616373,0x00000065,0x00030005,0x000000ca,0x00000063,0x00080005,0x000000cd, - 0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x000000e5, - 0x0000007a,0x00040005,0x000000e6,0x61726170,0x0000006d,0x00030005,0x000000e9,0x006d7573, - 0x00040005,0x000000ea,0x67696577,0x00007468,0x00040005,0x000000eb,0x6e756f62,0x00006563, - 0x00030005,0x000000ed,0x00000079,0x00030005,0x000000f6,0x00000078,0x00030005,0x000000fe, - 0x00000071,0x00030005,0x00000109,0x00000077,0x00040005,0x0000010a,0x61726170,0x0000006d, - 0x00030005,0x00000119,0x00000061,0x00040005,0x0000011a,0x745f6f61,0x00007865,0x00030005, - 0x00000132,0x00006f61,0x00030005,0x00000151,0x00747364,0x00040005,0x00000157,0x61726170, - 0x0000006d,0x00030005,0x00000169,0x00000065,0x00040005,0x0000016d,0x61726170,0x0000006d, - 0x00040005,0x00000170,0x616d756c,0x00000000,0x00040005,0x00000179,0x7470656b,0x00000000, - 0x00030005,0x0000017f,0x006e696c,0x00040005,0x00000198,0x61726170,0x0000006d,0x00040047, - 0x00000087,0x00000021,0x00000001,0x00040047,0x00000087,0x00000022,0x00000000,0x00030047, - 0x0000008e,0x00000002,0x00050048,0x0000008e,0x00000000,0x00000023,0x00000000,0x00050048, - 0x0000008e,0x00000001,0x00000023,0x00000008,0x00050048,0x0000008e,0x00000002,0x00000023, - 0x00000010,0x00050048,0x0000008e,0x00000003,0x00000023,0x00000020,0x00050048,0x0000008e, - 0x00000004,0x00000023,0x00000030,0x00040047,0x000000cd,0x0000000b,0x0000001c,0x00040047, - 0x0000011a,0x00000021,0x00000000,0x00040047,0x0000011a,0x00000022,0x00000000,0x00040047, - 0x00000151,0x00000021,0x00000002,0x00040047,0x00000151,0x00000022,0x00000000,0x00040047, - 0x0000019c,0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, - 0x00030016,0x00000006,0x00000020,0x00040020,0x00000007,0x00000007,0x00000006,0x00040021, - 0x00000008,0x00000006,0x00000007,0x00040017,0x0000000c,0x00000006,0x00000003,0x00040020, - 0x0000000d,0x00000007,0x0000000c,0x00040015,0x0000000e,0x00000020,0x00000000,0x00040021, - 0x0000000f,0x0000000e,0x0000000d,0x00040015,0x00000013,0x00000020,0x00000001,0x00040017, - 0x00000014,0x00000013,0x00000002,0x00040020,0x00000015,0x00000007,0x00000014,0x00040021, - 0x00000016,0x00000006,0x00000015,0x00040020,0x0000001a,0x00000007,0x0000000e,0x00040021, - 0x0000001b,0x0000000c,0x0000001a,0x0004002b,0x00000006,0x00000020,0x00000000,0x00020014, - 0x00000021,0x0004002b,0x00000006,0x00000027,0x477f8000,0x0004002b,0x0000000e,0x0000002f, - 0x00000000,0x0004002b,0x0000000e,0x00000035,0x00000001,0x0004002b,0x0000000e,0x0000003b, - 0x00000002,0x0004002b,0x00000006,0x00000046,0xc1800000,0x0004002b,0x00000006,0x00000048, - 0x0da24260,0x0004002b,0x00000006,0x0000004d,0x41800000,0x0004002b,0x00000006,0x00000051, - 0x41c00000,0x0004002b,0x00000006,0x00000057,0x3f000000,0x0004002b,0x00000006,0x0000005a, - 0x44000000,0x0004002b,0x00000006,0x0000005e,0x3f800000,0x0004002b,0x00000006,0x00000061, - 0x40000000,0x0004002b,0x00000013,0x00000070,0x00000009,0x0004002b,0x00000013,0x00000079, - 0x00000012,0x0004002b,0x00000013,0x0000007e,0x0000001b,0x00090019,0x00000084,0x00000006, - 0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000085, - 0x00000084,0x00040020,0x00000086,0x00000000,0x00000085,0x0004003b,0x00000086,0x00000087, - 0x00000000,0x0004002b,0x00000013,0x0000008a,0x00000000,0x0005002c,0x00000014,0x0000008b, - 0x0000008a,0x0000008a,0x00040017,0x0000008c,0x00000006,0x00000002,0x00040017,0x0000008d, - 0x00000006,0x00000004,0x0007001e,0x0000008e,0x0000008c,0x00000014,0x0000008d,0x0000008d, - 0x00000006,0x00040020,0x0000008f,0x00000009,0x0000008e,0x0004003b,0x0000008f,0x00000090, - 0x00000009,0x0004002b,0x00000013,0x00000091,0x00000001,0x00040020,0x00000092,0x00000009, - 0x00000014,0x0004002b,0x00000013,0x0000009b,0x00000003,0x0004002b,0x0000000e,0x0000009c, - 0x00000003,0x00040020,0x0000009d,0x00000009,0x00000006,0x0004002b,0x00000013,0x000000a7, - 0x00000002,0x0004002b,0x00000006,0x000000ae,0x33d6bf95,0x0004002b,0x0000000e,0x000000ba, - 0x000001ff,0x00040017,0x000000cb,0x0000000e,0x00000003,0x00040020,0x000000cc,0x00000001, - 0x000000cb,0x0004003b,0x000000cc,0x000000cd,0x00000001,0x00040017,0x000000ce,0x0000000e, - 0x00000002,0x00040020,0x000000d2,0x00000007,0x00000013,0x00040020,0x000000d5,0x00000009, - 0x00000013,0x0006002c,0x0000000c,0x000000ec,0x00000020,0x00000020,0x00000020,0x0004002b, - 0x00000013,0x000000ee,0xfffffffe,0x0004002b,0x00000006,0x00000111,0x3cf5c28f,0x0004002b, - 0x00000006,0x00000114,0x38d1b717,0x00040020,0x00000118,0x00000007,0x0000008d,0x0004003b, - 0x00000086,0x0000011a,0x00000000,0x00090019,0x0000014f,0x0000000e,0x00000001,0x00000000, - 0x00000000,0x00000000,0x00000002,0x00000021,0x00040020,0x00000150,0x00000000,0x0000014f, - 0x0004003b,0x00000150,0x00000151,0x00000000,0x00040017,0x00000159,0x0000000e,0x00000004, - 0x0004002b,0x00000006,0x0000015d,0x3f7fbe77,0x0006002c,0x0000000c,0x00000162,0x0000005e, - 0x0000005e,0x0000005e,0x0004002b,0x00000006,0x00000174,0x3e59b3d0,0x0004002b,0x00000006, - 0x00000175,0x3f371759,0x0004002b,0x00000006,0x00000176,0x3d93dd98,0x0006002c,0x0000000c, - 0x00000177,0x00000174,0x00000175,0x00000176,0x0004002b,0x00000013,0x0000018a,0x00000004, - 0x0004002b,0x00000006,0x00000190,0x3e800000,0x0004002b,0x0000000e,0x0000019b,0x00000008, - 0x0006002c,0x000000cb,0x0000019c,0x0000019b,0x0000019b,0x00000035,0x00050036,0x00000002, - 0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000015,0x000000ca, - 0x00000007,0x0004003b,0x00000007,0x000000e5,0x00000007,0x0004003b,0x00000015,0x000000e6, - 0x00000007,0x0004003b,0x00000007,0x000000e9,0x00000007,0x0004003b,0x00000007,0x000000ea, - 0x00000007,0x0004003b,0x0000000d,0x000000eb,0x00000007,0x0004003b,0x000000d2,0x000000ed, - 0x00000007,0x0004003b,0x000000d2,0x000000f6,0x00000007,0x0004003b,0x00000015,0x000000fe, - 0x00000007,0x0004003b,0x00000007,0x00000109,0x00000007,0x0004003b,0x00000015,0x0000010a, - 0x00000007,0x0004003b,0x00000118,0x00000119,0x00000007,0x0004003b,0x00000007,0x00000132, - 0x00000007,0x0004003b,0x00000007,0x00000135,0x00000007,0x0004003b,0x0000000d,0x0000013f, - 0x00000007,0x0004003b,0x0000000d,0x00000157,0x00000007,0x0004003b,0x0000000d,0x00000169, - 0x00000007,0x0004003b,0x0000001a,0x0000016d,0x00000007,0x0004003b,0x00000007,0x00000170, - 0x00000007,0x0004003b,0x00000007,0x00000179,0x00000007,0x0004003b,0x0000000d,0x0000017f, - 0x00000007,0x0004003b,0x0000000d,0x00000198,0x00000007,0x0004003d,0x000000cb,0x000000cf, - 0x000000cd,0x0007004f,0x000000ce,0x000000d0,0x000000cf,0x000000cf,0x00000000,0x00000001, - 0x0004007c,0x00000014,0x000000d1,0x000000d0,0x0003003e,0x000000ca,0x000000d1,0x00050041, - 0x000000d2,0x000000d3,0x000000ca,0x0000002f,0x0004003d,0x00000013,0x000000d4,0x000000d3, - 0x00060041,0x000000d5,0x000000d6,0x00000090,0x00000091,0x0000002f,0x0004003d,0x00000013, - 0x000000d7,0x000000d6,0x000500af,0x00000021,0x000000d8,0x000000d4,0x000000d7,0x000400a8, - 0x00000021,0x000000d9,0x000000d8,0x000300f7,0x000000db,0x00000000,0x000400fa,0x000000d9, - 0x000000da,0x000000db,0x000200f8,0x000000da,0x00050041,0x000000d2,0x000000dc,0x000000ca, - 0x00000035,0x0004003d,0x00000013,0x000000dd,0x000000dc,0x00060041,0x000000d5,0x000000de, - 0x00000090,0x00000091,0x00000035,0x0004003d,0x00000013,0x000000df,0x000000de,0x000500af, - 0x00000021,0x000000e0,0x000000dd,0x000000df,0x000200f9,0x000000db,0x000200f8,0x000000db, - 0x000700f5,0x00000021,0x000000e1,0x000000d8,0x00000005,0x000000e0,0x000000da,0x000300f7, - 0x000000e3,0x00000000,0x000400fa,0x000000e1,0x000000e2,0x000000e3,0x000200f8,0x000000e2, - 0x000100fd,0x000200f8,0x000000e3,0x0004003d,0x00000014,0x000000e7,0x000000ca,0x0003003e, - 0x000000e6,0x000000e7,0x00050039,0x00000006,0x000000e8,0x00000018,0x000000e6,0x0003003e, - 0x000000e5,0x000000e8,0x0003003e,0x000000e9,0x00000020,0x0003003e,0x000000ea,0x00000020, - 0x0003003e,0x000000eb,0x000000ec,0x0003003e,0x000000ed,0x000000ee,0x000200f9,0x000000ef, - 0x000200f8,0x000000ef,0x000400f6,0x000000f1,0x000000f2,0x00000000,0x000200f9,0x000000f3, - 0x000200f8,0x000000f3,0x0004003d,0x00000013,0x000000f4,0x000000ed,0x000500b3,0x00000021, - 0x000000f5,0x000000f4,0x00000091,0x000400fa,0x000000f5,0x000000f0,0x000000f1,0x000200f8, - 0x000000f0,0x0003003e,0x000000f6,0x000000ee,0x000200f9,0x000000f7,0x000200f8,0x000000f7, - 0x000400f6,0x000000f9,0x000000fa,0x00000000,0x000200f9,0x000000fb,0x000200f8,0x000000fb, - 0x0004003d,0x00000013,0x000000fc,0x000000f6,0x000500b3,0x00000021,0x000000fd,0x000000fc, - 0x00000091,0x000400fa,0x000000fd,0x000000f8,0x000000f9,0x000200f8,0x000000f8,0x0004003d, - 0x00000014,0x000000ff,0x000000ca,0x0004003d,0x00000013,0x00000100,0x000000f6,0x0004003d, - 0x00000013,0x00000101,0x000000ed,0x00050050,0x00000014,0x00000102,0x00000100,0x00000101, - 0x00050080,0x00000014,0x00000103,0x000000ff,0x00000102,0x00050041,0x00000092,0x00000104, - 0x00000090,0x00000091,0x0004003d,0x00000014,0x00000105,0x00000104,0x00050050,0x00000014, - 0x00000106,0x00000091,0x00000091,0x00050082,0x00000014,0x00000107,0x00000105,0x00000106, - 0x0008000c,0x00000014,0x00000108,0x00000001,0x0000002d,0x00000103,0x0000008b,0x00000107, - 0x0003003e,0x000000fe,0x00000108,0x0004003d,0x00000014,0x0000010b,0x000000fe,0x0003003e, - 0x0000010a,0x0000010b,0x00050039,0x00000006,0x0000010c,0x00000018,0x0000010a,0x0004003d, - 0x00000006,0x0000010d,0x000000e5,0x00050083,0x00000006,0x0000010e,0x0000010c,0x0000010d, - 0x0006000c,0x00000006,0x0000010f,0x00000001,0x00000004,0x0000010e,0x0004007f,0x00000006, - 0x00000110,0x0000010f,0x0004003d,0x00000006,0x00000112,0x000000e5,0x00050085,0x00000006, - 0x00000113,0x00000111,0x00000112,0x0007000c,0x00000006,0x00000115,0x00000001,0x00000028, - 0x00000113,0x00000114,0x00050088,0x00000006,0x00000116,0x00000110,0x00000115,0x0006000c, - 0x00000006,0x00000117,0x00000001,0x0000001b,0x00000116,0x0003003e,0x00000109,0x00000117, - 0x0004003d,0x00000085,0x0000011b,0x0000011a,0x0004003d,0x00000014,0x0000011c,0x000000fe, - 0x00040064,0x00000084,0x0000011d,0x0000011b,0x0007005f,0x0000008d,0x0000011e,0x0000011d, - 0x0000011c,0x00000002,0x0000008a,0x0003003e,0x00000119,0x0000011e,0x0004003d,0x00000006, - 0x0000011f,0x00000109,0x00050041,0x00000007,0x00000120,0x00000119,0x0000009c,0x0004003d, - 0x00000006,0x00000121,0x00000120,0x00050085,0x00000006,0x00000122,0x0000011f,0x00000121, - 0x0004003d,0x00000006,0x00000123,0x000000e9,0x00050081,0x00000006,0x00000124,0x00000123, - 0x00000122,0x0003003e,0x000000e9,0x00000124,0x0004003d,0x00000006,0x00000125,0x00000109, - 0x0004003d,0x0000008d,0x00000126,0x00000119,0x0008004f,0x0000000c,0x00000127,0x00000126, - 0x00000126,0x00000000,0x00000001,0x00000002,0x0005008e,0x0000000c,0x00000128,0x00000127, - 0x00000125,0x0004003d,0x0000000c,0x00000129,0x000000eb,0x00050081,0x0000000c,0x0000012a, - 0x00000129,0x00000128,0x0003003e,0x000000eb,0x0000012a,0x0004003d,0x00000006,0x0000012b, - 0x00000109,0x0004003d,0x00000006,0x0000012c,0x000000ea,0x00050081,0x00000006,0x0000012d, - 0x0000012c,0x0000012b,0x0003003e,0x000000ea,0x0000012d,0x000200f9,0x000000fa,0x000200f8, - 0x000000fa,0x0004003d,0x00000013,0x0000012e,0x000000f6,0x00050080,0x00000013,0x0000012f, - 0x0000012e,0x00000091,0x0003003e,0x000000f6,0x0000012f,0x000200f9,0x000000f7,0x000200f8, - 0x000000f9,0x000200f9,0x000000f2,0x000200f8,0x000000f2,0x0004003d,0x00000013,0x00000130, - 0x000000ed,0x00050080,0x00000013,0x00000131,0x00000130,0x00000091,0x0003003e,0x000000ed, - 0x00000131,0x000200f9,0x000000ef,0x000200f8,0x000000f1,0x0004003d,0x00000006,0x00000133, - 0x000000ea,0x000500ba,0x00000021,0x00000134,0x00000133,0x00000020,0x000300f7,0x00000137, - 0x00000000,0x000400fa,0x00000134,0x00000136,0x0000013b,0x000200f8,0x00000136,0x0004003d, - 0x00000006,0x00000138,0x000000e9,0x0004003d,0x00000006,0x00000139,0x000000ea,0x00050088, - 0x00000006,0x0000013a,0x00000138,0x00000139,0x0003003e,0x00000135,0x0000013a,0x000200f9, - 0x00000137,0x000200f8,0x0000013b,0x0003003e,0x00000135,0x0000005e,0x000200f9,0x00000137, - 0x000200f8,0x00000137,0x0004003d,0x00000006,0x0000013c,0x00000135,0x0003003e,0x00000132, - 0x0000013c,0x0004003d,0x00000006,0x0000013d,0x000000ea,0x000500ba,0x00000021,0x0000013e, - 0x0000013d,0x00000020,0x000300f7,0x00000141,0x00000000,0x000400fa,0x0000013e,0x00000140, - 0x00000146,0x000200f8,0x00000140,0x0004003d,0x0000000c,0x00000142,0x000000eb,0x0004003d, - 0x00000006,0x00000143,0x000000ea,0x00060050,0x0000000c,0x00000144,0x00000143,0x00000143, - 0x00000143,0x00050088,0x0000000c,0x00000145,0x00000142,0x00000144,0x0003003e,0x0000013f, - 0x00000145,0x000200f9,0x00000141,0x000200f8,0x00000146,0x0003003e,0x0000013f,0x000000ec, - 0x000200f9,0x00000141,0x000200f8,0x00000141,0x0004003d,0x0000000c,0x00000147,0x0000013f, - 0x0003003e,0x000000eb,0x00000147,0x00060041,0x0000009d,0x00000148,0x00000090,0x0000009b, - 0x0000009c,0x0004003d,0x00000006,0x00000149,0x00000148,0x0004006e,0x00000013,0x0000014a, - 0x00000149,0x000500c7,0x00000013,0x0000014b,0x0000014a,0x000000a7,0x000500ab,0x00000021, - 0x0000014c,0x0000014b,0x0000008a,0x000300f7,0x0000014e,0x00000000,0x000400fa,0x0000014c, - 0x0000014d,0x0000014e,0x000200f8,0x0000014d,0x0004003d,0x0000014f,0x00000152,0x00000151, - 0x0004003d,0x00000014,0x00000153,0x000000ca,0x0004003d,0x00000006,0x00000154,0x00000132, - 0x0006000c,0x00000006,0x00000155,0x00000001,0x0000001f,0x00000154,0x00060050,0x0000000c, - 0x00000156,0x00000155,0x00000155,0x00000155,0x0003003e,0x00000157,0x00000156,0x00050039, - 0x0000000e,0x00000158,0x00000011,0x00000157,0x00070050,0x00000159,0x0000015a,0x00000158, - 0x0000002f,0x0000002f,0x0000002f,0x00050063,0x00000152,0x00000153,0x0000015a,0x00002000, - 0x000100fd,0x000200f8,0x0000014e,0x0004003d,0x00000006,0x0000015c,0x00000132,0x000500be, - 0x00000021,0x0000015e,0x0000015c,0x0000015d,0x000300f7,0x00000160,0x00000000,0x000400fa, - 0x0000015e,0x0000015f,0x00000160,0x000200f8,0x0000015f,0x0004003d,0x0000000c,0x00000161, - 0x000000eb,0x00050094,0x00000006,0x00000163,0x00000161,0x00000162,0x000500b8,0x00000021, - 0x00000164,0x00000163,0x00000114,0x000200f9,0x00000160,0x000200f8,0x00000160,0x000700f5, - 0x00000021,0x00000165,0x0000015e,0x0000014e,0x00000164,0x0000015f,0x000300f7,0x00000167, - 0x00000000,0x000400fa,0x00000165,0x00000166,0x00000167,0x000200f8,0x00000166,0x000100fd, - 0x000200f8,0x00000167,0x0004003d,0x0000014f,0x0000016a,0x00000151,0x0004003d,0x00000014, - 0x0000016b,0x000000ca,0x00060062,0x00000159,0x0000016c,0x0000016a,0x0000016b,0x00002000, - 0x00050051,0x0000000e,0x0000016e,0x0000016c,0x00000000,0x0003003e,0x0000016d,0x0000016e, - 0x00050039,0x0000000c,0x0000016f,0x0000001d,0x0000016d,0x0003003e,0x00000169,0x0000016f, - 0x0004003d,0x0000000c,0x00000171,0x00000169,0x0004003d,0x0000000c,0x00000172,0x00000169, - 0x00050085,0x0000000c,0x00000173,0x00000171,0x00000172,0x00050094,0x00000006,0x00000178, - 0x00000173,0x00000177,0x0003003e,0x00000170,0x00000178,0x0004003d,0x00000006,0x0000017a, - 0x00000132,0x0004003d,0x00000006,0x0000017b,0x00000170,0x0008000c,0x00000006,0x0000017c, - 0x00000001,0x00000031,0x00000057,0x0000005e,0x0000017b,0x00050085,0x00000006,0x0000017d, - 0x00000057,0x0000017c,0x0008000c,0x00000006,0x0000017e,0x00000001,0x0000002e,0x0000017a, - 0x0000005e,0x0000017d,0x0003003e,0x00000179,0x0000017e,0x0004003d,0x0000000c,0x00000180, - 0x00000169,0x0004003d,0x0000000c,0x00000181,0x00000169,0x00050085,0x0000000c,0x00000182, - 0x00000180,0x00000181,0x0004003d,0x00000006,0x00000183,0x00000179,0x0005008e,0x0000000c, - 0x00000184,0x00000182,0x00000183,0x0004003d,0x0000000c,0x00000185,0x000000eb,0x0004003d, - 0x0000000c,0x00000186,0x00000169,0x00050085,0x0000000c,0x00000187,0x00000185,0x00000186, - 0x0004003d,0x0000000c,0x00000188,0x00000169,0x00050085,0x0000000c,0x00000189,0x00000187, - 0x00000188,0x00050041,0x0000009d,0x0000018b,0x00000090,0x0000018a,0x0004003d,0x00000006, - 0x0000018c,0x0000018b,0x0005008e,0x0000000c,0x0000018d,0x00000189,0x0000018c,0x0004003d, - 0x00000006,0x0000018e,0x00000179,0x00050083,0x00000006,0x0000018f,0x0000005e,0x0000018e, - 0x00050081,0x00000006,0x00000191,0x0000018f,0x00000190,0x0005008e,0x0000000c,0x00000192, - 0x0000018d,0x00000191,0x00050081,0x0000000c,0x00000193,0x00000184,0x00000192,0x0003003e, - 0x0000017f,0x00000193,0x0004003d,0x0000014f,0x00000194,0x00000151,0x0004003d,0x00000014, - 0x00000195,0x000000ca,0x0004003d,0x0000000c,0x00000196,0x0000017f,0x0006000c,0x0000000c, - 0x00000197,0x00000001,0x0000001f,0x00000196,0x0003003e,0x00000198,0x00000197,0x00050039, - 0x0000000e,0x00000199,0x00000011,0x00000198,0x00070050,0x00000159,0x0000019a,0x00000199, - 0x0000002f,0x0000002f,0x0000002f,0x00050063,0x00000194,0x00000195,0x0000019a,0x00002000, - 0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008,0x00030037, - 0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003b,0x00000007,0x00000023,0x00000007, - 0x0004003d,0x00000006,0x0000001f,0x00000009,0x000500ba,0x00000021,0x00000022,0x0000001f, - 0x00000020,0x000300f7,0x00000025,0x00000000,0x000400fa,0x00000022,0x00000024,0x00000029, - 0x000200f8,0x00000024,0x0004003d,0x00000006,0x00000026,0x00000009,0x0007000c,0x00000006, - 0x00000028,0x00000001,0x00000025,0x00000026,0x00000027,0x0003003e,0x00000023,0x00000028, - 0x000200f9,0x00000025,0x000200f8,0x00000029,0x0003003e,0x00000023,0x00000020,0x000200f9, - 0x00000025,0x000200f8,0x00000025,0x0004003d,0x00000006,0x0000002a,0x00000023,0x000200fe, - 0x0000002a,0x00010038,0x00050036,0x0000000e,0x00000011,0x00000000,0x0000000f,0x00030037, - 0x0000000d,0x00000010,0x000200f8,0x00000012,0x0004003b,0x00000007,0x0000002d,0x00000007, - 0x0004003b,0x00000007,0x0000002e,0x00000007,0x0004003b,0x00000007,0x00000033,0x00000007, - 0x0004003b,0x00000007,0x00000034,0x00000007,0x0004003b,0x00000007,0x00000039,0x00000007, - 0x0004003b,0x00000007,0x0000003a,0x00000007,0x0004003b,0x00000007,0x0000003f,0x00000007, - 0x0004003b,0x00000007,0x00000045,0x00000007,0x0004003b,0x00000007,0x0000004f,0x00000007, - 0x00050041,0x00000007,0x00000030,0x00000010,0x0000002f,0x0004003d,0x00000006,0x00000031, - 0x00000030,0x0003003e,0x0000002e,0x00000031,0x00050039,0x00000006,0x00000032,0x0000000a, - 0x0000002e,0x0003003e,0x0000002d,0x00000032,0x00050041,0x00000007,0x00000036,0x00000010, - 0x00000035,0x0004003d,0x00000006,0x00000037,0x00000036,0x0003003e,0x00000034,0x00000037, - 0x00050039,0x00000006,0x00000038,0x0000000a,0x00000034,0x0003003e,0x00000033,0x00000038, - 0x00050041,0x00000007,0x0000003c,0x00000010,0x0000003b,0x0004003d,0x00000006,0x0000003d, - 0x0000003c,0x0003003e,0x0000003a,0x0000003d,0x00050039,0x00000006,0x0000003e,0x0000000a, - 0x0000003a,0x0003003e,0x00000039,0x0000003e,0x0004003d,0x00000006,0x00000040,0x0000002d, - 0x0004003d,0x00000006,0x00000041,0x00000033,0x0007000c,0x00000006,0x00000042,0x00000001, - 0x00000028,0x00000040,0x00000041,0x0004003d,0x00000006,0x00000043,0x00000039,0x0007000c, - 0x00000006,0x00000044,0x00000001,0x00000028,0x00000042,0x00000043,0x0003003e,0x0000003f, - 0x00000044,0x0004003d,0x00000006,0x00000047,0x0000003f,0x0007000c,0x00000006,0x00000049, - 0x00000001,0x00000028,0x00000047,0x00000048,0x0006000c,0x00000006,0x0000004a,0x00000001, - 0x0000001e,0x00000049,0x0006000c,0x00000006,0x0000004b,0x00000001,0x00000008,0x0000004a, - 0x0007000c,0x00000006,0x0000004c,0x00000001,0x00000028,0x00000046,0x0000004b,0x00050081, - 0x00000006,0x0000004e,0x0000004c,0x0000004d,0x0003003e,0x00000045,0x0000004e,0x0004003d, - 0x00000006,0x00000050,0x00000045,0x00050083,0x00000006,0x00000052,0x00000050,0x00000051, - 0x0006000c,0x00000006,0x00000053,0x00000001,0x0000001d,0x00000052,0x0003003e,0x0000004f, - 0x00000053,0x0004003d,0x00000006,0x00000054,0x0000003f,0x0004003d,0x00000006,0x00000055, - 0x0000004f,0x00050088,0x00000006,0x00000056,0x00000054,0x00000055,0x00050081,0x00000006, - 0x00000058,0x00000056,0x00000057,0x0006000c,0x00000006,0x00000059,0x00000001,0x00000008, - 0x00000058,0x000500be,0x00000021,0x0000005b,0x00000059,0x0000005a,0x000300f7,0x0000005d, - 0x00000000,0x000400fa,0x0000005b,0x0000005c,0x0000005d,0x000200f8,0x0000005c,0x0004003d, - 0x00000006,0x0000005f,0x00000045,0x00050081,0x00000006,0x00000060,0x0000005f,0x0000005e, - 0x0003003e,0x00000045,0x00000060,0x0004003d,0x00000006,0x00000062,0x0000004f,0x00050085, - 0x00000006,0x00000063,0x00000062,0x00000061,0x0003003e,0x0000004f,0x00000063,0x000200f9, - 0x0000005d,0x000200f8,0x0000005d,0x0004003d,0x00000006,0x00000064,0x0000002d,0x0004003d, - 0x00000006,0x00000065,0x0000004f,0x00050088,0x00000006,0x00000066,0x00000064,0x00000065, - 0x00050081,0x00000006,0x00000067,0x00000066,0x00000057,0x0006000c,0x00000006,0x00000068, - 0x00000001,0x00000008,0x00000067,0x0004006d,0x0000000e,0x00000069,0x00000068,0x0004003d, - 0x00000006,0x0000006a,0x00000033,0x0004003d,0x00000006,0x0000006b,0x0000004f,0x00050088, - 0x00000006,0x0000006c,0x0000006a,0x0000006b,0x00050081,0x00000006,0x0000006d,0x0000006c, - 0x00000057,0x0006000c,0x00000006,0x0000006e,0x00000001,0x00000008,0x0000006d,0x0004006d, - 0x0000000e,0x0000006f,0x0000006e,0x000500c4,0x0000000e,0x00000071,0x0000006f,0x00000070, - 0x000500c5,0x0000000e,0x00000072,0x00000069,0x00000071,0x0004003d,0x00000006,0x00000073, - 0x00000039,0x0004003d,0x00000006,0x00000074,0x0000004f,0x00050088,0x00000006,0x00000075, - 0x00000073,0x00000074,0x00050081,0x00000006,0x00000076,0x00000075,0x00000057,0x0006000c, - 0x00000006,0x00000077,0x00000001,0x00000008,0x00000076,0x0004006d,0x0000000e,0x00000078, - 0x00000077,0x000500c4,0x0000000e,0x0000007a,0x00000078,0x00000079,0x000500c5,0x0000000e, - 0x0000007b,0x00000072,0x0000007a,0x0004003d,0x00000006,0x0000007c,0x00000045,0x0004006d, - 0x0000000e,0x0000007d,0x0000007c,0x000500c4,0x0000000e,0x0000007f,0x0000007d,0x0000007e, - 0x000500c5,0x0000000e,0x00000080,0x0000007b,0x0000007f,0x000200fe,0x00000080,0x00010038, - 0x00050036,0x00000006,0x00000018,0x00000000,0x00000016,0x00030037,0x00000015,0x00000017, - 0x000200f8,0x00000019,0x0004003b,0x00000007,0x00000083,0x00000007,0x0004003d,0x00000085, - 0x00000088,0x00000087,0x0004003d,0x00000014,0x00000089,0x00000017,0x00050041,0x00000092, - 0x00000093,0x00000090,0x00000091,0x0004003d,0x00000014,0x00000094,0x00000093,0x00050050, - 0x00000014,0x00000095,0x00000091,0x00000091,0x00050082,0x00000014,0x00000096,0x00000094, - 0x00000095,0x0008000c,0x00000014,0x00000097,0x00000001,0x0000002d,0x00000089,0x0000008b, - 0x00000096,0x00040064,0x00000084,0x00000098,0x00000088,0x0007005f,0x0000008d,0x00000099, - 0x00000098,0x00000097,0x00000002,0x0000008a,0x00050051,0x00000006,0x0000009a,0x00000099, - 0x00000000,0x0003003e,0x00000083,0x0000009a,0x00060041,0x0000009d,0x0000009e,0x00000090, - 0x0000009b,0x0000009c,0x0004003d,0x00000006,0x0000009f,0x0000009e,0x0004006e,0x00000013, - 0x000000a0,0x0000009f,0x000500c7,0x00000013,0x000000a1,0x000000a0,0x00000091,0x000500ab, - 0x00000021,0x000000a2,0x000000a1,0x0000008a,0x000300f7,0x000000a4,0x00000000,0x000400fa, - 0x000000a2,0x000000a3,0x000000a4,0x000200f8,0x000000a3,0x0004003d,0x00000006,0x000000a5, - 0x00000083,0x00050083,0x00000006,0x000000a6,0x0000005e,0x000000a5,0x0003003e,0x00000083, - 0x000000a6,0x000200f9,0x000000a4,0x000200f8,0x000000a4,0x00060041,0x0000009d,0x000000a8, - 0x00000090,0x000000a7,0x00000035,0x0004003d,0x00000006,0x000000a9,0x000000a8,0x0004003d, - 0x00000006,0x000000aa,0x00000083,0x00060041,0x0000009d,0x000000ab,0x00000090,0x000000a7, - 0x0000002f,0x0004003d,0x00000006,0x000000ac,0x000000ab,0x00050083,0x00000006,0x000000ad, - 0x000000aa,0x000000ac,0x0007000c,0x00000006,0x000000af,0x00000001,0x00000028,0x000000ad, - 0x000000ae,0x00050088,0x00000006,0x000000b0,0x000000a9,0x000000af,0x000200fe,0x000000b0, - 0x00010038,0x00050036,0x0000000c,0x0000001d,0x00000000,0x0000001b,0x00030037,0x0000001a, - 0x0000001c,0x000200f8,0x0000001e,0x0004003b,0x00000007,0x000000b3,0x00000007,0x0004003d, - 0x0000000e,0x000000b4,0x0000001c,0x000500c2,0x0000000e,0x000000b5,0x000000b4,0x0000007e, - 0x00040070,0x00000006,0x000000b6,0x000000b5,0x00050083,0x00000006,0x000000b7,0x000000b6, - 0x00000051,0x0006000c,0x00000006,0x000000b8,0x00000001,0x0000001d,0x000000b7,0x0003003e, - 0x000000b3,0x000000b8,0x0004003d,0x0000000e,0x000000b9,0x0000001c,0x000500c7,0x0000000e, - 0x000000bb,0x000000b9,0x000000ba,0x00040070,0x00000006,0x000000bc,0x000000bb,0x0004003d, - 0x0000000e,0x000000bd,0x0000001c,0x000500c2,0x0000000e,0x000000be,0x000000bd,0x00000070, - 0x000500c7,0x0000000e,0x000000bf,0x000000be,0x000000ba,0x00040070,0x00000006,0x000000c0, - 0x000000bf,0x0004003d,0x0000000e,0x000000c1,0x0000001c,0x000500c2,0x0000000e,0x000000c2, - 0x000000c1,0x00000079,0x000500c7,0x0000000e,0x000000c3,0x000000c2,0x000000ba,0x00040070, - 0x00000006,0x000000c4,0x000000c3,0x00060050,0x0000000c,0x000000c5,0x000000bc,0x000000c0, - 0x000000c4,0x0004003d,0x00000006,0x000000c6,0x000000b3,0x0005008e,0x0000000c,0x000000c7, - 0x000000c5,0x000000c6,0x000200fe,0x000000c7,0x00010038 + 0x76283565,0x003b3366,0x00030005,0x00000010,0x00000063,0x00060005,0x00000016,0x6c697665, + 0x6e69665f,0x28657469,0x003b3166,0x00030005,0x00000015,0x00000076,0x00060005,0x0000001a, + 0x6c697665,0x656c635f,0x76286e61,0x003b3366,0x00030005,0x00000019,0x00000063,0x00070005, + 0x00000021,0x74736964,0x65636e61,0x2874615f,0x3b326976,0x00000000,0x00030005,0x00000020, + 0x00000070,0x00070005,0x00000026,0x61706e75,0x725f6b63,0x65396267,0x31752835,0x0000003b, + 0x00030005,0x00000025,0x00000077,0x00030005,0x00000035,0x00000072,0x00040005,0x00000036, + 0x61726170,0x0000006d,0x00030005,0x0000003b,0x00000067,0x00040005,0x0000003c,0x61726170, + 0x0000006d,0x00030005,0x00000041,0x00000062,0x00040005,0x00000042,0x61726170,0x0000006d, + 0x00030005,0x00000047,0x0000006d,0x00030005,0x0000004d,0x00000065,0x00040005,0x00000057, + 0x6c616373,0x00000065,0x00040005,0x00000092,0x61726170,0x0000006d,0x00040005,0x0000009e, + 0x61726170,0x0000006d,0x00040005,0x000000aa,0x61726170,0x0000006d,0x00030005,0x000000b9, + 0x00000064,0x00050005,0x000000bd,0x74706564,0x65745f68,0x00000078,0x00040005,0x000000c4, + 0x68737550,0x00000000,0x00040006,0x000000c4,0x00000000,0x00766e69,0x00050006,0x000000c4, + 0x00000001,0x657a6973,0x00000000,0x00040006,0x000000c4,0x00000002,0x006d6163,0x00040006, + 0x000000c4,0x00000003,0x0000006b,0x00070006,0x000000c4,0x00000004,0x6e756f62,0x735f6563, + 0x6e657274,0x00687467,0x00030005,0x000000c6,0x00006370,0x00040005,0x000000e9,0x6c616373, + 0x00000065,0x00030005,0x00000100,0x00000063,0x00080005,0x00000103,0x475f6c67,0x61626f6c, + 0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x0000011b,0x0000007a,0x00040005, + 0x0000011c,0x61726170,0x0000006d,0x00030005,0x0000011f,0x006d7573,0x00040005,0x00000120, + 0x67696577,0x00007468,0x00040005,0x00000121,0x6e756f62,0x00006563,0x00030005,0x00000123, + 0x00000079,0x00030005,0x0000012c,0x00000078,0x00030005,0x00000134,0x00000071,0x00030005, + 0x0000013f,0x00000077,0x00040005,0x00000140,0x61726170,0x0000006d,0x00030005,0x0000014f, + 0x00000061,0x00040005,0x00000150,0x745f6f61,0x00007865,0x00040005,0x00000155,0x61726170, + 0x0000006d,0x00040005,0x0000015d,0x61726170,0x0000006d,0x00040005,0x0000016c,0x61726170, + 0x0000006d,0x00030005,0x0000017a,0x00006f61,0x00040005,0x00000185,0x61726170,0x0000006d, + 0x00030005,0x0000019f,0x00747364,0x00040005,0x000001a5,0x61726170,0x0000006d,0x00030005, + 0x000001b7,0x00000065,0x00040005,0x000001bb,0x61726170,0x0000006d,0x00040005,0x000001be, + 0x616d756c,0x00000000,0x00040005,0x000001c7,0x7470656b,0x00000000,0x00030005,0x000001cd, + 0x006e696c,0x00040005,0x000001e2,0x61726170,0x0000006d,0x00040005,0x000001ec,0x61726170, + 0x0000006d,0x00040005,0x000001f6,0x61726170,0x0000006d,0x00040047,0x000000bd,0x00000021, + 0x00000001,0x00040047,0x000000bd,0x00000022,0x00000000,0x00030047,0x000000c4,0x00000002, + 0x00050048,0x000000c4,0x00000000,0x00000023,0x00000000,0x00050048,0x000000c4,0x00000001, + 0x00000023,0x00000008,0x00050048,0x000000c4,0x00000002,0x00000023,0x00000010,0x00050048, + 0x000000c4,0x00000003,0x00000023,0x00000020,0x00050048,0x000000c4,0x00000004,0x00000023, + 0x00000030,0x00040047,0x00000103,0x0000000b,0x0000001c,0x00040047,0x00000150,0x00000021, + 0x00000000,0x00040047,0x00000150,0x00000022,0x00000000,0x00040047,0x0000019f,0x00000021, + 0x00000002,0x00040047,0x0000019f,0x00000022,0x00000000,0x00040047,0x000001fa,0x0000000b, + 0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, + 0x00000020,0x00040020,0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006, + 0x00000007,0x00040017,0x0000000c,0x00000006,0x00000003,0x00040020,0x0000000d,0x00000007, + 0x0000000c,0x00040015,0x0000000e,0x00000020,0x00000000,0x00040021,0x0000000f,0x0000000e, + 0x0000000d,0x00020014,0x00000013,0x00040021,0x00000014,0x00000013,0x00000007,0x00040021, + 0x00000018,0x0000000c,0x0000000d,0x00040015,0x0000001c,0x00000020,0x00000001,0x00040017, + 0x0000001d,0x0000001c,0x00000002,0x00040020,0x0000001e,0x00000007,0x0000001d,0x00040021, + 0x0000001f,0x00000006,0x0000001e,0x00040020,0x00000023,0x00000007,0x0000000e,0x00040021, + 0x00000024,0x0000000c,0x00000023,0x0004002b,0x00000006,0x00000029,0x00000000,0x0004002b, + 0x00000006,0x0000002f,0x477f8000,0x0004002b,0x0000000e,0x00000037,0x00000000,0x0004002b, + 0x0000000e,0x0000003d,0x00000001,0x0004002b,0x0000000e,0x00000043,0x00000002,0x0004002b, + 0x00000006,0x0000004e,0xc1800000,0x0004002b,0x00000006,0x00000050,0x0da24260,0x0004002b, + 0x00000006,0x00000055,0x41800000,0x0004002b,0x00000006,0x00000059,0x41c00000,0x0004002b, + 0x00000006,0x0000005f,0x3f000000,0x0004002b,0x00000006,0x00000062,0x44000000,0x0004002b, + 0x00000006,0x00000066,0x3f800000,0x0004002b,0x00000006,0x00000069,0x40000000,0x0004002b, + 0x0000001c,0x00000078,0x00000009,0x0004002b,0x0000001c,0x00000081,0x00000012,0x0004002b, + 0x0000001c,0x00000086,0x0000001b,0x0004002b,0x0000000e,0x0000008d,0x7f800000,0x00090019, + 0x000000ba,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000, + 0x0003001b,0x000000bb,0x000000ba,0x00040020,0x000000bc,0x00000000,0x000000bb,0x0004003b, + 0x000000bc,0x000000bd,0x00000000,0x0004002b,0x0000001c,0x000000c0,0x00000000,0x0005002c, + 0x0000001d,0x000000c1,0x000000c0,0x000000c0,0x00040017,0x000000c2,0x00000006,0x00000002, + 0x00040017,0x000000c3,0x00000006,0x00000004,0x0007001e,0x000000c4,0x000000c2,0x0000001d, + 0x000000c3,0x000000c3,0x00000006,0x00040020,0x000000c5,0x00000009,0x000000c4,0x0004003b, + 0x000000c5,0x000000c6,0x00000009,0x0004002b,0x0000001c,0x000000c7,0x00000001,0x00040020, + 0x000000c8,0x00000009,0x0000001d,0x0004002b,0x0000001c,0x000000d1,0x00000003,0x0004002b, + 0x0000000e,0x000000d2,0x00000003,0x00040020,0x000000d3,0x00000009,0x00000006,0x0004002b, + 0x0000001c,0x000000dd,0x00000002,0x0004002b,0x00000006,0x000000e4,0x33d6bf95,0x0004002b, + 0x0000000e,0x000000f0,0x000001ff,0x00040017,0x00000101,0x0000000e,0x00000003,0x00040020, + 0x00000102,0x00000001,0x00000101,0x0004003b,0x00000102,0x00000103,0x00000001,0x00040017, + 0x00000104,0x0000000e,0x00000002,0x00040020,0x00000108,0x00000007,0x0000001c,0x00040020, + 0x0000010b,0x00000009,0x0000001c,0x0006002c,0x0000000c,0x00000122,0x00000029,0x00000029, + 0x00000029,0x0004002b,0x0000001c,0x00000124,0xfffffffe,0x0004002b,0x00000006,0x00000147, + 0x3cf5c28f,0x0004002b,0x00000006,0x0000014a,0x38d1b717,0x00040020,0x0000014e,0x00000007, + 0x000000c3,0x0004003b,0x000000bc,0x00000150,0x00000000,0x00090019,0x0000019d,0x0000000e, + 0x00000001,0x00000000,0x00000000,0x00000000,0x00000002,0x00000021,0x00040020,0x0000019e, + 0x00000000,0x0000019d,0x0004003b,0x0000019e,0x0000019f,0x00000000,0x00040017,0x000001a7, + 0x0000000e,0x00000004,0x0004002b,0x00000006,0x000001ab,0x3f7fbe77,0x0006002c,0x0000000c, + 0x000001b0,0x00000066,0x00000066,0x00000066,0x0004002b,0x00000006,0x000001c2,0x3e59b3d0, + 0x0004002b,0x00000006,0x000001c3,0x3f371759,0x0004002b,0x00000006,0x000001c4,0x3d93dd98, + 0x0006002c,0x0000000c,0x000001c5,0x000001c2,0x000001c3,0x000001c4,0x0004002b,0x0000001c, + 0x000001d8,0x00000004,0x0004002b,0x00000006,0x000001de,0x3e800000,0x0004002b,0x0000000e, + 0x000001f9,0x00000008,0x0006002c,0x00000101,0x000001fa,0x000001f9,0x000001f9,0x0000003d, + 0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b, + 0x0000001e,0x00000100,0x00000007,0x0004003b,0x00000007,0x0000011b,0x00000007,0x0004003b, + 0x0000001e,0x0000011c,0x00000007,0x0004003b,0x00000007,0x0000011f,0x00000007,0x0004003b, + 0x00000007,0x00000120,0x00000007,0x0004003b,0x0000000d,0x00000121,0x00000007,0x0004003b, + 0x00000108,0x00000123,0x00000007,0x0004003b,0x00000108,0x0000012c,0x00000007,0x0004003b, + 0x0000001e,0x00000134,0x00000007,0x0004003b,0x00000007,0x0000013f,0x00000007,0x0004003b, + 0x0000001e,0x00000140,0x00000007,0x0004003b,0x0000014e,0x0000014f,0x00000007,0x0004003b, + 0x00000007,0x00000155,0x00000007,0x0004003b,0x00000007,0x0000015d,0x00000007,0x0004003b, + 0x00000007,0x00000161,0x00000007,0x0004003b,0x0000000d,0x0000016c,0x00000007,0x0004003b, + 0x00000007,0x0000017a,0x00000007,0x0004003b,0x00000007,0x0000017d,0x00000007,0x0004003b, + 0x00000007,0x00000185,0x00000007,0x0004003b,0x0000000d,0x0000018d,0x00000007,0x0004003b, + 0x0000000d,0x000001a5,0x00000007,0x0004003b,0x0000000d,0x000001b7,0x00000007,0x0004003b, + 0x00000023,0x000001bb,0x00000007,0x0004003b,0x00000007,0x000001be,0x00000007,0x0004003b, + 0x00000007,0x000001c7,0x00000007,0x0004003b,0x0000000d,0x000001cd,0x00000007,0x0004003b, + 0x0000000d,0x000001e2,0x00000007,0x0004003b,0x00000007,0x000001ec,0x00000007,0x0004003b, + 0x0000000d,0x000001f6,0x00000007,0x0004003d,0x00000101,0x00000105,0x00000103,0x0007004f, + 0x00000104,0x00000106,0x00000105,0x00000105,0x00000000,0x00000001,0x0004007c,0x0000001d, + 0x00000107,0x00000106,0x0003003e,0x00000100,0x00000107,0x00050041,0x00000108,0x00000109, + 0x00000100,0x00000037,0x0004003d,0x0000001c,0x0000010a,0x00000109,0x00060041,0x0000010b, + 0x0000010c,0x000000c6,0x000000c7,0x00000037,0x0004003d,0x0000001c,0x0000010d,0x0000010c, + 0x000500af,0x00000013,0x0000010e,0x0000010a,0x0000010d,0x000400a8,0x00000013,0x0000010f, + 0x0000010e,0x000300f7,0x00000111,0x00000000,0x000400fa,0x0000010f,0x00000110,0x00000111, + 0x000200f8,0x00000110,0x00050041,0x00000108,0x00000112,0x00000100,0x0000003d,0x0004003d, + 0x0000001c,0x00000113,0x00000112,0x00060041,0x0000010b,0x00000114,0x000000c6,0x000000c7, + 0x0000003d,0x0004003d,0x0000001c,0x00000115,0x00000114,0x000500af,0x00000013,0x00000116, + 0x00000113,0x00000115,0x000200f9,0x00000111,0x000200f8,0x00000111,0x000700f5,0x00000013, + 0x00000117,0x0000010e,0x00000005,0x00000116,0x00000110,0x000300f7,0x00000119,0x00000000, + 0x000400fa,0x00000117,0x00000118,0x00000119,0x000200f8,0x00000118,0x000100fd,0x000200f8, + 0x00000119,0x0004003d,0x0000001d,0x0000011d,0x00000100,0x0003003e,0x0000011c,0x0000011d, + 0x00050039,0x00000006,0x0000011e,0x00000021,0x0000011c,0x0003003e,0x0000011b,0x0000011e, + 0x0003003e,0x0000011f,0x00000029,0x0003003e,0x00000120,0x00000029,0x0003003e,0x00000121, + 0x00000122,0x0003003e,0x00000123,0x00000124,0x000200f9,0x00000125,0x000200f8,0x00000125, + 0x000400f6,0x00000127,0x00000128,0x00000000,0x000200f9,0x00000129,0x000200f8,0x00000129, + 0x0004003d,0x0000001c,0x0000012a,0x00000123,0x000500b3,0x00000013,0x0000012b,0x0000012a, + 0x000000c7,0x000400fa,0x0000012b,0x00000126,0x00000127,0x000200f8,0x00000126,0x0003003e, + 0x0000012c,0x00000124,0x000200f9,0x0000012d,0x000200f8,0x0000012d,0x000400f6,0x0000012f, + 0x00000130,0x00000000,0x000200f9,0x00000131,0x000200f8,0x00000131,0x0004003d,0x0000001c, + 0x00000132,0x0000012c,0x000500b3,0x00000013,0x00000133,0x00000132,0x000000c7,0x000400fa, + 0x00000133,0x0000012e,0x0000012f,0x000200f8,0x0000012e,0x0004003d,0x0000001d,0x00000135, + 0x00000100,0x0004003d,0x0000001c,0x00000136,0x0000012c,0x0004003d,0x0000001c,0x00000137, + 0x00000123,0x00050050,0x0000001d,0x00000138,0x00000136,0x00000137,0x00050080,0x0000001d, + 0x00000139,0x00000135,0x00000138,0x00050041,0x000000c8,0x0000013a,0x000000c6,0x000000c7, + 0x0004003d,0x0000001d,0x0000013b,0x0000013a,0x00050050,0x0000001d,0x0000013c,0x000000c7, + 0x000000c7,0x00050082,0x0000001d,0x0000013d,0x0000013b,0x0000013c,0x0008000c,0x0000001d, + 0x0000013e,0x00000001,0x0000002d,0x00000139,0x000000c1,0x0000013d,0x0003003e,0x00000134, + 0x0000013e,0x0004003d,0x0000001d,0x00000141,0x00000134,0x0003003e,0x00000140,0x00000141, + 0x00050039,0x00000006,0x00000142,0x00000021,0x00000140,0x0004003d,0x00000006,0x00000143, + 0x0000011b,0x00050083,0x00000006,0x00000144,0x00000142,0x00000143,0x0006000c,0x00000006, + 0x00000145,0x00000001,0x00000004,0x00000144,0x0004007f,0x00000006,0x00000146,0x00000145, + 0x0004003d,0x00000006,0x00000148,0x0000011b,0x00050085,0x00000006,0x00000149,0x00000147, + 0x00000148,0x0007000c,0x00000006,0x0000014b,0x00000001,0x00000028,0x00000149,0x0000014a, + 0x00050088,0x00000006,0x0000014c,0x00000146,0x0000014b,0x0006000c,0x00000006,0x0000014d, + 0x00000001,0x0000001b,0x0000014c,0x0003003e,0x0000013f,0x0000014d,0x0004003d,0x000000bb, + 0x00000151,0x00000150,0x0004003d,0x0000001d,0x00000152,0x00000134,0x00040064,0x000000ba, + 0x00000153,0x00000151,0x0007005f,0x000000c3,0x00000154,0x00000153,0x00000152,0x00000002, + 0x000000c0,0x0003003e,0x0000014f,0x00000154,0x0004003d,0x00000006,0x00000156,0x0000013f, + 0x0003003e,0x00000155,0x00000156,0x00050039,0x00000013,0x00000157,0x00000016,0x00000155, + 0x000400a8,0x00000013,0x00000158,0x00000157,0x000300f7,0x0000015a,0x00000000,0x000400fa, + 0x00000158,0x00000159,0x0000015a,0x000200f8,0x00000159,0x000200f9,0x00000130,0x000200f8, + 0x0000015a,0x0004003d,0x00000006,0x0000015c,0x0000013f,0x00050041,0x00000007,0x0000015e, + 0x0000014f,0x000000d2,0x0004003d,0x00000006,0x0000015f,0x0000015e,0x0003003e,0x0000015d, + 0x0000015f,0x00050039,0x00000013,0x00000160,0x00000016,0x0000015d,0x000300f7,0x00000163, + 0x00000000,0x000400fa,0x00000160,0x00000162,0x00000166,0x000200f8,0x00000162,0x00050041, + 0x00000007,0x00000164,0x0000014f,0x000000d2,0x0004003d,0x00000006,0x00000165,0x00000164, + 0x0003003e,0x00000161,0x00000165,0x000200f9,0x00000163,0x000200f8,0x00000166,0x0003003e, + 0x00000161,0x00000066,0x000200f9,0x00000163,0x000200f8,0x00000163,0x0004003d,0x00000006, + 0x00000167,0x00000161,0x00050085,0x00000006,0x00000168,0x0000015c,0x00000167,0x0004003d, + 0x00000006,0x00000169,0x0000011f,0x00050081,0x00000006,0x0000016a,0x00000169,0x00000168, + 0x0003003e,0x0000011f,0x0000016a,0x0004003d,0x00000006,0x0000016b,0x0000013f,0x0004003d, + 0x000000c3,0x0000016d,0x0000014f,0x0008004f,0x0000000c,0x0000016e,0x0000016d,0x0000016d, + 0x00000000,0x00000001,0x00000002,0x0003003e,0x0000016c,0x0000016e,0x00050039,0x0000000c, + 0x0000016f,0x0000001a,0x0000016c,0x0005008e,0x0000000c,0x00000170,0x0000016f,0x0000016b, + 0x0004003d,0x0000000c,0x00000171,0x00000121,0x00050081,0x0000000c,0x00000172,0x00000171, + 0x00000170,0x0003003e,0x00000121,0x00000172,0x0004003d,0x00000006,0x00000173,0x0000013f, + 0x0004003d,0x00000006,0x00000174,0x00000120,0x00050081,0x00000006,0x00000175,0x00000174, + 0x00000173,0x0003003e,0x00000120,0x00000175,0x000200f9,0x00000130,0x000200f8,0x00000130, + 0x0004003d,0x0000001c,0x00000176,0x0000012c,0x00050080,0x0000001c,0x00000177,0x00000176, + 0x000000c7,0x0003003e,0x0000012c,0x00000177,0x000200f9,0x0000012d,0x000200f8,0x0000012f, + 0x000200f9,0x00000128,0x000200f8,0x00000128,0x0004003d,0x0000001c,0x00000178,0x00000123, + 0x00050080,0x0000001c,0x00000179,0x00000178,0x000000c7,0x0003003e,0x00000123,0x00000179, + 0x000200f9,0x00000125,0x000200f8,0x00000127,0x0004003d,0x00000006,0x0000017b,0x00000120, + 0x000500ba,0x00000013,0x0000017c,0x0000017b,0x00000029,0x000300f7,0x0000017f,0x00000000, + 0x000400fa,0x0000017c,0x0000017e,0x00000183,0x000200f8,0x0000017e,0x0004003d,0x00000006, + 0x00000180,0x0000011f,0x0004003d,0x00000006,0x00000181,0x00000120,0x00050088,0x00000006, + 0x00000182,0x00000180,0x00000181,0x0003003e,0x0000017d,0x00000182,0x000200f9,0x0000017f, + 0x000200f8,0x00000183,0x0003003e,0x0000017d,0x00000066,0x000200f9,0x0000017f,0x000200f8, + 0x0000017f,0x0004003d,0x00000006,0x00000184,0x0000017d,0x0003003e,0x0000017a,0x00000184, + 0x0004003d,0x00000006,0x00000186,0x0000017a,0x0003003e,0x00000185,0x00000186,0x00050039, + 0x00000013,0x00000187,0x00000016,0x00000185,0x000400a8,0x00000013,0x00000188,0x00000187, + 0x000300f7,0x0000018a,0x00000000,0x000400fa,0x00000188,0x00000189,0x0000018a,0x000200f8, + 0x00000189,0x0003003e,0x0000017a,0x00000066,0x000200f9,0x0000018a,0x000200f8,0x0000018a, + 0x0004003d,0x00000006,0x0000018b,0x00000120,0x000500ba,0x00000013,0x0000018c,0x0000018b, + 0x00000029,0x000300f7,0x0000018f,0x00000000,0x000400fa,0x0000018c,0x0000018e,0x00000194, + 0x000200f8,0x0000018e,0x0004003d,0x0000000c,0x00000190,0x00000121,0x0004003d,0x00000006, + 0x00000191,0x00000120,0x00060050,0x0000000c,0x00000192,0x00000191,0x00000191,0x00000191, + 0x00050088,0x0000000c,0x00000193,0x00000190,0x00000192,0x0003003e,0x0000018d,0x00000193, + 0x000200f9,0x0000018f,0x000200f8,0x00000194,0x0003003e,0x0000018d,0x00000122,0x000200f9, + 0x0000018f,0x000200f8,0x0000018f,0x0004003d,0x0000000c,0x00000195,0x0000018d,0x0003003e, + 0x00000121,0x00000195,0x00060041,0x000000d3,0x00000196,0x000000c6,0x000000d1,0x000000d2, + 0x0004003d,0x00000006,0x00000197,0x00000196,0x0004006e,0x0000001c,0x00000198,0x00000197, + 0x000500c7,0x0000001c,0x00000199,0x00000198,0x000000dd,0x000500ab,0x00000013,0x0000019a, + 0x00000199,0x000000c0,0x000300f7,0x0000019c,0x00000000,0x000400fa,0x0000019a,0x0000019b, + 0x0000019c,0x000200f8,0x0000019b,0x0004003d,0x0000019d,0x000001a0,0x0000019f,0x0004003d, + 0x0000001d,0x000001a1,0x00000100,0x0004003d,0x00000006,0x000001a2,0x0000017a,0x0006000c, + 0x00000006,0x000001a3,0x00000001,0x0000001f,0x000001a2,0x00060050,0x0000000c,0x000001a4, + 0x000001a3,0x000001a3,0x000001a3,0x0003003e,0x000001a5,0x000001a4,0x00050039,0x0000000e, + 0x000001a6,0x00000011,0x000001a5,0x00070050,0x000001a7,0x000001a8,0x000001a6,0x00000037, + 0x00000037,0x00000037,0x00050063,0x000001a0,0x000001a1,0x000001a8,0x00002000,0x000100fd, + 0x000200f8,0x0000019c,0x0004003d,0x00000006,0x000001aa,0x0000017a,0x000500be,0x00000013, + 0x000001ac,0x000001aa,0x000001ab,0x000300f7,0x000001ae,0x00000000,0x000400fa,0x000001ac, + 0x000001ad,0x000001ae,0x000200f8,0x000001ad,0x0004003d,0x0000000c,0x000001af,0x00000121, + 0x00050094,0x00000006,0x000001b1,0x000001af,0x000001b0,0x000500b8,0x00000013,0x000001b2, + 0x000001b1,0x0000014a,0x000200f9,0x000001ae,0x000200f8,0x000001ae,0x000700f5,0x00000013, + 0x000001b3,0x000001ac,0x0000019c,0x000001b2,0x000001ad,0x000300f7,0x000001b5,0x00000000, + 0x000400fa,0x000001b3,0x000001b4,0x000001b5,0x000200f8,0x000001b4,0x000100fd,0x000200f8, + 0x000001b5,0x0004003d,0x0000019d,0x000001b8,0x0000019f,0x0004003d,0x0000001d,0x000001b9, + 0x00000100,0x00060062,0x000001a7,0x000001ba,0x000001b8,0x000001b9,0x00002000,0x00050051, + 0x0000000e,0x000001bc,0x000001ba,0x00000000,0x0003003e,0x000001bb,0x000001bc,0x00050039, + 0x0000000c,0x000001bd,0x00000026,0x000001bb,0x0003003e,0x000001b7,0x000001bd,0x0004003d, + 0x0000000c,0x000001bf,0x000001b7,0x0004003d,0x0000000c,0x000001c0,0x000001b7,0x00050085, + 0x0000000c,0x000001c1,0x000001bf,0x000001c0,0x00050094,0x00000006,0x000001c6,0x000001c1, + 0x000001c5,0x0003003e,0x000001be,0x000001c6,0x0004003d,0x00000006,0x000001c8,0x0000017a, + 0x0004003d,0x00000006,0x000001c9,0x000001be,0x0008000c,0x00000006,0x000001ca,0x00000001, + 0x00000031,0x0000005f,0x00000066,0x000001c9,0x00050085,0x00000006,0x000001cb,0x0000005f, + 0x000001ca,0x0008000c,0x00000006,0x000001cc,0x00000001,0x0000002e,0x000001c8,0x00000066, + 0x000001cb,0x0003003e,0x000001c7,0x000001cc,0x0004003d,0x0000000c,0x000001ce,0x000001b7, + 0x0004003d,0x0000000c,0x000001cf,0x000001b7,0x00050085,0x0000000c,0x000001d0,0x000001ce, + 0x000001cf,0x0004003d,0x00000006,0x000001d1,0x000001c7,0x0005008e,0x0000000c,0x000001d2, + 0x000001d0,0x000001d1,0x0004003d,0x0000000c,0x000001d3,0x00000121,0x0004003d,0x0000000c, + 0x000001d4,0x000001b7,0x00050085,0x0000000c,0x000001d5,0x000001d3,0x000001d4,0x0004003d, + 0x0000000c,0x000001d6,0x000001b7,0x00050085,0x0000000c,0x000001d7,0x000001d5,0x000001d6, + 0x00050041,0x000000d3,0x000001d9,0x000000c6,0x000001d8,0x0004003d,0x00000006,0x000001da, + 0x000001d9,0x0005008e,0x0000000c,0x000001db,0x000001d7,0x000001da,0x0004003d,0x00000006, + 0x000001dc,0x000001c7,0x00050083,0x00000006,0x000001dd,0x00000066,0x000001dc,0x00050081, + 0x00000006,0x000001df,0x000001dd,0x000001de,0x0005008e,0x0000000c,0x000001e0,0x000001db, + 0x000001df,0x00050081,0x0000000c,0x000001e1,0x000001d2,0x000001e0,0x0003003e,0x000001e2, + 0x000001e1,0x00050039,0x0000000c,0x000001e3,0x0000001a,0x000001e2,0x0003003e,0x000001cd, + 0x000001e3,0x00050041,0x00000007,0x000001e4,0x000001cd,0x00000037,0x0004003d,0x00000006, + 0x000001e5,0x000001e4,0x00050041,0x00000007,0x000001e6,0x000001cd,0x0000003d,0x0004003d, + 0x00000006,0x000001e7,0x000001e6,0x00050081,0x00000006,0x000001e8,0x000001e5,0x000001e7, + 0x00050041,0x00000007,0x000001e9,0x000001cd,0x00000043,0x0004003d,0x00000006,0x000001ea, + 0x000001e9,0x00050081,0x00000006,0x000001eb,0x000001e8,0x000001ea,0x0003003e,0x000001ec, + 0x000001eb,0x00050039,0x00000013,0x000001ed,0x00000016,0x000001ec,0x000400a8,0x00000013, + 0x000001ee,0x000001ed,0x000300f7,0x000001f0,0x00000000,0x000400fa,0x000001ee,0x000001ef, + 0x000001f0,0x000200f8,0x000001ef,0x000100fd,0x000200f8,0x000001f0,0x0004003d,0x0000019d, + 0x000001f2,0x0000019f,0x0004003d,0x0000001d,0x000001f3,0x00000100,0x0004003d,0x0000000c, + 0x000001f4,0x000001cd,0x0006000c,0x0000000c,0x000001f5,0x00000001,0x0000001f,0x000001f4, + 0x0003003e,0x000001f6,0x000001f5,0x00050039,0x0000000e,0x000001f7,0x00000011,0x000001f6, + 0x00070050,0x000001a7,0x000001f8,0x000001f7,0x00000037,0x00000037,0x00000037,0x00050063, + 0x000001f2,0x000001f3,0x000001f8,0x00002000,0x000100fd,0x00010038,0x00050036,0x00000006, + 0x0000000a,0x00000000,0x00000008,0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b, + 0x0004003b,0x00000007,0x0000002b,0x00000007,0x0004003d,0x00000006,0x00000028,0x00000009, + 0x000500ba,0x00000013,0x0000002a,0x00000028,0x00000029,0x000300f7,0x0000002d,0x00000000, + 0x000400fa,0x0000002a,0x0000002c,0x00000031,0x000200f8,0x0000002c,0x0004003d,0x00000006, + 0x0000002e,0x00000009,0x0007000c,0x00000006,0x00000030,0x00000001,0x00000025,0x0000002e, + 0x0000002f,0x0003003e,0x0000002b,0x00000030,0x000200f9,0x0000002d,0x000200f8,0x00000031, + 0x0003003e,0x0000002b,0x00000029,0x000200f9,0x0000002d,0x000200f8,0x0000002d,0x0004003d, + 0x00000006,0x00000032,0x0000002b,0x000200fe,0x00000032,0x00010038,0x00050036,0x0000000e, + 0x00000011,0x00000000,0x0000000f,0x00030037,0x0000000d,0x00000010,0x000200f8,0x00000012, + 0x0004003b,0x00000007,0x00000035,0x00000007,0x0004003b,0x00000007,0x00000036,0x00000007, + 0x0004003b,0x00000007,0x0000003b,0x00000007,0x0004003b,0x00000007,0x0000003c,0x00000007, + 0x0004003b,0x00000007,0x00000041,0x00000007,0x0004003b,0x00000007,0x00000042,0x00000007, + 0x0004003b,0x00000007,0x00000047,0x00000007,0x0004003b,0x00000007,0x0000004d,0x00000007, + 0x0004003b,0x00000007,0x00000057,0x00000007,0x00050041,0x00000007,0x00000038,0x00000010, + 0x00000037,0x0004003d,0x00000006,0x00000039,0x00000038,0x0003003e,0x00000036,0x00000039, + 0x00050039,0x00000006,0x0000003a,0x0000000a,0x00000036,0x0003003e,0x00000035,0x0000003a, + 0x00050041,0x00000007,0x0000003e,0x00000010,0x0000003d,0x0004003d,0x00000006,0x0000003f, + 0x0000003e,0x0003003e,0x0000003c,0x0000003f,0x00050039,0x00000006,0x00000040,0x0000000a, + 0x0000003c,0x0003003e,0x0000003b,0x00000040,0x00050041,0x00000007,0x00000044,0x00000010, + 0x00000043,0x0004003d,0x00000006,0x00000045,0x00000044,0x0003003e,0x00000042,0x00000045, + 0x00050039,0x00000006,0x00000046,0x0000000a,0x00000042,0x0003003e,0x00000041,0x00000046, + 0x0004003d,0x00000006,0x00000048,0x00000035,0x0004003d,0x00000006,0x00000049,0x0000003b, + 0x0007000c,0x00000006,0x0000004a,0x00000001,0x00000028,0x00000048,0x00000049,0x0004003d, + 0x00000006,0x0000004b,0x00000041,0x0007000c,0x00000006,0x0000004c,0x00000001,0x00000028, + 0x0000004a,0x0000004b,0x0003003e,0x00000047,0x0000004c,0x0004003d,0x00000006,0x0000004f, + 0x00000047,0x0007000c,0x00000006,0x00000051,0x00000001,0x00000028,0x0000004f,0x00000050, + 0x0006000c,0x00000006,0x00000052,0x00000001,0x0000001e,0x00000051,0x0006000c,0x00000006, + 0x00000053,0x00000001,0x00000008,0x00000052,0x0007000c,0x00000006,0x00000054,0x00000001, + 0x00000028,0x0000004e,0x00000053,0x00050081,0x00000006,0x00000056,0x00000054,0x00000055, + 0x0003003e,0x0000004d,0x00000056,0x0004003d,0x00000006,0x00000058,0x0000004d,0x00050083, + 0x00000006,0x0000005a,0x00000058,0x00000059,0x0006000c,0x00000006,0x0000005b,0x00000001, + 0x0000001d,0x0000005a,0x0003003e,0x00000057,0x0000005b,0x0004003d,0x00000006,0x0000005c, + 0x00000047,0x0004003d,0x00000006,0x0000005d,0x00000057,0x00050088,0x00000006,0x0000005e, + 0x0000005c,0x0000005d,0x00050081,0x00000006,0x00000060,0x0000005e,0x0000005f,0x0006000c, + 0x00000006,0x00000061,0x00000001,0x00000008,0x00000060,0x000500be,0x00000013,0x00000063, + 0x00000061,0x00000062,0x000300f7,0x00000065,0x00000000,0x000400fa,0x00000063,0x00000064, + 0x00000065,0x000200f8,0x00000064,0x0004003d,0x00000006,0x00000067,0x0000004d,0x00050081, + 0x00000006,0x00000068,0x00000067,0x00000066,0x0003003e,0x0000004d,0x00000068,0x0004003d, + 0x00000006,0x0000006a,0x00000057,0x00050085,0x00000006,0x0000006b,0x0000006a,0x00000069, + 0x0003003e,0x00000057,0x0000006b,0x000200f9,0x00000065,0x000200f8,0x00000065,0x0004003d, + 0x00000006,0x0000006c,0x00000035,0x0004003d,0x00000006,0x0000006d,0x00000057,0x00050088, + 0x00000006,0x0000006e,0x0000006c,0x0000006d,0x00050081,0x00000006,0x0000006f,0x0000006e, + 0x0000005f,0x0006000c,0x00000006,0x00000070,0x00000001,0x00000008,0x0000006f,0x0004006d, + 0x0000000e,0x00000071,0x00000070,0x0004003d,0x00000006,0x00000072,0x0000003b,0x0004003d, + 0x00000006,0x00000073,0x00000057,0x00050088,0x00000006,0x00000074,0x00000072,0x00000073, + 0x00050081,0x00000006,0x00000075,0x00000074,0x0000005f,0x0006000c,0x00000006,0x00000076, + 0x00000001,0x00000008,0x00000075,0x0004006d,0x0000000e,0x00000077,0x00000076,0x000500c4, + 0x0000000e,0x00000079,0x00000077,0x00000078,0x000500c5,0x0000000e,0x0000007a,0x00000071, + 0x00000079,0x0004003d,0x00000006,0x0000007b,0x00000041,0x0004003d,0x00000006,0x0000007c, + 0x00000057,0x00050088,0x00000006,0x0000007d,0x0000007b,0x0000007c,0x00050081,0x00000006, + 0x0000007e,0x0000007d,0x0000005f,0x0006000c,0x00000006,0x0000007f,0x00000001,0x00000008, + 0x0000007e,0x0004006d,0x0000000e,0x00000080,0x0000007f,0x000500c4,0x0000000e,0x00000082, + 0x00000080,0x00000081,0x000500c5,0x0000000e,0x00000083,0x0000007a,0x00000082,0x0004003d, + 0x00000006,0x00000084,0x0000004d,0x0004006d,0x0000000e,0x00000085,0x00000084,0x000500c4, + 0x0000000e,0x00000087,0x00000085,0x00000086,0x000500c5,0x0000000e,0x00000088,0x00000083, + 0x00000087,0x000200fe,0x00000088,0x00010038,0x00050036,0x00000013,0x00000016,0x00000000, + 0x00000014,0x00030037,0x00000007,0x00000015,0x000200f8,0x00000017,0x0004003d,0x00000006, + 0x0000008b,0x00000015,0x0004007c,0x0000000e,0x0000008c,0x0000008b,0x000500c7,0x0000000e, + 0x0000008e,0x0000008c,0x0000008d,0x000500ab,0x00000013,0x0000008f,0x0000008e,0x0000008d, + 0x000200fe,0x0000008f,0x00010038,0x00050036,0x0000000c,0x0000001a,0x00000000,0x00000018, + 0x00030037,0x0000000d,0x00000019,0x000200f8,0x0000001b,0x0004003b,0x00000007,0x00000092, + 0x00000007,0x0004003b,0x00000007,0x00000096,0x00000007,0x0004003b,0x00000007,0x0000009e, + 0x00000007,0x0004003b,0x00000007,0x000000a2,0x00000007,0x0004003b,0x00000007,0x000000aa, + 0x00000007,0x0004003b,0x00000007,0x000000ae,0x00000007,0x00050041,0x00000007,0x00000093, + 0x00000019,0x00000037,0x0004003d,0x00000006,0x00000094,0x00000093,0x0003003e,0x00000092, + 0x00000094,0x00050039,0x00000013,0x00000095,0x00000016,0x00000092,0x000300f7,0x00000098, + 0x00000000,0x000400fa,0x00000095,0x00000097,0x0000009c,0x000200f8,0x00000097,0x00050041, + 0x00000007,0x00000099,0x00000019,0x00000037,0x0004003d,0x00000006,0x0000009a,0x00000099, + 0x0007000c,0x00000006,0x0000009b,0x00000001,0x00000028,0x0000009a,0x00000029,0x0003003e, + 0x00000096,0x0000009b,0x000200f9,0x00000098,0x000200f8,0x0000009c,0x0003003e,0x00000096, + 0x00000029,0x000200f9,0x00000098,0x000200f8,0x00000098,0x0004003d,0x00000006,0x0000009d, + 0x00000096,0x00050041,0x00000007,0x0000009f,0x00000019,0x0000003d,0x0004003d,0x00000006, + 0x000000a0,0x0000009f,0x0003003e,0x0000009e,0x000000a0,0x00050039,0x00000013,0x000000a1, + 0x00000016,0x0000009e,0x000300f7,0x000000a4,0x00000000,0x000400fa,0x000000a1,0x000000a3, + 0x000000a8,0x000200f8,0x000000a3,0x00050041,0x00000007,0x000000a5,0x00000019,0x0000003d, + 0x0004003d,0x00000006,0x000000a6,0x000000a5,0x0007000c,0x00000006,0x000000a7,0x00000001, + 0x00000028,0x000000a6,0x00000029,0x0003003e,0x000000a2,0x000000a7,0x000200f9,0x000000a4, + 0x000200f8,0x000000a8,0x0003003e,0x000000a2,0x00000029,0x000200f9,0x000000a4,0x000200f8, + 0x000000a4,0x0004003d,0x00000006,0x000000a9,0x000000a2,0x00050041,0x00000007,0x000000ab, + 0x00000019,0x00000043,0x0004003d,0x00000006,0x000000ac,0x000000ab,0x0003003e,0x000000aa, + 0x000000ac,0x00050039,0x00000013,0x000000ad,0x00000016,0x000000aa,0x000300f7,0x000000b0, + 0x00000000,0x000400fa,0x000000ad,0x000000af,0x000000b4,0x000200f8,0x000000af,0x00050041, + 0x00000007,0x000000b1,0x00000019,0x00000043,0x0004003d,0x00000006,0x000000b2,0x000000b1, + 0x0007000c,0x00000006,0x000000b3,0x00000001,0x00000028,0x000000b2,0x00000029,0x0003003e, + 0x000000ae,0x000000b3,0x000200f9,0x000000b0,0x000200f8,0x000000b4,0x0003003e,0x000000ae, + 0x00000029,0x000200f9,0x000000b0,0x000200f8,0x000000b0,0x0004003d,0x00000006,0x000000b5, + 0x000000ae,0x00060050,0x0000000c,0x000000b6,0x0000009d,0x000000a9,0x000000b5,0x000200fe, + 0x000000b6,0x00010038,0x00050036,0x00000006,0x00000021,0x00000000,0x0000001f,0x00030037, + 0x0000001e,0x00000020,0x000200f8,0x00000022,0x0004003b,0x00000007,0x000000b9,0x00000007, + 0x0004003d,0x000000bb,0x000000be,0x000000bd,0x0004003d,0x0000001d,0x000000bf,0x00000020, + 0x00050041,0x000000c8,0x000000c9,0x000000c6,0x000000c7,0x0004003d,0x0000001d,0x000000ca, + 0x000000c9,0x00050050,0x0000001d,0x000000cb,0x000000c7,0x000000c7,0x00050082,0x0000001d, + 0x000000cc,0x000000ca,0x000000cb,0x0008000c,0x0000001d,0x000000cd,0x00000001,0x0000002d, + 0x000000bf,0x000000c1,0x000000cc,0x00040064,0x000000ba,0x000000ce,0x000000be,0x0007005f, + 0x000000c3,0x000000cf,0x000000ce,0x000000cd,0x00000002,0x000000c0,0x00050051,0x00000006, + 0x000000d0,0x000000cf,0x00000000,0x0003003e,0x000000b9,0x000000d0,0x00060041,0x000000d3, + 0x000000d4,0x000000c6,0x000000d1,0x000000d2,0x0004003d,0x00000006,0x000000d5,0x000000d4, + 0x0004006e,0x0000001c,0x000000d6,0x000000d5,0x000500c7,0x0000001c,0x000000d7,0x000000d6, + 0x000000c7,0x000500ab,0x00000013,0x000000d8,0x000000d7,0x000000c0,0x000300f7,0x000000da, + 0x00000000,0x000400fa,0x000000d8,0x000000d9,0x000000da,0x000200f8,0x000000d9,0x0004003d, + 0x00000006,0x000000db,0x000000b9,0x00050083,0x00000006,0x000000dc,0x00000066,0x000000db, + 0x0003003e,0x000000b9,0x000000dc,0x000200f9,0x000000da,0x000200f8,0x000000da,0x00060041, + 0x000000d3,0x000000de,0x000000c6,0x000000dd,0x0000003d,0x0004003d,0x00000006,0x000000df, + 0x000000de,0x0004003d,0x00000006,0x000000e0,0x000000b9,0x00060041,0x000000d3,0x000000e1, + 0x000000c6,0x000000dd,0x00000037,0x0004003d,0x00000006,0x000000e2,0x000000e1,0x00050083, + 0x00000006,0x000000e3,0x000000e0,0x000000e2,0x0007000c,0x00000006,0x000000e5,0x00000001, + 0x00000028,0x000000e3,0x000000e4,0x00050088,0x00000006,0x000000e6,0x000000df,0x000000e5, + 0x000200fe,0x000000e6,0x00010038,0x00050036,0x0000000c,0x00000026,0x00000000,0x00000024, + 0x00030037,0x00000023,0x00000025,0x000200f8,0x00000027,0x0004003b,0x00000007,0x000000e9, + 0x00000007,0x0004003d,0x0000000e,0x000000ea,0x00000025,0x000500c2,0x0000000e,0x000000eb, + 0x000000ea,0x00000086,0x00040070,0x00000006,0x000000ec,0x000000eb,0x00050083,0x00000006, + 0x000000ed,0x000000ec,0x00000059,0x0006000c,0x00000006,0x000000ee,0x00000001,0x0000001d, + 0x000000ed,0x0003003e,0x000000e9,0x000000ee,0x0004003d,0x0000000e,0x000000ef,0x00000025, + 0x000500c7,0x0000000e,0x000000f1,0x000000ef,0x000000f0,0x00040070,0x00000006,0x000000f2, + 0x000000f1,0x0004003d,0x0000000e,0x000000f3,0x00000025,0x000500c2,0x0000000e,0x000000f4, + 0x000000f3,0x00000078,0x000500c7,0x0000000e,0x000000f5,0x000000f4,0x000000f0,0x00040070, + 0x00000006,0x000000f6,0x000000f5,0x0004003d,0x0000000e,0x000000f7,0x00000025,0x000500c2, + 0x0000000e,0x000000f8,0x000000f7,0x00000081,0x000500c7,0x0000000e,0x000000f9,0x000000f8, + 0x000000f0,0x00040070,0x00000006,0x000000fa,0x000000f9,0x00060050,0x0000000c,0x000000fb, + 0x000000f2,0x000000f6,0x000000fa,0x0004003d,0x00000006,0x000000fc,0x000000e9,0x0005008e, + 0x0000000c,0x000000fd,0x000000fb,0x000000fc,0x000200fe,0x000000fd,0x00010038 }; diff --git a/gpu/vk/shaders/evil_ao_comp_spv.h b/gpu/vk/shaders/evil_ao_comp_spv.h index 155449d..632ba0a 100644 --- a/gpu/vk/shaders/evil_ao_comp_spv.h +++ b/gpu/vk/shaders/evil_ao_comp_spv.h @@ -1,383 +1,454 @@ -// evil_ao.comp + aa_common.glsl sha256 a9a6c6e961fdaa6cddf8d5afad4afdcb43258aaa37964e2a708e785effea88d6 (tests/test_evil_hd.py --write: glslangValidator -V --target-env vulkan1.2 --vn EVIL_AO_COMP_SPV) +// evil_ao.comp + aa_common.glsl sha256 fec41d186fd615e4bb6463d8f0ae6e5fd520feca25a02aeca28480299a3c18c3 (tests/test_evil_hd.py --write: glslangValidator -V --target-env vulkan1.2 --vn EVIL_AO_COMP_SPV) // 1116.6.0 #pragma once const uint32_t EVIL_AO_COMP_SPV[] = { - 0x07230203,0x00010500,0x0008000b,0x0000021e,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010500,0x0008000b,0x00000281,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x000a000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x00000018,0x00000044,0x00000071, - 0x000000b3,0x0000015f,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008,0x00000001, + 0x000a000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x00000055,0x0000007d,0x000000a9, + 0x000000e9,0x000001b1,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008,0x00000001, 0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,0x00000000,0x00060005, - 0x0000000a,0x74736964,0x65636e61,0x2874615f,0x003b3166,0x00030005,0x00000009,0x00000064, - 0x00060005,0x00000012,0x77656976,0x2874615f,0x3b326976,0x00000000,0x00030005,0x00000011, - 0x00000070,0x00040005,0x00000016,0x68737550,0x00000000,0x00040006,0x00000016,0x00000000, - 0x00766e69,0x00050006,0x00000016,0x00000001,0x657a6973,0x00000000,0x00040006,0x00000016, - 0x00000002,0x006d6163,0x00040006,0x00000016,0x00000003,0x0000006b,0x00030005,0x00000018, - 0x00006370,0x00030005,0x00000040,0x0000007a,0x00050005,0x00000044,0x74706564,0x65745f68, - 0x00000078,0x00040005,0x00000049,0x61726170,0x0000006d,0x00030005,0x0000004d,0x0063646e, - 0x00030005,0x0000006e,0x00000063,0x00080005,0x00000071,0x475f6c67,0x61626f6c,0x766e496c, - 0x7461636f,0x496e6f69,0x00000044,0x00040005,0x00000089,0x69646172,0x00007375,0x00030005, - 0x0000008c,0x00726166,0x00030005,0x00000090,0x00000070,0x00040005,0x00000091,0x61726170, - 0x0000006d,0x00040005,0x000000b3,0x6f5f6f61,0x00007475,0x00030005,0x000000b8,0x0000006c, - 0x00040005,0x000000bc,0x61726170,0x0000006d,0x00030005,0x000000be,0x00000072,0x00040005, - 0x000000c1,0x61726170,0x0000006d,0x00030005,0x000000c3,0x00000064,0x00040005,0x000000c7, - 0x61726170,0x0000006d,0x00030005,0x000000c9,0x00000075,0x00040005,0x000000cc,0x61726170, - 0x0000006d,0x00030005,0x000000ce,0x00007864,0x00030005,0x000000e7,0x00007964,0x00030005, - 0x00000100,0x0000006e,0x00040005,0x0000010e,0x67756f72,0x00000068,0x00050005,0x00000127, - 0x6f6f6d73,0x685f6874,0x00657265,0x00030005,0x00000134,0x00007870,0x00040005,0x00000147, - 0x73696f6e,0x00000065,0x00030005,0x00000157,0x00003272,0x00050005,0x0000015b,0x6c63636f, - 0x64656475,0x00000000,0x00040005,0x0000015c,0x6e756f62,0x00006563,0x00030005,0x0000015e, - 0x00006f6c,0x00030005,0x0000015f,0x00637273,0x00030005,0x0000016a,0x00006968,0x00030005, - 0x0000016c,0x00000069,0x00030005,0x00000175,0x00000074,0x00040005,0x0000017b,0x6c676e61, - 0x00000065,0x00040005,0x00000183,0x7366666f,0x00007465,0x00030005,0x0000018d,0x00000071, - 0x00040005,0x00000193,0x6e656573,0x00000000,0x00030005,0x0000019e,0x00000079,0x00030005, - 0x000001a7,0x00000076,0x00040005,0x000001a8,0x61726170,0x0000006d,0x00030005,0x000001ad, - 0x00007676,0x00040005,0x000001b7,0x69736f63,0x0000656e,0x00050005,0x000001be,0x7261656e, - 0x6168735f,0x00006572,0x00030005,0x000001c8,0x00000077,0x00050005,0x000001e1,0x746e6f63, - 0x74736172,0x00000000,0x00050005,0x000001e9,0x5f746f6e,0x74616c66,0x00000000,0x00030005, - 0x000001ee,0x00006f61,0x00040005,0x00000204,0x7065656b,0x00000000,0x00030047,0x00000016, - 0x00000002,0x00050048,0x00000016,0x00000000,0x00000023,0x00000000,0x00050048,0x00000016, - 0x00000001,0x00000023,0x00000008,0x00050048,0x00000016,0x00000002,0x00000023,0x00000010, - 0x00050048,0x00000016,0x00000003,0x00000023,0x00000020,0x00040047,0x00000044,0x00000021, - 0x00000000,0x00040047,0x00000044,0x00000022,0x00000000,0x00040047,0x00000071,0x0000000b, - 0x0000001c,0x00030047,0x000000b3,0x00000019,0x00040047,0x000000b3,0x00000021,0x00000002, - 0x00040047,0x000000b3,0x00000022,0x00000000,0x00040047,0x0000015f,0x00000021,0x00000001, - 0x00040047,0x0000015f,0x00000022,0x00000000,0x00040047,0x0000021d,0x0000000b,0x00000019, - 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, - 0x00040020,0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007, - 0x00040015,0x0000000c,0x00000020,0x00000001,0x00040017,0x0000000d,0x0000000c,0x00000002, - 0x00040020,0x0000000e,0x00000007,0x0000000d,0x00040017,0x0000000f,0x00000006,0x00000003, - 0x00040021,0x00000010,0x0000000f,0x0000000e,0x00040017,0x00000014,0x00000006,0x00000002, - 0x00040017,0x00000015,0x00000006,0x00000004,0x0006001e,0x00000016,0x00000014,0x0000000d, - 0x00000015,0x00000015,0x00040020,0x00000017,0x00000009,0x00000016,0x0004003b,0x00000017, - 0x00000018,0x00000009,0x0004002b,0x0000000c,0x00000019,0x00000003,0x00040015,0x0000001a, - 0x00000020,0x00000000,0x0004002b,0x0000001a,0x0000001b,0x00000003,0x00040020,0x0000001c, - 0x00000009,0x00000006,0x0004002b,0x0000000c,0x00000020,0x00000001,0x0004002b,0x0000000c, - 0x00000022,0x00000000,0x00020014,0x00000023,0x0004002b,0x00000006,0x00000027,0x3f800000, - 0x0004002b,0x0000000c,0x0000002a,0x00000002,0x0004002b,0x0000001a,0x0000002b,0x00000001, - 0x0004002b,0x0000001a,0x0000002f,0x00000000,0x0004002b,0x00000006,0x00000033,0x33d6bf95, - 0x0005002c,0x0000000d,0x00000039,0x00000022,0x00000022,0x00040020,0x0000003a,0x00000009, - 0x0000000d,0x00090019,0x00000041,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000, - 0x00000001,0x00000000,0x0003001b,0x00000042,0x00000041,0x00040020,0x00000043,0x00000000, - 0x00000042,0x0004003b,0x00000043,0x00000044,0x00000000,0x00040020,0x0000004c,0x00000007, - 0x00000014,0x0004002b,0x00000006,0x00000050,0x3f000000,0x00040020,0x00000053,0x00000009, - 0x00000014,0x0004002b,0x00000006,0x00000057,0x40000000,0x0004002b,0x0000001a,0x0000005d, - 0x00000002,0x00040017,0x0000006f,0x0000001a,0x00000003,0x00040020,0x00000070,0x00000001, - 0x0000006f,0x0004003b,0x00000070,0x00000071,0x00000001,0x00040017,0x00000072,0x0000001a, - 0x00000002,0x00040020,0x00000076,0x00000007,0x0000000c,0x00040020,0x00000079,0x00000009, - 0x0000000c,0x00040020,0x0000008f,0x00000007,0x0000000f,0x0004002b,0x00000006,0x00000096, - 0x00000000,0x00090019,0x000000b1,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000, - 0x00000002,0x00000002,0x00040020,0x000000b2,0x00000000,0x000000b1,0x0004003b,0x000000b2, - 0x000000b3,0x00000000,0x0007002c,0x00000015,0x000000b6,0x00000096,0x00000096,0x00000096, - 0x00000027,0x0005002c,0x0000000d,0x000000ba,0x00000020,0x00000022,0x0005002c,0x0000000d, - 0x000000c5,0x00000022,0x00000020,0x0004002b,0x00000006,0x00000128,0x3b83126f,0x0004002b, - 0x00000006,0x00000129,0x3ca3d70a,0x0004002b,0x00000006,0x00000141,0x3dcccccd,0x0004002b, - 0x00000006,0x00000148,0x4253ee82,0x0004002b,0x00000006,0x00000149,0x3d897143,0x0004002b, - 0x00000006,0x0000014e,0x3bbf4590,0x0006002c,0x0000000f,0x0000015d,0x00000096,0x00000096, - 0x00000096,0x0004003b,0x00000043,0x0000015f,0x00000000,0x0004002b,0x00000006,0x00000165, - 0x3e59b3d0,0x0004002b,0x00000006,0x00000166,0x3f371759,0x0004002b,0x00000006,0x00000167, - 0x3d93dd98,0x0006002c,0x0000000f,0x00000168,0x00000165,0x00000166,0x00000167,0x0004002b, - 0x0000000c,0x00000173,0x0000000c,0x0004002b,0x00000006,0x00000179,0x41400000,0x0004002b, - 0x00000006,0x0000017c,0x40c90fdb,0x0004002b,0x00000006,0x0000017e,0x40e00000,0x0004002b, - 0x00000006,0x000001b2,0x322bcc77,0x0004002b,0x00000006,0x000001bf,0x3e19999a,0x0004002b, - 0x00000006,0x000001c2,0x3ecccccd,0x0004002b,0x00000006,0x000001ca,0x3e800000,0x0004002b, - 0x00000006,0x000001cc,0x3f400000,0x0004002b,0x00000006,0x000001e6,0x3d4ccccd,0x0004002b, - 0x00000006,0x000001ea,0x3d23d70a,0x0004002b,0x00000006,0x000001eb,0x3e23d70a,0x0004002b, - 0x00000006,0x000001f7,0x3f19999a,0x0004002b,0x0000001a,0x0000021c,0x00000008,0x0006002c, - 0x0000006f,0x0000021d,0x0000021c,0x0000021c,0x0000002b,0x00050036,0x00000002,0x00000004, - 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000e,0x0000006e,0x00000007, - 0x0004003b,0x00000007,0x00000089,0x00000007,0x0004003b,0x00000007,0x0000008c,0x00000007, - 0x0004003b,0x0000008f,0x00000090,0x00000007,0x0004003b,0x0000000e,0x00000091,0x00000007, - 0x0004003b,0x0000008f,0x000000b8,0x00000007,0x0004003b,0x0000000e,0x000000bc,0x00000007, - 0x0004003b,0x0000008f,0x000000be,0x00000007,0x0004003b,0x0000000e,0x000000c1,0x00000007, - 0x0004003b,0x0000008f,0x000000c3,0x00000007,0x0004003b,0x0000000e,0x000000c7,0x00000007, - 0x0004003b,0x0000008f,0x000000c9,0x00000007,0x0004003b,0x0000000e,0x000000cc,0x00000007, - 0x0004003b,0x0000008f,0x000000ce,0x00000007,0x0004003b,0x0000008f,0x000000dc,0x00000007, - 0x0004003b,0x0000008f,0x000000e7,0x00000007,0x0004003b,0x0000008f,0x000000f5,0x00000007, - 0x0004003b,0x0000008f,0x00000100,0x00000007,0x0004003b,0x00000007,0x0000010e,0x00000007, - 0x0004003b,0x00000007,0x00000127,0x00000007,0x0004003b,0x00000007,0x00000134,0x00000007, - 0x0004003b,0x00000007,0x00000147,0x00000007,0x0004003b,0x00000007,0x00000157,0x00000007, - 0x0004003b,0x00000007,0x0000015b,0x00000007,0x0004003b,0x0000008f,0x0000015c,0x00000007, - 0x0004003b,0x00000007,0x0000015e,0x00000007,0x0004003b,0x00000007,0x0000016a,0x00000007, - 0x0004003b,0x00000076,0x0000016c,0x00000007,0x0004003b,0x00000007,0x00000175,0x00000007, - 0x0004003b,0x00000007,0x0000017b,0x00000007,0x0004003b,0x0000004c,0x00000183,0x00000007, - 0x0004003b,0x0000000e,0x0000018d,0x00000007,0x0004003b,0x0000008f,0x00000193,0x00000007, - 0x0004003b,0x00000007,0x0000019e,0x00000007,0x0004003b,0x0000008f,0x000001a7,0x00000007, - 0x0004003b,0x0000000e,0x000001a8,0x00000007,0x0004003b,0x00000007,0x000001ad,0x00000007, - 0x0004003b,0x00000007,0x000001b7,0x00000007,0x0004003b,0x00000007,0x000001be,0x00000007, - 0x0004003b,0x00000007,0x000001c8,0x00000007,0x0004003b,0x00000007,0x000001e1,0x00000007, - 0x0004003b,0x00000007,0x000001e9,0x00000007,0x0004003b,0x00000007,0x000001ee,0x00000007, - 0x0004003b,0x00000007,0x00000204,0x00000007,0x0004003d,0x0000006f,0x00000073,0x00000071, - 0x0007004f,0x00000072,0x00000074,0x00000073,0x00000073,0x00000000,0x00000001,0x0004007c, - 0x0000000d,0x00000075,0x00000074,0x0003003e,0x0000006e,0x00000075,0x00050041,0x00000076, - 0x00000077,0x0000006e,0x0000002f,0x0004003d,0x0000000c,0x00000078,0x00000077,0x00060041, - 0x00000079,0x0000007a,0x00000018,0x00000020,0x0000002f,0x0004003d,0x0000000c,0x0000007b, - 0x0000007a,0x000500af,0x00000023,0x0000007c,0x00000078,0x0000007b,0x000400a8,0x00000023, - 0x0000007d,0x0000007c,0x000300f7,0x0000007f,0x00000000,0x000400fa,0x0000007d,0x0000007e, - 0x0000007f,0x000200f8,0x0000007e,0x00050041,0x00000076,0x00000080,0x0000006e,0x0000002b, - 0x0004003d,0x0000000c,0x00000081,0x00000080,0x00060041,0x00000079,0x00000082,0x00000018, - 0x00000020,0x0000002b,0x0004003d,0x0000000c,0x00000083,0x00000082,0x000500af,0x00000023, - 0x00000084,0x00000081,0x00000083,0x000200f9,0x0000007f,0x000200f8,0x0000007f,0x000700f5, - 0x00000023,0x00000085,0x0000007c,0x00000005,0x00000084,0x0000007e,0x000300f7,0x00000087, - 0x00000000,0x000400fa,0x00000085,0x00000086,0x00000087,0x000200f8,0x00000086,0x000100fd, - 0x000200f8,0x00000087,0x00060041,0x0000001c,0x0000008a,0x00000018,0x00000019,0x0000002f, - 0x0004003d,0x00000006,0x0000008b,0x0000008a,0x0003003e,0x00000089,0x0000008b,0x00060041, - 0x0000001c,0x0000008d,0x00000018,0x00000019,0x0000005d,0x0004003d,0x00000006,0x0000008e, - 0x0000008d,0x0003003e,0x0000008c,0x0000008e,0x0004003d,0x0000000d,0x00000092,0x0000006e, - 0x0003003e,0x00000091,0x00000092,0x00050039,0x0000000f,0x00000093,0x00000012,0x00000091, - 0x0003003e,0x00000090,0x00000093,0x00050041,0x00000007,0x00000094,0x00000090,0x0000005d, - 0x0004003d,0x00000006,0x00000095,0x00000094,0x000500ba,0x00000023,0x00000097,0x00000095, - 0x00000096,0x000400a8,0x00000023,0x00000098,0x00000097,0x000400a8,0x00000023,0x00000099, - 0x00000098,0x000300f7,0x0000009b,0x00000000,0x000400fa,0x00000099,0x0000009a,0x0000009b, - 0x000200f8,0x0000009a,0x00050041,0x00000007,0x0000009c,0x00000090,0x0000005d,0x0004003d, - 0x00000006,0x0000009d,0x0000009c,0x0004003d,0x00000006,0x0000009e,0x0000008c,0x000500be, - 0x00000023,0x0000009f,0x0000009d,0x0000009e,0x000200f9,0x0000009b,0x000200f8,0x0000009b, - 0x000700f5,0x00000023,0x000000a0,0x00000098,0x00000087,0x0000009f,0x0000009a,0x000400a8, - 0x00000023,0x000000a1,0x000000a0,0x000300f7,0x000000a3,0x00000000,0x000400fa,0x000000a1, - 0x000000a2,0x000000a3,0x000200f8,0x000000a2,0x00050041,0x00000007,0x000000a4,0x00000090, - 0x0000005d,0x0004003d,0x00000006,0x000000a5,0x000000a4,0x0004009d,0x00000023,0x000000a6, - 0x000000a5,0x000200f9,0x000000a3,0x000200f8,0x000000a3,0x000700f5,0x00000023,0x000000a7, - 0x000000a0,0x0000009b,0x000000a6,0x000000a2,0x000400a8,0x00000023,0x000000a8,0x000000a7, - 0x000300f7,0x000000aa,0x00000000,0x000400fa,0x000000a8,0x000000a9,0x000000aa,0x000200f8, - 0x000000a9,0x00050041,0x00000007,0x000000ab,0x00000090,0x0000005d,0x0004003d,0x00000006, - 0x000000ac,0x000000ab,0x0004009c,0x00000023,0x000000ad,0x000000ac,0x000200f9,0x000000aa, - 0x000200f8,0x000000aa,0x000700f5,0x00000023,0x000000ae,0x000000a7,0x000000a3,0x000000ad, - 0x000000a9,0x000300f7,0x000000b0,0x00000000,0x000400fa,0x000000ae,0x000000af,0x000000b0, - 0x000200f8,0x000000af,0x0004003d,0x000000b1,0x000000b4,0x000000b3,0x0004003d,0x0000000d, - 0x000000b5,0x0000006e,0x00040063,0x000000b4,0x000000b5,0x000000b6,0x000100fd,0x000200f8, - 0x000000b0,0x0004003d,0x0000000d,0x000000b9,0x0000006e,0x00050082,0x0000000d,0x000000bb, - 0x000000b9,0x000000ba,0x0003003e,0x000000bc,0x000000bb,0x00050039,0x0000000f,0x000000bd, - 0x00000012,0x000000bc,0x0003003e,0x000000b8,0x000000bd,0x0004003d,0x0000000d,0x000000bf, - 0x0000006e,0x00050080,0x0000000d,0x000000c0,0x000000bf,0x000000ba,0x0003003e,0x000000c1, - 0x000000c0,0x00050039,0x0000000f,0x000000c2,0x00000012,0x000000c1,0x0003003e,0x000000be, - 0x000000c2,0x0004003d,0x0000000d,0x000000c4,0x0000006e,0x00050082,0x0000000d,0x000000c6, - 0x000000c4,0x000000c5,0x0003003e,0x000000c7,0x000000c6,0x00050039,0x0000000f,0x000000c8, - 0x00000012,0x000000c7,0x0003003e,0x000000c3,0x000000c8,0x0004003d,0x0000000d,0x000000ca, - 0x0000006e,0x00050080,0x0000000d,0x000000cb,0x000000ca,0x000000c5,0x0003003e,0x000000cc, - 0x000000cb,0x00050039,0x0000000f,0x000000cd,0x00000012,0x000000cc,0x0003003e,0x000000c9, - 0x000000cd,0x00050041,0x00000007,0x000000cf,0x000000be,0x0000005d,0x0004003d,0x00000006, - 0x000000d0,0x000000cf,0x00050041,0x00000007,0x000000d1,0x00000090,0x0000005d,0x0004003d, - 0x00000006,0x000000d2,0x000000d1,0x00050083,0x00000006,0x000000d3,0x000000d0,0x000000d2, - 0x0006000c,0x00000006,0x000000d4,0x00000001,0x00000004,0x000000d3,0x00050041,0x00000007, - 0x000000d5,0x00000090,0x0000005d,0x0004003d,0x00000006,0x000000d6,0x000000d5,0x00050041, - 0x00000007,0x000000d7,0x000000b8,0x0000005d,0x0004003d,0x00000006,0x000000d8,0x000000d7, - 0x00050083,0x00000006,0x000000d9,0x000000d6,0x000000d8,0x0006000c,0x00000006,0x000000da, - 0x00000001,0x00000004,0x000000d9,0x000500b8,0x00000023,0x000000db,0x000000d4,0x000000da, - 0x000300f7,0x000000de,0x00000000,0x000400fa,0x000000db,0x000000dd,0x000000e2,0x000200f8, - 0x000000dd,0x0004003d,0x0000000f,0x000000df,0x000000be,0x0004003d,0x0000000f,0x000000e0, - 0x00000090,0x00050083,0x0000000f,0x000000e1,0x000000df,0x000000e0,0x0003003e,0x000000dc, - 0x000000e1,0x000200f9,0x000000de,0x000200f8,0x000000e2,0x0004003d,0x0000000f,0x000000e3, - 0x00000090,0x0004003d,0x0000000f,0x000000e4,0x000000b8,0x00050083,0x0000000f,0x000000e5, - 0x000000e3,0x000000e4,0x0003003e,0x000000dc,0x000000e5,0x000200f9,0x000000de,0x000200f8, - 0x000000de,0x0004003d,0x0000000f,0x000000e6,0x000000dc,0x0003003e,0x000000ce,0x000000e6, - 0x00050041,0x00000007,0x000000e8,0x000000c9,0x0000005d,0x0004003d,0x00000006,0x000000e9, - 0x000000e8,0x00050041,0x00000007,0x000000ea,0x00000090,0x0000005d,0x0004003d,0x00000006, - 0x000000eb,0x000000ea,0x00050083,0x00000006,0x000000ec,0x000000e9,0x000000eb,0x0006000c, - 0x00000006,0x000000ed,0x00000001,0x00000004,0x000000ec,0x00050041,0x00000007,0x000000ee, - 0x00000090,0x0000005d,0x0004003d,0x00000006,0x000000ef,0x000000ee,0x00050041,0x00000007, - 0x000000f0,0x000000c3,0x0000005d,0x0004003d,0x00000006,0x000000f1,0x000000f0,0x00050083, - 0x00000006,0x000000f2,0x000000ef,0x000000f1,0x0006000c,0x00000006,0x000000f3,0x00000001, - 0x00000004,0x000000f2,0x000500b8,0x00000023,0x000000f4,0x000000ed,0x000000f3,0x000300f7, - 0x000000f7,0x00000000,0x000400fa,0x000000f4,0x000000f6,0x000000fb,0x000200f8,0x000000f6, - 0x0004003d,0x0000000f,0x000000f8,0x000000c9,0x0004003d,0x0000000f,0x000000f9,0x00000090, - 0x00050083,0x0000000f,0x000000fa,0x000000f8,0x000000f9,0x0003003e,0x000000f5,0x000000fa, - 0x000200f9,0x000000f7,0x000200f8,0x000000fb,0x0004003d,0x0000000f,0x000000fc,0x00000090, - 0x0004003d,0x0000000f,0x000000fd,0x000000c3,0x00050083,0x0000000f,0x000000fe,0x000000fc, - 0x000000fd,0x0003003e,0x000000f5,0x000000fe,0x000200f9,0x000000f7,0x000200f8,0x000000f7, - 0x0004003d,0x0000000f,0x000000ff,0x000000f5,0x0003003e,0x000000e7,0x000000ff,0x0004003d, - 0x0000000f,0x00000101,0x000000ce,0x0004003d,0x0000000f,0x00000102,0x000000e7,0x0007000c, - 0x0000000f,0x00000103,0x00000001,0x00000044,0x00000101,0x00000102,0x0006000c,0x0000000f, - 0x00000104,0x00000001,0x00000045,0x00000103,0x0003003e,0x00000100,0x00000104,0x0004003d, - 0x0000000f,0x00000105,0x00000100,0x0004003d,0x0000000f,0x00000106,0x00000090,0x0004007f, - 0x0000000f,0x00000107,0x00000106,0x00050094,0x00000006,0x00000108,0x00000105,0x00000107, - 0x000500b8,0x00000023,0x00000109,0x00000108,0x00000096,0x000300f7,0x0000010b,0x00000000, - 0x000400fa,0x00000109,0x0000010a,0x0000010b,0x000200f8,0x0000010a,0x0004003d,0x0000000f, - 0x0000010c,0x00000100,0x0004007f,0x0000000f,0x0000010d,0x0000010c,0x0003003e,0x00000100, - 0x0000010d,0x000200f9,0x0000010b,0x000200f8,0x0000010b,0x00050041,0x00000007,0x0000010f, - 0x000000b8,0x0000005d,0x0004003d,0x00000006,0x00000110,0x0000010f,0x00050041,0x00000007, - 0x00000111,0x000000be,0x0000005d,0x0004003d,0x00000006,0x00000112,0x00000111,0x00050081, - 0x00000006,0x00000113,0x00000110,0x00000112,0x00050041,0x00000007,0x00000114,0x00000090, - 0x0000005d,0x0004003d,0x00000006,0x00000115,0x00000114,0x00050085,0x00000006,0x00000116, - 0x00000057,0x00000115,0x00050083,0x00000006,0x00000117,0x00000113,0x00000116,0x0006000c, - 0x00000006,0x00000118,0x00000001,0x00000004,0x00000117,0x00050041,0x00000007,0x00000119, - 0x000000c9,0x0000005d,0x0004003d,0x00000006,0x0000011a,0x00000119,0x00050041,0x00000007, - 0x0000011b,0x000000c3,0x0000005d,0x0004003d,0x00000006,0x0000011c,0x0000011b,0x00050081, - 0x00000006,0x0000011d,0x0000011a,0x0000011c,0x00050041,0x00000007,0x0000011e,0x00000090, - 0x0000005d,0x0004003d,0x00000006,0x0000011f,0x0000011e,0x00050085,0x00000006,0x00000120, - 0x00000057,0x0000011f,0x00050083,0x00000006,0x00000121,0x0000011d,0x00000120,0x0006000c, - 0x00000006,0x00000122,0x00000001,0x00000004,0x00000121,0x00050081,0x00000006,0x00000123, - 0x00000118,0x00000122,0x00050041,0x00000007,0x00000124,0x00000090,0x0000005d,0x0004003d, - 0x00000006,0x00000125,0x00000124,0x00050088,0x00000006,0x00000126,0x00000123,0x00000125, - 0x0003003e,0x0000010e,0x00000126,0x0004003d,0x00000006,0x0000012a,0x0000010e,0x0008000c, - 0x00000006,0x0000012b,0x00000001,0x00000031,0x00000128,0x00000129,0x0000012a,0x00050083, - 0x00000006,0x0000012c,0x00000027,0x0000012b,0x0003003e,0x00000127,0x0000012c,0x0004003d, - 0x00000006,0x0000012d,0x00000127,0x000500bc,0x00000023,0x0000012e,0x0000012d,0x00000096, - 0x000300f7,0x00000130,0x00000000,0x000400fa,0x0000012e,0x0000012f,0x00000130,0x000200f8, - 0x0000012f,0x0004003d,0x000000b1,0x00000131,0x000000b3,0x0004003d,0x0000000d,0x00000132, - 0x0000006e,0x00040063,0x00000131,0x00000132,0x000000b6,0x000100fd,0x000200f8,0x00000130, - 0x0004003d,0x00000006,0x00000135,0x00000089,0x00050041,0x00000007,0x00000136,0x00000090, - 0x0000005d,0x0004003d,0x00000006,0x00000137,0x00000136,0x00060041,0x0000001c,0x00000138, - 0x00000018,0x0000002a,0x0000001b,0x0004003d,0x00000006,0x00000139,0x00000138,0x00050085, - 0x00000006,0x0000013a,0x00000137,0x00000139,0x00050088,0x00000006,0x0000013b,0x00000135, - 0x0000013a,0x00050085,0x00000006,0x0000013c,0x0000013b,0x00000050,0x00060041,0x00000079, - 0x0000013d,0x00000018,0x00000020,0x0000002b,0x0004003d,0x0000000c,0x0000013e,0x0000013d, - 0x0004006f,0x00000006,0x0000013f,0x0000013e,0x00050085,0x00000006,0x00000140,0x0000013c, - 0x0000013f,0x00060041,0x00000079,0x00000142,0x00000018,0x00000020,0x0000002b,0x0004003d, - 0x0000000c,0x00000143,0x00000142,0x0004006f,0x00000006,0x00000144,0x00000143,0x00050085, - 0x00000006,0x00000145,0x00000141,0x00000144,0x0008000c,0x00000006,0x00000146,0x00000001, - 0x0000002b,0x00000140,0x00000057,0x00000145,0x0003003e,0x00000134,0x00000146,0x00050041, - 0x00000076,0x0000014a,0x0000006e,0x0000002f,0x0004003d,0x0000000c,0x0000014b,0x0000014a, - 0x0004006f,0x00000006,0x0000014c,0x0000014b,0x00050085,0x00000006,0x0000014d,0x00000149, - 0x0000014c,0x00050041,0x00000076,0x0000014f,0x0000006e,0x0000002b,0x0004003d,0x0000000c, - 0x00000150,0x0000014f,0x0004006f,0x00000006,0x00000151,0x00000150,0x00050085,0x00000006, - 0x00000152,0x0000014e,0x00000151,0x00050081,0x00000006,0x00000153,0x0000014d,0x00000152, - 0x0006000c,0x00000006,0x00000154,0x00000001,0x0000000a,0x00000153,0x00050085,0x00000006, - 0x00000155,0x00000148,0x00000154,0x0006000c,0x00000006,0x00000156,0x00000001,0x0000000a, - 0x00000155,0x0003003e,0x00000147,0x00000156,0x0004003d,0x00000006,0x00000158,0x00000089, - 0x0004003d,0x00000006,0x00000159,0x00000089,0x00050085,0x00000006,0x0000015a,0x00000158, - 0x00000159,0x0003003e,0x00000157,0x0000015a,0x0003003e,0x0000015b,0x00000096,0x0003003e, - 0x0000015c,0x0000015d,0x0004003d,0x00000042,0x00000160,0x0000015f,0x0004003d,0x0000000d, - 0x00000161,0x0000006e,0x00040064,0x00000041,0x00000162,0x00000160,0x0007005f,0x00000015, - 0x00000163,0x00000162,0x00000161,0x00000002,0x00000022,0x0008004f,0x0000000f,0x00000164, - 0x00000163,0x00000163,0x00000000,0x00000001,0x00000002,0x00050094,0x00000006,0x00000169, - 0x00000164,0x00000168,0x0003003e,0x0000015e,0x00000169,0x0004003d,0x00000006,0x0000016b, - 0x0000015e,0x0003003e,0x0000016a,0x0000016b,0x0003003e,0x0000016c,0x00000022,0x000200f9, - 0x0000016d,0x000200f8,0x0000016d,0x000400f6,0x0000016f,0x00000170,0x00000000,0x000200f9, - 0x00000171,0x000200f8,0x00000171,0x0004003d,0x0000000c,0x00000172,0x0000016c,0x000500b1, - 0x00000023,0x00000174,0x00000172,0x00000173,0x000400fa,0x00000174,0x0000016e,0x0000016f, - 0x000200f8,0x0000016e,0x0004003d,0x0000000c,0x00000176,0x0000016c,0x0004006f,0x00000006, - 0x00000177,0x00000176,0x00050081,0x00000006,0x00000178,0x00000177,0x00000050,0x00050088, - 0x00000006,0x0000017a,0x00000178,0x00000179,0x0003003e,0x00000175,0x0000017a,0x0004003d, - 0x00000006,0x0000017d,0x00000175,0x00050085,0x00000006,0x0000017f,0x0000017d,0x0000017e, - 0x0004003d,0x00000006,0x00000180,0x00000147,0x00050081,0x00000006,0x00000181,0x0000017f, - 0x00000180,0x00050085,0x00000006,0x00000182,0x0000017c,0x00000181,0x0003003e,0x0000017b, - 0x00000182,0x0004003d,0x00000006,0x00000184,0x0000017b,0x0006000c,0x00000006,0x00000185, - 0x00000001,0x0000000e,0x00000184,0x0004003d,0x00000006,0x00000186,0x0000017b,0x0006000c, - 0x00000006,0x00000187,0x00000001,0x0000000d,0x00000186,0x00050050,0x00000014,0x00000188, - 0x00000185,0x00000187,0x0004003d,0x00000006,0x00000189,0x00000134,0x0004003d,0x00000006, - 0x0000018a,0x00000175,0x00050085,0x00000006,0x0000018b,0x00000189,0x0000018a,0x0005008e, - 0x00000014,0x0000018c,0x00000188,0x0000018b,0x0003003e,0x00000183,0x0000018c,0x0004003d, - 0x0000000d,0x0000018e,0x0000006e,0x0004003d,0x00000014,0x0000018f,0x00000183,0x0006000c, - 0x00000014,0x00000190,0x00000001,0x00000001,0x0000018f,0x0004006e,0x0000000d,0x00000191, - 0x00000190,0x00050080,0x0000000d,0x00000192,0x0000018e,0x00000191,0x0003003e,0x0000018d, - 0x00000192,0x0004003d,0x00000042,0x00000194,0x0000015f,0x0004003d,0x0000000d,0x00000195, - 0x0000018d,0x00050041,0x0000003a,0x00000196,0x00000018,0x00000020,0x0004003d,0x0000000d, - 0x00000197,0x00000196,0x00050050,0x0000000d,0x00000198,0x00000020,0x00000020,0x00050082, - 0x0000000d,0x00000199,0x00000197,0x00000198,0x0008000c,0x0000000d,0x0000019a,0x00000001, - 0x0000002d,0x00000195,0x00000039,0x00000199,0x00040064,0x00000041,0x0000019b,0x00000194, - 0x0007005f,0x00000015,0x0000019c,0x0000019b,0x0000019a,0x00000002,0x00000022,0x0008004f, - 0x0000000f,0x0000019d,0x0000019c,0x0000019c,0x00000000,0x00000001,0x00000002,0x0003003e, - 0x00000193,0x0000019d,0x0004003d,0x0000000f,0x0000019f,0x00000193,0x00050094,0x00000006, - 0x000001a0,0x0000019f,0x00000168,0x0003003e,0x0000019e,0x000001a0,0x0004003d,0x00000006, - 0x000001a1,0x0000015e,0x0004003d,0x00000006,0x000001a2,0x0000019e,0x0007000c,0x00000006, - 0x000001a3,0x00000001,0x00000025,0x000001a1,0x000001a2,0x0003003e,0x0000015e,0x000001a3, - 0x0004003d,0x00000006,0x000001a4,0x0000016a,0x0004003d,0x00000006,0x000001a5,0x0000019e, - 0x0007000c,0x00000006,0x000001a6,0x00000001,0x00000028,0x000001a4,0x000001a5,0x0003003e, - 0x0000016a,0x000001a6,0x0004003d,0x0000000d,0x000001a9,0x0000018d,0x0003003e,0x000001a8, - 0x000001a9,0x00050039,0x0000000f,0x000001aa,0x00000012,0x000001a8,0x0004003d,0x0000000f, - 0x000001ab,0x00000090,0x00050083,0x0000000f,0x000001ac,0x000001aa,0x000001ab,0x0003003e, - 0x000001a7,0x000001ac,0x0004003d,0x0000000f,0x000001ae,0x000001a7,0x0004003d,0x0000000f, - 0x000001af,0x000001a7,0x00050094,0x00000006,0x000001b0,0x000001ae,0x000001af,0x0003003e, - 0x000001ad,0x000001b0,0x0004003d,0x00000006,0x000001b1,0x000001ad,0x000500b8,0x00000023, - 0x000001b3,0x000001b1,0x000001b2,0x000300f7,0x000001b5,0x00000000,0x000400fa,0x000001b3, - 0x000001b4,0x000001b5,0x000200f8,0x000001b4,0x000200f9,0x00000170,0x000200f8,0x000001b5, - 0x0004003d,0x0000000f,0x000001b8,0x000001a7,0x0004003d,0x0000000f,0x000001b9,0x00000100, - 0x00050094,0x00000006,0x000001ba,0x000001b8,0x000001b9,0x0004003d,0x00000006,0x000001bb, - 0x000001ad,0x0006000c,0x00000006,0x000001bc,0x00000001,0x00000020,0x000001bb,0x00050085, - 0x00000006,0x000001bd,0x000001ba,0x000001bc,0x0003003e,0x000001b7,0x000001bd,0x0004003d, - 0x00000006,0x000001c0,0x00000089,0x00050085,0x00000006,0x000001c1,0x000001bf,0x000001c0, - 0x0004003d,0x00000006,0x000001c3,0x00000089,0x00050085,0x00000006,0x000001c4,0x000001c2, - 0x000001c3,0x0004003d,0x00000006,0x000001c5,0x000001ad,0x0006000c,0x00000006,0x000001c6, - 0x00000001,0x0000001f,0x000001c5,0x0008000c,0x00000006,0x000001c7,0x00000001,0x00000031, - 0x000001c1,0x000001c4,0x000001c6,0x0003003e,0x000001be,0x000001c7,0x0004003d,0x00000006, - 0x000001c9,0x000001b7,0x00050083,0x00000006,0x000001cb,0x000001c9,0x000001ca,0x00050088, - 0x00000006,0x000001cd,0x000001cb,0x000001cc,0x0008000c,0x00000006,0x000001ce,0x00000001, - 0x0000002b,0x000001cd,0x00000096,0x00000027,0x0004003d,0x00000006,0x000001cf,0x000001ad, - 0x0004003d,0x00000006,0x000001d0,0x00000157,0x00050088,0x00000006,0x000001d1,0x000001cf, - 0x000001d0,0x00050083,0x00000006,0x000001d2,0x00000027,0x000001d1,0x0008000c,0x00000006, - 0x000001d3,0x00000001,0x0000002b,0x000001d2,0x00000096,0x00000027,0x00050085,0x00000006, - 0x000001d4,0x000001ce,0x000001d3,0x0004003d,0x00000006,0x000001d5,0x000001be,0x00050085, - 0x00000006,0x000001d6,0x000001d4,0x000001d5,0x0003003e,0x000001c8,0x000001d6,0x0004003d, - 0x00000006,0x000001d7,0x000001c8,0x0004003d,0x00000006,0x000001d8,0x0000015b,0x00050081, - 0x00000006,0x000001d9,0x000001d8,0x000001d7,0x0003003e,0x0000015b,0x000001d9,0x0004003d, - 0x00000006,0x000001da,0x000001c8,0x0004003d,0x0000000f,0x000001db,0x00000193,0x0005008e, - 0x0000000f,0x000001dc,0x000001db,0x000001da,0x0004003d,0x0000000f,0x000001dd,0x0000015c, - 0x00050081,0x0000000f,0x000001de,0x000001dd,0x000001dc,0x0003003e,0x0000015c,0x000001de, - 0x000200f9,0x00000170,0x000200f8,0x00000170,0x0004003d,0x0000000c,0x000001df,0x0000016c, - 0x00050080,0x0000000c,0x000001e0,0x000001df,0x00000020,0x0003003e,0x0000016c,0x000001e0, - 0x000200f9,0x0000016d,0x000200f8,0x0000016f,0x0004003d,0x00000006,0x000001e2,0x0000016a, - 0x0004003d,0x00000006,0x000001e3,0x0000015e,0x00050083,0x00000006,0x000001e4,0x000001e2, - 0x000001e3,0x0004003d,0x00000006,0x000001e5,0x0000016a,0x00050081,0x00000006,0x000001e7, - 0x000001e5,0x000001e6,0x00050088,0x00000006,0x000001e8,0x000001e4,0x000001e7,0x0003003e, - 0x000001e1,0x000001e8,0x0004003d,0x00000006,0x000001ec,0x000001e1,0x0008000c,0x00000006, - 0x000001ed,0x00000001,0x00000031,0x000001ea,0x000001eb,0x000001ec,0x0003003e,0x000001e9, - 0x000001ed,0x00060041,0x0000001c,0x000001ef,0x00000018,0x00000019,0x0000002b,0x0004003d, - 0x00000006,0x000001f0,0x000001ef,0x0004003d,0x00000006,0x000001f1,0x0000015b,0x00050085, - 0x00000006,0x000001f2,0x000001f0,0x000001f1,0x00050088,0x00000006,0x000001f3,0x000001f2, - 0x00000179,0x00050083,0x00000006,0x000001f4,0x00000027,0x000001f3,0x0008000c,0x00000006, - 0x000001f5,0x00000001,0x0000002b,0x000001f4,0x00000050,0x00000027,0x0003003e,0x000001ee, - 0x000001f5,0x0004003d,0x00000006,0x000001f6,0x000001ee,0x0004003d,0x00000006,0x000001f8, - 0x0000008c,0x00050085,0x00000006,0x000001f9,0x000001f7,0x000001f8,0x0004003d,0x00000006, - 0x000001fa,0x0000008c,0x00050041,0x00000007,0x000001fb,0x00000090,0x0000005d,0x0004003d, - 0x00000006,0x000001fc,0x000001fb,0x0008000c,0x00000006,0x000001fd,0x00000001,0x00000031, - 0x000001f9,0x000001fa,0x000001fc,0x0008000c,0x00000006,0x000001fe,0x00000001,0x0000002e, - 0x000001f6,0x00000027,0x000001fd,0x0003003e,0x000001ee,0x000001fe,0x0004003d,0x00000006, - 0x000001ff,0x000001ee,0x0004003d,0x00000006,0x00000200,0x00000127,0x0004003d,0x00000006, - 0x00000201,0x000001e9,0x00050085,0x00000006,0x00000202,0x00000200,0x00000201,0x0008000c, - 0x00000006,0x00000203,0x00000001,0x0000002e,0x00000027,0x000001ff,0x00000202,0x0003003e, - 0x000001ee,0x00000203,0x0004003d,0x00000006,0x00000205,0x00000127,0x0004003d,0x00000006, - 0x00000206,0x000001e9,0x00050085,0x00000006,0x00000207,0x00000205,0x00000206,0x0004003d, - 0x00000006,0x00000208,0x0000008c,0x00050085,0x00000006,0x00000209,0x000001f7,0x00000208, - 0x0004003d,0x00000006,0x0000020a,0x0000008c,0x00050041,0x00000007,0x0000020b,0x00000090, - 0x0000005d,0x0004003d,0x00000006,0x0000020c,0x0000020b,0x0008000c,0x00000006,0x0000020d, - 0x00000001,0x00000031,0x00000209,0x0000020a,0x0000020c,0x00050083,0x00000006,0x0000020e, - 0x00000027,0x0000020d,0x00050085,0x00000006,0x0000020f,0x00000207,0x0000020e,0x0003003e, - 0x00000204,0x0000020f,0x0004003d,0x000000b1,0x00000210,0x000000b3,0x0004003d,0x0000000d, - 0x00000211,0x0000006e,0x0004003d,0x0000000f,0x00000212,0x0000015c,0x00060050,0x0000000f, - 0x00000213,0x00000179,0x00000179,0x00000179,0x00050088,0x0000000f,0x00000214,0x00000212, - 0x00000213,0x0004003d,0x00000006,0x00000215,0x00000204,0x0005008e,0x0000000f,0x00000216, - 0x00000214,0x00000215,0x0004003d,0x00000006,0x00000217,0x000001ee,0x00050051,0x00000006, - 0x00000218,0x00000216,0x00000000,0x00050051,0x00000006,0x00000219,0x00000216,0x00000001, - 0x00050051,0x00000006,0x0000021a,0x00000216,0x00000002,0x00070050,0x00000015,0x0000021b, - 0x00000218,0x00000219,0x0000021a,0x00000217,0x00040063,0x00000210,0x00000211,0x0000021b, - 0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008,0x00030037, - 0x00000007,0x00000009,0x000200f8,0x0000000b,0x00060041,0x0000001c,0x0000001d,0x00000018, - 0x00000019,0x0000001b,0x0004003d,0x00000006,0x0000001e,0x0000001d,0x0004006e,0x0000000c, - 0x0000001f,0x0000001e,0x000500c7,0x0000000c,0x00000021,0x0000001f,0x00000020,0x000500ab, - 0x00000023,0x00000024,0x00000021,0x00000022,0x000300f7,0x00000026,0x00000000,0x000400fa, - 0x00000024,0x00000025,0x00000026,0x000200f8,0x00000025,0x0004003d,0x00000006,0x00000028, - 0x00000009,0x00050083,0x00000006,0x00000029,0x00000027,0x00000028,0x0003003e,0x00000009, - 0x00000029,0x000200f9,0x00000026,0x000200f8,0x00000026,0x00060041,0x0000001c,0x0000002c, - 0x00000018,0x0000002a,0x0000002b,0x0004003d,0x00000006,0x0000002d,0x0000002c,0x0004003d, - 0x00000006,0x0000002e,0x00000009,0x00060041,0x0000001c,0x00000030,0x00000018,0x0000002a, - 0x0000002f,0x0004003d,0x00000006,0x00000031,0x00000030,0x00050083,0x00000006,0x00000032, - 0x0000002e,0x00000031,0x0007000c,0x00000006,0x00000034,0x00000001,0x00000028,0x00000032, - 0x00000033,0x00050088,0x00000006,0x00000035,0x0000002d,0x00000034,0x000200fe,0x00000035, - 0x00010038,0x00050036,0x0000000f,0x00000012,0x00000000,0x00000010,0x00030037,0x0000000e, - 0x00000011,0x000200f8,0x00000013,0x0004003b,0x00000007,0x00000040,0x00000007,0x0004003b, - 0x00000007,0x00000049,0x00000007,0x0004003b,0x0000004c,0x0000004d,0x00000007,0x0004003d, - 0x0000000d,0x00000038,0x00000011,0x00050041,0x0000003a,0x0000003b,0x00000018,0x00000020, - 0x0004003d,0x0000000d,0x0000003c,0x0000003b,0x00050050,0x0000000d,0x0000003d,0x00000020, - 0x00000020,0x00050082,0x0000000d,0x0000003e,0x0000003c,0x0000003d,0x0008000c,0x0000000d, - 0x0000003f,0x00000001,0x0000002d,0x00000038,0x00000039,0x0000003e,0x0003003e,0x00000011, - 0x0000003f,0x0004003d,0x00000042,0x00000045,0x00000044,0x0004003d,0x0000000d,0x00000046, - 0x00000011,0x00040064,0x00000041,0x00000047,0x00000045,0x0007005f,0x00000015,0x00000048, - 0x00000047,0x00000046,0x00000002,0x00000022,0x00050051,0x00000006,0x0000004a,0x00000048, - 0x00000000,0x0003003e,0x00000049,0x0000004a,0x00050039,0x00000006,0x0000004b,0x0000000a, - 0x00000049,0x0003003e,0x00000040,0x0000004b,0x0004003d,0x0000000d,0x0000004e,0x00000011, - 0x0004006f,0x00000014,0x0000004f,0x0000004e,0x00050050,0x00000014,0x00000051,0x00000050, - 0x00000050,0x00050081,0x00000014,0x00000052,0x0000004f,0x00000051,0x00050041,0x00000053, - 0x00000054,0x00000018,0x00000022,0x0004003d,0x00000014,0x00000055,0x00000054,0x00050085, - 0x00000014,0x00000056,0x00000052,0x00000055,0x0005008e,0x00000014,0x00000058,0x00000056, - 0x00000057,0x00050050,0x00000014,0x00000059,0x00000027,0x00000027,0x00050083,0x00000014, - 0x0000005a,0x00000058,0x00000059,0x0003003e,0x0000004d,0x0000005a,0x00050041,0x00000007, - 0x0000005b,0x0000004d,0x0000002f,0x0004003d,0x00000006,0x0000005c,0x0000005b,0x00060041, - 0x0000001c,0x0000005e,0x00000018,0x0000002a,0x0000005d,0x0004003d,0x00000006,0x0000005f, - 0x0000005e,0x00050085,0x00000006,0x00000060,0x0000005c,0x0000005f,0x0004003d,0x00000006, - 0x00000061,0x00000040,0x00050085,0x00000006,0x00000062,0x00000060,0x00000061,0x00050041, - 0x00000007,0x00000063,0x0000004d,0x0000002b,0x0004003d,0x00000006,0x00000064,0x00000063, - 0x00060041,0x0000001c,0x00000065,0x00000018,0x0000002a,0x0000001b,0x0004003d,0x00000006, - 0x00000066,0x00000065,0x00050085,0x00000006,0x00000067,0x00000064,0x00000066,0x0004003d, - 0x00000006,0x00000068,0x00000040,0x00050085,0x00000006,0x00000069,0x00000067,0x00000068, - 0x0004003d,0x00000006,0x0000006a,0x00000040,0x00060050,0x0000000f,0x0000006b,0x00000062, - 0x00000069,0x0000006a,0x000200fe,0x0000006b,0x00010038 + 0x0000000b,0x6c697665,0x6e69665f,0x28657469,0x003b3166,0x00030005,0x0000000a,0x00000076, + 0x00060005,0x00000011,0x6c697665,0x656c635f,0x76286e61,0x003b3366,0x00030005,0x00000010, + 0x00000063,0x00060005,0x00000015,0x74736964,0x65636e61,0x2874615f,0x003b3166,0x00030005, + 0x00000014,0x00000064,0x00060005,0x0000001c,0x77656976,0x2874615f,0x3b326976,0x00000000, + 0x00030005,0x0000001b,0x00000070,0x00040005,0x00000026,0x61726170,0x0000006d,0x00040005, + 0x00000034,0x61726170,0x0000006d,0x00040005,0x00000041,0x61726170,0x0000006d,0x00040005, + 0x00000053,0x68737550,0x00000000,0x00040006,0x00000053,0x00000000,0x00766e69,0x00050006, + 0x00000053,0x00000001,0x657a6973,0x00000000,0x00040006,0x00000053,0x00000002,0x006d6163, + 0x00040006,0x00000053,0x00000003,0x0000006b,0x00030005,0x00000055,0x00006370,0x00030005, + 0x00000079,0x0000007a,0x00050005,0x0000007d,0x74706564,0x65745f68,0x00000078,0x00040005, + 0x00000082,0x61726170,0x0000006d,0x00030005,0x00000086,0x0063646e,0x00030005,0x000000a6, + 0x00000063,0x00080005,0x000000a9,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69, + 0x00000044,0x00040005,0x000000c1,0x69646172,0x00007375,0x00030005,0x000000c4,0x00726166, + 0x00030005,0x000000c7,0x00000070,0x00040005,0x000000c8,0x61726170,0x0000006d,0x00040005, + 0x000000e9,0x6f5f6f61,0x00007475,0x00030005,0x000000ee,0x0000006c,0x00040005,0x000000f2, + 0x61726170,0x0000006d,0x00030005,0x000000f4,0x00000072,0x00040005,0x000000f7,0x61726170, + 0x0000006d,0x00030005,0x000000f9,0x00000064,0x00040005,0x000000fd,0x61726170,0x0000006d, + 0x00030005,0x000000ff,0x00000075,0x00040005,0x00000102,0x61726170,0x0000006d,0x00030005, + 0x00000104,0x00007864,0x00030005,0x0000011d,0x00007964,0x00030005,0x00000136,0x0000006e, + 0x00040005,0x0000013b,0x61726170,0x0000006d,0x00040005,0x00000143,0x61726170,0x0000006d, + 0x00040005,0x0000014c,0x61726170,0x0000006d,0x00040005,0x00000160,0x67756f72,0x00000068, + 0x00050005,0x00000179,0x6f6f6d73,0x685f6874,0x00657265,0x00030005,0x00000186,0x00007870, + 0x00040005,0x00000199,0x73696f6e,0x00000065,0x00030005,0x000001a9,0x00003272,0x00050005, + 0x000001ad,0x6c63636f,0x64656475,0x00000000,0x00040005,0x000001ae,0x6e756f62,0x00006563, + 0x00030005,0x000001b0,0x00006f6c,0x00030005,0x000001b1,0x00637273,0x00040005,0x000001b6, + 0x61726170,0x0000006d,0x00030005,0x000001be,0x00006968,0x00030005,0x000001c0,0x00000069, + 0x00030005,0x000001c9,0x00000074,0x00040005,0x000001cf,0x6c676e61,0x00000065,0x00040005, + 0x000001d7,0x7366666f,0x00007465,0x00030005,0x000001e1,0x00000071,0x00040005,0x000001e7, + 0x6e656573,0x00000000,0x00040005,0x000001f1,0x61726170,0x0000006d,0x00030005,0x000001f4, + 0x00000079,0x00030005,0x000001fd,0x00000076,0x00040005,0x000001fe,0x61726170,0x0000006d, + 0x00030005,0x00000203,0x00007676,0x00040005,0x0000020d,0x69736f63,0x0000656e,0x00050005, + 0x00000214,0x7261656e,0x6168735f,0x00006572,0x00030005,0x0000021e,0x00000077,0x00040005, + 0x0000022d,0x61726170,0x0000006d,0x00050005,0x0000023e,0x746e6f63,0x74736172,0x00000000, + 0x00050005,0x00000246,0x5f746f6e,0x74616c66,0x00000000,0x00030005,0x0000024b,0x00006f61, + 0x00040005,0x00000261,0x7065656b,0x00000000,0x00040005,0x00000274,0x61726170,0x0000006d, + 0x00040005,0x00000276,0x61726170,0x0000006d,0x00030047,0x00000053,0x00000002,0x00050048, + 0x00000053,0x00000000,0x00000023,0x00000000,0x00050048,0x00000053,0x00000001,0x00000023, + 0x00000008,0x00050048,0x00000053,0x00000002,0x00000023,0x00000010,0x00050048,0x00000053, + 0x00000003,0x00000023,0x00000020,0x00040047,0x0000007d,0x00000021,0x00000000,0x00040047, + 0x0000007d,0x00000022,0x00000000,0x00040047,0x000000a9,0x0000000b,0x0000001c,0x00030047, + 0x000000e9,0x00000019,0x00040047,0x000000e9,0x00000021,0x00000002,0x00040047,0x000000e9, + 0x00000022,0x00000000,0x00040047,0x000001b1,0x00000021,0x00000001,0x00040047,0x000001b1, + 0x00000022,0x00000000,0x00040047,0x00000280,0x0000000b,0x00000019,0x00020013,0x00000002, + 0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040020,0x00000007, + 0x00000007,0x00000006,0x00020014,0x00000008,0x00040021,0x00000009,0x00000008,0x00000007, + 0x00040017,0x0000000d,0x00000006,0x00000003,0x00040020,0x0000000e,0x00000007,0x0000000d, + 0x00040021,0x0000000f,0x0000000d,0x0000000e,0x00040021,0x00000013,0x00000006,0x00000007, + 0x00040015,0x00000017,0x00000020,0x00000001,0x00040017,0x00000018,0x00000017,0x00000002, + 0x00040020,0x00000019,0x00000007,0x00000018,0x00040021,0x0000001a,0x0000000d,0x00000019, + 0x00040015,0x0000001f,0x00000020,0x00000000,0x0004002b,0x0000001f,0x00000021,0x7f800000, + 0x0004002b,0x0000001f,0x00000027,0x00000000,0x0004002b,0x00000006,0x00000030,0x00000000, + 0x0004002b,0x0000001f,0x00000035,0x00000001,0x0004002b,0x0000001f,0x00000042,0x00000002, + 0x00040017,0x00000051,0x00000006,0x00000002,0x00040017,0x00000052,0x00000006,0x00000004, + 0x0006001e,0x00000053,0x00000051,0x00000018,0x00000052,0x00000052,0x00040020,0x00000054, + 0x00000009,0x00000053,0x0004003b,0x00000054,0x00000055,0x00000009,0x0004002b,0x00000017, + 0x00000056,0x00000003,0x0004002b,0x0000001f,0x00000057,0x00000003,0x00040020,0x00000058, + 0x00000009,0x00000006,0x0004002b,0x00000017,0x0000005c,0x00000001,0x0004002b,0x00000017, + 0x0000005e,0x00000000,0x0004002b,0x00000006,0x00000062,0x3f800000,0x0004002b,0x00000017, + 0x00000065,0x00000002,0x0004002b,0x00000006,0x0000006c,0x33d6bf95,0x0005002c,0x00000018, + 0x00000072,0x0000005e,0x0000005e,0x00040020,0x00000073,0x00000009,0x00000018,0x00090019, + 0x0000007a,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000, + 0x0003001b,0x0000007b,0x0000007a,0x00040020,0x0000007c,0x00000000,0x0000007b,0x0004003b, + 0x0000007c,0x0000007d,0x00000000,0x00040020,0x00000085,0x00000007,0x00000051,0x0004002b, + 0x00000006,0x00000089,0x3f000000,0x00040020,0x0000008c,0x00000009,0x00000051,0x0004002b, + 0x00000006,0x00000090,0x40000000,0x00040017,0x000000a7,0x0000001f,0x00000003,0x00040020, + 0x000000a8,0x00000001,0x000000a7,0x0004003b,0x000000a8,0x000000a9,0x00000001,0x00040017, + 0x000000aa,0x0000001f,0x00000002,0x00040020,0x000000ae,0x00000007,0x00000017,0x00040020, + 0x000000b1,0x00000009,0x00000017,0x00090019,0x000000e7,0x00000006,0x00000001,0x00000000, + 0x00000000,0x00000000,0x00000002,0x00000002,0x00040020,0x000000e8,0x00000000,0x000000e7, + 0x0004003b,0x000000e8,0x000000e9,0x00000000,0x0007002c,0x00000052,0x000000ec,0x00000030, + 0x00000030,0x00000030,0x00000062,0x0005002c,0x00000018,0x000000f0,0x0000005c,0x0000005e, + 0x0005002c,0x00000018,0x000000fb,0x0000005e,0x0000005c,0x0004002b,0x00000006,0x0000017a, + 0x3b83126f,0x0004002b,0x00000006,0x0000017b,0x3ca3d70a,0x0004002b,0x00000006,0x00000193, + 0x3dcccccd,0x0004002b,0x00000006,0x0000019a,0x4253ee82,0x0004002b,0x00000006,0x0000019b, + 0x3d897143,0x0004002b,0x00000006,0x000001a0,0x3bbf4590,0x0006002c,0x0000000d,0x000001af, + 0x00000030,0x00000030,0x00000030,0x0004003b,0x0000007c,0x000001b1,0x00000000,0x0004002b, + 0x00000006,0x000001b9,0x3e59b3d0,0x0004002b,0x00000006,0x000001ba,0x3f371759,0x0004002b, + 0x00000006,0x000001bb,0x3d93dd98,0x0006002c,0x0000000d,0x000001bc,0x000001b9,0x000001ba, + 0x000001bb,0x0004002b,0x00000017,0x000001c7,0x0000000c,0x0004002b,0x00000006,0x000001cd, + 0x41400000,0x0004002b,0x00000006,0x000001d0,0x40c90fdb,0x0004002b,0x00000006,0x000001d2, + 0x40e00000,0x0004002b,0x00000006,0x00000208,0x322bcc77,0x0004002b,0x00000006,0x00000215, + 0x3e19999a,0x0004002b,0x00000006,0x00000218,0x3ecccccd,0x0004002b,0x00000006,0x00000220, + 0x3e800000,0x0004002b,0x00000006,0x00000222,0x3f400000,0x0004002b,0x00000006,0x00000243, + 0x3d4ccccd,0x0004002b,0x00000006,0x00000247,0x3d23d70a,0x0004002b,0x00000006,0x00000248, + 0x3e23d70a,0x0004002b,0x00000006,0x00000254,0x3f19999a,0x0004002b,0x0000001f,0x0000027f, + 0x00000008,0x0006002c,0x000000a7,0x00000280,0x0000027f,0x0000027f,0x00000035,0x00050036, + 0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000019, + 0x000000a6,0x00000007,0x0004003b,0x00000007,0x000000c1,0x00000007,0x0004003b,0x00000007, + 0x000000c4,0x00000007,0x0004003b,0x0000000e,0x000000c7,0x00000007,0x0004003b,0x00000019, + 0x000000c8,0x00000007,0x0004003b,0x0000000e,0x000000ee,0x00000007,0x0004003b,0x00000019, + 0x000000f2,0x00000007,0x0004003b,0x0000000e,0x000000f4,0x00000007,0x0004003b,0x00000019, + 0x000000f7,0x00000007,0x0004003b,0x0000000e,0x000000f9,0x00000007,0x0004003b,0x00000019, + 0x000000fd,0x00000007,0x0004003b,0x0000000e,0x000000ff,0x00000007,0x0004003b,0x00000019, + 0x00000102,0x00000007,0x0004003b,0x0000000e,0x00000104,0x00000007,0x0004003b,0x0000000e, + 0x00000112,0x00000007,0x0004003b,0x0000000e,0x0000011d,0x00000007,0x0004003b,0x0000000e, + 0x0000012b,0x00000007,0x0004003b,0x0000000e,0x00000136,0x00000007,0x0004003b,0x00000007, + 0x0000013b,0x00000007,0x0004003b,0x00000007,0x00000143,0x00000007,0x0004003b,0x00000007, + 0x0000014c,0x00000007,0x0004003b,0x00000007,0x00000160,0x00000007,0x0004003b,0x00000007, + 0x00000179,0x00000007,0x0004003b,0x00000007,0x00000186,0x00000007,0x0004003b,0x00000007, + 0x00000199,0x00000007,0x0004003b,0x00000007,0x000001a9,0x00000007,0x0004003b,0x00000007, + 0x000001ad,0x00000007,0x0004003b,0x0000000e,0x000001ae,0x00000007,0x0004003b,0x00000007, + 0x000001b0,0x00000007,0x0004003b,0x0000000e,0x000001b6,0x00000007,0x0004003b,0x00000007, + 0x000001be,0x00000007,0x0004003b,0x000000ae,0x000001c0,0x00000007,0x0004003b,0x00000007, + 0x000001c9,0x00000007,0x0004003b,0x00000007,0x000001cf,0x00000007,0x0004003b,0x00000085, + 0x000001d7,0x00000007,0x0004003b,0x00000019,0x000001e1,0x00000007,0x0004003b,0x0000000e, + 0x000001e7,0x00000007,0x0004003b,0x0000000e,0x000001f1,0x00000007,0x0004003b,0x00000007, + 0x000001f4,0x00000007,0x0004003b,0x0000000e,0x000001fd,0x00000007,0x0004003b,0x00000019, + 0x000001fe,0x00000007,0x0004003b,0x00000007,0x00000203,0x00000007,0x0004003b,0x00000007, + 0x0000020d,0x00000007,0x0004003b,0x00000007,0x00000214,0x00000007,0x0004003b,0x00000007, + 0x0000021e,0x00000007,0x0004003b,0x00000007,0x0000022d,0x00000007,0x0004003b,0x00000007, + 0x0000023e,0x00000007,0x0004003b,0x00000007,0x00000246,0x00000007,0x0004003b,0x00000007, + 0x0000024b,0x00000007,0x0004003b,0x00000007,0x00000261,0x00000007,0x0004003b,0x0000000e, + 0x00000274,0x00000007,0x0004003b,0x00000007,0x00000276,0x00000007,0x0004003d,0x000000a7, + 0x000000ab,0x000000a9,0x0007004f,0x000000aa,0x000000ac,0x000000ab,0x000000ab,0x00000000, + 0x00000001,0x0004007c,0x00000018,0x000000ad,0x000000ac,0x0003003e,0x000000a6,0x000000ad, + 0x00050041,0x000000ae,0x000000af,0x000000a6,0x00000027,0x0004003d,0x00000017,0x000000b0, + 0x000000af,0x00060041,0x000000b1,0x000000b2,0x00000055,0x0000005c,0x00000027,0x0004003d, + 0x00000017,0x000000b3,0x000000b2,0x000500af,0x00000008,0x000000b4,0x000000b0,0x000000b3, + 0x000400a8,0x00000008,0x000000b5,0x000000b4,0x000300f7,0x000000b7,0x00000000,0x000400fa, + 0x000000b5,0x000000b6,0x000000b7,0x000200f8,0x000000b6,0x00050041,0x000000ae,0x000000b8, + 0x000000a6,0x00000035,0x0004003d,0x00000017,0x000000b9,0x000000b8,0x00060041,0x000000b1, + 0x000000ba,0x00000055,0x0000005c,0x00000035,0x0004003d,0x00000017,0x000000bb,0x000000ba, + 0x000500af,0x00000008,0x000000bc,0x000000b9,0x000000bb,0x000200f9,0x000000b7,0x000200f8, + 0x000000b7,0x000700f5,0x00000008,0x000000bd,0x000000b4,0x00000005,0x000000bc,0x000000b6, + 0x000300f7,0x000000bf,0x00000000,0x000400fa,0x000000bd,0x000000be,0x000000bf,0x000200f8, + 0x000000be,0x000100fd,0x000200f8,0x000000bf,0x00060041,0x00000058,0x000000c2,0x00000055, + 0x00000056,0x00000027,0x0004003d,0x00000006,0x000000c3,0x000000c2,0x0003003e,0x000000c1, + 0x000000c3,0x00060041,0x00000058,0x000000c5,0x00000055,0x00000056,0x00000042,0x0004003d, + 0x00000006,0x000000c6,0x000000c5,0x0003003e,0x000000c4,0x000000c6,0x0004003d,0x00000018, + 0x000000c9,0x000000a6,0x0003003e,0x000000c8,0x000000c9,0x00050039,0x0000000d,0x000000ca, + 0x0000001c,0x000000c8,0x0003003e,0x000000c7,0x000000ca,0x00050041,0x00000007,0x000000cb, + 0x000000c7,0x00000042,0x0004003d,0x00000006,0x000000cc,0x000000cb,0x000500ba,0x00000008, + 0x000000cd,0x000000cc,0x00000030,0x000400a8,0x00000008,0x000000ce,0x000000cd,0x000400a8, + 0x00000008,0x000000cf,0x000000ce,0x000300f7,0x000000d1,0x00000000,0x000400fa,0x000000cf, + 0x000000d0,0x000000d1,0x000200f8,0x000000d0,0x00050041,0x00000007,0x000000d2,0x000000c7, + 0x00000042,0x0004003d,0x00000006,0x000000d3,0x000000d2,0x0004003d,0x00000006,0x000000d4, + 0x000000c4,0x000500be,0x00000008,0x000000d5,0x000000d3,0x000000d4,0x000200f9,0x000000d1, + 0x000200f8,0x000000d1,0x000700f5,0x00000008,0x000000d6,0x000000ce,0x000000bf,0x000000d5, + 0x000000d0,0x000400a8,0x00000008,0x000000d7,0x000000d6,0x000300f7,0x000000d9,0x00000000, + 0x000400fa,0x000000d7,0x000000d8,0x000000d9,0x000200f8,0x000000d8,0x00050041,0x00000007, + 0x000000da,0x000000c7,0x00000042,0x0004003d,0x00000006,0x000000db,0x000000da,0x0004009d, + 0x00000008,0x000000dc,0x000000db,0x000200f9,0x000000d9,0x000200f8,0x000000d9,0x000700f5, + 0x00000008,0x000000dd,0x000000d6,0x000000d1,0x000000dc,0x000000d8,0x000400a8,0x00000008, + 0x000000de,0x000000dd,0x000300f7,0x000000e0,0x00000000,0x000400fa,0x000000de,0x000000df, + 0x000000e0,0x000200f8,0x000000df,0x00050041,0x00000007,0x000000e1,0x000000c7,0x00000042, + 0x0004003d,0x00000006,0x000000e2,0x000000e1,0x0004009c,0x00000008,0x000000e3,0x000000e2, + 0x000200f9,0x000000e0,0x000200f8,0x000000e0,0x000700f5,0x00000008,0x000000e4,0x000000dd, + 0x000000d9,0x000000e3,0x000000df,0x000300f7,0x000000e6,0x00000000,0x000400fa,0x000000e4, + 0x000000e5,0x000000e6,0x000200f8,0x000000e5,0x0004003d,0x000000e7,0x000000ea,0x000000e9, + 0x0004003d,0x00000018,0x000000eb,0x000000a6,0x00040063,0x000000ea,0x000000eb,0x000000ec, + 0x000100fd,0x000200f8,0x000000e6,0x0004003d,0x00000018,0x000000ef,0x000000a6,0x00050082, + 0x00000018,0x000000f1,0x000000ef,0x000000f0,0x0003003e,0x000000f2,0x000000f1,0x00050039, + 0x0000000d,0x000000f3,0x0000001c,0x000000f2,0x0003003e,0x000000ee,0x000000f3,0x0004003d, + 0x00000018,0x000000f5,0x000000a6,0x00050080,0x00000018,0x000000f6,0x000000f5,0x000000f0, + 0x0003003e,0x000000f7,0x000000f6,0x00050039,0x0000000d,0x000000f8,0x0000001c,0x000000f7, + 0x0003003e,0x000000f4,0x000000f8,0x0004003d,0x00000018,0x000000fa,0x000000a6,0x00050082, + 0x00000018,0x000000fc,0x000000fa,0x000000fb,0x0003003e,0x000000fd,0x000000fc,0x00050039, + 0x0000000d,0x000000fe,0x0000001c,0x000000fd,0x0003003e,0x000000f9,0x000000fe,0x0004003d, + 0x00000018,0x00000100,0x000000a6,0x00050080,0x00000018,0x00000101,0x00000100,0x000000fb, + 0x0003003e,0x00000102,0x00000101,0x00050039,0x0000000d,0x00000103,0x0000001c,0x00000102, + 0x0003003e,0x000000ff,0x00000103,0x00050041,0x00000007,0x00000105,0x000000f4,0x00000042, + 0x0004003d,0x00000006,0x00000106,0x00000105,0x00050041,0x00000007,0x00000107,0x000000c7, + 0x00000042,0x0004003d,0x00000006,0x00000108,0x00000107,0x00050083,0x00000006,0x00000109, + 0x00000106,0x00000108,0x0006000c,0x00000006,0x0000010a,0x00000001,0x00000004,0x00000109, + 0x00050041,0x00000007,0x0000010b,0x000000c7,0x00000042,0x0004003d,0x00000006,0x0000010c, + 0x0000010b,0x00050041,0x00000007,0x0000010d,0x000000ee,0x00000042,0x0004003d,0x00000006, + 0x0000010e,0x0000010d,0x00050083,0x00000006,0x0000010f,0x0000010c,0x0000010e,0x0006000c, + 0x00000006,0x00000110,0x00000001,0x00000004,0x0000010f,0x000500b8,0x00000008,0x00000111, + 0x0000010a,0x00000110,0x000300f7,0x00000114,0x00000000,0x000400fa,0x00000111,0x00000113, + 0x00000118,0x000200f8,0x00000113,0x0004003d,0x0000000d,0x00000115,0x000000f4,0x0004003d, + 0x0000000d,0x00000116,0x000000c7,0x00050083,0x0000000d,0x00000117,0x00000115,0x00000116, + 0x0003003e,0x00000112,0x00000117,0x000200f9,0x00000114,0x000200f8,0x00000118,0x0004003d, + 0x0000000d,0x00000119,0x000000c7,0x0004003d,0x0000000d,0x0000011a,0x000000ee,0x00050083, + 0x0000000d,0x0000011b,0x00000119,0x0000011a,0x0003003e,0x00000112,0x0000011b,0x000200f9, + 0x00000114,0x000200f8,0x00000114,0x0004003d,0x0000000d,0x0000011c,0x00000112,0x0003003e, + 0x00000104,0x0000011c,0x00050041,0x00000007,0x0000011e,0x000000ff,0x00000042,0x0004003d, + 0x00000006,0x0000011f,0x0000011e,0x00050041,0x00000007,0x00000120,0x000000c7,0x00000042, + 0x0004003d,0x00000006,0x00000121,0x00000120,0x00050083,0x00000006,0x00000122,0x0000011f, + 0x00000121,0x0006000c,0x00000006,0x00000123,0x00000001,0x00000004,0x00000122,0x00050041, + 0x00000007,0x00000124,0x000000c7,0x00000042,0x0004003d,0x00000006,0x00000125,0x00000124, + 0x00050041,0x00000007,0x00000126,0x000000f9,0x00000042,0x0004003d,0x00000006,0x00000127, + 0x00000126,0x00050083,0x00000006,0x00000128,0x00000125,0x00000127,0x0006000c,0x00000006, + 0x00000129,0x00000001,0x00000004,0x00000128,0x000500b8,0x00000008,0x0000012a,0x00000123, + 0x00000129,0x000300f7,0x0000012d,0x00000000,0x000400fa,0x0000012a,0x0000012c,0x00000131, + 0x000200f8,0x0000012c,0x0004003d,0x0000000d,0x0000012e,0x000000ff,0x0004003d,0x0000000d, + 0x0000012f,0x000000c7,0x00050083,0x0000000d,0x00000130,0x0000012e,0x0000012f,0x0003003e, + 0x0000012b,0x00000130,0x000200f9,0x0000012d,0x000200f8,0x00000131,0x0004003d,0x0000000d, + 0x00000132,0x000000c7,0x0004003d,0x0000000d,0x00000133,0x000000f9,0x00050083,0x0000000d, + 0x00000134,0x00000132,0x00000133,0x0003003e,0x0000012b,0x00000134,0x000200f9,0x0000012d, + 0x000200f8,0x0000012d,0x0004003d,0x0000000d,0x00000135,0x0000012b,0x0003003e,0x0000011d, + 0x00000135,0x0004003d,0x0000000d,0x00000137,0x00000104,0x0004003d,0x0000000d,0x00000138, + 0x0000011d,0x0007000c,0x0000000d,0x00000139,0x00000001,0x00000044,0x00000137,0x00000138, + 0x0006000c,0x0000000d,0x0000013a,0x00000001,0x00000045,0x00000139,0x0003003e,0x00000136, + 0x0000013a,0x00050041,0x00000007,0x0000013c,0x00000136,0x00000027,0x0004003d,0x00000006, + 0x0000013d,0x0000013c,0x0003003e,0x0000013b,0x0000013d,0x00050039,0x00000008,0x0000013e, + 0x0000000b,0x0000013b,0x000400a8,0x00000008,0x0000013f,0x0000013e,0x000400a8,0x00000008, + 0x00000140,0x0000013f,0x000300f7,0x00000142,0x00000000,0x000400fa,0x00000140,0x00000141, + 0x00000142,0x000200f8,0x00000141,0x00050041,0x00000007,0x00000144,0x00000136,0x00000035, + 0x0004003d,0x00000006,0x00000145,0x00000144,0x0003003e,0x00000143,0x00000145,0x00050039, + 0x00000008,0x00000146,0x0000000b,0x00000143,0x000400a8,0x00000008,0x00000147,0x00000146, + 0x000200f9,0x00000142,0x000200f8,0x00000142,0x000700f5,0x00000008,0x00000148,0x0000013f, + 0x0000012d,0x00000147,0x00000141,0x000400a8,0x00000008,0x00000149,0x00000148,0x000300f7, + 0x0000014b,0x00000000,0x000400fa,0x00000149,0x0000014a,0x0000014b,0x000200f8,0x0000014a, + 0x00050041,0x00000007,0x0000014d,0x00000136,0x00000042,0x0004003d,0x00000006,0x0000014e, + 0x0000014d,0x0003003e,0x0000014c,0x0000014e,0x00050039,0x00000008,0x0000014f,0x0000000b, + 0x0000014c,0x000400a8,0x00000008,0x00000150,0x0000014f,0x000200f9,0x0000014b,0x000200f8, + 0x0000014b,0x000700f5,0x00000008,0x00000151,0x00000148,0x00000142,0x00000150,0x0000014a, + 0x000300f7,0x00000153,0x00000000,0x000400fa,0x00000151,0x00000152,0x00000153,0x000200f8, + 0x00000152,0x0004003d,0x000000e7,0x00000154,0x000000e9,0x0004003d,0x00000018,0x00000155, + 0x000000a6,0x00040063,0x00000154,0x00000155,0x000000ec,0x000100fd,0x000200f8,0x00000153, + 0x0004003d,0x0000000d,0x00000157,0x00000136,0x0004003d,0x0000000d,0x00000158,0x000000c7, + 0x0004007f,0x0000000d,0x00000159,0x00000158,0x00050094,0x00000006,0x0000015a,0x00000157, + 0x00000159,0x000500b8,0x00000008,0x0000015b,0x0000015a,0x00000030,0x000300f7,0x0000015d, + 0x00000000,0x000400fa,0x0000015b,0x0000015c,0x0000015d,0x000200f8,0x0000015c,0x0004003d, + 0x0000000d,0x0000015e,0x00000136,0x0004007f,0x0000000d,0x0000015f,0x0000015e,0x0003003e, + 0x00000136,0x0000015f,0x000200f9,0x0000015d,0x000200f8,0x0000015d,0x00050041,0x00000007, + 0x00000161,0x000000ee,0x00000042,0x0004003d,0x00000006,0x00000162,0x00000161,0x00050041, + 0x00000007,0x00000163,0x000000f4,0x00000042,0x0004003d,0x00000006,0x00000164,0x00000163, + 0x00050081,0x00000006,0x00000165,0x00000162,0x00000164,0x00050041,0x00000007,0x00000166, + 0x000000c7,0x00000042,0x0004003d,0x00000006,0x00000167,0x00000166,0x00050085,0x00000006, + 0x00000168,0x00000090,0x00000167,0x00050083,0x00000006,0x00000169,0x00000165,0x00000168, + 0x0006000c,0x00000006,0x0000016a,0x00000001,0x00000004,0x00000169,0x00050041,0x00000007, + 0x0000016b,0x000000ff,0x00000042,0x0004003d,0x00000006,0x0000016c,0x0000016b,0x00050041, + 0x00000007,0x0000016d,0x000000f9,0x00000042,0x0004003d,0x00000006,0x0000016e,0x0000016d, + 0x00050081,0x00000006,0x0000016f,0x0000016c,0x0000016e,0x00050041,0x00000007,0x00000170, + 0x000000c7,0x00000042,0x0004003d,0x00000006,0x00000171,0x00000170,0x00050085,0x00000006, + 0x00000172,0x00000090,0x00000171,0x00050083,0x00000006,0x00000173,0x0000016f,0x00000172, + 0x0006000c,0x00000006,0x00000174,0x00000001,0x00000004,0x00000173,0x00050081,0x00000006, + 0x00000175,0x0000016a,0x00000174,0x00050041,0x00000007,0x00000176,0x000000c7,0x00000042, + 0x0004003d,0x00000006,0x00000177,0x00000176,0x00050088,0x00000006,0x00000178,0x00000175, + 0x00000177,0x0003003e,0x00000160,0x00000178,0x0004003d,0x00000006,0x0000017c,0x00000160, + 0x0008000c,0x00000006,0x0000017d,0x00000001,0x00000031,0x0000017a,0x0000017b,0x0000017c, + 0x00050083,0x00000006,0x0000017e,0x00000062,0x0000017d,0x0003003e,0x00000179,0x0000017e, + 0x0004003d,0x00000006,0x0000017f,0x00000179,0x000500bc,0x00000008,0x00000180,0x0000017f, + 0x00000030,0x000300f7,0x00000182,0x00000000,0x000400fa,0x00000180,0x00000181,0x00000182, + 0x000200f8,0x00000181,0x0004003d,0x000000e7,0x00000183,0x000000e9,0x0004003d,0x00000018, + 0x00000184,0x000000a6,0x00040063,0x00000183,0x00000184,0x000000ec,0x000100fd,0x000200f8, + 0x00000182,0x0004003d,0x00000006,0x00000187,0x000000c1,0x00050041,0x00000007,0x00000188, + 0x000000c7,0x00000042,0x0004003d,0x00000006,0x00000189,0x00000188,0x00060041,0x00000058, + 0x0000018a,0x00000055,0x00000065,0x00000057,0x0004003d,0x00000006,0x0000018b,0x0000018a, + 0x00050085,0x00000006,0x0000018c,0x00000189,0x0000018b,0x00050088,0x00000006,0x0000018d, + 0x00000187,0x0000018c,0x00050085,0x00000006,0x0000018e,0x0000018d,0x00000089,0x00060041, + 0x000000b1,0x0000018f,0x00000055,0x0000005c,0x00000035,0x0004003d,0x00000017,0x00000190, + 0x0000018f,0x0004006f,0x00000006,0x00000191,0x00000190,0x00050085,0x00000006,0x00000192, + 0x0000018e,0x00000191,0x00060041,0x000000b1,0x00000194,0x00000055,0x0000005c,0x00000035, + 0x0004003d,0x00000017,0x00000195,0x00000194,0x0004006f,0x00000006,0x00000196,0x00000195, + 0x00050085,0x00000006,0x00000197,0x00000193,0x00000196,0x0008000c,0x00000006,0x00000198, + 0x00000001,0x0000002b,0x00000192,0x00000090,0x00000197,0x0003003e,0x00000186,0x00000198, + 0x00050041,0x000000ae,0x0000019c,0x000000a6,0x00000027,0x0004003d,0x00000017,0x0000019d, + 0x0000019c,0x0004006f,0x00000006,0x0000019e,0x0000019d,0x00050085,0x00000006,0x0000019f, + 0x0000019b,0x0000019e,0x00050041,0x000000ae,0x000001a1,0x000000a6,0x00000035,0x0004003d, + 0x00000017,0x000001a2,0x000001a1,0x0004006f,0x00000006,0x000001a3,0x000001a2,0x00050085, + 0x00000006,0x000001a4,0x000001a0,0x000001a3,0x00050081,0x00000006,0x000001a5,0x0000019f, + 0x000001a4,0x0006000c,0x00000006,0x000001a6,0x00000001,0x0000000a,0x000001a5,0x00050085, + 0x00000006,0x000001a7,0x0000019a,0x000001a6,0x0006000c,0x00000006,0x000001a8,0x00000001, + 0x0000000a,0x000001a7,0x0003003e,0x00000199,0x000001a8,0x0004003d,0x00000006,0x000001aa, + 0x000000c1,0x0004003d,0x00000006,0x000001ab,0x000000c1,0x00050085,0x00000006,0x000001ac, + 0x000001aa,0x000001ab,0x0003003e,0x000001a9,0x000001ac,0x0003003e,0x000001ad,0x00000030, + 0x0003003e,0x000001ae,0x000001af,0x0004003d,0x0000007b,0x000001b2,0x000001b1,0x0004003d, + 0x00000018,0x000001b3,0x000000a6,0x00040064,0x0000007a,0x000001b4,0x000001b2,0x0007005f, + 0x00000052,0x000001b5,0x000001b4,0x000001b3,0x00000002,0x0000005e,0x0008004f,0x0000000d, + 0x000001b7,0x000001b5,0x000001b5,0x00000000,0x00000001,0x00000002,0x0003003e,0x000001b6, + 0x000001b7,0x00050039,0x0000000d,0x000001b8,0x00000011,0x000001b6,0x00050094,0x00000006, + 0x000001bd,0x000001b8,0x000001bc,0x0003003e,0x000001b0,0x000001bd,0x0004003d,0x00000006, + 0x000001bf,0x000001b0,0x0003003e,0x000001be,0x000001bf,0x0003003e,0x000001c0,0x0000005e, + 0x000200f9,0x000001c1,0x000200f8,0x000001c1,0x000400f6,0x000001c3,0x000001c4,0x00000000, + 0x000200f9,0x000001c5,0x000200f8,0x000001c5,0x0004003d,0x00000017,0x000001c6,0x000001c0, + 0x000500b1,0x00000008,0x000001c8,0x000001c6,0x000001c7,0x000400fa,0x000001c8,0x000001c2, + 0x000001c3,0x000200f8,0x000001c2,0x0004003d,0x00000017,0x000001ca,0x000001c0,0x0004006f, + 0x00000006,0x000001cb,0x000001ca,0x00050081,0x00000006,0x000001cc,0x000001cb,0x00000089, + 0x00050088,0x00000006,0x000001ce,0x000001cc,0x000001cd,0x0003003e,0x000001c9,0x000001ce, + 0x0004003d,0x00000006,0x000001d1,0x000001c9,0x00050085,0x00000006,0x000001d3,0x000001d1, + 0x000001d2,0x0004003d,0x00000006,0x000001d4,0x00000199,0x00050081,0x00000006,0x000001d5, + 0x000001d3,0x000001d4,0x00050085,0x00000006,0x000001d6,0x000001d0,0x000001d5,0x0003003e, + 0x000001cf,0x000001d6,0x0004003d,0x00000006,0x000001d8,0x000001cf,0x0006000c,0x00000006, + 0x000001d9,0x00000001,0x0000000e,0x000001d8,0x0004003d,0x00000006,0x000001da,0x000001cf, + 0x0006000c,0x00000006,0x000001db,0x00000001,0x0000000d,0x000001da,0x00050050,0x00000051, + 0x000001dc,0x000001d9,0x000001db,0x0004003d,0x00000006,0x000001dd,0x00000186,0x0004003d, + 0x00000006,0x000001de,0x000001c9,0x00050085,0x00000006,0x000001df,0x000001dd,0x000001de, + 0x0005008e,0x00000051,0x000001e0,0x000001dc,0x000001df,0x0003003e,0x000001d7,0x000001e0, + 0x0004003d,0x00000018,0x000001e2,0x000000a6,0x0004003d,0x00000051,0x000001e3,0x000001d7, + 0x0006000c,0x00000051,0x000001e4,0x00000001,0x00000001,0x000001e3,0x0004006e,0x00000018, + 0x000001e5,0x000001e4,0x00050080,0x00000018,0x000001e6,0x000001e2,0x000001e5,0x0003003e, + 0x000001e1,0x000001e6,0x0004003d,0x0000007b,0x000001e8,0x000001b1,0x0004003d,0x00000018, + 0x000001e9,0x000001e1,0x00050041,0x00000073,0x000001ea,0x00000055,0x0000005c,0x0004003d, + 0x00000018,0x000001eb,0x000001ea,0x00050050,0x00000018,0x000001ec,0x0000005c,0x0000005c, + 0x00050082,0x00000018,0x000001ed,0x000001eb,0x000001ec,0x0008000c,0x00000018,0x000001ee, + 0x00000001,0x0000002d,0x000001e9,0x00000072,0x000001ed,0x00040064,0x0000007a,0x000001ef, + 0x000001e8,0x0007005f,0x00000052,0x000001f0,0x000001ef,0x000001ee,0x00000002,0x0000005e, + 0x0008004f,0x0000000d,0x000001f2,0x000001f0,0x000001f0,0x00000000,0x00000001,0x00000002, + 0x0003003e,0x000001f1,0x000001f2,0x00050039,0x0000000d,0x000001f3,0x00000011,0x000001f1, + 0x0003003e,0x000001e7,0x000001f3,0x0004003d,0x0000000d,0x000001f5,0x000001e7,0x00050094, + 0x00000006,0x000001f6,0x000001f5,0x000001bc,0x0003003e,0x000001f4,0x000001f6,0x0004003d, + 0x00000006,0x000001f7,0x000001b0,0x0004003d,0x00000006,0x000001f8,0x000001f4,0x0007000c, + 0x00000006,0x000001f9,0x00000001,0x00000025,0x000001f7,0x000001f8,0x0003003e,0x000001b0, + 0x000001f9,0x0004003d,0x00000006,0x000001fa,0x000001be,0x0004003d,0x00000006,0x000001fb, + 0x000001f4,0x0007000c,0x00000006,0x000001fc,0x00000001,0x00000028,0x000001fa,0x000001fb, + 0x0003003e,0x000001be,0x000001fc,0x0004003d,0x00000018,0x000001ff,0x000001e1,0x0003003e, + 0x000001fe,0x000001ff,0x00050039,0x0000000d,0x00000200,0x0000001c,0x000001fe,0x0004003d, + 0x0000000d,0x00000201,0x000000c7,0x00050083,0x0000000d,0x00000202,0x00000200,0x00000201, + 0x0003003e,0x000001fd,0x00000202,0x0004003d,0x0000000d,0x00000204,0x000001fd,0x0004003d, + 0x0000000d,0x00000205,0x000001fd,0x00050094,0x00000006,0x00000206,0x00000204,0x00000205, + 0x0003003e,0x00000203,0x00000206,0x0004003d,0x00000006,0x00000207,0x00000203,0x000500b8, + 0x00000008,0x00000209,0x00000207,0x00000208,0x000300f7,0x0000020b,0x00000000,0x000400fa, + 0x00000209,0x0000020a,0x0000020b,0x000200f8,0x0000020a,0x000200f9,0x000001c4,0x000200f8, + 0x0000020b,0x0004003d,0x0000000d,0x0000020e,0x000001fd,0x0004003d,0x0000000d,0x0000020f, + 0x00000136,0x00050094,0x00000006,0x00000210,0x0000020e,0x0000020f,0x0004003d,0x00000006, + 0x00000211,0x00000203,0x0006000c,0x00000006,0x00000212,0x00000001,0x00000020,0x00000211, + 0x00050085,0x00000006,0x00000213,0x00000210,0x00000212,0x0003003e,0x0000020d,0x00000213, + 0x0004003d,0x00000006,0x00000216,0x000000c1,0x00050085,0x00000006,0x00000217,0x00000215, + 0x00000216,0x0004003d,0x00000006,0x00000219,0x000000c1,0x00050085,0x00000006,0x0000021a, + 0x00000218,0x00000219,0x0004003d,0x00000006,0x0000021b,0x00000203,0x0006000c,0x00000006, + 0x0000021c,0x00000001,0x0000001f,0x0000021b,0x0008000c,0x00000006,0x0000021d,0x00000001, + 0x00000031,0x00000217,0x0000021a,0x0000021c,0x0003003e,0x00000214,0x0000021d,0x0004003d, + 0x00000006,0x0000021f,0x0000020d,0x00050083,0x00000006,0x00000221,0x0000021f,0x00000220, + 0x00050088,0x00000006,0x00000223,0x00000221,0x00000222,0x0008000c,0x00000006,0x00000224, + 0x00000001,0x0000002b,0x00000223,0x00000030,0x00000062,0x0004003d,0x00000006,0x00000225, + 0x00000203,0x0004003d,0x00000006,0x00000226,0x000001a9,0x00050088,0x00000006,0x00000227, + 0x00000225,0x00000226,0x00050083,0x00000006,0x00000228,0x00000062,0x00000227,0x0008000c, + 0x00000006,0x00000229,0x00000001,0x0000002b,0x00000228,0x00000030,0x00000062,0x00050085, + 0x00000006,0x0000022a,0x00000224,0x00000229,0x0004003d,0x00000006,0x0000022b,0x00000214, + 0x00050085,0x00000006,0x0000022c,0x0000022a,0x0000022b,0x0003003e,0x0000021e,0x0000022c, + 0x0004003d,0x00000006,0x0000022e,0x0000021e,0x0003003e,0x0000022d,0x0000022e,0x00050039, + 0x00000008,0x0000022f,0x0000000b,0x0000022d,0x000400a8,0x00000008,0x00000230,0x0000022f, + 0x000300f7,0x00000232,0x00000000,0x000400fa,0x00000230,0x00000231,0x00000232,0x000200f8, + 0x00000231,0x000200f9,0x000001c4,0x000200f8,0x00000232,0x0004003d,0x00000006,0x00000234, + 0x0000021e,0x0004003d,0x00000006,0x00000235,0x000001ad,0x00050081,0x00000006,0x00000236, + 0x00000235,0x00000234,0x0003003e,0x000001ad,0x00000236,0x0004003d,0x00000006,0x00000237, + 0x0000021e,0x0004003d,0x0000000d,0x00000238,0x000001e7,0x0005008e,0x0000000d,0x00000239, + 0x00000238,0x00000237,0x0004003d,0x0000000d,0x0000023a,0x000001ae,0x00050081,0x0000000d, + 0x0000023b,0x0000023a,0x00000239,0x0003003e,0x000001ae,0x0000023b,0x000200f9,0x000001c4, + 0x000200f8,0x000001c4,0x0004003d,0x00000017,0x0000023c,0x000001c0,0x00050080,0x00000017, + 0x0000023d,0x0000023c,0x0000005c,0x0003003e,0x000001c0,0x0000023d,0x000200f9,0x000001c1, + 0x000200f8,0x000001c3,0x0004003d,0x00000006,0x0000023f,0x000001be,0x0004003d,0x00000006, + 0x00000240,0x000001b0,0x00050083,0x00000006,0x00000241,0x0000023f,0x00000240,0x0004003d, + 0x00000006,0x00000242,0x000001be,0x00050081,0x00000006,0x00000244,0x00000242,0x00000243, + 0x00050088,0x00000006,0x00000245,0x00000241,0x00000244,0x0003003e,0x0000023e,0x00000245, + 0x0004003d,0x00000006,0x00000249,0x0000023e,0x0008000c,0x00000006,0x0000024a,0x00000001, + 0x00000031,0x00000247,0x00000248,0x00000249,0x0003003e,0x00000246,0x0000024a,0x00060041, + 0x00000058,0x0000024c,0x00000055,0x00000056,0x00000035,0x0004003d,0x00000006,0x0000024d, + 0x0000024c,0x0004003d,0x00000006,0x0000024e,0x000001ad,0x00050085,0x00000006,0x0000024f, + 0x0000024d,0x0000024e,0x00050088,0x00000006,0x00000250,0x0000024f,0x000001cd,0x00050083, + 0x00000006,0x00000251,0x00000062,0x00000250,0x0008000c,0x00000006,0x00000252,0x00000001, + 0x0000002b,0x00000251,0x00000089,0x00000062,0x0003003e,0x0000024b,0x00000252,0x0004003d, + 0x00000006,0x00000253,0x0000024b,0x0004003d,0x00000006,0x00000255,0x000000c4,0x00050085, + 0x00000006,0x00000256,0x00000254,0x00000255,0x0004003d,0x00000006,0x00000257,0x000000c4, + 0x00050041,0x00000007,0x00000258,0x000000c7,0x00000042,0x0004003d,0x00000006,0x00000259, + 0x00000258,0x0008000c,0x00000006,0x0000025a,0x00000001,0x00000031,0x00000256,0x00000257, + 0x00000259,0x0008000c,0x00000006,0x0000025b,0x00000001,0x0000002e,0x00000253,0x00000062, + 0x0000025a,0x0003003e,0x0000024b,0x0000025b,0x0004003d,0x00000006,0x0000025c,0x0000024b, + 0x0004003d,0x00000006,0x0000025d,0x00000179,0x0004003d,0x00000006,0x0000025e,0x00000246, + 0x00050085,0x00000006,0x0000025f,0x0000025d,0x0000025e,0x0008000c,0x00000006,0x00000260, + 0x00000001,0x0000002e,0x00000062,0x0000025c,0x0000025f,0x0003003e,0x0000024b,0x00000260, + 0x0004003d,0x00000006,0x00000262,0x00000179,0x0004003d,0x00000006,0x00000263,0x00000246, + 0x00050085,0x00000006,0x00000264,0x00000262,0x00000263,0x0004003d,0x00000006,0x00000265, + 0x000000c4,0x00050085,0x00000006,0x00000266,0x00000254,0x00000265,0x0004003d,0x00000006, + 0x00000267,0x000000c4,0x00050041,0x00000007,0x00000268,0x000000c7,0x00000042,0x0004003d, + 0x00000006,0x00000269,0x00000268,0x0008000c,0x00000006,0x0000026a,0x00000001,0x00000031, + 0x00000266,0x00000267,0x00000269,0x00050083,0x00000006,0x0000026b,0x00000062,0x0000026a, + 0x00050085,0x00000006,0x0000026c,0x00000264,0x0000026b,0x0003003e,0x00000261,0x0000026c, + 0x0004003d,0x000000e7,0x0000026d,0x000000e9,0x0004003d,0x00000018,0x0000026e,0x000000a6, + 0x0004003d,0x0000000d,0x0000026f,0x000001ae,0x00060050,0x0000000d,0x00000270,0x000001cd, + 0x000001cd,0x000001cd,0x00050088,0x0000000d,0x00000271,0x0000026f,0x00000270,0x0004003d, + 0x00000006,0x00000272,0x00000261,0x0005008e,0x0000000d,0x00000273,0x00000271,0x00000272, + 0x0003003e,0x00000274,0x00000273,0x00050039,0x0000000d,0x00000275,0x00000011,0x00000274, + 0x0004003d,0x00000006,0x00000277,0x0000024b,0x0003003e,0x00000276,0x00000277,0x00050039, + 0x00000008,0x00000278,0x0000000b,0x00000276,0x0004003d,0x00000006,0x00000279,0x0000024b, + 0x000600a9,0x00000006,0x0000027a,0x00000278,0x00000279,0x00000062,0x00050051,0x00000006, + 0x0000027b,0x00000275,0x00000000,0x00050051,0x00000006,0x0000027c,0x00000275,0x00000001, + 0x00050051,0x00000006,0x0000027d,0x00000275,0x00000002,0x00070050,0x00000052,0x0000027e, + 0x0000027b,0x0000027c,0x0000027d,0x0000027a,0x00040063,0x0000026d,0x0000026e,0x0000027e, + 0x000100fd,0x00010038,0x00050036,0x00000008,0x0000000b,0x00000000,0x00000009,0x00030037, + 0x00000007,0x0000000a,0x000200f8,0x0000000c,0x0004003d,0x00000006,0x0000001e,0x0000000a, + 0x0004007c,0x0000001f,0x00000020,0x0000001e,0x000500c7,0x0000001f,0x00000022,0x00000020, + 0x00000021,0x000500ab,0x00000008,0x00000023,0x00000022,0x00000021,0x000200fe,0x00000023, + 0x00010038,0x00050036,0x0000000d,0x00000011,0x00000000,0x0000000f,0x00030037,0x0000000e, + 0x00000010,0x000200f8,0x00000012,0x0004003b,0x00000007,0x00000026,0x00000007,0x0004003b, + 0x00000007,0x0000002b,0x00000007,0x0004003b,0x00000007,0x00000034,0x00000007,0x0004003b, + 0x00000007,0x00000039,0x00000007,0x0004003b,0x00000007,0x00000041,0x00000007,0x0004003b, + 0x00000007,0x00000046,0x00000007,0x00050041,0x00000007,0x00000028,0x00000010,0x00000027, + 0x0004003d,0x00000006,0x00000029,0x00000028,0x0003003e,0x00000026,0x00000029,0x00050039, + 0x00000008,0x0000002a,0x0000000b,0x00000026,0x000300f7,0x0000002d,0x00000000,0x000400fa, + 0x0000002a,0x0000002c,0x00000032,0x000200f8,0x0000002c,0x00050041,0x00000007,0x0000002e, + 0x00000010,0x00000027,0x0004003d,0x00000006,0x0000002f,0x0000002e,0x0007000c,0x00000006, + 0x00000031,0x00000001,0x00000028,0x0000002f,0x00000030,0x0003003e,0x0000002b,0x00000031, + 0x000200f9,0x0000002d,0x000200f8,0x00000032,0x0003003e,0x0000002b,0x00000030,0x000200f9, + 0x0000002d,0x000200f8,0x0000002d,0x0004003d,0x00000006,0x00000033,0x0000002b,0x00050041, + 0x00000007,0x00000036,0x00000010,0x00000035,0x0004003d,0x00000006,0x00000037,0x00000036, + 0x0003003e,0x00000034,0x00000037,0x00050039,0x00000008,0x00000038,0x0000000b,0x00000034, + 0x000300f7,0x0000003b,0x00000000,0x000400fa,0x00000038,0x0000003a,0x0000003f,0x000200f8, + 0x0000003a,0x00050041,0x00000007,0x0000003c,0x00000010,0x00000035,0x0004003d,0x00000006, + 0x0000003d,0x0000003c,0x0007000c,0x00000006,0x0000003e,0x00000001,0x00000028,0x0000003d, + 0x00000030,0x0003003e,0x00000039,0x0000003e,0x000200f9,0x0000003b,0x000200f8,0x0000003f, + 0x0003003e,0x00000039,0x00000030,0x000200f9,0x0000003b,0x000200f8,0x0000003b,0x0004003d, + 0x00000006,0x00000040,0x00000039,0x00050041,0x00000007,0x00000043,0x00000010,0x00000042, + 0x0004003d,0x00000006,0x00000044,0x00000043,0x0003003e,0x00000041,0x00000044,0x00050039, + 0x00000008,0x00000045,0x0000000b,0x00000041,0x000300f7,0x00000048,0x00000000,0x000400fa, + 0x00000045,0x00000047,0x0000004c,0x000200f8,0x00000047,0x00050041,0x00000007,0x00000049, + 0x00000010,0x00000042,0x0004003d,0x00000006,0x0000004a,0x00000049,0x0007000c,0x00000006, + 0x0000004b,0x00000001,0x00000028,0x0000004a,0x00000030,0x0003003e,0x00000046,0x0000004b, + 0x000200f9,0x00000048,0x000200f8,0x0000004c,0x0003003e,0x00000046,0x00000030,0x000200f9, + 0x00000048,0x000200f8,0x00000048,0x0004003d,0x00000006,0x0000004d,0x00000046,0x00060050, + 0x0000000d,0x0000004e,0x00000033,0x00000040,0x0000004d,0x000200fe,0x0000004e,0x00010038, + 0x00050036,0x00000006,0x00000015,0x00000000,0x00000013,0x00030037,0x00000007,0x00000014, + 0x000200f8,0x00000016,0x00060041,0x00000058,0x00000059,0x00000055,0x00000056,0x00000057, + 0x0004003d,0x00000006,0x0000005a,0x00000059,0x0004006e,0x00000017,0x0000005b,0x0000005a, + 0x000500c7,0x00000017,0x0000005d,0x0000005b,0x0000005c,0x000500ab,0x00000008,0x0000005f, + 0x0000005d,0x0000005e,0x000300f7,0x00000061,0x00000000,0x000400fa,0x0000005f,0x00000060, + 0x00000061,0x000200f8,0x00000060,0x0004003d,0x00000006,0x00000063,0x00000014,0x00050083, + 0x00000006,0x00000064,0x00000062,0x00000063,0x0003003e,0x00000014,0x00000064,0x000200f9, + 0x00000061,0x000200f8,0x00000061,0x00060041,0x00000058,0x00000066,0x00000055,0x00000065, + 0x00000035,0x0004003d,0x00000006,0x00000067,0x00000066,0x0004003d,0x00000006,0x00000068, + 0x00000014,0x00060041,0x00000058,0x00000069,0x00000055,0x00000065,0x00000027,0x0004003d, + 0x00000006,0x0000006a,0x00000069,0x00050083,0x00000006,0x0000006b,0x00000068,0x0000006a, + 0x0007000c,0x00000006,0x0000006d,0x00000001,0x00000028,0x0000006b,0x0000006c,0x00050088, + 0x00000006,0x0000006e,0x00000067,0x0000006d,0x000200fe,0x0000006e,0x00010038,0x00050036, + 0x0000000d,0x0000001c,0x00000000,0x0000001a,0x00030037,0x00000019,0x0000001b,0x000200f8, + 0x0000001d,0x0004003b,0x00000007,0x00000079,0x00000007,0x0004003b,0x00000007,0x00000082, + 0x00000007,0x0004003b,0x00000085,0x00000086,0x00000007,0x0004003d,0x00000018,0x00000071, + 0x0000001b,0x00050041,0x00000073,0x00000074,0x00000055,0x0000005c,0x0004003d,0x00000018, + 0x00000075,0x00000074,0x00050050,0x00000018,0x00000076,0x0000005c,0x0000005c,0x00050082, + 0x00000018,0x00000077,0x00000075,0x00000076,0x0008000c,0x00000018,0x00000078,0x00000001, + 0x0000002d,0x00000071,0x00000072,0x00000077,0x0003003e,0x0000001b,0x00000078,0x0004003d, + 0x0000007b,0x0000007e,0x0000007d,0x0004003d,0x00000018,0x0000007f,0x0000001b,0x00040064, + 0x0000007a,0x00000080,0x0000007e,0x0007005f,0x00000052,0x00000081,0x00000080,0x0000007f, + 0x00000002,0x0000005e,0x00050051,0x00000006,0x00000083,0x00000081,0x00000000,0x0003003e, + 0x00000082,0x00000083,0x00050039,0x00000006,0x00000084,0x00000015,0x00000082,0x0003003e, + 0x00000079,0x00000084,0x0004003d,0x00000018,0x00000087,0x0000001b,0x0004006f,0x00000051, + 0x00000088,0x00000087,0x00050050,0x00000051,0x0000008a,0x00000089,0x00000089,0x00050081, + 0x00000051,0x0000008b,0x00000088,0x0000008a,0x00050041,0x0000008c,0x0000008d,0x00000055, + 0x0000005e,0x0004003d,0x00000051,0x0000008e,0x0000008d,0x00050085,0x00000051,0x0000008f, + 0x0000008b,0x0000008e,0x0005008e,0x00000051,0x00000091,0x0000008f,0x00000090,0x00050050, + 0x00000051,0x00000092,0x00000062,0x00000062,0x00050083,0x00000051,0x00000093,0x00000091, + 0x00000092,0x0003003e,0x00000086,0x00000093,0x00050041,0x00000007,0x00000094,0x00000086, + 0x00000027,0x0004003d,0x00000006,0x00000095,0x00000094,0x00060041,0x00000058,0x00000096, + 0x00000055,0x00000065,0x00000042,0x0004003d,0x00000006,0x00000097,0x00000096,0x00050085, + 0x00000006,0x00000098,0x00000095,0x00000097,0x0004003d,0x00000006,0x00000099,0x00000079, + 0x00050085,0x00000006,0x0000009a,0x00000098,0x00000099,0x00050041,0x00000007,0x0000009b, + 0x00000086,0x00000035,0x0004003d,0x00000006,0x0000009c,0x0000009b,0x00060041,0x00000058, + 0x0000009d,0x00000055,0x00000065,0x00000057,0x0004003d,0x00000006,0x0000009e,0x0000009d, + 0x00050085,0x00000006,0x0000009f,0x0000009c,0x0000009e,0x0004003d,0x00000006,0x000000a0, + 0x00000079,0x00050085,0x00000006,0x000000a1,0x0000009f,0x000000a0,0x0004003d,0x00000006, + 0x000000a2,0x00000079,0x00060050,0x0000000d,0x000000a3,0x0000009a,0x000000a1,0x000000a2, + 0x000200fe,0x000000a3,0x00010038 }; diff --git a/gpu/vk/shaders/evil_shafts.comp b/gpu/vk/shaders/evil_shafts.comp index e4a90ea..c358c50 100644 --- a/gpu/vk/shaders/evil_shafts.comp +++ b/gpu/vk/shaders/evil_shafts.comp @@ -21,6 +21,16 @@ layout(push_constant) uniform Push { #include "aa_common.glsl" +// ((Triforce, 11-27) a value that is a number: its exponent's bits not all set (not Inf, not NaN), tested by its bits so that +// no compiler takes it for always true. A ROG Ally X (Radeon 890M, AMD's driver) showed black blots and whole black frames +// with Evil HD: the game's picture there can hold a NaN pixel (its B10G11R11 target keeps them), and min, max and clamp of a +// NaN stay NaN on AMD's hardware, where NVIDIA's give the other operand: the occlusion and the shafts of every pixel that +// sampled it were NaN, which aa_pack_rgb9e5 writes as black. Every colour taken in and every result is cleaned) +bool evil_finite(float v) { return (floatBitsToUint(v) & 0x7f800000u) != 0x7f800000u; } +vec3 evil_clean(vec3 c) { + return vec3(evil_finite(c.r) ? max(c.r, 0.0) : 0.0, evil_finite(c.g) ? max(c.g, 0.0) : 0.0, evil_finite(c.b) ? max(c.b, 0.0) : 0.0); +} + const int kSamples = 48; const float kReach = 0.85; // (how far towards the sun the line runs, as a share of the way) const float kDecay = 0.978; // (each sample's weight after the one before) @@ -34,7 +44,7 @@ float distance_at(vec2 uv) { vec3 sky_light(vec2 uv) { if (uv.x < 0.0 || uv.y < 0.0 || uv.x > 1.0 || uv.y > 1.0) return vec3(0.0); if (distance_at(uv) < pc.cam.w) return vec3(0.0); - const vec3 c = textureLod(src, uv, 0.0).rgb; + const vec3 c = evil_clean(textureLod(src, uv, 0.0).rgb); const float l = dot(c, vec3(0.2126, 0.7152, 0.0722)); return c * smoothstep(0.2, 0.75, l); } @@ -60,7 +70,7 @@ void main() { } // (less as the pixel is further from the sun on the screen: the shafts gather round it) const float near_sun = 1.0 - smoothstep(0.2, 1.1, length((uv - pc.sun.xy) * vec2(pc.inv.y / pc.inv.x, 1.0))); - const vec3 shafts = sum / float(kSamples) * pc.sun.z * pc.sun.w * (0.35 + 0.65 * near_sun); + const vec3 shafts = evil_clean(sum / float(kSamples) * pc.sun.z * pc.sun.w * (0.35 + 0.65 * near_sun)); if ((int(pc.cam.z) & 2) != 0) { // (RX_VK_EVIL_AO_SHOW=2, the lab's: the shafts alone, and the sun's place as a dot) const float dot_here = 1.0 - smoothstep(0.004, 0.006, length(uv - pc.sun.xy)); imageStore(dst, c, uvec4(aa_pack_rgb9e5(sqrt(min(shafts * 4.0 + vec3(dot_here, 0.0, 0.0), vec3(1.0)))), 0u, 0u, 0u)); diff --git a/gpu/vk/shaders/evil_shafts_comp_spv.h b/gpu/vk/shaders/evil_shafts_comp_spv.h index 048a0de..5ba513d 100644 --- a/gpu/vk/shaders/evil_shafts_comp_spv.h +++ b/gpu/vk/shaders/evil_shafts_comp_spv.h @@ -1,318 +1,359 @@ -// evil_shafts.comp + aa_common.glsl sha256 1711a9827fc59280270126df53ad5ffbc2ab03aaeef0bb3ed5242c17792b9bf1 (tests/test_evil_hd.py --write: glslangValidator -V --target-env vulkan1.2 --vn EVIL_SHAFTS_COMP_SPV) +// evil_shafts.comp + aa_common.glsl sha256 0e55bd70099be09843ac3fe832348c2dc67d01405a69df1dc4df30ec4e90dbce (tests/test_evil_hd.py --write: glslangValidator -V --target-env vulkan1.2 --vn EVIL_SHAFTS_COMP_SPV) // 1116.6.0 #pragma once const uint32_t EVIL_SHAFTS_COMP_SPV[] = { - 0x07230203,0x00010500,0x0008000b,0x000001c3,0x00000000,0x00020011,0x00000001,0x0006000b, + 0x07230203,0x00010500,0x0008000b,0x000001fd,0x00000000,0x00020011,0x00000001,0x0006000b, 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x000a000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000008b,0x00000094,0x000000d4, - 0x00000103,0x00000194,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008,0x00000001, + 0x000a000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x000000c1,0x000000ca,0x0000010a, + 0x0000013b,0x000001ce,0x00060010,0x00000004,0x00000011,0x00000008,0x00000008,0x00000001, 0x00030003,0x00000002,0x000001c2,0x000a0004,0x475f4c47,0x4c474f4f,0x70635f45,0x74735f70, 0x5f656c79,0x656e696c,0x7269645f,0x69746365,0x00006576,0x00080004,0x475f4c47,0x4c474f4f, 0x6e695f45,0x64756c63,0x69645f65,0x74636572,0x00657669,0x00040005,0x00000004,0x6e69616d, 0x00000000,0x00070005,0x0000000a,0x635f6161,0x6e6e6168,0x395f6c65,0x66283565,0x00003b31, 0x00030005,0x00000009,0x00000076,0x00070005,0x00000011,0x705f6161,0x5f6b6361,0x39626772, - 0x76283565,0x003b3366,0x00030005,0x00000010,0x00000063,0x00070005,0x00000017,0x74736964, - 0x65636e61,0x2874615f,0x3b326676,0x00000000,0x00030005,0x00000016,0x00007675,0x00060005, - 0x0000001b,0x5f796b73,0x6867696c,0x66762874,0x00003b32,0x00030005,0x0000001a,0x00007675, - 0x00070005,0x00000020,0x61706e75,0x725f6b63,0x65396267,0x31752835,0x0000003b,0x00030005, - 0x0000001f,0x00000077,0x00030005,0x00000030,0x00000072,0x00040005,0x00000031,0x61726170, - 0x0000006d,0x00030005,0x00000036,0x00000067,0x00040005,0x00000037,0x61726170,0x0000006d, - 0x00030005,0x0000003c,0x00000062,0x00040005,0x0000003d,0x61726170,0x0000006d,0x00030005, - 0x00000042,0x0000006d,0x00030005,0x00000048,0x00000065,0x00040005,0x00000052,0x6c616373, - 0x00000065,0x00030005,0x00000087,0x00000064,0x00050005,0x0000008b,0x74706564,0x65745f68, - 0x00000078,0x00040005,0x00000092,0x68737550,0x00000000,0x00040006,0x00000092,0x00000000, - 0x00766e69,0x00050006,0x00000092,0x00000001,0x657a6973,0x00000000,0x00040006,0x00000092, - 0x00000002,0x006d6163,0x00040006,0x00000092,0x00000003,0x006e7573,0x00030005,0x00000094, - 0x00006370,0x00040005,0x000000c9,0x61726170,0x0000006d,0x00030005,0x000000d3,0x00000063, - 0x00030005,0x000000d4,0x00637273,0x00030005,0x000000d9,0x0000006c,0x00040005,0x000000e8, - 0x6c616373,0x00000065,0x00030005,0x00000100,0x00000063,0x00080005,0x00000103,0x475f6c67, - 0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005,0x0000011b,0x00007675, - 0x00040005,0x00000124,0x73696f6e,0x00000065,0x00040005,0x00000134,0x70657473,0x0076755f, - 0x00030005,0x0000013e,0x00000070,0x00030005,0x00000144,0x006d7573,0x00030005,0x00000145, - 0x00000077,0x00030005,0x00000146,0x00000069,0x00040005,0x0000014f,0x61726170,0x0000006d, - 0x00050005,0x0000015e,0x7261656e,0x6e75735f,0x00000000,0x00040005,0x0000016f,0x66616873, - 0x00007374,0x00050005,0x00000187,0x5f746f64,0x65726568,0x00000000,0x00030005,0x00000194, - 0x00747364,0x00040005,0x000001a0,0x61726170,0x0000006d,0x00030005,0x000001ac,0x00000065, - 0x00040005,0x000001b0,0x61726170,0x0000006d,0x00030005,0x000001b3,0x0074696c,0x00040005, - 0x000001bd,0x61726170,0x0000006d,0x00040047,0x0000008b,0x00000021,0x00000001,0x00040047, - 0x0000008b,0x00000022,0x00000000,0x00030047,0x00000092,0x00000002,0x00050048,0x00000092, - 0x00000000,0x00000023,0x00000000,0x00050048,0x00000092,0x00000001,0x00000023,0x00000008, - 0x00050048,0x00000092,0x00000002,0x00000023,0x00000010,0x00050048,0x00000092,0x00000003, - 0x00000023,0x00000020,0x00040047,0x000000d4,0x00000021,0x00000000,0x00040047,0x000000d4, - 0x00000022,0x00000000,0x00040047,0x00000103,0x0000000b,0x0000001c,0x00040047,0x00000194, - 0x00000021,0x00000002,0x00040047,0x00000194,0x00000022,0x00000000,0x00040047,0x000001c1, - 0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016, - 0x00000006,0x00000020,0x00040020,0x00000007,0x00000007,0x00000006,0x00040021,0x00000008, - 0x00000006,0x00000007,0x00040017,0x0000000c,0x00000006,0x00000003,0x00040020,0x0000000d, - 0x00000007,0x0000000c,0x00040015,0x0000000e,0x00000020,0x00000000,0x00040021,0x0000000f, - 0x0000000e,0x0000000d,0x00040017,0x00000013,0x00000006,0x00000002,0x00040020,0x00000014, - 0x00000007,0x00000013,0x00040021,0x00000015,0x00000006,0x00000014,0x00040021,0x00000019, - 0x0000000c,0x00000014,0x00040020,0x0000001d,0x00000007,0x0000000e,0x00040021,0x0000001e, - 0x0000000c,0x0000001d,0x0004002b,0x00000006,0x00000023,0x00000000,0x00020014,0x00000024, - 0x0004002b,0x00000006,0x0000002a,0x477f8000,0x0004002b,0x0000000e,0x00000032,0x00000000, - 0x0004002b,0x0000000e,0x00000038,0x00000001,0x0004002b,0x0000000e,0x0000003e,0x00000002, - 0x0004002b,0x00000006,0x00000049,0xc1800000,0x0004002b,0x00000006,0x0000004b,0x0da24260, - 0x0004002b,0x00000006,0x00000050,0x41800000,0x0004002b,0x00000006,0x00000054,0x41c00000, - 0x0004002b,0x00000006,0x0000005a,0x3f000000,0x0004002b,0x00000006,0x0000005d,0x44000000, - 0x0004002b,0x00000006,0x00000061,0x3f800000,0x0004002b,0x00000006,0x00000064,0x40000000, - 0x00040015,0x00000073,0x00000020,0x00000001,0x0004002b,0x00000073,0x00000074,0x00000009, - 0x0004002b,0x00000073,0x0000007d,0x00000012,0x0004002b,0x00000073,0x00000082,0x0000001b, - 0x00090019,0x00000088,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001, - 0x00000000,0x0003001b,0x00000089,0x00000088,0x00040020,0x0000008a,0x00000000,0x00000089, - 0x0004003b,0x0000008a,0x0000008b,0x00000000,0x00040017,0x0000008e,0x00000006,0x00000004, - 0x00040017,0x00000091,0x00000073,0x00000002,0x0006001e,0x00000092,0x00000013,0x00000091, - 0x0000008e,0x0000008e,0x00040020,0x00000093,0x00000009,0x00000092,0x0004003b,0x00000093, - 0x00000094,0x00000009,0x0004002b,0x00000073,0x00000095,0x00000002,0x00040020,0x00000096, - 0x00000009,0x00000006,0x0004002b,0x00000073,0x0000009a,0x00000001,0x0004002b,0x00000073, - 0x0000009c,0x00000000,0x0004002b,0x00000006,0x000000a8,0x33d6bf95,0x0006002c,0x0000000c, - 0x000000c7,0x00000023,0x00000023,0x00000023,0x0004002b,0x0000000e,0x000000cc,0x00000003, - 0x0004003b,0x0000008a,0x000000d4,0x00000000,0x0004002b,0x00000006,0x000000db,0x3e59b3d0, - 0x0004002b,0x00000006,0x000000dc,0x3f371759,0x0004002b,0x00000006,0x000000dd,0x3d93dd98, - 0x0006002c,0x0000000c,0x000000de,0x000000db,0x000000dc,0x000000dd,0x0004002b,0x00000006, - 0x000000e1,0x3e4ccccd,0x0004002b,0x00000006,0x000000e2,0x3f400000,0x0004002b,0x0000000e, - 0x000000ef,0x000001ff,0x00040020,0x000000ff,0x00000007,0x00000091,0x00040017,0x00000101, - 0x0000000e,0x00000003,0x00040020,0x00000102,0x00000001,0x00000101,0x0004003b,0x00000102, - 0x00000103,0x00000001,0x00040017,0x00000104,0x0000000e,0x00000002,0x00040020,0x00000108, - 0x00000007,0x00000073,0x00040020,0x0000010b,0x00000009,0x00000073,0x00040020,0x00000120, - 0x00000009,0x00000013,0x0004002b,0x00000006,0x00000125,0x4253ee82,0x0004002b,0x00000006, - 0x00000126,0x3d897143,0x0004002b,0x00000006,0x0000012b,0x3bbf4590,0x0004002b,0x00000073, - 0x00000135,0x00000003,0x00040020,0x00000136,0x00000009,0x0000008e,0x0004002b,0x00000006, - 0x0000013c,0x3c911111,0x0004002b,0x00000073,0x0000014d,0x00000030,0x0004002b,0x00000006, - 0x00000156,0x3f7a5e35,0x0004002b,0x00000006,0x0000015f,0x3f8ccccd,0x0004002b,0x00000006, - 0x00000171,0x42400000,0x0004002b,0x00000006,0x0000017a,0x3eb33333,0x0004002b,0x00000006, - 0x0000017b,0x3f266666,0x0004002b,0x00000006,0x00000188,0x3b83126f,0x0004002b,0x00000006, - 0x00000189,0x3bc49ba6,0x00090019,0x00000192,0x0000000e,0x00000001,0x00000000,0x00000000, - 0x00000000,0x00000002,0x00000021,0x00040020,0x00000193,0x00000000,0x00000192,0x0004003b, - 0x00000193,0x00000194,0x00000000,0x0004002b,0x00000006,0x00000198,0x40800000,0x0006002c, - 0x0000000c,0x0000019d,0x00000061,0x00000061,0x00000061,0x00040017,0x000001a2,0x0000000e, - 0x00000004,0x0004002b,0x00000006,0x000001a7,0x38d1b717,0x0004002b,0x0000000e,0x000001c0, - 0x00000008,0x0006002c,0x00000101,0x000001c1,0x000001c0,0x000001c0,0x00000038,0x0004002b, - 0x00000006,0x000001c2,0x3f59999a,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003, - 0x000200f8,0x00000005,0x0004003b,0x000000ff,0x00000100,0x00000007,0x0004003b,0x00000014, - 0x0000011b,0x00000007,0x0004003b,0x00000007,0x00000124,0x00000007,0x0004003b,0x00000014, - 0x00000134,0x00000007,0x0004003b,0x00000014,0x0000013e,0x00000007,0x0004003b,0x0000000d, - 0x00000144,0x00000007,0x0004003b,0x00000007,0x00000145,0x00000007,0x0004003b,0x00000108, - 0x00000146,0x00000007,0x0004003b,0x00000014,0x0000014f,0x00000007,0x0004003b,0x00000007, - 0x0000015e,0x00000007,0x0004003b,0x0000000d,0x0000016f,0x00000007,0x0004003b,0x00000007, - 0x00000187,0x00000007,0x0004003b,0x0000000d,0x000001a0,0x00000007,0x0004003b,0x0000000d, - 0x000001ac,0x00000007,0x0004003b,0x0000001d,0x000001b0,0x00000007,0x0004003b,0x0000000d, - 0x000001b3,0x00000007,0x0004003b,0x0000000d,0x000001bd,0x00000007,0x0004003d,0x00000101, - 0x00000105,0x00000103,0x0007004f,0x00000104,0x00000106,0x00000105,0x00000105,0x00000000, - 0x00000001,0x0004007c,0x00000091,0x00000107,0x00000106,0x0003003e,0x00000100,0x00000107, - 0x00050041,0x00000108,0x00000109,0x00000100,0x00000032,0x0004003d,0x00000073,0x0000010a, - 0x00000109,0x00060041,0x0000010b,0x0000010c,0x00000094,0x0000009a,0x00000032,0x0004003d, - 0x00000073,0x0000010d,0x0000010c,0x000500af,0x00000024,0x0000010e,0x0000010a,0x0000010d, - 0x000400a8,0x00000024,0x0000010f,0x0000010e,0x000300f7,0x00000111,0x00000000,0x000400fa, - 0x0000010f,0x00000110,0x00000111,0x000200f8,0x00000110,0x00050041,0x00000108,0x00000112, - 0x00000100,0x00000038,0x0004003d,0x00000073,0x00000113,0x00000112,0x00060041,0x0000010b, - 0x00000114,0x00000094,0x0000009a,0x00000038,0x0004003d,0x00000073,0x00000115,0x00000114, - 0x000500af,0x00000024,0x00000116,0x00000113,0x00000115,0x000200f9,0x00000111,0x000200f8, - 0x00000111,0x000700f5,0x00000024,0x00000117,0x0000010e,0x00000005,0x00000116,0x00000110, - 0x000300f7,0x00000119,0x00000000,0x000400fa,0x00000117,0x00000118,0x00000119,0x000200f8, - 0x00000118,0x000100fd,0x000200f8,0x00000119,0x0004003d,0x00000091,0x0000011c,0x00000100, - 0x0004006f,0x00000013,0x0000011d,0x0000011c,0x00050050,0x00000013,0x0000011e,0x0000005a, - 0x0000005a,0x00050081,0x00000013,0x0000011f,0x0000011d,0x0000011e,0x00050041,0x00000120, - 0x00000121,0x00000094,0x0000009c,0x0004003d,0x00000013,0x00000122,0x00000121,0x00050085, - 0x00000013,0x00000123,0x0000011f,0x00000122,0x0003003e,0x0000011b,0x00000123,0x00050041, - 0x00000108,0x00000127,0x00000100,0x00000032,0x0004003d,0x00000073,0x00000128,0x00000127, - 0x0004006f,0x00000006,0x00000129,0x00000128,0x00050085,0x00000006,0x0000012a,0x00000126, - 0x00000129,0x00050041,0x00000108,0x0000012c,0x00000100,0x00000038,0x0004003d,0x00000073, - 0x0000012d,0x0000012c,0x0004006f,0x00000006,0x0000012e,0x0000012d,0x00050085,0x00000006, - 0x0000012f,0x0000012b,0x0000012e,0x00050081,0x00000006,0x00000130,0x0000012a,0x0000012f, - 0x0006000c,0x00000006,0x00000131,0x00000001,0x0000000a,0x00000130,0x00050085,0x00000006, - 0x00000132,0x00000125,0x00000131,0x0006000c,0x00000006,0x00000133,0x00000001,0x0000000a, - 0x00000132,0x0003003e,0x00000124,0x00000133,0x00050041,0x00000136,0x00000137,0x00000094, - 0x00000135,0x0004003d,0x0000008e,0x00000138,0x00000137,0x0007004f,0x00000013,0x00000139, - 0x00000138,0x00000138,0x00000000,0x00000001,0x0004003d,0x00000013,0x0000013a,0x0000011b, - 0x00050083,0x00000013,0x0000013b,0x00000139,0x0000013a,0x0005008e,0x00000013,0x0000013d, - 0x0000013b,0x0000013c,0x0003003e,0x00000134,0x0000013d,0x0004003d,0x00000013,0x0000013f, - 0x0000011b,0x0004003d,0x00000013,0x00000140,0x00000134,0x0004003d,0x00000006,0x00000141, - 0x00000124,0x0005008e,0x00000013,0x00000142,0x00000140,0x00000141,0x00050081,0x00000013, - 0x00000143,0x0000013f,0x00000142,0x0003003e,0x0000013e,0x00000143,0x0003003e,0x00000144, - 0x000000c7,0x0003003e,0x00000145,0x00000061,0x0003003e,0x00000146,0x0000009c,0x000200f9, - 0x00000147,0x000200f8,0x00000147,0x000400f6,0x00000149,0x0000014a,0x00000000,0x000200f9, - 0x0000014b,0x000200f8,0x0000014b,0x0004003d,0x00000073,0x0000014c,0x00000146,0x000500b1, - 0x00000024,0x0000014e,0x0000014c,0x0000014d,0x000400fa,0x0000014e,0x00000148,0x00000149, - 0x000200f8,0x00000148,0x0004003d,0x00000013,0x00000150,0x0000013e,0x0003003e,0x0000014f, - 0x00000150,0x00050039,0x0000000c,0x00000151,0x0000001b,0x0000014f,0x0004003d,0x00000006, - 0x00000152,0x00000145,0x0005008e,0x0000000c,0x00000153,0x00000151,0x00000152,0x0004003d, - 0x0000000c,0x00000154,0x00000144,0x00050081,0x0000000c,0x00000155,0x00000154,0x00000153, - 0x0003003e,0x00000144,0x00000155,0x0004003d,0x00000006,0x00000157,0x00000145,0x00050085, - 0x00000006,0x00000158,0x00000157,0x00000156,0x0003003e,0x00000145,0x00000158,0x0004003d, - 0x00000013,0x00000159,0x00000134,0x0004003d,0x00000013,0x0000015a,0x0000013e,0x00050081, - 0x00000013,0x0000015b,0x0000015a,0x00000159,0x0003003e,0x0000013e,0x0000015b,0x000200f9, - 0x0000014a,0x000200f8,0x0000014a,0x0004003d,0x00000073,0x0000015c,0x00000146,0x00050080, - 0x00000073,0x0000015d,0x0000015c,0x0000009a,0x0003003e,0x00000146,0x0000015d,0x000200f9, - 0x00000147,0x000200f8,0x00000149,0x0004003d,0x00000013,0x00000160,0x0000011b,0x00050041, - 0x00000136,0x00000161,0x00000094,0x00000135,0x0004003d,0x0000008e,0x00000162,0x00000161, - 0x0007004f,0x00000013,0x00000163,0x00000162,0x00000162,0x00000000,0x00000001,0x00050083, - 0x00000013,0x00000164,0x00000160,0x00000163,0x00060041,0x00000096,0x00000165,0x00000094, - 0x0000009c,0x00000038,0x0004003d,0x00000006,0x00000166,0x00000165,0x00060041,0x00000096, - 0x00000167,0x00000094,0x0000009c,0x00000032,0x0004003d,0x00000006,0x00000168,0x00000167, - 0x00050088,0x00000006,0x00000169,0x00000166,0x00000168,0x00050050,0x00000013,0x0000016a, - 0x00000169,0x00000061,0x00050085,0x00000013,0x0000016b,0x00000164,0x0000016a,0x0006000c, - 0x00000006,0x0000016c,0x00000001,0x00000042,0x0000016b,0x0008000c,0x00000006,0x0000016d, - 0x00000001,0x00000031,0x000000e1,0x0000015f,0x0000016c,0x00050083,0x00000006,0x0000016e, - 0x00000061,0x0000016d,0x0003003e,0x0000015e,0x0000016e,0x0004003d,0x0000000c,0x00000170, - 0x00000144,0x00060050,0x0000000c,0x00000172,0x00000171,0x00000171,0x00000171,0x00050088, - 0x0000000c,0x00000173,0x00000170,0x00000172,0x00060041,0x00000096,0x00000174,0x00000094, - 0x00000135,0x0000003e,0x0004003d,0x00000006,0x00000175,0x00000174,0x0005008e,0x0000000c, - 0x00000176,0x00000173,0x00000175,0x00060041,0x00000096,0x00000177,0x00000094,0x00000135, - 0x000000cc,0x0004003d,0x00000006,0x00000178,0x00000177,0x0005008e,0x0000000c,0x00000179, - 0x00000176,0x00000178,0x0004003d,0x00000006,0x0000017c,0x0000015e,0x00050085,0x00000006, - 0x0000017d,0x0000017b,0x0000017c,0x00050081,0x00000006,0x0000017e,0x0000017a,0x0000017d, - 0x0005008e,0x0000000c,0x0000017f,0x00000179,0x0000017e,0x0003003e,0x0000016f,0x0000017f, - 0x00060041,0x00000096,0x00000180,0x00000094,0x00000095,0x0000003e,0x0004003d,0x00000006, - 0x00000181,0x00000180,0x0004006e,0x00000073,0x00000182,0x00000181,0x000500c7,0x00000073, - 0x00000183,0x00000182,0x00000095,0x000500ab,0x00000024,0x00000184,0x00000183,0x0000009c, - 0x000300f7,0x00000186,0x00000000,0x000400fa,0x00000184,0x00000185,0x00000186,0x000200f8, - 0x00000185,0x0004003d,0x00000013,0x0000018a,0x0000011b,0x00050041,0x00000136,0x0000018b, - 0x00000094,0x00000135,0x0004003d,0x0000008e,0x0000018c,0x0000018b,0x0007004f,0x00000013, - 0x0000018d,0x0000018c,0x0000018c,0x00000000,0x00000001,0x00050083,0x00000013,0x0000018e, - 0x0000018a,0x0000018d,0x0006000c,0x00000006,0x0000018f,0x00000001,0x00000042,0x0000018e, - 0x0008000c,0x00000006,0x00000190,0x00000001,0x00000031,0x00000188,0x00000189,0x0000018f, - 0x00050083,0x00000006,0x00000191,0x00000061,0x00000190,0x0003003e,0x00000187,0x00000191, - 0x0004003d,0x00000192,0x00000195,0x00000194,0x0004003d,0x00000091,0x00000196,0x00000100, - 0x0004003d,0x0000000c,0x00000197,0x0000016f,0x0005008e,0x0000000c,0x00000199,0x00000197, - 0x00000198,0x0004003d,0x00000006,0x0000019a,0x00000187,0x00060050,0x0000000c,0x0000019b, - 0x0000019a,0x00000023,0x00000023,0x00050081,0x0000000c,0x0000019c,0x00000199,0x0000019b, - 0x0007000c,0x0000000c,0x0000019e,0x00000001,0x00000025,0x0000019c,0x0000019d,0x0006000c, - 0x0000000c,0x0000019f,0x00000001,0x0000001f,0x0000019e,0x0003003e,0x000001a0,0x0000019f, - 0x00050039,0x0000000e,0x000001a1,0x00000011,0x000001a0,0x00070050,0x000001a2,0x000001a3, - 0x000001a1,0x00000032,0x00000032,0x00000032,0x00050063,0x00000195,0x00000196,0x000001a3, - 0x00002000,0x000100fd,0x000200f8,0x00000186,0x0004003d,0x0000000c,0x000001a5,0x0000016f, - 0x00050094,0x00000006,0x000001a6,0x000001a5,0x0000019d,0x000500b8,0x00000024,0x000001a8, - 0x000001a6,0x000001a7,0x000300f7,0x000001aa,0x00000000,0x000400fa,0x000001a8,0x000001a9, - 0x000001aa,0x000200f8,0x000001a9,0x000100fd,0x000200f8,0x000001aa,0x0004003d,0x00000192, - 0x000001ad,0x00000194,0x0004003d,0x00000091,0x000001ae,0x00000100,0x00060062,0x000001a2, - 0x000001af,0x000001ad,0x000001ae,0x00002000,0x00050051,0x0000000e,0x000001b1,0x000001af, - 0x00000000,0x0003003e,0x000001b0,0x000001b1,0x00050039,0x0000000c,0x000001b2,0x00000020, - 0x000001b0,0x0003003e,0x000001ac,0x000001b2,0x0004003d,0x0000000c,0x000001b4,0x000001ac, - 0x0004003d,0x0000000c,0x000001b5,0x000001ac,0x00050085,0x0000000c,0x000001b6,0x000001b4, - 0x000001b5,0x0004003d,0x0000000c,0x000001b7,0x0000016f,0x00050081,0x0000000c,0x000001b8, - 0x000001b6,0x000001b7,0x0003003e,0x000001b3,0x000001b8,0x0004003d,0x00000192,0x000001b9, - 0x00000194,0x0004003d,0x00000091,0x000001ba,0x00000100,0x0004003d,0x0000000c,0x000001bb, - 0x000001b3,0x0006000c,0x0000000c,0x000001bc,0x00000001,0x0000001f,0x000001bb,0x0003003e, - 0x000001bd,0x000001bc,0x00050039,0x0000000e,0x000001be,0x00000011,0x000001bd,0x00070050, - 0x000001a2,0x000001bf,0x000001be,0x00000032,0x00000032,0x00000032,0x00050063,0x000001b9, - 0x000001ba,0x000001bf,0x00002000,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a, - 0x00000000,0x00000008,0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003b, - 0x00000007,0x00000026,0x00000007,0x0004003d,0x00000006,0x00000022,0x00000009,0x000500ba, - 0x00000024,0x00000025,0x00000022,0x00000023,0x000300f7,0x00000028,0x00000000,0x000400fa, - 0x00000025,0x00000027,0x0000002c,0x000200f8,0x00000027,0x0004003d,0x00000006,0x00000029, - 0x00000009,0x0007000c,0x00000006,0x0000002b,0x00000001,0x00000025,0x00000029,0x0000002a, - 0x0003003e,0x00000026,0x0000002b,0x000200f9,0x00000028,0x000200f8,0x0000002c,0x0003003e, - 0x00000026,0x00000023,0x000200f9,0x00000028,0x000200f8,0x00000028,0x0004003d,0x00000006, - 0x0000002d,0x00000026,0x000200fe,0x0000002d,0x00010038,0x00050036,0x0000000e,0x00000011, - 0x00000000,0x0000000f,0x00030037,0x0000000d,0x00000010,0x000200f8,0x00000012,0x0004003b, - 0x00000007,0x00000030,0x00000007,0x0004003b,0x00000007,0x00000031,0x00000007,0x0004003b, - 0x00000007,0x00000036,0x00000007,0x0004003b,0x00000007,0x00000037,0x00000007,0x0004003b, - 0x00000007,0x0000003c,0x00000007,0x0004003b,0x00000007,0x0000003d,0x00000007,0x0004003b, - 0x00000007,0x00000042,0x00000007,0x0004003b,0x00000007,0x00000048,0x00000007,0x0004003b, - 0x00000007,0x00000052,0x00000007,0x00050041,0x00000007,0x00000033,0x00000010,0x00000032, - 0x0004003d,0x00000006,0x00000034,0x00000033,0x0003003e,0x00000031,0x00000034,0x00050039, - 0x00000006,0x00000035,0x0000000a,0x00000031,0x0003003e,0x00000030,0x00000035,0x00050041, - 0x00000007,0x00000039,0x00000010,0x00000038,0x0004003d,0x00000006,0x0000003a,0x00000039, - 0x0003003e,0x00000037,0x0000003a,0x00050039,0x00000006,0x0000003b,0x0000000a,0x00000037, - 0x0003003e,0x00000036,0x0000003b,0x00050041,0x00000007,0x0000003f,0x00000010,0x0000003e, - 0x0004003d,0x00000006,0x00000040,0x0000003f,0x0003003e,0x0000003d,0x00000040,0x00050039, - 0x00000006,0x00000041,0x0000000a,0x0000003d,0x0003003e,0x0000003c,0x00000041,0x0004003d, - 0x00000006,0x00000043,0x00000030,0x0004003d,0x00000006,0x00000044,0x00000036,0x0007000c, - 0x00000006,0x00000045,0x00000001,0x00000028,0x00000043,0x00000044,0x0004003d,0x00000006, - 0x00000046,0x0000003c,0x0007000c,0x00000006,0x00000047,0x00000001,0x00000028,0x00000045, - 0x00000046,0x0003003e,0x00000042,0x00000047,0x0004003d,0x00000006,0x0000004a,0x00000042, - 0x0007000c,0x00000006,0x0000004c,0x00000001,0x00000028,0x0000004a,0x0000004b,0x0006000c, - 0x00000006,0x0000004d,0x00000001,0x0000001e,0x0000004c,0x0006000c,0x00000006,0x0000004e, - 0x00000001,0x00000008,0x0000004d,0x0007000c,0x00000006,0x0000004f,0x00000001,0x00000028, - 0x00000049,0x0000004e,0x00050081,0x00000006,0x00000051,0x0000004f,0x00000050,0x0003003e, - 0x00000048,0x00000051,0x0004003d,0x00000006,0x00000053,0x00000048,0x00050083,0x00000006, - 0x00000055,0x00000053,0x00000054,0x0006000c,0x00000006,0x00000056,0x00000001,0x0000001d, - 0x00000055,0x0003003e,0x00000052,0x00000056,0x0004003d,0x00000006,0x00000057,0x00000042, - 0x0004003d,0x00000006,0x00000058,0x00000052,0x00050088,0x00000006,0x00000059,0x00000057, - 0x00000058,0x00050081,0x00000006,0x0000005b,0x00000059,0x0000005a,0x0006000c,0x00000006, - 0x0000005c,0x00000001,0x00000008,0x0000005b,0x000500be,0x00000024,0x0000005e,0x0000005c, - 0x0000005d,0x000300f7,0x00000060,0x00000000,0x000400fa,0x0000005e,0x0000005f,0x00000060, - 0x000200f8,0x0000005f,0x0004003d,0x00000006,0x00000062,0x00000048,0x00050081,0x00000006, - 0x00000063,0x00000062,0x00000061,0x0003003e,0x00000048,0x00000063,0x0004003d,0x00000006, - 0x00000065,0x00000052,0x00050085,0x00000006,0x00000066,0x00000065,0x00000064,0x0003003e, - 0x00000052,0x00000066,0x000200f9,0x00000060,0x000200f8,0x00000060,0x0004003d,0x00000006, - 0x00000067,0x00000030,0x0004003d,0x00000006,0x00000068,0x00000052,0x00050088,0x00000006, - 0x00000069,0x00000067,0x00000068,0x00050081,0x00000006,0x0000006a,0x00000069,0x0000005a, - 0x0006000c,0x00000006,0x0000006b,0x00000001,0x00000008,0x0000006a,0x0004006d,0x0000000e, - 0x0000006c,0x0000006b,0x0004003d,0x00000006,0x0000006d,0x00000036,0x0004003d,0x00000006, - 0x0000006e,0x00000052,0x00050088,0x00000006,0x0000006f,0x0000006d,0x0000006e,0x00050081, - 0x00000006,0x00000070,0x0000006f,0x0000005a,0x0006000c,0x00000006,0x00000071,0x00000001, - 0x00000008,0x00000070,0x0004006d,0x0000000e,0x00000072,0x00000071,0x000500c4,0x0000000e, - 0x00000075,0x00000072,0x00000074,0x000500c5,0x0000000e,0x00000076,0x0000006c,0x00000075, - 0x0004003d,0x00000006,0x00000077,0x0000003c,0x0004003d,0x00000006,0x00000078,0x00000052, - 0x00050088,0x00000006,0x00000079,0x00000077,0x00000078,0x00050081,0x00000006,0x0000007a, - 0x00000079,0x0000005a,0x0006000c,0x00000006,0x0000007b,0x00000001,0x00000008,0x0000007a, - 0x0004006d,0x0000000e,0x0000007c,0x0000007b,0x000500c4,0x0000000e,0x0000007e,0x0000007c, - 0x0000007d,0x000500c5,0x0000000e,0x0000007f,0x00000076,0x0000007e,0x0004003d,0x00000006, - 0x00000080,0x00000048,0x0004006d,0x0000000e,0x00000081,0x00000080,0x000500c4,0x0000000e, - 0x00000083,0x00000081,0x00000082,0x000500c5,0x0000000e,0x00000084,0x0000007f,0x00000083, - 0x000200fe,0x00000084,0x00010038,0x00050036,0x00000006,0x00000017,0x00000000,0x00000015, - 0x00030037,0x00000014,0x00000016,0x000200f8,0x00000018,0x0004003b,0x00000007,0x00000087, - 0x00000007,0x0004003d,0x00000089,0x0000008c,0x0000008b,0x0004003d,0x00000013,0x0000008d, - 0x00000016,0x00070058,0x0000008e,0x0000008f,0x0000008c,0x0000008d,0x00000002,0x00000023, - 0x00050051,0x00000006,0x00000090,0x0000008f,0x00000000,0x0003003e,0x00000087,0x00000090, - 0x00060041,0x00000096,0x00000097,0x00000094,0x00000095,0x0000003e,0x0004003d,0x00000006, - 0x00000098,0x00000097,0x0004006e,0x00000073,0x00000099,0x00000098,0x000500c7,0x00000073, - 0x0000009b,0x00000099,0x0000009a,0x000500ab,0x00000024,0x0000009d,0x0000009b,0x0000009c, - 0x000300f7,0x0000009f,0x00000000,0x000400fa,0x0000009d,0x0000009e,0x0000009f,0x000200f8, - 0x0000009e,0x0004003d,0x00000006,0x000000a0,0x00000087,0x00050083,0x00000006,0x000000a1, - 0x00000061,0x000000a0,0x0003003e,0x00000087,0x000000a1,0x000200f9,0x0000009f,0x000200f8, - 0x0000009f,0x00060041,0x00000096,0x000000a2,0x00000094,0x00000095,0x00000038,0x0004003d, - 0x00000006,0x000000a3,0x000000a2,0x0004003d,0x00000006,0x000000a4,0x00000087,0x00060041, - 0x00000096,0x000000a5,0x00000094,0x00000095,0x00000032,0x0004003d,0x00000006,0x000000a6, - 0x000000a5,0x00050083,0x00000006,0x000000a7,0x000000a4,0x000000a6,0x0007000c,0x00000006, - 0x000000a9,0x00000001,0x00000028,0x000000a7,0x000000a8,0x00050088,0x00000006,0x000000aa, - 0x000000a3,0x000000a9,0x000200fe,0x000000aa,0x00010038,0x00050036,0x0000000c,0x0000001b, - 0x00000000,0x00000019,0x00030037,0x00000014,0x0000001a,0x000200f8,0x0000001c,0x0004003b, - 0x00000014,0x000000c9,0x00000007,0x0004003b,0x0000000d,0x000000d3,0x00000007,0x0004003b, - 0x00000007,0x000000d9,0x00000007,0x00050041,0x00000007,0x000000ad,0x0000001a,0x00000032, - 0x0004003d,0x00000006,0x000000ae,0x000000ad,0x000500b8,0x00000024,0x000000af,0x000000ae, - 0x00000023,0x000400a8,0x00000024,0x000000b0,0x000000af,0x000300f7,0x000000b2,0x00000000, - 0x000400fa,0x000000b0,0x000000b1,0x000000b2,0x000200f8,0x000000b1,0x00050041,0x00000007, - 0x000000b3,0x0000001a,0x00000038,0x0004003d,0x00000006,0x000000b4,0x000000b3,0x000500b8, - 0x00000024,0x000000b5,0x000000b4,0x00000023,0x000200f9,0x000000b2,0x000200f8,0x000000b2, - 0x000700f5,0x00000024,0x000000b6,0x000000af,0x0000001c,0x000000b5,0x000000b1,0x000400a8, - 0x00000024,0x000000b7,0x000000b6,0x000300f7,0x000000b9,0x00000000,0x000400fa,0x000000b7, - 0x000000b8,0x000000b9,0x000200f8,0x000000b8,0x00050041,0x00000007,0x000000ba,0x0000001a, - 0x00000032,0x0004003d,0x00000006,0x000000bb,0x000000ba,0x000500ba,0x00000024,0x000000bc, - 0x000000bb,0x00000061,0x000200f9,0x000000b9,0x000200f8,0x000000b9,0x000700f5,0x00000024, - 0x000000bd,0x000000b6,0x000000b2,0x000000bc,0x000000b8,0x000400a8,0x00000024,0x000000be, - 0x000000bd,0x000300f7,0x000000c0,0x00000000,0x000400fa,0x000000be,0x000000bf,0x000000c0, - 0x000200f8,0x000000bf,0x00050041,0x00000007,0x000000c1,0x0000001a,0x00000038,0x0004003d, - 0x00000006,0x000000c2,0x000000c1,0x000500ba,0x00000024,0x000000c3,0x000000c2,0x00000061, - 0x000200f9,0x000000c0,0x000200f8,0x000000c0,0x000700f5,0x00000024,0x000000c4,0x000000bd, - 0x000000b9,0x000000c3,0x000000bf,0x000300f7,0x000000c6,0x00000000,0x000400fa,0x000000c4, - 0x000000c5,0x000000c6,0x000200f8,0x000000c5,0x000200fe,0x000000c7,0x000200f8,0x000000c6, - 0x0004003d,0x00000013,0x000000ca,0x0000001a,0x0003003e,0x000000c9,0x000000ca,0x00050039, - 0x00000006,0x000000cb,0x00000017,0x000000c9,0x00060041,0x00000096,0x000000cd,0x00000094, - 0x00000095,0x000000cc,0x0004003d,0x00000006,0x000000ce,0x000000cd,0x000500b8,0x00000024, - 0x000000cf,0x000000cb,0x000000ce,0x000300f7,0x000000d1,0x00000000,0x000400fa,0x000000cf, - 0x000000d0,0x000000d1,0x000200f8,0x000000d0,0x000200fe,0x000000c7,0x000200f8,0x000000d1, - 0x0004003d,0x00000089,0x000000d5,0x000000d4,0x0004003d,0x00000013,0x000000d6,0x0000001a, - 0x00070058,0x0000008e,0x000000d7,0x000000d5,0x000000d6,0x00000002,0x00000023,0x0008004f, - 0x0000000c,0x000000d8,0x000000d7,0x000000d7,0x00000000,0x00000001,0x00000002,0x0003003e, - 0x000000d3,0x000000d8,0x0004003d,0x0000000c,0x000000da,0x000000d3,0x00050094,0x00000006, - 0x000000df,0x000000da,0x000000de,0x0003003e,0x000000d9,0x000000df,0x0004003d,0x0000000c, - 0x000000e0,0x000000d3,0x0004003d,0x00000006,0x000000e3,0x000000d9,0x0008000c,0x00000006, - 0x000000e4,0x00000001,0x00000031,0x000000e1,0x000000e2,0x000000e3,0x0005008e,0x0000000c, - 0x000000e5,0x000000e0,0x000000e4,0x000200fe,0x000000e5,0x00010038,0x00050036,0x0000000c, - 0x00000020,0x00000000,0x0000001e,0x00030037,0x0000001d,0x0000001f,0x000200f8,0x00000021, - 0x0004003b,0x00000007,0x000000e8,0x00000007,0x0004003d,0x0000000e,0x000000e9,0x0000001f, - 0x000500c2,0x0000000e,0x000000ea,0x000000e9,0x00000082,0x00040070,0x00000006,0x000000eb, - 0x000000ea,0x00050083,0x00000006,0x000000ec,0x000000eb,0x00000054,0x0006000c,0x00000006, - 0x000000ed,0x00000001,0x0000001d,0x000000ec,0x0003003e,0x000000e8,0x000000ed,0x0004003d, - 0x0000000e,0x000000ee,0x0000001f,0x000500c7,0x0000000e,0x000000f0,0x000000ee,0x000000ef, - 0x00040070,0x00000006,0x000000f1,0x000000f0,0x0004003d,0x0000000e,0x000000f2,0x0000001f, - 0x000500c2,0x0000000e,0x000000f3,0x000000f2,0x00000074,0x000500c7,0x0000000e,0x000000f4, - 0x000000f3,0x000000ef,0x00040070,0x00000006,0x000000f5,0x000000f4,0x0004003d,0x0000000e, - 0x000000f6,0x0000001f,0x000500c2,0x0000000e,0x000000f7,0x000000f6,0x0000007d,0x000500c7, - 0x0000000e,0x000000f8,0x000000f7,0x000000ef,0x00040070,0x00000006,0x000000f9,0x000000f8, - 0x00060050,0x0000000c,0x000000fa,0x000000f1,0x000000f5,0x000000f9,0x0004003d,0x00000006, - 0x000000fb,0x000000e8,0x0005008e,0x0000000c,0x000000fc,0x000000fa,0x000000fb,0x000200fe, - 0x000000fc,0x00010038 + 0x76283565,0x003b3366,0x00030005,0x00000010,0x00000063,0x00060005,0x00000016,0x6c697665, + 0x6e69665f,0x28657469,0x003b3166,0x00030005,0x00000015,0x00000076,0x00060005,0x0000001a, + 0x6c697665,0x656c635f,0x76286e61,0x003b3366,0x00030005,0x00000019,0x00000063,0x00070005, + 0x00000020,0x74736964,0x65636e61,0x2874615f,0x3b326676,0x00000000,0x00030005,0x0000001f, + 0x00007675,0x00060005,0x00000024,0x5f796b73,0x6867696c,0x66762874,0x00003b32,0x00030005, + 0x00000023,0x00007675,0x00070005,0x00000029,0x61706e75,0x725f6b63,0x65396267,0x31752835, + 0x0000003b,0x00030005,0x00000028,0x00000077,0x00030005,0x00000038,0x00000072,0x00040005, + 0x00000039,0x61726170,0x0000006d,0x00030005,0x0000003e,0x00000067,0x00040005,0x0000003f, + 0x61726170,0x0000006d,0x00030005,0x00000044,0x00000062,0x00040005,0x00000045,0x61726170, + 0x0000006d,0x00030005,0x0000004a,0x0000006d,0x00030005,0x00000050,0x00000065,0x00040005, + 0x0000005a,0x6c616373,0x00000065,0x00040005,0x00000096,0x61726170,0x0000006d,0x00040005, + 0x000000a2,0x61726170,0x0000006d,0x00040005,0x000000ae,0x61726170,0x0000006d,0x00030005, + 0x000000bd,0x00000064,0x00050005,0x000000c1,0x74706564,0x65745f68,0x00000078,0x00040005, + 0x000000c8,0x68737550,0x00000000,0x00040006,0x000000c8,0x00000000,0x00766e69,0x00050006, + 0x000000c8,0x00000001,0x657a6973,0x00000000,0x00040006,0x000000c8,0x00000002,0x006d6163, + 0x00040006,0x000000c8,0x00000003,0x006e7573,0x00030005,0x000000ca,0x00006370,0x00040005, + 0x000000ff,0x61726170,0x0000006d,0x00030005,0x00000109,0x00000063,0x00030005,0x0000010a, + 0x00637273,0x00040005,0x0000010e,0x61726170,0x0000006d,0x00030005,0x00000111,0x0000006c, + 0x00040005,0x00000120,0x6c616373,0x00000065,0x00030005,0x00000138,0x00000063,0x00080005, + 0x0000013b,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044,0x00030005, + 0x00000153,0x00007675,0x00040005,0x0000015c,0x73696f6e,0x00000065,0x00040005,0x0000016c, + 0x70657473,0x0076755f,0x00030005,0x00000176,0x00000070,0x00030005,0x0000017c,0x006d7573, + 0x00030005,0x0000017d,0x00000077,0x00030005,0x0000017e,0x00000069,0x00040005,0x00000187, + 0x61726170,0x0000006d,0x00050005,0x00000196,0x7261656e,0x6e75735f,0x00000000,0x00040005, + 0x000001a7,0x66616873,0x00007374,0x00040005,0x000001b8,0x61726170,0x0000006d,0x00050005, + 0x000001c1,0x5f746f64,0x65726568,0x00000000,0x00030005,0x000001ce,0x00747364,0x00040005, + 0x000001da,0x61726170,0x0000006d,0x00030005,0x000001e6,0x00000065,0x00040005,0x000001ea, + 0x61726170,0x0000006d,0x00030005,0x000001ed,0x0074696c,0x00040005,0x000001f7,0x61726170, + 0x0000006d,0x00040047,0x000000c1,0x00000021,0x00000001,0x00040047,0x000000c1,0x00000022, + 0x00000000,0x00030047,0x000000c8,0x00000002,0x00050048,0x000000c8,0x00000000,0x00000023, + 0x00000000,0x00050048,0x000000c8,0x00000001,0x00000023,0x00000008,0x00050048,0x000000c8, + 0x00000002,0x00000023,0x00000010,0x00050048,0x000000c8,0x00000003,0x00000023,0x00000020, + 0x00040047,0x0000010a,0x00000021,0x00000000,0x00040047,0x0000010a,0x00000022,0x00000000, + 0x00040047,0x0000013b,0x0000000b,0x0000001c,0x00040047,0x000001ce,0x00000021,0x00000002, + 0x00040047,0x000001ce,0x00000022,0x00000000,0x00040047,0x000001fb,0x0000000b,0x00000019, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040020,0x00000007,0x00000007,0x00000006,0x00040021,0x00000008,0x00000006,0x00000007, + 0x00040017,0x0000000c,0x00000006,0x00000003,0x00040020,0x0000000d,0x00000007,0x0000000c, + 0x00040015,0x0000000e,0x00000020,0x00000000,0x00040021,0x0000000f,0x0000000e,0x0000000d, + 0x00020014,0x00000013,0x00040021,0x00000014,0x00000013,0x00000007,0x00040021,0x00000018, + 0x0000000c,0x0000000d,0x00040017,0x0000001c,0x00000006,0x00000002,0x00040020,0x0000001d, + 0x00000007,0x0000001c,0x00040021,0x0000001e,0x00000006,0x0000001d,0x00040021,0x00000022, + 0x0000000c,0x0000001d,0x00040020,0x00000026,0x00000007,0x0000000e,0x00040021,0x00000027, + 0x0000000c,0x00000026,0x0004002b,0x00000006,0x0000002c,0x00000000,0x0004002b,0x00000006, + 0x00000032,0x477f8000,0x0004002b,0x0000000e,0x0000003a,0x00000000,0x0004002b,0x0000000e, + 0x00000040,0x00000001,0x0004002b,0x0000000e,0x00000046,0x00000002,0x0004002b,0x00000006, + 0x00000051,0xc1800000,0x0004002b,0x00000006,0x00000053,0x0da24260,0x0004002b,0x00000006, + 0x00000058,0x41800000,0x0004002b,0x00000006,0x0000005c,0x41c00000,0x0004002b,0x00000006, + 0x00000062,0x3f000000,0x0004002b,0x00000006,0x00000065,0x44000000,0x0004002b,0x00000006, + 0x00000069,0x3f800000,0x0004002b,0x00000006,0x0000006c,0x40000000,0x00040015,0x0000007b, + 0x00000020,0x00000001,0x0004002b,0x0000007b,0x0000007c,0x00000009,0x0004002b,0x0000007b, + 0x00000085,0x00000012,0x0004002b,0x0000007b,0x0000008a,0x0000001b,0x0004002b,0x0000000e, + 0x00000091,0x7f800000,0x00090019,0x000000be,0x00000006,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000001,0x00000000,0x0003001b,0x000000bf,0x000000be,0x00040020,0x000000c0, + 0x00000000,0x000000bf,0x0004003b,0x000000c0,0x000000c1,0x00000000,0x00040017,0x000000c4, + 0x00000006,0x00000004,0x00040017,0x000000c7,0x0000007b,0x00000002,0x0006001e,0x000000c8, + 0x0000001c,0x000000c7,0x000000c4,0x000000c4,0x00040020,0x000000c9,0x00000009,0x000000c8, + 0x0004003b,0x000000c9,0x000000ca,0x00000009,0x0004002b,0x0000007b,0x000000cb,0x00000002, + 0x00040020,0x000000cc,0x00000009,0x00000006,0x0004002b,0x0000007b,0x000000d0,0x00000001, + 0x0004002b,0x0000007b,0x000000d2,0x00000000,0x0004002b,0x00000006,0x000000de,0x33d6bf95, + 0x0006002c,0x0000000c,0x000000fd,0x0000002c,0x0000002c,0x0000002c,0x0004002b,0x0000000e, + 0x00000102,0x00000003,0x0004003b,0x000000c0,0x0000010a,0x00000000,0x0004002b,0x00000006, + 0x00000113,0x3e59b3d0,0x0004002b,0x00000006,0x00000114,0x3f371759,0x0004002b,0x00000006, + 0x00000115,0x3d93dd98,0x0006002c,0x0000000c,0x00000116,0x00000113,0x00000114,0x00000115, + 0x0004002b,0x00000006,0x00000119,0x3e4ccccd,0x0004002b,0x00000006,0x0000011a,0x3f400000, + 0x0004002b,0x0000000e,0x00000127,0x000001ff,0x00040020,0x00000137,0x00000007,0x000000c7, + 0x00040017,0x00000139,0x0000000e,0x00000003,0x00040020,0x0000013a,0x00000001,0x00000139, + 0x0004003b,0x0000013a,0x0000013b,0x00000001,0x00040017,0x0000013c,0x0000000e,0x00000002, + 0x00040020,0x00000140,0x00000007,0x0000007b,0x00040020,0x00000143,0x00000009,0x0000007b, + 0x00040020,0x00000158,0x00000009,0x0000001c,0x0004002b,0x00000006,0x0000015d,0x4253ee82, + 0x0004002b,0x00000006,0x0000015e,0x3d897143,0x0004002b,0x00000006,0x00000163,0x3bbf4590, + 0x0004002b,0x0000007b,0x0000016d,0x00000003,0x00040020,0x0000016e,0x00000009,0x000000c4, + 0x0004002b,0x00000006,0x00000174,0x3c911111,0x0004002b,0x0000007b,0x00000185,0x00000030, + 0x0004002b,0x00000006,0x0000018e,0x3f7a5e35,0x0004002b,0x00000006,0x00000197,0x3f8ccccd, + 0x0004002b,0x00000006,0x000001a9,0x42400000,0x0004002b,0x00000006,0x000001b2,0x3eb33333, + 0x0004002b,0x00000006,0x000001b3,0x3f266666,0x0004002b,0x00000006,0x000001c2,0x3b83126f, + 0x0004002b,0x00000006,0x000001c3,0x3bc49ba6,0x00090019,0x000001cc,0x0000000e,0x00000001, + 0x00000000,0x00000000,0x00000000,0x00000002,0x00000021,0x00040020,0x000001cd,0x00000000, + 0x000001cc,0x0004003b,0x000001cd,0x000001ce,0x00000000,0x0004002b,0x00000006,0x000001d2, + 0x40800000,0x0006002c,0x0000000c,0x000001d7,0x00000069,0x00000069,0x00000069,0x00040017, + 0x000001dc,0x0000000e,0x00000004,0x0004002b,0x00000006,0x000001e1,0x38d1b717,0x0004002b, + 0x0000000e,0x000001fa,0x00000008,0x0006002c,0x00000139,0x000001fb,0x000001fa,0x000001fa, + 0x00000040,0x0004002b,0x00000006,0x000001fc,0x3f59999a,0x00050036,0x00000002,0x00000004, + 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000137,0x00000138,0x00000007, + 0x0004003b,0x0000001d,0x00000153,0x00000007,0x0004003b,0x00000007,0x0000015c,0x00000007, + 0x0004003b,0x0000001d,0x0000016c,0x00000007,0x0004003b,0x0000001d,0x00000176,0x00000007, + 0x0004003b,0x0000000d,0x0000017c,0x00000007,0x0004003b,0x00000007,0x0000017d,0x00000007, + 0x0004003b,0x00000140,0x0000017e,0x00000007,0x0004003b,0x0000001d,0x00000187,0x00000007, + 0x0004003b,0x00000007,0x00000196,0x00000007,0x0004003b,0x0000000d,0x000001a7,0x00000007, + 0x0004003b,0x0000000d,0x000001b8,0x00000007,0x0004003b,0x00000007,0x000001c1,0x00000007, + 0x0004003b,0x0000000d,0x000001da,0x00000007,0x0004003b,0x0000000d,0x000001e6,0x00000007, + 0x0004003b,0x00000026,0x000001ea,0x00000007,0x0004003b,0x0000000d,0x000001ed,0x00000007, + 0x0004003b,0x0000000d,0x000001f7,0x00000007,0x0004003d,0x00000139,0x0000013d,0x0000013b, + 0x0007004f,0x0000013c,0x0000013e,0x0000013d,0x0000013d,0x00000000,0x00000001,0x0004007c, + 0x000000c7,0x0000013f,0x0000013e,0x0003003e,0x00000138,0x0000013f,0x00050041,0x00000140, + 0x00000141,0x00000138,0x0000003a,0x0004003d,0x0000007b,0x00000142,0x00000141,0x00060041, + 0x00000143,0x00000144,0x000000ca,0x000000d0,0x0000003a,0x0004003d,0x0000007b,0x00000145, + 0x00000144,0x000500af,0x00000013,0x00000146,0x00000142,0x00000145,0x000400a8,0x00000013, + 0x00000147,0x00000146,0x000300f7,0x00000149,0x00000000,0x000400fa,0x00000147,0x00000148, + 0x00000149,0x000200f8,0x00000148,0x00050041,0x00000140,0x0000014a,0x00000138,0x00000040, + 0x0004003d,0x0000007b,0x0000014b,0x0000014a,0x00060041,0x00000143,0x0000014c,0x000000ca, + 0x000000d0,0x00000040,0x0004003d,0x0000007b,0x0000014d,0x0000014c,0x000500af,0x00000013, + 0x0000014e,0x0000014b,0x0000014d,0x000200f9,0x00000149,0x000200f8,0x00000149,0x000700f5, + 0x00000013,0x0000014f,0x00000146,0x00000005,0x0000014e,0x00000148,0x000300f7,0x00000151, + 0x00000000,0x000400fa,0x0000014f,0x00000150,0x00000151,0x000200f8,0x00000150,0x000100fd, + 0x000200f8,0x00000151,0x0004003d,0x000000c7,0x00000154,0x00000138,0x0004006f,0x0000001c, + 0x00000155,0x00000154,0x00050050,0x0000001c,0x00000156,0x00000062,0x00000062,0x00050081, + 0x0000001c,0x00000157,0x00000155,0x00000156,0x00050041,0x00000158,0x00000159,0x000000ca, + 0x000000d2,0x0004003d,0x0000001c,0x0000015a,0x00000159,0x00050085,0x0000001c,0x0000015b, + 0x00000157,0x0000015a,0x0003003e,0x00000153,0x0000015b,0x00050041,0x00000140,0x0000015f, + 0x00000138,0x0000003a,0x0004003d,0x0000007b,0x00000160,0x0000015f,0x0004006f,0x00000006, + 0x00000161,0x00000160,0x00050085,0x00000006,0x00000162,0x0000015e,0x00000161,0x00050041, + 0x00000140,0x00000164,0x00000138,0x00000040,0x0004003d,0x0000007b,0x00000165,0x00000164, + 0x0004006f,0x00000006,0x00000166,0x00000165,0x00050085,0x00000006,0x00000167,0x00000163, + 0x00000166,0x00050081,0x00000006,0x00000168,0x00000162,0x00000167,0x0006000c,0x00000006, + 0x00000169,0x00000001,0x0000000a,0x00000168,0x00050085,0x00000006,0x0000016a,0x0000015d, + 0x00000169,0x0006000c,0x00000006,0x0000016b,0x00000001,0x0000000a,0x0000016a,0x0003003e, + 0x0000015c,0x0000016b,0x00050041,0x0000016e,0x0000016f,0x000000ca,0x0000016d,0x0004003d, + 0x000000c4,0x00000170,0x0000016f,0x0007004f,0x0000001c,0x00000171,0x00000170,0x00000170, + 0x00000000,0x00000001,0x0004003d,0x0000001c,0x00000172,0x00000153,0x00050083,0x0000001c, + 0x00000173,0x00000171,0x00000172,0x0005008e,0x0000001c,0x00000175,0x00000173,0x00000174, + 0x0003003e,0x0000016c,0x00000175,0x0004003d,0x0000001c,0x00000177,0x00000153,0x0004003d, + 0x0000001c,0x00000178,0x0000016c,0x0004003d,0x00000006,0x00000179,0x0000015c,0x0005008e, + 0x0000001c,0x0000017a,0x00000178,0x00000179,0x00050081,0x0000001c,0x0000017b,0x00000177, + 0x0000017a,0x0003003e,0x00000176,0x0000017b,0x0003003e,0x0000017c,0x000000fd,0x0003003e, + 0x0000017d,0x00000069,0x0003003e,0x0000017e,0x000000d2,0x000200f9,0x0000017f,0x000200f8, + 0x0000017f,0x000400f6,0x00000181,0x00000182,0x00000000,0x000200f9,0x00000183,0x000200f8, + 0x00000183,0x0004003d,0x0000007b,0x00000184,0x0000017e,0x000500b1,0x00000013,0x00000186, + 0x00000184,0x00000185,0x000400fa,0x00000186,0x00000180,0x00000181,0x000200f8,0x00000180, + 0x0004003d,0x0000001c,0x00000188,0x00000176,0x0003003e,0x00000187,0x00000188,0x00050039, + 0x0000000c,0x00000189,0x00000024,0x00000187,0x0004003d,0x00000006,0x0000018a,0x0000017d, + 0x0005008e,0x0000000c,0x0000018b,0x00000189,0x0000018a,0x0004003d,0x0000000c,0x0000018c, + 0x0000017c,0x00050081,0x0000000c,0x0000018d,0x0000018c,0x0000018b,0x0003003e,0x0000017c, + 0x0000018d,0x0004003d,0x00000006,0x0000018f,0x0000017d,0x00050085,0x00000006,0x00000190, + 0x0000018f,0x0000018e,0x0003003e,0x0000017d,0x00000190,0x0004003d,0x0000001c,0x00000191, + 0x0000016c,0x0004003d,0x0000001c,0x00000192,0x00000176,0x00050081,0x0000001c,0x00000193, + 0x00000192,0x00000191,0x0003003e,0x00000176,0x00000193,0x000200f9,0x00000182,0x000200f8, + 0x00000182,0x0004003d,0x0000007b,0x00000194,0x0000017e,0x00050080,0x0000007b,0x00000195, + 0x00000194,0x000000d0,0x0003003e,0x0000017e,0x00000195,0x000200f9,0x0000017f,0x000200f8, + 0x00000181,0x0004003d,0x0000001c,0x00000198,0x00000153,0x00050041,0x0000016e,0x00000199, + 0x000000ca,0x0000016d,0x0004003d,0x000000c4,0x0000019a,0x00000199,0x0007004f,0x0000001c, + 0x0000019b,0x0000019a,0x0000019a,0x00000000,0x00000001,0x00050083,0x0000001c,0x0000019c, + 0x00000198,0x0000019b,0x00060041,0x000000cc,0x0000019d,0x000000ca,0x000000d2,0x00000040, + 0x0004003d,0x00000006,0x0000019e,0x0000019d,0x00060041,0x000000cc,0x0000019f,0x000000ca, + 0x000000d2,0x0000003a,0x0004003d,0x00000006,0x000001a0,0x0000019f,0x00050088,0x00000006, + 0x000001a1,0x0000019e,0x000001a0,0x00050050,0x0000001c,0x000001a2,0x000001a1,0x00000069, + 0x00050085,0x0000001c,0x000001a3,0x0000019c,0x000001a2,0x0006000c,0x00000006,0x000001a4, + 0x00000001,0x00000042,0x000001a3,0x0008000c,0x00000006,0x000001a5,0x00000001,0x00000031, + 0x00000119,0x00000197,0x000001a4,0x00050083,0x00000006,0x000001a6,0x00000069,0x000001a5, + 0x0003003e,0x00000196,0x000001a6,0x0004003d,0x0000000c,0x000001a8,0x0000017c,0x00060050, + 0x0000000c,0x000001aa,0x000001a9,0x000001a9,0x000001a9,0x00050088,0x0000000c,0x000001ab, + 0x000001a8,0x000001aa,0x00060041,0x000000cc,0x000001ac,0x000000ca,0x0000016d,0x00000046, + 0x0004003d,0x00000006,0x000001ad,0x000001ac,0x0005008e,0x0000000c,0x000001ae,0x000001ab, + 0x000001ad,0x00060041,0x000000cc,0x000001af,0x000000ca,0x0000016d,0x00000102,0x0004003d, + 0x00000006,0x000001b0,0x000001af,0x0005008e,0x0000000c,0x000001b1,0x000001ae,0x000001b0, + 0x0004003d,0x00000006,0x000001b4,0x00000196,0x00050085,0x00000006,0x000001b5,0x000001b3, + 0x000001b4,0x00050081,0x00000006,0x000001b6,0x000001b2,0x000001b5,0x0005008e,0x0000000c, + 0x000001b7,0x000001b1,0x000001b6,0x0003003e,0x000001b8,0x000001b7,0x00050039,0x0000000c, + 0x000001b9,0x0000001a,0x000001b8,0x0003003e,0x000001a7,0x000001b9,0x00060041,0x000000cc, + 0x000001ba,0x000000ca,0x000000cb,0x00000046,0x0004003d,0x00000006,0x000001bb,0x000001ba, + 0x0004006e,0x0000007b,0x000001bc,0x000001bb,0x000500c7,0x0000007b,0x000001bd,0x000001bc, + 0x000000cb,0x000500ab,0x00000013,0x000001be,0x000001bd,0x000000d2,0x000300f7,0x000001c0, + 0x00000000,0x000400fa,0x000001be,0x000001bf,0x000001c0,0x000200f8,0x000001bf,0x0004003d, + 0x0000001c,0x000001c4,0x00000153,0x00050041,0x0000016e,0x000001c5,0x000000ca,0x0000016d, + 0x0004003d,0x000000c4,0x000001c6,0x000001c5,0x0007004f,0x0000001c,0x000001c7,0x000001c6, + 0x000001c6,0x00000000,0x00000001,0x00050083,0x0000001c,0x000001c8,0x000001c4,0x000001c7, + 0x0006000c,0x00000006,0x000001c9,0x00000001,0x00000042,0x000001c8,0x0008000c,0x00000006, + 0x000001ca,0x00000001,0x00000031,0x000001c2,0x000001c3,0x000001c9,0x00050083,0x00000006, + 0x000001cb,0x00000069,0x000001ca,0x0003003e,0x000001c1,0x000001cb,0x0004003d,0x000001cc, + 0x000001cf,0x000001ce,0x0004003d,0x000000c7,0x000001d0,0x00000138,0x0004003d,0x0000000c, + 0x000001d1,0x000001a7,0x0005008e,0x0000000c,0x000001d3,0x000001d1,0x000001d2,0x0004003d, + 0x00000006,0x000001d4,0x000001c1,0x00060050,0x0000000c,0x000001d5,0x000001d4,0x0000002c, + 0x0000002c,0x00050081,0x0000000c,0x000001d6,0x000001d3,0x000001d5,0x0007000c,0x0000000c, + 0x000001d8,0x00000001,0x00000025,0x000001d6,0x000001d7,0x0006000c,0x0000000c,0x000001d9, + 0x00000001,0x0000001f,0x000001d8,0x0003003e,0x000001da,0x000001d9,0x00050039,0x0000000e, + 0x000001db,0x00000011,0x000001da,0x00070050,0x000001dc,0x000001dd,0x000001db,0x0000003a, + 0x0000003a,0x0000003a,0x00050063,0x000001cf,0x000001d0,0x000001dd,0x00002000,0x000100fd, + 0x000200f8,0x000001c0,0x0004003d,0x0000000c,0x000001df,0x000001a7,0x00050094,0x00000006, + 0x000001e0,0x000001df,0x000001d7,0x000500b8,0x00000013,0x000001e2,0x000001e0,0x000001e1, + 0x000300f7,0x000001e4,0x00000000,0x000400fa,0x000001e2,0x000001e3,0x000001e4,0x000200f8, + 0x000001e3,0x000100fd,0x000200f8,0x000001e4,0x0004003d,0x000001cc,0x000001e7,0x000001ce, + 0x0004003d,0x000000c7,0x000001e8,0x00000138,0x00060062,0x000001dc,0x000001e9,0x000001e7, + 0x000001e8,0x00002000,0x00050051,0x0000000e,0x000001eb,0x000001e9,0x00000000,0x0003003e, + 0x000001ea,0x000001eb,0x00050039,0x0000000c,0x000001ec,0x00000029,0x000001ea,0x0003003e, + 0x000001e6,0x000001ec,0x0004003d,0x0000000c,0x000001ee,0x000001e6,0x0004003d,0x0000000c, + 0x000001ef,0x000001e6,0x00050085,0x0000000c,0x000001f0,0x000001ee,0x000001ef,0x0004003d, + 0x0000000c,0x000001f1,0x000001a7,0x00050081,0x0000000c,0x000001f2,0x000001f0,0x000001f1, + 0x0003003e,0x000001ed,0x000001f2,0x0004003d,0x000001cc,0x000001f3,0x000001ce,0x0004003d, + 0x000000c7,0x000001f4,0x00000138,0x0004003d,0x0000000c,0x000001f5,0x000001ed,0x0006000c, + 0x0000000c,0x000001f6,0x00000001,0x0000001f,0x000001f5,0x0003003e,0x000001f7,0x000001f6, + 0x00050039,0x0000000e,0x000001f8,0x00000011,0x000001f7,0x00070050,0x000001dc,0x000001f9, + 0x000001f8,0x0000003a,0x0000003a,0x0000003a,0x00050063,0x000001f3,0x000001f4,0x000001f9, + 0x00002000,0x000100fd,0x00010038,0x00050036,0x00000006,0x0000000a,0x00000000,0x00000008, + 0x00030037,0x00000007,0x00000009,0x000200f8,0x0000000b,0x0004003b,0x00000007,0x0000002e, + 0x00000007,0x0004003d,0x00000006,0x0000002b,0x00000009,0x000500ba,0x00000013,0x0000002d, + 0x0000002b,0x0000002c,0x000300f7,0x00000030,0x00000000,0x000400fa,0x0000002d,0x0000002f, + 0x00000034,0x000200f8,0x0000002f,0x0004003d,0x00000006,0x00000031,0x00000009,0x0007000c, + 0x00000006,0x00000033,0x00000001,0x00000025,0x00000031,0x00000032,0x0003003e,0x0000002e, + 0x00000033,0x000200f9,0x00000030,0x000200f8,0x00000034,0x0003003e,0x0000002e,0x0000002c, + 0x000200f9,0x00000030,0x000200f8,0x00000030,0x0004003d,0x00000006,0x00000035,0x0000002e, + 0x000200fe,0x00000035,0x00010038,0x00050036,0x0000000e,0x00000011,0x00000000,0x0000000f, + 0x00030037,0x0000000d,0x00000010,0x000200f8,0x00000012,0x0004003b,0x00000007,0x00000038, + 0x00000007,0x0004003b,0x00000007,0x00000039,0x00000007,0x0004003b,0x00000007,0x0000003e, + 0x00000007,0x0004003b,0x00000007,0x0000003f,0x00000007,0x0004003b,0x00000007,0x00000044, + 0x00000007,0x0004003b,0x00000007,0x00000045,0x00000007,0x0004003b,0x00000007,0x0000004a, + 0x00000007,0x0004003b,0x00000007,0x00000050,0x00000007,0x0004003b,0x00000007,0x0000005a, + 0x00000007,0x00050041,0x00000007,0x0000003b,0x00000010,0x0000003a,0x0004003d,0x00000006, + 0x0000003c,0x0000003b,0x0003003e,0x00000039,0x0000003c,0x00050039,0x00000006,0x0000003d, + 0x0000000a,0x00000039,0x0003003e,0x00000038,0x0000003d,0x00050041,0x00000007,0x00000041, + 0x00000010,0x00000040,0x0004003d,0x00000006,0x00000042,0x00000041,0x0003003e,0x0000003f, + 0x00000042,0x00050039,0x00000006,0x00000043,0x0000000a,0x0000003f,0x0003003e,0x0000003e, + 0x00000043,0x00050041,0x00000007,0x00000047,0x00000010,0x00000046,0x0004003d,0x00000006, + 0x00000048,0x00000047,0x0003003e,0x00000045,0x00000048,0x00050039,0x00000006,0x00000049, + 0x0000000a,0x00000045,0x0003003e,0x00000044,0x00000049,0x0004003d,0x00000006,0x0000004b, + 0x00000038,0x0004003d,0x00000006,0x0000004c,0x0000003e,0x0007000c,0x00000006,0x0000004d, + 0x00000001,0x00000028,0x0000004b,0x0000004c,0x0004003d,0x00000006,0x0000004e,0x00000044, + 0x0007000c,0x00000006,0x0000004f,0x00000001,0x00000028,0x0000004d,0x0000004e,0x0003003e, + 0x0000004a,0x0000004f,0x0004003d,0x00000006,0x00000052,0x0000004a,0x0007000c,0x00000006, + 0x00000054,0x00000001,0x00000028,0x00000052,0x00000053,0x0006000c,0x00000006,0x00000055, + 0x00000001,0x0000001e,0x00000054,0x0006000c,0x00000006,0x00000056,0x00000001,0x00000008, + 0x00000055,0x0007000c,0x00000006,0x00000057,0x00000001,0x00000028,0x00000051,0x00000056, + 0x00050081,0x00000006,0x00000059,0x00000057,0x00000058,0x0003003e,0x00000050,0x00000059, + 0x0004003d,0x00000006,0x0000005b,0x00000050,0x00050083,0x00000006,0x0000005d,0x0000005b, + 0x0000005c,0x0006000c,0x00000006,0x0000005e,0x00000001,0x0000001d,0x0000005d,0x0003003e, + 0x0000005a,0x0000005e,0x0004003d,0x00000006,0x0000005f,0x0000004a,0x0004003d,0x00000006, + 0x00000060,0x0000005a,0x00050088,0x00000006,0x00000061,0x0000005f,0x00000060,0x00050081, + 0x00000006,0x00000063,0x00000061,0x00000062,0x0006000c,0x00000006,0x00000064,0x00000001, + 0x00000008,0x00000063,0x000500be,0x00000013,0x00000066,0x00000064,0x00000065,0x000300f7, + 0x00000068,0x00000000,0x000400fa,0x00000066,0x00000067,0x00000068,0x000200f8,0x00000067, + 0x0004003d,0x00000006,0x0000006a,0x00000050,0x00050081,0x00000006,0x0000006b,0x0000006a, + 0x00000069,0x0003003e,0x00000050,0x0000006b,0x0004003d,0x00000006,0x0000006d,0x0000005a, + 0x00050085,0x00000006,0x0000006e,0x0000006d,0x0000006c,0x0003003e,0x0000005a,0x0000006e, + 0x000200f9,0x00000068,0x000200f8,0x00000068,0x0004003d,0x00000006,0x0000006f,0x00000038, + 0x0004003d,0x00000006,0x00000070,0x0000005a,0x00050088,0x00000006,0x00000071,0x0000006f, + 0x00000070,0x00050081,0x00000006,0x00000072,0x00000071,0x00000062,0x0006000c,0x00000006, + 0x00000073,0x00000001,0x00000008,0x00000072,0x0004006d,0x0000000e,0x00000074,0x00000073, + 0x0004003d,0x00000006,0x00000075,0x0000003e,0x0004003d,0x00000006,0x00000076,0x0000005a, + 0x00050088,0x00000006,0x00000077,0x00000075,0x00000076,0x00050081,0x00000006,0x00000078, + 0x00000077,0x00000062,0x0006000c,0x00000006,0x00000079,0x00000001,0x00000008,0x00000078, + 0x0004006d,0x0000000e,0x0000007a,0x00000079,0x000500c4,0x0000000e,0x0000007d,0x0000007a, + 0x0000007c,0x000500c5,0x0000000e,0x0000007e,0x00000074,0x0000007d,0x0004003d,0x00000006, + 0x0000007f,0x00000044,0x0004003d,0x00000006,0x00000080,0x0000005a,0x00050088,0x00000006, + 0x00000081,0x0000007f,0x00000080,0x00050081,0x00000006,0x00000082,0x00000081,0x00000062, + 0x0006000c,0x00000006,0x00000083,0x00000001,0x00000008,0x00000082,0x0004006d,0x0000000e, + 0x00000084,0x00000083,0x000500c4,0x0000000e,0x00000086,0x00000084,0x00000085,0x000500c5, + 0x0000000e,0x00000087,0x0000007e,0x00000086,0x0004003d,0x00000006,0x00000088,0x00000050, + 0x0004006d,0x0000000e,0x00000089,0x00000088,0x000500c4,0x0000000e,0x0000008b,0x00000089, + 0x0000008a,0x000500c5,0x0000000e,0x0000008c,0x00000087,0x0000008b,0x000200fe,0x0000008c, + 0x00010038,0x00050036,0x00000013,0x00000016,0x00000000,0x00000014,0x00030037,0x00000007, + 0x00000015,0x000200f8,0x00000017,0x0004003d,0x00000006,0x0000008f,0x00000015,0x0004007c, + 0x0000000e,0x00000090,0x0000008f,0x000500c7,0x0000000e,0x00000092,0x00000090,0x00000091, + 0x000500ab,0x00000013,0x00000093,0x00000092,0x00000091,0x000200fe,0x00000093,0x00010038, + 0x00050036,0x0000000c,0x0000001a,0x00000000,0x00000018,0x00030037,0x0000000d,0x00000019, + 0x000200f8,0x0000001b,0x0004003b,0x00000007,0x00000096,0x00000007,0x0004003b,0x00000007, + 0x0000009a,0x00000007,0x0004003b,0x00000007,0x000000a2,0x00000007,0x0004003b,0x00000007, + 0x000000a6,0x00000007,0x0004003b,0x00000007,0x000000ae,0x00000007,0x0004003b,0x00000007, + 0x000000b2,0x00000007,0x00050041,0x00000007,0x00000097,0x00000019,0x0000003a,0x0004003d, + 0x00000006,0x00000098,0x00000097,0x0003003e,0x00000096,0x00000098,0x00050039,0x00000013, + 0x00000099,0x00000016,0x00000096,0x000300f7,0x0000009c,0x00000000,0x000400fa,0x00000099, + 0x0000009b,0x000000a0,0x000200f8,0x0000009b,0x00050041,0x00000007,0x0000009d,0x00000019, + 0x0000003a,0x0004003d,0x00000006,0x0000009e,0x0000009d,0x0007000c,0x00000006,0x0000009f, + 0x00000001,0x00000028,0x0000009e,0x0000002c,0x0003003e,0x0000009a,0x0000009f,0x000200f9, + 0x0000009c,0x000200f8,0x000000a0,0x0003003e,0x0000009a,0x0000002c,0x000200f9,0x0000009c, + 0x000200f8,0x0000009c,0x0004003d,0x00000006,0x000000a1,0x0000009a,0x00050041,0x00000007, + 0x000000a3,0x00000019,0x00000040,0x0004003d,0x00000006,0x000000a4,0x000000a3,0x0003003e, + 0x000000a2,0x000000a4,0x00050039,0x00000013,0x000000a5,0x00000016,0x000000a2,0x000300f7, + 0x000000a8,0x00000000,0x000400fa,0x000000a5,0x000000a7,0x000000ac,0x000200f8,0x000000a7, + 0x00050041,0x00000007,0x000000a9,0x00000019,0x00000040,0x0004003d,0x00000006,0x000000aa, + 0x000000a9,0x0007000c,0x00000006,0x000000ab,0x00000001,0x00000028,0x000000aa,0x0000002c, + 0x0003003e,0x000000a6,0x000000ab,0x000200f9,0x000000a8,0x000200f8,0x000000ac,0x0003003e, + 0x000000a6,0x0000002c,0x000200f9,0x000000a8,0x000200f8,0x000000a8,0x0004003d,0x00000006, + 0x000000ad,0x000000a6,0x00050041,0x00000007,0x000000af,0x00000019,0x00000046,0x0004003d, + 0x00000006,0x000000b0,0x000000af,0x0003003e,0x000000ae,0x000000b0,0x00050039,0x00000013, + 0x000000b1,0x00000016,0x000000ae,0x000300f7,0x000000b4,0x00000000,0x000400fa,0x000000b1, + 0x000000b3,0x000000b8,0x000200f8,0x000000b3,0x00050041,0x00000007,0x000000b5,0x00000019, + 0x00000046,0x0004003d,0x00000006,0x000000b6,0x000000b5,0x0007000c,0x00000006,0x000000b7, + 0x00000001,0x00000028,0x000000b6,0x0000002c,0x0003003e,0x000000b2,0x000000b7,0x000200f9, + 0x000000b4,0x000200f8,0x000000b8,0x0003003e,0x000000b2,0x0000002c,0x000200f9,0x000000b4, + 0x000200f8,0x000000b4,0x0004003d,0x00000006,0x000000b9,0x000000b2,0x00060050,0x0000000c, + 0x000000ba,0x000000a1,0x000000ad,0x000000b9,0x000200fe,0x000000ba,0x00010038,0x00050036, + 0x00000006,0x00000020,0x00000000,0x0000001e,0x00030037,0x0000001d,0x0000001f,0x000200f8, + 0x00000021,0x0004003b,0x00000007,0x000000bd,0x00000007,0x0004003d,0x000000bf,0x000000c2, + 0x000000c1,0x0004003d,0x0000001c,0x000000c3,0x0000001f,0x00070058,0x000000c4,0x000000c5, + 0x000000c2,0x000000c3,0x00000002,0x0000002c,0x00050051,0x00000006,0x000000c6,0x000000c5, + 0x00000000,0x0003003e,0x000000bd,0x000000c6,0x00060041,0x000000cc,0x000000cd,0x000000ca, + 0x000000cb,0x00000046,0x0004003d,0x00000006,0x000000ce,0x000000cd,0x0004006e,0x0000007b, + 0x000000cf,0x000000ce,0x000500c7,0x0000007b,0x000000d1,0x000000cf,0x000000d0,0x000500ab, + 0x00000013,0x000000d3,0x000000d1,0x000000d2,0x000300f7,0x000000d5,0x00000000,0x000400fa, + 0x000000d3,0x000000d4,0x000000d5,0x000200f8,0x000000d4,0x0004003d,0x00000006,0x000000d6, + 0x000000bd,0x00050083,0x00000006,0x000000d7,0x00000069,0x000000d6,0x0003003e,0x000000bd, + 0x000000d7,0x000200f9,0x000000d5,0x000200f8,0x000000d5,0x00060041,0x000000cc,0x000000d8, + 0x000000ca,0x000000cb,0x00000040,0x0004003d,0x00000006,0x000000d9,0x000000d8,0x0004003d, + 0x00000006,0x000000da,0x000000bd,0x00060041,0x000000cc,0x000000db,0x000000ca,0x000000cb, + 0x0000003a,0x0004003d,0x00000006,0x000000dc,0x000000db,0x00050083,0x00000006,0x000000dd, + 0x000000da,0x000000dc,0x0007000c,0x00000006,0x000000df,0x00000001,0x00000028,0x000000dd, + 0x000000de,0x00050088,0x00000006,0x000000e0,0x000000d9,0x000000df,0x000200fe,0x000000e0, + 0x00010038,0x00050036,0x0000000c,0x00000024,0x00000000,0x00000022,0x00030037,0x0000001d, + 0x00000023,0x000200f8,0x00000025,0x0004003b,0x0000001d,0x000000ff,0x00000007,0x0004003b, + 0x0000000d,0x00000109,0x00000007,0x0004003b,0x0000000d,0x0000010e,0x00000007,0x0004003b, + 0x00000007,0x00000111,0x00000007,0x00050041,0x00000007,0x000000e3,0x00000023,0x0000003a, + 0x0004003d,0x00000006,0x000000e4,0x000000e3,0x000500b8,0x00000013,0x000000e5,0x000000e4, + 0x0000002c,0x000400a8,0x00000013,0x000000e6,0x000000e5,0x000300f7,0x000000e8,0x00000000, + 0x000400fa,0x000000e6,0x000000e7,0x000000e8,0x000200f8,0x000000e7,0x00050041,0x00000007, + 0x000000e9,0x00000023,0x00000040,0x0004003d,0x00000006,0x000000ea,0x000000e9,0x000500b8, + 0x00000013,0x000000eb,0x000000ea,0x0000002c,0x000200f9,0x000000e8,0x000200f8,0x000000e8, + 0x000700f5,0x00000013,0x000000ec,0x000000e5,0x00000025,0x000000eb,0x000000e7,0x000400a8, + 0x00000013,0x000000ed,0x000000ec,0x000300f7,0x000000ef,0x00000000,0x000400fa,0x000000ed, + 0x000000ee,0x000000ef,0x000200f8,0x000000ee,0x00050041,0x00000007,0x000000f0,0x00000023, + 0x0000003a,0x0004003d,0x00000006,0x000000f1,0x000000f0,0x000500ba,0x00000013,0x000000f2, + 0x000000f1,0x00000069,0x000200f9,0x000000ef,0x000200f8,0x000000ef,0x000700f5,0x00000013, + 0x000000f3,0x000000ec,0x000000e8,0x000000f2,0x000000ee,0x000400a8,0x00000013,0x000000f4, + 0x000000f3,0x000300f7,0x000000f6,0x00000000,0x000400fa,0x000000f4,0x000000f5,0x000000f6, + 0x000200f8,0x000000f5,0x00050041,0x00000007,0x000000f7,0x00000023,0x00000040,0x0004003d, + 0x00000006,0x000000f8,0x000000f7,0x000500ba,0x00000013,0x000000f9,0x000000f8,0x00000069, + 0x000200f9,0x000000f6,0x000200f8,0x000000f6,0x000700f5,0x00000013,0x000000fa,0x000000f3, + 0x000000ef,0x000000f9,0x000000f5,0x000300f7,0x000000fc,0x00000000,0x000400fa,0x000000fa, + 0x000000fb,0x000000fc,0x000200f8,0x000000fb,0x000200fe,0x000000fd,0x000200f8,0x000000fc, + 0x0004003d,0x0000001c,0x00000100,0x00000023,0x0003003e,0x000000ff,0x00000100,0x00050039, + 0x00000006,0x00000101,0x00000020,0x000000ff,0x00060041,0x000000cc,0x00000103,0x000000ca, + 0x000000cb,0x00000102,0x0004003d,0x00000006,0x00000104,0x00000103,0x000500b8,0x00000013, + 0x00000105,0x00000101,0x00000104,0x000300f7,0x00000107,0x00000000,0x000400fa,0x00000105, + 0x00000106,0x00000107,0x000200f8,0x00000106,0x000200fe,0x000000fd,0x000200f8,0x00000107, + 0x0004003d,0x000000bf,0x0000010b,0x0000010a,0x0004003d,0x0000001c,0x0000010c,0x00000023, + 0x00070058,0x000000c4,0x0000010d,0x0000010b,0x0000010c,0x00000002,0x0000002c,0x0008004f, + 0x0000000c,0x0000010f,0x0000010d,0x0000010d,0x00000000,0x00000001,0x00000002,0x0003003e, + 0x0000010e,0x0000010f,0x00050039,0x0000000c,0x00000110,0x0000001a,0x0000010e,0x0003003e, + 0x00000109,0x00000110,0x0004003d,0x0000000c,0x00000112,0x00000109,0x00050094,0x00000006, + 0x00000117,0x00000112,0x00000116,0x0003003e,0x00000111,0x00000117,0x0004003d,0x0000000c, + 0x00000118,0x00000109,0x0004003d,0x00000006,0x0000011b,0x00000111,0x0008000c,0x00000006, + 0x0000011c,0x00000001,0x00000031,0x00000119,0x0000011a,0x0000011b,0x0005008e,0x0000000c, + 0x0000011d,0x00000118,0x0000011c,0x000200fe,0x0000011d,0x00010038,0x00050036,0x0000000c, + 0x00000029,0x00000000,0x00000027,0x00030037,0x00000026,0x00000028,0x000200f8,0x0000002a, + 0x0004003b,0x00000007,0x00000120,0x00000007,0x0004003d,0x0000000e,0x00000121,0x00000028, + 0x000500c2,0x0000000e,0x00000122,0x00000121,0x0000008a,0x00040070,0x00000006,0x00000123, + 0x00000122,0x00050083,0x00000006,0x00000124,0x00000123,0x0000005c,0x0006000c,0x00000006, + 0x00000125,0x00000001,0x0000001d,0x00000124,0x0003003e,0x00000120,0x00000125,0x0004003d, + 0x0000000e,0x00000126,0x00000028,0x000500c7,0x0000000e,0x00000128,0x00000126,0x00000127, + 0x00040070,0x00000006,0x00000129,0x00000128,0x0004003d,0x0000000e,0x0000012a,0x00000028, + 0x000500c2,0x0000000e,0x0000012b,0x0000012a,0x0000007c,0x000500c7,0x0000000e,0x0000012c, + 0x0000012b,0x00000127,0x00040070,0x00000006,0x0000012d,0x0000012c,0x0004003d,0x0000000e, + 0x0000012e,0x00000028,0x000500c2,0x0000000e,0x0000012f,0x0000012e,0x00000085,0x000500c7, + 0x0000000e,0x00000130,0x0000012f,0x00000127,0x00040070,0x00000006,0x00000131,0x00000130, + 0x00060050,0x0000000c,0x00000132,0x00000129,0x0000012d,0x00000131,0x0004003d,0x00000006, + 0x00000133,0x00000120,0x0005008e,0x0000000c,0x00000134,0x00000132,0x00000133,0x000200fe, + 0x00000134,0x00010038 }; diff --git a/gpu/vk/threaded_rendering.h b/gpu/vk/threaded_rendering.h index 0ecd05b..90e5b40 100644 --- a/gpu/vk/threaded_rendering.h +++ b/gpu/vk/threaded_rendering.h @@ -8,9 +8,10 @@ // // the render thread the replay thread (RX_VK_ASYNC=1, vk_replay.cpp async_on, with Triforce's rules: async_rules.h); // the host asks the renderer whether it runs (HOS_OPT_RENDER_THREAD: host/rx_backend.c rx_async_replay) -// the recorder thread vk_recorder.h's (RX_VK_RECORDER=thread), handed a part at a time: its packets published at the part's -// end and its end and submit made by the recorder (RX_VK_RECORDER_PARTS), the recorder waiting on its -// ring between batches; the render thread goes on into the next part at once +// the recorder thread vk_recorder.h's (RX_VK_RECORDER=thread). ((Triforce, 11-27) Not handed a part at a time any more +// (RX_VK_RECORDER_PARTS=1 alone does that now): with the hand-off the 3D was drawn with wrong +// textures, black characters and white leaves, in v0.8.3 too; without it the picture is right at Off's +// frame rate (the lab's RX 7900 XT; vk_replay.cpp rec_parts_hooks) // the presents the present thread (present_thread.h, RX_VK_PRESENT_THREAD), and the next image asked for on it // right after each present (RX_VK_ACQUIRE_AHEAD) on every card, with a zero timeout where the driver // waits in the acquire; not under frame generation or FIFO. Each present is held on the present @@ -112,7 +113,7 @@ constexpr Choice without_mirrors(const Choice& c, unsigned cores) { inline void describe(char* out, size_t size, const Choice& c, unsigned cores, const char* unsafe, bool by_env) { const char* src = by_env ? " (RX_VK_THREADED)" : ""; switch (c.why) { - case Why::On: std::snprintf(out, size, "On%s: the render thread, the recorder thread by part, the present thread", src); return; + case Why::On: std::snprintf(out, size, "On%s: the render thread, the recorder thread, the present thread", src); return; case Why::Off: std::snprintf(out, size, "Off%s: as before", src); return; case Why::AutoUnsafe: std::snprintf(out, size, "Auto%s: off (not safe on this run: %s)", src, unsafe ? unsafe : "?"); return; case Why::AutoFewCores: diff --git a/gpu/vk/title_tabs.h b/gpu/vk/title_tabs.h new file mode 100644 index 0000000..99b4734 --- /dev/null +++ b/gpu/vk/title_tabs.h @@ -0,0 +1,81 @@ +// (Triforce) The title's tabs: Mods and Save Select at the picture's top left, each with its button's prompt under it. The +// owner: "I want you to move the mod tab and the save select tab to the top left of the screen. I want there to be a button +// prompt below the tabs ... optimize those placements for every aspect ratio" (they were entries under the title's list, +// where Quit Game is now). +// +// Where they are: from the picture's own top left corner (game_grid.h Place: the picture as the present shows it, between +// bars or not), in the game's layout units (2160 down the picture), so that they keep their size against the title's own +// words in every window and are in the corner of what is seen in every shape: a 4:3 or 16:10 picture (the layouts squeezed +// across, and the tabs with them), 16:9, 21:9 and 32:9 (the corner of the wide picture, not of its 16:9 middle), and a +// picture between bars (never in the bars). +// +// The arithmetic alone, in the pixels of the column the entry is drawn on (vk_menu.cpp grid_ctx: 16:9 of the grid's height, +// from 0; put on the window by game_grid::Map after): no ImGui and no Vulkan, tests/test_title_tabs.py compiles it alone. +#pragma once +#include +#include "game_grid.h" + +namespace mkwvk::title_tabs { + +constexpr int kTabs = 2; // (Mods, Save Select) +constexpr float kLeft = 112; // (the first label's left edge from the picture's left edge, units) +constexpr float kTop = 108; // (the labels' middle under the picture's top edge) +constexpr float kText = 52; // (the labels' size: the title's own entries', vk_menu.cpp kTitleText) +constexpr float kBetween = 104; // (from a tab's widest part to the next one's) +constexpr float kIcon = 84; // (the prompt's icon: the game's guides have theirs at 102 beside 48-unit labels) +constexpr float kIconDrop = 92; // (the icon's middle under the label's) +constexpr float kPadX = 34, kPadY = 26; // (the hit box past the label and the icon) + +/// One tab in the column's pixels: its label's middle, its icon's middle, and the box a click or the mouse over it counts in +struct Tab { + float label_x = 0, label_y = 0; + float icon_x = 0, icon_y = 0; + float x0 = 0, y0 = 0, x1 = 0, y1 = 0; +}; +struct Layout { + Tab tab[kTabs]; + int n = 0; +}; + +/// The picture's left and top edges in the pixels of the column drawn on (m: where that column goes in the window). With no +/// picture known yet the grid is the window's own column: its edges +inline float picture_left(const game_grid::Place& g, const game_grid::Map& m) { return m.back_x(g.picture ? g.pic_x : g.x); } +inline float picture_top(const game_grid::Place& g, const game_grid::Map& m) { return m.back_y(g.picture ? g.pic_y : g.y); } +/// The whole picture in the pixels of the column drawn on: the clip rectangle the tabs are drawn in. ((Triforce) the lab's +/// first run of them, the owner's 3416 x 1440 picture: the tabs were not drawn at all. On a picture wider than 16:9 its +/// left edge is left of the column (x under 0 in its pixels), and ImGui leaves out the glyphs of text outside the clip +/// rectangle as it adds them, which was the window's own in the column's pixels) +inline void picture_clip(const game_grid::Place& g, const game_grid::Map& m, float* x0, float* y0, float* x1, float* y1) { + const float px = g.picture ? g.pic_x : g.x, py = g.picture ? g.pic_y : g.y; + const float pw = g.picture ? g.pic_w : g.w, ph = g.picture ? g.pic_h : g.h; + *x0 = m.back_x(px), *y0 = m.back_y(py), *x1 = m.back_x(px + pw), *y1 = m.back_y(py + ph); +} + +/// n tabs from the picture's top left (left, top: picture_left, picture_top). unit: pixels a layout unit (the column's height +/// over 2160); label_w, icon_w: each label's and each icon's width in the column's pixels; icons: the prompts are drawn (a +/// controller's: the hit box reaches under them) +inline Layout place(float left, float top, float unit, const float* label_w, const float* icon_w, int n, bool icons) { + Layout l; + l.n = std::clamp(n, 0, kTabs); + float x = left + kLeft * unit; + for (int i = 0; i < l.n; i++) { + const float w = std::max(label_w[i], icons ? icon_w[i] : 0.0f); // (the icon is centred under the label) + Tab& t = l.tab[i]; + t.label_x = x + w * 0.5f, t.label_y = top + kTop * unit; + t.icon_x = t.label_x, t.icon_y = t.label_y + kIconDrop * unit; + t.x0 = x - kPadX * unit, t.x1 = x + w + kPadX * unit; + t.y0 = t.label_y - (kText * 0.5f + kPadY) * unit; + t.y1 = (icons ? t.icon_y + kIcon * 0.5f * unit : t.label_y + kText * 0.5f * unit) + kPadY * unit; + x += w + kBetween * unit; + } + return l; +} + +/// The tab at a point of the column's pixels, -1 none +inline int at(const Layout& l, float x, float y) { + for (int i = 0; i < l.n; i++) + if (x >= l.tab[i].x0 && x < l.tab[i].x1 && y >= l.tab[i].y0 && y < l.tab[i].y1) return i; + return -1; +} + +} // namespace mkwvk::title_tabs diff --git a/gpu/vk/tpltable.h b/gpu/vk/tpltable.h new file mode 100644 index 0000000..7a19cae --- /dev/null +++ b/gpu/vk/tpltable.h @@ -0,0 +1,103 @@ +// The descriptor templates' per-thread table (no game, no GPU: a rule; vk_draw.cpp set_template, push_template). +// +// ((Triforce, 11-26, the GPU audit's C31, its part (a)) A program's descriptors go to the driver through a template of +// its own: an update template for a program over the push limit (set_template), a push template a bind point for one +// within it (push_template). Both are kept in maps by the program's address behind one mutex, tpl_mu, and each thread +// had 8 entries a kind of template in front of them (one table for sets, one for each bind point's pushes), by +// ((address >> 6) & 7). A frame pushes the descriptors of far more than 8 programs (335 to 535 sets pushed in full a +// frame, each through its template), so most lookups missed the 8, took the global mutex and searched a +// std::unordered_map: that map's lookup alone was 0.8% of the Presentation Thread's time at Lake Hylia and 1.1% in the +// Market (about 0.07 and 0.06 ms a frame), and the replay's helper threads met on the one mutex at every whole push. +// +// Each thread that looks templates up now has one table of kSets sets of kWays entries (512 x 2, 16 KB, for the three +// kinds of template), made at its first lookup and freed when the thread ends (none with RX_VK_TPL_TABLE=0, nor with +// RX_VK_DESC_TEMPLATE=0, which makes no templates), by a multiplicative hash of the key: the program's address with the +// kind in its two low bits. What an entry holds is what the 8 held, a key and the template the locked path gave for it, +// and the caller checks what it finds the same way before using it (the template's layout is still the program's: a +// program whose layout was made again misses, takes the lock and has a new template made, as before). A template is +// immutable once made and never freed in play (a replaced one is kept for its readers), so an entry never names freed +// memory. A miss is the locked path as it was, and its answer is put: in place where the key has an entry, else first +// in its set, the set's first moved to second and the second dropped. Nothing but where a template is found changes: +// the picture cannot. +// +// A set keeps its two keys first in, first out, and a hit does not move a key: a set that three or more of a frame's +// keys fall in misses on each of them every frame. The table does not take every lookup off the lock: in a play test's +// frame statistics, the lines of 400 lookups a frame or more still took it on about 10% of them (21% at worst), and 300 +// programs at scattered addresses lock on about 12% of lookups after the first round (tests/test_tpltable.py). More +// ways or another hash would change that; that is a change of its own, to be measured. +// +// The table is beside the program, not on it: sizeof(Program) is in the shader caches' stamp. +// +// RX_VK_TPL_TABLE=0: the 8 entries, as before. =2 or =check: the check, every find also asked of the map under the lock +// (so every lookup takes it) and the differences counted; the table's template is the one used, as by default. Another +// value is read by its leading number, as atoi reads it: 2 (as in 02 or +2) is the check, 0 the 8 entries when the value +// starts with 0 (as in 00), anything else the wide table, as by default. Any value other than 1 or empty is logged once, +// with what it gives. The lab's knob "notpltable" is the 8 entries in its phases. The frame statistics' line "a frame's +// descriptor templates" counts the lookups and how many of them missed and took the lock for the map, by the switch (not +// the lab's phase at the moment of the line).) +#pragma once +#include +#include +#include +#include + +namespace mkwvk::tpltable { + +enum Mode : int { kOld = 0, kWide = 1, kCheck = 2 }; + +/// RX_VK_TPL_TABLE: the wide table unless set to 0 (the 8 entries) or 2 or check (the wide table, checked against the map) +inline int mode(const char* env) { + if (!env || !*env) return kWide; + if (!std::strcmp(env, "check")) return kCheck; + const int v = std::atoi(env); + return v == 2 ? kCheck : v == 0 && env[0] == '0' ? kOld : kWide; +} + +/// The table before: 8 entries by the program's address +inline constexpr size_t kOldSlots = 8; +constexpr size_t old_slot(uintptr_t p) { + return (p >> 6) & 7; +} + +/// The kinds of template a program has, in its key's two low bits (a program's address is a multiple of 4 at least) +enum Kind : uintptr_t { kSet = 0, kPushGraphics = 1, kPushCompute = 2 }; +inline uintptr_t key_of(const void* program, uintptr_t kind) { + return (uintptr_t)program | kind; +} + +inline constexpr int kSetBits = 9; +inline constexpr size_t kSets = (size_t)1 << kSetBits, kWays = 2; + +/// A key's set: the top bits of its product with 2^64 / the golden ratio (every bit of the key moves them) +constexpr size_t set_of(uintptr_t key) { + return (size_t)(((uint64_t)key * 0x9E3779B97F4A7C15ull) >> (64 - kSetBits)); +} + +struct Entry { + uintptr_t key; // (0: empty; no program is at 0) + const void* t; // (its template, as the locked path gave it) +}; + +/// A thread's table (zeroed: empty). find gives what was put for the key, or null; the caller checks it is still the +/// program's before using it, and puts the locked path's answer after a miss +struct Table { + Entry e[kSets * kWays]; + + const void* find(uintptr_t key) const { + const Entry* s = &e[set_of(key) * kWays]; + if (s[0].key == key) return s[0].t; + if (s[1].key == key) return s[1].t; + return nullptr; + } + void put(uintptr_t key, const void* t) { + Entry* s = &e[set_of(key) * kWays]; + if (s[1].key == key) { // (in place: never two entries for one key) + s[1].t = t; + return; + } + if (s[0].key != key) s[1] = s[0]; + s[0] = {key, t}; + } +}; + +} // namespace mkwvk::tpltable diff --git a/gpu/vk/uboonly.h b/gpu/vk/uboonly.h new file mode 100644 index 0000000..cc5c484 --- /dev/null +++ b/gpu/vk/uboonly.h @@ -0,0 +1,279 @@ +// (Triforce, 11-26) The uniform-buffers-only build of a draw's descriptors (vk_draw.cpp ubo_only_build and draw), apart from Vulkan +// so that tests/test_uboonly.py can run it. The rule is this renderer's own, on desc_keep.h's. +// +// A draw keeps the descriptors of the draw before it only while nothing at all was bound anew (vk_draw.cpp same_gens: bind_gen), +// and every changed uniform buffer bind moves bind_gen (vk_replay.cpp NOP_BIND_UBO). So a draw of the same program that bound one +// per-object uniform buffer of its own ran the whole build_descriptors: every texture's handle read and looked for among the kept +// results, every storage buffer's three words read, the banks' cache asked, the writes made again, about 2,100 builds a frame at +// Lake Hylia, 1,600 to 1,700 of them pushing 1.5 descriptors each ("a frame's descriptors"), on the thread the frame waits for +// (the measured map: build_descriptors 23% of the Presentation Thread's samples there). The program pick has had this split since +// 0.6 (vk_shader.cpp: kept by its stages' tex_gen), and so have the banks (uniform_range: tex_gen, ssbo_gen). +// +// Now such a draw resolves its user uniform buffers alone (c3 to c18, each through kept_uniform as a whole build does, so a stream +// copy is made again and a kept range is taken) and writes them over the thread's last build (dw()), which is otherwise left as it +// is. That is done only where a whole build would have taken every other descriptor from what was kept, so that the two give the +// same writes: +// - the program is one whose other descriptors stand on nothing a uniform buffer bind moves (Maker, made once a program a +// thread, and again after another program took its slot): the kinds of descriptor vk_draw.cpp sig_shape keeps (not compute, +// the mesh fallback or RenoDX's; no texel buffer, no storage image; storage buffers single, read-only, not a simulated turf +// list, not a run-time pointer's, not the miss binding; no constant buffer past c18), but only stages 0 to 4, whose banks are +// kept by their stage's tex_gen and ssbo_gen (sig_shape takes task and mesh stages too), and set programs as well as push +// ones (the signature skip reads push programs only); and besides: no texture handle read through a handle program or from a +// word of c3 on, no storage buffer's address read from a word of c3 on (those are words of the very buffers that were bound +// anew); +// - the thread's last build was this program's, a whole one or one of these after it, and it was bound (Last); +// - no texture, sampler, image or storage buffer was bound to one of the program's stages since (gens_same): then every handle +// and every storage buffer's address and size are the same, and the banks' cache answers as it did; +// - desc_keep.h's stamps are what they were before that whole build began (stamps_same: the recording, the bind stamp, the +// samplers', the destroy and dummy generations, the texture epoch; not ub_generation, which only the uniform buffers stand on, +// and those are asked each time); +// - every descriptor left as it is has a kept result that a build would take now (stands: its kind, the stamps desc_keep.h's +// stamps_of gives that kind, a texture's slot version), no bank or sampler missing: nothing was dropped. Walked once after a +// whole build, and again only when a texture was registered since (a slot's version moves with registrations_generation); +// - the draw may leave textures for later (redrawn.h: one that may not takes no kept dummy), is not a dump's, not the +// upscaler's second recording; the per-binding reuse is on and not checked, the signature skip off, the banks' stage +// generations on, the uniform buffers not snapshots (ub_snapshot_wanted: every Intel GPU, and any other integrated GPU whose +// pools have no VRAM mirror; the rule is not tried there). +// A stamp that moved while the uniform buffers were resolved (a mirror made by one of their binds) makes the whole build follow. +// The textures the draw samples that the GPU wrote are read again from the last whole build's textures, as a build would. +// Anything else: the whole build, as before. +// RX_VK_DESC_UBO_ONLY=0: every such draw builds whole, as before. =check: such a draw is built both ways, the two compared +// descriptor for descriptor and sampled texture for sampled texture, a difference counted and logged ("vk: uniform-buffer-only +// build check"), and the whole build is the one used. So in check every such draw ends in a whole build, and the rule is only +// ever tried right after a whole build: never over a build of the uniform buffers alone, the chain the default mode runs (that +// state is tried by tests/test_uboonly.py alone). Each compared draw resolves its user uniform buffers twice, once a build, so a +// check run's descriptor counts and stream use are neither mode's. Any other value (not 0, 1 or check) is on, and is told once. +// The lab's knob "nouboonly" (RX_VK_LAB_AB) is =0 in its phases. The frame statistics' "a frame's uniform-buffer-only builds" +// line counts them against all builds, and why the others were not (in check, none counts as resolved alone: each was built +// whole). +#pragma once + +#include +#include +#include +#include +#include + +#include "desc_keep.h" + +namespace uboonly { + +/// RX_VK_DESC_UBO_ONLY: unset or anything else, on (1); 0, off; check, both ways and compared (2) +inline int mode_of(const char* env) { + if (!env) return 1; + if (!std::strcmp(env, "check")) return 2; + return env[0] == '0' && !env[1] ? 0 : 1; +} + +/// The mode in this draw: off where a rule above says so, or in the lab's "nouboonly" phases +struct Now { + int mode = 1; // (mode_of) + bool lab_off = false; // (lab_ab::on("nouboonly")) + int keep_mode = 1; // (RX_VK_DESC_KEEP: 1 on, 0 off, 2 checked) + int sig_mode = 0; // (RX_VK_DESC_SIG: 0 off) + bool snapshot = false; // (ub_snapshot_wanted) + bool bank_gen_off = false; // (RX_VK_BANK_GEN_OFF) + bool dump = false, retarget = false; // (dump_on, pre_retarget_on) + bool strict = false; // (a frame left textures and the draw may not: its descriptors are its own; implied by !may_defer) + bool may_defer = true; // (draw_may_defer) +}; +inline int mode_now(const Now& n) { + if (n.mode == 0 || n.lab_off) return 0; + if (n.keep_mode != 1 || n.sig_mode != 0 || n.snapshot || n.bank_gen_off) return 0; + if (n.dump || n.retarget || n.strict || !n.may_defer) return 0; + return n.mode; +} + +inline constexpr int kStages = 5; // (the NVN stages whose banks stand on their own generations: 0 to 4) + +/// A user uniform buffer of the program: the stage's place in Program::stages, its constant buffer index (3 to 18), its place in +/// the build's order (desc_keep::Prog::e) and among the build's buffers (DescWriter::bufs) +struct Ubo { + uint16_t stage = 0, index = 0; + uint32_t j = 0, buf = 0; +}; +/// A descriptor the build leaves as it is: its kind (kC1, kSsbo, kTex; kNone a driver bank, kept by uniform_range's own cache), +/// its place in the build's order and among the build's buffers (a texture: its images) +struct Rest { + uint8_t kind = desc_keep::kNone; + uint32_t j = 0, at = 0; +}; +/// What the uniform-buffers-only build of a program does, made once a program a thread, and again after another program took its +/// slot (its stages do not change once it is translated) +struct Plan { + const void* prog = nullptr; + bool pure = false; // (the rule's first point: false, every build of it is whole) + uint8_t stages = 0; // (its NVN stages, a bit each) + uint32_t n = 0, nbuf = 0, nimg = 0; // (its descriptors, and how many of them are buffers and images) + std::vector ubos; + std::vector rest; +}; +inline constexpr size_t kPlans = 64; +inline size_t plan_slot(const void* prog) { + const uintptr_t p = (uintptr_t)prog; + return (size_t)((p >> 6) ^ (p >> 14)) % kPlans; +} + +/// Makes a program's plan from its stages' lists, called in build_descriptors' order: begin, then for each stage: stage, its +/// constant buffers (one call an element), its storage buffers, its texel buffers, its sampled textures, its storage images +/// (one call a descriptor); end +struct Maker { + Plan& p; + bool ok = true; + uint16_t at_stage = 0; + bool first_stage = true; + explicit Maker(Plan& plan) : p(plan) {} + void begin(const void* prog, bool compute, bool fallback, bool renodx) { + p.ubos.clear(), p.rest.clear(); // (their room kept: a slot another program takes over allocates nothing) + p.prog = prog, p.pure = false, p.stages = 0, p.n = p.nbuf = p.nimg = 0; + ok = !compute && !fallback && !renodx; + first_stage = true, at_stage = 0; + } + void stage(int nvn_stage) { + if (!first_stage) at_stage++; + first_stage = false; + if (nvn_stage < 0 || nvn_stage >= kStages) ok = false; // (compute, task, mesh: their banks stand on bind_gen) + else p.stages |= (uint8_t)(1u << nvn_stage); + } + void cbuf(uint32_t index) { + if (index == 0 || index == 2) p.rest.push_back({desc_keep::kNone, p.n, p.nbuf}); + else if (index == 1) p.rest.push_back({desc_keep::kC1, p.n, p.nbuf}); + else if (index < 3 + 16) p.ubos.push_back({at_stage, (uint16_t)index, p.n, p.nbuf}); + else ok = false; // (no buffer there: nothing kept) + p.n++, p.nbuf++; + } + void storage(uint32_t count, bool written, bool native_bounds, bool sim_turf, uint32_t cbuf_index, uint32_t cbuf_offset) { + // (vk_draw.cpp sig_shape's: a single read-only one, the kind build_descriptors keeps) + if (count != 1 || written || native_bounds || sim_turf || (cbuf_index == 0 && cbuf_offset == 0xff0)) ok = false; + if (cbuf_index >= 3) ok = false; // (its address and size are words of a user uniform buffer: read anew with each bind) + for (uint32_t k = 0; k < count; k++) p.rest.push_back({desc_keep::kSsbo, p.n + k, p.nbuf + k}); + p.n += count, p.nbuf += count; + } + void texel(uint32_t count) { // (texel buffers, uniform or storage: resolved at every build, not kept) + ok = false; + p.n += count; + } + void texture(uint32_t count, bool handle_program, uint32_t cbuf_index, bool has_secondary, uint32_t secondary_cbuf_index) { + if (handle_program) ok = false; // (its handle is computed from storage and constant words at each draw) + if (cbuf_index >= 3 || (has_secondary && secondary_cbuf_index >= 3)) ok = false; // (a handle in a user uniform buffer) + for (uint32_t k = 0; k < count; k++) p.rest.push_back({desc_keep::kTex, p.n + k, p.nimg + k}); + p.n += count, p.nimg += count; + } + void image(uint32_t count) { // (storage images: resolved at every build, the written ones marked) + ok = false; + p.n += count, p.nimg += count; + } + void end() { + p.pure = ok && p.stages != 0; + if (!p.pure) p.ubos.clear(), p.rest.clear(); // (never read) + } +}; + +/// Whether no texture, sampler, image or storage buffer was bound to one of the program's stages since the gens were kept +/// (NvnState::tex_gen, ssbo_gen: what bind_gen was when a stage's last changed) +inline bool gens_same(uint8_t stages, const uint64_t* tex_was, const uint64_t* ssbo_was, const uint64_t* tex_now, const uint64_t* ssbo_now) { + for (int k = 0; k < kStages; k++) + if ((stages >> k & 1) && (tex_was[k] != tex_now[k] || ssbo_was[k] != ssbo_now[k])) return false; + return true; +} + +/// Whether the stamps the descriptors left as they are stand on are the same: all of desc_keep's but ub (the inline uniform +/// updates' generation: only a user uniform buffer stands on it, and each of those is asked again) +inline bool stamps_same(const desc_keep::Stamps& a, const desc_keep::Stamps& b) { + return a.rec == b.rec && a.bind == b.bind && a.samp == b.samp && a.destroy == b.destroy && a.dummy == b.dummy && a.epoch == b.epoch; +} + +/// Whether a whole build would take, now, every descriptor the plan leaves as it is, from kept (the program's kept results, in the +/// build's order): each has a result of its kind kept at the stamps its kind stands on now, a texture at its slot's version now +/// (slot_version(slot)); a texture with no result kept is one whose handle read 0, which resolves to the dummy and its sampler each +/// time. A handle that read 0 leaves its element as it was: one that still holds an older result is judged by it (stale, the +/// program builds whole while the slot stays unbound; standing, dw()'s dummy is what a build would make anyway). A sampler missing +/// (sampler_missing(at)) is a defence only: a whole build with one fails bind_descriptors and is never bound, so no candidate has +/// one. A driver bank that was not made (buffer_missing(at)) is made again. The inputs are not compared: gens_same says they are +/// the same +template +bool stands(const Plan& plan, const std::vector& kept, const desc_keep::Stamps& now, SlotVersion&& slot_version, + BufferMissing&& buffer_missing, SamplerMissing&& sampler_missing) { + if (!plan.pure || kept.size() != plan.n) return false; + for (const Rest& r : plan.rest) { + const desc_keep::Elem& e = kept[r.j]; + const desc_keep::Kind k = (desc_keep::Kind)r.kind; + if (k == desc_keep::kNone) { + if (buffer_missing(r.at)) return false; + continue; + } + if (k == desc_keep::kTex) { + if (sampler_missing(r.at)) return false; + if (e.kind == desc_keep::kNone) continue; + } + if (e.kind != k || e.at != desc_keep::stamps_of(k, now)) return false; + if (k == desc_keep::kTex && e.version != slot_version((uint32_t)(e.in[0] & 0xFFFFF))) return false; + } + return true; +} + +/// A recording thread's last whole build by a draw: whose it was, the stages' generations and the stamps it was made at (the +/// stamps read before it began: one that moves while it resolves makes the next draw build whole again), whether its descriptors +/// were bound (the draw's bookkeeping is that build's), whether a walk found them standing (stands) and the registrations' +/// generation at that walk; the dummies it counted (the frame statistics', counted again by each such draw) +struct Last { + const void* prog = nullptr; + bool bound = false, walked = false; + uint64_t tex[kStages]{}, ssbo[kStages]{}; + desc_keep::Stamps at; + uint64_t reg = 0; + int64_t dummies = 0, dummies_known = 0; +}; +/// A whole build of prog was made (tex_gen, ssbo_gen: the state's, kStages of each at least; before: the stamps read before it) +inline void built(Last& l, const void* prog, const uint64_t* tex_gen, const uint64_t* ssbo_gen, const desc_keep::Stamps& before, + int64_t dummies, int64_t dummies_known) { + l.prog = prog, l.bound = false, l.walked = false; + for (int k = 0; k < kStages; k++) l.tex[k] = tex_gen[k], l.ssbo[k] = ssbo_gen[k]; + l.at = before; + l.dummies = dummies, l.dummies_known = dummies_known; +} +/// A whole build the rule does not stand on (a dump's, the upscaler's second recording's, a strict draw's, the switch off) +inline void forget(Last& l) { l.prog = nullptr, l.bound = false, l.walked = false; } +/// Its descriptors were bound (prog: the program bound) +inline void bound(Last& l, const void* prog) { + if (l.prog == prog) l.bound = true; +} +/// Why a build is whole, or that it is not: counted in the frame statistics' line +enum Why : uint8_t { kFast = 0, kOther, kImpure, kBound, kStale }; +/// The first part of the rule, before the plan is asked for: whether the thread's last build (built_for: DescWriter::prog) and +/// the draw's bookkeeping (last_same: last_desc_valid and last_desc_prog) are this program's last whole build, bound +inline bool candidate(const Last& l, const void* prog, const void* built_for, bool last_same) { + return prog && l.prog == prog && l.bound && built_for == prog && last_same; +} +/// The rule before the uniform buffers are resolved: kFast, or why not. stamps_now(): desc_keep's stamps, read only once the +/// cheaper points hold: they must be the whole build's. walk(now): stands, asked once after a whole build and again when a +/// texture was registered since (reg_gen: a slot's version moves only with it) +template +Why decide(Last& l, const Plan& plan, const void* prog, const void* built_for, bool last_same, const uint64_t* tex_gen, + const uint64_t* ssbo_gen, StampsNow&& stamps_now, uint64_t reg_gen, Walk&& walk) { + if (!candidate(l, prog, built_for, last_same)) return kOther; + if (plan.prog != prog || !plan.pure) return kImpure; + if (!gens_same(plan.stages, l.tex, l.ssbo, tex_gen, ssbo_gen)) return kBound; + const desc_keep::Stamps now = stamps_now(); + if (!stamps_same(l.at, now)) return kStale; + if (l.walked && l.reg == reg_gen) return kFast; + l.walked = false; + if (!walk(now)) return kStale; + l.walked = true, l.reg = reg_gen; + return kFast; +} +/// After the uniform buffers were resolved: whether the stamps are still the whole build's (false: a whole build follows) +inline bool still(const Last& l, const desc_keep::Stamps& after) { + return stamps_same(l.at, after); +} + +/// (RX_VK_DESC_UBO_ONLY=check) Whether a buffer descriptor of the two builds is the same: {buffer, offset, range} equal; or, for a +/// user uniform buffer (ubo) that both builds copied into the recording's stream (stream_a, stream_b), the same range, and the +/// same bytes where both can be read (bytes_same) +inline bool buffer_same(bool ubo, uint64_t buf_a, uint64_t off_a, uint64_t range_a, bool stream_a, uint64_t buf_b, uint64_t off_b, + uint64_t range_b, bool stream_b, bool bytes_same) { + if (buf_a == buf_b && off_a == off_b && range_a == range_b) return true; + return ubo && stream_a && stream_b && buf_a && buf_b && range_a == range_b && bytes_same; +} + +} // namespace uboonly diff --git a/gpu/vk/vk_api.h b/gpu/vk/vk_api.h index 75b370a..37a9ba3 100644 --- a/gpu/vk/vk_api.h +++ b/gpu/vk/vk_api.h @@ -200,6 +200,16 @@ enum { HOS_MENU_SOUND_OPEN = 1, HOS_MENU_SOUND_CLOSE, HOS_MENU_SOUND_CURSOR, HOS /* ((Triforce) 11-17) the Mods entry under the game's lists sounds as those lists do: the system menu's cursor and its "decide" (the title's Continue, the Load list's choice: the lab's file opens, HOS_FS_TRACE) */ HOS_MENU_SOUND_SYS_CURSOR, HOS_MENU_SOUND_SYS_DECIDE, + /* ((Triforce, 11-25) the owner: "The SFX are incorrect. They should be using the title screen's SFX instead of the + in-game Menu SFX." Whose sound it is, a sound each so that each can be set by itself: moving, choosing and going + back on the settings' tabs and on the Mods screen, and going back to the pause menu's System list (out of the + Mods screen opened from it, and Cancel or B on Quit's dialog). The system menu's files unless the environment + names another, a variable of each one's name here: host/menu_sound.c roles) */ + HOS_MENU_SOUND_SETTINGS_NAVIGATE, HOS_MENU_SOUND_SETTINGS_SELECT, HOS_MENU_SOUND_SETTINGS_BACK, + HOS_MENU_SOUND_MODS_NAVIGATE, HOS_MENU_SOUND_MODS_SELECT, HOS_MENU_SOUND_MODS_BACK, HOS_MENU_SOUND_PAUSE_BACK, + /* ((Triforce, 11-25) a toggle of the settings' tabs switched On, and switched Off (the owner, in the lab: "the on + and off SFX are incorrect"): a sound each, set by itself as the seven above are */ + HOS_MENU_SOUND_SETTINGS_ON, HOS_MENU_SOUND_SETTINGS_OFF, HOS_MENU_SOUND_N }; /* (Triforce) The Mods entry under a game list's last button (host/oot_menu.c tells, gpu/vk/vk_menu.cpp draws it): the pause menu's System page and the title's list. Each frame such a list runs, option_set: HOS_OPT_MODS_X0 .. HOS_OPT_MODS_Y1 its @@ -310,6 +320,14 @@ enum { HOS_OPT_SIM_TURF_AREA_TEXT = 410, HOS_OPT_SIM_TURF_AREA }; /* ((Triforce, 11-25) Evil HD's render distance: HOS_OPT_EVIL_HD, option: 1 while Evil HD is on (evil_hd_now: the row, F2, RX_VK_EVIL_FLIP), read each frame by host/evil_hd.c; HOS_EVIL_HD over it. 420: 410 and 411 are the Simulated turf's */ enum { HOS_OPT_EVIL_HD = 420 }; +/* ((Triforce, 11-26) The Frame pacing row's Steady frame rate as it is now: HOS_OPT_STEADY_ROW, option, host/pace_steady.h's + PACE_STEADY_OFF, _ANY or _REFRESH (steady_frame_rate='s values), read each frame by host/nn_vi.c, which took the options + file's at the start before: a change took a restart. HOS_FPS_STEADY over it. No new function: MKWVK_API_VERSION stays */ +enum { HOS_OPT_STEADY_ROW = 430 }; +/* ((Triforce, 11-26) HOS_OPT_RES_HELD, option_set: the Render resolution's scale (1/10000) the host keeps for the next start, 0 + none. Where the render targets' pool is held to its size (host/nn_applet.c hos_rt_pool_pinned), host/nn_vi.c takes no 3D + larger than this run has had at the menu's Apply; the menu says so (gpu/vk/vk_menu.cpp menu_option_set) */ +enum { HOS_OPT_RES_HELD = 431 }; /* (Triforce) More rows of how the game plays (gpu/vk/vk_menu.cpp; 200 to 239 are theirs), each an option: what the row is set to, the game's own at its default. HOS_OPT_FOV: the System tab's Field of view row, percent of the game's own vertical angle in play, 50 to 150, 100 the game's own (host/oot_fov.c). HOS_OPT_TEXT_SIZE: its Text size row, 0 the game's own diff --git a/gpu/vk/vk_dlss.cpp b/gpu/vk/vk_dlss.cpp index 5c6c898..06d84e4 100644 --- a/gpu/vk/vk_dlss.cpp +++ b/gpu/vk/vk_dlss.cpp @@ -435,7 +435,7 @@ int prepare(VkCommandBuffer cmd, uint32_t rw, uint32_t rh, uint32_t ow, uint32_t // size seen changing under one output in this run. RX_VK_DLSS_FEATURE_MAX=1: always the largest, as before static const bool whole_range = dlss_feature::whole_range(getenv("RX_VK_DLSS_FEATURE_MAX")); const dlss_feature::Size made = - dlss_feature::size(aa, whole_range || s.range_seen || opts.resolution == 0, rw, rh, max_w, max_h); + dlss_feature::size(aa, whole_range || s.range_seen || applied_resolution() == 0, rw, rh, max_w, max_h); // ((Triforce, 11-26) as applied) cp.Feature.InWidth = made.w, cp.Feature.InHeight = made.h, cp.Feature.InTargetWidth = ow, cp.Feature.InTargetHeight = oh; cp.Feature.InPerfQualityValue = mode; // (LDR colour, already tonemapped: no exposure; motion at the render size, not jittered; depth not reversed) diff --git a/gpu/vk/vk_draw.cpp b/gpu/vk/vk_draw.cpp index d47315e..6f41bb8 100644 --- a/gpu/vk/vk_draw.cpp +++ b/gpu/vk/vk_draw.cpp @@ -82,6 +82,7 @@ #include "warm_computes.h" // ((Triforce) the compute pipelines the translation pass builds: only play's on Intel, prepare_run) #include "compile_level.h" // ((Triforce, 11-24) Compile shaders, All or Most: compile_level_now) #include "index_rebase.h" // ((Triforce, 11-21, DESC-12) an indexed draw's buffer bound at 0, its offset the first index) +#include "capturepushkeep.h" // ((Triforce, 11-26, C15) a plain draw's capture push left out while zeros are held) #include "predict_stream.h" // ((Triforce, 11-21, PIPE-83) the predicted builder's plan as record numbers) #include "pcache_bound.h" #include "pcache_carry.h" // ((Triforce) the file carried over a stamp change at an update's preparation, capped) @@ -116,6 +117,8 @@ #include "desc_sig.h" // (Triforce: the whole-draw skip by the signature of a draw's descriptor inputs, draw) #include "desc_pool_grow.h" // ((Triforce, 11-22, DESC-33) a slot's descriptor pool at half, whole once a recording runs out) #include "desc_counts.h" // ((Triforce, 11-22, DESC-22) a program's descriptor counts kept with it: build_descriptors) +#include "tpltable.h" // ((Triforce, 11-26, C31) the templates' per-thread table: set_template, push_template) +#include "uboonly.h" // ((Triforce, 11-26) a draw that only bound uniform buffers anew resolves those alone: draw) #include "view_keep.h" // (Triforce: texture looks kept through other textures' ends, texture_view_of) #include "mesh_ahead.h" // (Triforce: a run of indirect mesh draws' records copied at its first, RX_VK_MESH_AHEAD: mesh_indirect_convert) #include "checkpoint_kinds.h" // (Triforce: the markers' kinds and what lies after each, checkpoints_report) @@ -1586,7 +1589,15 @@ void pcache_init() { _fseeki64(f, 0, SEEK_END); const int64_t sz = _ftelli64(f); fclose(f); - if (max_mb > 0 && sz > (max_mb << 20)) { + // ((Triforce, 11-27) not on a PC the library check flagged (nv_own_folder_mark_path): there a start that finds the + // libraries cold makes them all again into this file (2-2.5 GB), and made again from the order at the next start it + // found them cold again: a full preparation at every start (a player's RTX 5090, Linux). Kept as big as it grew) + FILE* own = fopen(nv_own_folder_mark_path().c_str(), "rb"); + if (own) fclose(own); + if (own && max_mb > 0 && sz > (max_mb << 20)) + logf("vk: pipeline cache: the compact one is %lld MB (over %lld), kept: on this PC the libraries were made again " + "into it (%s)", (long long)(sz >> 20), (long long)max_mb, nv_own_folder_mark_path().c_str()); + else if (max_mb > 0 && sz > (max_mb << 20)) { remove(pcache_path.c_str()); logf("vk: pipeline cache: the compact one has grown to %lld MB (over %lld): made again from the last sessions' order", (long long)(sz >> 20), (long long)max_mb); @@ -6436,6 +6447,8 @@ std::atomic st_strict_builds{0}; // ((Triforce, redrawn.h) draws that std::atomic st_push_full{0}, st_push_full_n{0}, st_push_delta{0}, st_push_delta_n{0}, st_push_none{0}, st_push_tpl{0}; std::atomic st_set_new{0}, st_set_new_n{0}, st_set_tpl{0}, st_set_again{0}; std::atomic st_sig_walks{0}, st_sig_hits{0}, st_sig_checked{0}, st_sig_bad{0}; // ((Triforce) desc_sig.h) +// ((Triforce, 11-26, C31; tpltable.h) the templates' lookups: found in the thread's table, taken through tpl_mu, and the check's) +std::atomic st_tpl_fast{0}, st_tpl_locked{0}, st_tpl_checked{0}, st_tpl_bad{0}; inline void count_add(std::atomic& c, int64_t n) { c.store(c.load(std::memory_order_relaxed) + n, std::memory_order_relaxed); } @@ -7113,6 +7126,36 @@ struct Pushed { }; TLS_OBJECT(pushed, std::array) // [graphics, compute] int desc_sig_mode(); // (below: the whole-draw skip by the signature, desc_sig.h) +// ((Triforce, 11-26, the GPU audit's C15; capturepushkeep.h) RX_VK_CAPTURE_PUSH_KEEP: a plain draw's capture push (push_capture) +// left out while its command buffer holds zeros there. Unset or anything else: on (a value but 0, 1 or check is told). 0: +// pushed before every draw, as before. check: pushed before every draw too, and the pushes the rule would have left out +// counted, with those whose bytes the model of the pushes through vk_work.h does not have as zeros (must be 0; 0 by +// construction for every push and bind vk_work.h sees: it checks what pushed and full_pushed claim, not a library's +// recording or a call past the macros). Read once, told when it is not the default. The counts are of the frame +// statistics' "a frame's capture pushes" line (desc_report) +std::atomic st_cap_kept{0}, st_cap_pushed{0}, st_cap_bad{0}; +int capture_keep_mode() { + static const int mode = [] { + const char* const asked = getenv("RX_VK_CAPTURE_PUSH_KEEP"); + const capturepushkeep::Mode m = capturepushkeep::mode_of(asked); + if (m == capturepushkeep::OFF) + logf("vk: RX_VK_CAPTURE_PUSH_KEEP=0: the capture slot is pushed before every plain draw, as before"); + else if (m == capturepushkeep::CHECK) + logf("vk: RX_VK_CAPTURE_PUSH_KEEP=check: the capture slot is pushed before every plain draw, and the pushes the rule " + "would leave out are counted, with those whose bytes differ (the frame statistics' capture pushes line)"); + else if (asked && *asked && strcmp(asked, "1")) + logf("vk: RX_VK_CAPTURE_PUSH_KEEP=%s is not 0, 1 or check: the capture slot is kept, as by default", asked); + return (int)m; + }(); + return mode; +} +int tpl_table_env(); // (below: the templates' per-thread table, tpltable.h) +// ((Triforce, 11-26) uboonly.h, below: the builds that resolved their user uniform buffers alone and how many of those; the builds +// that were the next draw of the program last built (the rule's candidates), and of them the ones built whole for the program's +// kind, for a texture or storage buffer bound since, for a stamp moved or a result not kept; =check: compared, and differing) +int ubo_only_mode(); +std::atomic st_uo_fast{0}, st_uo_ubos{0}, st_uo_same{0}, st_uo_impure{0}, st_uo_bound{0}, st_uo_stale{0}; +std::atomic st_uo_checked{0}, st_uo_bad{0}; /// (Triforce) The frame statistics' line of what the draws' descriptors came to (every 120 presents, after the skips' line) void desc_report(double frames) { static int64_t l[17]; @@ -7144,6 +7187,54 @@ void desc_report(double frames) { snprintf(sig, sizeof sig, "%s", sm ? "on" : "off"); logf("vk: a frame's descriptor signatures: %.0f draws read theirs, %.0f kept the descriptors pushed before them whole (%s)", d[14], d[15], sig); + // ((Triforce, 11-26, C15) capturepushkeep.h: the plain draws' capture pushes left out and made; check: those the rule would + // have left out, and how many of them the pushes' own model did not have as zeros, in all) + { + static int64_t last_kept, last_pushed; + const int64_t kept = st_cap_kept.load(), made = st_cap_pushed.load(); + const int cm = capture_keep_mode(); + char keep[160]; + if (cm == capturepushkeep::CHECK) + snprintf(keep, sizeof keep, "check: every one pushed, the kept ones are those the rule would leave out, %lld of them " + "differed in all", (long long)st_cap_bad.load()); + else + snprintf(keep, sizeof keep, "%s", cm ? "on" : "off"); + logf("vk: a frame's capture pushes: %.0f kept (zeros the command buffer holds), %.0f pushed (%s)", + (double)(kept - last_kept) / frames, (double)(made - last_pushed) / frames, keep); + last_kept = kept, last_pushed = made; + } + // ((Triforce, 11-26, C31; tpltable.h) the templates looked up, and how many of the lookups missed and took tpl_mu and the map; + // labelled by the switch, as the lines above are, not by the lab's phase at this moment) + static int64_t tl[2]; + const int64_t tv[2] = {st_tpl_fast.load(), st_tpl_locked.load()}; + const double fast = (double)(tv[0] - tl[0]) / frames, locked = (double)(tv[1] - tl[1]) / frames; + tl[0] = tv[0], tl[1] = tv[1]; + const int tm = tpl_table_env(); + char wide[160]; + if (tm == tpltable::kCheck) + snprintf(wide, sizeof wide, "check: each one found took the lock too, to ask the map; %lld checked in all, %lld of them " + "not the map's", (long long)st_tpl_checked.load(), (long long)st_tpl_bad.load()); + else + snprintf(wide, sizeof wide, "%s", tm ? "on" : "off"); + logf("vk: a frame's descriptor templates: %.0f looked up, %.0f of them under the lock (the wide table %s)", fast + locked, locked, wide); + // ((Triforce, 11-26) uboonly.h: of the draws that built theirs, those that resolved their user uniform buffers alone) + static int64_t ul[6]; + const int64_t uv[6] = {st_uo_fast.load(), st_uo_ubos.load(), st_uo_same.load(), st_uo_impure.load(), st_uo_bound.load(), + st_uo_stale.load()}; + double u[6]; + for (int i = 0; i < 6; i++) u[i] = (double)(uv[i] - ul[i]) / frames, ul[i] = uv[i]; + const int um = ubo_only_mode(); + char uo[160]; + if (um == 2) + snprintf(uo, sizeof uo, "check: the rule's builds were built whole too, %lld built both ways in all, %lld of them came out " + "otherwise", (long long)st_uo_checked.load(), (long long)st_uo_bad.load()); + else + snprintf(uo, sizeof uo, "%s", um ? "on" : "off"); + logf("vk: a frame's uniform-buffer-only builds: %.0f of %.0f builds resolved their user uniform buffers alone (%.0f uniform " + "buffers); %.0f more were the next draw of the program last built and were built whole: %.0f of a program the rule does " + "not take (its kind), %.0f after a texture, sampler, image or storage buffer bound to its stages, %.0f " + "with a stamp moved or a result not kept (RX_VK_DESC_UBO_ONLY %s)", + u[0], d[0], u[1], std::max(0.0, u[2] - u[0]), u[3], u[4], u[5], uo); } } // namespace bool uniform_snapshot_on() { // ((Triforce) vk_internal.h: ub_snapshot_wanted's answer for vk_memory.cpp's guard) @@ -7447,12 +7538,65 @@ TLS_OBJECT(tpl_data, std::vector) // (the descriptors packed for a te std::mutex tpl_mu; std::unordered_map> tpls; // (never freed in play, as the programs are not) std::vector> tpls_old; // (a program's made again: the old one stays for its readers) +// ((Triforce, 11-26, the GPU audit's C31, its part (a); tpltable.h) A thread's table in front of the templates' maps: 512 sets of 2 +// by a hash of the program's address and the template's kind, where 8 entries by the address were. A frame pushes the descriptors of +// far more than 8 programs, so most lookups took tpl_mu and searched the map (0.8% of the Presentation Thread at Lake Hylia, 1.1% in +// the Market). What is found is checked as before (its layout is the program's), a miss is the locked path as before. Busy frames +// still take the lock on about 10% of their lookups (a set holds two keys; tpltable.h). RX_VK_TPL_TABLE=0: the 8 entries; =2 or +// =check: every find checked against the map; the lab's knob "notpltable": the 8 in its phases) +TLS_OBJECT(tpl_wide, tpltable::Table) +static_assert(alignof(Program) >= 4, "a program's address leaves the two bits of a template's kind free (tpltable::key_of)"); +/// RX_VK_TPL_TABLE, read once: 0, the 8 entries a kind of template, as before; 1, the wide table; 2 or check, and each find checked +int tpl_table_env() { + static const int env = [] { + const char* const asked = getenv("RX_VK_TPL_TABLE"); + const int m = tpltable::mode(asked); + if (m == tpltable::kOld) + logf("vk: RX_VK_TPL_TABLE=%s: the descriptor templates are looked up through 8 entries a kind of template, as before", asked); + else if (m == tpltable::kCheck) + logf("vk: RX_VK_TPL_TABLE=%s: every descriptor template found in a thread's table is checked against the map", asked); + else if (asked && *asked && strcmp(asked, "1")) + logf("vk: RX_VK_TPL_TABLE=%s is not 0, 1, 2 or check: the wide table, as by default", asked); + return m; + }(); + return env; +} +/// The table in force now: the switch's, or the 8 entries in the lab's notpltable phases +int tpl_table_mode() { + const int env = tpl_table_env(); + return lab_ab::on("notpltable") ? tpltable::kOld : env; +} +/// The check (RX_VK_TPL_TABLE=2 or check): whether t, found in the thread's table, is what the map holds for p now. (Another +/// thread making p's template again between the two is counted too: none does in play) +void tpl_check(const std::unordered_map>& map, const Program& p, const SetTemplate* t) { + std::lock_guard lk(tpl_mu); + const auto it = map.find(&p); + count_add(st_tpl_checked, 1); + if (it == map.end() || it->second.get() != t) { + count_add(st_tpl_bad, 1); + static std::atomic told{0}; + if (told++ < 4) logf("vk: descriptor template check: program %016llx's template in the thread's table is not the map's", (unsigned long long)p.key); + } +} /// p's set template, made from dw()'s writes at its first set (immutable once made; null when templates are off) const SetTemplate* set_template(const Program& p) { struct Last { const Program* p; const SetTemplate* t; }; - static thread_local Last last[8]; - Last& l = last[((uintptr_t)&p >> 6) & 7]; - if (l.p == &p && l.t && l.t->layout == p.set_layout) return l.t; + static thread_local Last last[tpltable::kOldSlots]; + const int wide = tpl_table_mode(); + const uintptr_t key = tpltable::key_of(&p, tpltable::kSet); + Last& l = last[tpltable::old_slot((uintptr_t)&p)]; + if (wide) { + const SetTemplate* t = static_cast(tpl_wide().find(key)); + if (t && t->layout == p.set_layout) { + count_add(st_tpl_fast, 1); + if (wide == tpltable::kCheck) tpl_check(tpls, p, t); + return t; + } + } else if (l.p == &p && l.t && l.t->layout == p.set_layout) { + count_add(st_tpl_fast, 1); + return l.t; + } + count_add(st_tpl_locked, 1); std::lock_guard lk(tpl_mu); std::unique_ptr& t = tpls[&p]; if (!t || t->layout != p.set_layout) { @@ -7472,7 +7616,8 @@ const SetTemplate* set_template(const Program& p) { (unsigned long long)p.key); } } - l = {&p, t.get()}; + if (wide) tpl_wide().put(key, t.get()); + else l = {&p, t.get()}; return t.get(); } /// set written with dw()'s descriptors through p's template: false when there is none or they do not fit it (then as before) @@ -7498,10 +7643,23 @@ std::unordered_map> push_tpls[2]; /// p's push template at bp, made from dw()'s writes at its first whole push (immutable once made; null when templates are off) const SetTemplate* push_template(const Program& p, VkPipelineBindPoint bp) { struct Last { const Program* p; const SetTemplate* t; }; - static thread_local Last last[2][8]; + static thread_local Last last[2][tpltable::kOldSlots]; const int k = bp == VK_PIPELINE_BIND_POINT_COMPUTE; - Last& l = last[k][((uintptr_t)&p >> 6) & 7]; - if (l.p == &p && l.t && l.t->pipe_layout == p.layout) return l.t; + const int wide = tpl_table_mode(); // ((Triforce, 11-26, C31; tpltable.h) the thread's wide table first, the 8 entries with it off) + const uintptr_t key = tpltable::key_of(&p, tpltable::kPushGraphics + k); + Last& l = last[k][tpltable::old_slot((uintptr_t)&p)]; + if (wide) { + const SetTemplate* t = static_cast(tpl_wide().find(key)); + if (t && t->pipe_layout == p.layout) { + count_add(st_tpl_fast, 1); + if (wide == tpltable::kCheck) tpl_check(push_tpls[k], p, t); + return t; + } + } else if (l.p == &p && l.t && l.t->pipe_layout == p.layout) { + count_add(st_tpl_fast, 1); + return l.t; + } + count_add(st_tpl_locked, 1); std::lock_guard lk(tpl_mu); std::unique_ptr& t = push_tpls[k][&p]; if (!t || t->pipe_layout != p.layout) { @@ -7522,7 +7680,8 @@ const SetTemplate* push_template(const Program& p, VkPipelineBindPoint bp) { (unsigned long long)p.key); } } - l = {&p, t.get()}; + if (wide) tpl_wide().put(key, t.get()); + else l = {&p, t.get()}; return t.get(); } /// dw()'s descriptors pushed whole at bp through p's push template: false when there is none or they do not fit it (then as before) @@ -7911,6 +8070,9 @@ void push_constants(VkCommandBuffer cmd, const Program& p, const Targets* at, ui std::memcpy(data + Shader::Backend::SPIRV::RENDERAREA_LAYOUT_OFFSET, ra, sizeof ra); } vkCmdPushConstants(cmd, p.layout, p.push_stages, 0, kPushSize, data); + // ((Triforce, 11-26, C15) the block has zeros in the capture's bytes (the macro forgot what was held: capturepushkeep.h)) + static_assert(kPushSize == capturepushkeep::kOffset + capturepushkeep::kSize, "the block ends with the capture's bytes"); + capturepushkeep::full_pushed(mkwvk::cmd_work(cmd).cap, p.push_stages); } } // namespace @@ -8174,6 +8336,188 @@ bool desc_slots_kept(uint64_t reg_gen) { if (texture_slot_version((int)(e & 0xFFFFF)) != (uint32_t)(e >> 20)) return false; return true; } + +// ---- (Triforce, 11-26) The uniform-buffers-only build of a draw's descriptors (uboonly.h) ---- +/// RX_VK_DESC_UBO_ONLY: unset or 1, on: a draw of the program this thread built last, with no texture, sampler, image or storage +/// buffer bound to its stages since, resolves its user uniform buffers alone and leaves the rest of that build as it is (the +/// rule and its conditions: uboonly.h). 0: every such draw builds whole, as before. check: built both ways and compared, the +/// whole build used. Off as well where the rule does not hold: the per-binding reuse off or checked (RX_VK_DESC_KEEP and the +/// switches that turn it off), the signature skip on (RX_VK_DESC_SIG), the uniform buffers snapshots (ub_snapshot_wanted: every +/// Intel GPU, and any other integrated GPU whose pools have no VRAM mirror), the banks kept by bind_gen (RX_VK_BANK_GEN_OFF). Read +/// at the first draw, said once when it is not plainly on, and a value but 0, 1 or check (on) told once +int ubo_only_mode() { + static const int mode = [] { + uboonly::Now n; + const char* const value = getenv("RX_VK_DESC_UBO_ONLY"); + n.mode = uboonly::mode_of(value); + if (value && *value && strcmp(value, "0") && strcmp(value, "1") && strcmp(value, "check")) + logf("vk: RX_VK_DESC_UBO_ONLY=%s is not 0, 1 or check: on", value); + const int asked = n.mode; + n.keep_mode = desc_keep_mode(), n.sig_mode = desc_sig_mode(), n.snapshot = ub_snapshot_wanted(); + n.bank_gen_off = getenv("RX_VK_BANK_GEN_OFF") != nullptr; + const int m = uboonly::mode_now(n); + const char* const why = !asked ? "RX_VK_DESC_UBO_ONLY=0" + : m ? nullptr + : n.keep_mode != 1 ? "the per-binding reuse is off or checked (RX_VK_DESC_KEEP)" + : n.sig_mode ? "the signature skip is on (RX_VK_DESC_SIG)" + : n.snapshot ? "the uniform buffers are snapshots (RX_VK_UB_SNAPSHOT: Intel, or an integrated GPU with no " + "VRAM mirror)" + : "the banks are kept by every binding (RX_VK_BANK_GEN_OFF)"; + if (m != 1) + logf("vk: uniform-buffer-only descriptor builds %s%s%s", m == 2 ? "on, each built whole too and compared, the whole build " + "used (RX_VK_DESC_UBO_ONLY=check)" : "off", why ? ": " : "", why ? why : ""); + return m; + }(); + return mode; +} +/// The mode for the draw being recorded: 0 as well in the lab's "nouboonly" phases (RX_VK_LAB_AB), in a dump, in the temporal +/// upscaler's second recording, and for a draw that may not leave textures for later (redrawn.h: it takes no kept dummy) +int ubo_only_now(bool strict) { + uboonly::Now n; + n.mode = ubo_only_mode(); + if (!n.mode) return 0; + n.lab_off = lab_ab::on("nouboonly"); + n.dump = dump_on(), n.retarget = pre_retarget_on, n.strict = strict, n.may_defer = draw_may_defer; + return uboonly::mode_now(n); +} +TLS_OBJECT(uo_plans, std::array) +/// p's plan: its user uniform buffers and the descriptors beside them, in build_descriptors' order, and whether the rule takes +/// the program at all (uboonly.h Maker; made once a program a thread, as sig_shape, and again after another program took its slot) +const uboonly::Plan& ubo_only_plan(const Program& p) { + uboonly::Plan& plan = uo_plans()[uboonly::plan_slot(&p)]; + if (plan.prog == &p) return plan; + if (!p.ready.load(std::memory_order_acquire)) { // (its stages are filled before ready and never after: not made before) + static const uboonly::Plan none; + return none; + } + uboonly::Maker m(plan); + m.begin(&p, p.compute, p.fallback, p.renodx != 0); + for (const Stage& st : p.stages) { + const Shader::Info& info = st.info; + m.stage(st.nvn_stage); + for (const auto& d : info.constant_buffer_descriptors) + for (uint32_t k = 0; k < d.count; k++) m.cbuf(d.index + k); + for (const auto& d : info.storage_buffers_descriptors) + m.storage(d.count, d.is_written, info.native_global_bounds, Shader::IsSimTurfStorage(d), d.cbuf_index, d.cbuf_offset); + for (const auto& d : info.texture_buffer_descriptors) m.texel(d.count); + for (const auto& d : info.image_buffer_descriptors) m.texel(d.count); + for (const auto& d : info.texture_descriptors) + m.texture(d.count, d.handle_program != ~0U, d.cbuf_index, d.has_secondary, d.secondary_cbuf_index); + for (const auto& d : info.image_descriptors) m.image(d.count); + } + m.end(); + return plan; +} +/// The stamps the descriptors such a build leaves stand on, now (uboonly.h stamps_same: not the inline uniform updates') +desc_keep::Stamps ubo_only_stamps() { + desc_keep::Stamps now; + now.rec = desc_rec, now.bind = gpu_bind_stamp(); + now.samp = sampler_registrations_generation(), now.destroy = texture_destroy_generation(); + now.dummy = texture_dummy_generation(), now.epoch = texture_epoch(); + return now; +} +thread_local uboonly::Last uo_last; // (this thread's last whole build by a draw) +/// (RX_VK_DESC_UBO_ONLY=check) What the uniform-buffers-only build made, for the whole build after it to be compared with +struct UboOnlyCheck { + std::vector bufs; + std::vector imgs; + std::vector sampled; + std::vector is_ubo; +}; +TLS_OBJECT(uo_check, UboOnlyCheck) +thread_local bool uo_check_armed = false; +/// The uniform-buffers-only build of p's descriptors for a draw, where uboonly.h's rule holds: true, and the thread's last build +/// (dw()) is this draw's, its user uniform buffers resolved anew, each through kept_uniform as build_descriptors does, and +/// draw_sampled() the textures it samples that the GPU wrote. False: nothing a whole build does not make again was changed, and +/// the whole build follows. last_same: the draw's bookkeeping is of p (last_desc_valid, last_desc_prog). check: the same, and +/// what it made is kept for ubo_only_built to compare with the whole build's; false then +bool ubo_only_build(const NvnState& s, const Program& p, bool last_same, uint64_t reg_gen, bool check) { + auto& dwr = dw(); + uboonly::Last& l = uo_last; + if (!uboonly::candidate(l, &p, dwr.prog, last_same)) return false; // (before the plan: most builds are another program's) + count_add(st_uo_same, 1); + const uboonly::Plan& plan = ubo_only_plan(p); + const uboonly::Why why = uboonly::decide(l, plan, &p, dwr.prog, last_same, s.tex_gen, s.ssbo_gen, ubo_only_stamps, reg_gen, + [&](const desc_keep::Stamps& now) { + if (dwr.bufs.size() != plan.nbuf || dwr.imgs.size() != plan.nimg) return false; + return uboonly::stands(plan, desc_keep::prog_of(kept_descs(), &p, plan.n).e, now, + [](uint32_t slot) { return texture_slot_version((int)slot); }, + [&](uint32_t at) { return dwr.bufs[at].buffer == VK_NULL_HANDLE; }, + [&](uint32_t at) { return dwr.imgs[at].sampler == VK_NULL_HANDLE; }); + }); + if (why != uboonly::kFast) { + count_add(why == uboonly::kImpure ? st_uo_impure : why == uboonly::kBound ? st_uo_bound : st_uo_stale, 1); + return false; + } + desc_keep::Prog& kp = desc_keep::prog_of(kept_descs(), &p, plan.n); + ub_prog_key = p.key; // (the Grass distance row: uniform_range, as build_descriptors sets it first) + // (every one, not only those bound anew: a copy in the recording's stream is never kept and is made again by each build) + for (const uboonly::Ubo& u : plan.ubos) dwr.bufs[u.buf] = kept_uniform(&kp, u.j, s, p.stages[u.stage], u.index); + // (a mirror made by one of those binds moves the bind stamp: a whole build would resolve the storage buffers after it again) + if (!uboonly::still(l, ubo_only_stamps())) { + count_add(st_uo_stale, 1); + return false; + } + auto& sampled = draw_sampled(); // (as the build left built_textures(): the ones the GPU wrote, read again as a build would) + sampled.clear(); + for (const void* t : built_textures()) + if (static_cast(t)->gpu_written) sampled.push_back(static_cast(t)); + if (check) { // (built whole after it: not counted as resolved alone) + UboOnlyCheck& c = uo_check(); + c.bufs = dwr.bufs, c.imgs = dwr.imgs, c.sampled = sampled; + c.is_ubo.assign(dwr.bufs.size(), 0); + for (const uboonly::Ubo& u : plan.ubos) c.is_ubo[u.buf] = 1; + uo_check_armed = true; + return false; + } + count_add(st_uo_fast, 1), count_add(st_uo_ubos, (int64_t)plan.ubos.size()); + st_dummy_textures += l.dummies, st_dummy_known += l.dummies_known; // (the frame statistics': as its build counted them) + return true; +} +/// (RX_VK_DESC_UBO_ONLY=check) The whole build of a draw whose uniform-buffers-only build was kept: whether the two made the same +/// descriptors (a user uniform buffer copied into the stream by both: the same range and bytes, at its own place) and the same +/// sampled textures the GPU wrote; counted, and logged (40 times) when not +void ubo_only_compare(const Program& p) { + uo_check_armed = false; + const UboOnlyCheck& c = uo_check(); + auto& dwr = dw(); + count_add(st_uo_checked, 1); + const char* what = nullptr; + size_t at = 0; + if (c.bufs.size() != dwr.bufs.size() || c.imgs.size() != dwr.imgs.size()) what = "another number of descriptors"; + for (size_t i = 0; !what && i < c.bufs.size(); i++) { + const VkDescriptorBufferInfo &a = c.bufs[i], &b = dwr.bufs[i]; + const bool sa = a.buffer && recording_stream(a.buffer), sb = b.buffer && recording_stream(b.buffer); + bool bytes = true; // (compared only when both copies are in the current stream: a pair with either copy in an older stream + // of the recording passes on its range) + if (c.is_ubo[i] && sa && sb && a.range == b.range && cur && a.buffer == cur->stream && b.buffer == cur->stream && cur->mapped && + a.range != VK_WHOLE_SIZE) + bytes = !std::memcmp(cur->mapped + a.offset, cur->mapped + b.offset, (size_t)a.range); + if (!uboonly::buffer_same(c.is_ubo[i] != 0, (uint64_t)(uintptr_t)a.buffer, a.offset, a.range, sa, (uint64_t)(uintptr_t)b.buffer, + b.offset, b.range, sb, bytes)) + what = c.is_ubo[i] ? "another user uniform buffer" : "another buffer beside the user uniform buffers", at = i; + } + for (size_t i = 0; !what && i < c.imgs.size(); i++) + if (c.imgs[i].sampler != dwr.imgs[i].sampler || c.imgs[i].imageView != dwr.imgs[i].imageView) + what = "another texture or sampler", at = i; + if (!what && c.sampled != draw_sampled()) what = "other sampled textures the GPU wrote"; + if (!what) return; + count_add(st_uo_bad, 1); + static std::atomic told{0}; + if (told++ < 40) + logf("vk: uniform-buffer-only build check: program %016llx: the whole build made %s (at %zu of its kind)", + (unsigned long long)p.key, what, at); +} +/// A draw built p's descriptors whole. uo: the mode for that draw (ubo_only_now): with it the build is what the next draws' rule +/// stands on, without it none is (a dump's or the upscaler's second recording's is not through the per-binding reuse, a strict +/// draw's is its own). before: the stamps read before the build. dummies, dummies_known: what it added to the frame statistics' +void ubo_only_built(const NvnState& s, const Program& p, int uo, const desc_keep::Stamps& before, int64_t dummies, + int64_t dummies_known) { + if (uo) uboonly::built(uo_last, &p, s.tex_gen, s.ssbo_gen, before, dummies, dummies_known); + else uboonly::forget(uo_last); + if (uo_check_armed) ubo_only_compare(p); +} + thread_local VkPipeline last_pipeline = VK_NULL_HANDLE; struct LastVb { VkBuffer b[16]; VkDeviceSize o[16], z[16], s[16]; }; thread_local LastVb last_vb; @@ -11092,6 +11436,10 @@ static const char* skin_check(const NvnState& s, const Program& p, const DrawArg if (d.mesh || d.indirect || d.instances != 1 || !at.n || !at.color[0] || !at.depth || !temporal_scene_size(at.width, at.height) || !temporal_scene_format(at.color_format[0]) || !temporal_motion_wanted()) return "not a plain draw into the scene"; // ((Triforce) AMD FSR 3.1's motion too: temporal_motion_wanted) + // ((Triforce, 11-27, after a player's patch in #bug-tracker "FSR4_navighostingfix.patch") Navi ghosted over Link with an + // upscaler on: her glow is drawn blended and without a depth test, so it has no depth of its own, and its motion was + // paired with the frame before's and dragged with the camera. Only opaque, depth-tested draws give the upscaler motion + if (!s.ds.dt || (s.color.blend_en & 1)) return "the draw does not cover opaque scene depth"; if (s.nvattr < 7) return "fewer than 7 vertex attributes"; const auto attr = [&](int i) { return *reinterpret_cast(&s.vattr[i]); }; const nvn_va_st pos = attr(0); @@ -11139,14 +11487,38 @@ static const char* skin_check(const NvnState& s, const Program& p, const DrawArg /// an address left from another draw would be written to. Only a plain, single-instance draw of triangles into the scene /// (its colour target 0 and depth) is given a slot, by the temporal upscaler's chain when it wants positions /// (vk_temporal.cpp capture_motion). capture: this draw may be one (false: an indirect draw, quads) +/// ((Triforce, 11-26) Whether a draw into the scene gets a motion of its own: not one that blends over the scene (target 0 +/// blending). The owner's "white lines" traced by particles after some area loads, caught at last (F8 and F9, Kokiri Forest, +/// AMD FSR 4 before bloom): the frame's steps are clean up to the scene's last particle draw and the lines are there right +/// after the upscaler, rings round every firefly. Every plain draw of triangles was given its own motion, the fireflies, +/// the fairies' glows and the fog cards blended over the scene among them: the upscaler then moved what is behind each sprite +/// as the sprite moved, and drew its outline and its trail into its history. What is blended over the scene is to carry the +/// motion of what is behind it (reactive_policy.h: the reactive mask is for those pixels); the camera's motion stays theirs. +/// RX_VK_DLSS_BLENDED_MOTION=1: a motion of their own too, as before (a lab switch, for the comparison) +static bool own_motion(const NvnState& s) { + static const bool blended_too = getenv("RX_VK_DLSS_BLENDED_MOTION") && atoi(getenv("RX_VK_DLSS_BLENDED_MOTION")) != 0; + if (blended_too || (s.color.blend_en & 1) == 0) return true; + static std::atomic told{false}; // (said once, at the first: a report with an upscaler's motion says which rule ran) + if (!told.exchange(true, std::memory_order_relaxed)) + logf("vk: the upscaler's motion: draws blended over the scene keep the camera's (RX_VK_DLSS_BLENDED_MOTION=1: their own)"); + return false; +} +/// ((Triforce, 11-26, the GPU audit's C15; capturepushkeep.h) Not pushed when it is zeros and the command buffer is known to +/// hold zeros there for this program's push stages: with no upscaler's chain asking, every draw pushed the same 16 zeros. +/// Every other push and bind forgets that (vk_work.h's macros, this one's own too: it notes what it left after), and so do a +/// new recording and every library's own recording (the recorder's B_DIRECT boundary: direct_gen); draw()'s program bind +/// takes it back only for the same push stages, and not after a draw state reset. RX_VK_CAPTURE_PUSH_KEEP=0: pushed before +/// every draw, as before; =check: pushed, and the rule's keeps counted against the model of the pushes through vk_work.h +/// (0 by construction for those: it checks what pushed and full_pushed claim, not the bind rule, a library's recording or a +/// call past the macros); the lab's knob nocappush: pushed in its phases) static void push_capture(VkCommandBuffer cmd, const Program& p, const NvnState& s, const DrawArgs& d, const Targets& at, VkPrimitiveTopology topo, bool capture) { if (!p.captures) return; CaptureSlot slot; - if (capture && !d.mesh && !d.indirect && d.instances <= 1 && d.count > 0 && at.n && at.color[0] && at.depth && + if (capture && own_motion(s) && !d.mesh && !d.indirect && d.instances <= 1 && d.count > 0 && at.n && at.color[0] && at.depth && (topo == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST || topo == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP || topo == VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN) && temporal_capture_wanted() && temporal_scene_size(at.width, at.height) && - temporal_scene_format(at.color_format[0])) { + temporal_scene_format(at.color_format[0]) && s.ds.dt && !(s.color.blend_en & 1)) { // ((Triforce, 11-27) as skin_check's CaptureDraw k; k.depth = at.depth, k.vbuf = s.vbuf[0].address, k.program = p.key, k.count = d.count; k.camera = s.ubo[0][0].addr, k.camera_size = s.ubo[0][0].size; @@ -11163,7 +11535,30 @@ static void push_capture(VkCommandBuffer cmd, const Program& p, const NvnState& static_assert(Shader::Backend::SPIRV::CAPTURE_FIRST_PUSH_OFFSET == Shader::Backend::SPIRV::CAPTURE_PUSH_OFFSET + 8 && Shader::Backend::SPIRV::CAPTURE_COUNT_PUSH_OFFSET == Shader::Backend::SPIRV::CAPTURE_PUSH_OFFSET + 12, "push_capture's layout"); + static_assert(capturepushkeep::kOffset == Shader::Backend::SPIRV::CAPTURE_PUSH_OFFSET && capturepushkeep::kSize == sizeof data, + "capturepushkeep.h's bytes"); + const int mode = capture_keep_mode(); + if (mode != capturepushkeep::OFF) { + const mkwvk::CmdWork& w = mkwvk::cmd_work(cmd); + if (capturepushkeep::keep(w.cap, w.known, p.push_stages, data)) { + if (mode == capturepushkeep::CHECK) { // (pushed all the same; a keep over bytes not known to be zeros is the rule's fault) + count_add(st_cap_kept, 1); + if (capturepushkeep::check_differs(w.cap)) { + st_cap_bad.fetch_add(1, std::memory_order_relaxed); // (exact with the helper threads: the count that must be 0) + static std::atomic told{0}; + if (told.fetch_add(1, std::memory_order_relaxed) < 8) + logf("vk: capture push check: program %016llx: the rule would keep a push over bytes that are not known " + "to be zeros (RX_VK_CAPTURE_PUSH_KEEP=check)", (unsigned long long)p.key); + } + } else if (!lab_ab::on("nocappush")) { // (lab: pushed in the knob's phases, as before) + count_add(st_cap_kept, 1); + return; + } + } + } vkCmdPushConstants(cmd, p.layout, p.push_stages, Shader::Backend::SPIRV::CAPTURE_PUSH_OFFSET, sizeof data, data); + count_add(st_cap_pushed, 1); + if (mode != capturepushkeep::OFF) capturepushkeep::pushed(mkwvk::cmd_work(cmd).cap, p.push_stages, data); } static bool writes_memory(const Program& p) { @@ -11258,7 +11653,10 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { { PROF_HOT(PROF_PROGRAM); ParLock lk(d.mesh); // (graphics programs: each thread's picks, program_pick's own lock) - cp = program_for(s, d.mesh ? ProgramKind::Mesh : ProgramKind::Graphics, types); + // ((Triforce, 11-26, the GPU audit's C02; pickwide.h) a graphics program from the wide memo in front of program_for + // (RX_VK_PICK_WIDE=0: program_for alone) + if (d.mesh) cp = program_for(s, ProgramKind::Mesh, types); + else cp = program_for_wide(s, types); } if (use.on) use.program(cp, cp && cp->ready.load(std::memory_order_acquire)), use.count_skips(&st_pending_skips); { // (hookshot, a test) RX_VK_NO_MESH=1: task / mesh draws left out, to see what they draw; =2: the others left out @@ -11629,13 +12027,23 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { pushed()[0].layout == p.layout && desc_sig::hit(sig_bound(), sig, &p); const bool same_desc = same_gens || (sig_hit && sig_mode == 1); bool sig_armed = false; // (the build below kept every descriptor: its signature may stand for them) + bool uo_fast = false; // ((Triforce, 11-26) the build below resolved the user uniform buffers alone: uboonly.h) if (!same_desc) { PROF_HOT(PROF_DESC); FINE_N(FC_BUILDS, 1); trace_tex_hit = nullptr, trace_tex_mask = 0; count_add(st_dk_builds, 1); const int64_t drops = desc_drops, dummies0 = desc_dummies, known0 = desc_dummies_known; - build_descriptors(s, p, true, scene); // (textures first used here are uploaded by the recording's upload command buffer) + // ((Triforce, 11-26) uboonly.h: the next draw of the program this thread built last, with nothing but uniform buffers bound + // anew since, resolves its user uniform buffers alone and leaves the rest of that build as it is: a whole build would take + // each of the others from what was kept. RX_VK_DESC_UBO_ONLY=0: built whole, as before; =check: both ways, compared) + const int uo = no_reuse ? 0 : ubo_only_now(strict); + uo_fast = uo && ubo_only_build(s, p, last_desc_valid && last_desc_prog == &p, reg_gen, uo == 2); + if (!uo_fast) { + const desc_keep::Stamps uo_at = uo ? ubo_only_stamps() : desc_keep::Stamps{}; // (read before the build: uboonly.h) + build_descriptors(s, p, true, scene); // (textures first used here are uploaded by the recording's upload command buffer) + ubo_only_built(s, p, uo, uo_at, desc_dummies - dummies0, desc_dummies_known - known0); + } FINE_N(FC_WRITES, (int64_t)dw().writes.size()); if (sig_walked) { // ((Triforce) desc_sig.h: what it left besides the descriptors, for a draw that keeps them) sig_armed = desc_drops == drops; @@ -11764,7 +12172,13 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { if (bound) { FINE_SCOPE(FT_BINDPL); FINE_N(FC_BIND_PIPE, 1); + const uint32_t cap_held = mkwvk::cmd_work(cmd).cap.zero_stages; // ((Triforce, 11-26, C15) below) + const bool cap_reset = last_pipeline == VK_NULL_HANDLE; vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pl), last_pipeline = pl; + // ((Triforce, 11-26, C15) the one bind after which a capture push's zeros are held again (capturepushkeep.h; the + // macro forgot them as at any bind): for the same push stages, and not when the draw state was reset before it + // (last_pipeline cleared: other things were recorded) + capturepushkeep::program_bound(mkwvk::cmd_work(cmd).cap, cap_held, p.push_stages, cap_reset); // ((Triforce, 11-22) a mesh pipeline has the vertex strides static (only the other pipelines have them dynamic, // build_graphics' dyn): binding it leaves the strides undefined for the next pipeline that has them dynamic, as it does // the topology (dyn_pack sets that again after a mesh draw). The next vertex draw binds all 16 streams again, strides @@ -11782,12 +12196,20 @@ void draw(VkCommandBuffer cmd, NvnState& s, const DrawArgs& d) { FINE_SCOPE(FT_BINDDESC); if (sig_hit) sig_check(cmd, p); // ((Triforce) RX_VK_DESC_SIG=check: before the push changes what is pushed) if (!bind_descriptors(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, p)) SKIP_HERE(); - last_desc_valid = true, last_desc_prog = &p, last_desc_bind = s.bind_gen, last_desc_reg = reg_gen; - last_desc_ub = ub_gen, last_desc_dgen = dgen, last_desc_scene = scene; - last_desc_fp_on = desc_fp_on; - if (desc_fp_on) // (RX_VK_DESC_SLOTGEN: what its handles resolved; the next such draw may keep it through other slots' churn) - last_desc_fp() = desc_fp(), last_desc_fp_dummy = desc_fp_dummy, last_desc_samp = desc_samp_seen, - last_desc_destroy = desc_destroy_seen; + // ((Triforce, 11-26) uboonly.h: a build of the uniform buffers alone moves only what stands on them, the bindings' and the + // inline updates' generations; the textures' side (the registrations, the slots read, the destroy generation) stays the + // whole build's, which the next draw's same_gens asks as before) + if (uo_fast) { + last_desc_bind = s.bind_gen, last_desc_ub = ub_gen; + } else { + last_desc_valid = true, last_desc_prog = &p, last_desc_bind = s.bind_gen, last_desc_reg = reg_gen; + last_desc_ub = ub_gen, last_desc_dgen = dgen, last_desc_scene = scene; + last_desc_fp_on = desc_fp_on; + if (desc_fp_on) // (RX_VK_DESC_SLOTGEN: what its handles resolved; the next such draw may keep it through other slots' churn) + last_desc_fp() = desc_fp(), last_desc_fp_dummy = desc_fp_dummy, last_desc_samp = desc_samp_seen, + last_desc_destroy = desc_destroy_seen; + uboonly::bound(uo_last, &p); // (the bookkeeping above is this whole build's) + } // ((Triforce) desc_sig.h: the bind point's descriptors are this build's now; its signature stands for them only when walked // before it and nothing was dropped) if (sig_walked) desc_sig::commit(sig_bound(), sig, sig_armed); @@ -12276,7 +12698,9 @@ static bool movie_keep_all_networks() { } static bool typed_upscale(VkCommandBuffer cmd, VkImageView input_view, VkImageView output_view, - Texture* out, uint32_t level, uint64_t key, const char* keys, bool temporal); + Texture* out, uint32_t level, uint64_t key, const char* keys, bool temporal, uint32_t out_w = 0, uint32_t out_h = 0); +static bool wide_upscale(VkCommandBuffer cmd, VkImageView input_view, Texture* out, uint32_t level, uint64_t key, const char* keys, + bool temporal); static bool temporal_rejected_network(VkCommandBuffer cmd, uint64_t key, Texture* src, const nvn_tex* in, Texture* dst, const nvn_tex* out); void stub_picture_written(VkCommandBuffer cmd, Texture* hud, Texture* fx); // ((Triforce) below: the ReShade preset's, after the lock) @@ -12457,6 +12881,21 @@ bool upscale_stub(VkCommandBuffer cmd, const NvnState& s, uint64_t key) { if (!warned_gameplay_upscale.exchange(true, std::memory_order_relaxed)) logf("vk: gameplay RGB9E5 upscale unavailable; the fallback blit may have incorrect colors"); } + // ((Triforce, 11-26) RenoDX's RGBA16F scene: a network's input is the square root of the scene colour, which the blit below + // copied as it is (Render resolution 67% and 50% on the lab's RX 7900 XT: the 3D veiled in white). wide_upscale squares it + // back, under the lock held since above + if (src->format == VK_FORMAT_R16G16B16A16_SFLOAT && dst->format == VK_FORMAT_R16G16B16A16_SFLOAT && src->type == VK_IMAGE_TYPE_2D && + dst->type == VK_IMAGE_TYPE_2D && src->depth == 1 && dst->depth == 1 && src->layers == 1 && dst->layers == 1 && !src->skip) { + const VkImageView input_view = texture_view(src, &in, nullptr, VK_IMAGE_VIEW_TYPE_2D, ViewUse::Sample); + if (input_view && wide_upscale(cmd, input_view, dst, 0, key, "a network left out, RGBA16F", false)) { + stub_picture_written(cmd, stub_hud_picture, stub_fx_picture); // ((Triforce) 11-24: null unless asked, above) + if (told("wide")) + logf("vk: program %016llx does not translate: its dispatch replaced by the squared upscale of %#llx %ux%u into %#llx " + "%ux%u (RGBA16F scene)", (unsigned long long)key, (unsigned long long)in.gpu, in.d.width, in.d.height, + (unsigned long long)out.gpu, out.d.width, out.d.height); + return true; + } + } VkImageBlit bl{}; bl.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; bl.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; @@ -12545,9 +12984,10 @@ bool taau_key(uint64_t key) { } return match; } +// ((Triforce, 11-26) out_w, out_h: the output's size where it is not out's (wide_upscale's scratch image, out then null) static bool typed_upscale(VkCommandBuffer cmd, VkImageView input_view, VkImageView output_view, - Texture* out, uint32_t level, uint64_t key, const char* keys, bool temporal) { - if (!dev.push_descriptor || !vkCmdPushDescriptorSetKHR || !input_view || !output_view || !out) return false; + Texture* out, uint32_t level, uint64_t key, const char* keys, bool temporal, uint32_t out_w, uint32_t out_h) { + if (!dev.push_descriptor || !vkCmdPushDescriptorSetKHR || !input_view || !output_view || (!out && (!out_w || !out_h))) return false; static VkPipeline pipe = VK_NULL_HANDLE; static VkPipelineLayout layout = VK_NULL_HANDLE; static VkSampler linear = VK_NULL_HANDLE; @@ -12584,7 +13024,7 @@ static bool typed_upscale(VkCommandBuffer cmd, VkImageView input_view, VkImageVi pipe ? "" : ": its pipeline was not made"); } if (!pipe) return false; - uint32_t size[3] = {std::max(1u, out->width >> level), std::max(1u, out->height >> level), 0}; + uint32_t size[3] = {out_w ? out_w : std::max(1u, out->width >> level), out_h ? out_h : std::max(1u, out->height >> level), 0}; // (the stand-in's last output, which bounds this one's pixels: shaders/taau_upscale.comp. Made again at a new size, // the first frame unbounded; RX_VK_TAAU_NO_CLAMP=1: never bounded) struct History { @@ -12665,6 +13105,84 @@ static bool typed_upscale(VkCommandBuffer cmd, VkImageView input_view, VkImageVi vkCmdPushConstants(cmd, layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, 12, size); vkCmdDispatch(cmd, (size[0] + 7) / 8, (size[1] + 7) / 8, 1); descriptors_disturbed(); // (the program's own pushes are gone from the bind point) + if (temporal && out) probe_image(cmd, out, level, 0, key, 't'); + return true; +} +/// ((Triforce, 11-26) The game's gameplay upscale with RenoDX's RGBA16F scene (host/nn_vi.c hos_scene_rgba16f): typed_upscale's +/// pass (shaders/taau_upscale.comp: the network's input is the square root of the scene colour, which it squares back) into a +/// scratch image of the scene's own SDR format, R11G11B10F, at the output's size, and that blitted into the RGBA16F output (the +/// shader stores R11G11B10F alone). The game's networks were not made for an RGBA16F scene. On the lab's RX 7900 XT with the +/// owner's settings, the 3/4 network (fd029a317a9a4b94: Render resolution 75%, and Auto's dynamic path) drew a black 3D. The +/// networks of 67% (6676619641320ba7) and 50% (72ba090c70fe2614), left out on that card, fell to upscale_stub's plain blit, which +/// copied the square root as it is: the 3D veiled in white. The same at a fresh start; 100%'s network (9dc98871eb7fc101) draws +/// right and is left to run. RX_VK_WIDE_UPSCALE=0: as before. false: nothing recorded (the caller goes on as before) +static bool wide_upscale(VkCommandBuffer cmd, VkImageView input_view, Texture* out, uint32_t level, uint64_t key, const char* keys, + bool temporal) { + static const bool off = getenv("RX_VK_WIDE_UPSCALE") && atoi(getenv("RX_VK_WIDE_UPSCALE")) == 0; + if (off || !input_view || !out || !out->image || out->format != VK_FORMAT_R16G16B16A16_SFLOAT || out->skip || + !temporal_scene_format(VK_FORMAT_R16G16B16A16_SFLOAT)) // (a run whose scene is RGBA16F alone: vk_temporal.h) + return false; + static const bool able = [] { + VkFormatProperties t{}, o{}; + vkGetPhysicalDeviceFormatProperties(dev.physical, VK_FORMAT_B10G11R11_UFLOAT_PACK32, &t); + vkGetPhysicalDeviceFormatProperties(dev.physical, VK_FORMAT_R16G16B16A16_SFLOAT, &o); + const bool ok = (t.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) && + (t.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT) && (o.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT); + if (!ok) logf("vk: the RGBA16F scene's gameplay upscale: this card cannot store R11G11B10F or blit it into RGBA16F: the game's own"); + return ok; + }(); + if (!able) return false; + const uint32_t w = std::max(1u, out->width >> level), h = std::max(1u, out->height >> level); + // (the scratch image, made again at a new size; the one before given back 120 presents later, when no work in flight can + // use it, as typed_upscale's history) + struct Scratch { VkImage image = VK_NULL_HANDLE; VmaAllocation mem = nullptr; VkImageView view = VK_NULL_HANDLE; uint32_t w = 0, h = 0; }; + struct Old { Scratch s; uint64_t frame; }; + static Scratch scratch; + static std::vector old; + for (size_t i = 0; i < old.size();) { + if (texture_frame_no() - old[i].frame < 120) { i++; continue; } + if (old[i].s.view) vkDestroyImageView(dev.device, old[i].s.view, nullptr); + destroy_image(old[i].s.image, old[i].s.mem); + old.erase(old.begin() + (ptrdiff_t)i); + } + if (scratch.w != w || scratch.h != h) { + if (scratch.image) old.push_back({scratch, texture_frame_no()}); + scratch = {}; + VkImageCreateInfo ic{VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO}; + ic.imageType = VK_IMAGE_TYPE_2D, ic.format = VK_FORMAT_B10G11R11_UFLOAT_PACK32; + ic.extent = {w, h, 1}, ic.mipLevels = 1, ic.arrayLayers = 1, ic.samples = VK_SAMPLE_COUNT_1_BIT; + ic.tiling = VK_IMAGE_TILING_OPTIMAL, ic.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + if (!create_image(ic, scratch.image, scratch.mem)) return scratch = {}, false; + VkImageViewCreateInfo vc{VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO}; + vc.image = scratch.image, vc.viewType = VK_IMAGE_VIEW_TYPE_2D, vc.format = ic.format; + vc.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}; + if (vkCreateImageView(dev.device, &vc, nullptr, &scratch.view) != VK_SUCCESS) { + destroy_image(scratch.image, scratch.mem); + return scratch = {}, false; + } + VkImageMemoryBarrier2 ib{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2}; // (UNDEFINED -> GENERAL, once) + ib.srcStageMask = VK_PIPELINE_STAGE_2_NONE, ib.srcAccessMask = VK_ACCESS_2_NONE; + ib.dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT, ib.dstAccessMask = VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT; + ib.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, ib.newLayout = VK_IMAGE_LAYOUT_GENERAL; + ib.srcQueueFamilyIndex = ib.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; + ib.image = scratch.image, ib.subresourceRange = vc.subresourceRange; + VkDependencyInfo di{VK_STRUCTURE_TYPE_DEPENDENCY_INFO}; + di.imageMemoryBarrierCount = 1, di.pImageMemoryBarriers = &ib; + vkCmdPipelineBarrier2(cmd, &di); + scratch.w = w, scratch.h = h; + logf("vk: the RGBA16F scene's gameplay upscale (%016llx): squared into R11G11B10F at %ux%u, then into the picture", + (unsigned long long)key, w, h); + } + if (!typed_upscale(cmd, input_view, scratch.view, nullptr, 0, key, keys, temporal, w, h)) return false; + full_barrier(cmd); + VkImageBlit bl{}; + bl.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}; + bl.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, level, 0, 1}; + bl.srcOffsets[1] = {(int32_t)w, (int32_t)h, 1}; + bl.dstOffsets[1] = {(int32_t)w, (int32_t)h, 1}; + vkCmdBlitImage(cmd, scratch.image, VK_IMAGE_LAYOUT_GENERAL, out->image, VK_IMAGE_LAYOUT_GENERAL, 1, &bl, VK_FILTER_NEAREST); + full_barrier(cmd); + texture_written(out); if (temporal) probe_image(cmd, out, level, 0, key, 't'); return true; } @@ -12989,7 +13507,8 @@ static bool upscale_off_on() { static const bool env = getenv("RX_VK_UPSCALE_OFF") && atoi(getenv("RX_VK_UPSCALE_OFF")) > 0; // ((Triforce) 11-24) and the Upscaler row's Off (upscaler_rows.h OFF), while no engine draws (an environment's engine goes // over the row: temporal_mode; FSR 3.1 is never at Off) - return env || lab_ab::on("upoff") || (opts.dlss == upscaler_rows::OFF && temporal_mode() == upscaler_rows::GAME); + // ((Triforce, 11-26) the row as applied, as temporal_mode reads it: vk_menu.h applied_dlss) + return env || lab_ab::on("upoff") || (applied_dlss() == upscaler_rows::OFF && temporal_mode() == upscaler_rows::GAME); } bool taau_stand_in(VkCommandBuffer cmd, const NvnState& s, const Program& p) { if (!dev.push_descriptor || !vkCmdPushDescriptorSetKHR || p.stages.empty()) return false; @@ -12999,7 +13518,11 @@ bool taau_stand_in(VkCommandBuffer cmd, const NvnState& s, const Program& p) { const bool shaped = (off || n64) && st.info.uses_cooperative_matrix && st.info.texture_descriptors.size() == 1 && st.info.image_descriptors.size() == 1; const upscale_off::Choice ch = upscale_off::choose(taau_key(p.key), off, gameplay_network(p.key), shaped, n64); - if (!ch.stand_in) return false; + // ((Triforce, 11-26) the 3/4 network (Render resolution 75%, Auto's dynamic path) on RenoDX's RGBA16F scene: wide_upscale in + // its place, which squares its input back; the network drew a black 3D there. Its picture is an RGBA16F image, which the + // stand-in below does not take (B10G11R11 alone): it is looked up as below, then given to wide_upscale + const bool wide = p.key == 0xfd029a317a9a4b94ull && !off && !n64; + if (!ch.stand_in && !wide) return false; if (st.info.texture_descriptors.empty() || st.info.image_descriptors.empty()) return false; Texture* in = nullptr; // (the network's input: for one taken by its shape, and for N64 Classic's grid, which needs its size) if (ch.by_shape || ch.n64) { @@ -13019,7 +13542,18 @@ bool taau_stand_in(VkCommandBuffer cmd, const NvnState& s, const Program& p) { const uint32_t handle = handle_of(s, st, od, 0); if (!handle) return false; texture_view_of(handle, VK_IMAGE_VIEW_TYPE_2D, ViewUse::Storage, image_format(od.format), &out, &level); - if (!out || out->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32) return false; + if (wide && out && out->format == VK_FORMAT_R16G16B16A16_SFLOAT) { // ((Triforce, 11-26) above: false, the network runs as before) + bool done; + { + ParLock wide_lk; // (typed_upscale's and wide_upscale's images and pipeline: shared by every recording thread) + done = wide_upscale(cmd, dw().imgs[0].imageView, out, level, p.key, "fd029a317a9a4b94, RGBA16F", true); + } + if (done) { + hudless_after_dispatch(cmd, p.key); // ((Triforce, FG-2) as below) + } + return done; + } + if (!ch.stand_in || !out || out->format != VK_FORMAT_B10G11R11_UFLOAT_PACK32) return false; const char* keys = !ch.temporal ? "the upscaler Off" : getenv("RX_VK_TAAU_KEYS") ? getenv("RX_VK_TAAU_KEYS") : "fd029a317a9a4b94"; bool done; { @@ -16162,7 +16696,8 @@ uint64_t dry_draw_program(void* ctx) { // (asked only where the point's choice const DryDraw& q = *static_cast(ctx); uint8_t types[8]; target_types(*q.at, types); - const Program* cp = program_for(*q.s, q.mesh ? ProgramKind::Mesh : ProgramKind::Graphics, types); + // ((Triforce, 11-26, C02; pickwide.h) through the wide memo as draw() goes: the picks' kept programs move only with it) + const Program* cp = q.mesh ? program_for(*q.s, ProgramKind::Mesh, types) : program_for_wide(*q.s, types); return cp ? cp->key : 0; } } // namespace diff --git a/gpu/vk/vk_dump.cpp b/gpu/vk/vk_dump.cpp index 832c994..89d84b6 100644 --- a/gpu/vk/vk_dump.cpp +++ b/gpu/vk/vk_dump.cpp @@ -1,6 +1,7 @@ // Frame dumps (vk_dump.h): each step's image blitted (nearest) into a small RGBA32 image of its numeric kind and copied // to host memory with the submission; written once the submission completed. #include +#include #include #include #include @@ -265,6 +266,19 @@ void dump_present(int64_t presents) { if (*q == ',') q++; } } + // ((11-28) lab: /dump.now: the next frame dumped, the file removed. Checked twice a second) + if (const char* d = getenv("RX_VK_DUMP_DIR"); d && presents >= 0 && !dump_armed) { + static auto next = std::chrono::steady_clock::now(); + if (std::chrono::steady_clock::now() >= next) { + next = std::chrono::steady_clock::now() + std::chrono::milliseconds(500); + const std::string trigger = std::string(d) + "/dump.now"; + if (FILE* f = fopen(trigger.c_str(), "rb")) { + fclose(f); + std::remove(trigger.c_str()); + targets.push_back(presents + 1), counts.push_back(1); + } + } + } if (dump_armed) logf("vk: dump of the frame after present %lld: %d steps so far", (long long)armed_present, seq); if (dump_armed && presents < armed_until) return; // (a run of frames: one folder, steps numbered on) dump_armed = std::find(targets.begin(), targets.end(), presents) != targets.end(); diff --git a/gpu/vk/vk_framegen.cpp b/gpu/vk/vk_framegen.cpp index bc19314..07918db 100644 --- a/gpu/vk/vk_framegen.cpp +++ b/gpu/vk/vk_framegen.cpp @@ -851,9 +851,28 @@ bool framegen_on() { // frame generation's display thread reads it (framegen_scale) while the replay thread writes it (wide_sides_tick) struct WideSides { float x0 = 0.0f; int side = 0; }; std::atomic wide_possible{false}; // (a margin and the setting on: vk_replay.cpp takes the scale pass's path for the sides) +// ((Triforce, 11-26) the whole picture out of focus, x0 kWholeBlur: Save Select over the title (vk_menu.cpp +// menu_backdrop_blurred). The owner: "remove the black shadow behind the save select and replace it with blur", "adding blur +// for the borders for 21:9 and 32:9", as the game's own Options over the title has the title blurred behind it, its sides +// too. The sides' own blur (fg_scale.comp side_fill) with both edges past the picture's: every pixel is a side's, so no +// shader of its own; on every screen shape, 16:9 too, as the game's) +constexpr float kWholeBlur = -1.0f; +float side_x0(const WideSides& w) { return w.x0 == kWholeBlur ? 2.0f : w.x0; } +float side_x1(const WideSides& w) { return w.x0 == kWholeBlur ? 3.0f : 1.0f - w.x0; } WideSides wide_sides() { WideSides w; - if (!host || !host->wide_menus) return w; + static bool whole_told = false; // (each change said once: a report of a blurred title says when it came and went) + if (menu_backdrop_blurred()) { + w.x0 = kWholeBlur, w.side = 1; + wide_possible.store(true, std::memory_order_relaxed); + if (!whole_told) whole_told = true, logf("vk: the picture out of focus behind Save Select"); + return w; + } + if (whole_told) whole_told = false, logf("vk: the picture in focus again (Save Select shut)"); + if (!host || !host->wide_menus) { + wide_possible.store(false, std::memory_order_relaxed); + return w; + } // (KEEP_VTABLES 1: the pause and system menus' background. 0, the item wheel's background, and 2 and 3, the event and // the loading fade, keep covering the whole picture. // (Triforce) This was 0xa: bit 3 was taken for a menu's, and it is the loading fade (host/oot_wide_hud.h's table). So @@ -1009,7 +1028,7 @@ VkImage scale_picture(VkCommandBuffer cmd, VkImageView src, VkImage image, uint3 scale.small_w = smw, scale.small_h = smh; to_general(cmd, scale.small.image); } - struct { int mode; float sharp; float x0, x1; int side; } sp{0, 0.0f, wide.x0, 1.0f - wide.x0, 3}; + struct { int mode; float sharp; float x0, x1; int side; } sp{0, 0.0f, side_x0(wide), side_x1(wide), 3}; pass(cmd, filter, {{src, scale.linear}, {scale.small.view, VK_NULL_HANDLE}, {src, scale.linear}}, smw, smh, &sp, sizeof sp); VkImageView picture = src; if (wide.side) { @@ -1087,7 +1106,7 @@ VkImage scale_picture(VkCommandBuffer cmd, VkImageView src, VkImage image, uint3 return scale.scaled.image; } struct { int mode; float sharp; float x0, x1; int side; } pc{sharpen_rules::window_mode(opts.upscale, fsr1, iw, ih, dw, dh), - sharp / 100.0f, wide.x0, 1.0f - wide.x0, wide.side}; + sharp / 100.0f, side_x0(wide), side_x1(wide), wide.side}; // (nothing left to do: the plain copy at 1:1, no Sharpness here, no sides. The picture goes to the window as it is) if (!pc.mode && !sharp && !wide.side && iw == dw && ih == dh) return VK_NULL_HANDLE; if (wide.side == 1) { // (the blurred sides: first the picture at 1/8, each pixel the mean of its 8 x 8, which they blur) diff --git a/gpu/vk/vk_fsr3.cpp b/gpu/vk/vk_fsr3.cpp index 63a3819..236cbf4 100644 --- a/gpu/vk/vk_fsr3.cpp +++ b/gpu/vk/vk_fsr3.cpp @@ -974,23 +974,27 @@ std::string own_said(Out& o) { } // namespace -bool fsr3_wanted() { +bool fsr3_wanted_of(int choice, bool now) { static const int env = env_switch("RX_VK_FSR"); if (env == 0) return false; // ((Triforce, 11-22, N64 Classic) not while its 3D pass draws the gameplay upscale: n64_rules.h upscaler, the switch too) - if (n64_rules::upscaler(n64_in_front(), upscaler_rows::FSR3) != upscaler_rows::FSR3) return false; + if (now && n64_rules::upscaler(n64_in_front(), upscaler_rows::FSR3) != upscaler_rows::FSR3) return false; // (the Upscaler row's FSR 3.1 or its Native AA, upscaler_rows.h, read each time: the row changes it while the game runs. // RX_VK_DLSS=1 / 2 or RX_VK_FSR4=1 / 2 goes over the row, its FSR 3.1 too: vk_temporal.cpp's chain draws then) - return (env > 0 || (upscaler_rows::is_fsr3(opts.dlss) && !temporal_env_chosen())) && fsr3::supported(); + return (env > 0 || (upscaler_rows::is_fsr3(choice) && !temporal_env_chosen())) && fsr3::supported(); } -bool fsr3_native() { +bool fsr3_native_of(int choice, bool now) { static const int env = env_switch("RX_VK_FSR"); // (the switch decides the size too when it turns FSR 3.1 on: 1 scaled, 2 and up its Native AA, as RX_VK_DLSS and // RX_VK_FSR4 count) - return fsr3_wanted() && (env > 0 ? env >= 2 : opts.dlss == upscaler_rows::FSR3_AA); + return fsr3_wanted_of(choice, now) && (env > 0 ? env >= 2 : choice == upscaler_rows::FSR3_AA); } +// ((Triforce, 11-26) the row as applied (vk_menu.h applied_dlss): a choice not applied yet runs nothing) +bool fsr3_wanted() { return fsr3_wanted_of(applied_dlss(), true); } +bool fsr3_native() { return fsr3_native_of(applied_dlss(), true); } + bool fsr3_pre_wanted() { return fsr3_wanted() && fsr3fi::frames_wanted() == 0; } bool fsr3_pre(VkCommandBuffer cmd, Texture* scene, VkImageView scene_view, uint32_t ow, uint32_t oh, VkImageView* picture, diff --git a/gpu/vk/vk_fsr3.h b/gpu/vk/vk_fsr3.h index 8032a70..34bd22d 100644 --- a/gpu/vk/vk_fsr3.h +++ b/gpu/vk/vk_fsr3.h @@ -104,11 +104,15 @@ bool fsr3_idle(); /// FSR 3.1 upscales: the Insert menu's Upscaler row says FSR 3.1 or its Native AA (upscaler_rows.h FSR3, FSR3_AA) and /// neither RX_VK_DLSS nor RX_VK_FSR4 is set over it (vk_temporal.h temporal_env_chosen), or RX_VK_FSR=1 or 2; and it -/// runs here +/// runs here. ((Triforce, 11-26) The row as applied, vk_menu.h applied_dlss) bool fsr3_wanted(); /// ...as its Native AA, the 3D at full size: the row's AMD FSR 3.1 Native AA, or RX_VK_FSR=2 (1: the Render resolution /// row's mode, whatever the row says) bool fsr3_native(); +/// ((Triforce, 11-26) The same for a choice of the Upscaler row (an opts.dlss value: the menu's row as it is being stepped). +/// now: and not while N64 Classic's 3D pass draws in its place (vk_temporal.h temporal_mode_of) +bool fsr3_wanted_of(int choice, bool now); +bool fsr3_native_of(int choice, bool now); /// A gameplay upscale's dispatch, as vk_temporal.h's temporal_upscale takes it (vk_draw.cpp's fsr3_stand_in finds them the same /// way). With FSR 3.1's frame interpolation on, the dispatch's input and this frame's camera become its inputs here diff --git a/gpu/vk/vk_fsr4.cpp b/gpu/vk/vk_fsr4.cpp index 49fa02d..a9a724b 100644 --- a/gpu/vk/vk_fsr4.cpp +++ b/gpu/vk/vk_fsr4.cpp @@ -1076,6 +1076,12 @@ void close() { bool load_library(Library& l) { if (l.lib_tried) return l.lib_ok; l.lib_tried = true; +#ifdef _WIN32 + // ((Triforce, 11-27, a player's RX 7800 XT: "AMD_FIDELITYFX_FRAMEGENERATION_VK.DLL is not made to run on Windows or has + // an error" at every start) a bad DLL the loader opens (now or in a later query) fails quietly on this thread instead of + // Windows' blocking box: it is refused either way and the game goes on without it, as it already did + SetThreadErrorMode(GetThreadErrorMode() | SEM_FAILCRITICALERRORS, nullptr); +#endif std::string where; for (const std::string& dir : library_dirs()) { where += (where.empty() ? "" : ", ") + dir; @@ -1770,6 +1776,9 @@ int fg_env() { // (RX_VK_FSR4_FG: 0 never; 4 FSR 4's alone, as before (FG-1); /// AMD's library asked once (s.mu held, the device made): whether it has an FSR 4 frame generation for this card and driver fgr::Why probe(Fg& s) { Library& l = lib(); +#ifdef _WIN32 + SetThreadErrorMode(GetThreadErrorMode() | SEM_FAILCRITICALERRORS, nullptr); // ((Triforce, 11-27) as load_library's +#endif { std::lock_guard lk(l.mu); if (!load_library(l)) return fgr::FG_NO_LIBRARY; diff --git a/gpu/vk/vk_game_tex.h b/gpu/vk/vk_game_tex.h index bc1cee8..8f6ab49 100644 --- a/gpu/vk/vk_game_tex.h +++ b/gpu/vk/vk_game_tex.h @@ -231,8 +231,10 @@ inline Image shrink_mask(const Image& m, uint32_t f) { /// (OptionBtnThinCursorGlow, a wider ramp) shows outside the line. The band is measured from the game's own cursor on its /// Options screen (1920 x 1080: the line 13 layout units thick, its inner edge a box of 809 x 114 units in the 960 x 260 /// pane: the ramp from 0.34 to 0.65; about 20 units of blue-white glow outside it, nothing inside). -/// *line and *glow: white, their strength in alpha (the glow is tinted and breathes at the draw) -inline void make_cursor(const Image& ramp, const Image& wide, Image* line, Image* glow) { +/// *line and *glow: white, their strength in alpha (the glow is tinted and breathes at the draw). ((Triforce, 11-26) falloff: +/// how the glow dies away outside the line, fitted to the game's own cursors in the lab's SDR shots (ui083_cursor_fit): the +/// Options rows' 1.35, the System list's buttons' 1.25; it was 1.6, a glow narrower and fainter than the game's) +inline void make_cursor(const Image& ramp, const Image& wide, Image* line, Image* glow, float falloff = 1.35f) { auto step = [](float v, float a, float b) { const float t = std::clamp((v - a) / (b - a), 0.0f, 1.0f); return t * t * (3 - 2 * t); @@ -242,12 +244,100 @@ inline void make_cursor(const Image& ramp, const Image& wide, Image* line, Image const float l = ramp.rgba[i * 4 + 3] / 255.0f; const float g = i < (size_t)wide.w * wide.h ? wide.rgba[i * 4 + 3] / 255.0f : 0; const float la = step(l, 0.31f, 0.37f) * (1 - step(l, 0.62f, 0.69f)); - const float outside = std::pow(std::clamp(g / 0.36f, 0.0f, 1.0f), 1.6f) * (1 - step(l, 0.31f, 0.37f)); + const float outside = std::pow(std::clamp(g / 0.36f, 0.0f, 1.0f), falloff) * (1 - step(l, 0.31f, 0.37f)); line->rgba[i * 4 + 3] = (unsigned char)(la * 255 + 0.5f); glow->rgba[i * 4 + 3] = (unsigned char)(outside * 255 + 0.5f); } } +// ---- ((Triforce, 11-25) the file select's cards, as the game's own Load list draws its saves (vk_menu.cpp draw_files). The +// owner, of our file select at 21:9: "It is very broken and it's only optimized for 16:9 ... improve the design, fix up the +// UI, use the in-game assets". The card is BtnDataFileBase_00 (its shape, white: the layout colours it), BtnDataFileFrame_01 +// (its frame and the line between the picture and the text) and BtnDataFileFrame_00 (the same with the rule under the place +// and its curl), 997 x 283 texels; the game's card on a 1440-line screen is 1442 x 246 pixels of which the texture's is +// 973 x 246, so the layout stretches it between the picture and the curl, the rest at its own size (the lab's capture of the +// game's Load screen, 3440 x 1440: the picture 426 wide, the curl 235 from the right edge, as in the texture). Its colours +// are measured there: the fill 143,102,46 to 160,116,55 in a fine grain, the frame 188,156,84, the rule a little darker +constexpr uint32_t kFileCardKeepL = 470, kFileCardKeepR = 715; // (texels of the source: [0, 470) and [715, 997) keep their size) +constexpr uint32_t kFileCardMore = 469; // (texels added between them) +constexpr unsigned char kFileCardLo[3] = {143, 102, 46}, kFileCardHi[3] = {160, 116, 55}; +constexpr unsigned char kFileCardLine[3] = {188, 156, 84}, kFileCardRule[3] = {182, 148, 78}; +// (the rule and its curl, in Frame_00 only: this box of it; the frame's own lines are Frame_01's) +constexpr uint32_t kFileRuleX0 = 470, kFileRuleX1 = 760, kFileRuleY0 = 128, kFileRuleY1 = 180; +/// The card, the game's three textures in one picture as wide as the game draws it (kFileCardMore texels wider than they +/// are): the fill in the shape, its grain from DecoNoise_00 (noise; none: the fill's middle colour), the frame, the rule. +/// sRGB, not a mask: drawn white +inline Image make_file_card(const Image& base, const Image& frame, const Image& ruled, const Image* noise) { + Image out; + out.w = base.w + kFileCardMore, out.h = base.h, out.srgb = true; + out.rgba.assign((size_t)out.w * out.h * 4, 0); + const auto source_x = [&](uint32_t x) -> uint32_t { // (the stretch: the source texel each of the card's comes from) + if (x < kFileCardKeepL) return x; + if (x >= kFileCardKeepR + kFileCardMore) return x - kFileCardMore; + const float t = (float)(x - kFileCardKeepL) / (float)(kFileCardKeepR + kFileCardMore - kFileCardKeepL); + return kFileCardKeepL + (uint32_t)(t * (float)(kFileCardKeepR - kFileCardKeepL)); + }; + const auto alpha_at = [](const Image& m, uint32_t x, uint32_t y) { + return x < m.w && y < m.h ? m.rgba[((size_t)y * m.w + x) * 4 + 3] / 255.0f : 0.0f; + }; + for (uint32_t y = 0; y < out.h; y++) + for (uint32_t x = 0; x < out.w; x++) { + const uint32_t sx = source_x(x); + const float a_base = alpha_at(base, sx, y), a_line = alpha_at(frame, sx, y); + const bool rule_box = sx >= kFileRuleX0 && sx < kFileRuleX1 && y >= kFileRuleY0 && y < kFileRuleY1; + const float a_rule = rule_box ? alpha_at(ruled, sx, y) : 0.0f; + const float a = std::max(a_base, a_line); + if (a <= 0) continue; + const float g = noise && noise->w && noise->h ? alpha_at(*noise, x % noise->w, y % noise->h) : 0.5f; + float c[3]; + for (int k = 0; k < 3; k++) { + c[k] = kFileCardLo[k] + (kFileCardHi[k] - kFileCardLo[k]) * g; + c[k] += (kFileCardRule[k] - c[k]) * a_rule; + c[k] += (kFileCardLine[k] - c[k]) * std::min(1.0f, a_line / a); + } + unsigned char* o = out.rgba.data() + ((size_t)y * out.w + x) * 4; + for (int k = 0; k < 3; k++) o[k] = (unsigned char)std::clamp(c[k] + 0.5f, 0.0f, 255.0f); + o[3] = (unsigned char)(a * 255 + 0.5f); + } + return out; +} +/// The tag at the right of a card's first line (the game's "Autosave"; ours names the file): NumBaseAutoSave_00 its plate, +/// NumBaseAutoSaveDeco_00 the line round it, both masks, in the colours measured on the game's (a dark olive, a light rim) +constexpr unsigned char kFileTagFill[3] = {112, 86, 38}, kFileTagRim[3] = {176, 138, 72}; +inline Image make_file_tag(const Image& plate, const Image& rim) { + Image out; + out.w = plate.w, out.h = plate.h, out.srgb = true; + out.rgba.assign((size_t)out.w * out.h * 4, 0); + for (size_t i = 0; i < (size_t)out.w * out.h; i++) { + const float ap = plate.rgba[i * 4 + 3] / 255.0f, ar = i < (size_t)rim.w * rim.h ? rim.rgba[i * 4 + 3] / 255.0f : 0.0f; + const float a = std::max(ap, ar); + if (a <= 0) continue; + for (int k = 0; k < 3; k++) out.rgba[i * 4 + k] = (unsigned char)(kFileTagFill[k] + (kFileTagRim[k] - kFileTagFill[k]) * std::min(1.0f, ar / a) + 0.5f); + out.rgba[i * 4 + 3] = (unsigned char)(a * 255 + 0.5f); + } + return out; +} +/// The file select's pieces from the archive, added to the skin: "file_card", "file_tag", and the cursor round a card, +/// "file_cursor_line" and "file_cursor_glow" (DataFileBtnCursorLine_00 and _Glow_00 are the same ramps as the options' +/// cursor's, at the card's size: make_cursor). Each only when its textures are there; the page draws its own without them +inline void make_file_skin(const Bntx& bntx, Skin& skin) { + const auto read = [&](const char* name, Image& img) { + const Bntx::Entry* e = bntx.find(name); + return e && bntx.decode(*e, img); + }; + Image base, frame, ruled, tag, rim, line, glow; + if (read("BtnDataFileBase_00", base) && read("BtnDataFileFrame_01", frame) && read("BtnDataFileFrame_00", ruled) && frame.mask && + frame.w == base.w && ruled.w == base.w && base.w > kFileRuleX1 && base.w > kFileCardKeepR) + skin.images.push_back({"file_card", make_file_card(base, frame, ruled, skin.get("DecoNoise_00"))}); + if (read("NumBaseAutoSave_00", tag) && read("NumBaseAutoSaveDeco_00", rim) && tag.mask && rim.mask) + skin.images.push_back({"file_tag", make_file_tag(tag, rim)}); + if (read("DataFileBtnCursorLine_00", line) && read("DataFileBtnCursorGlow_00", glow) && line.mask && glow.mask) { + Skin::Entry l{"file_cursor_line", {}}, g{"file_cursor_glow", {}}; + make_cursor(line, glow, &l.img, &g.img); + skin.images.push_back(std::move(l)), skin.images.push_back(std::move(g)); + } +} + /// The skin from the archive's bytes (a BNTX): false when it is not the game's (a texture of the list missing). (Triforce) /// The optional ones are the standalone menu's background (SystemBG_00's shade and noise): one missing is left out, and the /// menu draws its plain dim there instead (vk_ui.h system_bg); the skin stays @@ -287,13 +377,17 @@ inline bool make_skin(std::vector&& bntx_bytes, Skin& skin) { "DataFileImportantIcon_05", "DataFileImportantIcon_06", "DataFileImportantIcon_07", "DataFileImportantIcon_08", "HeartBase_00", "HeartFrame_00", "NumBaseAutoSave_00", // (and for the achievements' icons, vk_menu.cpp ach_icon: a song's, a Gold Skulltula's mark, a rupee) - "OcarinaMelodyIcon_00", "MapIconCollectSkullSign_00", "RupeeIconNew_00"}; + "OcarinaMelodyIcon_00", "MapIconCollectSkullSign_00", "RupeeIconNew_00", + // ((Triforce, 11-25) the plates the stones and the medallions sit in on the game's Load list: the three stones' alone + // (_00), the six medallions round the three stones (_01); the archive spells them so) + "DataFileImportantStateBase_DataDileImportantStateBase_00", "DataFileImportantStateBase_DataDileImportantStateBase_01"}; for (const char* n : more) { const Bntx::Entry* e = bntx.find(n); Skin::Entry out; out.name = n; if (e && bntx.decode(*e, out.img)) skin.images.push_back(std::move(out)); } + make_file_skin(bntx, skin); // ((Triforce, 11-25) the file select's cards, their tag and their cursor) const Image *shape = skin.get("BtnThinBase_00"), *grain = skin.get("BtnThinBase_05"); Skin::Entry row{"plate_row", make_plate(*shape, *grain, skin.get("BtnThinBase_04"), kPlateBlack, kPlateWhite, kPlateLine)}; Skin::Entry row_sel{"plate_row_sel", row.img}; // (the selected row's plate is the same: the game marks it with the cursor alone) @@ -306,8 +400,18 @@ inline bool make_skin(std::vector&& bntx_bytes, Skin& skin) { Skin::Entry tab_sel{"tab_select", make_tinted(*tab, kTabBlack, kTabWhite)}; skin.images.push_back(std::move(value)), skin.images.push_back(std::move(value_on)), skin.images.push_back(std::move(tab_sel)); Skin::Entry line{"cursor_line", {}}, glow{"cursor_glow", {}}; - make_cursor(*skin.get("OptionBtnThinCursorLine_00"), *skin.get("OptionBtnThinCursorGlow_00"), &line.img, &glow.img); + make_cursor(*skin.get("OptionBtnThinCursorLine_00"), *skin.get("OptionBtnThinCursorGlow_00"), &line.img, &glow.img, 1.35f); skin.images.push_back(std::move(line)), skin.images.push_back(std::move(glow)); + // ((Triforce, 11-26) the System list's buttons' own cursor (PaCommonBtnThin_00's N_Cursor_00: CmnBtnCursorLine_00 and + // CmnBtnCursorGlow_00, its line hand drawn, uneven), for our buttons (vk_ui.h button): the owner's "use the in-game's + // outline". Without them the Options rows' as before + Image cmn_line, cmn_glow; + const Bntx::Entry *el = bntx.find("CmnBtnCursorLine_00"), *eg = bntx.find("CmnBtnCursorGlow_00"); + if (el && eg && bntx.decode(*el, cmn_line) && bntx.decode(*eg, cmn_glow) && cmn_line.mask && cmn_glow.mask) { + Skin::Entry cl{"cmn_cursor_line", {}}, cg{"cmn_cursor_glow", {}}; + make_cursor(cmn_line, cmn_glow, &cl.img, &cg.img, 1.25f); + skin.images.push_back(std::move(cl)), skin.images.push_back(std::move(cg)); + } return true; } diff --git a/gpu/vk/vk_imgui.cpp b/gpu/vk/vk_imgui.cpp index b5d276c..e7110ec 100644 --- a/gpu/vk/vk_imgui.cpp +++ b/gpu/vk/vk_imgui.cpp @@ -407,28 +407,59 @@ void linearize(ImDrawData* dd) { v.col = (v.col & IM_COL32_A_MASK) | (ImU32)lut[v.col >> IM_COL32_R_SHIFT & 0xFF] << IM_COL32_R_SHIFT | (ImU32)lut[v.col >> IM_COL32_G_SHIFT & 0xFF] << IM_COL32_G_SHIFT | (ImU32)lut[v.col >> IM_COL32_B_SHIFT & 0xFF] << IM_COL32_B_SHIFT; } -/// (an HDR10 window image: ST 2084 (PQ) code values in Rec. 2020, framegen_hdr's) an sRGB colour as HDR10 shows it at the -/// paper white of the Insert menu's HDR rows: decoded, its primaries to Rec. 2020, its white at paper white nits, PQ coded -ImU32 hdr10_of(ImU32 c, float white) { +/// ((Triforce, 11-26) How the overlays are coded for an HDR10 window: their white in nits, their primaries, the display gamma +/// their codes are shown with. The owner, of our options beside the game's own with HDR Native and RenoDX: "washed out ... +/// correct the shading to be exactly the same color and shading of the vanilla options". RenoDX's encoder (its zelda-oot-oz +/// output_0x92D6F81D.frag.slang) codes the finished picture, the game's own menus in it, at the UI brightness row's nits, its +/// colours taken as the Color space row says (BT.709, or Display P3: more saturated), after the Gamma correction row's +/// power; with its tone mapper and its colour space both Vanilla, the game's own matrix and scale instead. The overlays were +/// coded at Paper white as BT.709 with the sRGB curve whatever those rows said: in the owner's setup (PsychoV35, DCI-P3) as +/// bright as the game's menus but less saturated (the lab's HDR shots: the game's chosen value's orange has a blue of 4, +/// ours 54; a row's plate 174,125,58 against 166,126,69). They are coded as RenoDX codes the game's menus now, wherever its +/// encoder codes them its own way; else at Paper white as BT.709, as before +struct UiHdr { + float white = 200; // (nits) + bool p3 = false; // (Display P3's primaries, white D65; else BT.709's) + float gamma = 0; // (the display gamma its codes are shown with, 2.2 or 2.4; 0: the sRGB curve) + bool operator==(const UiHdr& o) const { return white == o.white && p3 == o.p3 && gamma == o.gamma; } +}; +UiHdr ui_hdr_now() { + UiHdr u; + u.white = (float)std::clamp(opts.hdr_white, 80, 400); + if (opts.hdr == 2 && renodx_chosen() && (opts.rdx_space != 0 || opts.rdx_tonemap != 0)) { + u.white = (float)std::clamp(opts.rdx_ui_white, 80, 400); + u.p3 = opts.rdx_space == 2; + u.gamma = opts.rdx_gamma == 1 ? 2.2f : opts.rdx_gamma == 2 ? 2.4f : 0.0f; + } + return u; +} +/// (an HDR10 window image: ST 2084 (PQ) code values in Rec. 2020, framegen_hdr's) an sRGB colour as HDR10 shows it: decoded +/// (ui_hdr_now: by the sRGB curve or a display's gamma), its primaries (BT.709's or Display P3's) to Rec. 2020, its white at +/// that many nits, PQ coded +ImU32 hdr10_of(ImU32 c, const UiHdr& u) { static float lin[256]; static unsigned char pq[4097]; - static float pq_white = -1; - if (pq_white != white) { - pq_white = white; + static UiHdr made{-1.0f, false, -1.0f}; + if (!(made == u)) { + made = u; for (int i = 0; i < 256; i++) { const float v = i / 255.0f; - lin[i] = v <= 0.04045f ? v / 12.92f : std::pow((v + 0.055f) / 1.055f, 2.4f); + lin[i] = u.gamma > 0 ? std::pow(v, u.gamma) : v <= 0.04045f ? v / 12.92f : std::pow((v + 0.055f) / 1.055f, 2.4f); } - for (int i = 0; i <= 4096; i++) { // (linear light, 1 the paper white, to the 8-bit PQ code) - const float y = std::pow(i / 4096.0f * white / 10000.0f, 0.1593017578125f); + for (int i = 0; i <= 4096; i++) { // (linear light, 1 the white, to the 8-bit PQ code) + const float y = std::pow(i / 4096.0f * u.white / 10000.0f, 0.1593017578125f); const float e = std::pow((0.8359375f + 18.8515625f * y) / (1 + 18.6875f * y), 78.84375f); pq[i] = (unsigned char)std::clamp((int)(e * 255.0f + 0.5f), 0, 255); } } const float r = lin[c >> IM_COL32_R_SHIFT & 0xFF], g = lin[c >> IM_COL32_G_SHIFT & 0xFF], b = lin[c >> IM_COL32_B_SHIFT & 0xFF]; auto code = [&](float v) { return (ImU32)pq[std::clamp((int)(v * 4096.0f + 0.5f), 0, 4096)]; }; - return (c & IM_COL32_A_MASK) | code(0.6274f * r + 0.3293f * g + 0.0433f * b) << IM_COL32_R_SHIFT | - code(0.0691f * r + 0.9195f * g + 0.0114f * b) << IM_COL32_G_SHIFT | code(0.0164f * r + 0.0880f * g + 0.8956f * b) << IM_COL32_B_SHIFT; + // (BT.709 to Rec. 2020; ((11-26) Display P3 to Rec. 2020 through XYZ, as RenoDX's DISPLAYP3_TO_XYZ then XYZ_TO_BT2020) + static const float k709[9] = {0.6274f, 0.3293f, 0.0433f, 0.0691f, 0.9195f, 0.0114f, 0.0164f, 0.0880f, 0.8956f}; + static const float kP3[9] = {0.753833f, 0.198597f, 0.047570f, 0.045744f, 0.941777f, 0.012479f, -0.001210f, 0.017602f, 0.983609f}; + const float* m = u.p3 ? kP3 : k709; + return (c & IM_COL32_A_MASK) | code(m[0] * r + m[1] * g + m[2] * b) << IM_COL32_R_SHIFT | + code(m[3] * r + m[4] * g + m[5] * b) << IM_COL32_G_SHIFT | code(m[6] * r + m[7] * g + m[8] * b) << IM_COL32_B_SHIFT; } /// (Triforce, 11-13, the user: "Why is the [shader loading screen] so dark for me after turning hdr on?") A texture's texel /// for an HDR10 window image. The pipeline multiplies a texel by its vertex's colour, and hdr10 below codes every vertex @@ -439,22 +470,22 @@ ImU32 hdr10_of(ImU32 c, float white) { /// screen. So a texel is its HDR10 code over the code of white: times a white tint it is its own code again, exactly, and a /// white shape under a coloured tint is the tint's code, exactly (a coloured texel under a coloured tint is still a /// product of two codes: close, not exact; the exact way is the conversion in the fragment shader, not done) -ImU32 hdr10_texel(ImU32 c, float white) { +ImU32 hdr10_texel(ImU32 c, const UiHdr& u) { static unsigned char over_white[256]; - static float made_for = -1; - if (made_for != white) { - const float w = (float)(hdr10_of(IM_COL32_WHITE, white) >> IM_COL32_R_SHIFT & 0xFF); + static UiHdr made_for{-1.0f, false, -1.0f}; + if (!(made_for == u)) { + const float w = (float)(hdr10_of(IM_COL32_WHITE, u) >> IM_COL32_R_SHIFT & 0xFF); for (int i = 0; i < 256; i++) over_white[i] = (unsigned char)std::clamp((int)(i * 255.0f / std::max(w, 1.0f) + 0.5f), 0, 255); - made_for = white; + made_for = u; } - const ImU32 v = hdr10_of(c, white); + const ImU32 v = hdr10_of(c, u); return (v & IM_COL32_A_MASK) | (ImU32)over_white[v >> IM_COL32_R_SHIFT & 0xFF] << IM_COL32_R_SHIFT | (ImU32)over_white[v >> IM_COL32_G_SHIFT & 0xFF] << IM_COL32_G_SHIFT | (ImU32)over_white[v >> IM_COL32_B_SHIFT & 0xFF] << IM_COL32_B_SHIFT; } void hdr10(ImDrawData* dd) { - const float white = (float)std::clamp(opts.hdr_white, 80, 400); + const UiHdr u = ui_hdr_now(); for (ImDrawList* list : dd->CmdLists) - for (ImDrawVert& v : list->VtxBuffer) v.col = hdr10_of(v.col, white); + for (ImDrawVert& v : list->VtxBuffer) v.col = hdr10_of(v.col, u); } void layout(VkCommandBuffer cmd, VkImage image, VkImageLayout from, VkImageLayout to, VkPipelineStageFlags2 src_stage, VkAccessFlags2 src, VkPipelineStageFlags2 dst_stage, VkAccessFlags2 dst) { @@ -474,13 +505,13 @@ void pixels(ImTextureData* tex, int x, int y, int w, int h, unsigned char* dst) for (int row = 0; row < h; row++) { const unsigned char* src = (const unsigned char*)tex->GetPixelsAt(x, y + row); if (tex->Format == ImTextureFormat_RGBA32 && dev.hdr && tex != ImGui::GetIO().Fonts->TexData) { // (the logo, as HDR10 shows it) - const float white = (float)std::clamp(opts.hdr_white, 80, 400); + const UiHdr u = ui_hdr_now(); for (int i = 0; i < w; i++) { ImU32 c; memcpy(&c, src + i * 4, 4); // (over white's code: see hdr10_texel. RX_VK_HDR_TEXEL_OLD=1, a lab switch: coded as a colour, as before) static const bool as_before = getenv("RX_VK_HDR_TEXEL_OLD") != nullptr; - c = as_before ? hdr10_of(c, white) : hdr10_texel(c, white); + c = as_before ? hdr10_of(c, u) : hdr10_texel(c, u); memcpy(dst + ((size_t)row * w + i) * 4, &c, 4); } } else if (tex->Format == ImTextureFormat_RGBA32) { // (the glyphs: white, their coverage in alpha, the same in any space) diff --git a/gpu/vk/vk_main.cpp b/gpu/vk/vk_main.cpp index bf200fc..8f95cf9 100644 --- a/gpu/vk/vk_main.cpp +++ b/gpu/vk/vk_main.cpp @@ -147,15 +147,25 @@ std::string nv_own_folder_mark_path() { /// reads them; a path or size the player set wins. Windows' driver honours both (a probe at 100 MB stayed there); Linux's /// main sets the size for every player already (host/hos_main.c driver_cache_room) static void nv_own_folder() { - FILE* m = fopen(nv_own_folder_mark_path().c_str(), "rb"); - if (!m) return; - fclose(m); const std::string mark = nv_own_folder_mark_path(); const std::string dir = mark.substr(0, mark.find_last_of("\\/") + 1) + "triforce_nvidia_cache"; - if (getenv("__GL_SHADER_DISK_CACHE_PATH")) { - logf("vk: NVIDIA's shader cache: __GL_SHADER_DISK_CACHE_PATH is set already, kept (%s)", getenv("__GL_SHADER_DISK_CACHE_PATH")); + FILE* m = fopen(mark.c_str(), "rb"); + if (m) fclose(m); + if (const char* set = getenv("__GL_SHADER_DISK_CACHE_PATH")) { + // ((Triforce, 11-27) host/hos_main.c nv_own_cache_folder sets it at the start, before the driver loads (on Linux for + // every PC, on Windows with the marker): said here + if (dir == set) + logf("vk: NVIDIA's shader cache: a folder of the game's own, %s, %s bytes (set at the start%s; HOS_NV_OWN_CACHE=0: " + "the driver's folder)", dir.c_str(), + getenv("__GL_SHADER_DISK_CACHE_SIZE") ? getenv("__GL_SHADER_DISK_CACHE_SIZE") : "the driver's", + m ? ": this PC's driver did not keep the game's in its own folder" : ""); + else // ((Triforce, 11-28) said with or without the marker: a player saw the game build its shaders again when started + // from a Steam shortcut, as if that start's driver cache were another; this line names the folder it used) + logf("vk: NVIDIA's shader cache: __GL_SHADER_DISK_CACHE_PATH is set already, before the game (a launcher, Steam or the " + "player), kept: %s%s", set, m ? "" : " (a start without it uses the driver's own folder: two caches)"); return; } + if (!m) return; std::error_code ec; std::filesystem::create_directories(dir, ec); #ifdef _WIN32 diff --git a/gpu/vk/vk_memory.cpp b/gpu/vk/vk_memory.cpp index 90cc468..afc5a43 100644 --- a/gpu/vk/vk_memory.cpp +++ b/gpu/vk/vk_memory.cpp @@ -65,6 +65,10 @@ #include "shadow_prev.h" // (Triforce: the texture shadow's pages taken again with bytes it holds, RX_VK_SHADOW_KEEP / _PREV) #include "page_table_census.h" // ((Triforce) the page table's windows, the census of the pools outside them, the cover #include "wb_excl_clip.h" // ((Triforce, 11-22) no write-back into memory the capture leaves out, RX_VK_WB_EXCL_CLIP) +#include "cpuwordsseen.h" // ((Triforce, 11-26) a report word the sets hold is not noted again, RX_VK_CPU_WORDS_SEEN) +#include "capgap.h" // ((Triforce, 11-26) the left-out check from the gaps found before, RX_VK_CAP_EXCL_GAP) +#include "capunion.h" // ((Triforce, 11-26, C22) one union of the captures' range lists a version, its sorts as merges, RX_VK_CAP_UNION_SHARED) +#include "bindspan.h" // ((Triforce, 11-26, C08) a read binding answered from a span of its pool's mirror, RX_VK_BIND_SPAN) #ifdef __linux__ #include #include @@ -122,6 +126,11 @@ struct Pool { // given back and made again left cyan in play and over the Start menu (RX 5500M, gone with RX_VK_MIRROR_KEEP=1); kept too) bool gpu_written = false; bool inherit_lost = false; // (retired, and the pool that took it in made no mirror in time to copy its GPU contents) + // ((Triforce, 11-27, bindspan.h) made beside an import it overlaps, or overlapped by one so made (pool_lookup's plan past + // 1 GB, pools_flag_overlapping): no bind span is filled for it, and its read bindings go by the page as before. Set under + // pools_mu, read without it by gpu_buffer_bind (__atomic). Never cleared: it stays for the import's lifetime, also after + // the import it overlapped is taken in or given back, which costs it only its spans (its bindings go as in v0.8.4) + bool left_overlapping = false; // (EvilOOT) retired with its mirror on: the pool that took it in copies the GPU's contents from it when its own mirror is // made (mirror_make), and until then the mirror stays (mirrors_give_back) bool inherit_pending = false; @@ -1335,6 +1344,7 @@ namespace { void cap_view_bump(); } // (defined with cap_view_gen below, in th namespace { int cap_only_gpu(); bool cap_excl_hit(uint64_t lo, uint64_t hi); +bool cap_excl_hit_gap(uint64_t lo, uint64_t hi); bool cap_excl_page(uint64_t g); uint64_t cap_excl_kept(uint64_t lo, uint64_t hi, std::vector>& out); void cap_born_take(std::vector>& out); @@ -2648,7 +2658,8 @@ bool ranges_hit(const std::vector>& v, uint64_t lo } std::atomic cap_excl_ver{1}; // (bumped at every change of cap_excl: the threads' copies below) /// whether [lo, hi) reaches into the left-out ranges: a thread's own copy of them, taken again only when they changed (the -/// replay's reads and bindings ask at every uniform word and binding, from every recording thread: no lock there) +/// write-back's clip and RX_VK_CAP_ONLY_GPU=2's page count ask it, and cap_excl_note with RX_VK_CAP_EXCL_GAP=0 or in the +/// lab's nocapgap phases; by default the note asks cap_excl_hit_gap, from every recording thread: no lock there) bool cap_excl_hit(uint64_t lo, uint64_t hi) { static thread_local std::vector> mine; static thread_local uint64_t ver = 0; @@ -2660,6 +2671,61 @@ bool cap_excl_hit(uint64_t lo, uint64_t hi) { } return ranges_hit(mine, lo, hi); } +/// ((Triforce, 11-26, the GPU audit's C09; capgap.h) cap_excl_hit for the count's question (cap_excl_note: every buffer +/// binding, replay read and texture upload): answered from the last 8 gaps between left-out ranges this thread's searches +/// found, searched only outside them; the memo is dropped with the thread's copy of the list at every change of it. The +/// same answers as the search (the rule's test; RX_VK_CAP_EXCL_GAP=check runs both at every question, uses the search's +/// and counts the differences, the first 20 logged). RX_VK_CAP_EXCL_GAP=0 and the lab's "nocapgap" phases: cap_excl_hit, as +/// before. The write-back's clip and mode 2's page count ask cap_excl_hit itself. Counted a thread and added to the totals +/// every 256 questions (the capture's 10 s line) +std::atomic st_gap_memo{0}, st_gap_search{0}, st_gap_diff{0}; +bool cap_excl_hit_gap(uint64_t lo, uint64_t hi) { + static const capgap::Mode env = [] { + const char* e = getenv("RX_VK_CAP_EXCL_GAP"); + const capgap::Mode m = capgap::mode(e); + if (m != capgap::kOn) + logf("vk: the left-out ranges' check %s (RX_VK_CAP_EXCL_GAP)", + m == capgap::kOff ? "searches at every question, as before" : "runs the gap memo and the search and counts differences"); + else if (e && e[0] && strcmp(e, "1")) + logf("vk: RX_VK_CAP_EXCL_GAP=%s not known: the gap memo, as unset", e); + return m; + }(); + if (env == capgap::kOff) return cap_excl_hit(lo, hi); // (the switch says the search: no lab question) + // (the lab knob's answer, asked again only when the phase moves: every phase pays the same load and compare a question, + // where on()'s string compares at every question slowed the knobs' phases alone. on() loads the phase itself; a move + // between the two loads is taken at the next question) + static thread_local int lab_k = -1; + static thread_local bool lab_off = false; + if (const int k = lab_ab::active.load(std::memory_order_relaxed); k != lab_k) lab_k = k, lab_off = lab_ab::on("nocapgap"); + if (!capgap::use(env, lab_off)) return cap_excl_hit(lo, hi); + static thread_local std::vector> mine; + static thread_local uint64_t ver = 0; + static thread_local capgap::Memo memo; + static thread_local uint32_t n_memo = 0, n_search = 0; + const uint64_t now = cap_excl_ver.load(std::memory_order_acquire); + if (ver != now) { + std::lock_guard lk(cap_excl_mu); + mine = cap_excl; + ver = cap_excl_ver.load(std::memory_order_relaxed); + memo.clear(); // (its gaps were the old list's) + } + bool searched = false; + const bool r = capgap::hit(memo, mine, lo, hi, &searched); + if (searched) n_search++; + else n_memo++; + if (!((n_memo + n_search) & 255)) { + st_gap_memo.fetch_add(n_memo, std::memory_order_relaxed), st_gap_search.fetch_add(n_search, std::memory_order_relaxed); + n_memo = n_search = 0; + } + if (env == capgap::kCheck) { + const bool old = ranges_hit(mine, lo, hi); + if (old != r && st_gap_diff.fetch_add(1, std::memory_order_relaxed) < 20) + logf("vk: RX_VK_CAP_EXCL_GAP=check: [%#llx, %#llx) the gap memo says %d, the search %d (%zu left-out ranges, version %llu)", + (unsigned long long)lo, (unsigned long long)hi, (int)r, (int)old, mine.size(), (unsigned long long)ver); + return old; + } + return r; +} /// cap_excl_hit for the 4 KB page at g, for a caller that asks in ascending order (a collection's pages): a cursor that walks on /// instead of a search for every page, started again by a search when the order goes back or the list changed bool cap_excl_page(uint64_t g) { @@ -2702,6 +2768,50 @@ void cap_born_take(std::vector>& out) { out.swap(born_stamp); born_stamp.clear(); } +// ((Triforce, 11-26, the GPU audit's C22; capunion.h; RX_VK_CAP_UNION_SHARED, on; =0: as before; =check: both ways, the +// differences counted and the old lists used; the lab knob nocapunion: as before in its phases) The captures' union of the +// range lists is built once each time a list changes and copied by its callers (capture_union_take_locked, below), its +// sorts and the pool table's are merges of the runs that arrive sorted, and the pool table's look keeps the pools' first +// captures only for RX_VK_CAPTURE_EAGER. The counts are the capture's 10 s line's (memory_cap_present) +int cap_union_mode() { + static const int v = [] { + const char* e = getenv("RX_VK_CAP_UNION_SHARED"); + const int m = capunion::mode(e); + if (m != capunion::ON) + logf("vk: the captures' union of the range lists %s (RX_VK_CAP_UNION_SHARED)", + m == capunion::CHECK ? "built both ways and compared" : "built by each caller, as before"); + else if (e && e[0] && strcmp(e, "1")) + logf("vk: RX_VK_CAP_UNION_SHARED=%s not known: one union a version, as unset", e); + return m; + }(); + return v; +} +bool cap_union_shared() { + return capunion::shared(cap_union_mode(), lab_ab::on("nocapunion")); +} +// (built: the shared union's builds; reused: a caller's copy of one built already; own: a caller's own build, the switch off +// or the knob; sorts: runs that did not arrive sorted; diff: the check's lists that differ) +std::atomic st_cu_built{0}, st_cu_reused{0}, st_cu_own{0}, st_cu_sorts{0}, st_cu_diff{0}; +void cap_union_differs(const char* what, size_t now, size_t before) { + if (st_cu_diff.fetch_add(1, std::memory_order_relaxed) < 20) + logf("vk: RX_VK_CAP_UNION_SHARED=check: a difference in %s (%zu ranges, %zu as before)", what, now, before); +} +/// ranges_merged of v, whose first cut ranges are one list and the rest another (cap_ranges_mu held, the shared union on): +/// a merge when both arrive sorted; with the check, compared with ranges_merged, whose list is the one used (what: the +/// list, for the check's log line) +std::vector> cap_union_merged(std::vector> v, size_t cut, const char* what) { + uint64_t sorts = 0; + if (cap_union_mode() != capunion::CHECK) { + auto m = capunion::merged_runs(std::move(v), cut, cut, &sorts); + if (sorts) st_cu_sorts.fetch_add((int64_t)sorts, std::memory_order_relaxed); + return m; + } + const auto m = capunion::merged_runs(v, cut, cut, &sorts); + if (sorts) st_cu_sorts.fetch_add((int64_t)sorts, std::memory_order_relaxed); + auto old = ranges_merged(std::move(v)); + if (m != old) cap_union_differs(what, m.size(), old.size()); + return old; +} void refresh_pool_ranges_locked() { // (cap_ranges_mu held) if (!capture_pool_max() && !cap_only_gpu()) return; const uint32_t g = host->maps_generation(); @@ -2711,33 +2821,50 @@ void refresh_pool_ranges_locked() { // (cap_ranges_mu held) const int n = host->gpu_pools(reinterpret_cast(list.data()), (int)list.size()); std::vector> v, every; std::unordered_map seen; - seen.reserve((size_t)std::max(n, 0)); + // ((Triforce, 11-26, C22) a pool's first capture is read by RX_VK_CAPTURE_EAGER alone: without it (the default) the map + // is not made again at every look, a find and an insert a pool; RX_VK_CAP_UNION_SHARED=0 or the knob: as before. + // =check skips it as the default does: without RX_VK_CAPTURE_EAGER it changes no list) + const bool cu = cap_union_shared(); + const bool first_seen = capunion::first_seen_needed(eager_captures(), cu); + if (first_seen) seen.reserve((size_t)std::max(n, 0)); for (int i = 0; i < n; i++) { if (list[i][1] && list[i][0] < (1ull << 40)) // (RX_VK_CAP_ONLY_GPU: every pool, whatever its size) every.push_back({list[i][0] & ~4095ull, (list[i][0] + list[i][1] + 4095) & ~4095ull}); if (!list[i][1] || list[i][1] > capture_pool_max() || list[i][0] >= (1ull << 40)) continue; + if (!first_seen) { // (no eager count: every small pool, as the test below lets through) + v.push_back({list[i][0] & ~4095ull, (list[i][0] + list[i][1] + 4095) & ~4095ull}); + continue; + } auto it = pool_first_seen.find(list[i][0]); const uint64_t first = it != pool_first_seen.end() ? it->second : captures_made; seen[list[i][0]] = first; if (!eager_captures() || captures_made - first < eager_captures()) v.push_back({list[i][0] & ~4095ull, (list[i][0] + list[i][1] + 4095) & ~4095ull}); } - pool_first_seen.swap(seen); + if (first_seen) pool_first_seen.swap(seen); // ((Triforce) the lists' version moves only when one of them changed, RX_VK_CAP_RANGES_SAME=0: at every look, as before. Each // move has the captures' union of the lists made again (capture_ranges_merged), and the look comes every 64 captures and at // every change of the pool table, mostly to find the same pools) static const bool same_kept = !(getenv("RX_VK_CAP_RANGES_SAME") && atoi(getenv("RX_VK_CAP_RANGES_SAME")) == 0); bool changed = !same_kept; if (cap_only_gpu()) { + // ((Triforce, 11-26, C22) the host's pools and the recorded ones: two runs, each sorted where its source is in address + // order (asked, not assumed), merged; the same list as the sort's) + const size_t cut = every.size(); pool_records_ranges(every); - auto all = ranges_merged(std::move(every)); + auto all = cu ? cap_union_merged(std::move(every), cut, "the game's pools' list (all_pool_ranges)") : ranges_merged(std::move(every)); if (all != all_pool_ranges) all_pool_ranges = std::move(all), changed = true; } - std::sort(v.begin(), v.end()); std::vector> m; - for (const auto& r : v) { - if (!m.empty() && r.first <= m.back().second) m.back().second = std::max(m.back().second, r.second); - else m.push_back(r); + if (cu) { // (one run) + const size_t whole = v.size(); + m = cap_union_merged(std::move(v), whole, "the small pools' list (pool_cap_ranges)"); + } else { + std::sort(v.begin(), v.end()); + for (const auto& r : v) { + if (!m.empty() && r.first <= m.back().second) m.back().second = std::max(m.back().second, r.second); + else m.push_back(r); + } } if (m != pool_cap_ranges) pool_cap_ranges.swap(m), changed = true; if (changed) cap_ranges_ver++; @@ -2967,7 +3094,9 @@ void publish_tex_spans(uint64_t frame) { cap_ranges_ver++; } /// the captures' ranges: the mirrored imports (clipped to the GPU-visible memory with RX_VK_CAP_ONLY_GPU=1), the texture -/// storage, the small pools; their union, sorted and merged (cap_ranges_mu held). The left-out ranges published for the checks +/// storage, the small pools; their union, sorted and merged (cap_ranges_mu held). The left-out ranges published for the checks. +/// capunion.h's build, join and clip copy this, ranges_merged and ranges_clip: tests/test_capunion.py compiles the three +/// against them std::vector> capture_union_locked() { std::vector> imp = cap_ranges; if (cap_only_gpu()) { @@ -2987,12 +3116,56 @@ std::vector> capture_union_locked() { imp.insert(imp.end(), pool_cap_ranges.begin(), pool_cap_ranges.end()); return ranges_merged(std::move(imp)); } +/// ((Triforce, 11-26, C22; capunion.h; RX_VK_CAP_UNION_SHARED) The captures' ranges for a caller whose own copy is older than +/// cap_ranges_ver, into mine (cap_ranges_mu held). The union is built once a version of the lists, here, by whichever caller +/// comes first (capture_make, capture_ranges_merged: the Presentation thread calls both in the plain mode; with threaded +/// rendering the game's submitting thread calls one and the replay thread the other), and the left-out ranges are published +/// at that build alone; the next caller of the version copies it. mine is the caller's own: the shared one is read under +/// cap_ranges_mu only. =0 or the lab knob nocapunion: capture_union_locked for every caller, as before. =check: the build +/// is capture_union_locked's, compared with capunion's, and a reuse is compared with a build made again +void capture_union_take_locked(std::vector>& mine) { + static capunion::Shared cap_union; // (cap_ranges_mu) + static capunion::Built b; // (cap_ranges_mu; after a build, that version's union and left-out ranges, replaced at the next) + if (!cap_union_shared()) { + mine = capture_union_locked(); + st_cu_own.fetch_add(1, std::memory_order_relaxed); + return; + } + const bool checked = cap_union_mode() == capunion::CHECK; + uint64_t sorts = 0; + bool built = false; + const auto& u = capunion::get(cap_union, cap_ranges_ver, [&](std::vector>& uni) { + capunion::build(cap_ranges, all_pool_ranges, tex_cap_ranges, pool_cap_ranges, cap_only_gpu(), b, &sorts); + if (checked) { // (the lists as before, and the left-out ranges published as before; capunion's only compared) + uni = capture_union_locked(); + if (b.uni != uni) cap_union_differs("the captures' union", b.uni.size(), uni.size()); + std::lock_guard lk(cap_excl_mu); + if (b.excl_made && b.excl != cap_excl) cap_union_differs("the left-out ranges", b.excl.size(), cap_excl.size()); + return; + } + uni.swap(b.uni); + if (b.excl_made) { + std::lock_guard lk(cap_excl_mu); + cap_excl.swap(b.excl); + cap_excl_ver.fetch_add(1, std::memory_order_release); + } + }, &built); + if (checked && !built) { // (a reuse: what a build of the caller's own would have given, and published) + capunion::build(cap_ranges, all_pool_ranges, tex_cap_ranges, pool_cap_ranges, cap_only_gpu(), b, nullptr); + if (b.uni != u) cap_union_differs("a reused union", b.uni.size(), u.size()); + std::lock_guard lk(cap_excl_mu); + if (b.excl_made && b.excl != cap_excl) cap_union_differs("a reused union's left-out ranges", b.excl.size(), cap_excl.size()); + } + mine = u; + (built ? st_cu_built : st_cu_reused).fetch_add(1, std::memory_order_relaxed); + if (sorts) st_cu_sorts.fetch_add((int64_t)sorts, std::memory_order_relaxed); +} /// (RX_VK_CAP_ONLY_GPU) a replay read, texture upload or buffer binding of [gpu, gpu + n): counted, and the first 20 logged, /// when it reaches into the left-out ranges void cap_excl_note(uint64_t gpu, uint64_t n, const char* who) { if (!n) return; const uint64_t g = gpu < (1ull << 40) ? gpu : host->gpu_guest(gpu); - if (!g || !cap_excl_hit(g, g + n)) return; + if (!g || !cap_excl_hit_gap(g, g + n)) return; if (st_excl_reads.fetch_add(1, std::memory_order_relaxed) < 20) logf("vk: RX_VK_CAP_ONLY_GPU: %s of %#llx +%#llx reaches memory the capture leaves out", who, (unsigned long long)gpu, (unsigned long long)n); @@ -3027,7 +3200,8 @@ void cap_pool_born_now(uint64_t gpu, uint64_t size) { } // namespace /// (RX_VK_CAP_ONLY_GPU) a present: every 10 s, the capture's pages a frame (and with 2 those it would leave out), the reads -/// into the left-out ranges, and the largest of those ranges +/// into the left-out ranges, the largest of those ranges, the left-out checks answered from the gap memo and searched +/// (RX_VK_CAP_EXCL_GAP) and the union's builds (RX_VK_CAP_UNION_SHARED) void memory_cap_present() { if (!cap_only_gpu()) return; st_cap_presents.fetch_add(1, std::memory_order_relaxed); @@ -3053,9 +3227,17 @@ void memory_cap_present() { } logf("vk: capture (RX_VK_CAP_ONLY_GPU=%d), a frame over the last 10 s (%.0f frames, %.1f captures a frame): %.0f pages taken " "(%.1f MB), of them in the left-out ranges %.0f (counted with 2 only); reads and bindings into the left-out ranges %lld in " - "all; left-out ranges %zu, %.0f MB, the largest:%s", + "all; left-out ranges %zu, %.0f MB, the largest:%s; " + "left-out checks in all from the gap memo %lld, searched %lld, differing %lld (RX_VK_CAP_EXCL_GAP); " + "the captures' union of the lists (RX_VK_CAP_UNION_SHARED=%s): built %lld " + "times, copied from one built %lld, built by a caller for itself %lld, runs that had to be sorted %lld, check differences " + "%lld", cap_only_gpu(), f, takes / f, pages / f, pages * 4096.0 / 1048576.0 / f, excl / f, (long long)st_excl_reads.load(), - ex.size(), total / 1048576.0, top.c_str()); + ex.size(), total / 1048576.0, top.c_str(), (long long)st_gap_memo.load(std::memory_order_relaxed), + (long long)st_gap_search.load(std::memory_order_relaxed), (long long)st_gap_diff.load(std::memory_order_relaxed), + cap_union_mode() == capunion::CHECK ? "check" : cap_union_mode() == capunion::ON ? "1" : "0", + (long long)st_cu_built.exchange(0), (long long)st_cu_reused.exchange(0), (long long)st_cu_own.exchange(0), + (long long)st_cu_sorts.exchange(0), (long long)st_cu_diff.load()); } void memory_note_texture_upload(uint64_t guest, uint64_t size) { @@ -3968,7 +4150,7 @@ std::unique_ptr capture_make(bool behind) { static thread_local uint64_t ver = 0; if (ver != cap_ranges_ver) { // (the three lists overlap: their union, sorted, once each time one changes) ver = cap_ranges_ver; - mirrored = capture_union_locked(); // (RX_VK_CAP_ONLY_GPU: the imports clipped to the game's pools) + capture_union_take_locked(mirrored); // (RX_VK_CAP_ONLY_GPU: the imports clipped to the game's pools; (Triforce, 11-26, C22) the one union of this version, copied) texr = tex_cap_ranges; std::sort(texr.begin(), texr.end()); size_t m = 0; @@ -4168,8 +4350,9 @@ std::unique_ptr capture_make(bool behind) { /// The ranges the captures take (the mirrored pools, the texture storage, the small pools): their union, sorted and /// merged, as of now; empty while no capture was made (memory_collect_written: a page in them written after its -/// submit's capture is left for the next capture). Built again only when one of the three lists changed, as -/// capture_make keeps its own union; the reference is the calling thread's until its next call +/// submit's capture is left for the next capture). Copied again only when one of the lists changed, from the union +/// capture_union_take_locked builds once a version (each caller builds its own with RX_VK_CAP_UNION_SHARED=0 or in the +/// knob's phases); the reference is the calling thread's until its next call const std::vector>& capture_ranges_merged() { static const std::vector> none; static thread_local std::vector> merged; @@ -4181,7 +4364,7 @@ const std::vector>& capture_ranges_merged() { refresh_pool_ranges_locked(); // (a pool made since the last capture: the next one takes its pages, not this) if (ver != cap_ranges_ver) { ver = cap_ranges_ver; - merged = capture_union_locked(); // (the same ranges as the captures take: RX_VK_CAP_ONLY_GPU) + capture_union_take_locked(merged); // (the same ranges as the captures take: RX_VK_CAP_ONLY_GPU; (Triforce, 11-26, C22) the one union of this version, copied) } return merged; } @@ -5201,6 +5384,9 @@ namespace { /// pools_mu held. Pool* pool_cache[4096]; // (by 64 KB page: the pools buffer bindings hit lately) std::atomic pools_gen{1}; // (bumped when a pool leaves the table: the recording threads' caches go stale) +// ((Triforce, 11-27, bindspan.h) bumped when imports are left overlapping (pools_flag_overlapping): a bind span filled before +// is not asked again, as its pool may be one of them. The bind spans' key only: the memo and the per-page slots keep theirs) +std::atomic pools_overlap_gen{0}; struct TlPool { Pool* p; uint64_t gen; @@ -5546,6 +5732,30 @@ void span_game_pools(uint64_t& lo, uint64_t& hi, uint64_t chunk) { } } +/// ((Triforce, 11-27, bindspan.h) The import n was made beside the imports its range overlaps (pool_lookup's plan past 1 GB: +/// they stay): it and each of them are flagged left_overlapping, which no bind span is filled for, and pools_overlap_gen +/// moves, so that a span of one of them filled before is not asked again. Their read bindings go by the page, the pool a +/// thread's slot or pool_of gives, as before the spans. The imports it overlaps, counted (pools_mu held) +int pools_flag_overlapping(std::map::iterator n) { + const uint64_t lo = n->second.lo, hi = n->second.hi; + int found = 0; + for (auto it = imported.lower_bound(hi); it != imported.begin();) { // (the imports starting below hi, the last ones first) + --it; + if (it == n) continue; + if (it->second.hi <= lo) { + if (it->second.hi + (1ull << 30) < lo) break; // (imports are at most 1 GB: none further down reaches lo) + continue; + } + __atomic_store_n(&it->second.left_overlapping, true, __ATOMIC_RELAXED); + found++; + } + if (found) { + __atomic_store_n(&n->second.left_overlapping, true, __ATOMIC_RELAXED); + pools_overlap_gen.fetch_add(1, std::memory_order_release); // (after the flags: a key with the new value sees them) + } + return found; +} + Pool* pool_lookup(uint64_t guest, uint64_t size) { if (guest_pools.empty()) return nullptr; bg_drain(); @@ -5605,8 +5815,10 @@ Pool* pool_lookup(uint64_t guest, uint64_t size) { // new import of both and moved its GPU-written contents into it, for bindings that may never come. A real overlap of // the binding still takes the neighbour in. plan returns whether only the padding reached one) static const bool narrow_wanted = getenv("RX_VK_IMPORT_NARROW") && atoi(getenv("RX_VK_IMPORT_NARROW")) != 0; + bool left_overlapping = false; // ((Triforce, 11-27) the last plan went past 1 GB: the import stays beside the others) auto plan = [&](bool spanned) { // (the range, the imported pools it takes in; spanned: span_game_pools's chunks too) bool padding_only = false; + left_overlapping = false; lo = want_lo, hi = std::max(want_hi, imp != imported.end() ? imp->second.hi : 0); if (spanned && chunk) span_game_pools(lo, hi, chunk); for (bool grew = true; grew;) { @@ -5633,6 +5845,7 @@ Pool* pool_lookup(uint64_t guest, uint64_t size) { lo = want_lo, hi = std::max(want_hi, imp != imported.end() ? imp->second.hi : 0); overlapped.clear(); if (imp != imported.end()) overlapped.push_back(imp->first); + left_overlapping = true; } return padding_only; }; @@ -5678,6 +5891,7 @@ Pool* pool_lookup(uint64_t guest, uint64_t size) { } p.imported_value = mem_rec_value; imp = imported.emplace(p.lo, p).first; + if (left_overlapping) pools_flag_overlapping(imp); // ((Triforce, 11-27) no bind spans over two imports of one page) guest_pages_set(p.lo, p.hi, p.address); if (chunk) prefetch_chunks(p.lo, p.hi, chunk); if (overlapped.size() > 1) { @@ -5847,6 +6061,9 @@ bool mirror_small_full(const Pool& p, uint64_t take) { return mirror_heat_on() && __atomic_load_n(&p.heat, __ATOMIC_RELAXED) < mirror_hot_bytes() && mirror_bytes + take > mirror_small_cap(); } bool mirror_upload = false; // (a submission is being recorded: its upload command buffer takes the syncs) +// ((Triforce, 11-27) the lab knob nobindspan, read once a submission (memory_begin_submission): a span is only asked while +// mirror_upload is on. Not lab_ab::on at every binding: its string compares ran in the knobs' phases alone) +std::atomic bind_span_lab_off{false}; std::vector mirror_wanted, mirror_synced; struct WriteBack { Pool* pool; @@ -5888,16 +6105,39 @@ void cpu_words_merge() { // (holding cpu_words_mu) } cpu_words_new.clear(); } +// ((Triforce, 11-26) The words the sets hold, asked at the note (cpuwordsseen.h): the same report words come every frame, +// and each was pushed, sorted and searched for in both sets again at every part's end with write-backs, to be dropped +// there. An entry is the word's whole address and the sets' generation, so the table never calls a word known that the +// sets do not hold; it forgets where the sets are cleared, in memory_cpu_owned. Read and written under cpu_words_mu. +// RX_VK_CPU_WORDS_SEEN=0: every word noted again, as before; =check: as before, and each word the table knows looked up +// in the sets (mismatches in the mirror syncs' line). The lab knob nowordsseen notes every word again in its phases) +cpu_words_seen::Table cpu_words_table; +int cpu_words_seen_mode() { + static const int env = [] { + const char* e = getenv("RX_VK_CPU_WORDS_SEEN"); + const int m = cpu_words_seen::mode(e); + if (m != cpu_words_seen::ON) logf("vk: report words the sets hold are %s (RX_VK_CPU_WORDS_SEEN)", + m == cpu_words_seen::OFF ? "noted again every time, as before" : "noted again and checked against the sets"); + else if (e && e[0] && strcmp(e, "1")) + logf("vk: RX_VK_CPU_WORDS_SEEN=%s not known: report words the sets hold are not noted again, as unset", e); + return m; + }(); + return cpu_words_seen::mode_now(env, lab_ab::on("nowordsseen")); +} } // namespace void memory_cpu_owned(uint64_t guest, uint64_t size) { static const bool off = getenv("RX_VK_WB_REPORTS") != nullptr; if (off || !guest || wb_notes_off()) return; // ((Triforce, 11-22, MEM-51) no mirrors: no write-back cuts these words out) + const int seen = cpu_words_seen_mode(); std::lock_guard lk(cpu_words_mu); if (cpu_words.size() + cpu_words_recent.size() + cpu_words_new.size() > 65536) { // (as before: forgotten when it gets this big) cpu_words_merge(); // (which leaves cpu_words_new empty) - if (cpu_words.size() + cpu_words_recent.size() > 65536) cpu_words.clear(), cpu_words_recent.clear(); + // ((Triforce, 11-26) the only place a word leaves the sets: the table of the words they hold forgets with them) + if (cpu_words.size() + cpu_words_recent.size() > 65536) cpu_words.clear(), cpu_words_recent.clear(), cpu_words_table.forget(); } - for (uint64_t a = guest & ~7ull; a < guest + size; a += 8) cpu_words_new.push_back(a); + // ((Triforce, 11-26) a word the sets hold already is not noted again: the merge would only find it there) + for (uint64_t a = guest & ~7ull; a < guest + size; a += 8) + if (cpu_words_seen::push(cpu_words_table, seen, a, cpu_words, cpu_words_recent, cpu_words_new)) cpu_words_new.push_back(a); // (the write itself, guest_cpu_write, has told the write-back diff's shadows) } namespace { @@ -7104,9 +7344,78 @@ std::atomic st_binds_written{0}, st_binds_guest{0}; void memory_bind_counts(uint64_t* written, uint64_t* guest) { *written = st_binds_written.load(std::memory_order_relaxed), *guest = st_binds_guest.load(std::memory_order_relaxed); } +// ((Triforce, 11-26, the GPU pass on v0.8.3, C08) bindspan.h: a read binding inside a span of its pool's mirror that this +// thread's lock-free path resolved before, under the same stamp, pool table, segment and recording, is given the mirror by two +// compares in place of the pool table, the pool's fields, the add on Pool::binds and the resident pieces' walk. RX_VK_BIND_SPAN=0: +// as before; =check: a hit is resolved the whole way too and the two compared (the whole way's returned); the lab's knob +// "nobindspan" is =0 in its phases. Counted every 600 submissions (bind_span_report, memory_end_submission) +static int bind_span_mode() { + static const int m = [] { + const char* e = getenv("RX_VK_BIND_SPAN"); + const int v = bindspan::mode(e); + if (v != bindspan::kOn) + logf("vk: bind spans %s (RX_VK_BIND_SPAN)", v == bindspan::kCheck ? "checked: every hit is resolved the whole way too, the " + "whole way's result returned, the differences counted" : "off: every read binding the whole way, as before"); + else if (e && e[0] && strcmp(e, "1")) + logf("vk: RX_VK_BIND_SPAN=%s not known: bind spans, as unset", e); + return v; + }(); + return m; +} +static thread_local bindspan::Set tl_bind_spans; +static thread_local bool tl_bind_span_checking = false; // (=check: the whole way is being asked for a hit's binding) +static std::atomic st_span_hits{0}, st_span_misses{0}, st_span_fills{0}, st_span_checked{0}, st_span_diffs{0}; +/// The lock-free path just gave p's mirror to a read binding of [off, off + size): the span around it, the pool's or its +/// resident pieces' run. None for an import left overlapping another (pools_flag_overlapping): a span of either would +/// answer for pages the other holds too, where the bindings go by the page +static void bind_span_fill(const bindspan::Key& key, Pool* p, uint64_t off, uint64_t size) { + if (__atomic_load_n(&p->left_overlapping, __ATOMIC_RELAXED)) return; + const bool pieces = p->mpieces; + if (pieces && p->res_bits.empty()) return; + uint64_t lo = 0, hi = 0; + bindspan::bounds(p->lo, p->hi, off, size, pieces ? p->res_bits.data() : nullptr, p->res_bits.size(), p->piece_shift, &lo, &hi); + tl_bind_spans.fill(key, lo, hi, p->lo, p->mirror, p, [](Pool* q, uint32_t n) { __atomic_fetch_add(&q->binds, n, __ATOMIC_RELAXED); }); +} +/// The thread's span counts to the sums now and then (every kTakeAt of its questions, a hit's or a miss's), not at each binding +static void bind_span_take() { + uint64_t h = 0, m = 0, f = 0; + if (!tl_bind_spans.take_counts(&h, &m, &f)) return; + st_span_hits.fetch_add(h, std::memory_order_relaxed), st_span_misses.fetch_add(m, std::memory_order_relaxed); + st_span_fills.fetch_add(f, std::memory_order_relaxed); +} +/// (RX_VK_BIND_SPAN=check) a hit's answer against the whole way's; a difference logged with the span and its key +static void bind_span_checked(const BufferRef& span, const BufferRef& whole, uint64_t guest, const bindspan::Set::Span& s, + const bindspan::Key& key) { + st_span_checked.fetch_add(1, std::memory_order_relaxed); + if (span.buffer == whole.buffer && span.offset == whole.offset && span.size == whole.size && span.address == whole.address) return; + if (st_span_diffs.fetch_add(1, std::memory_order_relaxed) < 20) + logf("vk: bind spans: a read binding of %#llx +%#llx: the span gave buffer %p at %#llx, the whole way %p at %#llx +%#llx " + "(RX_VK_BIND_SPAN=check); the span %#llx..%#llx of the pool at %#llx%s, key stamp %#llx, pools %llu, segment %llu, " + "recording %llu, overlaps %llu", (unsigned long long)guest, (unsigned long long)span.size, (void*)span.buffer, + (unsigned long long)span.offset, (void*)whole.buffer, (unsigned long long)whole.offset, (unsigned long long)whole.size, + (unsigned long long)s.lo, (unsigned long long)s.hi, (unsigned long long)s.base, s.pool->mpieces ? " (in pieces)" : "", + (unsigned long long)key.stamp, (unsigned long long)key.pools_gen, (unsigned long long)key.segment, + (unsigned long long)key.rec_value, (unsigned long long)key.overlaps); +} +static void bind_span_report() { // (every 600 submissions) + const int mode = bind_span_mode(); + if (mode == bindspan::kOff || !mirror_on()) return; // (no mirror: no span, nothing to count) + static uint64_t l_hits, l_misses, l_fills; + const uint64_t h = st_span_hits.load(std::memory_order_relaxed), m = st_span_misses.load(std::memory_order_relaxed), + f = st_span_fills.load(std::memory_order_relaxed); + char chk[128] = ""; + if (mode == bindspan::kCheck) + snprintf(chk, sizeof chk, "; checked against the whole way so far %llu, %llu differed (RX_VK_BIND_SPAN=check)", + (unsigned long long)st_span_checked.load(std::memory_order_relaxed), (unsigned long long)st_span_diffs.load(std::memory_order_relaxed)); + logf("vk: bind spans (600 submits): %llu read bindings answered from a span, %llu the whole way past the memo, %llu spans " + "filled%s", (unsigned long long)(h - l_hits), (unsigned long long)(m - l_misses), (unsigned long long)(f - l_fills), chk); + l_hits = h, l_misses = m, l_fills = f; +} + BufferRef gpu_buffer_bind(uint64_t gpu, uint64_t size, bool written) { if (written) texture_gpu_wrote(gpu, size), st_binds_written.fetch_add(1, std::memory_order_relaxed); - if (cap_only_gpu()) cap_excl_note(gpu, size, "a buffer binding"); + // ((Triforce, 11-27) not again for RX_VK_BIND_SPAN=check's whole way of a span's hit: the outer call noted it) + if (cap_only_gpu() && !tl_bind_span_checking) cap_excl_note(gpu, size, "a buffer binding"); // (below 1 TB a GPU address is the guest address itself, and a pool holds the whole range or nothing: the host's // two translations are for the virtual pools above) uint64_t guest = gpu; @@ -7140,6 +7449,30 @@ BufferRef gpu_buffer_bind(uint64_t gpu, uint64_t size, bool written) { if (bind_memo_hit(guest, size, gpu_bind_stamp(), m.guest, m.size, m.stamp, m.ref.buffer != VK_NULL_HANDLE)) return m.ref; } + // ((Triforce, 11-26, C08) bindspan.h, after the memo and written into it as before: a span this thread filled under the + // same key holds this read binding: its mirror, at the same offset the path below would find. Not for the cases the rule + // leaves out, nor outside a submission's uploads (mirror_upload: the path below gives the import there)) + const int span_mode = bind_span_mode(); + const bool span_ok = span_mode != bindspan::kOff && !tl_bind_span_checking && + bindspan::eligible(written, size, mirror_upload && mirror_on(), mirror_use_on(), mirror_heat_on(), piece_idle_for() != 0) && + !bind_span_lab_off.load(std::memory_order_relaxed); + bindspan::Key span_key; + if (span_ok) { + span_key = {gpu_bind_stamp(), pools_gen.load(std::memory_order_relaxed), texture_segment(), mem_rec_value, + pools_overlap_gen.load(std::memory_order_acquire)}; + bind_span_take(); // (before the question: a checked hit takes its count back below) + if (auto* s = tl_bind_spans.find(span_key, guest, size)) { + const BufferRef ref{s->buffer, guest - s->base, size, 0}; + if (span_mode != bindspan::kCheck) return remember(ref); + tl_bind_spans.checked(s); // (the whole way counts this binding itself; the line counts it as checked) + const auto span = *s; + tl_bind_span_checking = true; + const BufferRef whole = gpu_buffer_bind(gpu, size, false); + tl_bind_span_checking = false; + bind_span_checked(ref, whole, guest, span, span_key); + return whole; + } + } // (a read binding of a pool this thread found before and whose mirror is in use this submission or that has none, // without the lock: every thread's, the replay thread's too (each draw binds several uniform buffers: the pool's // lookup under the lock was ~8% of the replay's time in a race); the rest under it, as below) @@ -7159,6 +7492,7 @@ BufferRef gpu_buffer_bind(uint64_t gpu, uint64_t size, bool written) { // (Triforce: a mirror in pieces: only where it has memory; a piece left in guest memory for good: the import; else below) if (pieces_resident(p, off, size)) { pieces_touch(p, off, size); // ((Triforce, 11-22, MEM-26's count) nothing unless RX_VK_MIRROR_PIECE_IDLE is set + if (span_ok) bind_span_fill(span_key, p, off, size); // ((Triforce, 11-26, C08) the span around it, for the next ones) return remember({p->mirror, off, size, 0}); } if (pieces_direct(p, off, size)) return remember(in_guest({p->buffer, off, size, 0})); @@ -8383,6 +8717,7 @@ void memory_begin_submission() { retired_imports_give_back(); mirror_epoch++; mirror_upload = true; + bind_span_lab_off.store(lab_ab::on("nobindspan"), std::memory_order_relaxed); // ((Triforce, 11-27) bindspan.h) mirror_synced.clear(); writebacks.clear(); imports_give_back(); @@ -9189,12 +9524,23 @@ void memory_end_submission(VkCommandBuffer cmd) { static int64_t n, l_live, l_cap; if (++n % 600 == 0) { msync_pass_report(); // ((Triforce, 11-21, MEM-48) how the syncs' pass went) + bind_span_report(); // ((Triforce, 11-26, C08) the read bindings answered from a span, bindspan.h) static int64_t l_old; + // ((Triforce, 11-26) the report words: cpuwordsseen.h's counters, since the last line, the check's mismatches since + // the start; nothing is asked of the table with RX_VK_CPU_WORDS_SEEN=0 or in the lab knob nowordsseen's phases) + static uint64_t l_wn, l_wk, l_wf; + const uint64_t wn = cpu_words_table.st_noted.load(std::memory_order_relaxed), wk = cpu_words_table.st_known.load(std::memory_order_relaxed), + wf = cpu_words_table.st_forgets.load(std::memory_order_relaxed), wm = cpu_words_table.st_mismatch.load(std::memory_order_relaxed); logf("vk: mirror syncs (600 submits): %lld dirty pages from their submits' captures, %lld from earlier ones', " "%lld from guest memory as it was at the replay; %zu captures kept; %lld pages the GPU wrote copied over " - "(%lld live); %lld kept for the GPU (RX_VK_PROTECT_BARE)", (long long)(st_sync_cap_pages - l_cap), + "(%lld live); %lld kept for the GPU (RX_VK_PROTECT_BARE); report words: %llu asked of the table, %llu known " + "to it and not noted again (noted all the same with =check), the sets forgotten %llu times, %llu check " + "mismatches since the start (RX_VK_CPU_WORDS_SEEN)", + (long long)(st_sync_cap_pages - l_cap), (long long)(st_sync_old_pages - l_old), (long long)(st_sync_live_pages - l_live), cap_bufs.size(), - (long long)st_sync_gpu_pages, (long long)st_sync_gpu_live, (long long)st_prot_kept.load()); + (long long)st_sync_gpu_pages, (long long)st_sync_gpu_live, (long long)st_prot_kept.load(), + (unsigned long long)(wn - l_wn), (unsigned long long)(wk - l_wk), (unsigned long long)(wf - l_wf), (unsigned long long)wm); + l_wn = wn, l_wk = wk, l_wf = wf; l_cap = st_sync_cap_pages, l_live = st_sync_live_pages, l_old = st_sync_old_pages; if (shadow_bytes || st_wbd_runs) logf("vk: write-back diff (600 submits): %lld runs, %.1f MB compared; %lld pages read into the shadows; %llu MB of shadows; " diff --git a/gpu/vk/vk_menu.cpp b/gpu/vk/vk_menu.cpp index ada42ca..12dcb56 100644 --- a/gpu/vk/vk_menu.cpp +++ b/gpu/vk/vk_menu.cpp @@ -8,7 +8,8 @@ // (hookshot) The mouse is free while it is open (the window lets it go: WM_APP + 8, host/display.c and // host/posix/display_sdl.c): the row under the cursor is selected, a click on a tab shows it, on a value's left or right // half changes it down or up, on a toggle flips it, on a slider's track sets it (or drag it); the wheel scrolls the rows -// (never a value, wherever the cursor is); a right click is Esc. On the Cheats page and its lists a click is Enter (on a +// (never a value, wherever the cursor is), and so does the page slider at a list's side, held and drawn along or its track +// clicked ((Triforce) bar_mouse); a right click is Esc. On the Cheats page and its lists a click is Enter (on a // choice's or an amount's left or right half, Left or Right) and a right click goes back. The drawing records each control's // place and the mouse is tested against that (vk_menu_hit.h). // (hookshot) The rows that take a restart (Row::restart) are tagged "After restart" while their value is not the one the game @@ -100,6 +101,7 @@ #include "achievement_rows.h" // (Triforce: the achievements the host names, their notice and their page) #include "save_file_rows.h" // (Triforce: the save files the host names, and the title's file select) #include "menu_sound_events.h" // (Triforce: the options' own sounds: which one a tick asks for, and their queue to the host) +#include "title_tabs.h" // ((Triforce) the title's Mods and Save Select tabs at the picture's top left: where they are) #include "mods_entry_anim.h" // ((Triforce, 11-19) the Mods entry under the title's list: the game's entries' animations) #include "focus_anim.h" // ((Triforce, 11-19) Mods and Quit under the System list, Quit's dialog: the game's buttons' and dialogs') #include "mods_page_anim.h" // ((Triforce, 11-20) the Mods screen as it opens: its In) @@ -129,6 +131,13 @@ void texture_stats(int64_t* uploads, int64_t* astc_gpu, int64_t* bytes_uploaded) bool framegen_on(); Options opts; +// ((Triforce, 11-26) vk_menu.h applied_dlss: the Upscaler, Render resolution and Upscale before bloom rows as they run, the +// defaults until the file is read; written on the menu's thread (applied_take: apply_init, menu_apply), read on any) +int applied_rows[3] = {Options().dlss, Options().resolution, Options().upscale_pre}; +int applied_dlss() { return __atomic_load_n(&applied_rows[0], __ATOMIC_RELAXED); } +int applied_resolution() { return __atomic_load_n(&applied_rows[1], __ATOMIC_RELAXED); } +int applied_upscale_pre() { return __atomic_load_n(&applied_rows[2], __ATOMIC_RELAXED); } +int menu_steady_row() { return __atomic_load_n(&opts.steady_fps, __ATOMIC_RELAXED); } namespace { @@ -262,9 +271,9 @@ const char* tx_pacing(int v) { } MENU_HINTS(hn_pacing, 0, "Each frame as soon as it is ready.", "Frames at an even interval: less stutter, at up to a frame of delay.", "The game paced to a rate this PC holds here, under the Frame rate cap, each frame shown evenly: for a display with " - "G-SYNC or FreeSync, or VSync off. Applies after a restart.", + "G-SYNC or FreeSync, or VSync off.", "As Steady, any rate, kept to whole divisions of the refresh rate (at 240 Hz: 120, 80, 60): for VSync without G-SYNC or " - "FreeSync. Applies after a restart.") + "FreeSync.") // ((Triforce, 11-26) both at once now: host/nn_vi.c steady_mode follows the row each present // (Triforce) The VSync row (opts.vsync; present_mode.h has what On and Off ask for): the line under its help says what the // choice came to on this driver, by the present mode of the swapchain there is, or which switch decides for the run. // Variants (every one): each mode the value can come to, then the two switches @@ -352,23 +361,29 @@ unsigned upscalers_available() { ur::fsr4_bits(fsr4_why() == FSR_OK) | ur::xess_bits(xess_why() == XESS_OK); // ((Triforce) Intel XeSS where it runs) } /// (FSR 3.1 has inputs of its own, at the Render resolution's mode or as its Native AA; DLSS and FSR 4 run on the frame -/// chain they share, temporal_mode) -int upscaler() { - if (fsr3_wanted()) return fsr3_native() ? ur::FSR3_AA : ur::FSR3; - const int t = temporal_mode(); - return t == ur::GAME && opts.dlss == ur::OFF ? (int)ur::OFF : t; // ((Triforce) 11-24: Off, no engine: upscale_off_wanted) +/// chain they share, temporal_mode). ((Triforce, 11-26) What a choice of the row (an opts.dlss value) comes to here: now, and +/// what stands in for a while as well (vk_temporal.h temporal_mode_of)) +int upscaler_of(int choice, bool now) { + if (fsr3_wanted_of(choice, now)) return fsr3_native_of(choice, now) ? ur::FSR3_AA : ur::FSR3; + const int t = temporal_mode_of(choice, now); + return t == ur::GAME && choice == ur::OFF ? (int)ur::OFF : t; // ((Triforce) 11-24: Off, no engine: upscale_off_wanted) } -/// ((Triforce, options_version 7) the engine alone: an engine's native AA is the Render resolution row's Native (100%)) -const char* tx_upscaler(int) { +/// The Upscaler row's choice as it comes to here: what the rows show and step from. ((Triforce, 11-26) The row as chosen, +/// which runs once applied (vk_menu.h applied_dlss): the rows after it show what goes with it) +int upscaler() { return upscaler_of(opts.dlss, true); } +/// ((Triforce, options_version 7) the engine alone: an engine's native AA is the Render resolution row's Native (100%). +/// ((Triforce, 11-26) up: an upscaler_of; the row's own is upscaler(), the performance panel's the one applied) +const char* upscaler_name(int up) { if (n64_in_front() != n64_rules::OFF) return "N64 Classic"; // ((Triforce, N64 Classic) its 3D pass draws in their place) static const char* t[ur::kUpscalers] = {"Game", "NVIDIA DLSS", "NVIDIA DLSS", "AMD FSR 3.1", "AMD FSR 4", "AMD FSR 4", "AMD FSR 3.1", "Off", "Intel XeSS", "Intel XeSS"}; // ((Triforce, FSR4-7) FSR 4 by the version AMD's library runs here, "AMD FSR 4.1", once it has been asked. up is the // engine (ur::engine), so FSR 4's Native AA reads as its engine too, "AMD FSR 4.1": the Render resolution says Native) - const int up = ur::engine(std::clamp(upscaler(), 0, ur::kUpscalers - 1)); + up = ur::engine(std::clamp(up, 0, ur::kUpscalers - 1)); if (ur::is_fsr4(up)) return fsr4_name(up == ur::FSR4_AA); return t[up]; } +const char* tx_upscaler(int) { return upscaler_name(upscaler()); } /// The Upscaler: the one shown (what runs, upscaler()), and with the game's own, why DLSS and FSR are not offered. Variants /// (every one): each value, then the game's own with each of DLSS's reasons, then with each of FSR's const char* hn_upscaler(int v, int variant) { @@ -895,9 +910,10 @@ void game_size(float scale, uint32_t& w, uint32_t& h) { const int k = twelfths(scale); w = (o.w * k + 11) / 12, h = o.h * k / 12; } -const char* tx_resolution(int v) { +/// The Render resolution's value v for the upscaler up (an upscaler_of: the row's own is upscaler(), the performance panel's +/// the one applied) +const char* resolution_name(int up, int v) { static char b[48]; - const int up = upscaler(); if (ur::full_scale(up)) return "Native (100%)"; // ((Triforce, options_version 7) DLAA, FSR 4's and FSR 3.1's native AA) v = ur::snap(up, v); // ((Triforce) 11-24: the Upscaler's own step for the saved scale, which stays the player's: set_row) if (!ur::percent(v)) return "Auto (dynamic)"; @@ -911,14 +927,15 @@ const char* tx_resolution(int v) { snprintf(b, sizeof b, "%d%% (%ux%u)", ur::percent(v), w, h); return b; } +const char* tx_resolution(int v) { return resolution_name(upscaler(), v); } /// The Render resolution: the value chosen, for the Upscaler shown (every one: each value with each Upscaler) const char* hn_resolution(int v, int variant) { const int up = variant < 0 ? std::clamp(upscaler(), 0, ur::kUpscalers - 1) : variant; if (up >= ur::kUpscalers) return nullptr; if (ur::full_scale(up)) // ((Triforce, options_version 7) Native (100%): the engine's native anti-aliasing) - // ((Triforce, FSR4-2) chosen in play, the engine scales the smaller 3D up to the output until the next start) - return "The 3D at the output's full size, its edges smoothed by the upscaler: the sharpest, and the slowest. The 3D " - "takes its full size at the next start."; + // ((Triforce, FSR4-2) chosen in play, the engine scaled the smaller 3D up to the output until a restart; ((11-26) the + // 3D takes its full size at Apply now: host/nn_vi.c realtime_step) + return "The 3D at the output's full size, its edges smoothed by the upscaler: the sharpest, and the slowest."; const int p = ur::percent(ur::snap(up, v)); // ((Triforce) 11-24: as tx_resolution shows it) if (up == ur::DLSS) { switch (p) { @@ -1657,8 +1674,11 @@ MENU_HINTS(hn_menu_size, 0, "Large in fullscreen on a screen of 1080 lines or mo "Smaller, for a desk.", "The usual size.", "Larger, for a TV across the room.") MENU_HINTS(hn_speed, 0, "A step each frame: the game slows down whenever it runs below 60 fps.", "Normal speed down to 15 fps, by taking longer steps.") -MENU_HINTS(hn_text_speed, 0, "The game's own pace, with its pauses.", "Twice as fast.", "Four times as fast.", - "Each page at once, as pressing A does.") +// ((Triforce, 11-27) #bug-tracker "sages final words cut off": a cutscene that moves on when its text has been shown (the +// sages' farewells) ends its voiced line early at the faster speeds: said on those rows) +MENU_HINTS(hn_text_speed, 0, "The game's own pace, with its pauses.", "Twice as fast. Some voiced cutscene lines end early.", + "Four times as fast. Some voiced cutscene lines end early.", + "Each page at once, as pressing A does. Voiced cutscene lines (the sages') end early.") MENU_HINTS(hn_text_size, 0, "The game's own size.", "A little larger.", "Larger.", "Much larger.", "The largest.") MENU_HINTS(hn_audio_output, 0, "5.1 when the output device has 5.1 or more speakers, else stereo.", "Stereo, whatever the device has.", "5.1, whatever the device has. Mixed down on stereo speakers.", @@ -1921,23 +1941,25 @@ Row rows[] = { {TAB_GRAPHICS, "Auto (this PC)", &opts.auto_pc, 0, 1, 1, tx_onoff, "On: the Upscaler, Render resolution, Texture detail, Shadow resolution and Grass distance are set for this PC's graphics " "card, memory and processor, and adjusted in the first minutes of play to hold the Frame rate cap. Changing one of those " - "rows yourself turns it Off. The Render resolution and Upscaler apply after a restart.", hn_auto_pc, false, true}, + "rows yourself turns it Off. The Upscaler and Render resolution take effect after Apply.", hn_auto_pc, false, true}, MENU_HEADING(TAB_GRAPHICS, "Upscaling"), // (the Upscaler only in a build with DLSS or FSR 4, or where AMD FSR 3.1 runs: row_shown. An engine's native anti-aliasing - // is the Render resolution's Native (100%), upscaler_rows.h) - {TAB_GRAPHICS, "Upscaler", &opts.dlss, 0, ur::kUpscalers - 1, 1, tx_upscaler, "What draws the 3D up to the Output resolution.", - hn_upscaler}, + // is the Render resolution's Native (100%), upscaler_rows.h. ((Triforce, 11-26) It, the Render resolution and Upscale before + // bloom are taken at Apply: applies, menu_apply) + {TAB_GRAPHICS, "Upscaler", &opts.dlss, 0, ur::kUpscalers - 1, 1, tx_upscaler, + "What draws the 3D up to the Output resolution. Takes effect after Apply.", hn_upscaler}, {TAB_GRAPHICS, "DLSS model", &opts.dlss_model, 0, ur::kModels - 1, 1, tx_dlss_model, "Which of NVIDIA's DLSS networks draws the picture.", hn_dlss_model, false, true}, {TAB_GRAPHICS, "FSR 4 model", &opts.fsr4_model, 0, ur::kFsr4Models - 1, 1, tx_fsr4_model, // ((Triforce)) "The FSR 4 network: Auto lets AMD pick for this GPU, Lite is the faster INT8 network.", hn_fsr4_model, false, true}, - // (Triforce: read once, at the start (host/nn_vi.c): Auto -> 100% in game left the 3D at the dynamic path's size) + // (Triforce: read once, at the start (host/nn_vi.c): Auto -> 100% in game left the 3D at the dynamic path's size. + // ((11-26) Read each present as applied now: the game's recompute undoes the dynamic path's size, nx2/oot_patches.py) {TAB_GRAPHICS, "Render resolution", &opts.resolution, 0, ur::kValues - 1, 1, tx_resolution, - "The size the 3D is drawn at; the upscaler fills in the rest. Applies after a restart.", hn_resolution, true}, + "The size the 3D is drawn at; the upscaler fills in the rest. Takes effect after Apply.", hn_resolution}, // (Triforce, 11-13: vk_temporal.cpp pre_wanted. Shown with DLSS or FSR: row_shown) {TAB_GRAPHICS, "Upscale before bloom", &opts.upscale_pre, 0, 1, 1, tx_onoff, "On: the upscaler works on the scene before the game's glow and tone mapping, which are then made at full size. " - "Evil HD's ambient occlusion and light shafts are not drawn with this on. Applies after a restart.", nullptr, true, true}, + "Evil HD's ambient occlusion and light shafts are not drawn with this on. Takes effect after Apply.", nullptr, false, true}, {TAB_GRAPHICS, "Sharpness", &opts.sharpness, 0, 100, 10, tx_percent, "With DLSS, DLAA or AMD FSR as the Upscaler, the 3D before the HUD (FSR's own sharpening; AMD's RCAS for DLSS); with " "the game's own upscaler, the picture at the window. 0 is off. Too much shows halos around edges.", hn_sharpness}, @@ -2025,10 +2047,11 @@ Row rows[] = { {TAB_GRAPHICS, "VSync", &opts.vsync, 0, 2, 1, tx_vsync, "Whether a finished frame waits for the screen's next refresh. Off: a little less delay, and the picture can tear. " "Every refresh: always the screen's own pacing (FIFO), for a display that tears or stutters otherwise. Changes at once.", hn_vsync, false, true}, - // (Frame pacing and Steady frame rate in one row, merged_rows.h: host/pace_steady.h, host/nn_vi.c steady_period) + // (Frame pacing and Steady frame rate in one row, merged_rows.h: host/pace_steady.h, host/nn_vi.c steady_period. ((Triforce, + // 11-26) Steady at once too: the host follows the row each present, HOS_OPT_STEADY_ROW; it took a restart) {TAB_GRAPHICS, "Frame pacing", &merged.pacing, 0, 3, 1, tx_pacing, "When each frame is shown. Steady paces the game to a rate this PC holds where you are: steadier, at some frame rate.", - hn_pacing, true}, + hn_pacing}, // (NVIDIA Reflex and AMD Anti-Lag 2 in one row, by the card's maker, merged_rows.h; none where neither runs) {TAB_GRAPHICS, "Low latency", &merged.latency, 0, 2, 1, tx_latency, "Each frame starts as late as it can, for less input delay: NVIDIA Reflex on NVIDIA cards, AMD Anti-Lag 2 on AMD ones.", @@ -2589,6 +2612,11 @@ focus_anim::Focus mods_focus[2]; // (Mods, Quit) // ((Triforce, 11-20) the owner: "Mod menu fade in". The Mods screen came whole on the frame after the press; it fades in as // the game's lists and windows do (mods_page_anim.h), stepped by menu_tick, and takes input once that has played) mods_page::Page mods_screen; +// ((Triforce, 11-26) Save Select fades in as the Mods screen does (the game's lists' and windows' In, mods_page_anim.h) and +// takes input once that has played; each card's cursor fades in and out as the game's own settings' buttons' do (focus_anim.h) +mods_page::Page files_screen; +focus_anim::Focus files_focus[save_file_rows::kSlots]; +std::atomic files_blur{false}; // (Save Select shows over the title: the picture behind it out of focus, menu_backdrop_blurred) focus_anim::Focus quit_focus[3]; // (the dialog's buttons) int64_t quit_open_ns = 0; // (prof_now when the dialog opened: its In; 0 shut) int64_t quit_shut_ns = 0; // (when B or Cancel closed it: its Out; 0 none playing) @@ -2603,9 +2631,9 @@ void quit_gone() { quit_ask = false, quit_open_ns = 0, quit_shut_ns = 0; } /// (its Out still playing) bool quit_closing() { return !quit_ask && quit_shut_ns && prof_now() - quit_shut_ns < focus_anim::kOutNs; } bool quit_entry_shown() { return (mods_list_bits.load(std::memory_order_relaxed) & HOS_MODS_LIST_TITLE) == 0; } -/// (Triforce) Save Select, the entry under Mods on the title's list while the host has named the save files (host/save_files.c): -/// where Quit is under the System list's Mods, and mods_row_sel 1 as it is. Not on the pause menu: a file is changed at the title -bool files_row_shown() { +/// (Triforce) Save Select, a tab at the title's top left beside Mods while the host has named the save files +/// (host/save_files.c). Not on the pause menu: a file is changed at the title +bool files_tab_shown() { return save_files.shown() > 0 && (mods_list_bits.load(std::memory_order_relaxed) & HOS_MODS_LIST_TITLE) != 0; } std::atomic game_frames{0}; // (the game's frames shown: menu_note_frame) @@ -2620,7 +2648,18 @@ int64_t mods_list_age() { const int64_t frames = game_frames.load(std::memory_order_relaxed) - mods_list_frame.load(std::memory_order_relaxed); return frames >= 0 && frames <= 2 ? 0 : prof_now() - t; } -bool mods_list_fresh() { return mods_list_age() < 150000000LL; } +bool mods_title_list(); // (below) +bool mods_list_fresh() { + // ((Triforce, 11-26) the pause menu's System list is gone once the game has shown three frames without it: the owner's + // picture of Mods and Quit still on the game, the menu gone, "delayed by a few frames when closing the menu. Fix that to + // where it fades away the same way as the entire menu does". Its last word held them whole for 150 ms, at 240 frames a + // second 36 frames. The title's list keeps the 150 ms its entry's own fade needs (mods_title_fading); a slow frame of + // either is no list gone, as before (mods_list_age)) + if (!mods_title_list() && mods_list_ns.load(std::memory_order_relaxed) && + game_frames.load(std::memory_order_relaxed) - mods_list_frame.load(std::memory_order_relaxed) > 2) + return false; + return mods_list_age() < 150000000LL; +} /// ((Triforce, 11-20) the owner: "the mods button ... should be synced with the timing of the other button ui so it /// seamlessly moves and disappears with them". How much of its own list's buttons the game shows this frame, 0 to 1, as /// the host reads it from the game (host/oot_menu.c, HOS_OPT_MODS_ALPHA); under 0 while it has not said (an older host) @@ -2638,6 +2677,21 @@ bool mods_title_fading() { return mods_title_list() && mods_list_age() < mods_en int64_t mods_decide_ns = 0; // (A on the title's entry: when, while its Decide plays; 0 none) float mods_entry_px[5] = {}; // (the Mods entry as last drawn, the menu's column's pixels: its hit x0 y0 x1 y1, and the pitch) bool mods_decided = false; // (its Decide ended this tick: the Mods screen opened with no sound of its own, it had the press's) +// ((Triforce) the owner: "I want you to move the mod tab and the save select tab to the top left of the screen. I want there to +// be a button prompt below the tabs ... The player should select Y to open the mod menu. And X to open the save select. +// Triangle for mods and Square for save select for PlayStation. PC should be able to select those tabs by mouse", and "Add a +// quit game option below the Options tab". On the title the entry under the list's last button is Quit Game, and Mods and Save +// Select are tabs at the picture's top left (title_tabs.h): the buttons the Switch's X and Y are bound to open them (the top +// and the left face button: Y and X on an Xbox pad, Triangle and Square on a PlayStation one, and the icons under the tabs +// are the game's own of those bindings), or a click; the mouse over one lights it. They never take the cursor) +int title_decide = 0; // (what the Decide playing on the title ends in: 0 the Mods screen, its tab's; 1 Quit Game, the entry's) +title_tabs::Layout title_tab_layout; // (the tabs as last drawn, the pixels of the column they were drawn on) +game_grid::Map title_tab_map; // (...and where that column is in the window) +int64_t title_tab_ns = 0; // (prof_now when they were last drawn: 0 never) +int title_tab_hover = -1; // (the tab the mouse is over: 0 Mods, 1 Save Select, -1 none) +bool title_tab_read = false; // (the mouse read for them since they came: a click from before is not theirs) +bool tick_sound_done = false; // (this tick's sound was asked for where it was made: none by what the tick changed) +mods_entry::Anim title_tab_anim[title_tabs::kTabs]; // ((Triforce) 11-17, his ask "We need a search bar for mods") The Mods screen's search: a bar above the cards (mods_choice -1 is // the bar), typed into from the keyboard anywhere on the screen (host/display.c: HOS_OPT_TEXT_CHAR), or from a keyboard of the // game's look on the screen for a controller (A on the bar). The text is searched 0.5 s after the typing stops, or at once @@ -2919,13 +2973,18 @@ const char* restart_names[mr::kMax]; /// What of a row takes the restart: its value; ((Triforce, options_version 7) of a merged row only what of it is read at the /// start: HDR's Native + RenoDX (the scene's RGBA16F target and RenoDX's shaders, host/nn_vi.c hos_scene_rgba16f and /// vk_temporal.cpp, from hdr_at_start and renodx_at_start; Off, Expanded and Native change at once: the swapchain is made -/// again at the next present, and the game asks nn::vi for the display's HDR as it goes), Frame generation's NVIDIA DLSS -/// (vk_dlssg.cpp), Frame pacing's Steady (host/nn_vi.c), and the Render resolution's Native (100%) with its share +/// again at the next present, and the game asks nn::vi for the display's HDR as it goes) and Frame generation's NVIDIA DLSS +/// (vk_dlssg.cpp). ((Triforce, 11-26) Frame pacing's Steady changes at once now (host/nn_vi.c steady_mode), and the Render +/// resolution, the Upscaler and Upscale before bloom are taken at Apply (applies): none of them takes a restart. But where the +/// render targets' pool is held to its size (a picture past 3840 x 2160's pixels), a larger 3D than this run has had waits for +/// the next start (host/nn_vi.c, HOS_OPT_RES_HELD: res_held): the Render resolution then takes a restart as the others, its +/// value 1 while the host keeps one back, 0 (the start's) when not (takes_restart)) +std::atomic res_held{0}; +bool takes_restart(const Row& r) { return r.value && (r.restart || r.value == &opts.resolution); } int restart_value_of(const Row& r) { if (r.value == &merged.hdr) return opts.hdr == 2 && opts.renodx ? 1 : 0; if (r.value == &merged.framegen) return opts.dlssg; - if (r.value == &merged.pacing) return opts.steady_fps; - if (r.value == &opts.resolution) return ur::snap(upscaler(), opts.resolution) + (ur::full_scale(opts.dlss) ? 100 : 0); + if (r.value == &opts.resolution) return res_held.load(std::memory_order_relaxed) != 0; // ((Triforce) Audio output: Mono is stereo's layout, the game asked for the same speakers; its average is taken at once) if (r.value == &opts.audio_output && *r.value == 3) return 1; return *r.value; @@ -2935,7 +2994,7 @@ void restart_init() { if (done) return; done = true; for (int i = 0; i < kRows; i++) { - restart_slot[i] = rows[i].restart && rows[i].value ? restart_state.add(restart_value_of(rows[i])) : -1; + restart_slot[i] = takes_restart(rows[i]) ? restart_state.add(restart_value_of(rows[i])) : -1; if (restart_slot[i] >= 0) restart_names[restart_slot[i]] = rows[i].name; } } @@ -2943,7 +3002,7 @@ int restart_slot_of(const Row& r) { return restart_slot[&r - rows]; } /// A row that takes a restart, changed from what the game started with (a row past menu_restart.h's kMax has no slot: never) bool restart_changed(const Row& r) { const int slot = restart_slot_of(r); - return r.value && r.restart && slot >= 0 && restart_value_of(r) != restart_state.start[slot]; + return takes_restart(r) && slot >= 0 && restart_value_of(r) != restart_state.start[slot]; } /// (Triforce) A row whose value the game does not read as the options are: the Custom size's two sides while the Output /// resolution is a fixed size (walking the row past a screen's size leaves that size in them). Such a row asks for no restart @@ -2977,6 +3036,90 @@ std::string restart_list_shown(const char* last) { } int ask_sel = 0; // (the restart question's choice: 0 Later, 1 Restart now) +// ---- ((Triforce, 11-26) the rows taken at Apply. The owner: "Every option that requires a restart should be changed in game +// without having to restart unless if the setting has to have the game be restarted. I want you to implement an apply option +// in the menu ... If the player tries to back out without applying the settings, they should get a pop-up that asks them to +// apply these settings. Same prompt as the Restart pop up." The Upscaler, the Render resolution and Upscale before bloom: a +// change of one remakes the game's 3D targets (host/nn_vi.c realtime_step reads the scale each present, and the game's own +// recompute makes them at the new size: nx2/oot_patches.py APPLY_NEW) and the upscaler's own (each engine makes its feature +// again for another size or colour), a hitch of a moment, so it is taken once, at Apply (the guides' Apply: the key bound to +// the Switch's X, Space unless rebound, the button bound to it, or a click on the guide), not at each step of a row. The rows +// show the choice and are saved as chosen, so a start takes them; vk_menu.h applied_dlss and its kin are what runs. Until it +// is applied, a row has the game's corner mark, its caption says "Takes effect after Apply" and the caption's foot "Apply +// needed", and closing the options asks first: the restart question's page (5), with Apply Now in place of Restart Now (ask_kind). +// Later keeps the choice for the next start and is not asked again until it changes, as the restart question's Later. The +// rows that still take a restart are those the game or the device takes once: the Output resolution and the Aspect ratio +// (the game's window textures, its picture's size and its render targets' pool are made at them before it starts: +// host/hos_main.c, host/nn_applet.c), the GPU device and Mesh shaders (the device), HDR's Native + RenoDX (the scene's +// format and its room in that pool), NVIDIA DLSS frame generation (Streamline, before the Vulkan instance), Texture detail +// (each texture is made at it), the Game language, 5.1 sound and the Camera speed (the game reads them at its start), and the +// Debug tab's developer rows ---- +mr::State apply_state; +int apply_slot[kRows]; // (a row's slot in apply_state, -1 none) +const char* apply_names[mr::kMax]; +/// A row taken at Apply +bool applies(const Row& r) { return r.value == &opts.dlss || r.value == &opts.resolution || r.value == &opts.upscale_pre; } +enum { kQuestionRestart = 0, kQuestionApply = 1 }; +int ask_kind = kQuestionRestart; // (page 5's question: the restart question, or Apply's) +constexpr int kApplyGuide = 40; // (the options' Apply guide, a kButton of the mouse's: none of page 0's other parts is one) +void apply_values(int* now) { + for (int i = 0; i < kRows; i++) + if (apply_slot[i] >= 0) now[apply_slot[i]] = *rows[i].value; +} +/// The rows whose choice is not what runs (a bit a slot) +unsigned apply_pending() { + int now[mr::kMax]; + apply_values(now); + return apply_state.pending(now); +} +/// A row taken at Apply whose choice is not what runs +bool apply_changed(const Row& r) { + const int slot = apply_slot[&r - rows]; + return slot >= 0 && *r.value != apply_state.start[slot]; +} +/// Whether closing the options asks to apply first: something not applied, and not declined with Later for the same choice +bool apply_ask() { + int now[mr::kMax]; + apply_values(now); + return apply_state.ask(now); +} +std::string apply_list(const char* last) { return mr::names(apply_names, apply_state.n, apply_pending(), ", ", last); } +/// (apply_list in the menu's language, for the question: the log keeps the English) +std::string apply_list_shown(const char* last) { + const char* names[mr::kMax]; + for (int i = 0; i < apply_state.n; i++) names[i] = i18n::tr(apply_names[i]); + return mr::names(names, apply_state.n, apply_pending(), ", ", last); +} +/// A row's mark of a change not in force yet: one that takes a restart, or Apply +bool row_pending(const Row& r) { return restart_changed(r) || apply_changed(r); } +/// What runs is the choice now, for the rows in mask (a bit a slot): applied_rows, and the slots' start values +void applied_take(unsigned mask) { + for (int i = 0; i < kRows; i++) { + const int slot = apply_slot[i]; + if (slot < 0 || !((mask >> slot) & 1)) continue; + apply_state.start[slot] = *rows[i].value; + int* to = rows[i].value == &opts.dlss ? &applied_rows[0] : rows[i].value == &opts.resolution ? &applied_rows[1] : &applied_rows[2]; + __atomic_store_n(to, *rows[i].value, __ATOMIC_RELAXED); + } +} +/// The rows taken at Apply, and what runs: the file's choice (menu_init, after the switches over it). Once +void apply_init() { + static bool done = false; + if (done) return; + done = true; + for (int i = 0; i < kRows; i++) { + apply_slot[i] = rows[i].value && applies(rows[i]) ? apply_state.add(*rows[i].value) : -1; + if (apply_slot[i] >= 0) apply_names[apply_slot[i]] = rows[i].name; + } + applied_take(~0u); +} +/// One row's choice in force at once, nothing else: a choice made for the player before the host's first read +/// (menu_first_start, auto_start) or by Auto (this PC)'s tuning in play (auto_tick) +void applied_take_row(const int* value) { + for (int i = 0; i < kRows; i++) + if (rows[i].value == value && apply_slot[i] >= 0) applied_take(1u << apply_slot[i]); +} + /// A row on its tab: the debug tools only with them on, the Upscaler only in a build with DLSS or FSR 4, or where AMD /// FSR 3.1 runs bool rdx_row(const int* v) { // (local, RenoDX port) @@ -3616,14 +3759,32 @@ void set_row(Row& r, int v, int dir, bool keep = true) { prompts_at_once(r); // ((Triforce) the button prompts' live part) if (r.value == &opts.reshade) reshade_menu::preset_chosen(); // ((Triforce) 11-24: the ReShade preset, prepared anew) if (r.value == &reshade_menu::user_pick) reshade_menu::user_picked(); - { // (a row that takes a restart: asked again at the next close) + { // (a row that takes a restart: asked again at the next close; ((Triforce, 11-26)) and one taken at Apply) int now[mr::kMax]; restart_values(now); restart_state.note(now); + apply_values(now); + apply_state.note(now); } if (keep) save(); } +/// ((Triforce, 11-26) Apply: the rows taken at Apply run as chosen from the next frame (the host reads the Render resolution +/// each present, the game makes its 3D's targets again at the new size, the upscaler its own), and the file has them. why: +/// for the log (the guide, the question's Apply Now) +void menu_apply(const char* why) { + const unsigned was = apply_pending(); + if (!was) return; + const int dlss = applied_dlss(), res = applied_resolution(), pre = applied_upscale_pre(); + const int up = upscaler_of(opts.dlss, false); + logf("menu: Apply (%s): %s. Upscaler %d (was %d), Render resolution %d (was %d), Upscale before bloom %d (was %d): %s, the " + "3D at %s from the next frame", why, apply_list(", ").c_str(), opts.dlss, dlss, opts.resolution, res, opts.upscale_pre, + pre, upscaler_name(up), resolution_name(up, opts.resolution)); + applied_take(was); + apply_state.later = false; + save(); +} + // Snapshot the drawable in pixels when confirmed. Both dimensions share one save and restart prompt. void use_window_size(unsigned width, unsigned height) { unsigned w, h; @@ -3818,6 +3979,10 @@ struct ControlConfirmation { ControlConfirmation control_confirmation; int blocked_reset_row = -1; // (a reset refused: another control has one of the row's defaults; its help says so) int pad_clear = HOS_PAD_NORTH; // (the Controls page's Clear on a controller: a face button neither Bind's nor Back's) +// ((Triforce, 11-26) the options' Apply (menu_apply): on a controller the input bound to the Switch's X, the top face button +// unless rebound, where the menu has no other use for it; on the keys the key bound to it, Space unless rebound. 0: no key) +int pad_apply = HOS_PAD_NORTH; +int apply_key = VK_SPACE; /// The next row Up or Down (direction -1, 1) goes to: on the Reset column, the next control with a Reset of its own /// (wrapping, the column kept); elsewhere the next row of the page int next_control_selection(int selection, int col, int direction) { @@ -3937,6 +4102,17 @@ int wheel_rows[TAB_SIM_TURF + 1]; // (the mouse wheel's notches since the last int scrolled_to[TAB_SIM_TURF + 1] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; // (the selection scroll_rows last brought into view) static_assert(TAB_SIM_TURF + 1 == 10, "scrolled_to: a slot for each tab, the Motion page, the Controls page, the Remembered page and the Simulated turf page"); float scroll_want[TAB_SIM_TURF + 1]; // (where scroll_at is going: the wheel moves it, a new selection too) +// ((Triforce) the page slider: the scroll bar beside a list (scroll_bar), taken by the mouse. The owner: "I want you to make +// that accessible for mouse. So when a player clicks that, it should be able to move up or down. How a normal touch slider +// should work." Its thumb held with the left button draws the list along with the cursor until the button is let go, +// wherever the cursor goes meanwhile (as a row's slider is held, drag_row); a press on its track off the thumb brings the +// thumb under the cursor first, the list with it, and is held the same way (vk_menu_hit.h Bar, bar_mouse below). Like the +// wheel it moves the list alone: no selection, no value, and no sound. A list's bar has the list's number: a tab's rows', +// the Motion, Remembered and Simulated turf pages' and the Controls page's their slot of scroll_at; the others' these) +constexpr int kBarTeleport = 100, kBarMods = 101, kBarModsDesc = 102, kBarInventory = 103, kBarNames = 104; // ((11-26) the last two the paged pages': a page a step) +int bar_held = -1; // (the one held with the left button: its number; -1 none) +float bar_grab = 0; // (how far under its thumb's top the cursor has hold of it) +int bar_hover = -1; // (the one the cursor is on, or holds: its thumb is drawn brighter) float ease_step = 0; // (this drawing's share of the way: the time since the last one) bool ease_live = false; // ((Triforce) menu_record steps the easing: a window's frames. Without them a still is drawn settled) @@ -3949,6 +4125,13 @@ ui::Ctx ui_ctx(uint32_t w, uint32_t h) { for (int i = 0; i < 4 && host && host->binding; i++) if (host->binding(HOS_BIND_PAD, face[i], 0) == pad_clear) c.clear_icon = icons[i]; c.clear_name = pad_name(pad_clear); + // ((Triforce, 11-26) and the options' Apply: its face button's icon (pad_apply, menu_tick), its key's name (apply_key)) + for (int i = 0; i < 4 && host && host->binding; i++) + if (host->binding(HOS_BIND_PAD, face[i], 0) == pad_apply) c.apply_icon = icons[i]; + c.apply_name = pad_name(pad_apply); + static char apply_label[24]; // (a fixed place: a Ctx made before keeps pointing at it) + snprintf(apply_label, sizeof apply_label, "%s", apply_key ? key_name(apply_key) : "-"); // (no key free: the mouse's alone) + c.key_apply = apply_label; } { // ((Triforce) the keys the tab strip's ends and the guides name: those bound to the Switch's L, R and B where the menu // takes them (menu_bound_key), as the game's own guides name the bindings; else the menu's own Q, E and Esc) @@ -3966,7 +4149,9 @@ ui::Ctx ui_ctx(uint32_t w, uint32_t h) { c.s = ui::unit((float)h, 0, false, false, &c.safe); // (the cursor's glow breathes, as the game's: a 2 s cycle; RX_VK_UI_STILL=1 holds it, for pictures that compare) static const bool still = getenv("RX_VK_UI_STILL") != nullptr; - c.pulse = still ? 0.6f : 0.5f + 0.5f * std::sin((float)((prof_now() % 2000000000LL) / 2e9 * 6.2831853)); + // ((Triforce, 11-26) over the game's cursors' CursorLoop, 40 frames (the layouts' keys at 0, 20 and 40); it was 2 s) + c.pulse = still ? 0.6f : 0.5f + 0.5f * std::sin((float)((prof_now() % 666666667LL) / 666666667.0 * 6.2831853)); + c.hdr10 = dev.hdr; // ((Triforce, 11-26) the overlay then blended on HDR10's PQ codes: the glows' own look (ui::glow_layers)) return c; } /// (Triforce) The menu's, the counter's and the notice's: the game's menu fonts where the pages draw their text (body its @@ -4098,7 +4283,13 @@ float scroll_rows(int slot, int n, int sel, float top, float bottom, float pitch float& want = scroll_want[slot]; const int wheel = std::exchange(wheel_rows[slot], 0); if (n <= fit) want = 0; // (nothing to scroll: the wheel does nothing) - else { + else if (bar_held == slot) { + // ((Triforce) its page slider held (bar_mouse): the rows where the cursor has them, between two rows too, and at once, + // not eased: the thumb stays under the cursor. Whole rows again, eased, once it is let go (below). The selection + // stays where it was, as with the wheel; one the keys or the pad move meanwhile is brought into view after) + want = std::clamp(want, 0.0f, (float)(n - fit)); + return at = want; + } else { want -= (float)wheel; // (the wheel scrolls the rows and leaves the selection, and every value, as they are) static int fits[sizeof scroll_at / sizeof *scroll_at]; // (and after a resize: the rows that fit changed) if (sel != scrolled_to[slot] || fit != std::exchange(fits[slot], fit)) { // (a new selection, by the keys or the pad: brought into view) @@ -4114,21 +4305,63 @@ float scroll_rows(int slot, int n, int sel, float top, float bottom, float pitch return at; } /// The scroll bar at x, beside a list of n rows of which shown fit, the first at `first`: the game's (PaScrollBar_00: a short -/// bar, 32 x 312 units, at the list's middle; its lit part the rows in view) -void scroll_bar(ui::Ctx& c, float x, float top, float bottom, int n, int shown, float first) { +/// bar, 32 x 312 units, at the list's middle; its lit part the rows in view). ((Triforce) id: the list's number (kBarTeleport +/// and the others, a rows' list its slot of scroll_at), for the mouse: the bar is recorded as it is drawn (hits.add_bar: the +/// same track and thumb the picture has), 36 units either side of its middle, as far as the nearest cards begin (the +/// teleport list's), and 12 past its ends; its lit part brighter under the cursor, brighter still while it is held. Without +/// a number it only shows) +void scroll_bar(ui::Ctx& c, float x, float top, float bottom, int n, int shown, float first, int id = -1) { if (n <= shown && !c.over_game) return; // (over the game's own list its bar is under ours: drawn, whole, even so) if (n <= shown) n = shown = 1, first = 0; const float mid = (top + bottom) * 0.5f, half = ui::lu(c, 156), w = ui::lu(c, 16); const float y0 = mid - half + 2 * half * first / n, y1 = mid - half + 2 * half * (first + shown) / n; + const menu_hit::Bar bar{id, mid - half, mid + half, (float)n, (float)shown, first, ui::lu(c, 24)}; + hits.add_bar(x - ui::lu(c, 36), x + ui::lu(c, 36), bar, ui::lu(c, 12)); + const bool live = id >= 0 && bar.scrolls(); + const ImU32 lit = live && id == bar_held ? ui::rgba(255, 216, 132) : live && id == bar_hover ? ui::rgba(232, 182, 98) : ui::rgba(200, 146, 66); if (const ui::Art* t = ui::skin("ScrollBarBase_00")) { ui::image(c, t, ImVec2(x - w, mid - half), ImVec2(x + w, mid + half), ui::rgba(18, 14, 9, 235)); c.d->PushClipRect(ImVec2(x - w, y0), ImVec2(x + w, y1), true); - ui::image(c, t, ImVec2(x - w, mid - half), ImVec2(x + w, mid + half), ui::rgba(200, 146, 66)); + ui::image(c, t, ImVec2(x - w, mid - half), ImVec2(x + w, mid + half), lit); c.d->PopClipRect(); return; } c.d->AddRectFilled(ImVec2(x - w * 0.4f, mid - half), ImVec2(x + w * 0.4f, mid + half), ui::rgba(18, 14, 9, 235), w * 0.4f); - c.d->AddRectFilled(ImVec2(x - w * 0.4f, y0), ImVec2(x + w * 0.4f, y1), ui::rgba(200, 146, 66), w * 0.4f); + c.d->AddRectFilled(ImVec2(x - w * 0.4f, y0), ImVec2(x + w * 0.4f, y1), lit, w * 0.4f); +} +/// ((Triforce) the page slider's list scrolled to `first` (its rows, or its pixels), by the mouse on its bar: where each +/// list keeps its place. A rows' list: scroll_rows takes it as it is while the bar is held. The cards' lists: at once, and +/// the cards no longer follow the choice, as after the wheel (the next move of the choice has them follow again). Each +/// list's drawing holds it to the list's ends) +void names_slider_to(int page); // ((Triforce, 11-26) below, with the name pages) +void bar_scroll(int id, float first) { + if (id >= 0 && id < (int)(sizeof scroll_want / sizeof *scroll_want)) scroll_want[id] = first; + else if (id == kBarTeleport) teleport_scroll_px = teleport_want_px = first, teleport_follow = false; + else if (id == kBarMods) mods_scroll_px = mods_want_px = first, mods_follow = false; + else if (id == kBarModsDesc) mods_desc_px = first; + else if (id == kBarInventory) inventory_page = std::max(0, (int)std::lround(first)); // (its drawing keeps it to its pages) + else if (id == kBarNames) names_slider_to(std::max(0, (int)std::lround(first))); +} +/// ((Triforce) the mouse on a page's sliders (the scroll bars it drew with a number), the cursor at y on `hit`: a press of +/// the left button on one takes hold of it (on its thumb where it is; elsewhere on its track the thumb comes under the +/// cursor, and the list with it), and until the button is let go the list follows the cursor, wherever it goes. True while +/// one is held: the mouse is the bar's alone then, and the page gives its rows, cards and wheel nothing of it +bool bar_mouse(const MkwVkPointer& ptr, int y, const menu_hit::Hit& hit, bool& changed) { + const int over = hit.part == menu_hit::kScroll ? hit.index : -1; + if (bar_held >= 0) { + const menu_hit::Bar* b = hits.bar_of(bar_held); + if (!b || !(ptr.held & HOS_MOUSE_LEFT)) bar_held = -1, changed = true; // (let go, or its list no longer drawn) + else if (const float first = b->drag((float)y, bar_grab); first != b->first) bar_scroll(bar_held, first), changed = true; + } else if ((ptr.pressed & HOS_MOUSE_LEFT) && over >= 0) { + if (const menu_hit::Bar* b = hits.bar_of(over)) { + bar_held = over, bar_grab = b->grab((float)y); + bar_scroll(over, b->drag((float)y, bar_grab)); + changed = true; + } + } + const int lit = bar_held >= 0 ? bar_held : over; + if (lit != bar_hover) bar_hover = lit, changed = true; + return bar_held >= 0; } /// The header with a page's title in the middle (the Controls, Motion and list pages: as the game's "Load"), its height float title_banner(ui::Ctx& c, const char* title, const char* right) { @@ -4142,13 +4375,22 @@ float title_banner(ui::Ctx& c, const char* title, const char* right) { /// set off by a bar, a line at its foot; the text in the plate's middle, as the game sets its caption. min_h: its text's /// room at least; kept between y_min and y_max. bleed: how far the plate goes on to the right of x1, off the screen (the /// game's caption plate does) +/// ((Triforce, 11-26) gold_line: one line, or two parted by '\n' (the rows that take a restart and those Apply takes, both +/// waiting). after_restart: the row's change waits, 1 for a restart, 2 for Apply (kNoteApply) +constexpr int kNoteRestart = 1, kNoteApply = 2; +int gold_lines(const char* gold_line) { + if (!gold_line) return 0; + int n = 1; + for (const char* p = gold_line; *p; p++) n += *p == '\n'; + return n; +} void help_box(ui::Ctx& c, float x0, float x1, float y0, const char* title, const char* help, const char* hint, const char* gold_line, - float min_h = 0, bool after_restart = false, float y_min = 0, float y_max = FLT_MAX, float bleed = 0) { + float min_h = 0, int after_restart = 0, float y_min = 0, float y_max = FLT_MAX, float bleed = 0) { const float s = c.s, pad_x = ui::lu(c, 72), pad_y = ui::lu(c, 56), w = x1 - x0 - 2 * pad_x; const float th = help ? ui::para(c, c.f.body, kHelpPt * s, ImVec2(), 0, help, w, false) : 0, hh = hint ? ui::para(c, c.f.body, kHintPt * s, ImVec2(), 0, hint, w - 18 * s, false) : 0; const float text_h = th + (hint ? 14 * s + hh : 0), note = after_restart ? 30 * s : 0; - const float content = (title ? 34 * s : 0) + note + text_h + (gold_line ? 46 * s : 0); + const float content = (title ? 34 * s : 0) + note + text_h + (gold_line ? 14 * s + 32 * s * gold_lines(gold_line) : 0); float tall = std::max(min_h, content + 2 * pad_y); if (y0 + tall > y_max) y0 = std::max(y_min, y_max - tall); const float y1 = std::min(y0 + tall, y_max); @@ -4163,7 +4405,8 @@ void help_box(ui::Ctx& c, float x0, float x1, float y0, const char* title, const if (title) ui::text(c, c.f.strong, 21.6f * s, ImVec2(x0 + pad_x, y), ui::kInk, title), y += 34 * s; if (after_restart) { // (this row's change applies at the next start: said here, not in the row, where it would cut the name) ui::diamond(c, ImVec2(x0 + pad_x + 5 * s, y + 10 * s), 4 * s, ui::kGoldHi); - ui::text_mid(c, c.f.strong, kHintPt * s, x0 + pad_x + 16 * s, y + 10 * s, ui::kGoldHi, "Takes effect after a restart"); + ui::text_mid(c, c.f.strong, kHintPt * s, x0 + pad_x + 16 * s, y + 10 * s, ui::kGoldHi, + after_restart == kNoteApply ? "Takes effect after Apply" : "Takes effect after a restart"); // ((Triforce, 11-26)) y += note; } if (help) ui::para(c, c.f.body, kHelpPt * s, ImVec2(x0 + pad_x, y), ui::kInk, help, w); @@ -4177,15 +4420,21 @@ void help_box(ui::Ctx& c, float x0, float x1, float y0, const char* title, const if (gold_line) { y += 14 * s; c.d->AddLine(ImVec2(x0 + pad_x, y), ImVec2(x1 - pad_x, y), ui::alpha(ui::kEdge, 0.8f), std::max(1.0f, s)); - ui::diamond(c, ImVec2(x0 + pad_x + 5 * s, y + 18 * s), 4 * s, ui::kGoldHi); - ui::text_mid(c, c.f.strong, kHintPt * s, x0 + pad_x + 16 * s, y + 18 * s, ui::kGoldHi, gold_line); + for (const char* line = gold_line; line;) { // ((Triforce, 11-26) a line each, parted by '\n') + const char* end = strchr(line, '\n'); + const std::string one = end ? std::string(line, end) : std::string(line); + ui::diamond(c, ImVec2(x0 + pad_x + 5 * s, y + 18 * s), 4 * s, ui::kGoldHi); + ui::text_mid(c, c.f.strong, kHintPt * s, x0 + pad_x + 16 * s, y + 18 * s, ui::kGoldHi, one.c_str()); + y += 32 * s; + line = end ? end + 1 : nullptr; + } } c.d->PopClipRect(); } /// The caption of a page at the options' place (SystemOption_00's N_Caption: its plate 90 units under the screen's middle, off the /// screen's right edge), as tall as its text asks, between the header and the guides void caption(ui::Ctx& c, float hx0, float hx1, const char* title, const char* help, const char* hint, const char* gold_line, float min_h = 0, - bool after_restart = false); + int after_restart = 0); /// The game's Options layout (SystemOption_00): the list's column 2240 units wide, its middle 730 left of the screen's (drawn by /// draw_menu, under the header); the caption plate to its right, what shows of it from 440 to the screen's edge constexpr float kListX = -730; // (N_List_00) @@ -4196,12 +4445,13 @@ void columns(const ui::Ctx& c, float* x0, float* x1, float* hx0, float* hx1, boo } void column(ui::Ctx&, float, float, float) {} // (the column is under the header: draw_menu draws it first) void caption(ui::Ctx& c, float hx0, float hx1, const char* title, const char* help, const char* hint, const char* gold_line, float min_h, - bool after_restart) { + int after_restart) { // (the game's: 476 units of plate about a line 90 under the screen's middle; taller, about the same line, for a long text) const float s = c.s, hh = banner_h(c), bar_top = ui::prompt_bar_top(c), w = hx1 - hx0 - 2 * ui::lu(c, 72); const float th = help ? ui::para(c, c.f.body, kHelpPt * s, ImVec2(), 0, help, w, false) : 0, nh = hint ? 14 * s + ui::para(c, c.f.body, kHintPt * s, ImVec2(), 0, hint, w - 18 * s, false) : 0; - const float content = std::max(min_h, th + nh) + (title ? 34 * s : 0) + (after_restart ? 30 * s : 0) + (gold_line ? 46 * s : 0); + const float content = std::max(min_h, th + nh) + (title ? 34 * s : 0) + (after_restart ? 30 * s : 0) + + (gold_line ? 14 * s + 32 * s * gold_lines(gold_line) : 0); const float tall = std::max(ui::lu(c, 476), content + 2 * ui::lu(c, 56)), mid = ui::at(c, 0, -90).y; const float y0 = std::max(hh + 14 * s, mid - tall * 0.5f); // ((Triforce, 11-17) the plate's right end where the game's own ends on a window wider than 16:9 (measured at 3440 x 1440: @@ -4263,19 +4513,20 @@ void slider_cell(ui::Ctx& c, ImVec2 a, ImVec2 b, const char* value, int permille c.d->AddRectFilled(ImVec2(x0, y - h), ImVec2(x0 + (x1 - x0) * permille / 1000.0f, y + h), ui::kInk, h); *t0 = x0, *t1 = x1; } -/// "Restart needed: " and the pending rows, on one line of width: the last ones as "and N more" when they do not fit -std::string restart_line(ui::Ctx& c, float px, float width) { - const unsigned all = restart_pending(); +/// "Restart needed: " and the pending rows, on one line of width: the last ones as "and N more" when they do not fit. +/// ((Triforce, 11-26) The same for the rows Apply waits for, with "Apply needed: ": pending_line) +std::string pending_line(ui::Ctx& c, float px, float width, const mr::State& st, const char* const* row_names, unsigned all, + const char* head) { std::string line; - for (int keep = restart_state.n; keep >= 0; keep--) { // (the first `keep` pending rows by name) + for (int keep = st.n; keep >= 0; keep--) { // (the first `keep` pending rows by name) unsigned shown = 0; int named = 0, more = 0; - for (int i = 0; i < restart_state.n; i++) + for (int i = 0; i < st.n; i++) if ((all >> i) & 1) (named < keep ? (shown |= 1u << i, named++) : more++); // ((Triforce) in the menu's language: the rows' names and the pieces between them) const char* names[mr::kMax]; - for (int i = 0; i < restart_state.n; i++) names[i] = i18n::tr(restart_names[i]); - line = i18n::tr("Restart needed: ") + mr::names(names, restart_state.n, shown); + for (int i = 0; i < st.n; i++) names[i] = i18n::tr(row_names[i]); + line = i18n::tr(head) + mr::names(names, st.n, shown); if (more) { // (" settings (many)": the form Russian and Polish take for 5 and up, i18n::plural; never asked in English) const int form = i18n::plural(more); line += std::string(named ? i18n::tr(" and ") : "") + std::to_string(more) + @@ -4285,6 +4536,12 @@ std::string restart_line(ui::Ctx& c, float px, float width) { } return line; } +std::string restart_line(ui::Ctx& c, float px, float width) { + return pending_line(c, px, width, restart_state, restart_names, restart_pending(), "Restart needed: "); +} +std::string apply_line(ui::Ctx& c, float px, float width) { + return pending_line(c, px, width, apply_state, apply_names, apply_pending(), "Apply needed: "); +} /// (hookshot) The Debug tab's order: the tools' rows by their group (Row::cheat), Up and Down walking them so; Inventory item /// and Change quantity are not shown (the Inventory page edits every amount) @@ -4486,21 +4743,30 @@ void draw_tune_bar(ui::Ctx& c) { ui::box(c, a, b, 0.92f); const float px = ui::lu(c, 40 * ui::kType), ty = a.y + ui::lu(c, 46); ui::text_mid(c, c.f.heading, px, a.x + ui::lu(c, 40), ty, ui::kGoldHi, tab); - if (restart_changed(r)) + if (restart_changed(r) || apply_changed(r)) // ((Triforce, 11-26) or Apply's) ui::text_mid(c, c.f.body, ui::lu(c, 36 * ui::kType), a.x + ui::lu(c, 80) + ui::size_of(c.f.heading, px, tab).x, ty, ui::kGoldHi, - "Applies after a restart"); + restart_changed(r) ? "Applies after a restart" : "Takes effect after Apply"); // (the row: as in the list, its plate 2200 units wide here, its value's panel 804 x 108 at its right) const float rh = ui::lu(c, 124), y = a.y + ui::lu(c, 96), my = y + rh * 0.5f; const float rx0 = a.x + ui::lu(c, 40), rx1 = b.x - ui::lu(c, 40), vx = rx1 - ui::lu(c, 452); - name_cell(c, ImVec2(rx0, y), ImVec2(rx1, y + rh), r.name, true, restart_changed(r)); + name_cell(c, ImVec2(rx0, y), ImVec2(rx1, y + rh), r.name, true, row_pending(r)); const ImVec2 va(vx - ui::lu(c, 402), my - ui::lu(c, 54)), vb(vx + ui::lu(c, 402), my + ui::lu(c, 54)); float t0 = 0, t1 = 0; const float vm = r.heading ? 0 : row_value_cell(c, r, va, vb, true, &t0, &t1); hits.add(rx0, y, rx1, y + rh, menu_hit::kRow, sel, va.x, vb.x, t0, t1, 0, vm); - // (the guides, inside the bar's foot) - const ui::Prompt list[4] = {{ui::kUpDown, "Choose"}, {ui::kLeftRight, "Change"}, {ui::kKey, "Full menu", "RCtrl"}, {ui::kBack, "Close"}}; - const float pw = ui::prompts(c, 0, 0, list, 4, false); - ui::prompts(c, (a.x + b.x - pw) * 0.5f, b.y - ui::lu(c, 50), list, 4, true); + // (the guides, inside the bar's foot; ((Triforce, 11-26)) Apply first while a row waits for it: the bar is where a change + // is judged in play, so the change is taken there too) + ui::Prompt list[5] = {{ui::kUpDown, "Choose"}, {ui::kLeftRight, "Change"}, {ui::kKey, "Full menu", "RCtrl"}, {ui::kBack, "Close"}}; + int n = 4; + const bool to_apply = apply_pending() != 0; + if (to_apply) { + for (int i = n; i > 0; i--) list[i] = list[i - 1]; + list[0] = {ui::kApply, "Apply"}, n++; + } + const float pw = ui::prompts(c, 0, 0, list, n, false), gy = b.y - ui::lu(c, 50); + float spans[10]; + ui::prompts(c, (a.x + b.x - pw) * 0.5f, gy, list, n, true, spans); + if (to_apply) hits.add(spans[0] - ui::lu(c, 16), gy - ui::lu(c, 40), spans[1] + ui::lu(c, 16), gy + ui::lu(c, 40), menu_hit::kButton, kApplyGuide); } /// The Options screen: the header with the tabs across it (as the pause menu's categories: MenuOverlay_00, 460 units apart, @@ -4528,14 +4794,17 @@ void draw_options(ui::Ctx& c) { const int sel_cheat = mod_cheat_slot(selr.name); // (Triforce: a mod's cheat: the mod it is from, or why it cannot be switched) if (sel_cheat >= 0 && mod_cheats.line(sel_cheat)[0]) hint = mod_cheats.line(sel_cheat); const float cap_w = hx1 - hx0 - 2 * ui::lu(c, 76); - const std::string pending_line = restart_pending() ? restart_line(c, kHintPt * s, cap_w - 20 * s) : ""; + // ((Triforce, 11-26) the caption's foot: what waits for Apply, then what waits for a restart, a line each) + const bool to_apply = apply_pending() != 0; + std::string pending_line = to_apply ? apply_line(c, kHintPt * s, cap_w - 20 * s) : ""; + if (restart_pending()) pending_line += (to_apply ? "\n" : "") + restart_line(c, kHintPt * s, cap_w - 20 * s); static float help_tall = 0, help_tall_w = 0; static int help_tall_lang = -1; // ((Triforce) the menu's language it was measured in: another one's texts are longer or shorter) if (help_tall_w != cap_w || help_tall_lang != i18n::lang_now()) help_tall_w = cap_w, help_tall_lang = i18n::lang_now(), help_tall = measure_help(c, cap_w); // (the guides: what the buttons do on this row, as the game's own say only that) const bool confirms = false; // ((Triforce) 11-19: no Restart and Quit rows any more: the pause menu's Quit) - ui::Prompt prompt_list[5] = {{ui::kLeftRight, "Change"}, {ui::kTabs, "Category"}, {ui::kBack, "Back"}}; + ui::Prompt prompt_list[6] = {{ui::kLeftRight, "Change"}, {ui::kTabs, "Category"}, {ui::kBack, "Back"}}; int prompts_n = 3; if (!selr.value) prompt_list[0] = {ui::kConfirm, confirms ? (pending == &selr ? "Confirm" : selr.name) : "Open"}; if (share_row(selr)) prompt_list[0] = {ui::kConfirm, share_label(share_row(selr))}; @@ -4554,8 +4823,14 @@ void draw_options(ui::Ctx& c) { } // ((Triforce) over play, with the keys: Right Ctrl's tuning bar, draw_tune_bar) if (!embed_open && !c.pad && prompts_n < 5) prompt_list[prompts_n++] = {ui::kKey, "Tuning bar", "RCtrl"}; + // ((Triforce, 11-26) Apply, first of the guides while a row waits for it, on every tab (closing from any asks): as the + // game's own Options screen has its Default Settings on X among them) + if (to_apply) { + for (int i = prompts_n; i > 0; i--) prompt_list[i] = prompt_list[i - 1]; + prompt_list[0] = {ui::kApply, "Apply"}, prompts_n++; + } const float bar_top = ui::prompt_bar_top(c); // (the strip itself drawn last, over all: below) - const bool after = restart_changed(selr); + const int after = restart_changed(selr) ? kNoteRestart : apply_changed(selr) ? kNoteApply : 0; caption(c, hx0, hx1, nullptr, selr.help, hint, pending_line.empty() ? nullptr : pending_line.c_str(), help_tall, after); // (measured on the game's screen: a row's plate 1824 x 124, 170 apart, the first one's top 344 under the screen's top; the // value's near-black panel 804 x 108, its middle 500 right of the list's) @@ -4577,7 +4852,7 @@ void draw_options(ui::Ctx& c) { if (list[j] == sel) sel_at = j; int shown = 0; const float first = scroll_rows(cur_tab, listed, sel_at, top, bottom, pitch, &shown); - scroll_bar(c, ui::at(c, kListX - 1102, 0).x, ui::at(c, 0, 100).y, ui::at(c, 0, -212).y, listed, shown, first); // (PaScrollBar: 56 under the middle) + scroll_bar(c, ui::at(c, kListX - 1102, 0).x, ui::at(c, 0, 100).y, ui::at(c, 0, -212).y, listed, shown, first, cur_tab); // (PaScrollBar: 56 under the middle) marquee_max = 0; // (set again below while the selected row's value is too long) c.d->PushClipRect(ImVec2(cx0, clip0), ImVec2(cx1, clip1), true); for (int j = 0; j < listed; j++) { @@ -4592,7 +4867,7 @@ void draw_options(ui::Ctx& c) { continue; } const bool selected = i == sel; - name_cell(c, ImVec2(rx0, y), ImVec2(rx1, y + rh), r.name, selected, restart_changed(r)); + name_cell(c, ImVec2(rx0, y), ImVec2(rx1, y + rh), r.name, selected, row_pending(r)); const ImVec2 va(vx - vhw, my - vhh), vb(vx + vhw, my + vhh); float t0 = 0, t1 = 0; const float vm = row_value_cell(c, r, va, vb, selected, &t0, &t1); @@ -4603,7 +4878,12 @@ void draw_options(ui::Ctx& c) { const std::string ver = std::string("Triforce ") + HOOKSHOT_VERSION; ui::text_mid(c, c.f.body, ui::lu(c, 36), ui::at(c, -1840, 0).x, ui::at(c, 0, -1030).y, ui::rgba(255, 251, 238, 120), ver.c_str()); } - ui::prompt_bar(c, prompt_list, prompts_n); // (the guides, on top of the caption and the rows) + float spans[12]; + ui::prompt_bar(c, prompt_list, prompts_n, spans); // (the guides, on top of the caption and the rows) + if (to_apply) { // ((Triforce, 11-26) Apply's guide, a click on it as its key: menu_tick's page 0) + const float my = ui::at(c, 0, -1018).y, half = ui::lu(c, 56); + hits.add(spans[0] - ui::lu(c, 16), my - half, spans[1] + ui::lu(c, 16), my + half, menu_hit::kButton, kApplyGuide); + } } /// ((Triforce) per-control reset and confirmed rebinds) The Controls page's question (control_confirmation) over it, as the @@ -4703,7 +4983,7 @@ void draw_controls(ui::Ctx& c) { top += 24 * s; int shown = 0; const float first = scroll_rows(kControlsSlot, n, csel, top, bottom, pitch, &shown); - scroll_bar(c, cx0 + 20 * s, top, top + shown * pitch - (pitch - rh), n, shown, first); + scroll_bar(c, cx0 + 20 * s, top, top + shown * pitch - (pitch - rh), n, shown, first, kControlsSlot); c.d->PushClipRect(ImVec2(cx0, top - 8 * s), ImVec2(cx1, bottom + 8 * s)); for (int j = 0; j < n; j++) { const float y = top + (j - first) * pitch; @@ -4902,18 +5182,28 @@ void names_confirm(bool& changed) { /// (Triforce) the mouse on a name page: a card is chosen by a click, the action button acts, the group's and the page's /// arrows turn them, a flag's halves set and clear it; the wheel turns the page shown and leaves the choice; a right click /// goes back -void names_mouse(const MkwVkPointer& ptr, int mx, int my, bool* press, bool& changed) { +/// ((Triforce, 11-26) the name page shown turned to a page by its slider (its drawing keeps it to its pages) +void names_slider_to(int page) { names_page[names_kind].shown = page; } +void names_mouse(const MkwVkPointer& ptr, int mx, int my, bool moved, bool* press, bool& changed) { dn::Page& p = names_page[names_kind]; - const menu_hit::Hit hit = hits.at((float)mx, (float)my); + menu_hit::Hit hit = hits.at((float)mx, (float)my); + // ((Triforce, 11-26) its slider held: the pages follow the cursor, nothing else is the mouse's (bar_mouse). The card the + // mouse moves onto chosen, with the move's sound; a click on the chosen card is its action, as A (the owner: "improve the + // menu overall", as Save Select's cards) + const bool bar = bar_mouse(ptr, my, hit, changed); + if (bar) hit = menu_hit::Hit{}; + const bool on_card = hit.part == menu_hit::kListLine && hit.index >= 0; + if (on_card && moved && !(ptr.pressed & HOS_MOUSE_LEFT) && !names_edit && hit.index != p.choice && p.choose(hit.index)) changed = true; if (ptr.pressed & HOS_MOUSE_LEFT) { - if (hit.part == menu_hit::kListLine && p.choose(hit.index)) names_edit = false, changed = true; + if (on_card && hit.index == p.choice) press[7] = true; + else if (on_card && p.choose(hit.index)) names_edit = false, changed = true; else if (hit.part == menu_hit::kButton && hit.index == 0) press[7] = true; else if (hit.part == menu_hit::kButton && hit.index == 1 && hit.side) press[hit.side < 0 ? 3 : 4] = true; else if (hit.part == menu_hit::kButton && (hit.index == 2 || hit.index == 3)) press[hit.index == 2 ? 13 : 14] = true, names_edit = false; else if (hit.part == menu_hit::kButton && hit.index == 4 && hit.side) p.turn_group(hit.side), names_edit = false, changed = true; } if (ptr.pressed & HOS_MOUSE_RIGHT) press[5] = true; - if (ptr.wheel) p.turn_shown(-ptr.wheel), changed = true; + if (ptr.wheel && !bar) p.turn_shown(-ptr.wheel), changed = true; } /// (Triforce) the keys on a name page: back leaves a flag's On and Off first, then the page (to the Debug tab, its row still /// selected); L and R another group; the arrows, Page Up and Down, Home and End move the choice; confirm acts @@ -4965,6 +5255,46 @@ void names_tick() { } /// A small square page arrow at a (its size side): dir 0 back, 1 on; dim when it cannot go that way +/// ((Triforce, 11-26) The Debug tab's pages within the edges of the options' own rows (draw_options: 912 units either side of +/// the list's middle), their slider where the options' is. The owner, of the Inventory's sections and the pages' cards: +/// "fix the tabs positions so where they don't overlap the black behind": they ran from 72 units inside the column's edge, +/// over SystemBg_05's soft dark border, to past its other side +void page_edges(const ui::Ctx& c, float* left, float* right) { *left = ui::at(c, kListX - 912, 0).x, *right = ui::at(c, kListX + 912, 0).x; } +float page_slider_x(const ui::Ctx& c) { return ui::at(c, kListX - 1102, 0).x; } +/// ((Triforce, 11-26) a page's cursor from card to card as the game's settings move theirs (focus_anim.h: the card let go +/// fades its cursor out over UnSelect's 14 frames while the new one fades its in over Select's 8; none slides). The owner: +/// "improve the menu overall", as Save Select's cards (files_focus) +struct CardFocus { + int ids[2] = {-1, -1}; // (the chosen card, the one let go) + focus_anim::Focus f[2]; + void step(int chosen, int64_t now, bool settle) { + if (chosen != ids[0]) { + ids[1] = ids[0], f[1] = f[0]; + ids[0] = chosen, f[0] = focus_anim::Focus{}; + f[0].step(now, false, true); // (from nothing: it fades in) + } + f[0].step(now, true, settle), f[1].step(now, false, settle); + } + float of(int id) const { return id < 0 ? 0.0f : id == ids[0] ? f[0].shown : id == ids[1] ? f[1].shown : 0.0f; } +}; +CardFocus inventory_focus, teleport_focus, names_focus; +/// (the cursors of a page's cards, after them all: the chosen one's and the one fading out, each as much as it shows) +struct CardCursors { + ImVec2 a[2], b[2]; + bool have[2] = {false, false}; + void note(const CardFocus& f, int id, ImVec2 ca, ImVec2 cb) { + for (int k = 0; k < 2; k++) + if (id == f.ids[k]) a[k] = ca, b[k] = cb, have[k] = true; + } + void draw(ui::Ctx& c, const CardFocus& f) { + for (int k = 1; k >= 0; k--) + if (have[k]) ui::cursor(c, a[k], b[k], f.of(f.ids[k])); + } +}; +bool cards_settle() { + static const bool still = getenv("RX_VK_UI_STILL") != nullptr; // (pictures that compare: as it stands) + return !ease_live || still; +} void page_arrow(ui::Ctx& c, ImVec2 a, float side, int dir, bool can) { const float s = c.s; const ImVec2 b = a + ImVec2(side, side); @@ -5013,7 +5343,8 @@ void draw_inventory(ui::Ctx& c) { columns(c, &cx0, &cx1, &hx0, &hx1, &narrow); column(c, cx0, cx1, hh); const float bar = ui::prompt_bar_top(c); // (the strip itself drawn last, over all: below) - const float left = cx0 + 24 * s, right = cx1 - 24 * s; + float left, right; + page_edges(c, &left, &right); const float gap = 10 * s; // the sections, as tabs over the grid (Q and E, or a click) // (on one line: their padding, then their text, made smaller as far as needed for the column's width) @@ -5065,9 +5396,13 @@ void draw_inventory(ui::Ctx& c) { inventory_page = std::clamp(inventory_page, 0, pages_n - 1); const int first = begin + inventory_page * inventory_capacity; const float width = (right - left + gap) / inventory_columns; + // ((Triforce, 11-26) its slider, a page a step: held, or a click on its track, the pages follow the cursor (bar_mouse). + // The owner: "fix the page slider because it is just a still image, it doesn't work": the page drew none, and inside the + // game's own Options screen the game's slider of its own list showed through, still. Drawn over it with one page too) + scroll_bar(c, page_slider_x(c), top, grid_bottom, pages_n, 1, (float)inventory_page, kBarInventory); + inventory_focus.step(item_choice, prof_now(), cards_settle()); c.d->PushClipRect(ImVec2(left - 12 * s, top - 12 * s), ImVec2(right + 12 * s, grid_bottom + 12 * s)); - ImVec2 glow_a{}, glow_b{}; // ((Triforce, 11-18) the chosen one's cursor, drawn after every item: the next one's - bool glow_have = false; // plate covered part of it, which read as the highlight clipped) + CardCursors cursors; // ((Triforce, 11-18) the cursors drawn after every item: the next one's plate covered part of it) for (int i = first; i < std::min(end, first + inventory_capacity); ++i) { const int cell = i - first; const ImVec2 a(left + (cell % inventory_columns) * width, top + (cell / inventory_columns) * pitch); @@ -5076,7 +5411,8 @@ void draw_inventory(ui::Ctx& c) { const bool selected = i == item_choice, owned = count > 0, editing = selected && inventory_amount; ui::plate(c, a, b, owned); c.d->PushClipRect(a + ImVec2(8 * s, 0), b - ImVec2(8 * s, 0), true); - ui::text_mid(c, c.f.strong, 15.5f * s, a.x + 13 * s, loaded ? a.y + 17 * s : (a.y + b.y) * 0.5f, count < 0 ? ui::kDim : ui::kInkBright, item_names[i]); + // ((Triforce, 11-26) an item not read yet (no save loaded) in kSoft: kDim on the plate could hardly be read) + ui::text_mid(c, c.f.strong, 15.5f * s, a.x + 13 * s, loaded ? a.y + 17 * s : (a.y + b.y) * 0.5f, count < 0 ? ui::kSoft : ui::kInkBright, item_names[i]); char amount[40]; if (count < 0) snprintf(amount, sizeof amount, "%s", loaded ? "Unavailable" : ""); else if (item_kinds[i]) snprintf(amount, sizeof amount, "Quantity %d", count); @@ -5090,10 +5426,10 @@ void draw_inventory(ui::Ctx& c) { ui::text_mid(c, c.f.body, 15 * s, a.x + 13 * s, ly, owned ? ui::kAccent : kCardOff, amount); } c.d->PopClipRect(); - if (selected) glow_a = a, glow_b = b, glow_have = true; + cursors.note(inventory_focus, i, a, b); if (a.y < grid_bottom) hits.add(a.x, a.y, b.x, std::min(b.y, grid_bottom), menu_hit::kListLine, i); } - if (glow_have) ui::glow(c, glow_a, glow_b); + cursors.draw(c, inventory_focus); c.d->PopClipRect(); if (detail >= top) { // (the page: its arrows, Page n of m and the range; the selected item's action at the right) c.d->AddLine(ImVec2(left, detail), ImVec2(right, detail), ui::alpha(ui::kEdge, 0.8f)); @@ -5144,7 +5480,9 @@ void draw_teleport(ui::Ctx& c) { const ui::Prompt prompts[] = {{ui::kUpDown, "Move"}, {ui::kLeftRight, "Move"}, {ui::kTabs, "Section"}, {ui::kConfirm, "Travel"}, {ui::kBack, "Back"}}; const float bar = ui::prompt_bar_top(c); // (the strip itself drawn last, over all: below) - const float left = cx0 + 24 * s, right = cx1 - 24 * s, top = hh + 16 * s; + float left, right; + page_edges(c, &left, &right); + const float top = hh + 16 * s; const float strip = 58 * s, detail = bar - 14 * s - strip; const float bottom = std::max(top, detail - 6 * s), gap = 10 * s, pitch = 48 * s, head = 40 * s; const char* const note = teleport_notes[teleport_choice]; @@ -5192,7 +5530,9 @@ void draw_teleport(ui::Ctx& c) { } at += (want - at) * ease_step; if (std::fabs(want - at) < 0.5f) at = want; - if (total > view) scroll_bar(c, cx0 + 12 * s, top, bottom, (int)total, (int)view, at); + // ((Triforce, 11-26) at the options' slider's place, and drawn over the game's own however few the cards) + scroll_bar(c, page_slider_x(c), top, bottom, (int)std::max(total, view), (int)view, at, kBarTeleport); + teleport_focus.step(teleport_choice, prof_now(), cards_settle()); c.d->PushClipRect(ImVec2(left - 12 * s, top), ImVec2(right + 12 * s, bottom), true); for (int k = 0; k < kTeleportSections; ++k) { const float hy = top + section_y[k] - at + head * 0.5f; @@ -5206,8 +5546,7 @@ void draw_teleport(ui::Ctx& c) { c.d->AddLine(ImVec2(left + tw + 14 * s, hy + s), ImVec2(right - nw - 12 * s, hy + s), ui::alpha(ui::kAccent, 0.45f), std::max(1.0f, s)); } - ImVec2 glow_a{}, glow_b{}; // ((Triforce, 11-18) the chosen one's cursor, drawn after every item: the next one's - bool glow_have = false; // plate covered part of it, which read as the highlight clipped) + CardCursors cursors; // ((Triforce, 11-18) the cursors drawn after every item: the next one's plate covered part of it) for (int i = 0; i < kTeleports; ++i) { const int k = teleport_section_of(i), cell = i - teleport_sections[k].first; const ImVec2 a(left + cell % cols * width, top + card_y(i) - at); @@ -5220,10 +5559,10 @@ void draw_teleport(ui::Ctx& c) { c.d->PushClipRect(a, ImVec2(name_end, b.y), true); ui::text_mid(c, c.f.body, 17 * s, a.x + 16 * s, (a.y + b.y) * 0.5f, ui::kInk, teleport_names[i]); c.d->PopClipRect(); - if (selected) glow_a = a, glow_b = b, glow_have = true; + cursors.note(teleport_focus, i, a, b); hits.add(a.x, std::max(a.y, top), b.x, std::min(b.y, bottom), menu_hit::kListLine, i); } - if (glow_have) ui::glow(c, glow_a, glow_b); + cursors.draw(c, teleport_focus); c.d->PopClipRect(); if (detail >= top) { // (the selection, its section and note, and Travel: what Enter does) c.d->AddLine(ImVec2(left, detail), ImVec2(right, detail), ui::alpha(ui::kEdge, 0.8f)); @@ -5258,11 +5597,15 @@ void draw_names(ui::Ctx& c) { columns(c, &cx0, &cx1, &hx0, &hx1, &narrow); column(c, cx0, cx1, hh); const float bar = ui::prompt_bar_top(c); // (the strip itself drawn last, over all: below) - const float left = cx0 + 24 * s, right = cx1 - 24 * s, gap = 10 * s; + float left, right; + page_edges(c, &left, &right); + const float gap = 10 * s; const float y = hh + 18 * s, top = y + 50 * s, pitch = (flags ? 62 : 46) * s; // (a flag's card: its state under its name) const float strip = 58 * s, detail = bar - 14 * s - strip, grid_bottom = std::max(top, detail - 8 * s); - // (as many columns as fit, at most 3: the names are long; whole pages of cards, never more than a W line's flags) - p.columns = std::clamp((int)((right - left + gap) / (340 * s + gap)), 1, 3); + // (as many columns as fit, at most 3: the names are long; whole pages of cards, never more than a W line's flags. + // ((Triforce, 11-26) 290 points a card, not 340: within the options' rows' edges (page_edges) two still fit at 16:9, as + // they did across the column; a long name is cut in its middle, as before) + p.columns = std::clamp((int)((right - left + gap) / (290 * s + gap)), 1, 3); p.capacity = std::min(p.columns * std::max(1, (int)((grid_bottom - top + gap) / pitch)), (int)OOT_WATCH_MAX); p.shown = std::clamp(p.shown, 0, p.pages() - 1); // (what the game's side last said, while the chosen name is the one it said it of: under another name it would read as @@ -5288,6 +5631,7 @@ void draw_names(ui::Ctx& c) { ui::diamond(c, ImVec2(left + 5 * s, hh + 34 * s), 4 * s, ui::kGoldHi); ui::para(c, c.f.body, 16 * s, ImVec2(left + 18 * s, hh + 24 * s), ui::kSoft, note, right - left - 18 * s); caption(c, hx0, hx1, titles[names_kind], names_help(names_kind), nullptr, nullptr); + scroll_bar(c, page_slider_x(c), top, grid_bottom, 1, 1, 0.0f, kBarNames); // ((Triforce, 11-26) over the game's own slider, still) const ui::Prompt back[] = {{ui::kBack, "Back"}}; ui::prompt_bar(c, back, 1); return; @@ -5331,9 +5675,11 @@ void draw_names(ui::Ctx& c) { } const int first = p.first(), last = p.last(); const float width = (right - left + gap) / p.columns; + // ((Triforce, 11-26) its slider, a page a step, as the Inventory's) + scroll_bar(c, page_slider_x(c), top, grid_bottom, p.pages(), 1, (float)std::clamp(p.shown, 0, p.pages() - 1), kBarNames); + names_focus.step(names_kind * 1000000 + p.choice, prof_now(), cards_settle()); c.d->PushClipRect(ImVec2(left - 12 * s, top - 12 * s), ImVec2(right + 12 * s, grid_bottom + 12 * s)); - ImVec2 glow_a{}, glow_b{}; // ((Triforce, 11-18) the chosen one's cursor, drawn after every item: the next one's - bool glow_have = false; // plate covered part of it, which read as the highlight clipped) + CardCursors cursors; // ((Triforce, 11-18) the cursors drawn after every item: the next one's plate covered part of it) for (int i = first; i < last; ++i) { const int cell = i - first; const ImVec2 a(left + (cell % p.columns) * width, top + (cell / p.columns) * pitch); @@ -5359,10 +5705,10 @@ void draw_names(ui::Ctx& c) { ui::text_mid(c, c.f.body, 15 * s, a.x + 13 * s, a.y + 37 * s, st == '1' ? ui::kAccent : st == '0' ? ui::kSoft : kCardOff, st == '1' ? "Set" : st == '0' ? "Not set" : st == '-' ? "Not in this save" : "Not known"); c.d->PopClipRect(); - if (selected) glow_a = a, glow_b = b, glow_have = true; + cursors.note(names_focus, names_kind * 1000000 + i, a, b); if (a.y < grid_bottom) hits.add(a.x, a.y, b.x, std::min(b.y, grid_bottom), menu_hit::kListLine, i); } - if (glow_have) ui::glow(c, glow_a, glow_b); + cursors.draw(c, names_focus); c.d->PopClipRect(); if (detail >= top) { // (the page: its arrows, Page n of m and the range; the chosen name's action at the right) c.d->AddLine(ImVec2(left, detail), ImVec2(right, detail), ui::alpha(ui::kEdge, 0.8f)); @@ -5769,7 +6115,7 @@ void draw_mods(ui::Ctx& c) { } at += (want - at) * ease_step; if (std::fabs(want - at) < 0.5f) at = want; - if (total_h > view) scroll_bar(c, cx0 + 12 * s, list_top, bottom, (int)total_h, (int)view, at); + if (total_h > view) scroll_bar(c, cx0 + 12 * s, list_top, bottom, (int)total_h, (int)view, at, kBarMods); c.d->PushClipRect(ImVec2(left - 14 * s, list_top), ImVec2(right + 14 * s, bottom), true); std::vector ask_thumbs; // (asked for once the list is let go: the engine's calls lock it themselves) int ask_details = -1; @@ -5936,7 +6282,7 @@ void draw_mods(ui::Ctx& c) { c.d->PushClipRect(ImVec2(x0, dtop), ImVec2(x1, dbot), true); ui::para(c, c.f.body, kModsDescPt * s, ImVec2(x0 + pad, dtop - mods_desc_px), ui::kInk, text, w); c.d->PopClipRect(); - if (most > 0) scroll_bar(c, x1 - pad * 0.45f, dtop, dbot, (int)th, (int)room, mods_desc_px); + if (most > 0) scroll_bar(c, x1 - pad * 0.45f, dtop, dbot, (int)th, (int)room, mods_desc_px, kBarModsDesc); mods_desc_x0 = x0; } c.d->PopClipRect(); @@ -6134,9 +6480,10 @@ constexpr ImU32 kTitleInkSel = ui::rgba(255, 255, 255); // (T_Btn_02's: white) constexpr ImU32 kTitleDecoInk = ui::rgba(131, 115, 22); // (P_Deco_*_00's: colour 4, linear 0.227 0.173 0.008) constexpr ImU32 kTitleGlow = ui::rgba(120, 140, 255); mods_entry::Anim title_anim; -// ((Triforce) Save Select under it is the same part with its own label and animation: draw_title_files sets these for its call) -const char* title_label = "Mods"; -int title_entry = 0; // (0 Mods, 1 Save Select: its hit, and Mods' Decide and place are Mods' alone) +// ((Triforce) a tab at the top left is the same part with its own label and animation: draw_title_tabs sets these for its call) +const char* title_label = "Quit Game"; // ((Triforce) the list's entry; a tab's own while draw_title_tabs draws it) +int title_entry = 0; // (0 the list's entry, 1 a tab: its hit, its Decide and its place are the entry's alone) +bool title_corner = false; // (a tab at the top left: the words alone, lit while chosen; no band and no filigree) void draw_title_mods(ui::Ctx& c, bool sel, float cx, float cy, float k, float pitch) { const int64_t now = prof_now(), age = mods_list_age(); title_anim.step(now, sel, std::min(age, mods_entry::kListShownNs), mods_list_shown()); @@ -6145,8 +6492,8 @@ void draw_title_mods(ui::Ctx& c, bool sel, float cx, float cy, float k, float pi const char* const label = title_label; const float px = ui::lu(c, kTitleText * ui::kType * k), tw = ui::size_of(c.f.body, px, label).x; const float deco_x = tw * 0.5f + ui::lu(c, kTitleDecoGap * k); - const mods_entry::Decide d = mods_entry::decide_at(mods_decide_ns && !title_entry ? now - mods_decide_ns : -1); - if (f > 0 && show > 0) { + const mods_entry::Decide d = mods_entry::decide_at(mods_decide_ns && !title_entry && title_decide == 1 ? now - mods_decide_ns : -1); + if (f > 0 && show > 0 && !title_corner) { const float hw = deco_x + ui::lu(c, kTitleBandPast * k), hh = ui::lu(c, kTitleBandH * 0.5f * k); const ImVec2 a(m.x - hw, m.y - hh), b(m.x + hw, m.y + hh); if (const ui::Art* band = ui::art("title_band")) { @@ -6215,6 +6562,7 @@ void draw_title_mods(ui::Ctx& c, bool sel, float cx, float cy, float k, float pi const ImU32 ink_sel = ui::alpha(kTitleInkSel, text_spread::weight_alpha(f * show)); for (int i = 0; i < text_spread::kTextWeight; i++) c.d->AddText(c.f.body, px, at, ink_sel, label); } + if (title_corner) return; // (a tab: its hit is the tabs' own, title_tabs.h) // (the entry's hit: across the line as the host takes the game's (host/oot_menu.c list_boxes: 1100 wide), a pitch high) const float hw = ui::lu(c, 550 * k), hh = ui::lu(c, pitch * 0.5f); hits.add(m.x - hw, m.y - hh, m.x + hw, m.y + hh, menu_hit::kButton, title_entry); @@ -6222,14 +6570,55 @@ void draw_title_mods(ui::Ctx& c, bool sel, float cx, float cy, float k, float pi mods_entry_px[0] = m.x - hw, mods_entry_px[1] = m.y - hh, mods_entry_px[2] = m.x + hw, mods_entry_px[3] = m.y + hh; mods_entry_px[4] = ui::lu(c, pitch); } -/// (Triforce) Save Select on the title's list: the same entry a pitch under Mods, with its own animation -mods_entry::Anim files_title_anim; -void draw_title_files(ui::Ctx& c, bool sel, float cx, float cy, float k, float pitch) { - std::swap(title_anim, files_title_anim); - title_label = "Save Select", title_entry = 1; - draw_title_mods(c, sel, cx, cy, k, pitch); - title_label = "Mods", title_entry = 0; - std::swap(title_anim, files_title_anim); +/// ((Triforce) The title's tabs, Mods and Save Select at the picture's top left (title_tabs.h): each the title's own entry's +/// words (draw_title_mods, the same font and size, cream with the dark edge; lit as a chosen entry's words are while the mouse +/// is over it or its Decide plays), and under it, with a controller, the icon of the button that opens it: the game's own of +/// what the Switch's X (Mods) and Y (Save Select) are bound to, as its guides show a binding. c: the grid's column, as the +/// entry's; decide: Mods' Decide plays (its tab lit until its screen comes)) +bool game_prompts_pad(); // (below: the prompts are a controller's) +game_grid::Place title_grid; // (the grid the title's entry is drawn on now: draw_mods_row's callers say) +void draw_title_tabs(ui::Ctx& c, bool decide) { + static const char* const labels[title_tabs::kTabs] = {"Mods", "Save Select"}; + static const char* const icons[title_tabs::kTabs] = {ui::kIconX, ui::kIconY}; + static const char* const names[title_tabs::kTabs] = {"X", "Y"}; // (no icon font: the Switch's names, as the guides' A and B) + const game_grid::Map m = game_grid::map_of(title_grid); + const int n = files_tab_shown() ? 2 : 1; + const bool pad = game_prompts_pad(); + const float unit = ui::lu(c, 1), px = ui::lu(c, kTitleText * ui::kType), ipx = ui::lu(c, title_tabs::kIcon); + float lw[title_tabs::kTabs] = {}, iw[title_tabs::kTabs] = {}; + for (int i = 0; i < n; i++) { + lw[i] = ui::size_of(c.f.body, px, labels[i]).x; + iw[i] = !pad ? 0.0f : c.f.glyph ? ui::size_of(c.f.glyph, ipx, icons[i]).x : ui::lu(c, 62); + } + const title_tabs::Layout l = title_tabs::place(title_tabs::picture_left(title_grid, m), title_tabs::picture_top(title_grid, m), unit, lw, iw, n, pad); + // (drawn inside the whole picture: its corner may be left of the column, where the window's clip rectangle left out + // every glyph (title_tabs.h picture_clip); put on the window with the drawing (put_on_grid moves this rectangle too)) + float clip[4]; + title_tabs::picture_clip(title_grid, m, &clip[0], &clip[1], &clip[2], &clip[3]); + c.d->PushClipRect(ImVec2(clip[0], clip[1]), ImVec2(clip[2], clip[3]), false); + for (int i = 0; i < n; i++) { + const title_tabs::Tab& t = l.tab[i]; + const bool sel = decide ? i == 0 : !mods_decide_ns && title_tab_hover == i; + std::swap(title_anim, title_tab_anim[i]); + title_label = labels[i], title_entry = 1, title_corner = true; + draw_title_mods(c, sel, (t.label_x - c.w * 0.5f) / unit, (c.h * 0.5f - t.label_y) / unit, 1.0f, 0.0f); + const float show = title_anim.shown; + title_label = "Quit Game", title_entry = 0, title_corner = false; + std::swap(title_anim, title_tab_anim[i]); + if (!pad || show <= 0) continue; + if (c.f.glyph) { // (the icon, a dark copy a little under it: the title's sky is bright behind it) + const ImVec2 sz = ui::size_of(c.f.glyph, ipx, icons[i]); + const ImVec2 at(std::floor(t.icon_x - sz.x * 0.5f), std::floor(t.icon_y - sz.y * 0.5f)); + c.d->AddText(c.f.glyph, ipx, ImVec2(at.x, at.y + ui::lu(c, 3)), ui::rgba(0, 0, 0, (int)(140 * show)), icons[i]); + c.d->AddText(c.f.glyph, ipx, at, ui::alpha(ui::kInk, show), icons[i]); + } else { + const ui::Prompt p{ui::kKey, "", names[i]}; + const float w = ui::glyph(c, t.icon_y, 0, p, false); + ui::glyph(c, t.icon_y, t.icon_x - w * 0.5f, p, true); + } + } + c.d->PopClipRect(); + title_tab_layout = l, title_tab_map = m, title_tab_ns = prof_now(); } /// (Triforce) The Mods entry, under the game list's last button by the list's own pitch (host/oot_menu.c): on the pause menu's @@ -6264,9 +6653,11 @@ void draw_mods_row(ui::Ctx& c, bool sel) { } // (the list's scale: the part's 60-unit hit box as the host finds it; one not told, the part's own size) const float k = x1 - x0 > 6 && x1 - x0 < 600 ? (x1 - x0) / 60.0f : 1.0f; - // ((Triforce) Save Select under it while the save files are on: the cursor is on one of the two) - if (files_row_shown()) draw_title_files(c, sel && mods_row_sel == 1, cx, cy - pitch, k, pitch), sel = sel && mods_row_sel == 0; - draw_title_mods(c, sel, cx, cy, k, pitch); + // ((Triforce) Quit Game there; Mods and Save Select are the tabs at the top left. While Mods' Decide plays the page is + // this one with its tab lit, not the entry) + const bool tab_decides = sel && mods_decide_ns && title_decide == 0; + draw_title_mods(c, sel && !tab_decides, cx, cy, k, pitch); + draw_title_tabs(c, tab_decides); } /// (the entry while the menu is shut: on the game's grid, where its list is (game_grid.h). (Triforce, 11-19) It was on a 16:9 @@ -6275,6 +6666,7 @@ void draw_mods_row(ui::Ctx& c, bool sel) { void draw_mods_row_shut(ui::Ctx& c) { const game_grid::Place g = menu_grid(c.w, c.h); ui::Ctx k = grid_ctx(c, g); + title_grid = g; const int vtx0 = c.d->VtxBuffer.Size, cmd0 = c.d->CmdBuffer.Size; const ImVec4 window_clip = clip_now(c.d); const menu_hit::Map saved = hits; // (its hit is not the menu's: the host takes clicks on it while the menu is shut) @@ -6580,43 +6972,109 @@ void files_open(bool at_title) { files_choice = std::max(0, save_files.current()); files_pictures_load(); } -/// (Triforce) The file select (kFilesPage): a card for each file the host named, its number, its name and when it was last -/// saved; the one this run plays is marked. The caption says what choosing the chosen one does +/// (Triforce) The file select (kFilesPage): a card for each file the host named, its save's picture, when it was saved, +/// where, the hearts and the stones and medallions held, its name on the tag; the one this run plays is marked +/// ((Triforce, 11-25) The owner, of it at 21:9: "It is very broken and it's only optimized for 16:9. I want you to optimize +/// it for ultra-wide as well. I want you to improve the design, fix up the UI, use the in-game assets, fix the out-of-place +/// buttons and overlapping prompts." It was the options' layout: the list at the left of the 16:9 grid, a caption box at its +/// right over the title (and over the performance overlay on a wide screen), a Play button of its own under the list. Now +/// it is the game's own Load list, as the lab's capture of it (3440 x 1440) measures: one column in the middle of the grid, +/// the cards in it, the game's textures (vk_game_tex.h make_file_skin), its cursor; what choosing a file does one line under +/// the cards; the prompts alone at the bottom right. A click chooses a card, a click on the chosen one plays it) +// (the game's Load list in layout units: the column's opaque middle 2472 wide about the screen's (SystemBg_05's soft edges +// outside it: 2652 in all), the cards 2163 x 369 at 435 apart, the first one's top 124 under the header. A texel of the +// cards' textures is 1.5 units: what follows in texels is the card picture's, make_file_card's, whose visible card begins +// 12 texels in and 18 down) +constexpr float kFilesColumnHalf = 1326, kFilesCardTop = 756, kFilesPitch = 435, kFilesCardLeft = -1081.5f; +constexpr float kFileCardW = 1442, kFileCardH = 246, kFileCardInX = 12, kFileCardInY = 18; // (texels) +/// The file select's column, x0 to x1 (draw_menu draws it under the header) +void files_columns(const ui::Ctx& c, float* x0, float* x1) { *x0 = ui::at(c, -kFilesColumnHalf, 0).x, *x1 = ui::at(c, kFilesColumnHalf, 0).x; } +/// A convex polygon of the texture `t`: its corners p (pixels) and uv +void textured_poly(ui::Ctx& c, ImTextureRef t, const ImVec2* p, const ImVec2* uv, int n, ImU32 col = IM_COL32_WHITE) { + c.d->PushTexture(t); + c.d->PrimReserve((n - 2) * 3, n); + const ImDrawIdx base = (ImDrawIdx)c.d->_VtxCurrentIdx; + for (int i = 0; i < n; i++) c.d->PrimWriteVtx(p[i], uv[i], col); + for (int i = 1; i + 1 < n; i++) c.d->PrimWriteIdx(base), c.d->PrimWriteIdx((ImDrawIdx)(base + i)), c.d->PrimWriteIdx((ImDrawIdx)(base + i + 1)); + c.d->PopTexture(); +} +/// The stones and medallions held, on the game's plate (DataFileImportantStateBase: _01 the six medallions round the three +/// stones, _00 the stones alone), its middle m, tx pixels a texel; none held: no plate, as the game's early saves have none +void files_plate(ui::Ctx& c, int items, ImVec2 m, float tx) { + namespace ar = achievement_rows; + const int stones = items & 7, medals = items >> save_file_rows::kStones & 63; + if (!stones && !medals) return; + // (the sockets in the plates' 216 texels, found in their pictures: the medallions round from the top, light, forest, + // fire, water, spirit, shadow; then the stones, forest, fire, water) + static const float k01[9][2] = {{64.9f, 107.5f}, {107.5f, 107.5f}, {150.2f, 107.5f}, {107.5f, 33.4f}, {185.6f, 73.0f}, + {185.6f, 142.6f}, {107.5f, 182.3f}, {29.4f, 142.6f}, {29.4f, 73.0f}}; + static const float k00[3][2] = {{54.4f, 107.9f}, {107.1f, 107.9f}, {159.9f, 107.9f}}; + static const int medal_tones[save_file_rows::kMedals] = {ar::kYellow, ar::kGreen, ar::kRed, ar::kBlue, ar::kOrange, ar::kPurple}; + static const int stone_tones[save_file_rows::kStones] = {ar::kGreen, ar::kRed, ar::kBlue}; + const ui::Art* plate = ui::art(medals ? "DataFileImportantStateBase_DataDileImportantStateBase_01" : "DataFileImportantStateBase_DataDileImportantStateBase_00"); + const float k = tx * 0.92f, half = 108 * k; + if (plate) ui::image(c, plate, m - ImVec2(half, half), m + ImVec2(half, half), ui::rgba(214, 180, 108)); + else c.d->AddNgonFilled(m, half * 0.9f, ui::rgba(74, 56, 30, 240), 6), c.d->AddNgon(m, half * 0.9f, ui::alpha(ui::kEdge, 0.9f), 6, std::max(1.0f, k * 2)); + for (int bit = 0; bit < save_file_rows::kStones + save_file_rows::kMedals; bit++) { + if (!(items >> bit & 1) || (!medals && bit >= save_file_rows::kStones)) continue; + const float* at = medals ? k01[bit] : k00[bit]; + const float r = (medals ? (bit < save_file_rows::kStones ? 17.0f : 18.9f) : 19.7f) * k; + const ImVec2 p = m + ImVec2((at[0] - 108) * k, (at[1] - 108) * k); + char name[32]; + snprintf(name, sizeof name, "DataFileImportantIcon_%02d", bit); // (the stones, then light to shadow: 11-18's order) + if (const ui::Art* t = ui::art(name); t && !t->mask) { + const float hw = r * 1.45f, hh = hw * t->h / t->w; + ui::image(c, t, ImVec2(p.x - hw, p.y - hh), ImVec2(p.x + hw, p.y + hh)); + } else if (bit < save_file_rows::kStones) ach_icon(c, p, r, ar::kGem | stone_tones[bit] << 4, true); + else ach_icon(c, p, r, ar::kMedal | medal_tones[bit - save_file_rows::kStones] << 4, true); + } +} +/// A heart of a card's, its middle at (mx, hy), slot_w a heart's room: the game's heart frame over its red-orange fill +void files_heart(ui::Ctx& c, float mx, float hy, float slot_w) { + // ((Triforce) 11-18, the owner's pictures: the hearts were small and grey, then dark inside the game's frame. HeartBase_00 is the + // heart's dark ground, not its red: the fill is drawn here, the load list's red-orange with a lighter upper half, inside + // the game's own frame, drawn twice the slot's width as its layout does) + const float fw = slot_w * 0.80f, fy = hy - fw * 0.02f; + const ImU32 fill = ui::rgba(238, 92, 48), lit = ui::rgba(250, 128, 70); + c.d->AddCircleFilled(ImVec2(mx - fw * 0.24f, fy - fw * 0.13f), fw * 0.27f, fill, 20); + c.d->AddCircleFilled(ImVec2(mx + fw * 0.24f, fy - fw * 0.13f), fw * 0.27f, fill, 20); + c.d->AddTriangleFilled(ImVec2(mx - fw * 0.49f, fy - fw * 0.02f), ImVec2(mx + fw * 0.49f, fy - fw * 0.02f), ImVec2(mx, fy + fw * 0.50f), fill); + c.d->AddCircleFilled(ImVec2(mx - fw * 0.24f, fy - fw * 0.17f), fw * 0.15f, lit, 16); + c.d->AddCircleFilled(ImVec2(mx + fw * 0.24f, fy - fw * 0.17f), fw * 0.15f, lit, 16); + if (const ui::Art* frame = ui::art("HeartFrame_00")) { + const float hw = slot_w * 2.1f, hh = hw * frame->h / frame->w; + ui::image(c, frame, ImVec2(mx - hw * 0.5f, hy - hh * 0.5f), ImVec2(mx + hw * 0.5f, hy + hh * 0.5f), ui::rgba(255, 150, 96)); + } else { + c.d->AddCircle(ImVec2(mx - fw * 0.24f, fy - fw * 0.13f), fw * 0.29f, ui::rgba(140, 34, 22), 20, std::max(1.0f, fw * 0.06f)); + c.d->AddCircle(ImVec2(mx + fw * 0.24f, fy - fw * 0.13f), fw * 0.29f, ui::rgba(140, 34, 22), 20, std::max(1.0f, fw * 0.06f)); + } +} void draw_files(ui::Ctx& c) { - const float s = c.s; const int n = save_files.shown(), cur = save_files.current(); files_choice = std::clamp(files_choice, 0, std::max(0, n - 1)); const bool here = files_choice == cur, waiting = files_wait >= 0; - const float hh = title_banner(c, "Select a file", nullptr); + title_banner(c, "Save Select", nullptr); const char* act = here ? "Play" : "Switch file"; const ui::Prompt prompts[] = {{ui::kUpDown, "Move"}, {ui::kConfirm, act}, {ui::kBack, "Back"}}; - float cx0, cx1, hx0, hx1; - bool narrow; - columns(c, &cx0, &cx1, &hx0, &hx1, &narrow); - column(c, cx0, cx1, hh); - const float bar = ui::prompt_bar_top(c); - const float left = cx0 + 24 * s, right = cx1 - 24 * s, top = hh + 22 * s, pitch = 124 * s; - if (n > 0) { - const bool saved = save_files.saved(files_choice); - char when[64] = "No save in it yet."; - const char* const made = file_pictures[files_choice].when[0] ? file_pictures[files_choice].when : save_files.whens[files_choice]; - if (saved && made[0]) snprintf(when, sizeof when, "Last saved %s", made); - else if (saved) snprintf(when, sizeof when, "Has a save."); - const char* help = here ? "The file the game is playing now. Its saves and autosaves are its own." : - saved ? "Another file, with its own saves and autosaves. The game starts again to play it: what is not saved in " - "the file you are playing now is lost." : - "An empty file: a new game of its own. The game starts again to play it."; - caption(c, hx0, hx1, save_files.names[files_choice], help, when, - waiting ? "Starting the game on this file..." : files_failed ? "The choice could not be kept: nothing changed." : nullptr); - } + const float tx = ui::lu(c, 1.5f); // (a texel of the cards' textures, in pixels) + const ui::Art* card = ui::art("file_card"); + const ui::Art* tag = ui::art("file_tag"); + const ui::Art *cursor_line = ui::art("file_cursor_line"), *cursor_glow = ui::art("file_cursor_glow"); + static const bool still = getenv("RX_VK_UI_STILL") != nullptr; // (pictures that compare: as it stands) + const int64_t now = prof_now(); + const bool settle = !ease_live || still || now - files_screen.since_ns < mods_page::kInNs; + float bottom = ui::at(c, 0, kFilesCardTop).y; for (int i = 0; i < n; ++i) { - const ImVec2 a(left, top + i * pitch), b(right, a.y + pitch - 12 * s); + // (the card's visible edges, a..b; its picture's from o, kFileCardInX and kFileCardInY texels up and left of a) + const ImVec2 a = ui::at(c, kFilesCardLeft, kFilesCardTop - i * kFilesPitch), b = a + ImVec2(kFileCardW * tx, kFileCardH * tx); + const ImVec2 o = a - ImVec2(kFileCardInX * tx, kFileCardInY * tx); + const auto P = [&](float x, float y) { return o + ImVec2(x * tx, y * tx); }; // (a place on the card, in its texels) + bottom = b.y; const bool saved = save_files.saved(i); - ui::plate(c, a, b, i == cur); - const float my = (a.y + b.y) * 0.5f; - // (its save's picture at the left, 16:9; a file without one: a dark plate that says so) - const float ph = b.y - a.y - 20 * s, pw = ph * 16.0f / 9.0f; - const ImVec2 pa(a.x + 12 * s, a.y + 10 * s), pb(pa.x + pw, pa.y + ph); + if (card) ui::image(c, card, o, o + ImVec2(card->w * tx, card->h * tx)); + else ui::plate(c, a, b, i == cur); + // (its save's picture at the left, in the frame, the frame's corner cut from it as the game's thumbnail mask cuts it; + // a file without one: the same place dark, and what it is) FilePicture& pic = file_pictures[i]; if (pic.state == 1) { // (its texture, at the first drawing) pic.texture = IM_NEW(ImTextureData)(); @@ -6627,116 +7085,83 @@ void draw_files(ui::Ctx& c) { pic.rgba.clear(), pic.rgba.shrink_to_fit(); pic.state = 2; } - c.d->AddRectFilled(pa, pb, ui::rgba(18, 13, 8, 255)); + const ImVec2 pa = P(16, 24), pb = P(440, 261); + const float cut = 28 * tx; + const ImVec2 poly[6] = {ImVec2(pa.x + cut, pa.y), ImVec2(pb.x, pa.y), pb, ImVec2(pa.x + cut, pb.y), ImVec2(pa.x, pb.y - cut), ImVec2(pa.x, pa.y + cut)}; if (pic.state == 2 && pic.texture) { - const float iw = (float)pic.w, ih = (float)pic.h; + const float pw = pb.x - pa.x, ph = pb.y - pa.y, iw = (float)pic.w, ih = (float)pic.h; ImVec2 uv0(0, 0), uv1(1, 1); if (iw / ih > pw / ph) { const float k = (ph / pw) * iw / ih; uv0.x = (1 - 1 / k) * 0.5f, uv1.x = 1 - uv0.x; } // (wider: its sides cut) else { const float k = (pw / ph) * ih / iw; uv0.y = (1 - 1 / k) * 0.5f, uv1.y = 1 - uv0.y; } - c.d->AddImage(pic.texture->GetTexRef(), pa, pb, uv0, uv1); + ImVec2 uv[6]; + for (int k = 0; k < 6; k++) uv[k] = ImVec2(uv0.x + (uv1.x - uv0.x) * (poly[k].x - pa.x) / pw, uv0.y + (uv1.y - uv0.y) * (poly[k].y - pa.y) / ph); + textured_poly(c, pic.texture->GetTexRef(), poly, uv, 6); } else { - ui::text_mid_centre(c, c.f.body, 13 * s, (pa.x + pb.x) * 0.5f, my, ui::kDim, saved ? "No picture" : "New game"); + c.d->AddConvexPolyFilled(poly, 6, ui::rgba(18, 13, 8, 255)); + ui::text_mid_centre(c, c.f.body, ui::lu(c, 42), (pa.x + pb.x) * 0.5f, (pa.y + pb.y) * 0.5f, ui::kDim, saved ? "No picture" : "New game"); } - c.d->AddRect(pa, pb, ui::alpha(ui::kEdge, 0.9f), 0, std::max(1.0f, s)); - // (Triforce, 11-18, his picture of the game's own load list: "can we show progress of the latest autosave like this?") - // The card as the game's: the save's time over the place it was played last, a line, the hearts under it, and at the - // right the plate with the six medallions round the three Spiritual Stones, each in its place when held. The file's - // name on the tag where the game says Autosave. What the host kept as the file was played (host/save_files.h - // SaveCard): a file not played with this yet has its name and its time alone - namespace ar = achievement_rows; + if (!card) c.d->AddRect(pa, pb, ui::alpha(ui::kEdge, 0.9f), 0, std::max(1.0f, tx)); + // (the card as the game's: the save's time, the place it was played last under it, the rule, the hearts; at the right + // the tag, here the file's name, and the plate of the stones and medallions. What the host kept as the file was + // played (host/save_files.h SaveCard): a file not played with this yet has its name and its time alone) const bool carded = saved && (save_files.places[i][0] || save_files.items[i] || save_files.hearts[i]); - const float R = 44 * s, tx = pb.x + 18 * s; - const ImVec2 wc(b.x - 18 * s - R, my); - const float text_right = carded ? wc.x - R - 16 * s : b.x - 16 * s; - { // (the tag: the file's name; the one this run plays in gold, "Playing" before it) - const float tw = ui::size_of(c.f.strong, 13.5f * s, save_files.names[i]).x + 22 * s; - const ImVec2 g(text_right - tw, a.y + 10 * s); - c.d->AddRectFilled(g, g + ImVec2(tw, 23 * s), i == cur ? ui::kAccent : ui::alpha(ui::kAccent, 0.45f), 4 * s); - ui::text_mid_centre(c, c.f.strong, 13.5f * s, g.x + tw * 0.5f, g.y + 11.5f * s, ui::kGoldInk, save_files.names[i]); - if (i == cur) ui::text_mid_right(c, c.f.strong, 13.5f * s, g.x - 10 * s, g.y + 11.5f * s, ui::kGoldHi, "Playing"); - } - c.d->PushClipRect(ImVec2(tx, a.y), ImVec2(text_right, b.y), true); - ui::text_mid(c, c.f.body, 15 * s, tx, a.y + 21 * s, saved ? ui::kSoft : kCardOff, + const int items = carded ? save_files.items[i] : 0; + const float plate_x = 1337, text_x = 482; + const float text_right = (items ? plate_x - 108 : 1440) * tx + o.x; + const ImVec2 ta = P(1016, 32), tb = P(1212, 88); // (the tag, where the game's "Autosave" is) + if (tag) ui::image(c, tag, ta, tb); + else c.d->AddRectFilled(ta, tb, i == cur ? ui::kAccent : ui::alpha(ui::kAccent, 0.45f), ui::lu(c, 6)); + ui::text_mid_centre(c, c.f.body, ui::lu(c, 46), (ta.x + tb.x) * 0.5f, (ta.y + tb.y) * 0.5f, ui::kInkBright, save_files.names[i]); + if (i == cur) ui::text_mid_right(c, c.f.strong, ui::lu(c, 44), ta.x - ui::lu(c, 24), (ta.y + tb.y) * 0.5f, ui::kGoldHi, "Playing"); + const float when_right = ta.x - ui::lu(c, i == cur ? 190 : 24); + c.d->PushClipRect(P(text_x, 30), ImVec2(when_right, P(0, 92).y), true); + ui::text_mid(c, c.f.body, ui::lu(c, 51), P(text_x, 63).x, P(0, 63).y, saved ? ui::kInkBright : kCardOff, saved ? (pic.when[0] ? pic.when : save_files.whens[i][0] ? save_files.whens[i] : "Saved") : "No save yet"); - const char* const place = !saved ? "New game" : save_files.places[i][0] ? save_files.places[i] : "Saved game"; - ui::text_mid(c, c.f.strong, 23 * s, tx, a.y + 50 * s, saved ? ui::kInkBright : ui::kSoft, place); c.d->PopClipRect(); - c.d->AddLine(ImVec2(tx, a.y + 71 * s), ImVec2(text_right, a.y + 71 * s), ui::alpha(ui::kEdge, 0.7f), std::max(1.0f, s)); - for (int k = 0, hearts = carded ? save_files.hearts[i] : 0; k < hearts; k++) { // (a heart: two lobes over a point) - const float w = 15 * s, hx = tx + w * 0.5f + k * (w + 4 * s), hy = a.y + 90 * s; - if (hx + w * 0.5f > text_right) break; - if (const ui::Art* heart = ui::art("HeartBase_00")) { // (the game's own heart: its base in its red, its frame over it) - // ((Triforce) 11-18, his picture: the hearts were small and grey. The game's heart is a pale picture in the middle - // of a square of margin, which its layout colours and draws larger than its slot: twice the slot's width here, - // a slot apart, the base in the load list's red-orange and the frame's line over it a shade lighter) - const float slot_w = 21 * s, hw = slot_w * 2.1f, hh2 = hw * heart->h / heart->w, mx = tx + slot_w * 0.5f + k * slot_w; - if (mx + slot_w * 0.5f > text_right) break; - const ImVec2 ha(mx - hw * 0.5f, hy - hh2 * 0.5f), hb(mx + hw * 0.5f, hy + hh2 * 0.5f); - // ((Triforce) 11-18, his next picture: the frame came out right, an orange outline, but the heart inside it dark - // brown. HeartBase_00 is the heart's dark ground, not its red: the game lays the fill over it from other layers. - // The fill is drawn here, in the load list's red-orange with a lighter upper half, inside the game's own frame) - (void)heart; - const float fw = slot_w * 0.80f, fy = hy - fw * 0.02f; - const ImU32 fill = ui::rgba(238, 92, 48), lit = ui::rgba(250, 128, 70); - c.d->AddCircleFilled(ImVec2(mx - fw * 0.24f, fy - fw * 0.13f), fw * 0.27f, fill, 20); - c.d->AddCircleFilled(ImVec2(mx + fw * 0.24f, fy - fw * 0.13f), fw * 0.27f, fill, 20); - c.d->AddTriangleFilled(ImVec2(mx - fw * 0.49f, fy - fw * 0.02f), ImVec2(mx + fw * 0.49f, fy - fw * 0.02f), ImVec2(mx, fy + fw * 0.50f), fill); - c.d->AddCircleFilled(ImVec2(mx - fw * 0.24f, fy - fw * 0.17f), fw * 0.15f, lit, 16); - c.d->AddCircleFilled(ImVec2(mx + fw * 0.24f, fy - fw * 0.17f), fw * 0.15f, lit, 16); - if (const ui::Art* frame = ui::art("HeartFrame_00")) ui::image(c, frame, ha, hb, ui::rgba(255, 150, 96)); - continue; - } - const ImU32 red = ui::rgba(236, 86, 52), rim = ui::rgba(140, 34, 22); - c.d->AddCircleFilled(ImVec2(hx - w * 0.25f, hy - w * 0.14f), w * 0.31f, rim, 16), c.d->AddCircleFilled(ImVec2(hx + w * 0.25f, hy - w * 0.14f), w * 0.31f, rim, 16); - c.d->AddTriangleFilled(ImVec2(hx - w * 0.55f, hy + w * 0.02f), ImVec2(hx + w * 0.55f, hy + w * 0.02f), ImVec2(hx, hy + w * 0.60f), rim); - c.d->AddCircleFilled(ImVec2(hx - w * 0.25f, hy - w * 0.14f), w * 0.25f, red, 16), c.d->AddCircleFilled(ImVec2(hx + w * 0.25f, hy - w * 0.14f), w * 0.25f, red, 16); - c.d->AddTriangleFilled(ImVec2(hx - w * 0.46f, hy + w * 0.01f), ImVec2(hx + w * 0.46f, hy + w * 0.01f), ImVec2(hx, hy + w * 0.50f), red); - c.d->AddCircleFilled(ImVec2(hx - w * 0.28f, hy - w * 0.20f), w * 0.08f, ui::rgba(255, 190, 160, 200), 8); + c.d->PushClipRect(P(text_x, 92), ImVec2(text_right, P(0, 150).y), true); + const char* const place = !saved ? "New game" : save_files.places[i][0] ? save_files.places[i] : "Saved game"; + ui::text_mid(c, c.f.strong, ui::lu(c, 75), P(text_x, 121).x, P(0, 121).y, saved ? ui::kInkBright : ui::kSoft, place); + c.d->PopClipRect(); + if (!card) c.d->AddLine(P(text_x, 156), ImVec2(text_right, P(0, 156).y), ui::alpha(ui::kEdge, 0.7f), std::max(1.0f, tx)); + const int hearts = carded ? save_files.hearts[i] : 0; // (ten to a row, as the game's own life gauge) + for (int k = 0; k < hearts; k++) { + const float y = hearts > 10 ? (k < 10 ? 182 : 222) : 196, x = 484 + 20.5f + (k % 10) * 41; + files_heart(c, P(x, 0).x, P(0, y).y, 41 * tx); } - if (carded) { // (the plate: the medallions of light, forest, fire, water, spirit and shadow round it from the top, the stones in its middle) - static const int medal_tones[save_file_rows::kMedals] = {ar::kYellow, ar::kGreen, ar::kRed, ar::kBlue, ar::kOrange, ar::kPurple}; - static const int stone_tones[save_file_rows::kStones] = {ar::kGreen, ar::kRed, ar::kBlue}; - // (the game's own pictures of them, DataFileImportantIcon_00 to _08, when its archive gave them. kFileIcon: the - // picture's number for each of the items' bits. The stones first (forest, fire, water), then the medallions as the - // plate has them round it from the top: light, forest, fire, water, spirit, shadow. (11-18: taken first to be in - // gpu/vk/oot_cheat_items.h's order, light last: his card had Shadow's picture where Light is held and Light's where - // Forest is. _03 is Light, then, and the six go round the plate; _08, Shadow's, was drawn for Light)) - static const int kFileIcon[save_file_rows::kStones + save_file_rows::kMedals] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; - const auto game_icon = [&](int bit, ImVec2 m, float r) { - char name[32]; - snprintf(name, sizeof name, "DataFileImportantIcon_%02d", kFileIcon[bit]); - const ui::Art* t = ui::art(name); - if (!t || t->mask) return false; // (a mask is a shape without its colours: the drawn icon then) - const float hw = r * 1.45f, hh2 = hw * t->h / t->w; - ui::image(c, t, ImVec2(m.x - hw, m.y - hh2), ImVec2(m.x + hw, m.y + hh2)); - return true; - }; - const ImU32 socket = ui::rgba(30, 22, 12, 230); - c.d->AddNgonFilled(wc, R, ui::rgba(74, 56, 30, 240), 6); - c.d->AddNgon(wc, R, ui::alpha(ui::kEdge, 0.9f), 6, std::max(1.0f, 1.3f * s)); - for (int k = 0; k < save_file_rows::kMedals; k++) { - const float ang = -1.5707963f + k * 1.0471976f, r = R * 0.19f; - const ImVec2 m(wc.x + std::cos(ang) * R * 0.66f, wc.y + std::sin(ang) * R * 0.66f); - if (!(save_files.items[i] >> (save_file_rows::kStones + k) & 1)) c.d->AddCircleFilled(m, r, socket, 24); - else if (game_icon(save_file_rows::kStones + k, m, r)) {} - else ach_icon(c, m, r, ar::kMedal | medal_tones[k] << 4, true); - } - for (int k = 0; k < save_file_rows::kStones; k++) { - const float r = R * 0.17f; - const ImVec2 m(wc.x + (k - 1) * R * 0.36f, wc.y); - if (!(save_files.items[i] >> k & 1)) c.d->AddCircleFilled(m, r, socket, 24); - else if (game_icon(k, m, r)) {} - else ach_icon(c, m, r, ar::kGem | stone_tones[k] << 4, true); - } + files_plate(c, items, P(plate_x, 141), tx); + // (the game's cursor round the card: its white line on the card's edge, its glow outside. ((Triforce, 11-26) As the + // game's settings move theirs: the card let go fades its cursor out while the new one fades its in (focus_anim.h, + // PaCommonBtnThin_00's UnSelect and Select); none slides. Settled at once as the page opens, which fades in whole) + files_focus[i].step(now, i == files_choice, settle); + if (const float k = files_focus[i].shown; k > 0) { + if (cursor_line && cursor_glow) { + const ImVec2 m(59.5f * tx, 63.5f * tx); + ui::glow_layers(c, cursor_glow, a - m, b + m, 150, 120, ui::kCursorGlow, ui::kCursorGlowBase, ui::kCursorGlowHdr, k); + ui::nine(c, cursor_line, a - m, b + m, 150, 120, ui::alpha(ui::kCursor, k)); + } else ui::cursor(c, a, b, k); } - if (i == files_choice) ui::glow(c, a, b); hits.add(a.x, a.y, b.x, b.y, menu_hit::kListLine, i); } - if (n > 0 && !waiting) { // (the chosen file's action, for the mouse) - const float my = bar - 14 * s - 29 * s, bw = ui::size_of(c.f.strong, 18 * s, "Switch file").x + 36 * s; - const ImVec2 a(right - bw, my - 17 * s), b(right, my + 17 * s); - ui::button(c, a, b, act, false); - hits.add(a.x, a.y, b.x, b.y, menu_hit::kButton, 0); + // (what choosing the chosen card does, under the cards, in the middle; the host's word on a choice in its place) + if (n > 0) { + const bool saved = save_files.saved(files_choice); + const char* line = waiting ? "Starting the game on this file..." : + files_failed ? "The choice could not be kept: nothing changed." : + here ? "The file the game is playing now. Its saves and autosaves are its own." : + saved ? "Another file, with its own saves and autosaves. The game starts again to play it: what is not saved in the " + "file you are playing now is lost." : + "An empty file: a new game of its own. The game starts again to play it."; + const ImU32 col = waiting || files_failed ? ui::kGoldHi : ui::kSoft; + const float px = ui::lu(c, 48), wrap = kFileCardW * tx, mid = ui::at(c, 0, 0).x; + float y = bottom + ui::lu(c, 110); + for (const char *t = line, *end = line + strlen(line); t < end;) { // (each line in the middle, as the game sets a caption's) + const char* cut = c.f.body->CalcWordWrapPosition(px, t, end, wrap); + if (cut == t) cut = t + 1; + ui::text_mid_centre(c, c.f.body, px, mid, y, col, std::string(t, cut).c_str()); + y += px * 1.35f; + t = cut; + while (t < end && *t == ' ') t++; + } } ui::prompt_bar(c, prompts, (int)(sizeof prompts / sizeof prompts[0])); } @@ -6768,9 +7193,16 @@ void draw_ach_notice(ui::Ctx& c) { void draw_ask(ui::Ctx& c) { const float s = c.s; - dim_page(c, ui::rgba(8, 5, 2, 110)); // (the dialog over the page: darker still; the whole window, the Full panel with it) - ui::banner(c, 0, "Restart Needed"); - const std::string ask = i18n::tr("Restart to apply ") + restart_list_shown(i18n::tr(" and ")) + "?"; // ((Triforce) translated) + // ((Triforce, 11-26) Apply's question (ask_kind) is this one's, as the owner asked ("Same prompt as the Restart pop up"): + // its title, what it would take, the same two buttons with Apply Now in Restart Now's place, the same guides) + const bool apply = ask_kind == kQuestionApply; + // (the dialog over the page: darker still; the whole window, the Full panel with it. ((Triforce, 11-26) Inside the game's own + // Options screen (over_game) nothing of ours dims it first, and the game's list showed through under the question's text (the + // lab's first run of Apply's question): as dark as the game's own Quit dialog makes the pause menu behind it) + dim_page(c, ui::rgba(8, 5, 2, c.over_game ? 215 : 110)); + ui::banner(c, 0, apply ? "Apply Settings" : "Restart Needed"); + const std::string ask = apply ? i18n::tr("Apply ") + apply_list_shown(i18n::tr(" and ")) + "?" + : i18n::tr("Restart to apply ") + restart_list_shown(i18n::tr(" and ")) + "?"; // ((Triforce) translated) const float wrap = ui::lu(c, 1440), px = ui::lu(c, 54 * ui::kType); const float th = ui::para(c, c.f.body, px, ImVec2(), 0, ask.c_str(), wrap, false); float y = ui::at(c, 0, 250).y - th * 0.5f; @@ -6787,10 +7219,12 @@ void draw_ask(ui::Ctx& c) { while (t < end && (*t == ' ' || *t == '\n')) t++; } } - ui::text_mid_centre(c, c.f.body, ui::lu(c, 52), c.w * 0.5f, y + 16 * s, ui::kSoft, "Progress since your last save is lost."); + ui::text_mid_centre(c, c.f.body, ui::lu(c, 52), c.w * 0.5f, y + 16 * s, ui::kSoft, + apply ? "The game goes on where it is. The picture may pause for a moment." + : "Progress since your last save is lost."); // (SystemWindow_00's buttons: PaCommonBtnThin's plate, 684 x 156 units, 188 apart; the upper one acts, the lower one backs out) const float bw = ui::lu(c, 336), bh = ui::lu(c, 72); - const char* labels[2] = {"Later", "Restart Now"}; + const char* labels[2] = {"Later", apply ? "Apply Now" : "Restart Now"}; for (int i = 0; i < 2; i++) { const float my = ui::at(c, 0, i ? -330.0f : -518.0f).y; const ImVec2 a(c.w * 0.5f - bw, my - bh), b(c.w * 0.5f + bw, my + bh); @@ -6917,7 +7351,11 @@ void draw_menu(ui::Ctx& c, bool perf_under) { // (the game behind: inside its own Options screen its own background, untouched; over play the System screens' own // (ui::system_bg), or dimmed flat without its textures) const bool tuning = tune_mode && page == 0 && !embed_open && !row; // ((Triforce) the tuning bar: the game seen whole - if (!embed_open && !row && !tuning && !ui::system_bg(c)) c.d->AddRectFilled(ImVec2(0, 0), ImVec2(c.w, c.h), ui::rgba(8, 5, 2, ui::kDimAlpha)); + // ((Triforce, 11-26) Save Select over the title: none of it. The owner: "remove the black. Shadow behind the save select + // and replace it with blur": the title behind it is out of focus, as behind the game's own Options there (vk_framegen.cpp + // wide_sides, asked by files_blur), and the System screens' shade on it was the black) + const bool blurred = files_blur.load(std::memory_order_relaxed) && page == kFilesPage; + if (!embed_open && !row && !tuning && !blurred && !ui::system_bg(c)) c.d->AddRectFilled(ImVec2(0, 0), ImVec2(c.w, c.h), ui::rgba(8, 5, 2, ui::kDimAlpha)); // ((Triforce, 11-19) inside the game's own Options screen the Full panel between our page and our header, as on the game's // own tab it is over the game's panes and under our header (menu_record: draw_perf, then draw_game_tab): the lab's "our // help box draws over part of the stats panel" (fullscreen 3440 x 1440). ((11-20) Over play under the pages, as before. @@ -6941,6 +7379,7 @@ void draw_menu(ui::Ctx& c, bool perf_under) { const game_grid::Place g = menu_grid(c.w, c.h); k = grid_ctx(c, g), k.over_game = false; menu_map = game_grid::map_of(g); + title_grid = g; } const int vtx0 = c.d->VtxBuffer.Size, cmd0 = c.d->CmdBuffer.Size; const ImVec4 window_clip = clip_now(c.d); @@ -6957,6 +7396,7 @@ void draw_menu(ui::Ctx& c, bool perf_under) { float cx0, cx1, hx0, hx1; bool narrow; columns(k, &cx0, &cx1, &hx0, &hx1, &narrow); + if (page == kFilesPage) files_columns(k, &cx0, &cx1); // ((Triforce, 11-25) the game's Load list: one column, in the middle) // (over the game's own Options screen its column is under ours: only our opaque middle, over its list, so its soft // edges stay as the game draws them, once) ui::column_bg(k, cx0, cx1, k.over_game); @@ -6983,8 +7423,12 @@ void draw_menu(ui::Ctx& c, bool perf_under) { } // ((Triforce, 11-20) the Mods screen fades in whole: the background, the column, the cards, the details, the Salesman's // picture and the prompts; not the Full panel, which was there before it) - for (int i = vtx_page; mods_in < 1 && i < c.d->VtxBuffer.Size; i++) - if (i < perf0 || i >= perf1) c.d->VtxBuffer[i].col = ui::alpha(c.d->VtxBuffer[i].col, mods_in); + // ((Triforce, 11-26) and Save Select the same way: the owner's "add animation when you open the save select ... instead of + // it popping up instantly") + static const bool still_in = getenv("RX_VK_UI_STILL") != nullptr; + const float page_in = page == kFilesPage ? files_screen.alpha(prof_now(), !ease_live || still_in) : mods_in; + for (int i = vtx_page; page_in < 1 && i < c.d->VtxBuffer.Size; i++) + if (i < perf0 || i >= perf1) c.d->VtxBuffer[i].col = ui::alpha(c.d->VtxBuffer[i].col, page_in); if (menu_map.ox <= 0 && menu_map.oy <= 0 && menu_map.kx == 1) return; // (a clip rectangle of the column's: moved with it; the whole window's (the dim's, and the draw list's own) stays, as it // holds the column wherever it is) @@ -7688,6 +8132,7 @@ void menu_init() { lang_load(); // (Triforce: the Game language row, from language.txt) merged_sync(); // ((Triforce, options_version 7) the merged rows from what was read) restart_init(); // (what this run started with: the rows that take a restart differ from it once changed) + apply_init(); // ((Triforce, 11-26) and what runs of the rows taken at Apply: the file's choice, the switches over it) } namespace { @@ -7769,8 +8214,8 @@ void auto_start() { return; } auto_apply("new hardware", true); - for (const Row& r : rows) - if (r.value == &opts.resolution || r.value == &opts.dlss) restart_state.restart_value(restart_slot_of(r), restart_value_of(r)); + // ((Triforce, 11-26) what this run starts with, before the host's first read: rows taken at Apply, in force at once) + applied_take_row(&opts.dlss), applied_take_row(&opts.resolution); } /// (the tuning's Render resolution steps, dir -1 lighter, +1 heavier: the upscaler's own steps by size, up to best_step; /// none from Auto (dynamic) or an engine's native AA) @@ -7809,8 +8254,12 @@ void auto_tick() { snprintf(was, sizeof was, "%s", tx_resolution(opts.resolution)); if (action == AUTO_GRASS) __atomic_store_n(&opts.grass_distance, std::max(0, opts.grass_distance - 1), __ATOMIC_RELAXED); if (action == AUTO_SHADOW) __atomic_store_n(&opts.shadow_res, std::max(0, opts.shadow_res - 1), __ATOMIC_RELAXED); - if (action == AUTO_RES_LIGHTER || action == AUTO_RES_HEAVIER) + if (action == AUTO_RES_LIGHTER || action == AUTO_RES_HEAVIER) { opts.resolution = auto_res_step(up, opts.resolution, action == AUTO_RES_LIGHTER ? -1 : 1); + // ((Triforce, 11-26) at once, as the menu's Apply takes it, the row alone. No choice of the player's waits there: a + // change of the Upscaler or this row by hand turns Auto Off, and the tuning with it (auto_row_set)) + applied_take_row(&opts.resolution); + } opts.auto_tune = req >> 8; save(); if (action == AUTO_GRASS || action == AUTO_SHADOW) @@ -7818,14 +8267,14 @@ void auto_tick() { action == AUTO_GRASS ? "Grass distance" : "Shadow resolution", action == AUTO_GRASS ? tx_grass_distance(opts.grass_distance) : tx_shadow_res(opts.shadow_res)); else if (action != AUTO_SETTLED) - logf("menu: Auto (this PC): %s: Render resolution %s to %s, from the next start", action == AUTO_RES_LIGHTER + logf("menu: Auto (this PC): %s: Render resolution %s to %s, at once", action == AUTO_RES_LIGHTER ? "frames missed with the GPU busy" : "the cap held with the GPU under half busy", was, tx_resolution(opts.resolution)); else logf("menu: Auto (this PC): the settings hold this PC's cap: tuning done"); } /// ((Triforce) the replay's thread, every 120 presents: Auto (this PC)'s tuning while the row is On (not with frame /// generation, whose made frames are not the game's). Lighter: the Grass distance, then the Shadow resolution, a step at -/// once; then the Render resolution, for the next start (it takes a restart: the tuning is done for this run). Heavier: the -/// Render resolution, for the next start +/// once; then the Render resolution, one step and the tuning done for this run (at once since 11-26: applied_take_row; it was +/// the next start's). Heavier: the Render resolution, the same void auto_tune_window(double gpu_ms, double draws, double fps) { static const bool off = getenv("RX_VK_AUTO_TUNE") && atoi(getenv("RX_VK_AUTO_TUNE")) == 0; if (off || !__atomic_load_n(&opts.auto_pc, __ATOMIC_RELAXED) || framegen_on()) return; @@ -7931,18 +8380,21 @@ void menu_first_start() { return; } opts.resolution = ur::snap(upscaler(), choice.row); - // (the row takes a restart: what this run starts with is this, not menu_init's) - for (const Row& r : rows) - if (r.value == &opts.resolution) restart_state.restart_value(restart_slot_of(r), restart_value_of(r)); + // (what this run starts with is this, not menu_init's: ((Triforce, 11-26)) the row is taken at Apply, in force at once here) + applied_take_row(&opts.resolution); logf("menu: first start: tier 1 (%s, %llu MB of video memory%s, %u threads): Render resolution %s " "(RX_VK_FIRST_START_AUTO; nothing is saved)", first_start::why_text(choice.why), (unsigned long long)card.vram_mb, asked > 0 ? " asked" : "", card.threads, tx_resolution(opts.resolution)); } -bool resolution_auto() { return opts.resolution == 0; } +// ((Triforce, 11-26) the Render resolution and the Upscaler as applied (applied_resolution, applied_dlss): what the host takes +// each present (vk_replay.cpp options 2 and 3). The engine by the applied choice on this PC alone (upscaler_of's now false): +// N64 Classic's 3D pass and an engine standing off after failures leave the 3D's size as it is, not remade back and forth +bool resolution_auto() { return applied_resolution() == 0; } +bool resolution_full() { return ur::full_scale(upscaler_of(applied_dlss(), false)); } int resolution_scale() { // ((Triforce) 11-24: the Upscaler's own step for the saved scale, set_row) - const float s = upscaler_rows::percent(ur::snap(upscaler(), opts.resolution)) / 100.0f; + const float s = upscaler_rows::percent(ur::snap(upscaler_of(applied_dlss(), false), applied_resolution())) / 100.0f; return s > 0 ? (int)(twelfths(s) * 10000.0f / 12.0f + 0.5f) : 0; // (the twelfth game_size labels) } @@ -7961,6 +8413,7 @@ void menu_set_gpu_count(int count) { } bool menu_is_open() { return open_now.load(std::memory_order_relaxed); } +bool menu_backdrop_blurred() { return files_blur.load(std::memory_order_relaxed); } int menu_grass_distance() { return __atomic_load_n(&opts.grass_distance, __ATOMIC_RELAXED); } // (the menu's thread writes it) // (the tools off on the Debug tab: flight, the free camera and heart protection put away; -1, heart protection never set, is the // host's own HOS_OOT_PROTECT_HEARTS) @@ -7997,6 +8450,12 @@ static_assert(menu_sound::kOpen == HOS_MENU_SOUND_OPEN && menu_sound::kClose == menu_sound::kCancel == HOS_MENU_SOUND_CANCEL && menu_sound::kTabLeft == HOS_MENU_SOUND_TAB_LEFT && menu_sound::kTabRight == HOS_MENU_SOUND_TAB_RIGHT && menu_sound::kFanfare == HOS_MENU_SOUND_FANFARE && menu_sound::kSysCursor == HOS_MENU_SOUND_SYS_CURSOR && menu_sound::kSysDecide == HOS_MENU_SOUND_SYS_DECIDE && + // ((Triforce, 11-25) whose cursor, decide and cancel: the settings' tabs', the Mods screen's, the pause menu's) + menu_sound::kSettingsNavigate == HOS_MENU_SOUND_SETTINGS_NAVIGATE && + menu_sound::kSettingsSelect == HOS_MENU_SOUND_SETTINGS_SELECT && menu_sound::kSettingsBack == HOS_MENU_SOUND_SETTINGS_BACK && + menu_sound::kModsNavigate == HOS_MENU_SOUND_MODS_NAVIGATE && menu_sound::kModsSelect == HOS_MENU_SOUND_MODS_SELECT && + menu_sound::kModsBack == HOS_MENU_SOUND_MODS_BACK && menu_sound::kPauseBack == HOS_MENU_SOUND_PAUSE_BACK && + menu_sound::kSettingsOn == HOS_MENU_SOUND_SETTINGS_ON && menu_sound::kSettingsOff == HOS_MENU_SOUND_SETTINGS_OFF && menu_sound::kLast + 1 == HOS_MENU_SOUND_N, // ((Triforce) the fanfare and the system menu's two: the Mods screen's and entry's own, not the options') "menu_sound_events.h's sounds are vk_api.h's HOS_MENU_SOUND_*"); @@ -8033,6 +8492,7 @@ static menu_sound::State sound_state() { const Row& r = rows[tab_row_to_global(cur_tab, tab_selected[cur_tab])]; s.cursor = tab_selected[cur_tab]; s.mode = pending ? menu_sound::kModeConfirm : menu_sound::kModeNone; + s.toggle = r.value && r.text == tx_onoff; // ((Triforce) drawn as On and Off: its own sounds, toggle_sound) if (r.value) s.value = *r.value; else if (mod_cheat_slot(r.name) >= 0) s.value = mod_cheats.is_on(mod_cheat_slot(r.name)); else if (r.cheat >= 0) s.value = hashed(cheat_value(r.cheat)); @@ -8043,6 +8503,7 @@ static menu_sound::State sound_state() { if (i < 0) { const Row& r = rows[tab_row_to_global(TAB_PAGE, csel)]; if (r.value) s.value = *r.value; + s.toggle = r.value && r.text == tx_onoff; } else if (i < kControls && can_bind()) { const int b = controls[i].button; s.value = keys_only(i) ? 0 : host->binding(HOS_BIND_PAD, b, 0); @@ -8071,6 +8532,11 @@ static menu_sound::State sound_state() { } int menu_take_sound() { return sound_queue.take(prof_now()); } // (the options' next sound, for the host's sound thread) void mods_sound(int id) { if (opts.menu_sounds > 0) sound_queue.put(id, prof_now()); } // ((Triforce) the Mods entry's and screen's own sounds +/// ((Triforce, 11-25) the owner's "They should be using the title screen's SFX instead of the in-game Menu SFX", each a sound +/// that can be set by itself) The sound of a step back out of the Mods screen: back to the pause menu's System list it is that +/// list's (as Cancel and B on Quit's dialog under it), else the Mods screen's own (opened from the title's list, where +/// mods_back gives the title its list again, or from the tab strip) +int mods_back_sound() { return mods_list_fresh() && !mods_title_list() ? HOS_MENU_SOUND_PAUSE_BACK : HOS_MENU_SOUND_MODS_BACK; } int menu_mods_selected() { // ((Triforce) and the file select opened from Save Select, the entry under Mods on the title) return open_now.load(std::memory_order_relaxed) && (page == kModsRowPage || page == kModsPage || (page == kFilesPage && files_at_title)); } @@ -8130,6 +8596,7 @@ std::string changed_rows_text() { out += " (default: "; out += r.value == &opts.mic && was >= 2 ? "a microphone by its name" : r.text(was); if (restart_changed(r)) out += "; takes effect after a restart"; + else if (apply_changed(r)) out += "; not applied yet"; // ((Triforce, 11-26) chosen, Apply not pressed: what runs is the other) out += ")\n"; } if (!changed) out = "Every option is at its default.\n"; @@ -8251,16 +8718,17 @@ const char* perf_rate_text(const char* cap, char* out, size_t n) { /// (Triforce) The Upscaling setting's value on the panel: the upscaler in effect with its mode ("NVIDIA DLAA (native)", "NVIDIA /// DLSS, Quality (67%)"); with the game's own the words of its own way ("Game's own (dynamic)", "Game's own, 75% (1440x810)": /// NX2navi names no scaler of the game's own, its Ocarina leaving the row out). The Upscaler and Render resolution rows -/// keep their own texts +/// keep their own texts. ((Triforce, 11-26) What runs: the two rows as applied, not a choice that waits for Apply) const char* perf_upscaling_text(char* out, size_t n) { - const char* res = tx_resolution(opts.resolution); - if (upscaler() == ur::GAME) { + const int up = upscaler_of(applied_dlss(), true); + const char* res = resolution_name(up, applied_resolution()); + if (up == ur::GAME) { if (resolution_auto()) snprintf(out, n, "Game's own (dynamic)"); else snprintf(out, n, "Game's own, %s", res); } else if (!strncmp(res, "Native (", 8)) { - snprintf(out, n, "%s (native)", tx_upscaler(0)); + snprintf(out, n, "%s (native)", upscaler_name(up)); } else { - snprintf(out, n, "%s, %s", tx_upscaler(0), res); + snprintf(out, n, "%s, %s", upscaler_name(up), res); } return out; } @@ -8416,6 +8884,10 @@ void perf_machine_start() { int menu_vibration_status_option() { return vibration_status_cache.load(std::memory_order_relaxed); } void menu_option_set(int id, int value) { + if (id == HOS_OPT_RES_HELD) { // ((Triforce, 11-26) a larger 3D the host keeps for the next start: res_held) + res_held.store(value, std::memory_order_relaxed); + return; + } if (id == HOS_OPT_VIBRATION_STATUS) { // ((Triforce) 11-24: what plays the controller used last, host/pad_sdl.c) vibration_status_cache.store(value, std::memory_order_relaxed); return; @@ -8654,19 +9126,24 @@ int menu_setting_set(const char* key, int value, MkwVkSetting* out) { /// (hookshot) the mouse on the inventory: a section tab chooses it, a card the item (a click selects it, it does not edit), /// the page arrows turn the page with the choice, the action button and the amount's halves act; the wheel turns the page /// shown and leaves the choice where it is; a right click goes back -void inventory_mouse(const MkwVkPointer& ptr, int mx, int my, bool* press, bool& changed) { - const menu_hit::Hit hit = hits.at((float)mx, (float)my); +void inventory_mouse(const MkwVkPointer& ptr, int mx, int my, bool moved, bool* press, bool& changed) { + menu_hit::Hit hit = hits.at((float)mx, (float)my); + // ((Triforce, 11-26) as the name pages: the slider, the card under the mouse chosen, a click on the chosen card its action) + const bool bar = bar_mouse(ptr, my, hit, changed); + if (bar) hit = menu_hit::Hit{}; + const bool on_card = hit.part == menu_hit::kListLine && hit.index >= inventory_begin() && hit.index < inventory_end(); + if (on_card && moved && !(ptr.pressed & HOS_MOUSE_LEFT) && !inventory_amount && hit.index != item_choice) item_choice = hit.index, changed = true; if (ptr.pressed & HOS_MOUSE_LEFT) { if (hit.part == menu_hit::kRow && hit.index >= 0 && hit.index <= kItemSections) choose_inventory_filter(hit.index), changed = true; - else if (hit.part == menu_hit::kListLine && hit.index >= inventory_begin() && hit.index < inventory_end()) - item_choice = hit.index, inventory_amount = false, changed = true; + else if (on_card && hit.index == item_choice && !inventory_amount) press[7] = true; + else if (on_card) item_choice = hit.index, inventory_amount = false, changed = true; else if (hit.part == menu_hit::kButton && hit.index == 0) press[7] = true; else if (hit.part == menu_hit::kButton && hit.index == 1 && hit.side) press[hit.side < 0 ? 3 : 4] = true; else if (hit.part == menu_hit::kButton && (hit.index == 2 || hit.index == 3)) // (the page arrows) press[hit.index == 2 ? 13 : 14] = true, inventory_amount = false; } if (ptr.pressed & HOS_MOUSE_RIGHT) press[5] = true; - if (ptr.wheel) { + if (ptr.wheel && !bar) { const int was = inventory_page; inventory_page = std::max(0, inventory_page - ptr.wheel); // (drawing keeps it to the pages there are) changed |= inventory_page != was; @@ -8674,15 +9151,23 @@ void inventory_mouse(const MkwVkPointer& ptr, int mx, int my, bool* press, bool& } /// (hookshot) the mouse on the teleport list: a click on a card selects it (Travel, or confirm, goes), the Travel button /// goes; the wheel scrolls the cards and leaves the choice where it is; a right click goes back -void teleport_mouse(const MkwVkPointer& ptr, int mx, int my, bool* press, bool& changed) { - const menu_hit::Hit hit = hits.at((float)mx, (float)my); +void teleport_mouse(const MkwVkPointer& ptr, int mx, int my, bool moved, bool* press, bool& changed) { + menu_hit::Hit hit = hits.at((float)mx, (float)my); + // ((Triforce) the cards' page slider held: the cards follow the cursor, no card is chosen and the wheel rests (bar_mouse)) + const bool bar = bar_mouse(ptr, my, hit, changed); + if (bar) hit = menu_hit::Hit{}; + // ((Triforce, 11-26) the card the mouse moves onto chosen (the cards stay where they are under it), a click on the chosen + // card goes, as Travel: as the name pages and the Inventory) + const bool on_card = hit.part == menu_hit::kListLine && hit.index >= 0 && hit.index < kTeleports; + if (on_card && moved && !(ptr.pressed & HOS_MOUSE_LEFT) && hit.index != teleport_choice) + teleport_choice = hit.index, teleport_follow = false, changed = true; if (ptr.pressed & HOS_MOUSE_LEFT) { - if (hit.part == menu_hit::kListLine && hit.index >= 0 && hit.index < kTeleports) - teleport_choice = hit.index, teleport_follow = true, changed = true; + if (on_card && hit.index == teleport_choice) press[7] = true; + else if (on_card) teleport_choice = hit.index, teleport_follow = true, changed = true; else if (hit.part == menu_hit::kButton) press[7] = true; } if (ptr.pressed & HOS_MOUSE_RIGHT) press[5] = true; - if (ptr.wheel) teleport_wheel += ptr.wheel, teleport_follow = false, changed = true; + if (ptr.wheel && !bar) teleport_wheel += ptr.wheel, teleport_follow = false, changed = true; } /// A debug tool's row on the Debug tab (Row::cheat i): Left and Right, and confirm (press[7]: A, Enter, a click). Teleport and /// Inventory open their pages; back from them comes to the Debug tab, the row still selected @@ -8765,11 +9250,39 @@ void tab_move(int dir) { /// (Left and Right), Install (Confirm); an install's Cancel; its end's Restart Now or Later /// (Triforce) Back from the Mods screen: to the game's list it was opened from, the cursor on the Mods entry (as the game's own /// screens give the cursor back to the entry that opened them); the list gone meanwhile, the menu shuts +/// ((Triforce) on the title Mods is a tab now, which never has the cursor: Back gives the game its list again, the menu shut, +/// with the Mods screen's own step back (asked for here: the tick's own would be the menu's closing). Onto the pause menu's +/// System list the tick's own is that list's step back (sound_for); Not now on the warning asks for it too, the same sound +/// restarting, not stacked (host/menu_sound.c) +int mods_back_sound(); // (below, with the sounds) void mods_back(bool& changed) { - if (mods_list_fresh()) page = kModsRowPage; - else open_now = false, page = 0; + if (mods_list_fresh() && !mods_title_list()) page = kModsRowPage; + else open_now = false, page = 0, mods_sound(mods_back_sound()), tick_sound_done = true; changed = true; } +/// ((Triforce) the title's tabs can be chosen now: the title's list is there with its buttons shown, the tabs were drawn for +/// it, and nothing of ours is open but the entry under that list (the cursor on Quit Game)) +bool title_tabs_live() { + if (!mods_title_list() || !mods_list_fresh() || !title_tab_ns || prof_now() - title_tab_ns > 250000000LL) return false; + if (const float shown = mods_list_shown(); shown >= 0 && shown < 0.5f) return false; + return !open_now.load() || (page == kModsRowPage && !mods_decide_ns && !quit_ask); +} +/// ((Triforce) a tab of the title chosen: by its button, a click, or the host's word (a test's scripted press). 0 Mods: the +/// game's Decide on its tab first, then its screen (menu_tick, as A on the entry did); 1 Save Select: the file select at +/// once. With the system menu's "decide", as the title's own entries. false: not there to choose) +bool title_tab_go(int tab) { + if (!title_tabs_live() || tab < 0 || tab > 1 || (tab == 1 && !files_tab_shown())) return false; + open_now = true, embed_open = false, listening = 0, mods_btn = 0, mods_follow = true; + page = kModsRowPage, mods_row_sel = 0, quit_gone(), quit_sel = 0, title_tab_hover = -1; + if (tab == 0) title_decide = 0, mods_decide_ns = prof_now(); + else files_open(true); + auto_pad = pad_last; + ui::want_glyphs(); + mods_sound(HOS_MENU_SOUND_SYS_DECIDE), tick_sound_done = true; + logf("menu: the title's %s tab chosen", tab ? "Save Select" : "Mods"); + menu_refresh = true; + return true; +} /// ((Triforce) 11-17) The pictures' textures of a list the engine emptied (a search's results, a list after a failure): let go void mods_retire(const std::vector& textures) { for (void* t : textures) texture_retire((ImTextureData*)t); @@ -8829,7 +9342,11 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move if (dialog) mods_kbd = false; bool kbd_click = false; // (a key clicked: typed, not the keyboard's Enter) if (mouse) { - const menu_hit::Hit hit = hits.at((float)mx, (float)my); + menu_hit::Hit hit = hits.at((float)mx, (float)my); + // ((Triforce) the page sliders, the cards' and the description's: one held has its list follow the cursor, and + // nothing else is the mouse's meanwhile (bar_mouse). Not under a dialog, nor under the on-screen keyboard) + const bool bar = !dialog && !mods_kbd && bar_mouse(ptr, my, hit, changed); + if (bar) hit = menu_hit::Hit{}; if (hit.part == menu_hit::kButton && (moved || ptr.pressed) && hit.index != mods_btn) mods_btn = hit.index, changed = true; if ((ptr.pressed & HOS_MOUSE_LEFT) && hit.part == menu_hit::kButton) press[7] = true; if (!dialog && mods_kbd) { // ((Triforce) the on-screen keyboard: a key pointed at is chosen, a click types it; a click off it shuts it) @@ -8837,7 +9354,7 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move const int r = hit.index / 10, col = hit.index % 10; if (r != mods_kbd_row || col != mods_kbd_col) { mods_kbd_row = r, mods_kbd_col = col, changed = true; - if (ptr.pressed & HOS_MOUSE_LEFT) mods_sound(HOS_MENU_SOUND_CURSOR); // (a click; hover alone is quiet) + if (ptr.pressed & HOS_MOUSE_LEFT) mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); // (a click; hover alone is quiet) } } const bool inside = mx >= mods_kbd_box[0] && mx <= mods_kbd_box[2] && my >= mods_kbd_box[1] && my <= mods_kbd_box[3]; @@ -8845,10 +9362,10 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move else if ((ptr.pressed & HOS_MOUSE_LEFT) && hit.part != menu_hit::kSearch && !inside) mods_kbd = false, changed = true; } else if (!dialog) { if (hit.part == menu_hit::kListLine && (moved || ptr.pressed) && hit.index != mods_choice) - mods_choice = hit.index, mods_follow = true, changed = true, mods_sound(HOS_MENU_SOUND_CURSOR); + mods_choice = hit.index, mods_follow = true, changed = true, mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); if (hit.part == menu_hit::kSearch && (moved || ptr.pressed) && mods_choice != -1) mods_choice = -1, mods_follow = true, changed = true; if ((ptr.pressed & HOS_MOUSE_LEFT) && hit.part == menu_hit::kSearch) - mods_kbd = true, mods_kbd_row = 1, mods_kbd_col = 0, changed = true, mods_sound(HOS_MENU_SOUND_DECIDE); + mods_kbd = true, mods_kbd_row = 1, mods_kbd_col = 0, changed = true, mods_sound(HOS_MENU_SOUND_MODS_SELECT); if (ptr.pressed & HOS_MOUSE_LEFT) { if (hit.part == menu_hit::kTabPrev) tab_left = true; else if (hit.part == menu_hit::kTabNext) tab_right = true; @@ -8856,7 +9373,7 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move else if (hit.part == menu_hit::kTab && hit.index >= 100 && hit.index < 100 + kModsCats) mods_cat_pick = hit.index - 100; else if (hit.part == menu_hit::kTab && hit.index != kModsTab && hit.index >= 0 && hit.index < TAB_COUNT) page = 0, cur_tab = hit.index, changed = true; } - if (ptr.wheel) (mx >= mods_desc_x0 ? mods_desc_wheel : mods_wheel) += ptr.wheel, changed = true; // (over the details: theirs) + if (ptr.wheel && !bar) (mx >= mods_desc_x0 ? mods_desc_wheel : mods_wheel) += ptr.wheel, changed = true; // (over the details: theirs) } if (ptr.pressed & HOS_MOUSE_RIGHT) press[5] = true; } @@ -8865,41 +9382,41 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move return; } if (!mods::accepted()) { // (the warning: I understand, or Not now) - if (press[1] || press[2] || press[3] || press[4]) mods_btn ^= 1, changed = true, mods_sound(HOS_MENU_SOUND_CURSOR); + if (press[1] || press[2] || press[3] || press[4]) mods_btn ^= 1, changed = true, mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); if (press[7] && mods_btn == 0) { mods::accept(); logf("mods: the warning accepted"); mods_open_page(); - changed = true, mods_sound(HOS_MENU_SOUND_DECIDE); + changed = true, mods_sound(HOS_MENU_SOUND_MODS_SELECT); } else if (press[5] || press[7]) { // (Not now: back to the game's list) - mods_sound(HOS_MENU_SOUND_CANCEL); + mods_sound(mods_back_sound()); mods_back(changed); } return; } if (busy) { // (only Cancel) - if (press[5] || press[7]) mods::cancel(), changed = true, mods_sound(HOS_MENU_SOUND_CANCEL); + if (press[5] || press[7]) mods::cancel(), changed = true, mods_sound(HOS_MENU_SOUND_MODS_BACK); return; } if (ended) { if (inst.job == mods::Job::Done && inst.kit) { // ((Triforce) 11-18) a kit started: OK alone - if (press[5] || press[7]) mods::clear_done(), mods_btn = 0, changed = true, mods_sound(HOS_MENU_SOUND_DECIDE); + if (press[5] || press[7]) mods::clear_done(), mods_btn = 0, changed = true, mods_sound(HOS_MENU_SOUND_MODS_SELECT); } else if (inst.job == mods::Job::Done) { - if (press[1] || press[2] || press[3] || press[4]) mods_btn ^= 1, changed = true, mods_sound(HOS_MENU_SOUND_CURSOR); + if (press[1] || press[2] || press[3] || press[4]) mods_btn ^= 1, changed = true, mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); if (press[7] && mods_btn == 0) { // (Restart Now: as the restart question's, everything saved first) logf("mods: restart now, to load %s", inst.mod_name.c_str()); mods::clear_done(); - mods_sound(HOS_MENU_SOUND_DECIDE); + mods_sound(HOS_MENU_SOUND_MODS_SELECT); save(); pipeline_cache_save(true); memory_trial_orderly_end(); open_now = false, page = 0, changed = true; PostMessageA(app_window(), WM_APP + 9, 0, 0); } else if (press[5] || press[7]) { - mods::clear_done(), mods_btn = 0, changed = true, mods_sound(HOS_MENU_SOUND_CANCEL); + mods::clear_done(), mods_btn = 0, changed = true, mods_sound(HOS_MENU_SOUND_MODS_BACK); } } else if (press[5] || press[7]) { - mods::clear_done(), mods_btn = 0, changed = true, mods_sound(HOS_MENU_SOUND_CANCEL); + mods::clear_done(), mods_btn = 0, changed = true, mods_sound(HOS_MENU_SOUND_MODS_BACK); } return; } @@ -8912,7 +9429,7 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move else if (cp == 127) edited |= !mods_query.empty(), mods_query.clear(); else if (cp >= 0x20 && mods_query.size() < 100) utf8_add(mods_query, cp), edited = true; } - if (edited && !mods_kbd) mods_sound(HOS_MENU_SOUND_CURSOR); // ((Triforce, 11-18) a character typed; the host's + if (edited && !mods_kbd) mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); // ((Triforce, 11-18) a character typed; the host's // cursor gap keeps fast typing from stacking) if (edited && !mods_kbd && mods_choice != -1) mods_choice = -1, mods_follow = true; // (typing: the cursor on the bar) if (mods_kbd && !pad_last && !kbd_click && (press[7] || press[5])) { @@ -8930,7 +9447,7 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move if (mods_kbd_row == 4) mods_kbd_col = kKbdWideAt[(kbd_wide(mods_kbd_col) + (press[4] ? 1 : 3)) % 4]; else mods_kbd_col = (mods_kbd_col + (press[4] ? 1 : 9)) % 10; } - if (mods_kbd_row != was_row || mods_kbd_col != was_col) changed = true, mods_sound(HOS_MENU_SOUND_CURSOR); + if (mods_kbd_row != was_row || mods_kbd_col != was_col) changed = true, mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); if (press[7]) { if (mods_kbd_row < 4) { if (mods_query.size() < 100) utf8_add(mods_query, kKbdRows[mods_kbd_row][mods_kbd_col]), edited = true; @@ -8941,12 +9458,12 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move else if (k == 2) edited |= !mods_query.empty(), mods_query.clear(); else if (k == 3) search_now = true, mods_kbd = false; } - changed = true, mods_sound(search_now ? HOS_MENU_SOUND_DECIDE : HOS_MENU_SOUND_CURSOR); // (a key pressed) + changed = true, mods_sound(search_now ? HOS_MENU_SOUND_MODS_SELECT : HOS_MENU_SOUND_MODS_NAVIGATE); // (a key pressed) } if (press[5]) { // (Back: a character off; with none left the keyboard shut) if (!mods_query.empty()) edited |= utf8_pop(mods_query); else mods_kbd = false; - changed = true, mods_sound(mods_kbd ? HOS_MENU_SOUND_CURSOR : HOS_MENU_SOUND_CANCEL); + changed = true, mods_sound(mods_kbd ? HOS_MENU_SOUND_MODS_NAVIGATE : HOS_MENU_SOUND_MODS_BACK); } press[7] = press[5] = false; for (int i = 1; i <= 4; i++) press[i] = false; @@ -8999,12 +9516,12 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move else if (press[16]) at = n - 1; else at = std::clamp(at + (press[2] - press[1]) + (press[14] - press[13]) * mods_page_rows, -1, std::max(n - 1, -1)); mods_choice = at >= 0 ? vis[at] : -1; - if (mods_choice != was) mods_follow = true, changed = true, mods_sound(HOS_MENU_SOUND_CURSOR); + if (mods_choice != was) mods_follow = true, changed = true, mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); if (mods_choice >= 0) { mods::Mod& m = mods::list()[mods_choice]; const int files = (int)m.files.size(); if ((press[3] || press[4]) && files > 1) - m.file_choice = (m.file_choice + files + (press[4] ? 1 : -1)) % files, changed = true, mods_sound(HOS_MENU_SOUND_CURSOR); + m.file_choice = (m.file_choice + files + (press[4] ? 1 : -1)) % files, changed = true, mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); if (press[7] && m.details_state == 2 && files) install = mods_choice; } else if (press[7]) { // (Confirm on the bar: tried again after a failure; else the on-screen keyboard (a pad), or the results) if (feed == mods::Feed::Failed) retry = true; // ((Triforce) 11-18: also a list that stopped with cards in it) @@ -9015,14 +9532,14 @@ void mods_tick(bool* press, bool tab_left, bool tab_right, bool mouse, bool move mods::unlock(); if (install >= 0) { mods::install(install); - mods_btn = 0, changed = true, mods_sound(HOS_MENU_SOUND_DECIDE); + mods_btn = 0, changed = true, mods_sound(HOS_MENU_SOUND_MODS_SELECT); } else if (retry) { // (try again: the search, or the list; (Triforce) 11-18: a list that stopped on a page goes on from it) if (searching) mods_retire(mods::search(mods::search_text())); else if (n_all) mods::load_more(); else mods_retire(mods::open()); - changed = true, mods_sound(HOS_MENU_SOUND_CURSOR); + changed = true, mods_sound(HOS_MENU_SOUND_MODS_NAVIGATE); } else if (keyboard) { - mods_kbd = true, mods_kbd_row = 1, mods_kbd_col = 0, changed = true, mods_sound(HOS_MENU_SOUND_DECIDE); + mods_kbd = true, mods_kbd_row = 1, mods_kbd_col = 0, changed = true, mods_sound(HOS_MENU_SOUND_MODS_SELECT); } // ((Triforce) 11-18) the next pages: asked for by the engine one after another (vk_mods.cpp fetch_page), not by the cursor if (feed == mods::Feed::Loading) changed = true; // (drawn again as it comes) @@ -9042,6 +9559,8 @@ void mic_test_tick(bool focused) { mic_test_state = host && host->mic_test ? host->mic_test(mic_testing, mic_levels) : 0; if (!(mic_test_state & HOS_MIC_TEST_ON)) mic_testing = false, mic_test_state = 0; } +// ((Triforce, 11-26) a held Up or Down: its first repeat and each after, the game's own Options screen's (the owner's clip)) +constexpr int64_t kNavFirstNs = 330000000LL, kNavStepNs = 135000000LL; void menu_tick() { std::lock_guard bridge_lk(menu_mu); // ((Triforce) the control bridge's settings: menu_setting_set) auto_tick(); // ((Triforce) Auto (this PC): a step its tuning asked for @@ -9060,27 +9579,29 @@ void menu_tick() { bool entered_by_down = false; static int64_t mods_down_repeat_ns = 0; // (the held Down's repeat onto Mods, word 5: when; 0 none) if (const int enter = mods_enter.exchange(0, std::memory_order_relaxed)) { - if (!open_now.load() && mods_list_fresh()) { - // ((Triforce, 11-19) a click on the title's entry: the game's Decide on it first, then the Mods screen (as A, below)) + if (enter == 6 || enter == 7) { // ((Triforce) a test's scripted X or Y on the title: its Mods or Save Select tab) + if (!title_tab_go(enter - 6)) logf("menu: the host's word %d for a tab of the title not taken", enter); + } else if (!open_now.load() && mods_list_fresh() && !(mods_title_list() && (enter == 3 || enter == 4))) { + // ((Triforce, 11-19) a click on the title's entry: the game's Decide on it first, then what it is for (as A, below): + // Quit Game now) const bool decide = enter == 2 && mods_title_list(); open_now = true, embed_open = false, listening = 0, mods_btn = 0, mods_follow = true; page = enter == 2 && !decide ? kModsPage : kModsRowPage; // ((Triforce) 11-19: 3, Quit clicked: its dialog opens; 4, the mouse moved onto Quit: it has the cursor) mods_row_sel = enter == 3 || enter == 4 ? 1 : 0, quit_gone(), quit_sel = 0; if (enter == 3 && !mods_title_list()) quit_open(); - if (enter == 3 && files_row_shown()) files_open(true); // ((Triforce) on the title it is Save Select: the file select at once) entered_by_down = enter == 1 || enter == 5; // ((Triforce, 11-19) 5: a Down held from higher up the game's list, its repeat onto Mods: held on, it repeats // on at the step (the repeat below takes it as held past the first delay), as the game's list went on) mods_down_repeat_ns = enter == 5 ? prof_now() : 0; if (enter == 2 && !decide) mods_open_page(); - if (decide) mods_decide_ns = prof_now(); + if (decide) mods_decide_ns = prof_now(), title_decide = 1; auto_pad = pad_last; ui::want_glyphs(); // (its own: before the options' state is taken. (Triforce, 11-17) the system menu's, as the game's list it is under) const bool clicked = enter == 2 || enter == 3; mods_sound(clicked ? HOS_MENU_SOUND_SYS_DECIDE : HOS_MENU_SOUND_SYS_CURSOR); - logf("menu: the %s entry %s%s", enter == 3 || enter == 4 ? "Quit" : "Mods", clicked ? "clicked" : "has the cursor", + logf("menu: the %s entry %s%s", enter == 3 || enter == 4 ? "Quit" : mods_title_list() ? "Quit Game" : "Mods", clicked ? "clicked" : "has the cursor", enter == 5 ? " (a held Down's repeat)" : ""); menu_refresh = true; } else { // ((Triforce, 11-19) a word not taken says so: the lab's lost Down left no line) @@ -9166,6 +9687,45 @@ void menu_tick() { pad_clear = HOS_PAD_NORTH; for (int k = 3; k >= 0; k--) if (order[k] != pad_confirm && order[k] != pad_back) pad_clear = order[k]; + // ((Triforce, 11-26) the options' Apply: the input bound to the Switch's X where the menu has no other use for it (not + // confirm or back, the tuning bar's left face button, the D-pad, the shoulders and triggers that are the tabs, Home, + // Select and Start), else the first face button of those order has that is free) + const auto taken = [&](int p) { + return p == pad_confirm || p == pad_back || p == HOS_PAD_WEST || p == HOS_PAD_UP || p == HOS_PAD_DOWN || p == HOS_PAD_LEFT || + p == HOS_PAD_RIGHT || p == HOS_PAD_GUIDE || p == HOS_PAD_BACK || p == HOS_PAD_START || p == HOS_PAD_LSHOULDER || + p == HOS_PAD_RSHOULDER || p == HOS_PAD_LTRIGGER || p == HOS_PAD_RTRIGGER; + }; + const int x = host && host->binding ? host->binding(HOS_BIND_PAD, HOS_SW_X, 0) : HOS_PAD_NORTH; + pad_apply = hos_pad_bindable(x) && !taken(x) ? x : -1; + for (int k = 0; k < 4 && pad_apply < 0; k++) + if (!taken(order[k])) pad_apply = order[k]; + } + { // ((Triforce, 11-26) and on the keys: the key bound to the Switch's X (Space unless rebound) the menu takes, else Space, + // else F: the first not a key the menu takes for the tabs or Back (the Switch's L, R and B as bound: menu_bound_key) + const auto taken = [](int k) { + for (const int b : {HOS_SW_L, HOS_SW_R, HOS_SW_B}) + for (int slot = 0; slot < 2; slot++) + if (menu_bound_key(b, slot) == k) return true; + return false; + }; + apply_key = 0; + for (const int k : {menu_bound_key(HOS_SW_X, 0), menu_bound_key(HOS_SW_X, 1), (int)VK_SPACE, (int)'F'}) + if (k && !taken(k)) { + apply_key = k; + break; + } + } + bool apply_press = false; // ((Triforce, 11-26) the options' Apply asked for at this tick: page 0's, below. Read there alone: + // the Controls page's binding takes any key, Space too, and the Mods search takes text + { + static bool held = false; + const bool open = open_now.load() && page == 0 && listening == 0 && !menu_mods_typing(); + const bool down = open && mine && apply_key && (GetAsyncKeyState(apply_key) & 0x8000) != 0; + const bool queued = open && apply_key && host && host->take_key_press && host->take_key_press(apply_key) && mine; + apply_press = !held && (down || queued); + held = down; + if (apply_press) pad_last = false; + if (open && pad_apply >= 0 && pad(pad_apply)) apply_press = true; } if (pad(HOS_PAD_GUIDE) || chord_now) press[0] = true; // (Menu shortcut's touchpad choices: a DualShock 4's or DualSense's touchpad click is F1, it opens and closes the menu as @@ -9225,7 +9785,13 @@ void menu_tick() { if (game_keys_new) pad_last = false; } { // holding an arrow or the D-pad repeats it: after 0.35 s, 12 a second, then 30 a second after 1.5 s held + // ((Triforce, 11-26) Up and Down at the game's own pace: the owner's clip of the game's Options, a direction held, moves + // 330 ms after the first, then each 135 ms, and no faster held longer ("match the game's vanilla's navigation + // effects": its cursor sound rings on under the next, which at 12 or 30 a second ran together). Left and Right, which + // change a value, as before) static int64_t held_since[5], next_repeat[5]; + const auto first_ns = [](int dir) { return dir <= 2 ? kNavFirstNs : 350000000LL; }; + const auto step_ns = [](int dir, int64_t held) { return dir <= 2 ? kNavStepNs : held > 1500000000LL ? 33000000LL : 83000000LL; }; const int pads[5] = {0, HOS_PAD_UP, HOS_PAD_DOWN, HOS_PAD_LEFT, HOS_PAD_RIGHT}; // ((Triforce) 11-17, his "you cannot go up from mods ... with the analog stick": the left stick as the D-pad) const int sticks[5] = {0, HOS_PAD_LS_UP, HOS_PAD_LS_DOWN, HOS_PAD_LS_LEFT, HOS_PAD_LS_RIGHT}; @@ -9242,13 +9808,13 @@ void menu_tick() { if (!down) { held_since[i] = 0; continue; } if (!held_since[i] && i == 2 && mods_down_repeat_ns && t - mods_down_repeat_ns < 250000000LL) { // ((Triforce, 11-19) the held Down that came onto Mods by repeat: past the first delay already, on at the step) - held_since[i] = t - 350000000LL, next_repeat[i] = t + 83000000LL, mods_down_repeat_ns = 0; + held_since[i] = t - first_ns(i), next_repeat[i] = t + step_ns(i, first_ns(i)), mods_down_repeat_ns = 0; continue; // (a script's held Down is told at the host's next read: a quarter second for it) } - if (!held_since[i]) { held_since[i] = t, next_repeat[i] = t + 350000000LL; continue; } + if (!held_since[i]) { held_since[i] = t, next_repeat[i] = t + first_ns(i); continue; } if (t >= next_repeat[i] && open_now.load() && listening == 0) { press[i] = true; - next_repeat[i] = t + (t - held_since[i] > 1500000000LL ? 33000000LL : 83000000LL); + next_repeat[i] = t + step_ns(i, t - held_since[i]); } } } @@ -9268,6 +9834,7 @@ void menu_tick() { if (next && sscanf(next, "%lf:%7[A-Z]%n", &at, key, &n) == 2 && (prof_now() - start) / 1e9 >= at) { static const char* names[] = {"INS", "UP", "DOWN", "LEFT", "RIGHT", "ESC", "", "ENTER", "", "", "TABL", "TABR"}; for (int i = 0; i < 12; i++) press[i] |= *names[i] && !strcmp(key, names[i]); + if (!strcmp(key, "APPLY")) apply_press = true; // ((Triforce, 11-26) the options' Apply, as its key) script_tab = !strcmp(key, "TABL") ? -1 : !strcmp(key, "TABR") ? 1 : 0; static const char* pads[] = {"PADS", "PADE", "PADW", "PADN"}; for (int p = 0; p < 4; p++) @@ -9503,16 +10070,86 @@ void menu_tick() { last_x = mx, last_y = my, mouse_read = true; // menu as it opens leaves the selection alone) if (moved) pad_last = false; if (!mouse) ptr.pressed = 0, ptr.wheel = 0; + // ((Triforce) a page slider held (bar_mouse) is let go with the button, on whatever page and wherever the cursor is + // by then; and none is lit while the cursor is off the window) + if (bar_held >= 0 && !(ptr.held & HOS_MOUSE_LEFT)) bar_held = -1, changed = true; + if (!mouse && bar_held < 0 && bar_hover >= 0) bar_hover = -1, changed = true; if (ptr.pressed || ptr.wheel) // (a click or the wheel with a modifier bound to L, R or B held: it is no press of its own) for (auto& armed : bound_armed) armed[0] = armed[1] = false; } + // ((Triforce) the title's tabs (title_tabs.h, draw_title_tabs), with the menu shut over the title's list or the cursor on + // Quit Game under it. A controller: the buttons the Switch's X and Y are bound to, read from the pad itself (a key or a + // mouse button bound to them is not it: the left mouse button is Y by default). The mouse: the tab under it lit once it + // moves there, until it leaves or a controller is used; a click on one chooses it. The window keeps the title's left + // clicks for this (host/display.c game_menu_press), as it does the game's Options screen's for our tabs there) + if (title_tabs_live()) { + ui::want_glyphs(); // (the game's button icons, for the prompts under them) + int go = -1; + for (int i = 0; i < title_tabs::kTabs && go < 0 && host && host->binding; i++) { + const int p = host->binding(HOS_BIND_PAD, i ? HOS_SW_Y : HOS_SW_X, 0); + if (hos_pad_bindable(p) && (pad_press >> p & 1)) go = i, pad_last = true; + } + MkwVkPointer tp = ptr; + bool on = mouse, tab_moved = moved; + if (!open_now.load() && host && host->pointer) { // (shut: the mouse was not read above) + on = host->pointer(&tp) != 0; + if (!title_tab_read) tp.pressed = 0; + static int last_x = -1, last_y = -1; + tab_moved = on && title_tab_read && (tp.x != last_x || tp.y != last_y); + last_x = tp.x, last_y = tp.y; + } + title_tab_read = true; + int ix = 0, iy = 0; + menu_hit::to_image(tp.x, tp.y, tp.width, tp.height, (int)dev.swap_extent.width, (int)dev.swap_extent.height, &ix, &iy); + if (options_under_tv) n64_screen_point(&ix, &iy, (int)dev.swap_extent.width, (int)dev.swap_extent.height); + const int under = on ? title_tabs::at(title_tab_layout, title_tab_map.back_x((float)ix), title_tab_map.back_y((float)iy)) : -1; + int hover = title_tab_hover; + if (pad_press || under < 0) hover = -1; // (a controller in use, or the mouse off them) + else if (tab_moved || (tp.pressed & HOS_MOUSE_LEFT)) hover = under; + // ((Triforce, 11-26) the owner: "When the cursor hovers over the mod and save select, it doesn't play a sound. It should + // play SE_Sys_SysMenu_Cursor00": the mouse onto a tab is a move onto it, with the system menu's cursor sound, as the + // title's own entries under the mouse have. Not when it goes off them, nor with the click that comes with it (the + // tab's decide is the sound then: title_tab_go) + if (hover >= 0 && hover != title_tab_hover && !(tp.pressed & HOS_MOUSE_LEFT)) mods_sound(HOS_MENU_SOUND_SYS_CURSOR); + if (hover != title_tab_hover) title_tab_hover = hover, changed = true; + if (go < 0 && on && (tp.pressed & HOS_MOUSE_LEFT) && under >= 0) go = under, pad_last = false; + if (go >= 0 && title_tab_go(go)) { // (the press is the tab's alone: nothing of it for the page it opens) + for (int i = 0; i < K_N; i++) press[i] = false; + tab_left = tab_right = false, changed = true; + ptr.pressed = 0, ptr.wheel = 0; + } + } else { + title_tab_hover = -1; + if (!mods_title_list() || !mods_list_fresh()) title_tab_read = false; // (read anew when the title's list comes again) + } // (closing with a setting that takes a restart changed: the restart question first, Later already chosen on it) auto later = [&] { + // ((Triforce, 11-26) and with one Apply waits for: Apply's question before it, on the same page (ask_first). Its Later + // keeps the choice for the next start as the restart question's does; then the restart question when one waits too, + // unless the options' keys (Insert, F1, Home) closed them: then that waits for the next close) int now[mr::kMax]; + if (ask_kind == kQuestionApply) { + apply_values(now); + apply_state.choose_later(now); + if (!press[0] && !press[6] && restart_ask()) { + ask_kind = kQuestionRestart, ask_sel = 0, changed = true; + return; + } + open_now = false, page = 0, ask_kind = kQuestionRestart, changed = true; + return; + } restart_values(now); restart_state.choose_later(now); open_now = false, page = 0, changed = true; }; + // ((Triforce, 11-26) the question to ask on a close: Apply's first, then the restart question; false: none) + auto ask_first = [&] { + if (apply_ask()) ask_kind = kQuestionApply; + else if (restart_ask()) ask_kind = kQuestionRestart; + else return false; + page = 5, ask_sel = 0, listening = 0, changed = true; + return true; + }; // (Triforce) Setup chooses the settings before the game starts, and the menu was hidden for that. 11-10: on by default again, // for upstream's new rows that Setup has no place for yet. TRIFORCE_INGAME_MENU=0 (triforce_env.txt) hides it: Insert, F1, // Home and Select+Start then open nothing @@ -9542,8 +10179,8 @@ void menu_tick() { if (esc_opens) press[5] = false; if ((press[0] || press[6]) && open_now.load() && page == 5) { later(); - } else if ((press[0] || press[6]) && open_now.load() && restart_ask()) { - page = 5, ask_sel = 0, listening = 0, changed = true; + } else if ((press[0] || press[6]) && open_now.load() && ask_first()) { + // (the question, above) } else if (((press[0] || press[6]) && (menu_allowed || open_now.load())) || esc_opens) { open_now = !open_now.load(), changed = true; page = 0, listening = 0; @@ -9579,6 +10216,11 @@ void menu_tick() { if (press[1] || press[2] || press[3] || press[4] || tab_left || tab_right) ask_sel ^= 1, changed = true; if (press[5] || (press[7] && ask_sel == 0)) { later(); + } else if (press[7] && ask_kind == kQuestionApply) { // ((Triforce, 11-26) Apply Now: then the restart question, if one waits) + menu_apply("the question's Apply Now"); + if (restart_ask()) ask_kind = kQuestionRestart, ask_sel = 0; + else open_now = false, page = 0, ask_kind = kQuestionRestart; + changed = true; } else if (press[7]) { // (Restart now: everything saved, then the window closes as the player would close it) logf("menu: restart now, to apply %s", restart_list(", ").c_str()); save(); @@ -9649,7 +10291,9 @@ void menu_tick() { } else { if (mouse) { // (the mouse: the row under it selected, a click on a binding listens for its new input, on // Reset resets; the wheel scrolls the page, a right click goes back) - const menu_hit::Hit hit = hits.at((float)mx, (float)my); + menu_hit::Hit hit = hits.at((float)mx, (float)my); + // ((Triforce) its page slider held: the rows follow the cursor, and nothing else is the mouse's (bar_mouse)) + if (bar_mouse(ptr, my, hit, changed)) hit = menu_hit::Hit{}, ptr.wheel = 0; const bool option = hit.part == menu_hit::kCtlOption; const bool on = option || hit.part == menu_hit::kCtlRow || hit.part == menu_hit::kCtlCell; const int at = option ? hit.index : kTop + hit.index; // (the page's row: its own rows first) @@ -9700,7 +10344,7 @@ void menu_tick() { } } else if (open_now.load() && page == 4) { // the inventory const int chosen = item_choice; // (the page follows the choice when it moves; the wheel's page stays otherwise) - if (mouse) inventory_mouse(ptr, mx, my, press, changed); + if (mouse) inventory_mouse(ptr, mx, my, moved, press, changed); if (press[5] && inventory_amount) inventory_amount = false, changed = true; // (back: out of the amount first) else if (press[5]) page = 0, changed = true; // (to the Debug tab, Inventory still selected) else if (tab_left || tab_right) { // (another section, from editing an amount too: that ends) @@ -9735,10 +10379,10 @@ void menu_tick() { if (item_choice != chosen) inventory_reveal(); // (a click on a card: its page) } } else if (open_now.load() && page == 6) { // (Triforce) a name page: Game flags, Cutscenes, Scan amiibo - if (mouse) names_mouse(ptr, mx, my, press, changed); + if (mouse) names_mouse(ptr, mx, my, moved, press, changed); names_press(press, tab_left, tab_right, changed); } else if (open_now.load() && page == 3) { // the teleport list - if (mouse) teleport_mouse(ptr, mx, my, press, changed); + if (mouse) teleport_mouse(ptr, mx, my, moved, press, changed); if (press[5]) page = 0, changed = true; // (to the Debug tab, Teleport still selected) else if (press[7]) { cheat_action.store(1000 + teleport_choice); @@ -9760,17 +10404,28 @@ void menu_tick() { } } else if (open_now.load() && page == kFilesPage) { // (Triforce) the file select: the choice moves, confirm plays the file const int n = save_files.shown(); - if (mouse) { // (a card chosen by a click, the button plays it; a right click goes back) + // ((Triforce, 11-26) nothing taken while its In plays, as the game's own screens (and the Mods screen) take none) + static const bool still_files = getenv("RX_VK_UI_STILL") != nullptr; + if (!files_screen.ready(prof_now()) && ease_live && !still_files) { + for (int i = 0; i < K_N; i++) press[i] = false; + ptr.pressed = 0; + } + if (mouse) { // (the card under the mouse chosen, a click on it plays it; a right click goes back) + // ((Triforce, 11-25) the page's own Play button is gone (the owner's "fix the out-of-place buttons"): the chosen + // card is the button, as the game's Load list takes a click. ((11-26) The owner: "add hovering effects, so when you + // move your cursor on one of the saves, it will navigate to that automatically": the mouse moved onto a card + // chooses it, with the move's sound, as the game's lists take the mouse) const menu_hit::Hit hit = hits.at((float)mx, (float)my); - if ((ptr.pressed & HOS_MOUSE_LEFT) && hit.part == menu_hit::kListLine && hit.index >= 0 && hit.index < n && files_wait < 0) - changed |= files_choice != hit.index, files_choice = hit.index; - else if ((ptr.pressed & HOS_MOUSE_LEFT) && hit.part == menu_hit::kButton && hit.index == 0) press[7] = true; + const bool on_card = hit.part == menu_hit::kListLine && hit.index >= 0 && hit.index < n && files_wait < 0; + if (on_card && (moved || ptr.pressed) && files_choice != hit.index) files_choice = hit.index, changed = true; + else if (on_card && (ptr.pressed & HOS_MOUSE_LEFT)) press[7] = true; if (ptr.pressed & HOS_MOUSE_RIGHT) press[5] = true; } - // (Back from the title's: the cursor on Save Select again; Play there, or the list gone: the game's list. From its row: - // the System tab, the row still selected) + // (Back from the title's, or Play there: the game's list again, the menu shut ((Triforce) Save Select is a tab, which + // never has the cursor; Back sounds as a step back, not as the menu closing). From its row: the System tab, the row + // still selected) const auto leave = [&](bool play) { - if (files_at_title && !play && mods_list_fresh() && files_row_shown()) page = kModsRowPage, mods_row_sel = 1; + if (files_at_title && !play) open_now = false, page = 0, mods_sound(HOS_MENU_SOUND_SETTINGS_BACK), tick_sound_done = true; else if (files_at_title) open_now = false, page = 0; else page = 0; changed = true; @@ -9800,13 +10455,16 @@ void menu_tick() { if (!mods_list_fresh()) mods_decide_ns = 0, open_now = false, page = 0, changed = true; else if (prof_now() - mods_decide_ns >= mods_entry::kDecideNs) { mods_decide_ns = 0, mods_decided = true; - page = kModsPage, mods_btn = 0, mods_follow = true, changed = true; - mods_open_page(); + if (title_decide == 1) { // ((Triforce) Quit Game's: the game ends, as Quit Game of the pause menu's dialog) + end_game(false), quit_ended = true, open_now = false, page = 0, changed = true; + } else { + page = kModsPage, mods_btn = 0, mods_follow = true, changed = true; + mods_open_page(); + } } } else if (open_now.load() && page == kModsRowPage) { // (Triforce) the cursor on the entries under the game's list const bool quit_here = quit_entry_shown(); - const bool files_here = files_row_shown(); // ((Triforce) on the title Save Select is under Mods, as Quit is here) - if (!quit_here && !files_here) mods_row_sel = 0; + if (!quit_here) mods_row_sel = 0; // ((Triforce) the title's list has the one entry, Quit Game) if (!quit_here) quit_gone(); // ((Triforce, 11-19) the dialog takes input once its In has played, as the game's: what comes before is not kept) const bool quit_ready = quit_ask && focus_anim::window_ready(prof_now() - quit_open_ns); @@ -9836,19 +10494,15 @@ void menu_tick() { if (press[1] && quit_sel > 0) quit_sel--, mods_sound(HOS_MENU_SOUND_SYS_CURSOR), changed = true; else if (press[2] && quit_sel < 2) quit_sel++, mods_sound(HOS_MENU_SOUND_SYS_CURSOR), changed = true; else if (press[7]) { - mods_sound(quit_sel == 2 ? HOS_MENU_SOUND_CANCEL : HOS_MENU_SOUND_SYS_DECIDE); + mods_sound(quit_sel == 2 ? HOS_MENU_SOUND_PAUSE_BACK : HOS_MENU_SOUND_SYS_DECIDE); if (quit_sel == 2) quit_cancel(); else end_game(quit_sel == 1), quit_gone(), quit_ended = true, open_now = false, page = 0; changed = true; - } else if (press[5] || press[0] || press[6]) quit_cancel(), mods_sound(HOS_MENU_SOUND_CANCEL), changed = true; + } else if (press[5] || press[0] || press[6]) quit_cancel(), mods_sound(HOS_MENU_SOUND_PAUSE_BACK), changed = true; press[1] = press[2] = press[5] = press[0] = press[6] = false, tab_left = tab_right = false; - } else if (press[7] && files_here && mods_row_sel == 1) { // ((Triforce) A on Save Select: the file select) - files_open(true), mods_sound(HOS_MENU_SOUND_SYS_DECIDE), changed = true; - } else if (press[2] && files_here && mods_row_sel == 0) { // ((Triforce) Down from the title's Mods: Save Select) - mods_row_sel = 1, mods_sound(HOS_MENU_SOUND_SYS_CURSOR), changed = true; - } else if (press[7]) { // (A: Mods opens; on Quit its dialog) + } else if (press[7]) { // (A: Mods opens; on Quit its dialog; (Triforce) on the title it is Quit Game: its Decide, then the game ends) if (mods_row_sel == 1) quit_open(), mods_sound(HOS_MENU_SOUND_SYS_DECIDE), changed = true; - else if (mods_title_list()) mods_decide_ns = prof_now(), mods_sound(HOS_MENU_SOUND_SYS_DECIDE), changed = true; // (its Decide first) + else if (mods_title_list()) mods_decide_ns = prof_now(), title_decide = 1, mods_sound(HOS_MENU_SOUND_SYS_DECIDE), changed = true; // (its Decide first) else { page = kModsPage, mods_btn = 0, mods_follow = true, changed = true; mods_open_page(); @@ -9866,7 +10520,11 @@ void menu_tick() { if (mods_screen.ready(prof_now())) mods_tick(press, tab_left, tab_right, mouse, moved, ptr, mx, my, changed); } else if (open_now.load()) { if (mouse) { // (the mouse: see the top of this file) - const menu_hit::Hit hit = hits.at((float)mx, (float)my); + menu_hit::Hit hit = hits.at((float)mx, (float)my); + // ((Triforce) the rows' page slider, the scroll bar at their left: a press on it holds it and the rows follow the + // cursor (bar_mouse). While it is held the mouse is its alone: no tab lit, no row chosen under the cursor, no + // click and no wheel. Not while a row's slider is held: that one has the mouse then) + if (drag_row < 0 && bar_mouse(ptr, my, hit, changed)) hit = menu_hit::Hit{}, ptr.wheel = 0; const int ht = hit.part == menu_hit::kTab ? (hit.index == kGameTab ? -1 : hit.index) : hit.part == menu_hit::kTabPrev ? TAB_COUNT : hit.part == menu_hit::kTabNext ? TAB_COUNT + 1 : -1; if (ht != hover_tab) hover_tab = ht, changed = true; @@ -9900,6 +10558,8 @@ void menu_tick() { const int v = menu_hit::slider_value(hit.permille, d.lo, d.hi, d.step); if (v != *d.value) set_row(d, v, v > *d.value ? 1 : -1, false); changed = true; + } else if (hit.part == menu_hit::kButton && hit.index == kApplyGuide) { + apply_press = true; // ((Triforce, 11-26) the Apply guide clicked: as its key, below) } else if (hit.part == menu_hit::kRow) { Row& d = rows[tab_row_to_global(cur_tab, hit.index)]; if (!d.value && d.cheat >= 0 && (cheat_chooses(d.cheat) || age_shown(d.cheat) || d.cheat <= 1 || d.cheat == 7) && @@ -9961,6 +10621,14 @@ void menu_tick() { } size_text_wanted.store(size_row, std::memory_order_relaxed); } + // ((Triforce, 11-26) the options' Apply, its guide's key, button or click, while a row waits for it (draw_options): the + // game's 3D and the upscaler made again at the next frame. Its sound the settings' Select, which a tick that changed + // nothing on the page would not name) + if (apply_press && !size_edit && listening == 0 && apply_pending()) { + menu_apply("the guide"); + mods_sound(HOS_MENU_SOUND_SETTINGS_SELECT); // (the queue's put, Menu sounds above 0 alone) + tick_sound_done = true, changed = true; + } if (press[5] && cur_tab == TAB_MOTION) cur_tab = TAB_CONTROLS, press[5] = false, changed = true; // (back) if (press[5] && cur_tab == TAB_N64) cur_tab = TAB_GRAPHICS, press[5] = false, changed = true; // ((Triforce, N64 Classic) back) if (press[5] && cur_tab == TAB_SIM_TURF) cur_tab = TAB_GRAPHICS, press[5] = false, changed = true; // ((Triforce, 11-24) back) @@ -9968,7 +10636,7 @@ void menu_tick() { else if (press[5] && cur_tab == TAB_MOTION) cur_tab = TAB_CONTROLS, press[5] = false, changed = true; // (back) else if (press[5] && cur_tab == TAB_N64) cur_tab = TAB_GRAPHICS, press[5] = false, changed = true; // ((Triforce, N64 Classic)) else if (press[5] && cur_tab == TAB_SIM_TURF) cur_tab = TAB_GRAPHICS, press[5] = false, changed = true; // ((Triforce, 11-24)) - else if (press[5] && restart_ask()) page = 5, ask_sel = 0, changed = true; // (the restart question first) + else if (press[5] && ask_first()) {} // (Apply's question first, then the restart question: ((Triforce, 11-26)) ask_first) else if (press[5]) open_now = false; // (the tabs: LB and RB, Q and E, or Tab; from the Motion page, as from Controls) if ((tab_left || tab_right) && cur_tab == TAB_MOTION) cur_tab = TAB_CONTROLS; @@ -10064,9 +10732,16 @@ void menu_tick() { if (row_before) { if (after.open && after.page == kModsPage) { if (!mods_decided) mods_sound(HOS_MENU_SOUND_SYS_DECIDE); } // (the title's: at the press) else if (!after.open && !quit_ended) mods_sound(HOS_MENU_SOUND_SYS_CURSOR); // (not after Quit Game or Restart Game's decide) - } else if (sound_before.open || !after.open || after.page != kModsRowPage) { - if (opts.menu_sounds > 0) sound_queue.put(menu_sound::sound_of(sound_before, sound_state(), in), prof_now()); + } else if (!tick_sound_done && (sound_before.open || !after.open || after.page != kModsRowPage)) { + // ((Triforce, 11-25) whose cursor, decide and cancel it is: the settings' tabs', or the Mods screen's when the tick + // found it shown; its Back onto the pause menu's System list is that list's step back (menu_sound_events.h)) + const bool on_mods = sound_before.page == kModsPage; + const bool to_pause = after.open && after.page == kModsRowPage && mods_back_sound() == HOS_MENU_SOUND_PAUSE_BACK; + // ((Triforce, 11-25) and a toggle switched: its On or its Off (the owner, in the lab: "In the display, the on and off SFX are incorrect ... let me pick the correct SFX for the on and off selection for the settings") + const int sound = menu_sound::sound_for(menu_sound::sound_of(sound_before, after, in), on_mods, to_pause); + if (opts.menu_sounds > 0) sound_queue.put(menu_sound::toggle_sound(sound, sound_before, after), prof_now()); } + tick_sound_done = false; // ((Triforce) a title's tab chosen, or Back to the title's list: sounded where it was made) mods_decided = false; quit_ended = false; if (!open_now.load() || page != kModsRowPage) mods_decide_ns = 0; // (a Decide cut short: the menu shut by its keys) @@ -10076,6 +10751,8 @@ void menu_tick() { salesman::show(open_now.load() && page == kModsPage && mods::available() && mods::accepted(), salesman_w, salesman_h); if (open_now.load() && page == kModsPage) changed = true; // (he moves: drawn again) mods_screen.step(prof_now(), open_now.load() && page == kModsPage); // ((Triforce, 11-20) its In from the tick it came at) + files_screen.step(prof_now(), open_now.load() && page == kFilesPage); // ((Triforce, 11-26) and Save Select's + files_blur.store(open_now.load() && page == kFilesPage && files_at_title, std::memory_order_relaxed); { // (hookshot) the window lets the mouse go while the menu is open, and takes it back after (host/display.c) static bool told = false; const bool now_open = open_now.load(); @@ -10084,6 +10761,7 @@ void menu_tick() { sim_turf_flush(); // ((Triforce, 11-24) the Simulated turf page's file: written now, if it waits) if (!in_game_options) hover_tab = -1; // ((Triforce) on the game's own tab, the tabs' own: above) drag_row = -1, mouse_read = false; + bar_held = bar_hover = -1; // ((Triforce) a page slider held as the menu shut: let go) pending = nullptr; } if (now_open != told && app_window()) { diff --git a/gpu/vk/vk_menu.h b/gpu/vk/vk_menu.h index 63760e2..43c188b 100644 --- a/gpu/vk/vk_menu.h +++ b/gpu/vk/vk_menu.h @@ -243,6 +243,20 @@ extern int hdr_at_start; /// (Triforce) opts.renodx and opts.upscale_pre as the file had them at the start: what this run does (RX_VK_RENODX and /// RX_VK_DLSS_PRE, 0 or 1, over them) extern int renodx_at_start, upscale_pre_at_start; +/// ((Triforce, 11-26) the owner: "Every option that requires a restart should be changed in game ... implement an apply +/// option in the menu") The Upscaler, Render resolution and Upscale before bloom rows as they run: their values as the player +/// last applied them (the options' Apply, vk_menu.cpp menu_apply), the file's at the start. The rows themselves (opts.dlss, +/// opts.resolution, opts.upscale_pre) are what is chosen and saved. The renderer and the host read these, any thread: a +/// change remakes the game's 3D targets and the upscaler's own, so it is taken once, at Apply, not at each step of a row +int applied_dlss(); +int applied_resolution(); +int applied_upscale_pre(); +/// (the 3D at the output's full size: the applied Upscaler is an engine's native anti-aliasing. Its choice on this PC, the +/// switches over it, not what stands in for a while: an engine off after failures, N64 Classic's 3D pass) +bool resolution_full(); +/// ((Triforce, 11-26) the Frame pacing row's Steady frame rate now, opts.steady_fps (host/pace_steady.h PACE_STEADY_*): the host +/// reads it each frame, HOS_OPT_STEADY_ROW, so the row's Steady changes at once +int menu_steady_row(); /// Whether RenoDX's shaders run in this session: the RenoDX HDR row as it was at the start, or RX_VK_RENODX bool renodx_chosen(); /// (Triforce) opts.replay_threads as the file had it at the start, and the threads a value of that row stands for: 0 none, @@ -274,9 +288,12 @@ void menu_set_gpu_count(int count); const std::string& menu_gpu_name(); void menu_tick(); // (each frame shown: the keys, while the game's window has the focus) bool menu_is_open(); +/// ((Triforce, 11-26) the picture behind the menu wanted out of focus, whole: Save Select over the title, as the game's own +/// system menus there have the title blurred behind them (vk_framegen.cpp wide_sides). Any thread +bool menu_backdrop_blurred(); int menu_grass_distance(); // ((Triforce) the Grass distance row as now, for the recording threads: opts.grass_distance read atomically) -bool resolution_auto(); // (the game's dynamic resolution: Resolution Auto) -int resolution_scale(); // (the fixed path's scale in 1/10000: the Resolution row's, as a twelfth of the output) +bool resolution_auto(); // (the game's dynamic resolution: Resolution Auto, as applied) +int resolution_scale(); // (the fixed path's scale in 1/10000: the Resolution row's as applied, as a twelfth of the output) void menu_option_set(int id, int value); // (from the game's side: 7 the mouse's sensitivity, the - and = keys) int menu_setting(int index, MkwVkSetting* out); // ((Triforce) the control bridge, host/control.c: the rows with a value) int menu_setting_set(const char* key, int value, MkwVkSetting* out); diff --git a/gpu/vk/vk_menu_hit.h b/gpu/vk/vk_menu_hit.h index 2aafa40..fa50613 100644 --- a/gpu/vk/vk_menu_hit.h +++ b/gpu/vk/vk_menu_hit.h @@ -1,6 +1,7 @@ // The Insert menu's mouse: what a point over it is on. The menu records each control's rectangle as it draws it (Map::add, in // the window image's pixels), and the next frame's mouse is tested against them (Map::at): the picture and the hit-test cannot -// drift apart, at any size. Plain arithmetic, no Vulkan or ImGui: tests/test_menu_hit.cpp checks it. +// drift apart, at any size. Plain arithmetic, no Vulkan or ImGui: tests/test_menu_hit.cpp checks it, and +// tests/test_menu_page_slider.py the page sliders (Bar: the scroll bar beside a list, held and drawn along by the mouse). #pragma once namespace mkwvk::menu_hit { @@ -22,6 +23,7 @@ enum Part { kButton, // the restart question's buttons: index 0 Later, 1 Restart now kSearch, // ((Triforce) the Mods screen's search bar) kKey, // ((Triforce) a key of its on-screen keyboard: index row * 10 + column, the wide keys' row 4 by their first column) + kScroll, // ((Triforce) a list's page slider, the scroll bar beside it: index the list's number, Map::bar_of(index) the bar) }; struct Hit { Part part = kNone; @@ -51,6 +53,43 @@ inline int slider_permille(int v, int lo, int hi) { return p < 0 ? 0 : p > 1000 ? 1000 : p; } +/// ((Triforce) A list's page slider, the scroll bar beside it, as it was drawn: its track from y0 down to y1, beside a list n +/// long of which `shown` is in view, the first of it in view at `first` (rows, or pixels: the same unit for the three). Its +/// thumb is the part of the track the view is of the list. The mouse takes it as a touch slider: the thumb held with the +/// left button is drawn along with the cursor (grab at the press, drag while it is held), a press on the track off the +/// thumb brings the thumb's middle under the cursor first, so the list jumps to there, and is held the same way +struct Bar { + int id = -1; // (the list's number: the menu's own, vk_menu.cpp; -1 none) + float y0 = 0, y1 = 0; // (the track) + float n = 0, shown = 0, first = 0; // (the list) + float reach = 0; // (a short thumb is taken hold of this far either side of its middle, in pixels) + + /// (a list longer than its view, on a track that has a length: there is somewhere to scroll to) + bool scrolls() const { return y1 > y0 && shown > 0 && n > shown; } + /// (the furthest the first in view can go: the list's end at the view's) + float most() const { return scrolls() ? n - shown : 0; } + /// The thumb's top with f the first in view, and the thumb's length + float thumb(float f) const { return scrolls() ? y0 + (y1 - y0) * f / n : y0; } + float length() const { return scrolls() ? (y1 - y0) * shown / n : y1 - y0; } + /// The first in view with the thumb's top at y, held to the list's ends + float first_at(float y) const { + if (!scrolls()) return 0; + const float f = (y - y0) * n / (y1 - y0), m = most(); + return f < 0 ? 0 : f > m ? m : f; + } + /// A press at y: how far under the thumb's top the cursor has hold of it. On the thumb (a short one: within reach of its + /// middle), where the cursor is, so that the press alone moves nothing; elsewhere on the track, the thumb's middle, so + /// that the thumb comes under the cursor + float grab(float y) const { + const float top = thumb(first), len = length(); + float a = top, b = top + len; + if (len < 2 * reach) a = top + len / 2 - reach, b = top + len / 2 + reach; + return y >= a && y < b ? y - top : len / 2; + } + /// Held by `grab`, the cursor at y: the first in view, held to the list's ends wherever the cursor went + float drag(float y, float grab) const { return first_at(y - grab); } +}; + /// The controls as last drawn struct Map { struct Box { @@ -64,15 +103,32 @@ struct Map { }; static constexpr int kMax = 96; static constexpr float kGrab = 6; // (a click this far past either end of a track still takes the end, in pixels) + static constexpr int kBars = 4; // ((Triforce) the page sliders a page can have: the Mods screen has two) Box box[kMax]; int n = 0; float ax0 = 0, ay0 = 0, ax1 = 0, ay1 = 0; // (the menu's area: off it, kOutside) + Bar bar[kBars]; // ((Triforce) the page sliders drawn: add_bar, bar_of) + int bars = 0; - void clear(float x0, float y0, float x1, float y1) { n = 0, ax0 = x0, ay0 = y0, ax1 = x1, ay1 = y1; } + void clear(float x0, float y0, float x1, float y1) { n = 0, bars = 0, ax0 = x0, ay0 = y0, ax1 = x1, ay1 = y1; } void add(float x0, float y0, float x1, float y1, Part part, int index, float v0 = 0, float v1 = 0, float t0 = 0, float t1 = 0, int side = 0, float vm = 0) { if (n < kMax) box[n++] = {x0, y0, x1, y1, part, index, v0, v1, t0, t1, side, vm}; } + /// ((Triforce) A page slider as drawn: its box from x0 to x1 (the track, and room either side of it to take hold of it: + /// the track is thin), `past` pixels past the track's ends too (a press there takes the end), a kScroll of the bar's + /// number; and the bar, for the drag. One with nowhere to scroll to, or with no number, is not recorded: no hit + void add_bar(float x0, float x1, const Bar& b, float past = kGrab) { + if (b.id < 0 || !b.scrolls() || bars >= kBars || n >= kMax) return; + bar[bars++] = b; + add(x0, b.y0 - past, x1, b.y1 + past, kScroll, b.id); + } + /// (the page slider of that number as last drawn; null when the page drew none) + const Bar* bar_of(int id) const { + for (int i = 0; i < bars; i++) + if (bar[i].id == id) return &bar[i]; + return nullptr; + } Hit at(float x, float y) const { Hit hit; if (x < ax0 || y < ay0 || x >= ax1 || y >= ay1) return hit.part = kOutside, hit; diff --git a/gpu/vk/vk_recorder.h b/gpu/vk/vk_recorder.h index 7eb9617..b69d607 100644 --- a/gpu/vk/vk_recorder.h +++ b/gpu/vk/vk_recorder.h @@ -63,6 +63,7 @@ #include "vk_loader.h" #include "lock_census.h" // ((Triforce, 11-22, THREAD-68) who holds the lock a thread waits for, RX_VK_LOCK_CENSUS: DrainingMutex) #include "new_wait.h" // ((Triforce, 11-22, OS-04) a nothrow new that must answer at once: NoWait) +#include "capturepushkeep.h" // ((Triforce, 11-26, C15) a direct recording voids the capture push the command buffers hold) namespace mkwvk { void logf(const char* fmt, ...); // (vk_main.cpp) @@ -133,7 +134,8 @@ enum Bound : uint16_t { B_PAR, // a parallel replay's segments being recorded (par_active) B_RING_FULL, // backpressure: the ring had no room B_FOREIGN, // a thread without replay_mu made a call while the recorder was busy - B_DIRECT, // code about to record into a command buffer directly, outside vk_work.h (Dear ImGui: vk_menu.cpp) + B_DIRECT, // code about to record into a command buffer directly, outside vk_work.h (Dear ImGui: vk_menu.cpp; NGX, FFX, + // XeSS); ((Triforce, 11-26, C15) it also voids every command buffer's kept capture push (capturepushkeep.h)) B_PART, // ((Triforce) parts) a part's submit: its slot's reuse, a wait for its recording (vk_replay.cpp) B_QUEUE_LOCK, // ((Triforce) parts) the queue's lock about to be taken: the parts handed over submitted first (QueueMutex) B_COUNT @@ -182,11 +184,12 @@ inline void (*g_wake_by_address)(void* addr) = nullptr; // producer goes on into the next part at once. What needs a part submitted waits for that (parts_done, wait_part, settle_parts), // not for the ring to empty; replay_mu's unlock publishes and does not wait; the recorder waits on W between batches. A thread // about to take the queue's lock (QueueMutex, vk_internal.h) waits for the parts handed over first; one that holds a queue lock -// never waits for a recorder that waits for that lock (queue_escaped). Unset: on with Threaded rendering (g_parts_default), so -// off by default; =1 on with any recorder thread, =0 off. +// never waits for a recorder that waits for that lock (queue_escaped). Unset: off ((Triforce, 11-27) Threaded rendering no longer +// turns it on: with it the 3D was drawn with wrong textures on the lab's RX 7900 XT, vk_replay.cpp rec_parts_hooks); =1 on with any +// recorder thread, =0 off. /// Set by mode_init from the switch; false until then, so the checks that set a mode themselves keep a boundary's drain inline std::atomic g_parts{false}; -/// (vk_replay.cpp: Threaded rendering's say with RX_VK_RECORDER_PARTS unset; null: off) +/// (the switch unset: this one's say; null, as vk_replay.cpp leaves it since 11-27: off) inline bool (*g_parts_default)() = nullptr; /// (parts) a part's packets published in chunks of this many bytes while it is translated (a part of 512 draws is ~100-200 KB: /// most go over at their end, in one batch; a longer one is begun on by the recorder before its end). Tests change it @@ -922,6 +925,9 @@ inline void boundary_parts(Bound k) { /// vkDestroyInstance: the recorder stopped and joined first); ((Triforce) RX_VK_RECORDER_PARTS: boundary_parts; the recorder's own /// calls, a part's ends and submit, wait for nothing); otherwise a relaxed load and a branch inline void boundary(Bound k) { + // ((Triforce, 11-26, C15) a library is about to record into a command buffer itself: its pushes and binds are not seen by + // vk_work.h's macros, so no command buffer's kept capture push stands (capturepushkeep.h; k is a constant at every call) + if (k == B_DIRECT) ::capturepushkeep::direct_recorded(); const int m = g_mode.load(std::memory_order_relaxed); if (m == DEFER) { drain(); diff --git a/gpu/vk/vk_replay.cpp b/gpu/vk/vk_replay.cpp index 0b3a0bb..d872c0c 100644 --- a/gpu/vk/vk_replay.cpp +++ b/gpu/vk/vk_replay.cpp @@ -164,6 +164,9 @@ std::map value_rec; // submission value (or a recording' // recording's own value at its first part's submit, which a wait for a write-back may not stop at. Noted at the submit that ends // the recording, not a part's (submit_recording's part). rec_map_mu; wb_rec_wait.h) ::mkwvk::wb_rec_wait::Finished fin_rec; +// ((Triforce, 11-27) the recordings by their own value, the value their write-backs are noted under: the newest part submitted and +// whether it ended the recording, for a readback's wait (readback_rec_wait; wb_rec_wait.h Parts). rec_map_mu) +::mkwvk::wb_rec_wait::Parts rec_parts_by_value; std::unordered_map q_last; // queue -> its last submission's value (sync_order_mu) std::map value_queue; // a submission's value -> its queue (sync_order_mu) std::atomic pushed{0}; @@ -222,10 +225,14 @@ const bool rec_thread_hook = (::mkwvk::rec::g_thread_start_hook = [] { // (Triforce, lab) RX_VK_LAB_AB's knob norec: in its phases the replay makes its calls directly with the recorder thread on, what the // recorder gives the frame measured in one run (vk_recorder.h DrainingMutex::enter) const bool rec_direct_hook = (::mkwvk::rec::g_direct_hook = [] { return lab_ab::on("norec"); }, true); -// ((Triforce) Threaded rendering's recorder (threaded_rendering.h): the hand-off by part with RX_VK_RECORDER_PARTS unset; the queue -// locks tell the recorder when they are taken and let go (vk_internal.h QueueMutex; the hook does nothing without the hand-off) -const bool rec_parts_hooks = (::mkwvk::rec::g_parts_default = [] { return threaded_on(); }, - ::mkwvk::queue_lock_hook = ::mkwvk::rec::queue_lock_event, true); +// ((Triforce) The recorder's hand-off by part (vk_recorder.h): the queue locks tell the recorder when they are taken and let go +// (vk_internal.h QueueMutex; the hook does nothing without the hand-off). ((Triforce, 11-27) The hand-off is no longer Threaded +// rendering's to turn on (rec::g_parts_default left unset): RX_VK_RECORDER_PARTS=1 alone does. The owner's F8 capture (RX 7900 XT, +// AMD FSR 4.1 at 67%, RenoDX, 21:9: black characters, white ferns) and the lab's runs at the Kokiri Forest chest: Threaded rendering +// On drew the 3D with wrong textures, in v0.8.3 as in this build; every piece of it on but the hand-off (RX_VK_RECORDER_PARTS=0), the +// picture right at Off's frame rate (79-80 fps against 80); the hand-off without the render thread (RX_VK_ASYNC=0), a white 3D. +// What in the hand-off draws them wrong is not found yet) +const bool rec_parts_hooks = (::mkwvk::queue_lock_hook = ::mkwvk::rec::queue_lock_event, true); // ((Triforce) RX_VK_RECORDER_IDLE=wait, and the hand-off by part: the recorder's idle waits on its ring counter. Windows: from // kernelbase.dll, without linking Synchronization.lib; Linux: host/posix's, a futex) const bool rec_wait_hooks = [] { @@ -1203,7 +1210,7 @@ void gpu_time_end(Recording& r, bool uploads) { // (at its 1st and every 10th) by the first 64 report addresses with their counts. // Lab: RX_VK_LAB_AB naming the knob occq runs the queries the whole run; a report placed in a phase without the knob gets // no count written (4096 stays, as before). -constexpr uint32_t kOccPerSlot = 1024; // (a recording is ~120 draws, a segment ~160 or more; a count is a query a pass) +constexpr uint32_t kOccPerSlot = 1024; // (a recording is ~120-512 draws, a segment ~160 or more; a count is a query a pass) struct OccSlot { uint32_t used = 0; // (queries of the block taken by the recording made in it, not yet reset) bool armed = false; // (its block is reset: queries may begin) @@ -1847,7 +1854,7 @@ void submit_recording(Recording& r, bool signal_value = true, uint64_t signal_at if (!seq) return; std::lock_guard mk(rec_map_mu); // (upstream #2419, behind RX_VK_REC_LAST: a submission recorded in parts maps its value to its LAST part. emplace keeps - // the first, and a wait for the submission through wait_recorded comes back after its first ~120 draws) + // the first, and a wait for the submission through wait_recorded comes back after its first part) const bool last_part = rb_fix(0); const auto finished_in = [&](uint64_t v) { auto it = value_rec.find(v); @@ -1856,6 +1863,7 @@ void submit_recording(Recording& r, bool signal_value = true, uint64_t signal_at }; for (uint64_t v : rec_open_values) finished_in(v); fin_rec.submitted(rec_open_values, seq, !part); // ((Triforce, wp20) a part's: noted at the recording's end) + rec_parts_by_value.part_submitted(r.value, seq, part); // ((Triforce, 11-27) every part, for a readback's wait: readback_rec_wait) if (r.value) finished_in(r.value); rec_open_values.clear(); // (RX_VK_FENCE_POLL_FAST: after value_rec has them, under rec_map_mu, so a poll that sees the mark finds the recording) @@ -3550,7 +3558,7 @@ void replay(VkCommandBuffer& cmd, NvnState& s, const uint8_t* p, const uint8_t* } } -// ---- chunks: a long submission goes to the GPU in parts (RX_VK_CHUNK=, default 120; +// ---- chunks: a long submission goes to the GPU in parts (RX_VK_CHUNK=, unset: the driver's default; // 0: whole), so the GPU starts on its first part while the rest is recorded. The game waits for its fences within // the frame: with the whole submission recorded before the GPU saw any of it, its wait was the replay's time plus // the GPU's. Only the last part signals the submission's timeline value; the parts' slots free with it. ---- @@ -3576,22 +3584,30 @@ int par_seg_most() { return v; } +bool pass_end_parts_on(); // (Threaded rendering's parts on: below) + /// ((Triforce, 11-22, the performance audit's SYNC-66, after Source B's; barrier_rules.h part_draws) A part's size: RX_VK_CHUNK /// when it is set, read once; else the RX_VK_LAB_AB knob chunk: in its phases, read at each call, and the driver's default -/// outside them (120 for every driver until the lab picks). It was a static of maybe_split: no knob could change it in a run +/// outside them (240 on NVIDIA's driver, VK_DRIVER_ID_NVIDIA_PROPRIETARY, since 11-26, measured; 120 for every other driver, +/// NVK on an NVIDIA card too, until the lab picks). It was a static of maybe_split: no knob could change it in a run. Read only +/// where parts are counted: Threaded rendering's parts end at the game's pass ends outside the knob's phases (pass_end_parts) int64_t part_draws() { static const char* const env = getenv("RX_VK_CHUNK"); static const int64_t env_value = env ? atoll(env) : 0; static const int64_t by_driver = [] { - bool radv = false; - VkPhysicalDeviceDriverProperties dp{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES}; - VkPhysicalDeviceProperties2 p2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2}; - p2.pNext = &dp; - if (dev.physical) vkGetPhysicalDeviceProperties2(dev.physical, &p2), radv = dp.driverID == VK_DRIVER_ID_MESA_RADV; - const int64_t v = barrier_rules::part_draws_default(dev.props.vendorID, radv); + const int64_t v = barrier_rules::part_draws_default((uint32_t)dev.driver_id); + // (with Threaded rendering's parts on, the size printed decides only in the knob's phases, and there only when RX_VK_CHUNK + // is set: unset, the knob's own number decides in its phases, and the driver's default nowhere) + const char* const not_in_force = + !pass_end_parts_on() ? "" + : env ? "; not in force outside the knob's phases: a part ends where the game ends its render pass (Threaded rendering, " + "RX_VK_PART_PASS_END)" + : "; not in force: a part ends where the game ends its render pass (Threaded rendering, RX_VK_PART_PASS_END; the " + "knob's phases are counted)"; logf("vk: a submission's parts: %lld draws and dispatches each (RX_VK_CHUNK%s%s; 0: whole submissions; this driver's default " - "%lld; the lab knob chunk: in its phases when the variable is unset)", - (long long)barrier_rules::part_draws(env != nullptr, env_value, v), env ? "=" : " unset", env ? env : "", (long long)v); + "%lld; the lab knob chunk: in its phases when the variable is unset)%s", + (long long)barrier_rules::part_draws(env != nullptr, env_value, v), env ? "=" : " unset", env ? env : "", (long long)v, + not_in_force); return v; }(); return barrier_rules::part_draws(env != nullptr, env_value, lab_ab::value_of("chunk", by_driver)); @@ -3607,7 +3623,7 @@ int64_t part_draws() { // Measured on a renderer of the same base: in the Market faster than a part every 240 in all of 9 rounds paired (median standing // +4%, walking +15%, turning +2.5%; walking's 99th percentile 26.8 ms against 36.7, frames over 50 ms 20 against 44), and no // part ended inside a pass but at the ceiling. On with Threaded rendering and RX_VK_CHUNK unset; RX_VK_PART_PASS_END=1 on any -// run, =0 off (the count, as before). Not with the lab knob chunk: in its phases (part_draws decides there) +// run, =0 off (counted parts of part_draws' size). Not with the lab knob chunk: in its phases (part_draws decides there) struct PassEndParts { bool on = false; int64_t min = 120, max = 512, first = 32; @@ -3624,12 +3640,14 @@ PassEndParts& pass_end_parts() { v.first = std::clamp(num("RX_VK_PART_FIRST", 32), 0, v.min); if (v.on) logf("vk: a submission's parts end where the game has ended its render pass, from %lld draws and dispatches (the first " - "part from %lld), at %lld at the latest (Threaded rendering; RX_VK_PART_PASS_END=0: every RX_VK_CHUNK, as before)", + "part from %lld), at %lld at the latest (Threaded rendering; RX_VK_PART_PASS_END=0: counted parts of RX_VK_CHUNK or " + "the driver's default, RX_VK_CHUNK=120 the size before)", (long long)v.min, (long long)v.first, (long long)v.max); return v; }(); return p; } +bool pass_end_parts_on() { return pass_end_parts().on; } // ((Triforce, RX_VK_DRY_SHORT) a short command buffer replay_handle records on the replay thread in place of its dry pass and // one segment: one segment's worth, and a segment is not split) @@ -6173,6 +6191,105 @@ bool wait_recorded(uint64_t f, uint64_t timeout_ns, int* ok) { if (lost) wait_lost("a wait for recording", seq); return true; } +/// ((Triforce, 11-27) RX_VK_RB_REC_END: a readback's wait for its write-back ends at the LAST part of the recording that writes it +/// back, not the first (wb_rec_wait.h readback_wait: the exposure meter read as 0 between a recording's parts, the brightness +/// flashes). On unless =0, read once +bool rb_rec_end_on() { + static const bool v = [] { + const bool on = ::mkwvk::wb_rec_wait::rec_end_on(getenv("RX_VK_RB_REC_END")); + logf("vk: a readback waits for %s (RX_VK_RB_REC_END%s)", + on ? "the last part of the recording that writes it back" : "the first part of the recording that writes it back, as before", + on ? "=0: the first part, as before" : "=0"); + return on; + }(); + return v; +} +std::atomic st_rb_went_on{0}, st_rb_went_on_ns{0}; // ((Triforce, 11-27) readbacks whose writer's recording went on past a part) +/// ((Triforce, 11-27) A readback's wait for write-back value v on the recordings' timeline, by the rule (rb_rec_end_on): true when +/// the writer's recording is known (the result in *ok, as wait_recorded), false when it is not (the caller's fallback) +bool readback_rec_wait(uint64_t v, int* ok) { + if (!rec_timeline || per_queue_fences_off()) return false; + struct Calls { + uint64_t v; + uint64_t first_part() { + std::lock_guard mk(rec_map_mu); + const auto it = value_rec.find(v); + return it == value_rec.end() ? 0 : it->second; + } + ::mkwvk::wb_rec_wait::Parts::Entry look() { + std::lock_guard mk(rec_map_mu); + return rec_parts_by_value.of(v); + } + int rec_wait(uint64_t seq) { // (as wait_recorded: done on the timeline already, no flush; else flushed, then waited) + uint64_t rec_done = 0; + if (pend_held_on() && vkGetSemaphoreCounterValue(dev.device, rec_timeline, &rec_done) == VK_SUCCESS && rec_done >= seq) + return 0; + queue_flush_for(FR_WAIT); + VkSemaphoreWaitInfo wi{VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO}; + wi.semaphoreCount = 1; + wi.pSemaphores = &rec_timeline; + wi.pValues = &seq; + const VkResult res = vkWaitSemaphores(dev.device, &wi, UINT64_MAX); + wait_rec_result = res; + // (said as a lost device, as wait_recorded says it; the next submit or the GPU hang watch ends the game, as there) + const bool lost = res == VK_ERROR_DEVICE_LOST; + if (lost) wait_lost("a readback's wait for recording", seq); + return res == VK_SUCCESS ? 0 : 2; + } + void flush() { queue_flush_for(FR_WAIT); } + int slice() { + VkSemaphoreWaitInfo wi{VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO}; + wi.semaphoreCount = 1; + wi.pSemaphores = &timeline; + wi.pValues = &v; + const VkResult res = vkWaitSemaphores(dev.device, &wi, ::mkwvk::wb_rec_wait::kSliceNs); + return res == VK_SUCCESS ? 0 : res == VK_TIMEOUT ? 1 : 2; + } + } calls{v}; + GpuWaitTimer gwt("readback_rec_wait", v); + const auto t0 = std::chrono::steady_clock::now(); + const ::mkwvk::wb_rec_wait::ReadbackWait r = ::mkwvk::wb_rec_wait::readback_wait(rb_rec_end_on(), calls); + if (!r.known) return false; + *ok = r.ok ? 1 : 0; + if (r.went_on) + st_rb_went_on.fetch_add(1, std::memory_order_relaxed), + st_rb_went_on_ns.fetch_add(std::chrono::duration_cast(std::chrono::steady_clock::now() - t0).count(), + std::memory_order_relaxed); + return true; +} +// ((Triforce, 11-27) The three below are invalidate's new lines, kept out of it: the renderer's play profile matches a function +// by a hash of its control flow (if, ?:, !, &&, ||), and an `if` or `?:` added in invalidate (or `!` in submit_recording's +// note) left both at plain -O2, invalidate's ~460,000 calls a benchmark run among them. A call in place of a call keeps it. +/// A readback's wait on the recordings' timeline: by the rule (readback_rec_wait), or the first part as before (wait_recorded) +bool readback_recorded_wait(uint64_t v, int* ok) { + return rb_rec_end_on() ? readback_rec_wait(v, ok) : wait_recorded(v, UINT64_MAX, ok); +} +/// RX_VK_LOG_READBACK_ZERO's line, with the writer's recording now: its first part (the old wait's), its newest part and +/// whether that ended it, and the recordings' timeline (a read between the parts waited for the first alone) +void readback_zero_line(long long presents, uint64_t gpu, uint64_t size, uint64_t fence, uint64_t v, int behind, int waited) { + uint64_t first = 0, rec_done = 0; + ::mkwvk::wb_rec_wait::Parts::Entry e; + { + std::lock_guard mk(rec_map_mu); + const auto it = value_rec.find(v); + if (it != value_rec.end()) first = it->second; + e = rec_parts_by_value.of(v); + } + if (rec_timeline) vkGetSemaphoreCounterValue(dev.device, rec_timeline, &rec_done); + logf("vk: readback zero %lld %#llx +%#llx: all 0 where it was not at its last readback (fence %llu, GPU done %llu, " + "its write-back %llu, the replay behind %d, waited %d; its recording's first part %llu, newest %llu%s, " + "recordings done %llu)", presents, (unsigned long long)gpu, (unsigned long long)size, (unsigned long long)fence, + (unsigned long long)completed(), (unsigned long long)v, behind, waited, (unsigned long long)first, + (unsigned long long)e.seq, e.ended ? " (ended)" : " (goes on)", (unsigned long long)rec_done); +} +/// The 3000-readback line's count of the readbacks whose writer's recording went on past the part first found (the old wait +/// ended there) +void readback_went_on_line() { + if (const int64_t on = st_rb_went_on.exchange(0)) + logf("vk: readbacks of GPU results: %lld of them found their writer's recording going on past a part and waited for " + "its last part, %.2f ms each (RX_VK_RB_REC_END=0: the first part, as before)", + (long long)on, st_rb_went_on_ns.exchange(0) / (double)on / 1e6); +} // ((Triforce, 11-22, the performance audit's SYNC-122, after Source B's) A readback whose write-back is not recorded yet // (wait_recorded said so: its writer is still being recorded, or stopped at an event wait). It waited on the submissions' // timeline with no bound and never looked again: recorded and done a moment later, the read still waited for every older @@ -6680,10 +6797,11 @@ void invalidate(uint64_t gpu, uint64_t size) { } } else if (!is_late && v > completed()) { int ok = 0; - if (!(unforced && wait_recorded(v, UINT64_MAX, &ok))) { + // ((Triforce, 11-27) RX_VK_RB_REC_END, on: the last part of the writer's recording, not its first (readback_recorded_wait) + if (!(unforced && readback_recorded_wait(v, &ok))) { if (unforced && !async_on() && replay_behind()) wait_queue_empty(); // (not recorded whole: as before) if (async_unforced()) { // (its recording is being made: when the replay thread has it, on its timeline) - while (completed() < v && !wait_recorded(v, UINT64_MAX, &ok) && async_wait_step(v)) {} + while (completed() < v && !readback_recorded_wait(v, &ok) && async_wait_step(v)) {} if (completed() < v && !ok) wait_value(v); } else { // ((Triforce, 11-22, SYNC-122) the fallback: counted; in slices that look the recording up under @@ -6738,11 +6856,8 @@ void invalidate(uint64_t gpu, uint64_t size) { for (const uint32_t x : zw) nz |= x != 0; std::lock_guard zk(zm); uint8_t& l = last[gpu]; - if (l == 1 && !nz && zn++ < 6000) - logf("vk: readback zero %lld %#llx +%#llx: all 0 where it was not at its last readback (fence %llu, GPU done %llu, " - "its write-back %llu, the replay behind %d, waited %d)", (long long)presents_now, (unsigned long long)gpu, - (unsigned long long)size, (unsigned long long)f0, (unsigned long long)completed(), (unsigned long long)v, - (int)behind0, (int)w); + if (l == 1 && !nz && zn++ < 6000) // ((Triforce, 11-27) with the writer's recording's parts: readback_zero_line) + readback_zero_line((long long)presents_now, gpu, size, f0, v, (int)behind0, (int)w); l = nz ? 1 : 2; } } @@ -6771,6 +6886,7 @@ void invalidate(uint64_t gpu, uint64_t size) { "%.2f ms in all after it was done (counted with RX_VK_WB_WAIT_REC=2: what 1 would not have waited)", (long long)fb, fb_ns / (double)fb / 1e6, (long long)at_rec, (long long)held, held_ns / 1e6); } + readback_went_on_line(); // ((Triforce, 11-27) those whose writer's recording went on past a part) } } } @@ -7521,8 +7637,27 @@ void log_frame_stats() { snprintf(libs, sizeof libs, "; %.2f library links tried (%.2f ms), %lld libraries the driver had and %lld cold in all; " "%lld of the cold built by workers (%.0f ms)", (links - l_links) / 120.0, (link_ms - l_link_ms) / 120.0, (long long)lib_hits, (long long)lib_cold, (long long)lib_built, lib_build_ms); - logf("vk: a frame: %.0f draws kept their neighbour's descriptors (%.0f of them through other slots' registrations)", - (draw_desc_reused() - l_reused) / 120.0, (draw_slotgen_saves() - l_saves) / 120.0); + // ((Triforce, 11-26, the GPU audit's C02; pickwide.h, vk_shader.cpp program_for_wide) and the graphics draws' programs: by + // the wide memo, by one pass over their answers, by program_for; with RX_VK_PICK_WIDE=check what the two ways differed in. + // "by program_for" near the memo's count: more programs in a stretch of the frame than the memo holds, or one program object + // drawn with three or more sets of vertex inputs or colour types in turn, each noted and replaced. With RX_VK_PICK_WIDE=0 + // and in the lab's nopickwide phases nothing is counted: the picks are 0 there but for what a thread held from before) + int64_t pw[kProgramWideStats]; + static int64_t l_pw[kProgramWideStats]; + program_wide_stats(pw); + char pw_check[320] = ""; + if (pw[6] || pw[7]) + snprintf(pw_check, sizeof pw_check, "; RX_VK_PICK_WIDE=check (every draw is program_for's, the memo's picks above were " + "compared with it): %lld picks compared, %lld differences (%lld of them a program NOT of the bound textures' types) " + "in all", (long long)pw[6], (long long)pw[7], (long long)pw[8]); + logf("vk: a frame: %.0f draws kept their neighbour's descriptors (%.0f of them through other slots' registrations); " + "%.0f program picks by the wide memo (%.0f past a uniform update), %.0f by one pass over their answers (%.0f of them " + "a noted program's first, %.1f types compared), %.0f by program_for (%lld of its programs not of the textures at " + "their next draw, in all)%s", + (draw_desc_reused() - l_reused) / 120.0, (draw_slotgen_saves() - l_saves) / 120.0, (pw[0] - l_pw[0]) / 120.0, + (pw[1] - l_pw[1]) / 120.0, (pw[2] - l_pw[2]) / 120.0, (pw[9] - l_pw[9]) / 120.0, (pw[4] - l_pw[4]) / 120.0, + (pw[3] - l_pw[3]) / 120.0, (long long)pw[5], pw_check); + std::memcpy(l_pw, pw, sizeof l_pw); l_reused = draw_desc_reused(), l_saves = draw_slotgen_saves(); logf("vk: a frame: %.1f draws left out (not ready), %.2f waits for shaders or pipelines (%.1f ms); " "translation %.0f ms in all, %d jobs queued%s", @@ -10671,6 +10806,10 @@ int jitter_option(int id) { return (int)(d ? d : fsr3_inputs::jitter_size(axis)); } +// ((Triforce, 11-27) the files still being written when the exit's wait ended (option_set's HOS_OPT_EXITING): the host asks +// for it (option HOS_OPT_EXITING) and then ends the process without the libraries' unloading, host/hos_relaunch.c +static std::atomic exit_cut{0}; + void fill_replay_table(MkwVkRenderer& t) { t.stats = stats; t.nvn_submit = submit; @@ -10686,6 +10825,8 @@ void fill_replay_table(MkwVkRenderer& t) { t.nvn_register_texture = register_texture_queued; t.nvn_event_signal = event_signal_queued; t.option = [](int id) -> int { // (3: the fixed path's scale in 1/10000, vk_menu.cpp; DLAA: full scale, vk_dlss.cpp) + // ((Triforce, 11-27) host/hos_relaunch.c: a write cut at the exit; RX_VK_LAB_EXIT_CUT=1: as if one was (the lab's test) + if (id == HOS_OPT_EXITING) return exit_cut.load() + (getenv("RX_VK_LAB_EXIT_CUT") && atoi(getenv("RX_VK_LAB_EXIT_CUT")) > 0); if (id == 11) return opts.stick_dead_zone; if (id == HOS_OPT_LSTICK_ZONE) return std::clamp(opts.lstick_dead_zone, -1, 50) + 1; // (0: none of its own) if (id == HOS_OPT_RSTICK_ZONE) return std::clamp(opts.rstick_dead_zone, -1, 50) + 1; @@ -10715,7 +10856,13 @@ void fill_replay_table(MkwVkRenderer& t) { return std::clamp(opts.pad_speaker_volume, 0, 200) | (std::clamp(opts.pad_speaker_sync, -100, 150) + 100) << 8 | std::clamp(opts.pad_speaker_headphone_volume, 0, 100) << 16; if (id == HOS_OPT_PAD_SPEAKER_HEADPHONES) return std::clamp(opts.pad_speaker_headphones, 0, 2); - if (id == HOS_OPT_HDR_NATIVE) return dev.hdr && opts.hdr == 2; + if (id == HOS_OPT_HDR_NATIVE) { + // ((Triforce, 11-27, lab) RX_VK_LAB_HDR_NATIVE=1: the game told its display is HDR10 with no HDR swapchain, so it + // makes its native HDR shaders on an SDR screen (their modules' checksums for RenoDX, RX_VK_DUMP_ALL_SPV); the + // picture is wrong. Never for play) + static const bool lab = getenv("RX_VK_LAB_HDR_NATIVE") && atoi(getenv("RX_VK_LAB_HDR_NATIVE")) == 1; + return lab || (dev.hdr && opts.hdr == 2); + } if (id == HOS_OPT_HDR_PEAK) return std::clamp(opts.hdr_peak, 400, 10000); if (id == HOS_OPT_HDR_WHITE) return std::clamp(opts.hdr_white, 80, 500); if (id == HOS_OPT_DISCORD) return opts.discord != 0; @@ -10767,7 +10914,11 @@ void fill_replay_table(MkwVkRenderer& t) { if (id == HOS_OPT_AUDIO_OUTPUT) return opts.audio_output; // ((Triforce) the Audio output row now: its Mono, host/nn_audio.c audio_mono) if (id == HOS_OPT_MUTE_BACKGROUND) return opts.mute_background != 0; // ((Triforce) the Mute in background row, host/nn_audio.c) if (id == HOS_OPT_MIC_GAIN) return std::clamp(opts.mic_gain, 25, 400); // ((Triforce) the Microphone gain row, host/nn_audio_in.c) - return id == 0 ? opts.realtime : id == 1 ? menu_is_open() : id == 2 ? resolution_auto() && !temporal_full_scale() : id == 3 ? (temporal_full_scale() ? 10000 : resolution_scale()) : id == 4 ? opts.pad_background : id == 5 ? opts.text_speed : id == 6 ? opts.mouse_native : + if (id == HOS_OPT_STEADY_ROW) return menu_steady_row(); // ((Triforce, 11-26) the Frame pacing row's Steady, now: host/nn_vi.c) + // ((Triforce, 11-26) 2 and 3, the Render resolution as applied (vk_menu.h applied_resolution): host/nn_vi.c reads them + // each frame, and the game remakes its 3D's targets when the scale changes. The 3D's full size by the applied choice + // alone (resolution_full), not by what stands in for a while: a stand-in would remake them back and forth) + return id == 0 ? opts.realtime : id == 1 ? menu_is_open() : id == 2 ? resolution_auto() && !resolution_full() : id == 3 ? (resolution_full() ? 10000 : resolution_scale()) : id == 4 ? opts.pad_background : id == 5 ? opts.text_speed : id == 6 ? opts.mouse_native : id == 7 ? opts.mouse_sens : id == 8 ? opts.mouse_invert : id == 9 ? opts.rumble : id == 16 ? opts.invert_cam_x : id == 17 ? opts.invert_cam_y : id == HOS_OPT_GYRO ? opts.gyro : id == HOS_OPT_GYRO_SENS_X ? opts.gyro_sens_x : id == HOS_OPT_GYRO_SENS_Y ? opts.gyro_sens_y : id == HOS_OPT_GYRO_INV_X ? opts.gyro_inv_x : id == HOS_OPT_GYRO_INV_Y ? opts.gyro_inv_y : id == HOS_OPT_GYRO_DEADZONE ? opts.gyro_deadzone : id == HOS_OPT_DLSS_JITTER_W || id == HOS_OPT_DLSS_JITTER_H || id == HOS_OPT_DLSS_JITTER_PHASES ? jitter_option(id) : 0; }; @@ -10783,6 +10934,7 @@ void fill_replay_table(MkwVkRenderer& t) { t.option_set = [](int id, int value) { if (id == HOS_OPT_EXITING) { // ((Triforce, handoff §8) the files threads of their own are writing, finished first) const file_writers::Stopped s = file_writers::stop(file_writers::exit_wait_ms()); + exit_cut.store(s.left); if (s.left || s.waited_ms >= 1 || s.refused) logf("vk: exit: the files being written on threads of their own were waited for %.0f ms%s (%d not begun; " "RX_VK_WRITERS_WAIT_MS)", s.waited_ms, s.left ? (", " + std::to_string(s.left) + " still under way: cut, " diff --git a/gpu/vk/vk_shader.cpp b/gpu/vk/vk_shader.cpp index 2e84c35..55604b7 100644 --- a/gpu/vk/vk_shader.cpp +++ b/gpu/vk/vk_shader.cpp @@ -361,7 +361,21 @@ Code parse_code(const uint8_t* ctl, const uint8_t* area, uint32_t end) { // (triforce 11-08) EvilOOT's lowering (lower_to_maxwell.h: high GPRs shadowed in more register banks), and Triforce's old // one (lower_to_maxwell_regmap.h: REGMAP_nx2 extended registers) for a program it rejects, so that nothing drawn before is // lost. RX_VK_OLD_LOWERING=1: the old one for every program, as before - static const bool old_lowering = getenv("RX_VK_OLD_LOWERING") != nullptr; + // ((11-28) lab: RX_VK_OLD_LOWERING=,...: the old one for those programs only, for the Jabu-Jabu bars) + static const char* const old_env = getenv("RX_VK_OLD_LOWERING"); + bool old_lowering = old_env != nullptr; + if (old_env && strcmp(old_env, "1") != 0) { + char hex[24]; + snprintf(hex, sizeof hex, "%016llx", (unsigned long long)c.key); + old_lowering = false; + for (const char* q = old_env; *q && !old_lowering;) { + const char* e = q; + while (*e && *e != ',') e++; + old_lowering = e > q && !strncmp(hex, q, (size_t)(e - q)); + q = *e ? e + 1 : e; + } + if (old_lowering) logf("vk: NVN2 program %s (stage %u): the old lowering, as RX_VK_OLD_LOWERING asks", hex, st); + } Shader::Ampere::LoweredProgram lowered; if (!old_lowering) lowered = Shader::Ampere::LowerToMaxwell(native); if (old_lowering || !lowered) { @@ -3953,7 +3967,19 @@ void translate_mesh_into(Program& p, const NvnState& s, const Code* task, const mrt.mesh_fallback_task = task_t != nullptr; mrt.mesh_fallback_task_threads = task_t ? task_t->program.workgroup_size[0] : 0; mrt.mesh_fallback_layout = fallback ? mesh_fallback_layout() : 0; - const std::vector mspirv = Shader::Backend::SPIRV::EmitSPIRV(fallback ? profile_pinned() : profile_graphics(VK_SHADER_STAGE_MESH_BIT_EXT), mrt, mesh_t->program, bindings); + std::vector mspirv = Shader::Backend::SPIRV::EmitSPIRV(fallback ? profile_pinned() : profile_graphics(VK_SHADER_STAGE_MESH_BIT_EXT), mrt, mesh_t->program, bindings); + // ((11-28) lab: RX_VK_SPV_SWAP_DIR: the mesh stage from _mesh.spv there too, as the fragment stage below) + if (const char* sd = getenv("RX_VK_SPV_SWAP_DIR"); sd && !fallback) { + char path[512]; + snprintf(path, sizeof path, "%s/%016llx_mesh.spv", sd, (unsigned long long)p.key); + if (FILE* f = fopen(path, "rb")) { + std::vector w; + uint32_t x; + while (fread(&x, 4, 1, f) == 1) w.push_back(x); + fclose(f); + if (!w.empty()) mspirv = std::move(w), logf("vk: mesh stage of %016llx swapped for %s", (unsigned long long)p.key, path); + } + } kept.push_back(mspirv); Stage ms; ms.nvn_stage = bank_stage(mesh); @@ -4031,7 +4057,20 @@ void translate_mesh_into(Program& p, const NvnState& s, const Code* task, const if (fs->program.info.loads.Generic(i) && !mesh_t->program.info.stores.Generic(i)) frt.point_coord_generics.set(i); for (int i = 0; i < 8; i++) frt.color_output_types[i] = static_cast(color_types[i]); - const std::vector fspirv = Shader::Backend::SPIRV::EmitSPIRV(profile_graphics(VK_SHADER_STAGE_FRAGMENT_BIT), frt, fs->program, bindings); + std::vector fspirv = Shader::Backend::SPIRV::EmitSPIRV(profile_graphics(VK_SHADER_STAGE_FRAGMENT_BIT), frt, fs->program, bindings); + // ((11-28) lab: RX_VK_SPV_SWAP_DIR=: a mesh program's fragment stage from _frag.spv there when there is + // one (a hand-edited translation, with RX_VK_NO_PROGRAM_CACHE=1), for the Jabu-Jabu bars) + if (const char* sd = getenv("RX_VK_SPV_SWAP_DIR")) { + char path[512]; + snprintf(path, sizeof path, "%s/%016llx_frag.spv", sd, (unsigned long long)p.key); + if (FILE* f = fopen(path, "rb")) { + std::vector w; + uint32_t x; + while (fread(&x, 4, 1, f) == 1) w.push_back(x); + fclose(f); + if (!w.empty()) fspirv = std::move(w), logf("vk: fragment stage of %016llx swapped for %s", (unsigned long long)p.key, path); + } + } kept.push_back(fspirv); Stage f; f.nvn_stage = 1; @@ -4707,6 +4746,142 @@ std::string program_cache_path() { disk_init(); return disk_on ? disk_path : std::string(); } +} // namespace mkwvk +#include "lab_ab.h" +#include "pickwide.h" +namespace mkwvk { +// ---- ((Triforce, 11-26, the GPU audit's C02) A draw's program by a wider memo in front of program_for: pickwide.h has the rule ---- +// Here, outside the translation stamp: it changes no translation, no record and no key a record is picked by. It returns a program +// only where that is the last one program_for gave these inputs on this thread and one pass over its answers (or the generations +// that pass was made at) says it is of the bound textures' types; everything else is program_for, in the stamp, token for token as +// it was. A draw that goes to program_for pays nothing here but the find and the note of what it gave (the inputs and a pointer +// copied): the pass is made when those inputs are next seen, so a program drawn once before its entry is replaced is never +// walked a third time. +// program_for's own line ("vk: program picks: N kept ... of N") counts only the picks that come to it. What it reads of the stamp's side it reads as program_for's memo and its two walks do: prog_stage_sig, answer_stage_mask, +// answer_handle, answer_of, canonical_answer. +namespace { +enum PwCount { PW_MEMO, PW_PAST_UB, PW_PASS, PW_FULL, PW_ASKED, PW_UNKEPT, PW_COMPARED, PW_DIFFER, PW_WRONG, PW_FIRST, PW_COUNT }; +std::atomic pw_count[PW_COUNT]; +thread_local int64_t pw_mine[PW_COUNT]; // (this thread's, added to pw_count by pw_flush: no shared line written at a draw) +thread_local uint32_t pw_picks = 0; +// (a recording thread's own, as the picks are; made at its first pick and left to the process: a pointer, since with llvm-mingw +// every use of a thread_local Table, which holds vectors, would go through its TLS wrapper and the file's TLS init function, as +// tests/test_tls_objects.py says of vk_draw.cpp's) +thread_local pickwide::Table* pw_table = nullptr; +thread_local int pw_mode_was = -1; + +/// This thread's counts added to the totals: at every 256th pick, at a change of mode, and at once at a check-mode difference +/// (the totals are what check mode is read by, and a helper thread may record nothing more for the rest of the run) +void pw_flush() { + for (int k = 0; k < PW_COUNT; k++) + if (pw_mine[k]) pw_count[k].fetch_add(pw_mine[k], std::memory_order_relaxed), pw_mine[k] = 0; +} + +/// RX_VK_PICK_WIDE (read once; logged when not the default), off in the lab's "nopickwide" phases +pickwide::Mode pw_mode() { + static const pickwide::Mode env = [] { + const pickwide::Mode m = pickwide::mode(getenv("RX_VK_PICK_WIDE")); + if (m != pickwide::Mode::On) + logf("vk: program picks: the wide memo %s (RX_VK_PICK_WIDE=%s)", + m == pickwide::Mode::Off ? "off: program_for's pair of last picks and its two walks, as before" + : "checked: a draw the memo answers is asked of program_for too, whose program is drawn; the " + "frame line counts the differences", + getenv("RX_VK_PICK_WIDE")); + return m; + }(); + return pickwide::in_phase(env, lab_ab::on("nopickwide")); +} +/// The variant's types, canonical, an answer each: what one pass compares a bound texture's with +void pw_canon(const Program& p, pickwide::Entry& e) { + e.canon.resize(p.answers.size()); + for (size_t i = 0; i < e.canon.size(); i++) e.canon[i] = canonical_answer(p, p.answers[i], p.answers[i].type); +} +/// One pass over p's answers (pickwide.h one_pass): whether the textures bound now are of the variant's types +bool pw_pass(const NvnState& s, const Program& p, pickwide::Entry& e, pickwide::Walk* w) { + return pickwide::one_pass( + e, p.answers.size(), [&](size_t i) { return answer_handle(s, p, p.answers[i]); }, + [](uint32_t id) { return texture_slot_version((int)id); }, + [&](size_t i, uint32_t h) { + const Program::Answer& a = p.answers[i]; + return canonical_answer(p, a, answer_of(h, a.image)) == e.canon[i]; + }, + w); +} +} // namespace + +const Program* program_for_wide(const NvnState& s, const uint8_t color_types[8]) { + static_assert(pickwide::kStages == kNvnStages, "pickwide.h kStages is NvnState::tex_gen's count"); + const pickwide::Mode mode = pw_mode(); + if ((int)mode != pw_mode_was) { // (a lab phase began or ended: program_for moved its picks without the memo, or will) + if (pw_table) pickwide::clear(*pw_table); + pw_mode_was = (int)mode; + pw_flush(); // (what this thread counted before: the off path below does not flush, and a run can end in a nopickwide phase) + } + if (mode == pickwide::Mode::Off || !s.has_prog) return program_for(s, ProgramKind::Graphics, color_types); + if (!pw_table) pw_table = new pickwide::Table(); + pickwide::Table& t = *pw_table; + if ((++pw_picks & 255) == 0) pw_flush(); + static const pickwide::Rules rules = + pickwide::rules(getenv("RX_VK_PICK_BIND_GEN") != nullptr, getenv("RX_VK_DEFERRED_LATE") != nullptr); + const pickwide::Now now{s.prog.serial, prog_stage_sig(s.prog), s.bind_gen, registrations_generation(), ub_generation(), s.nvattr, + s.vattr, color_types, s.tex_gen}; + const Program* mine = nullptr; // (the memo's; null: program_for) + pickwide::Entry* e = pickwide::find(t, now); + if (e) { + const Program* const p = static_cast(e->p); + if (!p->ready.load(std::memory_order_acquire) || p->failed) { + pickwide::drop(*e), e = nullptr; + } else if (!e->walked) { // (noted at its last draw, program_for's: its first pass, every answer asked) + pw_canon(*p, *e); + pickwide::Walk w; + const bool ok = pw_pass(s, *p, *e, &w); + pw_mine[PW_ASKED] += w.checked; + if (ok) pickwide::found(*e, now, answer_stage_mask(*p)), mine = p, pw_mine[PW_PASS]++, pw_mine[PW_FIRST]++; + else pickwide::drop(*e), e = nullptr, pw_mine[PW_UNKEPT]++; // (finished under the pick, or other textures since) + } else if (const pickwide::Stand st = pickwide::stands(*e, now, rules); st != pickwide::Stand::No) { + mine = p, pw_mine[PW_MEMO]++, pw_mine[PW_PAST_UB] += st == pickwide::Stand::PastUpdate; + } else { // (its textures moved, or a slot was registered: asked in one pass) + pickwide::Walk w; + if (pw_pass(s, *p, *e, &w)) pickwide::restamp(*e, now), mine = p, pw_mine[PW_PASS]++; + pw_mine[PW_ASKED] += w.checked; + } + } + if (mine && mode == pickwide::Mode::On) return mine; + const Program* const full = program_for(s, ProgramKind::Graphics, color_types); + if (mine) { // (RX_VK_PICK_WIDE=check: program_for's is drawn, the memo's compared) + pw_mine[PW_COMPARED]++; + if (mine == full) return full; + pickwide::Entry probe; // (every answer of the memo's asked afresh: of the bound textures' types, or a wrong variant) + pw_canon(*mine, probe); + const bool of_types = pw_pass(s, *mine, probe, nullptr); + pw_mine[PW_DIFFER]++, pw_mine[PW_WRONG] += !of_types; + pw_flush(); // (the whole batch: its compares go out with its differences) + static std::atomic told{0}; + if (told.fetch_add(1, std::memory_order_relaxed) < 20) + logf("vk: program picks: RX_VK_PICK_WIDE=check: the memo's program %016llx variant %016llx, program_for's %016llx variant " + "%016llx%s; the memo's is %s the bound textures' types", + (unsigned long long)mine->key, (unsigned long long)mine->variant, (unsigned long long)(full ? full->key : 0), + (unsigned long long)(full ? full->variant : 0), + !full ? " (no program: the draw is left out)" : !full->ready.load(std::memory_order_acquire) ? " (not ready)" : "", + of_types ? "of" : "NOT of"); + } else { + pw_mine[PW_FULL]++; + } + if (full && full->ready.load(std::memory_order_acquire) && !full->failed) { + // (only noted for these inputs, in their entry where one is left (its pass failed, or check mode's differed): nothing of + // the program is read here. It is kept once a pass, every answer asked, finds it of the bound textures' types, and that + // is at these inputs' next draw: a draw that had to go to program_for does not pay a third walk for a draw that may not come) + pickwide::note(e ? *e : pickwide::place(t, now), now, full); + } else if (e) { + pickwide::drop(*e); + } + return full; +} + +void program_wide_stats(int64_t out[kProgramWideStats]) { + static_assert(kProgramWideStats == PW_COUNT, "vk_shader.h kProgramWideStats is PW_COUNT"); + for (int k = 0; k < PW_COUNT; k++) out[k] = pw_count[k].load(std::memory_order_relaxed); +} // ---- (Triforce) Inside the translation stamp again ---- /// (hookshot, the prediction: vk_predict.cpp) every kept graphics program variant, read without making its modules. diff --git a/gpu/vk/vk_shader.h b/gpu/vk/vk_shader.h index d52f4d2..3966005 100644 --- a/gpu/vk/vk_shader.h +++ b/gpu/vk/vk_shader.h @@ -168,6 +168,16 @@ enum class ProgramKind { Graphics, Compute, Mesh }; /// color_types: the attachments' Shader::AttributeType (Float / SignedInt / UnsignedInt), for the fragment outputs. /// Graphics programs may come back not ready yet (translation queued): the draw leaves itself out or program_wait()s. const Program* program_for(const NvnState& s, ProgramKind kind, const uint8_t color_types[8]); +/// ((Triforce, 11-26, the GPU audit's C02; pickwide.h) A graphics draw's program: program_for's last one for these inputs on this +/// thread, from a wider memo of this thread's in front of it, while it is of the bound textures' types, else program_for's own +/// pick (pickwide.h has the one known way to another variant than program_for's; RX_VK_PICK_WIDE=0: program_for alone; =check: +/// both, compared; the lab's knob "nopickwide"). Mesh and compute programs are asked of program_for +const Program* program_for_wide(const NvnState& s, const uint8_t color_types[8]); +inline constexpr int kProgramWideStats = 10; +/// (the frame line's: picks by the memo, of them past a uniform update, by one pass, full, types compared in passes, noted programs +/// not kept (not of the bound textures' types at their next draw), check mode's picks compared, differences, wrong variants, and +/// the passes that were a noted program's first; from the start) +void program_wide_stats(int64_t out[kProgramWideStats]); uint64_t compute_code_key(const NvnState& s); // (hookshot) the bound compute program's code key, 0: none std::string program_textures(const NvnState& s, const Program& p); // (hookshot, for logs) std::string program_code_keys(const NvnState& s); // (hookshot) " stage:key" for each of the bound program's codes diff --git a/gpu/vk/vk_temporal.cpp b/gpu/vk/vk_temporal.cpp index 8c8bd91..749cdee 100644 --- a/gpu/vk/vk_temporal.cpp +++ b/gpu/vk/vk_temporal.cpp @@ -127,33 +127,39 @@ bool temporal_env_chosen() { return env_xess() > 0 && xess_why() == XESS_OK; } -int temporal_mode() { +int temporal_mode_of(int choice, bool now) { const int dlss = env_dlss(), fsr4 = env_fsr4(), xess = env_xess(); - int v = opts.dlss; - rearm_on_choice(v); + int v = choice; if (dlss > 0) v = dlss >= 2 ? ur::DLAA : ur::DLSS; // (2 and up: DLAA, as RX_VK_DLSS was clamped before) else if (fsr4 > 0) v = fsr4 >= 2 ? ur::FSR4_AA : ur::FSR4; else if (xess > 0) v = xess >= 2 ? ur::XESS_AA : ur::XESS; // ((Triforce, 11-22, N64 Classic) while its 3D pass draws the gameplay upscale, the game's own as far as the chain is // concerned (n64_rules.h upscaler): no jitter, no motion, no feature drawn. The row and the switches keep their values - v = n64_rules::upscaler(n64_in_front(), v); + if (now) v = n64_rules::upscaler(n64_in_front(), v); // (FSR 3.1, the row's 3, is not an engine of this chain: the game's own as far as it is concerned. Nor anything while // FSR 3.1 upscales: one upscaler at a time, and one camera jitter. A switch above goes over the row's FSR 3.1 too // (fsr3_wanted asks temporal_env_chosen); RX_VK_FSR=1 goes over them) if (!chain_engine(v)) return ur::GAME; - if (fsr3_wanted()) return ur::GAME; + if (fsr3_wanted_of(choice, now)) return ur::GAME; if (ur::is_dlss(v) && dlss_why() != DLSS_OK) return ur::GAME; if (ur::is_fsr4(v) && fsr4_why() != FSR_OK) return ur::GAME; if (ur::is_xess(v) && xess_why() != XESS_OK) return ur::GAME; // ((Triforce) Intel XeSS) // ((Triforce, FSR4-1) off after failing again and again: the game's own, which the Upscaler row and the rows after it // then say. Not while it waits to try again: the hooks that feed the chain stay on for the retry) - if (stood_in(v)) return ur::GAME; + if (now && stood_in(v)) return ur::GAME; return v; } +int temporal_mode() { + // ((Triforce, 11-26) the row as applied, not as it is being stepped: vk_menu.h applied_dlss) + const int v = applied_dlss(); + rearm_on_choice(v); + return temporal_mode_of(v, true); +} + int temporal_stood_in() { const int dlss = env_dlss(), fsr4 = env_fsr4(), xess = env_xess(); - int v = opts.dlss; + int v = applied_dlss(); // ((Triforce, 11-26) as applied) if (dlss > 0) v = dlss >= 2 ? ur::DLAA : ur::DLSS; else if (fsr4 > 0) v = fsr4 >= 2 ? ur::FSR4_AA : ur::FSR4; else if (xess > 0) v = xess >= 2 ? ur::XESS_AA : ur::XESS; @@ -457,7 +463,8 @@ bool stood_in(int mode) { const Engine& k = slot_of(mode); return k.retry.is_off() || k.failed.load(std::memory_order_relaxed); } -/// A fresh choice on the Upscaler row (opts.dlss changed): an engine off after failures is tried anew, with a count from 0 +/// A fresh choice on the Upscaler row (its applied value changed, vk_menu.h applied_dlss): an engine off after failures is +/// tried anew, with a count from 0 void rearm_on_choice(int choice) { static std::atomic seen{-1}; if (seen.load(std::memory_order_relaxed) == choice) return; @@ -1908,11 +1915,11 @@ bool chain(VkCommandBuffer cmd, int mode, Engine& engine, const Camera& cam, con /// inputs and passes, the rest of this the same; mode is then the game's own, as for the chain). RX_VK_DLSS_PRE=0: as before, in place of /// the upscale's dispatch, on the tone mapped picture (the name is DLSS's from before FSR came: it applies to either) bool pre_wanted(int mode) { - // (Triforce, 11-13: off until the Upscale before bloom row turns it on, read at the start; RX_VK_DLSS_PRE=0 or 1 over it) - static const bool on = [] { - const int e = env_switch("RX_VK_DLSS_PRE"); - return e >= 0 ? e != 0 : upscale_pre_at_start != 0; - }(); + // (Triforce, 11-13: off until the Upscale before bloom row turns it on; RX_VK_DLSS_PRE=0 or 1 over it. ((11-26) The row as + // applied, read each time: it was read at the start, and a change took a restart. The engines make their features + // again for the other kind of colour, as for another size: vk_dlss.cpp's key, temporal_rules plan_context) + static const int e = env_switch("RX_VK_DLSS_PRE"); + const bool on = e >= 0 ? e != 0 : applied_upscale_pre() != 0; return on && (chain_engine(mode) || fsr3_pre_wanted()); } diff --git a/gpu/vk/vk_temporal.h b/gpu/vk/vk_temporal.h index 7791a33..a1d6190 100644 --- a/gpu/vk/vk_temporal.h +++ b/gpu/vk/vk_temporal.h @@ -18,8 +18,13 @@ struct Texture; /// (opts.dlss), or RX_VK_DLSS=1 / 2 or RX_VK_FSR4=1 / 2 over it; GAME when the chosen engine cannot run here, and while /// AMD FSR 3.1 (vk_fsr3.cpp, its own inputs) upscales: RX_VK_FSR=1, or the row's FSR 3.1 with neither switch above set. /// (Triforce, FSR4-1) GAME too while the chosen engine is off after failing again and again: a creation or an evaluation -/// that fails is tried again 2 s later, and the fourth failure in a row turns it off until the Upscaler row is set again +/// that fails is tried again 2 s later, and the fourth failure in a row turns it off until the Upscaler row is set again. +/// ((Triforce, 11-26) The row's choice as applied, vk_menu.h applied_dlss: a choice not applied yet runs nothing) int temporal_mode(); +/// ((Triforce, 11-26) What a choice of the Upscaler row (an opts.dlss value) comes to here, as temporal_mode for the applied +/// one: the switches over it and the engines that run. now: and what stands in for a while (N64 Classic's 3D pass, an +/// engine off after failures); without it the choice's own, which the 3D's size follows (vk_menu.cpp resolution_full) +int temporal_mode_of(int choice, bool now); /// (Triforce, FSR4-1) The engine chosen (DLSS, DLAA, FSR4, FSR4_AA) when it is off after failures and the game's upscale /// stands in for it (the Upscaler row's help says so); GAME when nothing stands in int temporal_stood_in(); @@ -48,8 +53,8 @@ void temporal_note_cascade(uint64_t camera, uint64_t camera_size, uint32_t width /// DLAA or FSR's native anti-aliasing (FSR 4's on this chain, FSR 3.1's with its own passes: vk_fsr3.h fsr3_native): the 3D /// drawn at full scale, whatever the Render resolution row says bool temporal_full_scale(); -/// ((Triforce, FSR3-06, FSR4-5) The engine (or AMD FSR 3.1) draws before the game's bloom and tone mapping this run (the -/// Upscale before bloom row at the start, RX_VK_DLSS_PRE over it): it takes the scene, which the game's SMAA has not been over +/// ((Triforce, FSR3-06, FSR4-5) The engine (or AMD FSR 3.1) draws before the game's bloom and tone mapping now (the +/// Upscale before bloom row as applied, RX_VK_DLSS_PRE over it): it takes the scene, which the game's SMAA has not been over bool temporal_before_bloom(); /// ((Triforce, S1) The Sharpness row as the upscalers' own sharpening, 0 to 1 (sharpen_rules.h amount); 0 at 0, and with diff --git a/gpu/vk/vk_texture.cpp b/gpu/vk/vk_texture.cpp index c6638b0..dfc767a 100644 --- a/gpu/vk/vk_texture.cpp +++ b/gpu/vk/vk_texture.cpp @@ -102,6 +102,7 @@ #include "gpu_write_history.h" // ((Triforce) RX_VK_GPU_WRITE_HISTORY=1: gpu_wrote_hist) #include "wrote_regions.h" // ((Triforce, 11-21, TEX-02) the regions a GPU write ever reached: "not written" without the lock) #include "drawn_page_map.h" // ((Triforce, 11-21, TEX-21) a drawn texture's page map recorded at its first draw +#include "bakescan.h" // ((Triforce, 11-26, C36) the bake write-back's scan: the list of the textures it can take #include "dead_count.h" // ((Triforce, 11-21, THREAD-21's first step) what destroying the dead images costs a present: counted #include "finalized_obsolete.h" // ((Triforce, 11-21, TEX-43) a finalized target whose storage the CPU has rewritten goes) #include "slot_retire.h" // ((Triforce, 11-21, TEX-76) a depth target another size replaced at its start: let go after 16 presents) @@ -3218,6 +3219,25 @@ bool upload_inner(Texture& tex, const Ranges* dirty) { widen_rows(out, blocks, (size_t)g.tw * th * g.td, src_bpb, out_bpb, widen_alpha(src_vf)); } st_bytes += (int64_t)out_bytes; + // ((11-28) lab: RX_VK_TEX_SAVE=x[,x...]: those sizes' uploads into RX_VK_TEX_SAVE_DIR as uploaded: + // ASTC decoded (RGBA8), others in their blocks. For the Jabu-Jabu bars' textures) + if (static const char* save = getenv("RX_VK_TEX_SAVE"); save && level == 0) { + char want[32]; + snprintf(want, sizeof want, "%ux%u", tex.width, tex.height); + const char* dir = getenv("RX_VK_TEX_SAVE_DIR"); + if (dir && strstr(save, want)) { + static std::atomic saved{0}; + char name[512]; + snprintf(name, sizeof name, "%s\\tex_%s_vf%d_%llx_y%u_%d.bin", dir, want, (int)tex.format, + (unsigned long long)tex.gpu, y0, saved++); + if (FILE* f = fopen(name, "wb")) { + fwrite(tex.astc ? out : blocks, 1, tex.astc ? out_bytes : block_bytes, f); + fclose(f); + logf("vk: texture saved: %s (%llu bytes, %ux%u, rows from block %u)", name, + (unsigned long long)(tex.astc ? out_bytes : block_bytes), g.w, px_h, y0); + } + } + } // (a sparse image: only its blocks this holds texels other than zero get memory; the others read // zero unbound, and what the copy writes into them is dropped) if (tex.sparse) { @@ -3487,9 +3507,11 @@ bool bc1_retype(Texture& x, const char* why) { } void vw_forget(const Texture& t); // (below: a destroyed texture leaves the list of GPU-written ones) +void bake_forget(Texture* tex); // ((Triforce, 11-26, C36) and the bake write-back's list: bakescan.h) void forget_gpu(Texture* tex) { if (tex->freed_listed) reuse_drop(*tex); // ((Triforce, 11-21, TEX-14) gone: no image to take) vw_forget(*tex); + bake_forget(tex); if (gpu_write_history_on()) { // ((Triforce) RX_VK_GPU_WRITE_HISTORY: watched no more) std::lock_guard lk(gpu_wrote_mu); gpu_wrote_hist.forget(tex->id, tex->gpu, tex->gpu + tex->guest_size); @@ -4670,6 +4692,18 @@ uint32_t texture_epoch() { // game that reads it on the CPU gets them too. Not marked: a texture that had the CPU's texels before the GPU's (mixed // content), virtual pools, storage over 64 MB. void bake_note_written(Texture* t); // (below: what the GPU baked, into the game's memory) +// ((Triforce, 11-26, C36) bakescan.h: the textures bake_writeback_step can take (drawn by the GPU in one frame, their texels +// not in the game's memory yet), listed where they become so: texture_written and the step's two lost copies; a destroyed +// one leaves it in forget_gpu. The step walks this, not the whole cache. RX_VK_BAKE_SCAN=all: the whole cache and no list, +// as before) +bool bake_list_kept(); // (below: not with RX_VK_BAKE_WRITEBACK=0 or RX_VK_BAKE_SCAN=all, where nothing reads the list) +namespace { // (the same unnamed namespace forget_gpu's declaration of bake_forget is in, above) +bakescan::List bake_list; +void bake_forget(Texture* tex) { bake_list.forget(tex); } +// (every place that tells the list calls this: listed where the list is kept. A call and not a branch at the call, so that +// texture_written's control flow, and with it its entry in the renderer's play profile (RX_VK_PGO), stays v0.8.4's) +void bake_list_note(Texture* tex) { if (bake_list_kept()) bake_list.note(tex); } +} // namespace constexpr uint32_t kAuditMark = 0x6f555047; // ("GPUo") bool audit_on() { static const bool on = getenv("RX_VK_AUDIT_GPU_ONLY") && atoi(getenv("RX_VK_AUDIT_GPU_ONLY")) != 0; @@ -5516,6 +5550,10 @@ VkImageView twin3d_view(Texture* tex, VkFormat f, uint32_t level0, uint32_t nlev namespace texpack { constexpr uint64_t kPackBudget = 3ull << 30; +// ((Triforce, 11-27) the pack's share of the card (texpack_pressure): a fifth of what the driver allows, kPackBudget at most; +// and whether the use is past the line where the pack's images go before any of the game's textures (no new one meanwhile) +uint64_t cap = kPackBudget; +bool pressed = false; /// A pack file's picture as RGBA8 (false: not a picture this reads) bool decode_png(const std::string& bytes, std::vector& rgba, int* w, int* h) { #ifdef _WIN32 @@ -5777,12 +5815,12 @@ VkImageView pack_view(Texture* tex, VkFormat f, uint32_t level0, uint32_t nlevel } // ((Triforce, 11-25) 4: its image did not fit kPackBudget, its file let go: asked again once there is room) const uint64_t want_need = (uint64_t)fw * tex_pack::kScale * fh * tex_pack::kScale * 4 * 4 / 3; - if (tex->pack_state == 4 && texpack::frame_no.load(std::memory_order_relaxed) >= tex->pack_retry_at && - texpack::bytes + want_need <= texpack::kPackBudget) + if (tex->pack_state == 4 && texpack::frame_no.load(std::memory_order_relaxed) >= tex->pack_retry_at && !texpack::pressed && + texpack::bytes + want_need <= texpack::cap) texpack::want(tex); if (tex->pack_state != 3) return VK_NULL_HANDLE; if (!tex->hd) { - if (texpack::bytes + want_need > texpack::kPackBudget) { + if (texpack::bytes + want_need > texpack::cap || texpack::pressed) { // ((Triforce, 11-27) its share, and not under pressure) static std::atomic told{0}; if (told.fetch_add(1) < 4) logf("vk: texture pack: its %llu MB of video memory are used: the game's own textures from here", (unsigned long long)(texpack::bytes >> 20)); @@ -5903,6 +5941,48 @@ void texpack_gone(Texture& tex) { texpack::bytes -= std::min(texpack::bytes, (uint64_t)tex.hd_bytes); tex.hd = VK_NULL_HANDLE, tex.hd_alloc = nullptr, tex.hd_views.clear(); } +/// ((Triforce, 11-27) texture_frame's, each look with the driver's count: the pack's share and its yielding. A player's RX 6800 +/// XT (16 GB, ~13.5 GB allowed) ran Castle Town at ~30 fps with "textures 3489 MB (budget 1208 MB)": the pack's images (up to +/// 3 GB) were not textures to the budget, so the live line squeezed the game's own instead, which were made again at every +/// turn (texture lookups 20 ms a frame), each taking its pack image with it to be decoded again; an RTX 3060 Ti (8 GB, 1440p) +/// lost its device at "textures 1041 MB (budget 181 MB)". Now the pack's share is a fifth of what the driver allows (3 GB at +/// most), and past 75% of it (under the textures' own lines: the live one's ~80%, the 90% rule) the pack's images go first, the least recently used, down to 2% under that line, before any of +/// the game's textures: those textures are drawn from the game's own image (pack_state 4, asked again after kRetryFrames once +/// the use is back under the line). No pack image is made while the use is past it +void texpack_pressure(bool known, uint64_t pressure, uint64_t allowed) { + if (!texpack::on() || !known || !allowed) return; + texpack::cap = std::min(texpack::kPackBudget, allowed / 5); + // (RX_VK_TEX_PACK_LINE=, 20 to 95: another line, the lab's way to see the yielding on a card with room) + static const uint64_t pct = getenv("RX_VK_TEX_PACK_LINE") ? (uint64_t)std::clamp(atoi(getenv("RX_VK_TEX_PACK_LINE")), 20, 95) : 75; + const uint64_t line = allowed / 100 * pct; + texpack::pressed = pressure > line; + if (!texpack::pressed || !texpack::bytes) return; + const uint64_t want = pressure - line + allowed / 50; + std::vector held; + for (auto& kv : textures) + if (kv.second && kv.second->hd) held.push_back(&*kv.second); + std::sort(held.begin(), held.end(), [](const Texture* a, const Texture* b) { return a->last_frame < b->last_frame; }); + uint64_t freed = 0; + int n = 0; + const uint64_t now = texpack::frame_no.load(std::memory_order_relaxed); + for (Texture* t : held) { + if (freed >= want) break; + freed += t->hd_bytes; + views_gone.went(t->id); + texpack_gone(*t); + texpack::let_go(t->pack_key); // (its decoded file not held in RAM meanwhile) + t->pack_state = 4, t->pack_retry_at = now + texpack::kRetryFrames; + n++; + } + if (!n) return; + destroy_gen++; + static std::atomic told{0}; + if (told.fetch_add(1, std::memory_order_relaxed) < 8) + logf("vk: texture pack: VRAM past %llu%% of what the driver allows (%llu of %llu MB): %d of its images let go first, %llu MB " + "(the least recently used; %llu MB of them now, its share %llu MB)", (unsigned long long)pct, (unsigned long long)(pressure >> 20), + (unsigned long long)(allowed >> 20), n, (unsigned long long)(freed >> 20), (unsigned long long)(texpack::bytes >> 20), + (unsigned long long)(texpack::cap >> 20)); +} /// (texture_frame) decoded files' textures, and Evil HD turned (F2, the row): the views that had the game's or the pack's /// image go stale, so the next look takes the other void texpack_tick() { @@ -6020,6 +6100,10 @@ VkImageView texture_view(Texture* tex, const nvn_tex* t, const nvn_view* v, VkIm unsigned sw[4] = {d.swizzle_r, d.swizzle_g, d.swizzle_b, d.swizzle_a}; if (v && v->set_swizzle) for (int i = 0; i < 4; i++) sw[i] = v->swz[i]; + // ((11-28) lab: RX_VK_BC4_SWZ=abcd, NVN swizzle digits (0 zero, 1 one, 2-5 RGBA) for every BC4 view) + if (static const char* o = getenv("RX_VK_BC4_SWZ"); o && strlen(o) >= 4 && + (nf == NVN_FORMAT_RGTC1_UNORM || nf == NVN_FORMAT_RGTC1_SNORM)) + for (int i = 0; i < 4; i++) sw[i] = (unsigned)(o[i] - '0'); // (X formats read alpha as one) switch (nf) { case NVN_FORMAT_RGBX8: case NVN_FORMAT_RGBX8SN: case NVN_FORMAT_RGBX8UI: case NVN_FORMAT_RGBX8I: @@ -6036,7 +6120,7 @@ VkImageView texture_view(Texture* tex, const nvn_tex* t, const nvn_view* v, VkIm cm = {component(sw[0]), component(sw[1]), component(sw[2]), component(sw[3])}; static const bool log_swizzle = getenv("RX_VK_LOG_SWIZZLE") != nullptr; // (hookshot: RGB9E5 and R11G11B10 views) static int swizzle_logged; - if (log_swizzle && nf == NVN_FORMAT_RGB9E5F && swizzle_logged++ < 12) + if (log_swizzle && (nf == NVN_FORMAT_RGB9E5F || nf == NVN_FORMAT_RGTC1_UNORM || nf == NVN_FORMAT_RGTC1_SNORM) && swizzle_logged++ < 40) logf("vk: sampled view of #%u NVN %#x as vk %d: swizzle %u %u %u %u (descriptor %u %u %u %u, view %d)", tex->id, nf, (int)f, sw[0], sw[1], sw[2], sw[3], d.swizzle_r, d.swizzle_g, d.swizzle_b, d.swizzle_a, v && v->set_swizzle ? 1 : 0); @@ -6677,6 +6761,7 @@ void texture_written(Texture* tex, const char* why) { tex->uploaded = true; if (tex->owed.from) upload_owed::paid(tex->owed); // (Triforce: the image is the content now, not what an upload still owed it) bake_note_written(tex); // (Triforce: early in such a run, its texels go into its memory at this recording's end) + bake_list_note(tex); // ((Triforce, 11-26, C36) and, should that not take it, the step's list has it: bakescan.h) } @@ -7368,12 +7453,35 @@ struct BakeBatch { std::deque bake_batches; uint64_t st_bake_wb, st_bake_wb_bytes, st_bake_wb_lost, st_bake_wb_logged; uint64_t st_bake_gpu, st_bake_gpu_bytes, swizzle_map_bytes, swizzle_map_n; // (texture_end_recording's, below) +// ((Triforce, 11-26, C36) the step's scan: steps by the list and by the whole cache, the listed textures looked at and +// the cache's that the walk would have looked at, and RX_VK_BAKE_SCAN=check's armed textures the list did not have) +std::atomic st_scan_list{0}, st_scan_all{0}, st_scan_looked{0}, st_scan_cache{0}, st_scan_missed{0}; struct BakeKind { uint32_t w, h, levels; int format; uint64_t n, bytes; }; std::unordered_map bake_kinds; // (what it wrote back, by size and format: the log's largest) bool bake_writeback_on() { static const bool on = !getenv("RX_VK_BAKE_WRITEBACK") || atoi(getenv("RX_VK_BAKE_WRITEBACK")) != 0; return on; } +// ((Triforce, 11-26, C36) RX_VK_BAKE_SCAN, read once, and logged when not the default and the write-back is on: bakescan.h) +bakescan::Mode bake_scan_mode() { + static const bakescan::Mode scan = [] { + const bakescan::Mode m = bakescan::mode_of(getenv("RX_VK_BAKE_SCAN")); + if (m != bakescan::kList && bake_writeback_on()) + logf("vk: RX_VK_BAKE_SCAN=%s: the bake write-back's scan walks the whole texture cache every fourth present, as " + "before%s", getenv("RX_VK_BAKE_SCAN"), + m == bakescan::kCheck ? ", and counts the armed textures its list does not hold (must be 0)" + : ", and keeps no list"); + return m; + }(); + return scan; +} +// ((Triforce, 11-26, C36) whether bake_list is kept: not where nothing reads it (RX_VK_BAKE_WRITEBACK=0: no step at all; +// RX_VK_BAKE_SCAN=all: the walk of the whole cache, as before). =check, which asks it, and the lab knob nobakescan keep it: +// bakescan::kept) +bool bake_list_kept() { + static const bool kept = bakescan::kept(bake_writeback_on(), bake_scan_mode()); + return kept; +} void bake_writeback_step(uint64_t completed) { if (!bake_writeback_on()) return; while (!bake_batches.empty() && bake_batches.front().value <= completed) { // (the CPU half of what the GPU is past) @@ -7389,10 +7497,16 @@ void bake_writeback_step(uint64_t completed) { watch_tex(t, "baked: its texels written into its memory"); } else { t->wb_written = 0, st_bake_wb_lost++; + bake_list_note(t); // ((C36) listed again: bakescan.h) } - } else { // (gone, finalized or drawn again since: its memory is left as it is; drawn again, it is listed again) + } else { // (gone, finalized or drawn again since: its memory is left as it is) if (it.f.buf) destroy_buffer(it.f.buf, it.f.alloc); - if (t && t->wb_written == it.written) t->wb_written = 0; + // ((C36) and the list told: a finalized one is listed again, never ripe while released; one drawn anew + // was listed by texture_written) + if (t && t->wb_written == it.written) { + t->wb_written = 0; + bake_list_note(t); + } st_bake_wb_lost++; } } @@ -7419,28 +7533,80 @@ void bake_writeback_step(uint64_t completed) { // (drawn in one frame, four presents or more ago; still the game's, and sampled in the last four presents: the game's own // draws say its storage is still this texture's. The small ones the eviction calls baked; the guest window's, which the // game's code can read) + // ((Triforce, 11-26, the GPU audit's C36) Not by a walk of the whole cache (1.1% of the Presentation Thread at Lake + // Hylia, for nothing where the recordings write them back): bake_list holds every texture that passes the tests time + // does not change (bakescan::armed: told wherever a texture can become armed), and the rest (bakescan::ripe, the image, + // its format) is asked of the listed ones here, as it was of all. The caps as before (bakescan::room); the oldest listed + // go first, and one no step can take does not stop the newer ones. RX_VK_BAKE_SCAN=all: the whole cache and no list, as + // before; =check: the whole cache, and what the list would have missed counted, each once (armed and not listed: must + // be 0). The lab knob nobakescan: the whole cache in its phases) + const bakescan::Mode scan = bake_scan_mode(); + const bool whole = scan != bakescan::kList || lab_ab::on("nobakescan"); + static std::vector listed; + bake_list.settle(listed); // (in every mode: those armed no more leave it; with RX_VK_BAKE_SCAN=all it is empty) + if (scan == bakescan::kCheck) + for (auto& kv : textures) { + Texture* t = kv.second.get(); + if (!bakescan::armed(t->gpu_written, t->first_written, t->last_written, t->wb_written) || t->wb_listed) continue; + if (const uint64_t n = st_scan_missed.fetch_add(1, std::memory_order_relaxed); n < 20) + logf_at(log_warn, "vk: RX_VK_BAKE_SCAN=check: #%u %#llx %ux%u NVN %#x is armed for the bake write-back and not " + "listed (drawn at frame %llu, written back for %llu, now %llu): the list would have missed it", + t->id, (unsigned long long)t->gpu, t->width, t->height, t->nvn_format, (unsigned long long)t->last_written, + (unsigned long long)t->wb_written, (unsigned long long)frame_no); + bake_list_note(t); // (listed now: counted once, not again at each step) + } BakeBatch nb; uint64_t bytes = 0; VkCommandBuffer cmd = VK_NULL_HANDLE; - for (auto& kv : textures) { - Texture* t = kv.second.get(); - if (!t->gpu_written || t->released || t->only_cleared || !t->first_written || t->first_written != t->last_written || - t->wb_written == t->last_written || frame_no < t->last_written + 4 || frame_no - t->last_frame > 4 || - t->bytes > (4ull << 20) || t->gpu >= (1ull << 39) || !t->image || !flushable(*t)) - continue; - if (nb.items.size() >= 24 || bytes + t->guest_size > (8ull << 20)) break; // (the rest four presents on) + const auto take = [&](Texture* t) { // (false: the step is full) + if (!bakescan::armed(t->gpu_written, t->first_written, t->last_written, t->wb_written) || + !bakescan::ripe(t->released, t->only_cleared, t->last_written, t->last_frame, t->bytes, t->gpu, frame_no) || + !t->image || !flushable(*t)) + return true; + // ((C36) one no step can take (more than a step's 8 MB of storage) does not stop the newer ones in the list; the walk + // of the whole cache stops at it, as before) + if (!whole && !bakescan::room(0, 0, t->guest_size)) return true; + if (!bakescan::room(nb.items.size(), bytes, t->guest_size)) return false; // (the rest four presents on) if (!cmd) { cmd = upload_cmd(); full_barrier(cmd, "bake write-back: before the copies"); } BakeItem it{Flush{t, t->gpu, t->gpu + t->guest_size}, t->id, t->gpu, t->last_written}; it.f.ignore_cpu = audit_on(); - if (!flush_record(it.f, cmd)) continue; // (no staging buffer: tried again four presents on) + if (!flush_record(it.f, cmd)) return true; // (no staging buffer: tried again four presents on) t->wb_written = t->last_written, t->wb_done_frame = 0; t->last_value = std::max(t->last_value, rec_value); // (its end, if it goes now, waits for the copy) bytes += t->guest_size; nb.items.push_back(std::move(it)); + return true; + }; + if (whole) { + st_scan_all.fetch_add(1, std::memory_order_relaxed); + for (auto& kv : textures) + if (!take(kv.second.get())) break; + } else { + st_scan_list.fetch_add(1, std::memory_order_relaxed); + st_scan_cache.fetch_add(textures.size(), std::memory_order_relaxed); + size_t looked = 0; // (up to where the caps stopped it) + for (Texture* t : listed) { + looked++; + if (!take(t)) break; + } + st_scan_looked.fetch_add(looked, std::memory_order_relaxed); } + // ((Triforce, 11-26, C36) bakescan.h: a line of its own every 600 presents (a multiple of 4: after this step's settle), + // so that a run with nothing written back, and both arms of the knob's A/B, say it. Listed at this step: what that + // settle kept (listed, the step's copy), all of it armed then, those the step took included) + if (frame_no % 600 == 0) + logf("vk: the bake write-back's scan: by the list at %llu steps (%llu listed textures looked at; the cache held %llu at " + "those steps), by the whole cache at %llu steps; %zu listed at this step, %llu listed in all; armed and not " + "listed (counted with RX_VK_BAKE_SCAN=check, each once, must be 0): %llu (RX_VK_BAKE_SCAN=all: the whole cache " + "and no list, as before)", (unsigned long long)st_scan_list.load(std::memory_order_relaxed), + (unsigned long long)st_scan_looked.load(std::memory_order_relaxed), + (unsigned long long)st_scan_cache.load(std::memory_order_relaxed), + (unsigned long long)st_scan_all.load(std::memory_order_relaxed), listed.size(), + (unsigned long long)bake_list.added.load(std::memory_order_relaxed), + (unsigned long long)st_scan_missed.load(std::memory_order_relaxed)); if (nb.items.empty()) return; VkMemoryBarrier2 b{VK_STRUCTURE_TYPE_MEMORY_BARRIER_2}; // (the copies' writes, for the host) b.srcStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT; @@ -8176,6 +8342,7 @@ void texture_frame(uint64_t completed) { if (textures_pool_usage(&pool_blocks, &pool_free)) reclaim = vram_compact::reclaimable(block_free, pool_free); } const uint64_t pressure = by_blocks ? used : used - std::min(used, reclaim); + texpack_pressure(known, pressure, allowed); // ((Triforce, 11-27) Evil HD's pack yields first: texpack_pressure) pool_pressed = known && pressure > allowed / 10 * 9; // (the target pool given back meanwhile) pool_tier = target_pool::tier(known, pressure, allowed); // ((Triforce, 11-21, TEX-29) halved above 90%, none above 97%) compact.pressed = known && vram_compact::pressed(used, allowed); // (hookshot, RX_VK_COMPACT: by the driver's own count) diff --git a/gpu/vk/vk_texture.h b/gpu/vk/vk_texture.h index 8b84a6f..87c1780 100644 --- a/gpu/vk/vk_texture.h +++ b/gpu/vk/vk_texture.h @@ -111,6 +111,7 @@ struct Texture { uint64_t owned_frame = 0; // (the present its storage was last noted as render targets' (gpu_owned)) uint32_t key_layout = 0, key_cls = 0; // (the key's storage layout and format class) bool vw_listed = false; // (in the list of GPU-written textures of virtual pools: texture_flush_to_guest) + bool wb_listed = false; // ((Triforce, 11-26, C36) in bake_writeback_step's list of the textures it can take: bakescan.h) uint64_t wb_written = 0; // (Triforce: the last_written its texels were put into the game's memory for, or are on their way for (bake_writeback_step); 0: not) uint64_t wb_done_frame = 0; // (and the present they got there at; 0: not yet) uint64_t wb_burst = 0; // (the frame the GPU began drawing into it after a frame or more of not doing so: texture_written) diff --git a/gpu/vk/vk_ui.h b/gpu/vk/vk_ui.h index a5a3439..4b9a40b 100644 --- a/gpu/vk/vk_ui.h +++ b/gpu/vk/vk_ui.h @@ -52,7 +52,26 @@ constexpr Palette kGamePalette = { rgba(124, 93, 49, 255), rgba(84, 64, 38), rgba(44, 36, 26, 244), rgba(150, 122, 78, 255), rgba(118, 94, 58, 255), rgba(255, 251, 238), rgba(40, 28, 14), rgba(60, 42, 22, 235), rgba(52, 38, 22, 250), rgba(122, 98, 64, 220), rgba(10, 8, 5, 200), rgba(150, 120, 40), rgba(24, 21, 14, 255), rgba(211, 144, 37, 255), rgba(255, 254, 228), - rgba(255, 255, 255), rgba(150, 185, 255), rgba(75, 57, 34), rgba(28, 13, 13), 0}; + rgba(255, 255, 255), rgba(163, 184, 255), rgba(75, 57, 34), rgba(28, 13, 13), 0}; +// ((Triforce, 11-26) the cursors' glows as the game's (the lab's SDR shots, fitted: ui083_cursor_fit): the Options rows' +// 163,184,255 at 0.80 (it was 150,185,255 at 0.5 to 0.85, breathing over 2 s), the System list's buttons' bluer, at 0.72. +// The game's breathes little, over its CursorLoop's 40 frames (vk_menu.cpp ui_ctx's pulse): 0.76 to 0.84, 0.68 to 0.76 +constexpr ImU32 kCmnCursorGlow = rgba(125, 161, 255); +constexpr float kCursorGlowBase = 0.76f, kCmnCursorGlowBase = 0.68f, kCursorGlowBreath = 0.08f; +// ((Triforce, 11-26) The glows with HDR on (glow_layers). The game blends its cursor's glow into its picture as sRGB codes +// and RenoDX then codes the picture for HDR10: the lab's HDR shot of the game's System list is its SDR shot coded so, pixel +// for pixel. Our overlay blends on HDR10's PQ codes (vk_imgui.cpp hdr10), where the same glow came out narrow and grey: the +// owner's "whiter compared to the vanilla's bluer white outline" (at 5 pixels out the game's 25,54,133 over its background, +// ours 43,61,90). A faint glow moves a PQ code about a third as far as it moves an sRGB code, and no one strength makes up +// for that both near the line and far out. So with HDR on each glow is drawn twice, each layer its own colour and strength, +// fitted to the game's glow as RenoDX codes it over the menus' browns (labbuild ui083_hdr_glow_layers.py): within 5 of 1023 +// codes of it at 200 nits in Display P3, 5 to 7 at 100 to 400 nits and in BT.709; drawn once as in SDR, 22 to 34 off +struct GlowLayer { + ImU32 col; + float a; // (its strength at the breath's middle) +}; +constexpr GlowLayer kCursorGlowHdr[2] = {{rgba(144, 174, 255), 0.698f}, {rgba(143, 159, 255), 0.690f}}; +constexpr GlowLayer kCmnCursorGlowHdr[2] = {{rgba(85, 116, 255), 0.627f}, {rgba(110, 159, 254), 0.622f}}; inline ImU32 kInk = kGamePalette.ink, kInkBright = kGamePalette.ink_bright, kSoft = kGamePalette.soft, kDim = kGamePalette.dim, kGold = kGamePalette.gold, kGoldHi = kGamePalette.gold_hi, kGoldInk = kGamePalette.gold_ink, kAccent = kGamePalette.accent, kEdge = kGamePalette.edge, kCellDark = kGamePalette.cell_dark, kCellName = kGamePalette.cell_name, @@ -90,6 +109,7 @@ struct Ctx { const char* clear_icon = nullptr; const char* clear_name = "X"; float pulse = 1; // (the cursor's glow now, 0 to 1: the game's breathes) + bool hdr10 = false; // ((Triforce, 11-26) the overlay is blended on HDR10's PQ codes (vk_imgui.cpp hdr10): glow_layers' look bool over_game = false; // (Triforce: drawn over the game's own Options screen: the guides' band hides the game's guides) // ((Triforce, 11-20) over_game: where the game's guides band ends at the right, in these pixels (game_grid.h // guide_band_x1): past w on a picture wider than the grid; w or less, the plate ends at w as before) @@ -99,6 +119,11 @@ struct Ctx { const char* key_tab_l = "Q"; const char* key_tab_r = "E"; const char* key_back = "Esc"; + // ((Triforce, 11-26) the options' Apply, kApply: the key bound to the Switch's X (Space unless rebound), and on a + // controller the icon of the Switch button bound to its face button, or its name without one, as Clear's + const char* key_apply = "Space"; + const char* apply_icon = nullptr; + const char* apply_name = "Y"; }; /// A place of the game's layout (units from the screen's centre, y up) in pixels @@ -289,6 +314,18 @@ inline void value_plate(Ctx& c, ImVec2 a, ImVec2 b, bool on = false, float k = 1 else if (const Art* g = skin("OptionBtnThinElement_00")) nine(c, g, a - m, b + m, 200, 28, alpha(on ? kValueOn : kValue, k)); else c.d->AddRectFilled(a, b, alpha(on ? kValueOn : kValue, k), lu(c, 4)); } +/// ((Triforce, 11-26) A cursor's glow texture t over a..b (nine's): once, col at base and breathing, with SDR; its two layers +/// hdr with HDR on (c.hdr10: kCursorGlowHdr's note), breathing as much. k: how much of the cursor shows +inline void glow_layers(Ctx& c, const Art* t, ImVec2 a, ImVec2 b, float bx, float by, ImU32 col, float base, + const GlowLayer (&hdr)[2], float k) { + const float s = base + kCursorGlowBreath * c.pulse; + if (!c.hdr10) { + nine(c, t, a, b, bx, by, alpha(col, s * k)); + return; + } + const float r = s / (base + kCursorGlowBreath * 0.5f) * k; + for (const GlowLayer& l : hdr) nine(c, t, a, b, bx, by, alpha(l.col, l.a * r)); +} /// The cursor: the game's white hand-drawn frame, its inner edge on a..b, and its blue-white glow outside, which breathes /// (vk_game_tex.h make_cursor, from OptionBtnThinCursorLine and OptionBtnThinCursorGlow: the layout draws the 640 x 173 /// texture 960 x 260 units, the line's inner edge then a box of 809 x 114). (Triforce) k: how much of it shows, as the @@ -298,7 +335,7 @@ inline void cursor(Ctx& c, ImVec2 a, ImVec2 b, float k = 1) { const Art *line = skin("cursor_line"), *glow = skin("cursor_glow"); const ImVec2 m(lu(c, 75.5f), lu(c, 73)); if (line && glow) { - nine(c, glow, a - m, b + m, 150, 80, alpha(kCursorGlow, (0.50f + 0.35f * c.pulse) * k)); + glow_layers(c, glow, a - m, b + m, 150, 80, kCursorGlow, kCursorGlowBase, kCursorGlowHdr, k); nine(c, line, a - m, b + m, 150, 80, alpha(kCursor, k)); return; } @@ -310,6 +347,21 @@ inline void cursor(Ctx& c, ImVec2 a, ImVec2 b, float k = 1) { } /// (the old name: the selection's outline) inline void glow(Ctx& c, ImVec2 a0, ImVec2 b0) { cursor(c, a0, b0); } +/// ((Triforce, 11-26) A button's cursor as the game's System list draws its own (PaCommonBtnThin_00: CmnBtnCursorLine_00 and +/// _Glow_00, vk_game_tex.h cmn_cursor_*): its line's inner edge on the plate's edge a..b, the line outside it (the lab's SDR +/// shots: the game's 7 pixels at 1440 lines from the plate's edge outwards; ours sat 4 pixels further in, over the plate's +/// rim), its glow the bluer one. Without those textures the Options rows' cursor, where it was +inline void cmn_cursor(Ctx& c, ImVec2 a, ImVec2 b, float k = 1) { + if (k <= 0) return; + const Art *line = skin("cmn_cursor_line"), *glow = skin("cmn_cursor_glow"); + if (!line || !glow) { + cursor(c, a + ImVec2(lu(c, 8), lu(c, 8)), b - ImVec2(lu(c, 8), lu(c, 8)), k); + return; + } + const ImVec2 m(lu(c, 68.25f), lu(c, 72)); // (the line's inner edge 45.5 and 48 texels in from the texture's edges) + glow_layers(c, glow, a - m, b + m, 140, 90, kCmnCursorGlow, kCmnCursorGlowBase, kCmnCursorGlowHdr, k); + nine(c, line, a - m, b + m, 140, 90, alpha(kCursor, k)); +} /// The game's arrow at m, pointing left or right: on its Options screen a plain white triangle, 18 x 22 units inline void arrow(Ctx& c, ImVec2 m, bool right, ImU32 col = kInk) { triangle(c, m, lu(c, 28), right ? 1 : 0, col); } // (28: its anti-aliased rim counted) /// The game's separator across x0..x1 at y: its mark in the middle, a fine line to either side (PaSlideListSeparator: P_DecoMark_00, @@ -355,7 +407,8 @@ inline void heading(Ctx& c, ImVec2 a, ImVec2 b, float name_x, const char* title) } // ---- the button prompts: the game's own icons (its External font), or the keys' caps ---- -enum Glyph { kUpDown, kLeftRight, kTabs, kConfirm, kBack, kKey, kClear }; // ((Triforce) kClear: Del, or Ctx's clear_* on a pad) +// ((Triforce) kClear: Del, or Ctx's clear_* on a pad; (11-26) kApply: the options' Apply, Ctx's key_apply and apply_*) +enum Glyph { kUpDown, kLeftRight, kTabs, kConfirm, kBack, kKey, kClear, kApply }; struct Prompt { Glyph g; const char* what; @@ -379,6 +432,8 @@ inline float glyph(Ctx& c, float my, float x, const Prompt& pr, bool draw) { if (pr.g == kKey) return key(x, pr.key); if (pr.g == kClear && !c.pad) return key(x, "Del"); if (pr.g == kClear && (!c.f.glyph || !c.clear_icon)) return key(x, c.clear_name); + if (pr.g == kApply && !c.pad) return key(x, c.key_apply); // ((Triforce, 11-26)) + if (pr.g == kApply && (!c.f.glyph || !c.apply_icon)) return key(x, c.apply_name); if (!c.pad || !c.f.glyph) { if (c.pad) { // (a controller, and no icon font: the buttons by name) switch (pr.g) { @@ -434,17 +489,21 @@ inline float glyph(Ctx& c, float my, float x, const Prompt& pr, bool draw) { } case kConfirm: return icon(x, kIconA); case kClear: return icon(x, c.clear_icon); + case kApply: return icon(x, c.apply_icon); default: return icon(x, kIconB); } } /// The prompts from x on, the label before its icon as the game's own (PaGuideKey: the label 48 units): their width (draw /// false: measured only) -inline float prompts(Ctx& c, float x, float my, const Prompt* list, int n, bool draw) { +inline float prompts(Ctx& c, float x, float my, const Prompt* list, int n, bool draw, float* spans = nullptr) { const float px = lu(c, 48 * kType), x0 = x, gap = lu(c, 20), between = lu(c, 76); for (int i = 0; i < n; i++) { + if (spans) spans[2 * i] = x; // ((Triforce, 11-26) where each prompt is, its label to its icon: for the mouse) if (draw) text_mid(c, c.f.body, px, x, my, kInk, list[i].what); x += size_of(c.f.body, px, list[i].what).x + gap; - x += glyph(c, my, x, list[i], draw) + between; + x += glyph(c, my, x, list[i], draw); + if (spans) spans[2 * i + 1] = x; + x += between; } return n ? x - x0 - between : 0; } @@ -452,9 +511,11 @@ inline float prompts(Ctx& c, float x, float my, const Prompt* list, int n, bool inline float prompt_bar_top(const Ctx& c) { return at(c, 0, -1080 + 160).y; } /// The prompts at the bottom right, as the System screens' guides: the dark band fading to the left (SystemGuideBase), the /// labels and icons ending 80 units from the right edge, their middle 62 units up; its top (prompt_bar_top). Prompts wider -/// than the window take smaller ones -inline float prompt_bar(Ctx& c, const Prompt* list, int n) { - const float my = at(c, 0, -1018).y, right = at(c, 1840, 0).x; +/// than the window take smaller ones. ((Triforce, 11-26) spans: each prompt's left and right, 2 n of them, for the mouse) +inline float prompt_bar(Ctx& c, const Prompt* list, int n, float* spans = nullptr) { + // ((Triforce, 11-25) a window narrower than 16:9 is the whole column, and the grid's right edge is past it: the prompts + // end 80 units inside the window then, as on 16:9 (at 5:4 the last ones were off the screen)) + const float my = at(c, 0, -1018).y, right = std::min(at(c, 1840, 0).x, c.w - lu(c, 80)); Ctx k = c; const float room = c.w - lu(c, 160), full = prompts(c, 0, my, list, n, false); if (full > room) k.s = c.s * room / full; @@ -475,7 +536,7 @@ inline float prompt_bar(Ctx& c, const Prompt* list, int n) { c.d->AddRectFilledMultiColor(ImVec2(band0, top), ImVec2(c.w, c.h), alpha(kBar, 0), kBar, kBar, alpha(kBar, 0)); if (x1 > c.w) c.d->AddRectFilled(ImVec2(c.w, top), ImVec2(x1, c.h), kBar); } - prompts(k, right - pw, my, list, n, true); + prompts(k, right - pw, my, list, n, true, spans); return top; } /// The System screens' header across the top (SystemHeader_00: 200 units high, the picture's ragged lower edge and the @@ -554,7 +615,7 @@ inline void box(Ctx& c, ImVec2 a, ImVec2 b, float opacity = 1) { inline void button(Ctx& c, ImVec2 a0, ImVec2 b0, const char* label, float focus) { plate(c, a0, b0, false, true); text_mid_centre(c, c.f.body, lu(c, 54 * kType), (a0.x + b0.x) * 0.5f, (a0.y + b0.y) * 0.5f - lu(c, 2), kInk, label); - if (focus > 0) cursor(c, a0 + ImVec2(lu(c, 8), lu(c, 8)), b0 - ImVec2(lu(c, 8), lu(c, 8)), focus); // (the line on the plate's edge, as the game's) + if (focus > 0) cmn_cursor(c, a0, b0, focus); // ((Triforce, 11-26) the game's System list's own cursor, outside the plate's edge) } inline void button(Ctx& c, ImVec2 a0, ImVec2 b0, const char* label, bool sel) { button(c, a0, b0, label, sel ? 1.0f : 0.0f); } diff --git a/gpu/vk/vk_work.h b/gpu/vk/vk_work.h index fb4d1bb..6bafbae 100644 --- a/gpu/vk/vk_work.h +++ b/gpu/vk/vk_work.h @@ -44,6 +44,25 @@ inline VkResult query_results(Call&& call, VkDevice device, VkQueryPool pool, ui } } // namespace mkwvk::gpu_waits_vk +// ((Triforce, 11-26, the GPU audit's C15; capturepushkeep.h) Every push constants call and every pipeline bind of the renderer +// goes through here, so that the zeros a plain draw's capture push left on a command buffer (vk_draw.cpp push_capture, kept in +// that command buffer's state: cmd_work.h CmdWork::cap) are forgotten by anything that could have changed them: a compute +// pass's push over the same bytes, another pipeline's layout. Here and not at the call sites: a site left out would leave a +// stale address for a vertex stage to write through. Neither is counted as work (the barrier rules' counts are as before). +// The draw's own pushes and its program's bind go through here as well, and note what they left after (push_capture, +// push_constants, draw). RX_VK_CAPTURE_PUSH_KEEP=0: nothing reads what is noted here +namespace mkwvk::capture_keep_vk { +inline void push(VkCommandBuffer cmd, VkPipelineLayout layout, VkShaderStageFlags stages, uint32_t offset, uint32_t size, + const void* values) { + ::capturepushkeep::any_push(::mkwvk::cmd_work(cmd).cap, offset, size, values); + ::mkwvk::rec::rx_vkCmdPushConstants(cmd, layout, stages, offset, size, values); +} +inline void bind(VkCommandBuffer cmd, VkPipelineBindPoint point, VkPipeline pipeline) { + ::capturepushkeep::any_bind(::mkwvk::cmd_work(cmd).cap); + ::mkwvk::rec::rx_vkCmdBindPipeline(cmd, point, pipeline); +} +} // namespace mkwvk::capture_keep_vk + // ((Triforce) the command buffer, the first argument, counted as it is passed on: work_on returns it. __VA_OPT__: a call with no // argument after it, vkCmdEndRendering's) #define RX_WORK_ON(cmd, ...) ::mkwvk::work_on(cmd) __VA_OPT__(, ) __VA_ARGS__ @@ -82,11 +101,12 @@ inline VkResult query_results(Call&& call, VkDevice device, VkQueryPool pool, ui // (RX_VK_RECORDER) the calls that set state, bind or mark: not work (no count), but in the command buffer in order with the work, so // through the recorder too -#define vkCmdBindPipeline(...) (::mkwvk::rec::rx_vkCmdBindPipeline(__VA_ARGS__)) +// ((Triforce, 11-26, C15) these two through capture_keep_vk, above, then the recorder as the others) +#define vkCmdBindPipeline(...) (::mkwvk::capture_keep_vk::bind(__VA_ARGS__)) #define vkCmdBindDescriptorSets(...) (::mkwvk::rec::rx_vkCmdBindDescriptorSets(__VA_ARGS__)) #define vkCmdBindIndexBuffer(...) (::mkwvk::rec::rx_vkCmdBindIndexBuffer(__VA_ARGS__)) #define vkCmdBindVertexBuffers2(...) (::mkwvk::rec::rx_vkCmdBindVertexBuffers2(__VA_ARGS__)) -#define vkCmdPushConstants(...) (::mkwvk::rec::rx_vkCmdPushConstants(__VA_ARGS__)) +#define vkCmdPushConstants(...) (::mkwvk::capture_keep_vk::push(__VA_ARGS__)) #define vkCmdPushDescriptorSetKHR(...) (::mkwvk::rec::rx_vkCmdPushDescriptorSetKHR(__VA_ARGS__)) #define vkCmdPushDescriptorSetWithTemplateKHR(...) (::mkwvk::rec::rx_vkCmdPushDescriptorSetWithTemplateKHR(__VA_ARGS__)) #define vkCmdSetViewport(...) (::mkwvk::rec::rx_vkCmdSetViewport(__VA_ARGS__)) diff --git a/gpu/vk/wb_rec_wait.h b/gpu/vk/wb_rec_wait.h index a62f93f..93f8862 100644 --- a/gpu/vk/wb_rec_wait.h +++ b/gpu/vk/wb_rec_wait.h @@ -185,4 +185,106 @@ inline int64_t fallback_held_ns(const FallbackResult& r) { return held_ns(true, true, r.rec_ns, r.total_ns); } +// ---- (Triforce, 11-27) A readback waits for the LAST part of the recording that writes it back ---- +// The owner's random brightness changes: in a still view the picture flashed brighter for a frame, then stepped down, a few times +// a minute (3 times at Hyrule Field in a four-scene held-camera benchmark run, on v0.8.4 as on the GPU pass). Each flash is +// one present after the game read its exposure meter (a 64-byte sum the GPU adds to each frame; the CPU reads it and sets it to 0) +// back as all zeros, after a wait for the meter's write-back (RX_VK_LOG_READBACK_ZERO: "waited 1", and the GPU's done value still +// below the write-back's value after the wait). A recording made in parts (vk_replay.cpp maybe_split: RX_VK_CHUNK's counted parts, +// 240 draws on NVIDIA's driver, or Threaded rendering's pass-end parts) writes back at each part's end, and every part's +// write-backs are noted under the recording's own value (Recording::value, vk_memory.cpp mem_rec_value). The readback's wait +// (vk_replay.cpp invalidate, on the game's submitting thread's replay with nothing forced: the default) looked that value up in +// value_rec, which keeps the recording's FIRST part (emplace; RX_VK_REC_LAST, off, keeps a later one only when the value comes +// again). So a read that came between the first part's submit and the last one's waited for the first part alone and read what +// guest memory held then: the CPU's 0, the GPU's sum still in a later part. The sum landed after the read, over the CPU's next 0, +// and the next frame added to it (2x): the step down. The capture's wait (vk_timeline_wait) already looks its writer up at the +// recording's end (Finished); this is the readback's side. +// Now the readback looks up the newest part submitted of the recording by its value, and whether that part ended the recording +// (Parts, noted at each submit). An ended recording: its last part is waited for, as the old wait waited for the first. A +// recording that goes on: the part known is waited for (the old wait, never longer), then the readback looks again between 1 ms +// slices of the submissions' timeline, until the recording has ended (then its last part) or the timeline reaches the value +// (everything up to it done). A value not known at all is the caller's fallback, as before. RX_VK_RB_REC_END=0: the first part, as +// before. tests/test_readback_rec_end.py + +/// A recording's parts by its own value: the newest part submitted (its number on the recordings' timeline) and whether that part +/// ended the recording. A later recording made under the same value (a stopped submission's, replayed again) takes the entry over +/// from its first part on. The oldest go past cap +struct Parts { + struct Entry { + uint64_t seq = 0; // (0: not known) + bool ended = false; + }; + std::map by_value; + size_t cap = 8192; + /// A submit of recording value as number seq: ends, the submit that ends it (finish_recording, a present's); else a part + void submitted(uint64_t value, uint64_t seq, bool ends) { + if (!value || !seq) return; + Entry& e = by_value[value]; + if (seq < e.seq) return; // (the numbers rise: an older submit's note after a newer one changes nothing) + e.seq = seq, e.ended = ends; + while (by_value.size() > cap) by_value.erase(by_value.begin()); + } + /// The same from the submit's side (vk_replay.cpp submit_recording): part, a submit that does not end the recording. (The + /// `!` is here so that the submit's code keeps the control flow its renderer profile was recorded with) + void part_submitted(uint64_t value, uint64_t seq, bool part) { submitted(value, seq, !part); } + Entry of(uint64_t value) const { + const auto it = by_value.find(value); + return it == by_value.end() ? Entry{} : it->second; + } +}; + +/// RX_VK_RB_REC_END's text: on unset or empty; set, its number (atoi, as the renderer's other switches: 0 or a word is off) +inline bool rec_end_on(const char* text) { return !(text && *text && std::atoi(text) == 0); } + +/// What a readback's wait by recordings did +struct ReadbackWait { + bool known = false; // (the writer's recording was known: false, the caller's fallback waits) + bool ok = false; // (the wait came back done: false after an error, a lost device) + bool went_on = false; // (its recording went on past the part first found: what the old wait would have stopped at) + int64_t slices = 0; // (1 ms slices of the submissions' timeline while the recording went on) +}; +/// The readback's wait over the calls it makes, so that a test can run it against a made-up GPU. d has: +/// uint64_t first_part() the old lookup (value_rec): the recording's first part, 0 while not known +/// Parts::Entry look() the newest part of the recording by its value, and whether it ended the recording +/// int rec_wait(seq) the held submits flushed, the recordings' timeline waited for with no bound: 0 done, 2 an error +/// void flush() the held submits flushed (nothing when none is held) +/// int slice() the submissions' timeline waited for kSliceNs: 0 reached, 1 not yet, 2 an error +/// rec_end: the rule (RX_VK_RB_REC_END); off, the first part alone, as before +template +ReadbackWait readback_wait(bool rec_end, D& d) { + ReadbackWait r; + if (!rec_end) { + const uint64_t seq = d.first_part(); + if (!seq) return r; + r.known = true; + r.ok = d.rec_wait(seq) == 0; + return r; + } + Parts::Entry e = d.look(); + if (!e.seq) return r; + r.known = true; + for (;;) { + if (d.rec_wait(e.seq) != 0) return r; + if (e.ended) break; + r.went_on = true; // (a part: the recording's later parts write back too) + for (;;) { + d.flush(); // (a batched submit's recording is noted once the batch goes out: RX_VK_PEND_HELD) + const Parts::Entry n = d.look(); + if (n.ended || n.seq != e.seq) { + e = n; + break; + } + const int s = d.slice(); + r.slices++; + if (s == 0) { // (the timeline at the value: every recording up to it done, its last part too) + r.ok = true; + return r; + } + if (s != 1) return r; + } + } + r.ok = true; + return r; +} + } // namespace mkwvk::wb_rec_wait diff --git a/host/discord_rpc.c b/host/discord_rpc.c index 425bbc0..4a0ab7d 100644 --- a/host/discord_rpc.c +++ b/host/discord_rpc.c @@ -49,8 +49,8 @@ void hos_log(const char *fmt, ...); int rx_option(int id, int otherwise); const char *hos_version(void); /* hos_main.c */ /* (hos_main.c, read on the game's thread while hos_oot_discord_watch is 1: the map Link was last seen in, its state, his stats) */ -int hos_oot_current_map(char *out, size_t cap); -int hos_oot_state(int *event, int *loading, int *child); +int hos_oot_discord_map(char *out, size_t cap); /* ((Triforce, 11-27) host/hos_main.c: the copy kept for Discord */ +int hos_oot_discord_state(int *event, int *loading, int *child); int hos_oot_stats(int *life, int *max_life, int *rupees, int *tokens, int *pieces); /* (-1 each when not known) */ int64_t hos_oot_player_seen_ns(void); /* (when Link's update last ran, 0 never) */ void hos_oot_discord_watch(int on); @@ -244,9 +244,9 @@ static void activity_now(unsigned nonce, long long started, char *json, size_t c char version[64], build[64], commit[64], release[64], map[96] = "", area[128] = ""; discord_version_parts(hos_version(), version, build, commit, release, sizeof version); const int game = discord_settings_use_game(&settings); - const int known = game && hos_oot_current_map(map, sizeof map); + const int known = game && hos_oot_discord_map(map, sizeof map); int event = 0, loading = 0, child = 1; - const int have_age = game && hos_oot_state(&event, &loading, &child); + const int have_age = game && hos_oot_discord_state(&event, &loading, &child); if (known) hos_oot_area_name(map, area, sizeof area); /* (not in a map, the title: no location, age or map, so the template's {location|...} part is left out) */ const int in_map = discord_in_map(known, hos_oot_player_seen_ns(), hos_now_ns()); diff --git a/host/display.c b/host/display.c index bb47287..da29f24 100644 --- a/host/display.c +++ b/host/display.c @@ -362,6 +362,7 @@ int hos_mouse_game_pointer(int *x, int *y, int *w, int *h, uint32_t *pressed, in return shown ? 1 : 2; } int hos_oot_options_front(void); /* (host/oot_menu.c) */ +int hos_oot_title_tabs(void); static void game_menu_press(LPARAM lp, LONG bit) { ptr_x = (short)LOWORD(lp), ptr_y = (short)HIWORD(lp), ptr_in = 1; gm_mouse_used(); @@ -369,6 +370,9 @@ static void game_menu_press(LPARAM lp, LONG bit) { /* ((Triforce) the game's Options screen: the options' tabs over its header (gpu/vk/vk_menu.cpp draw_game_tab) take their clicks through hos_mouse_pointer as the open menu does; host/oot_menu.c leaves the header to them, the rest is the game's) */ if (bit == HOS_MOUSE_LEFT && hos_oot_options_front()) InterlockedOr(&ptr_pressed, bit); + /* ((Triforce) and on the title, whose Mods and Save Select tabs at the top left are the renderer's own (draw_title_tabs): + it looks at each click there, and takes the one on a tab; host/oot_menu.c has no button under those) */ + else if (bit == HOS_MOUSE_LEFT && hos_oot_title_tabs()) InterlockedOr(&ptr_pressed, bit); } static void menu_press(HWND w, LPARAM lp, LONG bit) { /* (a click while the menu is open: the menu's) */ ptr_x = (short)LOWORD(lp), ptr_y = (short)HIWORD(lp), ptr_in = 1; diff --git a/host/hos_bench.c b/host/hos_bench.c index 732c16f..1974a6d 100644 --- a/host/hos_bench.c +++ b/host/hos_bench.c @@ -14,6 +14,10 @@ host/hos_main.c and their names; HOS_BENCH_SECONDS each, default 15) a teleport, its arrival (the map loaded and no event playing), 1.5 s settling (not counted), then every present's interval is measured while the camera turns steadily (the right stick at 35%, Link standing). The next teleport follows the moment a scene ends. + ((Triforce) 11-26) HOS_BENCH_PAN=: the right stick's push instead of 35 (0: the camera holds still, so an in-run + A/B, RX_VK_LAB_AB, compares its phases on one view per scene instead of on views the turn changed; a phase that holds a + teleport still spans two scenes; measurement only). Unset: 35. When it is set, the push in force is logged once (a value + that is not a percent from 0 to 100 too) and written to the results as "pan". 3. The results (version 1): average fps, 1% and 0.1% lows (nearest rank, as gpu/vk/perf_stats.h), frames, seconds and the frame times in ~120 points per scene, the GPU and the options that shape the frame rate, written atomically (.new, then renamed); then the game quits as its window's close does (host/hos_relaunch.c: a save being committed finished, the @@ -110,6 +114,8 @@ static struct { the scene's half being measured (0, 1), the way it holds (0 off, 1 on), and the halves measured so far */ int helpers, helper_threads, half, way, way_set; Half halves[2]; + int pan; /* (the right stick's push: PAN, or HOS_BENCH_PAN's) */ + int pan_set, pan_rejected; /* ((Triforce) 11-26) HOS_BENCH_PAN set (not empty), and its value not a percent from 0 to 100 */ } B = {SRWLOCK_INIT}; int hos_bench_on(void) { return B.on; } @@ -143,6 +149,21 @@ static void parse_scenes(const char *s) { } } +/* ((Triforce) 11-26) HOS_BENCH_PAN: the stick's push in percent, 0 to 100 (the leading number: 35% is 35), rounded up as PAN + is, so 35 gives PAN; unset or empty: PAN (35%); not a number (nan too) or outside 0-100: PAN, with *rejected set. The range + test is written so that a NaN, which every comparison fails, is rejected too: converting it to int is undefined */ +static int bench_pan(const char *e, int *rejected) { + *rejected = 0; + if (!e || !*e) return PAN; + char *end; + const double v = strtod(e, &end); + if (end == e || !(v >= 0 && v <= 100)) { + *rejected = 1; + return PAN; + } + return (int)ceil(v * 32767.0 / 100.0); +} + void hos_bench_init(void) { const char *p = getenv("HOS_BENCHMARK"); if (!p || !*p) return; @@ -155,6 +176,9 @@ void hos_bench_init(void) { B.slot = B.newest = -1; const char *helpers = getenv("HOS_BENCH_HELPERS"); B.helpers = helpers && atoi(helpers) != 0; + const char *pan = getenv("HOS_BENCH_PAN"); + B.pan = bench_pan(pan, &B.pan_rejected); + B.pan_set = pan && *pan; B.helper_threads = -1; B.t_start = hos_now_ns(); B.phase = MKWVK_BENCH_BOOT; @@ -421,6 +445,7 @@ static void write_results(int stopped) { /* (under the lock; once) */ for (int i = 0; i < B.nskipped; i++) fprintf(f, "%s", i ? "," : ""), json_text(f, B.scenes[B.skipped[i]].name); fprintf(f, "]"); if (B.helpers) fprintf(f, ",\"helper_test\":{\"threads\":%d}", B.helper_threads > 0 ? B.helper_threads : 0); + if (B.pan_set) fprintf(f, ",\"pan\":%.2f", B.pan * 100.0 / 32767.0); /* ((Triforce) 11-26) HOS_BENCH_PAN's push, percent */ fprintf(f, ",\"settings\":"); json_settings(f); fprintf(f, "}\n"); @@ -615,6 +640,15 @@ void hos_bench_present(int64_t now) { if (!told) { told = 1; hos_log("benchmark: on: %d scenes of %.1f s, results to %s", B.nscenes, B.seconds, B.path); + if (B.pan_set) { /* ((Triforce) 11-26) the camera turn in force, once; unset logs nothing, as before */ + const char *pan = getenv("HOS_BENCH_PAN"); + if (B.pan_rejected) + hos_log("benchmark: HOS_BENCH_PAN=%.40s is not a percent from 0 to 100: the right stick at 35%%, as unset", + pan ? pan : ""); + else + hos_log("benchmark: HOS_BENCH_PAN=%.40s: the right stick at %.2f%% (%d of 32767)", pan ? pan : "", + B.pan * 100.0 / 32767.0, B.pan); + } } switch (B.phase) { case MKWVK_BENCH_BOOT: { @@ -631,7 +665,7 @@ void hos_bench_present(int64_t now) { } break; case MKWVK_BENCH_SETTLE: - hos_hid_stick(0, 0, PAN, 0, 250); + hos_hid_stick(0, 0, B.pan, 0, 250); if (B.helpers && B.helper_threads < 0) { /* ((Triforce) 11-22) the helper-thread test: what it can use, asked once */ B.helper_threads = rx_option(HOS_OPT_HELPERS_FORCE, 0); if (helper_test()) @@ -650,7 +684,7 @@ void hos_bench_present(int64_t now) { } break; case MKWVK_BENCH_MEASURE: - hos_hid_stick(0, 0, PAN, 0, 250); + hos_hid_stick(0, 0, B.pan, 0, 250); if (B.measure_t0 != now && d > 0) { if (B.n == B.cap) { const int cap = B.cap ? B.cap * 2 : 16384; diff --git a/host/hos_main.c b/host/hos_main.c index 4d6382c..3b25762 100644 --- a/host/hos_main.c +++ b/host/hos_main.c @@ -780,6 +780,24 @@ int hos_oot_stats(int *life, int *max_life, int *rupees, int *tokens, int *piece oot_discord_unlock(); return have; } +/* ((Triforce, 11-27, a player's report: the status said only "Playing Triforce" with the time) The map and the state for the + Discord status, from the copy kept for it here. discord_rpc.c read hos_oot_current_map/hos_oot_state, the control bridge's + copy, which only HOS_CONTROL fills: the place, the age and the stats never showed for any player */ +int hos_oot_discord_map(char *out, size_t cap) { + oot_discord_lock(); + const int have = oot_discord_map[0] != 0; + if (have) snprintf(out, cap, "%s", oot_discord_map); + oot_discord_unlock(); + return have; +} +int hos_oot_discord_state(int *event, int *loading, int *child) { + oot_discord_lock(); + const int f = oot_discord_flags; + oot_discord_unlock(); + if (f < 0) return 0; + *event = f & 1, *loading = (f >> 1) & 1, *child = (f >> 2) & 1; + return 1; +} #if defined(_WIN32) || defined(__linux__) /* (the debug tools: host/posix has what they call) */ /* QueryGetPouchContentNumByActorName (f_82a3c260): f_805b63e0(pouch manager, &name, 0, 0) counts one content. */ @@ -3070,6 +3088,85 @@ static DWORD WINAPI game_thread(void *p) { hos_crash_clean_end(); /* ((Triforce) ExitProcess is quick_exit here, which runs no atexit: host/hos_crash_record.c */ ExitProcess(result); } +/* ((Triforce, 11-27) A PC whose NVIDIA shader cache did not keep the game's (triforce_nvidia_cache.own beside the game, left + by the renderer's library check: gpu/vk/vk_draw.cpp nv_own_folder_mark_path): the driver's cache in a folder of the game's + own, triforce_nvidia_cache, with 10 GB of room, set here before anything loads the driver. v0.8.4 set it in the renderer's + create_instance, which Windows' driver still honoured but Linux's did not: SDL had loaded it with the window, and a + player's RTX 5090 (Arch) rebuilt every shader at every start, the folder empty and ~/.cache/nvidia growing instead. A path + the player set wins; the size too. Nothing is done without the marker */ +#ifndef _WIN32 +#include +/* the files under dir, summed into *total (bytes); with drop, removed instead. Two levels of folders, as NVIDIA's are */ +static void nv_cache_sum(const char *dir, unsigned long long *total, int drop) { + DIR *d = opendir(dir); + if (!d) return; + struct dirent *e; + char p[4096]; + while ((e = readdir(d))) { + if (e->d_name[0] == '.') continue; + snprintf(p, sizeof p, "%s/%s", dir, e->d_name); + struct stat st; + if (lstat(p, &st)) continue; + if (S_ISDIR(st.st_mode)) { + nv_cache_sum(p, total, drop); + if (drop) rmdir(p); + } else if (S_ISREG(st.st_mode)) { + if (drop) remove(p); + else *total += (unsigned long long)st.st_size; + } + } + closedir(d); +} +#endif +static void nv_own_cache_folder(void) { + char mark[MAX_PATH], dir[MAX_PATH + 32]; + const DWORD len = hos_game_path_a(mark, MAX_PATH); + char *slash = len ? strrchr(mark, '\\') : NULL; + if (!slash && len) slash = strrchr(mark, '/'); + if (!slash) return; + const size_t at = (size_t)(slash + 1 - mark); + memcpy(dir, mark, at); + dir[at] = 0; + snprintf(slash + 1, (size_t)(MAX_PATH - at), "triforce_nvidia_cache.own"); + FILE *f = fopen(mark, "rb"); + const char *own = getenv("HOS_NV_OWN_CACHE"); +#ifdef _WIN32 + if (!f) return; +#else + /* ((Triforce, 11-27) On Linux for every PC, marker or not: a second player's RTX 3070 (v0.8.3, a start whose check found + the caches warm) still had 52 recorded pipelines compiled in play, 40 ms to 2.3 s each, the shared ~/.cache/nvidia + having lost them. The variables touch NVIDIA's driver alone (Mesa reads its own). HOS_NV_OWN_CACHE=0: the shared + folder, as before; on Windows the marker alone decides, as there the driver keeps what it is given unless its + control-panel size is too small */ + if (!f && own && !strcmp(own, "0")) return; +#endif + if (f) fclose(f); + if (own && !strcmp(own, "0")) return; + if (getenv("__GL_SHADER_DISK_CACHE_PATH")) return; + snprintf(dir + at, sizeof dir - at, "triforce_nvidia_cache"); +#ifdef _WIN32 + CreateDirectoryA(dir, NULL); + _putenv_s("__GL_SHADER_DISK_CACHE_PATH", dir); + SetEnvironmentVariableA("__GL_SHADER_DISK_CACHE_PATH", dir); + if (!getenv("__GL_SHADER_DISK_CACHE_SIZE")) { + _putenv_s("__GL_SHADER_DISK_CACHE_SIZE", "10737418240"); + SetEnvironmentVariableA("__GL_SHADER_DISK_CACHE_SIZE", "10737418240"); + } +#else + mkdir(dir, 0700); + setenv("__GL_SHADER_DISK_CACHE_PATH", dir, 0); + setenv("__GL_SHADER_DISK_CACHE_SIZE", "10737418240", 0); + /* ((Triforce, 11-27) and NVIDIA's cleanup pass left out in this folder alone: the same player's shared cache lost its + entries between starts with 10 GiB of room (1.7 GB -> 405 MB -> 170 MB). The folder holds the game's shaders only; + its size is kept here instead: past 12 GB (stale updates' shaders) it is emptied, and the next start makes them again */ + setenv("__GL_SHADER_DISK_CACHE_SKIP_CLEANUP", "1", 0); + { + unsigned long long total = 0; + nv_cache_sum(dir, &total, 0); + if (total > 12ull << 30) nv_cache_sum(dir, &total, 1); + } +#endif +} int main(int argc, char **argv) { { /* ((Triforce) the crash window's helper of a run (host/hos_crash_dialog.c): first, so it starts nothing of the game */ int hos_crash_helper_main(int argc, char **argv); @@ -3079,6 +3176,7 @@ int main(int argc, char **argv) { int hos_display_init(void); void hos_display_loop(void); load_hookshot_env(); + nv_own_cache_folder(); /* ((Triforce, 11-27) before the driver loads: see above (and before driver_cache_folder makes it) */ #ifdef __linux__ driver_env_choose(); /* ((Triforce) after the env file, which may set HOS_HALF_RATE_SHADING; before Vulkan, the builder's run too) */ driver_cache_room(); /* ((Triforce, 11-22) the performance audit's PIPE-97: 10 GiB for the driver's shader cache, likewise */ diff --git a/host/hos_relaunch.c b/host/hos_relaunch.c index 823e86d..610e3a0 100644 --- a/host/hos_relaunch.c +++ b/host/hos_relaunch.c @@ -124,5 +124,21 @@ void hos_window_closed_exit(void) { { void rx_option_set(int id, int value); rx_option_set(HOS_OPT_EXITING, 1); } { void hos_crash_clean_end(void); hos_crash_clean_end(); } /* ((Triforce) a clean end: host/hos_crash_record.c */ if (again) relaunch(); + /* ((Triforce, 11-27) a file the renderer was still writing when its wait ended (vk_replay.cpp's HOS_OPT_EXITING: the + pipeline cache's save, 2 GB, inside the driver's vkGetPipelineCacheData) is cut here: ExitProcess stops that thread + wherever it is, holding the driver's own lock, and then runs every library's unloading, where the driver waits for that + lock forever. A player's RX 6800 XT hung at every close after "1 still under way: cut" and had to be ended in Task + Manager. The game's own ends are all done above and the log written: the process ends as Task Manager ends it, without + the unloading (as hos_fatal's end, host/hos_thread.c). Nothing cut: ExitProcess as before */ + { + int rx_option(int id, int otherwise); + if (rx_option(HOS_OPT_EXITING, 0) > 0) { + hos_log("display: a file was still being written at the exit (the pipeline cache's save): the game ends without " + "the libraries' unloading, which waited for it forever"); + hos_log_flush(); + fflush(NULL); + TerminateProcess(GetCurrentProcess(), 0); + } + } ExitProcess(0); } diff --git a/host/hos_thread.c b/host/hos_thread.c index 0933bba..15e8762 100644 --- a/host/hos_thread.c +++ b/host/hos_thread.c @@ -1800,6 +1800,11 @@ static struct { sleep (NX2navi's "core grant to run", runtime/kernel.c grant_at) */ int64_t spun, slept, spin_ns, spin_capped, run_spin_ns, run_spin_n, run_sleep_ns, run_sleep_n, run_max_ns; int64_t pin_waits; /* ((Triforce, 11-23) waits past esc_eq kept to their one core behind a better holder: vc_acquire */ + /* (Triforce, the AMD limits work) who the longest wait was: the waiter and the holders of the cores it may use, read a + millisecond into the wait (vc_acquire). The 5 s line says how long the longest wait was, not whose: the title screen's + hitches (frames of 50-250 ms "outside the replay and the present" while the movie plays) had waits of 70-190 ms with + no name on them */ + char max_who[224]; } vc_st; /* ((Triforce, 11-22, the performance audit's OS-51) the waits since the last present, beside vc_st's 5 s: their time summed over the threads, how many, the longest. Added to with vc_lock held, taken by the present's look without it @@ -1899,6 +1904,8 @@ static void vc_stats_locked(int64_t now) { if (vc_st.pin_waits) /* ((Triforce, 11-23) vc_acquire: the escapes the one-core rule held back) */ hos_log("vcores: %lld waits held to their one core past the escape, behind a holder of better priority there " "(HOS_VCORE_PIN_ESCAPE_MS=0: they escape at HOS_VCORE_ESCAPE_EQ_US, as before)", (long long)vc_st.pin_waits); + if (vc_st.max_ns >= 20000000 && vc_st.max_who[0]) /* (20 ms: more than a frame at 60 fps) */ + hos_log("vcores: the longest wait, %.1f ms: %s", vc_st.max_ns / 1e6, vc_st.max_who); memset(&vc_st, 0, sizeof vc_st); vc_st.since = now; } @@ -1988,6 +1995,7 @@ static void vc_acquire(HosThread *t) { vc_st.waits++; int spun = 0, slept = 0, ended = 0; /* ((Triforce) the spin tried, a sleep taken, the wait ended in the spin) */ int pin_noted = 0; /* ((Triforce, 11-23) this wait counted in vc_st.pin_waits */ + char holders[160] = ""; /* ((Triforce) the holders of t's cores, a millisecond into the wait) */ for (;;) { /* the worst holder worse than t on a core t may use gives it up at its next checkpoint; after HOS_VCORE_SLICE_US (2000) of waiting, a holder as good as t does too (a time slice: Horizon would leave @@ -2039,6 +2047,13 @@ static void vc_acquire(HosThread *t) { vc_take(t, c); break; } + if (!holders[0]) { + int len = 0; + for (int k = 0; k < vc_cores() && len < 120; k++) + if ((m >> k & 1) && vc_owner[k]) + len += snprintf(holders + len, sizeof holders - len, " core %d: %s (%d)%s;", k, vc_owner[k]->name, + vc_owner[k]->priority, vc_owner[k]->vc_kick ? " asked" : ""); + } const int64_t waited = hos_now_ns() - t0; /* ((Triforce, 11-23) A waiter held to one core, behind a holder of better priority there, does not escape at esc_eq: Horizon never runs it then, and the game pins threads to another's core so the two never overlap. @@ -2079,7 +2094,11 @@ static void vc_acquire(HosThread *t) { const int64_t now = hos_now_ns(), waited = now - t0; HOS_CHAIN(HOS_CHAIN_WOKE, vc_chain_key(t)); vc_st.wait_ns += waited; - if (waited > vc_st.max_ns) vc_st.max_ns = waited; + if (waited > vc_st.max_ns) { + vc_st.max_ns = waited; + if (holders[0]) snprintf(vc_st.max_who, sizeof vc_st.max_who, "%s (priority %d) waited for%s", t->name, t->priority, holders); + else vc_st.max_who[0] = 0; + } __atomic_add_fetch(&vc_gap.ns, waited, __ATOMIC_RELAXED), __atomic_add_fetch(&vc_gap.n, 1, __ATOMIC_RELAXED); /* ((Triforce, OS-51)) */ if (waited > __atomic_load_n(&vc_gap.longest, __ATOMIC_RELAXED)) __atomic_store_n(&vc_gap.longest, waited, __ATOMIC_RELAXED); if (ended) vc_st.spun++; /* ((Triforce) every wait ends in the spin or after a sleep) */ diff --git a/host/menu_sound.c b/host/menu_sound.c index 005c573..d761251 100644 --- a/host/menu_sound.c +++ b/host/menu_sound.c @@ -25,11 +25,16 @@ the mix moved the new sound on by a block it never played (or ended one shorter than a block unheard). Here both run on the sound thread, one after the other. + ((Triforce, 11-25) Whose sound: the settings' tabs, the Mods screen and the step back to the pause menu's System list + have a sound each for moving, choosing and going back (HOS_MENU_SOUND_SETTINGS_NAVIGATE and the six after it), the + system menu's files unless the environment names another (roles, roles_from_env).) + The level: the Audio tab's Menu sounds row (menu_sounds= in triforce_options.ini, 0 to 100, 80 unless set; 0 silent), read at each block, and the Master volume over it as over the game's own sound (the sounds are added before render_frame applies it). They are added after the game's limiter, and the block is clipped as it is made 16-bit. */ #include #include +#include #include #include @@ -64,7 +69,7 @@ typedef struct { uint32_t frames; } Sound; -static const char *const files[SOUNDS] = { +static const char *files[SOUNDS] = { /* (a role's is another's when the environment says so: roles_from_env) */ [HOS_MENU_SOUND_OPEN] = "Sound/Resource/Stream/SE_Sys_PlusMenu_Open00.bwav", [HOS_MENU_SOUND_CLOSE] = "Sound/Resource/Stream/SE_Sys_PlusMenu_Close00.bwav", [HOS_MENU_SOUND_CURSOR] = "Sound/Resource/Stream/SE_Sys_Cursor00.bwav", @@ -79,8 +84,75 @@ static const char *const files[SOUNDS] = { file opens: the title's cursor, its Continue and the Load list's choice) */ [HOS_MENU_SOUND_SYS_CURSOR] = "Sound/Resource/Stream/SE_Sys_SysMenu_Cursor00.bwav", [HOS_MENU_SOUND_SYS_DECIDE] = "Sound/Resource/Stream/SE_Sys_SysMenu_DecideL00.bwav", + /* ((Triforce, 11-25) the owner: "The SFX are incorrect. They should be using the title screen's SFX instead of the + in-game Menu SFX." The settings' tabs, the Mods screen and the step back to the pause menu's System list, a sound + each: the system menu's cursor, its decide and its cancel (Cansel: the file's own spelling), as the owner chose them + from the game's own (the settings' Select the large decide, the title's Continue's; the Mods screen's the small + one). The in-game menu's three above, the cursor's, decide's and cancel's, are what these were until then) */ + [HOS_MENU_SOUND_SETTINGS_NAVIGATE] = "Sound/Resource/Stream/SE_Sys_SysMenu_Cursor00.bwav", + [HOS_MENU_SOUND_SETTINGS_SELECT] = "Sound/Resource/Stream/SE_Sys_SysMenu_DecideL00.bwav", + [HOS_MENU_SOUND_SETTINGS_BACK] = "Sound/Resource/Stream/SE_Sys_SysMenu_Cansel00.bwav", + [HOS_MENU_SOUND_MODS_NAVIGATE] = "Sound/Resource/Stream/SE_Sys_SysMenu_Cursor00.bwav", + [HOS_MENU_SOUND_MODS_SELECT] = "Sound/Resource/Stream/SE_Sys_SysMenu_DecideS00.bwav", + [HOS_MENU_SOUND_MODS_BACK] = "Sound/Resource/Stream/SE_Sys_SysMenu_Cansel00.bwav", + [HOS_MENU_SOUND_PAUSE_BACK] = "Sound/Resource/Stream/SE_Sys_SysMenu_Cansel00.bwav", + /* ((Triforce, 11-25) a toggle of the settings' tabs switched On, and Off (the owner, in the lab: 'In the display, the + on and off SFX are incorrect ... let me pick the correct SFX for the on and off selection for the settings'): as the + owner chose them, On the system menu's small decide, Off its cancel */ + [HOS_MENU_SOUND_SETTINGS_ON] = "Sound/Resource/Stream/SE_Sys_SysMenu_DecideS00.bwav", + [HOS_MENU_SOUND_SETTINGS_OFF] = "Sound/Resource/Stream/SE_Sys_SysMenu_Cansel00.bwav", }; +/* ((Triforce, 11-25) the seven roles above, each with the variable of the environment that names another sound for it, so + that one can be tried without a build: HOS_MENU_SOUND_SETTINGS_NAVIGATE=SE_Sys_Cursor00, in the environment or in + triforce_env.txt (host/hos_main.c env_line_allowed takes these names and a sound's bare name). The value is a file's + name in Sound/Resource/Stream without its .bwav: letters, digits and _, 64 at most, so it names nothing outside that + folder; any other value is left out with a line in the log. Read once, when the files are (load_all) */ +static const struct { int id; const char *env; } roles[] = { + {HOS_MENU_SOUND_SETTINGS_NAVIGATE, "HOS_MENU_SOUND_SETTINGS_NAVIGATE"}, + {HOS_MENU_SOUND_SETTINGS_SELECT, "HOS_MENU_SOUND_SETTINGS_SELECT"}, + {HOS_MENU_SOUND_SETTINGS_BACK, "HOS_MENU_SOUND_SETTINGS_BACK"}, + {HOS_MENU_SOUND_MODS_NAVIGATE, "HOS_MENU_SOUND_MODS_NAVIGATE"}, + {HOS_MENU_SOUND_MODS_SELECT, "HOS_MENU_SOUND_MODS_SELECT"}, + {HOS_MENU_SOUND_MODS_BACK, "HOS_MENU_SOUND_MODS_BACK"}, + {HOS_MENU_SOUND_PAUSE_BACK, "HOS_MENU_SOUND_PAUSE_BACK"}, + {HOS_MENU_SOUND_SETTINGS_ON, "HOS_MENU_SOUND_SETTINGS_ON"}, + {HOS_MENU_SOUND_SETTINGS_OFF, "HOS_MENU_SOUND_SETTINGS_OFF"}, +}; +#define ROLES (int)(sizeof roles / sizeof *roles) +#define ROLE_NAME_MOST 64 +static char role_files[ROLES][sizeof "Sound/Resource/Stream/.bwav" + ROLE_NAME_MOST]; +static const char *role_own[ROLES]; /* (a role's own file while the environment's is in files[]; NULL: files[] has its own) */ + +/* 1 when name is a sound's bare name: letters, digits and _, 1 to ROLE_NAME_MOST of them */ +static int role_name_ok(const char *name) { + size_t n = 0; + for (; name[n]; n++) { + const char c = name[n]; + if (n >= ROLE_NAME_MOST) return 0; + if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '_')) return 0; + } + return n > 0; +} +#ifndef MENU_SOUND_ENV /* (tests/menu_sound_test.c: the environment the test says) */ +#define MENU_SOUND_ENV(name) getenv(name) +#endif +static void roles_from_env(void) { + for (int k = 0; k < ROLES; k++) { + const char *name = MENU_SOUND_ENV(roles[k].env); + if (!name || !*name) continue; + if (!role_name_ok(name)) { + hos_log("menu sounds: %s: its value is not a sound's name (letters, digits and _, 64 at most, as SE_Sys_Cursor00): " + "left out", roles[k].env); + continue; + } + snprintf(role_files[k], sizeof role_files[k], "Sound/Resource/Stream/%s.bwav", name); + if (!strcmp(role_files[k], files[roles[k].id])) continue; /* (its own: nothing to say) */ + role_own[k] = files[roles[k].id], files[roles[k].id] = role_files[k]; + hos_log("menu sounds: %s: %s, the environment's (its own: %s)", roles[k].env, role_files[k], role_own[k]); + } +} + static Sound sounds[SOUNDS]; static atomic_int loaded; /* 0 not yet, 1 being read (sounds[] is written before the release store of 2), 2 ready */ @@ -201,22 +273,40 @@ float *hos_menu_sound_decode_long(const uint8_t *b, uint64_t size, uint32_t *fra return decode_most(b, size, frames_out, seconds); } +/* sounds[id] from files[id]: 1 when it plays. ((Triforce, 11-25) a file a sound before it has is not read again, and its + samples are both sounds': the roles' seven are three files, and one of them the system menu's cursor's) */ +static int load_sound(int id) { + for (int k = 1; k < id; k++) + if (!strcmp(files[k], files[id])) return sounds[id] = sounds[k], sounds[id].pcm != NULL; + uint64_t size = 0; + uint8_t *b = hos_fs_rom_file(files[id], FILE_MOST, &size); + if (!b) return 0; + uint32_t frames = 0; + float *pcm = hos_menu_sound_decode(b, size, &frames); + free(b); + if (!pcm) { + hos_log("menu sounds: %s is not a BWAV file the options play (PCM16 or DSP-ADPCM, one or two channels, at most 10 s): " + "left out", files[id]); + return 0; + } + sounds[id] = (Sound){pcm, frames}; + return 1; +} + static void load_all(void) { /* (once: hos_menu_sound_frame's store of 1 into loaded starts it) */ int n = 0; + roles_from_env(); for (int id = 1; id < SOUNDS; id++) { - uint64_t size = 0; - uint8_t *b = hos_fs_rom_file(files[id], FILE_MOST, &size); - if (!b) continue; - uint32_t frames = 0; - float *pcm = hos_menu_sound_decode(b, size, &frames); - free(b); - if (!pcm) { - hos_log("menu sounds: %s is not a BWAV file the options play (PCM16 or DSP-ADPCM, one or two channels, at most 10 s): " - "left out", files[id]); - continue; - } - sounds[id] = (Sound){pcm, frames}; - n++; + int ok = load_sound(id); + /* ((Triforce, 11-25) a role's sound from the environment that the game's files do not have, or that is not a + sound: the role's own again, and said: not a role gone silent for a name typed wrong) */ + for (int k = 0; !ok && k < ROLES; k++) + if (roles[k].id == id && role_own[k]) { + hos_log("menu sounds: %s: no sound %s in the game's files: its own, %s", roles[k].env, files[id], role_own[k]); + files[id] = role_own[k], role_own[k] = NULL; + ok = load_sound(id); + } + n += ok; } for (int i = 0; i < VOICES; i++) atomic_store(&voices[i].at, -1); hos_log("menu sounds: %d of %d interface sounds from the game's files", n, SOUNDS - 1); @@ -225,36 +315,55 @@ static void load_all(void) { /* (once: hos_menu_sound_frame's store of 1 into float hos_menu_sound_gain(int percent) { return percent <= 0 ? 0.0f : percent >= 100 ? 1.0f : (float)percent / 100.0f; } -/* The least time between a cursor tick and the sound before it. Moving down a list or changing a value asks for a tick - at every step, up to 30 a second while a direction is held, and the focus moving with a press or a tab change is - part of that sound: at most five ticks a second are heard. */ -#define CURSOR_GAP_NS 180000000ll -#define CURSOR_GAIN 0.6f /* the tick under the sounds of a decision */ -static _Atomic int64_t last_start_ns = -CURSOR_GAP_NS; +/* ((Triforce, 11-26) The navigation sounds: the cursor's tick, the settings' tabs' and the Mods screen's own, and the system + menu's cursor, as the game's own Options screen plays its cursor. The owner sent a clip of the game's Options and ours + navigated quickly: "match the game's vanilla's navigation effects" and "Increase to the same exact volume as the vanilla + navigation sound effect". Measured in it: the game's cursor sound starts with each move and the one before rings on under + it (none is cut), at 0.70 of the file's level; ours were cut short by the next (11-25) and played at 0.43, the 0.6 the + ticks had under the other sounds. Now each plays whole, at the whole level, beside the ones before it; a held direction + moves at the game's own pace (vk_menu.cpp: 330 ms, then each 135 ms), so they ring over one another no more than the + game's do. Only an ask within NAV_GAP_NS of the sound before is left out: one press that asks twice, or a move that comes + with a tab's or a page's own sound */ +#define NAV_GAP_NS 45000000ll +static _Atomic int64_t last_start_ns = -NAV_GAP_NS; +/* ((Triforce, 11-25) the ticks: the cursor's, and the settings' tabs' and the Mods screen's own now that each has a sound of + its own) */ +static int is_tick(int id) { + return id == HOS_MENU_SOUND_CURSOR || id == HOS_MENU_SOUND_SETTINGS_NAVIGATE || id == HOS_MENU_SOUND_MODS_NAVIGATE; +} +/* (the navigation sounds: the ticks and the system menu's cursor) */ +static int is_nav(int id) { return is_tick(id) || id == HOS_MENU_SOUND_SYS_CURSOR; } void hos_menu_sound_play(int id, int64_t now_ns) { if (id <= 0 || id >= SOUNDS) return; - if (id == HOS_MENU_SOUND_CURSOR && now_ns - atomic_load(&last_start_ns) < CURSOR_GAP_NS) return; + if (is_nav(id) && now_ns - atomic_load(&last_start_ns) < NAV_GAP_NS) return; atomic_store(&last_start_ns, now_ns); if (atomic_load_explicit(&loaded, memory_order_acquire) != 2 || !sounds[id].pcm) return; - int pick = 0; - uint64_t oldest = UINT64_MAX; - for (int i = 0; i < VOICES; i++) { - if (atomic_load_explicit(&voices[i].at, memory_order_acquire) < 0) { pick = i; break; } - if (voices[i].started < oldest) oldest = voices[i].started, pick = i; - } - /* A sound that replaces itself restarts instead of stacking up, and a decision replaces the tick of the same press - (a row changes its value in the tick the press is seen). ((Triforce, 11-19) the system menu's tick too: the mouse - onto Mods or Quit and its click in one tick is their decide alone) */ - for (int i = 0; i < VOICES; i++) { + /* A decision replaces the tick of the same press (a row changes its value in the tick the press is seen), and a sound + that replaces itself restarts instead of stacking up. ((Triforce, 11-19) the system menu's tick too: the mouse onto + Mods or Quit and its click in one tick is their decide alone.) ((Triforce, 11-26) A navigation sound never takes + another's voice this way: the one before rings on beside it, as the game's) */ + int pick = -1; + for (int i = 0; !is_nav(id) && i < VOICES; i++) { const int64_t at = atomic_load_explicit(&voices[i].at, memory_order_acquire); const int was = atomic_load(&voices[i].sound); - if (at >= 0 && (was == id || was == HOS_MENU_SOUND_CURSOR || was == HOS_MENU_SOUND_SYS_CURSOR) && - AT_FRAME(at) < 2400) { /* started under 50 ms ago */ + if (at >= 0 && (was == id || is_nav(was)) && AT_FRAME(at) < 2400) { /* started under 50 ms ago */ pick = i; break; } } + /* else a free voice; else the oldest navigation sound's (with all eight playing, the first of a held run, near its end), + so that a longer sound (the Mods screen's fanfare, the options' opening) is not cut by a tick; else the oldest */ + if (pick < 0) { + int nav = -1, oldest = 0; + for (int i = 0; i < VOICES && pick < 0; i++) { + const int64_t at = atomic_load_explicit(&voices[i].at, memory_order_acquire); + if (at < 0) { pick = i; break; } + if (is_nav(atomic_load(&voices[i].sound)) && (nav < 0 || voices[i].started < voices[nav].started)) nav = i; + if (voices[i].started < voices[oldest].started) oldest = i; + } + if (pick < 0) pick = nav >= 0 ? nav : oldest; + } atomic_store_explicit(&voices[pick].at, -1, memory_order_release); atomic_store_explicit(&voices[pick].sound, id, memory_order_relaxed); voices[pick].started = __atomic_add_fetch(&started_n, 1, __ATOMIC_RELAXED); @@ -281,12 +390,13 @@ void hos_menu_sound_mix(float *left, float *right, uint32_t frames, float gain) atomic_compare_exchange_strong(&voices[v].at, &at, -1); continue; } - const float vg = which == HOS_MENU_SOUND_CURSOR ? gain * CURSOR_GAIN : gain; + /* ((Triforce, 11-26) every sound at the whole level, the cursor's ticks too: the game's own cursor sound is (the + owner's clip) as loud as the rest of its menu's) */ const uint32_t n = s->frames - pos < frames ? s->frames - pos : frames; const float *src = s->pcm + (size_t)pos * 2; - for (uint32_t i = 0; vg != 0.0f && i < n; i++) { - left[i] += src[2 * (size_t)i] * vg; - right[i] += src[2 * (size_t)i + 1] * vg; + for (uint32_t i = 0; gain != 0.0f && i < n; i++) { + left[i] += src[2 * (size_t)i] * gain; + right[i] += src[2 * (size_t)i + 1] * gain; } MENU_SOUND_BETWEEN(1); /* Only advance if the voice was not restarted meanwhile. */ diff --git a/host/menu_sound.h b/host/menu_sound.h index ba6e54c..278107e 100644 --- a/host/menu_sound.h +++ b/host/menu_sound.h @@ -17,8 +17,10 @@ float *hos_menu_sound_decode_long(const uint8_t *file, uint64_t size, uint32_t * void hos_mods_music_frame(float *const *channels, int nch, uint32_t frames); /* The Menu sounds row's percent as a gain: 0 at 0 and under, 1 at 100 and over */ float hos_menu_sound_gain(int percent); -/* Starts the sound of a HOS_MENU_SOUND_* (gpu/vk/vk_api.h) on a free voice, else on the oldest. No lock is taken: it - may run while another thread mixes. now_ns: the caller's clock (the cursor's tick is not started twice in 180 ms) */ +/* Starts the sound of a HOS_MENU_SOUND_* (gpu/vk/vk_api.h) on a free voice, else on the oldest navigation sound's, else + on the oldest. ((Triforce, 11-26) Each plays whole beside the ones before it, as the game's own menu sounds; a + navigation sound asked for within 45 ms of the sound before is left out.) No lock is taken: it may run while + another thread mixes. now_ns: the caller's clock */ void hos_menu_sound_play(int id, int64_t now_ns); /* Adds the playing sounds to `frames` samples of the left and the right channel at 48 kHz, times gain, and moves the voices on (at gain 0 too: a sound goes on unheard) */ diff --git a/host/mods.c b/host/mods.c index 728d622..d9d9a4f 100644 --- a/host/mods.c +++ b/host/mods.c @@ -402,7 +402,11 @@ uint64_t hos_mods_table_size(uint64_t size, uint64_t path) { if (!need) { const uint64_t real = packed ? zs_content_size(e->host) : e->size; if (!real) return size; /* (a packed file whose header has no size: the table's figure, as the game has it) */ - const uint64_t room = real / 8 > (128u << 10) ? real / 8 : (128u << 10); + /* ((Triforce, 11-27) at most 2 MB: two crash reports with big mods (a 50 MB-a-file animation mod, a 206 MB mod) ran + the game's heap out while loading (an allocation returned 0, written through), an eighth of each file on top of the + files' own size. A model's materials and shapes need a few KB each; 2 MB is far more than any of the game's needed */ + const uint64_t eighth = real / 8 < (2u << 20) ? real / 8 : (2u << 20); + const uint64_t room = eighth > (128u << 10) ? eighth : (128u << 10); need = (real + room + (64u << 10) + 0xfff) & ~(uint64_t)0xfff; if (need > 0xfffff000u) need = 0xfffff000u; e->need = need; diff --git a/host/mouse_native.c b/host/mouse_native.c index 7bf4989..272ec22 100644 --- a/host/mouse_native.c +++ b/host/mouse_native.c @@ -126,8 +126,41 @@ void hos_mouse_native_stick(int held) { InterlockedExchange(&stick_held, held ? whether the game left the camera free, whether a stick turned it, and the degrees the mouse turned it by), and a replay gives them back at the same update (HOS_INPUT_PLAY) in place of the mouse, the menu's row and the window's clock: the camera then turns as it did, whatever the mouse and the settings do now (host/input_movie.c) */ +/* ((Triforce, 11-27) The player camera's state as it changes, the first 12 times a run, with what last pushed the right + stick (host/nn_hid.c): 3 follows Link, 4 the player's (the game's own centering waits for R3 or a recenter). A load of + his save in the lab: -1 -> 4 -> 0 -> 3 within 0.5 s, nothing on the stick. A report: at some loads the camera stopped + following Link until R3 (a Pro controller connected over Bluetooth while it loaded); the next log says whether the + camera stayed in 4 and whether a stick, the mouse or the keys pushed it then. Whatever the Mouse camera row */ +static void camera_state_note(uint64_t cam) { + static uint32_t was = 0xffffffffu; + static int said; + static int64_t first_ns; + static SRWLOCK lock = SRWLOCK_INIT; /* (the game's executors update it on several threads) */ + if (said >= 12 || !looks_like_camera(cam)) return; + uint32_t state; + memcpy(&state, GP(cam + STATE_AT), 4); + if (state == was) return; + AcquireSRWLockExclusive(&lock); + const uint32_t before = was; + was = state; + ReleaseSRWLockExclusive(&lock); + if (before == state) return; + const int64_t now = hos_now_ns(); + if (!first_ns) first_ns = now; + said++; + void hos_hid_rstick_said(char *out, size_t n); + char who[320]; + hos_hid_rstick_said(who, sizeof who); + hos_log("camera: state %d -> %u (%s), %.1f s after the first camera; the right stick last pushed by: %s", + before == 0xffffffffu ? -1 : (int)before, state, + state == STATE_PLAYER ? "the player's: the game follows Link again after R3" : state == STATE_FOLLOWS ? "follows Link" : + "another view", + (now - first_ns) / 1e9, who); +} + void hos_mouse_camera(uint64_t cam) { if (!cam) return; + camera_state_note(cam); /* (no recording written or played: as before, the mouse camera's row first, and nothing of the guest's read while it is off. With one, every update goes through it, the native camera on or not) */ const int recorded = hos_input_movie_active(); diff --git a/host/nn_audio.c b/host/nn_audio.c index 36581db..1328c62 100644 --- a/host/nn_audio.c +++ b/host/nn_audio.c @@ -97,6 +97,7 @@ typedef struct { float vol[MAX_CH][MAX_BUF]; /* to the destination mix */ float ramp_volume, ramp_vol[MAX_CH][MAX_BUF]; /* the volumes the last frame ended with (ramped to the above) */ int snap; /* started or a new destination: no ramp from the old volumes */ + int64_t dry_at; /* (Triforce) the mix frame it first played with no buffer left; 0: fed */ uint64_t wb[MAX_WB]; /* queued WaveBuffer*, oldest first (their identity) */ WB wbc[MAX_WB]; /* and their contents when appended */ int nwb, pending_wb; /* (pending: appended, not yet applied by an update) */ @@ -120,6 +121,28 @@ typedef struct { } Voice; static uint64_t split_bq_epoch; /* (the last epoch given to a splitter's filter: never 0, a voice's "none yet") */ +/* (Triforce, the AMD limits work) Late refills: a playing voice ran out of the game's wave buffers and was given one again + within half a second, so what it played in between was silence: the game's audio thread came late (it needs one of + the virtual cores). Nothing counted this, nor the mix frames dropped because the device was behind, so a stutter left + no line in the log. One line every 10 s that had any (au_late_report). A sound that ends and whose voice is used + again without a stop counts too when it is within the half second: read the count against a quiet stretch's. + au_mix_frame: the mix frame being rendered (5 ms each), from 1. tests/test_audio_late.py */ +enum { AUDIO_LATE_MOST = 100 }; /* (mix frames: half a second) */ +static int64_t au_mix_frame = 1; +static struct { int64_t gaps, frames, longest; } au_late; +/* the voice's dry mark after a mix frame: 0 while it played a source frame in it or has buffers queued, else the frame + it first played nothing in */ +static inline int64_t audio_late_mark(int64_t dry_at, int any, int nwb, int64_t frame) { + if (any || nwb) return 0; + return dry_at ? dry_at : frame; +} +/* a buffer appended at mix frame `frame`: the mix frames a playing voice played dry before it, 0 when it was fed in time + or the gap is longer than a late refill's (a new sound on the voice) */ +static inline int64_t audio_late_gap(int playing, int64_t dry_at, int64_t frame) { + if (!playing || !dry_at) return 0; + const int64_t gap = frame - dry_at; + return gap >= 1 && gap <= AUDIO_LATE_MOST ? gap : 0; +} static CRITICAL_SECTION lock; static int lock_ready; static Voice voices[MAX_VOICES]; @@ -778,6 +801,13 @@ static void tv_delay_frame(void) { /* after the voices: each line takes its st } } +static void au_late_report(unsigned dropped) { /* (the mixer thread, every 2000 mix frames; see au_late) */ + if (au_late.gaps || dropped) + hos_log("audio: in the last 10 s %lld late refills (a playing voice out of the game's buffers, fed again after %lld ms " + "in all, the longest %lld ms), %u mix frames dropped with the device behind", + (long long)au_late.gaps, (long long)au_late.frames * 5, (long long)au_late.longest * 5, dropped); + memset(&au_late, 0, sizeof au_late); +} static void render_voice(Voice *v) { /* (a started voice without a destination still plays, as on the DSP: its buffers run out and are released) */ if (v->state != PLAY_STARTED) return; @@ -814,7 +844,7 @@ static void render_voice(Voice *v) { } if (ocarina) hos_pad_speaker_ocarina_seen(); v->ramp_volume = v->volume; - (void)any; + v->dry_at = audio_late_mark(v->dry_at, any, v->nwb, au_mix_frame); /* ((Triforce) late refills: see au_late) */ /* the biquad filters (transposed direct form II, as the DSP's) */ for (int f = 0; f < 2; f++) { if (!v->bq_on[f]) continue; @@ -1302,6 +1332,7 @@ static int out_next; /* the next candidate: 0 = HOS_AUDIO_DEVICE, 1 = static uint64_t out_opened, out_stall_since; static unsigned out_played, out_peak, out_reported; static unsigned out_completed; /* ((Triforce) 11-24) blocks the device gave back since it opened: played, not only taken */ +static unsigned out_dropped; /* ((Triforce) mix frames dropped with the device behind, since the mixer's last line) */ /* (hookshot) A device gone (a Bluetooth headset off, the audio service restarted: "no driver", "invalid handle" from the next call) is closed and the default opened again; none opening, the default is tried every second until one does. Opened as the default, the output follows Windows': its key (au_default_key) looked at every second, a change reopens @@ -1573,6 +1604,7 @@ static void output_frame(const int16_t *pcm) { WAVEHDR *h = &hdr[fill_block]; if (fill_frames == 0) { if (!(h->dwFlags & WHDR_DONE)) { /* the device is behind: this frame is dropped */ + out_dropped++; /* ((Triforce) counted: the mixer's "late refills" line) */ const uint64_t now = au_ms(); if (!out_stall_since) out_stall_since = now; else if (now - out_stall_since > 1500) output_reopen(); @@ -1690,10 +1722,19 @@ static void apply(const Cmd *k) { /* (with the lock held) */ v->yn1 = v->yn2 = 0; } if (k->i0 == PLAY_STARTED && v->state != PLAY_STARTED) v->snap = 1; + if (v->state != k->i0) v->dry_at = 0; v->state = k->i0; break; case OP_VOICE_APPEND: if (v->pending_wb > 0) v->pending_wb--; + { /* ((Triforce) fed again after running dry: a late refill, see au_late) */ + const int64_t gap = audio_late_gap(v->state == PLAY_STARTED, v->dry_at, au_mix_frame); + if (gap) { + au_late.gaps++, au_late.frames += gap; + if (gap > au_late.longest) au_late.longest = gap; + } + v->dry_at = 0; + } if (v->nwb < MAX_WB) { v->wbc[v->nwb] = k->wb; v->wbc[v->nwb].source = k->i0; /* ((Triforce) its class, for the controller speaker: -1 none known) */ @@ -1829,6 +1870,8 @@ static DWORD WINAPI renderer_main(void *p) { if (ncmds && hos_now_ns() - last_update_ns > 50000000) commit(); /* (no update came: see "parameter updates") */ render_frame(pcm, out_channels); audio_mono(pcm, FRAME, out_channels, rx_option(HOS_OPT_AUDIO_OUTPUT, 0) == 3); /* ((Triforce) the Audio output row's Mono) */ + const int report = ++au_mix_frame % 2000 == 0; + if (report) au_late_report(out_dropped), out_dropped = 0; /* (out_dropped: this thread's alone) */ au_unlock(); /* ((Triforce) the controller speaker's frame (every frame, silence too: the pad's stream runs on), after the Master volume as the TV's; headphones in the pad's jack that take all the sound, as on the console: the TV silent */ diff --git a/host/nn_hid.c b/host/nn_hid.c index 9ef51a9..3e1175c 100644 --- a/host/nn_hid.c +++ b/host/nn_hid.c @@ -625,6 +625,30 @@ static void stick_max(int32_t stick[4], const int32_t v[4]) { if ((v[i] < 0 ? -v[i] : v[i]) > (stick[i] < 0 ? -stick[i] : stick[i])) stick[i] = v[i]; } +/* ((Triforce, 11-27) What last pushed the right stick, by source, for host/mouse_native.c's camera lines: a report of the + camera that stopped following Link at a load until R3 (state 4, the player's) said a Pro controller had just connected; + which source turned it is asked of the next such log. Written on the reading threads, read for a log line: no lock */ +enum { RS_SCRIPT, RS_PADS, RS_MOUSE, RS_KEYS, RS_N }; +static volatile struct { int64_t ns; int32_t x, y; } rs_seen[RS_N]; +static void rs_note(int src, const int32_t v[4]) { + if (v[2] || v[3]) rs_seen[src].x = v[2], rs_seen[src].y = v[3], rs_seen[src].ns = hos_now_ns(); +} +void hos_hid_rstick_said(char *out, size_t n) { + static const char *const names[RS_N] = {"a script or the control bridge", "a controller", "the mouse", "the camera keys"}; + const int64_t now = hos_now_ns(); + size_t at = 0; + out[0] = 0; + for (int i = 0; i < RS_N && at + 1 < n; i++) { + const int64_t ns = rs_seen[i].ns; + if (!ns || now - ns > 3000000000LL) continue; + const int w = snprintf(out + at, n - at, "%s%s (%d, %d) %lld ms ago", at ? "; " : "", names[i], (int)rs_seen[i].x, + (int)rs_seen[i].y, (long long)((now - ns) / 1000000)); + if (w < 0) break; + at += (size_t)w; + } + if (!out[0]) snprintf(out, n, "nothing in the last 3 s"); +} + /* ---- (hookshot) the controls: the gamepad input (by position) and the keys that press each Switch button, from triforce_options.ini beside the executable when it has them: pad_