mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 21:05:56 +00:00
Give the camera and interface the output's shape on 1.2.1, so 16:10 and 21:9 are not stretched.
The aspect patch set (recomp/patches-v121.txt) makes the world camera's DefaultAspect parameter default, the two camera-viewport updates that divide a 16:9 rectangle, and the five loads of the 2D canvas size read the patch page. resolution.c writes the output's aspect and the canvas factors there (wider than 16:9 the canvas grows in x, narrower in y) and switches the set on when the game resolution is not 16:9. The sites are those of Fruithapje21's TOTK-Ultrawide 1.2.1 patch (GPL-3.0, read for behaviour); a heap scan of the live projections confirmed the four world cameras take the new aspect. The interface keeps its 16:9 layout in the middle of the canvas: the per-layout edits that move it to the screen's edges are not done. A version without the set (1.4.3 for now) draws the largest 16:9 size inside the wanted one, letterboxed. The Steam Deck profile now draws the screen's own 1280x800, and the menu offers 16:10 and 21:9 game resolutions.
This commit is contained in:
1 parent
2f78585b4c
commit
f3ab1b0e76
7 files changed
+74
-17
No files matched your search
+4
-3
@@ -204,11 +204,12 @@ int cfg_load(const char *path) {
|
||||
// (default: the Steam Deck when the firmware says so), desktop (none) or deck.
|
||||
//
|
||||
// The Steam Deck (LCD Jupiter, OLED Galileo; 1280x800, 16:10, 4 Zen 2 cores, RDNA 2 with 8 CUs sharing 16 GB): the game
|
||||
// at 1280x720 with its own 5/6 scene, letterboxed in the 16:10 screen (TOTK_PICTURE_FIT) until the game draws 16:10
|
||||
// itself; fullscreen and vsync, as gamescope composes Game Mode; 40 fps, which divides 40 Hz (and 120 Hz on the OLED).
|
||||
// at the screen's 1280x800 with its own 5/6 scene (a version without the aspect patch draws 1280x720, letterboxed,
|
||||
// resolution.c); fullscreen and vsync, as gamescope composes Game Mode; 40 fps, which divides 40 Hz (and 120 Hz on the
|
||||
// OLED).
|
||||
// Starting points to replace with measured ones (docs/tester-guide.md, Steam Deck).
|
||||
static const struct { const char *key, *value; } DECK[] = {
|
||||
{"FULLSCREEN", "1"}, {"WINDOW_SIZE", "1280x800"}, {"OUTPUT_RES", "1280x720"}, {"RENDER_SCALE", "game"},
|
||||
{"FULLSCREEN", "1"}, {"WINDOW_SIZE", "1280x800"}, {"OUTPUT_RES", "1280x800"}, {"RENDER_SCALE", "game"},
|
||||
{"VK_PRESENT", "fifo"}, {"FPS_LIMIT", "40"},
|
||||
};
|
||||
static int profile = -1; // 0 none, 1 Steam Deck
|
||||
|
||||
+28
-1
@@ -5,7 +5,8 @@
|
||||
// MacNativeGames contributors) make the game read both sizes from the patch page, and the texture heap that holds the
|
||||
// output- and scene-sized render targets grows with them.
|
||||
//
|
||||
// Settings, read at start: TOTK_OUTPUT_RES = <w>x<h> (default 1920x1080, the game's own), TOTK_RENDER_SCALE = the
|
||||
// Settings, read at start: TOTK_OUTPUT_RES = <w>x<h> (default 1920x1080, the game's own; another shape than 16:9 gets
|
||||
// a camera and interface canvas of that shape, aspect_init), TOTK_RENDER_SCALE = the
|
||||
// scene's size relative to the output: "game" (default, 5/6, the game's 1600x900 at 1080p) or a percentage; above 100
|
||||
// the game supersamples its scene, which smooths edges (anti-aliasing) at the cost of GPU time. The game's own final
|
||||
// pass (FSR 1 EASU) scales the scene to the output; the present scales the output to the window (vk_fsr.c).
|
||||
@@ -41,6 +42,7 @@
|
||||
#define SCENE_H 900
|
||||
#define DTA_KIB 113664u // DynamicTextureAllocatorMem, shipped
|
||||
#define SCENE_MAX 4096 // per side, as MacNativeGames' TOTK_RENDER_RES
|
||||
#define ASPECT_EPS 0.002 // an output this close to 16:9 is 16:9 (1366x768 is 1.7786)
|
||||
|
||||
static struct {
|
||||
int decided;
|
||||
@@ -64,6 +66,16 @@ static void decide(void) {
|
||||
} else {
|
||||
rt_log("resolution: TOTK_OUTPUT_RES=%s is not <width>x<height> in 1280x720..7680x4320; 1920x1080", o);
|
||||
}
|
||||
// A game version without the aspect set draws 16:9 only: the largest 16:9 size inside the wanted one, which the
|
||||
// present letterboxes in a window of the wanted shape (TOTK_PICTURE_FIT)
|
||||
double a = (double)R.ow / R.oh, base = (double)BASE_W / BASE_H;
|
||||
if (fabs(a - base) >= ASPECT_EPS && rt_patch_set("aspect") < 0) {
|
||||
unsigned w = R.ow, h = R.oh;
|
||||
if (a > base) R.ow = (unsigned)(R.oh * base + 0.5) & ~1u;
|
||||
else R.oh = (unsigned)(R.ow / base + 0.5) & ~1u;
|
||||
rt_log("resolution: this game version has no aspect patch set: %ux%u draws %ux%u (16:9), letterboxed", w, h, R.ow,
|
||||
R.oh);
|
||||
}
|
||||
const char *s = cfg_value("TOTK_RENDER_SCALE");
|
||||
double k = 5.0 / 6.0;
|
||||
if (strcmp(s, "game")) {
|
||||
@@ -188,6 +200,20 @@ int res_heapdef_build(const void *in, size_t n, void **out, size_t *out_n) {
|
||||
|
||||
void res_heapdef_served(void) { R.heapdef_ok = 1; }
|
||||
|
||||
// ---- aspect ratio: an output of another shape than 16:9 gets a camera and a 2D canvas of its shape (the aspect set,
|
||||
// recomp/patches-v121.txt). Page +64 the aspect, +68 and +72 the factors of the canvas width and height: wider than 16:9
|
||||
// the canvas grows in x, narrower in y, so the 16:9 layouts keep their proportions and sit in the middle of it.
|
||||
static void aspect_init(uint8_t *page) {
|
||||
int set = rt_patch_set("aspect"); // decide() kept a version without it at 16:9
|
||||
double a = (double)R.ow / R.oh, base = (double)BASE_W / BASE_H;
|
||||
if (fabs(a - base) < ASPECT_EPS || set < 0) return;
|
||||
float v[3] = {(float)a, (float)(a > base ? a / base : 1.0), (float)(a < base ? base / a : 1.0)};
|
||||
memcpy(page + 64, v, sizeof v);
|
||||
rt_patch_switch(set, 1);
|
||||
rt_log("resolution: aspect %.4f (%ux%u): camera and interface canvas follow it (x %.4f, y %.4f)", a, R.ow, R.oh, v[1],
|
||||
v[2]);
|
||||
}
|
||||
|
||||
// ---- start: the patch page and the sets
|
||||
static uint64_t pack(unsigned w, unsigned h) { return (uint64_t)h << 32 | w; }
|
||||
|
||||
@@ -218,6 +244,7 @@ void res_init(void) {
|
||||
rt_patch_switch(output, R.ow != BASE_W || R.oh != BASE_H);
|
||||
rt_patch_switch(scene, scene_on);
|
||||
R.on = 1;
|
||||
aspect_init(page);
|
||||
rt_log("resolution: output %ux%u, scene %ux%u%s; texture heap +%llu KiB", R.ow, R.oh, R.sw, R.sh,
|
||||
scene_on ? "" : " (the game's own 5/6 of the output)", (unsigned long long)res_heap_extra_kib());
|
||||
}
|
||||
|
||||
+3
-2
@@ -412,8 +412,9 @@ static void row_window_size(void) {
|
||||
// The game resolution (resolution.c): 16:9 sizes from the game's own 1920x1080 up, and the current value when it is
|
||||
// another size.
|
||||
static void row_output_res(void) {
|
||||
// 1280x720: the Steam Deck's (letterboxed in its 1280x800 screen, TOTK_PICTURE_FIT)
|
||||
static const char *const vals[] = {"1280x720", "1600x900", "1920x1080", "2560x1440", "3200x1800", "3840x2160"};
|
||||
// 16:9, 16:10 (the Steam Deck's 1280x800) and 21:9 sizes: the aspect patch gives the game the output's shape
|
||||
static const char *const vals[] = {"1280x720", "1280x800", "1600x900", "1920x1080", "1920x1200",
|
||||
"2560x1080", "2560x1440", "3440x1440", "3200x1800", "3840x2160"};
|
||||
enum { N = sizeof vals / sizeof *vals };
|
||||
char shown[N][32];
|
||||
const char *names[N];
|
||||
|
||||
+5
-4
@@ -51,8 +51,9 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
||||
[UI_PERF_LINE_FPS] = "%.0f fps",
|
||||
[UI_MENU_GRAPHICS] = "Picture",
|
||||
[UI_MENU_OUTPUT_RES] = "Game resolution",
|
||||
[UI_MENU_OUTPUT_RES_DESC] = "The size the game draws its picture and interface in. Above 1920 x 1080 the game needs "
|
||||
"more video memory and GPU time.",
|
||||
[UI_MENU_OUTPUT_RES_DESC] = "The size the game draws its picture and interface in. A 16:10 or 21:9 size gives the "
|
||||
"camera and the interface that shape. Above 1920 x 1080 the game needs more video memory "
|
||||
"and GPU time.",
|
||||
[UI_MENU_RENDER_SCALE] = "3D render scale",
|
||||
[UI_MENU_RENDER_SCALE_DESC] = "Size of the 3D scene relative to the game resolution; the game's FSR scales it to "
|
||||
"that size. Above 100 % smooths jagged edges (supersampling) at a high GPU cost.",
|
||||
@@ -275,8 +276,8 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
||||
[UI_PERF_LINE_FPS] = "%.0f к/с",
|
||||
[UI_MENU_GRAPHICS] = "Изображение",
|
||||
[UI_MENU_OUTPUT_RES] = "Разрешение игры",
|
||||
[UI_MENU_OUTPUT_RES_DESC] = "Размер, в котором игра рисует картинку и интерфейс. Выше 1920 × 1080 игре нужно больше "
|
||||
"видеопамяти и времени GPU.",
|
||||
[UI_MENU_OUTPUT_RES_DESC] = "Размер, в котором игра рисует картинку и интерфейс. Размер 16:10 или 21:9 даёт камере и "
|
||||
"интерфейсу эту форму. Выше 1920 × 1080 игре нужно больше видеопамяти и времени GPU.",
|
||||
[UI_MENU_RENDER_SCALE] = "Масштаб 3D-отрисовки",
|
||||
[UI_MENU_RENDER_SCALE_DESC] = "Размер 3D-сцены относительно разрешения игры; FSR игры доводит её до этого размера. "
|
||||
"Выше 100 % сглаживает лесенки на краях (суперсэмплинг) ценой большой нагрузки на GPU.",
|
||||
|
||||
Reference in new issue
Block a user