mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 06:05:56 +00:00
Add a Steam Deck profile and keep the picture's proportions on screens of another shape.
The present fits the game's picture into the largest centred rectangle of its own aspect ratio and clears the rest to black (gfx_fit_rect, through both the blit and FSR), so a 16:9 game on the Deck's 16:10 screen is no longer stretched; picture_fit = stretch keeps the old fill. probe-window checks the bars as well as the picture. device_profile = auto|desktop|deck: on a Steam Deck (the firmware's Valve Jupiter or Galileo board, or SteamDeck=1) the keys totk.ini does not set default to fullscreen, a 1280x800 window, a 1280x720 game resolution, the game's own scene scale, vsync and a 40 fps limit; the environment and totk.ini still win. These are starting points until measured on the device (docs/tester-guide.md, Steam Deck). Both stick clicks (L3 + R3) step the performance overlay as F10 does, for a controller with no keyboard. The menu offers 1280x720 and 1600x900 game resolutions and 40, 45 and 90 fps limits.
This commit is contained in:
1 parent
29a14d69fe
commit
2f78585b4c
15 files changed
+200
-35
No files matched your search
+28
-4
@@ -510,6 +510,20 @@ static void save_capture(const char *path) {
|
||||
rt_log("gfx: menu test shot %s (%dx%d)", path, g_cap_w, g_cap_h);
|
||||
}
|
||||
|
||||
// The rectangle {x, y, w, h} of a dw x dh swapchain image the cw x ch picture goes into: the whole image with
|
||||
// TOTK_PICTURE_FIT=stretch, else the largest one of the picture's own aspect ratio, centred (a 16:9 picture on the Steam
|
||||
// Deck's 1280x800 screen gets bars of 40 rows above and below; a wider window, bars at the sides).
|
||||
void gfx_fit_rect(int cw, int ch, int dw, int dh, int out[4]) {
|
||||
out[0] = out[1] = 0, out[2] = dw, out[3] = dh;
|
||||
if (cw <= 0 || ch <= 0 || !strcmp(cfg_value("TOTK_PICTURE_FIT"), "stretch")) return;
|
||||
if ((int64_t)dw * ch > (int64_t)dh * cw) out[2] = (int)(((int64_t)dh * cw + ch / 2) / ch); // window wider: pillarbox
|
||||
else out[3] = (int)(((int64_t)dw * ch + cw / 2) / cw); // taller: letterbox
|
||||
out[2] += out[2] & 1, out[3] += out[3] & 1; // even sizes keep the bars equal
|
||||
if (out[2] > dw) out[2] = dw;
|
||||
if (out[3] > dh) out[3] = dh;
|
||||
out[0] = (dw - out[2]) / 2, out[1] = (dh - out[3]) / 2;
|
||||
}
|
||||
|
||||
static void present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w, int h, const int crop[4], int defer) {
|
||||
int general = layout == VK_IMAGE_LAYOUT_GENERAL;
|
||||
gfx_window_start();
|
||||
@@ -566,16 +580,26 @@ static void present_image(VkImage src, VkImageLayout layout, VkFormat fmt, int w
|
||||
sync_barrier(cb, dst, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_2_TRANSFER_BIT, 0,
|
||||
VK_PIPELINE_STAGE_2_TRANSFER_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT);
|
||||
const int rect[4] = {cx, cy, cw, ch};
|
||||
// FSR (TOTK_UPSCALER) when the swapchain is larger than the crop; else the bilinear blit
|
||||
int fsr = general && vk_fsr_record(cb, slot, src, fmt, w, h, rect, dst, g_sc_ext.width, g_sc_ext.height);
|
||||
g_scaler = fsr ? 2 : (uint32_t)cw != g_sc_ext.width || (uint32_t)ch != g_sc_ext.height;
|
||||
int to[4]; // where the picture goes in the swapchain image: {x, y, w, h}
|
||||
gfx_fit_rect(cw, ch, (int)g_sc_ext.width, (int)g_sc_ext.height, to);
|
||||
if (to[2] != (int)g_sc_ext.width || to[3] != (int)g_sc_ext.height) { // black bars beside or above and below it
|
||||
VkClearColorValue black = {.float32 = {0, 0, 0, 1}};
|
||||
VkImageSubresourceRange all = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
vkCmdClearColorImage(cb, dst, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &black, 1, &all);
|
||||
sync_barrier(cb, dst, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_2_TRANSFER_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_2_TRANSFER_BIT,
|
||||
VK_ACCESS_2_TRANSFER_WRITE_BIT);
|
||||
}
|
||||
// FSR (TOTK_UPSCALER) when the picture's rectangle is larger than the crop; else the bilinear blit
|
||||
int fsr = general && vk_fsr_record(cb, slot, src, fmt, w, h, rect, dst, to[0], to[1], (uint32_t)to[2], (uint32_t)to[3]);
|
||||
g_scaler = fsr ? 2 : cw != to[2] || ch != to[3];
|
||||
if (!fsr) {
|
||||
if (general) // a GENERAL source (vk_texture.c images): earlier submissions' writes become visible to the blit here
|
||||
sync_barrier(cb, src, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL, VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
||||
VK_ACCESS_2_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_2_TRANSFER_BIT, VK_ACCESS_2_TRANSFER_READ_BIT);
|
||||
VkImageBlit region = {
|
||||
.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .srcOffsets = {{cx, cy, 0}, {cx + cw, cy + ch, 1}},
|
||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .dstOffsets = {{0, 0, 0}, {(int)g_sc_ext.width, (int)g_sc_ext.height, 1}}};
|
||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, .dstOffsets = {{to[0], to[1], 0}, {to[0] + to[2], to[1] + to[3], 1}}};
|
||||
vkCmdBlitImage(cb, src, general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion, VK_FILTER_LINEAR);
|
||||
if (general) // later submissions that write the source wait for the blit's read
|
||||
|
||||
Reference in new issue
Block a user