diff --git a/docs/macos/configuration.md b/docs/macos/configuration.md index 8920bbf6c..98c053ff8 100644 --- a/docs/macos/configuration.md +++ b/docs/macos/configuration.md @@ -40,7 +40,9 @@ them for measurements or to isolate a problem. | `SHARPEMU_GUEST_BACKING` | chunked | `shm` backs guest memory with one POSIX shared-memory object instead of 2 MiB purgeable memory objects. The default allows memory the guest frees to return to the OS. | | `SHARPEMU_GUEST_BACKING_SHAREABLE` | unset | `1` makes the guest backing shareable with another process, and keeps a shared table and log of guest views. This is groundwork for the two-process split (`SHARPEMU_GPU_PROCESS=1` sets it too). See [Guest memory for the two-process split](split-shared-memory.md). | | `SHARPEMU_HLE_FAST_PATH` | on | `0` disables the native stubs for `pthread_self` and `pthread_getspecific`. They are also off while import or pthread tracing is active. | +| `SHARPEMU_TITLE_SCENE_RESOLUTION` | unset | Demon's Souls only (known build). Caps the game's internal scene size below the display: `900p`, `720p`, `540p` (any `p`, 16:9) or `WIDTHxHEIGHT`, at least 640x360. The game renders the scene at that size and upscales it itself; the output, display buffers and UI keep their sizes. Lowers image quality for frame time: on a base M4 at a 1080p display, about 78 ms per frame uncapped, 69 ms at `900p`, 63 ms at `720p`, 55 ms at `540p`. Below `540p` the picture breaks and nothing more is gained. | | `SHARPEMU_STALL_WATCHDOG_SECONDS` | `20` | Seconds without import progress before the stall watchdog acts. `0` disables it. | +| `SHARPEMU_FLIP_AHEAD` | off | Experimental. `1` tells the game a GPU flip is done once the flip is recorded and the flip before it has really finished on the GPU, instead of when the frame is shown, so the game can build its next frame while the GPU draws this one (at most one flip ahead). Each such frame is copied in the GPU stream into a presenter-owned texture (up to 7 textures the size of the display buffer), so what is shown is unchanged; a flip whose frame cannot be copied keeps the usual timing, and the refusal is logged once. Pacing, interrupts and labels are unchanged. Counters: `[VIDEOOUT][FLIP-AHEAD]` and the `flip_copy*` fields of `[METAL-PRESENT]`. | ## Metal memory @@ -50,6 +52,7 @@ them for measurements or to isolate a problem. | `SHARPEMU_METAL_V2_WINDOW_MB` | `1024` | Largest a window grows to hold one binding. 512 to 4096. | | `SHARPEMU_METAL_V2_IMAGE_BUDGET_MB` | computed | Fixed byte budget for the detiled image cache, at least 256. By default the budget follows the memory the host has free. | | `SHARPEMU_METAL_V2_SINGLE_COPY` | on | `0` never releases guest memory that a clean texture's Metal copy duplicates. Requires the chunked guest backing. | +| `SHARPEMU_METAL_V2_WHOLE_STALE_RELOAD` | on | `0` restores the old refusal: a GPU-written image whose every byte an alias has since written keeps its older texels instead of reloading them, and writes them back over the alias's bytes. For A/B comparisons only. | | `SHARPEMU_METAL_V2_STAGED_CACHE_MB` | `256` | Budget of the staged-range cache. | | `SHARPEMU_METAL_V2_TRANSIENT_COMMIT_MB` | `256` | Transient staging a command buffer may hold before it is committed early. | | `SHARPEMU_METAL_V2_RESIDENCY_SET` | off | `1` puts every guest window in an `MTLResidencySet`. | @@ -66,6 +69,9 @@ them for measurements or to isolate a problem. | `SHARPEMU_METAL_V2_BINARY_ARCHIVE_BUDGET_MB` | `8192` | Size bound of the archives on disk. | | `SHARPEMU_METAL_V2_ASYNC_PIPELINES` | on | `0` builds pipeline states on the GPU worker thread. | | `SHARPEMU_METAL_V2_ASYNC_LIBRARIES` | on | `0` compiles each shader library on the thread that needs it, not on the compile pool. | +| `SHARPEMU_RESOLVE_SHARDS` | `1` | Threads that resolve draw and dispatch programs ahead of the GPU worker, 1 to 8. With more than one, each has its own queue and its own part of the resolve memo, and a draw always goes to the same one. `1` is the single resolver; `2` measured no frame-time gain in Demon's Souls for more resolver CPU. Logged once at start; per-thread counts and the shared-lock wait are in the `shards=(...)` field of the `[METAL-V2][PERF]` prefetch counters. | +| `SHARPEMU_PREFETCH_EXACT_EFFECTS` | on | A dispatch or draw resolved ahead of a dispatch the host consumed as a kernel fill or copy is no longer refused for that alone: its take refuses it only when the fill's or copy's logged write covers what its resolution read (the same check as across any other dispatch). DCC and constant fills, image clears, metadata clears, image copies and CPU-predicted dispatches still refuse every dispatch and draw resolved ahead of them. The prefetch counters report `dispatch_effects=(...)` by kind and `exact_effects=(mode,refused,taken,draws,draw_refused,draw_taken)`, the jobs the old rule would have refused that the check refused or took. `dispatch` keeps the old rule for draws only; `0` refuses on every effect again. | +| `SHARPEMU_RESOLVE_UNSHARED_COMPUTE` | on | With more than one resolve shard, a dispatch whose kept program still holds, or whose kept program only needs new user data on a fast plan with a permutation already made, is answered on its own thread without the shared lock. `0` sends every dispatch through the shared lock. The `shards=(...)` counters split the shared-lock takes and wait by reason (`shared_by=`, `shared_wait_by=`) and count the dispatches answered without it (`unshared_compute=`) and why a rebinding still took it (`rebind_shared_by=`). | | `SHARPEMU_METAL_V2_PIPELINE_LIMIT` | `8192` | Pipeline states kept before idle ones are released. `0` is unlimited. | | `SHARPEMU_METAL_V2_MODULE_LIMIT` | `2048` | The same for shader modules. | | `SHARPEMU_METAL_V2_SHADER_EVICTION` | on | `0` keeps every pipeline and module. | @@ -97,10 +103,14 @@ undoes an optimization to isolate a miscompile: | `SHARPEMU_MSL_CONSTANTTABLES` | on | Reads uniform tables through the device address space. | | `SHARPEMU_MSL_LDSSIZE` | on | Declares all 32 KB of threadgroup memory. | | `SHARPEMU_MSL_MASKBALLOT` | on | Materializes every wave ballot. | +| `SHARPEMU_MSL_HALF_BRANCHES` | on | Tests the whole wave64 (an exchange between its two simdgroups) at every forward `S_CBRANCH_EXECZ` of a one-wave compute group, instead of letting each half skip a body that only touches its own lanes. | | `SHARPEMU_MSL_SPILLCOPY` | on | Reads spilled scalar registers through the lane exchange. | | `SHARPEMU_MSL_PERSISTENT_FENCES` | on | Leaves `S_WAITCNT` a no-op in persistent-thread kernels. | | `SHARPEMU_MSL_PERSISTENT_RECORDS` | on | Accesses multi-dword records of persistent-thread kernels dword by dword. | | `SHARPEMU_MSL_BYTEBIAS` | off | `1` keeps the per-buffer byte bias. | +| `SHARPEMU_MSL_FUSE_MAD` | on | Emits the guest's legacy multiply-adds (`V_MAD_F32`, `V_MAC_F32`) as one fused operation in compute programs and pixel programs without depth export. Faster (about 5 ms of an 82 ms Demon's Souls frame) but not bit-exact for MAD/MAC: the guest rounds the product first. `0` restores the exact two-op form. | +| `SHARPEMU_METAL_V2_BUFFER_WORD_CONSTANTS` | on | With portable buffers (`SHARPEMU_METAL_V2_PORTABLE_BUFFERS`, on), each buffer stride and format word a program reads at run time is also a Metal function constant. A draw draws through its pipeline as before and, once a background compile has made it, through a variant whose functions have the draw's words folded in (same pixels, faster vertex stage). Up to 16 variants a pipeline; mesh, rectangle-list and tessellation pipelines stay generic. A variant built once is stored in the title's binary archive (each specialized stage's library file, the pipeline in its segment), so later starts load it instead of compiling. The periodic counter line reports `buffer_words=[...]`, with where built variants came from (`from_file`, `from_library`: this process's own library, `from_msl`: the module's MSL compiled again, `msl_compiles`), `pipelines_compiled`, `files_rejected`, `unresident` and the builders' `build_ms` / `wait_ms`. `0` restores the previous MSL exactly. | +| `SHARPEMU_METAL_V2_BUFFER_WORD_COMPUTE` | on | The same variants for compute pipelines: a dispatch runs the generic pipeline until a background compile has made the one with its words folded in (same results). Off whenever `SHARPEMU_METAL_V2_BUFFER_WORD_CONSTANTS=0`. `0` keeps every compute dispatch on its generic pipeline while draws keep their variants, so the two can be measured apart; it does not change the MSL. The periodic counter line reports `buffer_words_compute=[...]` (`generic_off` counts dispatches the switch kept generic). | | `SHARPEMU_LOD_STATS` | guarded | `always` compiles the LOD statistics counters into every pixel pipeline. | ## Diagnostics @@ -112,12 +122,14 @@ undoes an optimization to isolate a miscompile: | `SHARPEMU_METAL_V2_WAIT_TRACE=1` (or `SHARPEMU_METAL_V2_EOP_TRACE=1`) | Names, on each `[METAL-V2][SLOW-WAIT]` line, the shader whose resources were being prepared. | | `SHARPEMU_METAL_V2_PROFILE_SHADERS=1` | Gives every draw and dispatch its own command buffer and prints GPU time per shader hash (`[METAL-V2][SHADER-PROF]`). It serializes the GPU, so only ratios are meaningful. | | `SHARPEMU_METAL_V2_PROFILE_TOP=` | Entries per profile report. Default 8. | -| `SHARPEMU_METAL_V2_PROFILE_PASSES=1` | Per-encoder GPU time (`[METAL-V2][PASS-PROF]`). | +| `SHARPEMU_METAL_V2_PROFILE_PASSES=1` | Per-encoder GPU time (`[METAL-V2][PASS-PROF]`). Blit encoders (`k=blit`), the tiler's compute encoders (`k=tiler-compute`) and the host's other compute encoders (`k=host-compute`) are recorded too, named for the transfer that opened them, so `gap_us` is time no encoder ran; the `sub` line sums GPU time per kind (`kind_us=`). | +| `SHARPEMU_DIAG_SKIP_ALL_DRAWS_AFTER_S=` | Diagnostic. From that many seconds after the GPU process translated its first draw, every draw is dropped before it is resolved or recorded; dispatches, labels and flips go on. Shows the frame time a draw path of no cost would leave. The picture is wrong by design; logged once when it starts. | | `SHARPEMU_PROFILE_RENDER=1` | Per-phase timing of the draw translation path on the GPU worker, reported at each flip. | | `SHARPEMU_METAL_V2_DUMP_TARGETS=` | Writes each render pass's color target and each presented frame as PNG. Waits for the GPU after each dump. `1` writes to `metal-targets` under the logs folder. | | `SHARPEMU_METAL_V2_DUMP_MAX=` | Maximum dumps. Default 240. | | `SHARPEMU_METAL_V2_DUMP_EVERY=` | Dump one frame's targets every `n` flips. | | `SHARPEMU_METAL_V2_DUMP_AFTER_SECONDS=`, `SHARPEMU_METAL_V2_DUMP_AFTER_FLIPS=` | Hold dumps back until the game has run that long, or flipped that many times. | +| `SHARPEMU_MSL_HALF_BRANCH_REPORT=1` | Prints, for each forward `S_CBRANCH_EXECZ` of a wave64 compute program, whether each half may take it alone and the first reason it may not (`[MSL][HALF-BRANCH]`). Works with the shader corpus replay. | | `SHARPEMU_SHADER_MSL_DUMP_DIR=` | Writes each translated program as `-.metal` with a `-.gen5` listing of the guest instructions. `1` writes to `msl-dumps` under the logs folder. | | `SHARPEMU_SHADER_MSL_DUMP_HASH=` | Restricts the dump to a comma-separated list of shader hashes. | | `SHARPEMU_METAL_V2_IGNORE_TESTS=1` | Drops culling, depth and stencil tests from every draw, to tell an empty pass from a rejected one. | @@ -127,6 +139,23 @@ undoes an optimization to isolate a miscompile: | `SHARPEMU_FRAME_TIMES=` | Writes one timestamp line per guest flip. `1` writes `frame-times-.txt` under the logs folder. | | `SHARPEMU_INPUT_FILE=` | Test automation: the file lists the keys held right now; it is polled every 30 ms and works without window focus. | +### Finding what overwrote guest memory + +These cost nothing until the game faults. When it does, the crash report names +the writes that covered the bytes you asked about. + +| Variable | Effect | +| --- | --- | +| `SHARPEMU_FAULT_DUMP=