# Title profiles The engine is generic: a translator of console and system interfaces. What it knows of one title (where to patch its executable, which of its shaders play which role for the engine, and data tables) lives in a **title profile**, a file kept outside this repository. The engine reads one at start if one is there. Without one it runs the title as generically as it can, every feature that needs the profile is off, and the log says which. This repository holds the engine side only: the reader (`crates/victory-profile`), the roles it knows, the refusal rules, and tests with a made-up executable. It holds no profile of any real title. ## Where a profile is looked for In order: 1. the folder named by `VICTORY_TITLE_PROFILE_DIR`; 2. `%LOCALAPPDATA%\foxhound\profiles\`, where `` is the BLAKE3 hash of the executable's file in hex: what the launcher's **Load title profile…** installs, so a profile installed on purpose wins over a stray copy; 3. the folder of the title's executable; 4. the folder of `victory.exe`; 5. the launcher's folder (`VICTORY_LAUNCHER_DIR`, which the launcher passes); 6. one level of folders inside 3 to 5 (an archive unpacked as it is, `install\profile.toml`). In each folder the engine reads `profile.toml`, then any other `profile*.toml` (a browser's renamed copy such as `profile (1).toml`). The first profile for this executable is used. If there is none, the first profile for another copy of the executable is used for its shaders' roles and tables only (see below). When more than one profile is found, the log names the one used and the others. When none is found, the log lists every folder searched and the executable's hash. Profile files are read as UTF-8 (with or without a byte-order mark) or as UTF-16 with its mark. ### A changed or updated executable A profile names the executable it is for by the hash of its file. A profile for another copy (a patched or updated executable) is still used for its shaders' roles and its tables. Its patch groups (output size, upscaler route, frame rate) and places are not used, because their offsets belong to the other file; the log says so (`exe=differs`). If a copy kept beside the executable (a `.bak` or `.orig`, or another file named after it) is the one the profile is for, the log says to put that copy back. `VICTORY_PROFILE_ANY_EXE=0` refuses such a profile whole instead. ### The launcher's line `victory title-profile status ` prints one line that starts with `PROFILE `: - `PROFILE loaded | groups= | tables=ok|missing: | roles=/ | bcpack=ok|missing | file=`, then ` | exe=differs` for a profile of another copy and ` | others=` for profiles found and not used; - `PROFILE not-loaded | searched=;;.. | bcpack=ok|missing`; - `PROFILE refused | `. `roles=/` counts the roles below that the profile names shaders for (a family counts once). The launcher shows the line and, without a profile loaded, greys the options that need one. **Load title profile…** runs `victory title-profile install `. The chosen profile and its table files are checked first, and nothing is copied if one is missing or malformed. Then they are copied into place 2 under the names the profile gives, whatever names they had (a renamed download is found by its hash). The command then prints the same line. Picking `bcpack-tables.bin` by mistake installs the profile beside it. The run prints the profile state and its own version on the error stream whatever the log filter, so a log at `warn` still shows them. The shader commands take the executable from `VICTORY_TITLE_EXE` (the launcher sets it), else the folder they are given. ### The BCPack table file Textures packed with BCPack need the format's table file, `bcpack-tables.bin`, which is not part of this repository. The engine takes the first usable one of: 1. the file `VICTORY_BCPACK_TABLES` names; 2. the profile's `bcpack` table (checked against the hash the profile gives); 3. a `bcpack*.bin` file in the places above, with or without a profile. Each must parse; one that does not is said, and the next is tried. Without any, packed textures are filled with flat grey blocks of their kind and a line says how many (`VICTORY_BCPACK_NEUTRAL=0`: such reads fail instead, as in 0.8.3, and their textures keep whatever their memory held). ### The pipeline list A run with `VICTORY_PIPELINE_BOOK=1` (the launcher sets it) writes down every pipeline the title creates, and the next "Getting ready" compiles them ahead (`victory warm`). Before a first run there is nothing written down, so a first run compiles each pipeline when it is first drawn. A profile's `pipelines` table lists them instead: entries as the record in the cache folder has them (a key, the stage and BLAKE3 hash of each shader, and the Direct3D 12 state: blend, rasterizer, depth, input layout, formats), without the shaders themselves. `victory warm` adds the listed entries the record lacks before it compiles. It reads each shader they need from the title's own files, found by its hash (the folder of `VICTORY_TITLE_EXE`, else the configured game folder), and says what came of it in one line: `title profile pipelines: listed, in the record already, added, without their shaders in the game's files`. An entry whose shaders are not all found (another version of the title) is not added. `VICTORY_PIPELINE_LIST=` takes a list file in place of the table. `victory title-profile pipelines ` writes the record in the cache folder as such a list, the pipelines that runs drew with first (`warm` compiles in the list's order after those), and prints the `[[table]]` lines that name it. Engines before 0.8.3.5 read the profile and ignore the table. ## The file `profile.toml`, plain text, with binary tables beside it: ```toml format = 1 [image] blake3 = "…64 hex digits…" # the executable's file [[patch]] group = "some_group" # applied all or nothing offset = 0x1234 # in the executable's image, as loaded stock_len = 8 # bytes checked from offset (default: as many as `replace` has) stock_blake3 = "…64 hex…" # BLAKE3 of those bytes; or stock = "…hex…", the bytes themselves replace = "b8 {rate:u32} .. 90" # a template: hex bytes, `..` keeps a byte, {value:width} the engine fills in [[place]] # an offset read while running (diagnostics), never written name = "some_place" offset = 0x5678 # or value = 0x48, a number [[shader]] role = "bake" # what the engine does with it hash = "0123456789abcdef" # the engine's 16-hex id of the program (roles told by hash) # or, for roles told by name: # name_len = 24 # name_fnv = "…16 hex…" # FNV-1a 64 of the name # or, for roles told by digest (the 16 bytes the shader's container carries): # digest = "…32 hex…" [[code_patch]] # a patch of a shader's own code before translation role = "tiled_light_writers" digest = "…32 hex…" # by digest only: the translator has nothing else at hand offset = 0x40 # in the program expect = "…hex…" # the bytes there; a shader that differs is left alone replace = "…hex…" # as many bytes as `expect` [[table]] name = "bcpack" file = "bcpack-tables.bin" # beside profile.toml (or in the places above) blake3 = "…64 hex…" [[table]] name = "pipelines" # optional: the pipeline list (see above) file = "pipelines.bin" blake3 = "…64 hex…" ``` Unknown keys refuse the file (a misspelling is not silently ignored). ## Patch templates and the values the engine fills in A patch's `replace` is a template. Each value is written little-endian, and only the engine fills it in, from its own settings, never from the profile: | Value | Width | What it is | |---|---|---| | `rate` | u32 | the frame rate the program is given (`VICTORY_FRAME_INTERVAL_MS`, `VICTORY_TITLE_FPS`); 0 for no limit | | `sim_rate` | u32 | the rate its shortest timer step is made of: `rate`, or 1000 for no limit | | `output_width`, `output_height` | u32 | the display mode of a native output; in `interface_canvas`, the output's size | | `scanout_bytes` | u32 | the scanout reservation for that mode (two tiled RGBA8 surfaces, rounded to 2 MiB); with `interface_canvas`, two of the output and two of the 3840x2160 canvas | | `scene_scale` | f32 | the scene's scale of the output | | `upscaler_mode` | u8 | the FidelityFX quality mode (0 native AA to 4 ultra performance) | | `upscaler_scale` | f32 | that mode's scale | | `max_step` | f32 | the longest step the program's timers take, in seconds (`VICTORY_MAX_STEP_MS`, 250 ms by default) | The engine applies these groups when asked: `native_output` and `scene_scale` for a native output (`VICTORY_NATIVE_1440P`, `VICTORY_NATIVE_ULTRAWIDE`, `VICTORY_RENDER_1080P`), with `interface_canvas` beside them for a 16:9 output smaller than 3840x2160 (see below), `upscaler_path` for the upscaler route (DLSS, FSR in its place, `VICTORY_FSR_PATH`), `frame_rate` for a frame rate, and `max_step` for the game speed at low frame rates (unless `VICTORY_MAX_STEP_MS=off`). A group is applied all or nothing. Every site's stock bytes are checked first, and nothing is written if one differs or if the group asks for a value the run has not given. A template value the engine does not know refuses that group, not the profile. A width other than the value's own refuses the profile. Without a profile, or without the group, the program keeps its own output, upscaling and frame rate, and the run says so once. ### The interface canvas A program made for the console lays its interface out on the console's 3840x2160 display mode. Given a smaller output as its display mode, it lays the interface out at that size, so the interface is larger than on the console, and menus can run past the screen. The `interface_canvas` group keeps the canvas: its sites have the program lay the interface out on 3840x2160 and scale it to the output, whose size the group's `output_width` and `output_height` give. With it, `native_output` is written with the canvas as the display mode, and its `scanout_bytes` holds the canvas's surfaces beside the output's. The display mode reported to the program is then the canvas too. The engine uses the group for a 16:9 output smaller than the canvas (2560x1440), when the profile has it and its stock bytes are there. Without the group, the interface is laid out at the output's size, as before, and the run says so once. `VICTORY_INTERFACE_CANVAS=0` asks for that layout with a profile that has the group. Wider outputs (3440x1440, 1920x1200) keep their own layout. An engine that does not know the group leaves it unused, so a profile with it still serves such an engine. A group writes every one of its sites each time it is applied, whatever the values. For some values a site's result can equal what the program already holds there, or a site can redirect a load to a literal holding the same value the stock constant holds. The engine does not skip such sites, because a rule that skips sites for particular values would be logic about one program. The program behaves the same, but its image is not byte for byte what code that skipped those writes made. Where this applies, profiles are checked against such code by behaviour, not by bytes alone. ## Roles A role names what the engine does with a shader, never what the title calls it. Each role's shaders are told in one way only: by the engine's **hash** of the program (the 16 hex digits the frame listings print), by its container's **digest**, or by its **name** (`name_len` and `name_fnv`). A shader told in another way could never be matched; it is left out with a line. | Role | Told by | The engine… | |---|---|---| | `bake` | hash | uploads the textures a bake's pixel shader picks by index before it draws, and makes its pipelines at creation | | `bake_geometry` | hash | treats it as the geometry stage of a bake (catching pixel shaders the profile does not list) | | `interface_composite` | hash | takes the picture before the pipeline that holds every shader of the role as the scene without the interface (frame generation) | | `scene_input` | hash | makes its pipeline at creation, before the first frame needs it | | `face_shapes` | hash | gives it the blend-shape map made at creation, and makes its pipeline once at its first use | | `leave_out` | hash | does not run it (`VICTORY_LEAVE_OUT` adds hashes; `VICTORY_LEAVE_OUT_PROFILE=0` runs the role's shaders) | | `lds_unbounded` | hash | translates it without the shared-memory bounds checks (`VICTORY_LDS_UNBOUNDED=0`: bounded like every other) | | `rt_resolve` | name | leaves it out of cold pipeline making while ray tracing is skipped | | `probe_ray_activation` | name | leaves it out of cold pipeline making while probe rays are skipped | | `ambient.*` | name | uses it for the stand-in for indirect light: `ambient.resolve`, `ambient.radiance`, `ambient.air`, `ambient.miss`, one input each | | `water.*` | hash | `water.leave_out`: does not run it with `VICTORY_WATER_LEAVE_OUT=1` (the launcher's water setting "nopatches"); other `water.` roles are accepted and read by nothing in this version | | `pass.*` | hash | counts it in the culling census under that number (`pass.0` to `pass.8`) | | `scene_kernel_64` | digest | gives programs of groups of 64 the wave-wide form on a 32-lane host | | `wave_wide` | digest | gives programs of groups of 128 the wave-wide form on a 32-lane host | | `wave_wide_refused` | digest | gives the wave-wide form to programs otherwise refused (`VICTORY_WAVE_WIDE_REFUSED`) | | `meet_lowering` | digest | lets the halves of a two-wave group meet per console wave where not every thread arrives (`VICTORY_MEET_LOWERING`) | | `tile_list_append` | digest | replaces a tile-list program's wave-wide slot allocation with one slot per lane (`VICTORY_WATER_TILE_APPEND`) | | `tile_list_local_plain` | digest | sends that program's tiles with local lights to the plain list (`VICTORY_WATER_LOCAL_PLAIN`) | | `tiled_light_writers` | digest | lets every lane of a tiled light program write where one lane did (`VICTORY_WATER_ALL_WRITE`) | | `shadow_rays` | name | treats the program's rays as shadow rays (`VICTORY_SHADOW_RAYS_LIT`) | | `early_pipeline` | hash | accepted, and read by nothing in this version | | `cull_census` | hash | accepted, and read by nothing in this version | Translator roles: `scene_kernel_64`, `wave_wide`, `wave_wide_refused`, `meet_lowering`, `tile_list_append`, `tiled_light_writers`, `tile_list_local_plain`, `shadow_rays`, `lds_unbounded`. The translator roles and the code patches decide how shaders are translated. The profile's translation key (a digest of those alone, with the format number) is part of the shader cache's key, so a profile that changes a translation translates anew, and one that changes only other roles does not. The run and the shader commands (`victory shaders`, `victory warm`) read the same profile in the same way. The run logs the shaders per role it read (`title profile: shaders per role`). A role the engine does not know is left out with a line, not an error. A `[[code_patch]]` given by hash is read, said, and never applied, because code patches are matched by digest. ## Refusals - **Another executable:** used for its roles and tables only (see above), or refused whole with `VICTORY_PROFILE_ANY_EXE=0`. - **Another format number:** the whole profile is refused (read before the rest, so a newer format with new keys is said as such). - **Patch sites that overlap**, in one group or in two: the whole profile is refused. - **A table file that is not a plain name** (a folder, a drive, a stream): the whole profile is refused. - **A patch group whose stock bytes differ** at any of its sites (or cannot be read): the group is skipped whole; nothing of it is written. Other groups are checked on their own. - **A table whose file is missing or hashes otherwise:** that table is refused, and the launcher's line says `tables=missing:`; the feature that needs it is off (for `bcpack`, see the BCPack table file above). - **A malformed entry:** the whole profile is refused, with the entry named. Every line says file names and hashes, never title words. ## Making a profile A profile is made by whoever has the knowledge of a title, from the values that title needs. It is not part of this repository, and none is distributed from here.