mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-24 21:55:57 +00:00
Merge remote-tracking branch 'origin/dev' into perf/heap-lazy-commit
# Conflicts: # runtime/cfg.c
This commit is contained in:
commit
54b2975d98
91 files changed
+11601
-528
No files matched your search
+13
-12
@@ -33,7 +33,7 @@ static int save_ok = 1; // the last cfg_save_to wrote (o
|
||||
// logged as unknown. A new variable goes here too, or its ini key logs a harmless "unknown key" line, and gets a
|
||||
// description in totk.ini.example or docs/settings.md (tests/settings_doc_check.py checks both).
|
||||
static const char *const known[] = {
|
||||
"AB", "ABILITY_GUARD", "ADDR_REPORT", "AMIIBO_DIR", "ANISO", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_CHANNELS", "AUDIO_DEVICE", "AUDIO_DRAIN_FIX", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"AB", "ABILITY_GUARD", "ADDR_REPORT", "AMIIBO_DIR", "ANISO", "ANV_VS_BARRIER", "APP_POOL", "ASPECT", "ASPECT_PATCH", "ASSUME_FOCUS", "ASTC", "ASTC_BC", "ASTC_TIME", "ASYNC_PREEMPT", "AUDIO", "AUDIO_CHANNELS", "AUDIO_DEVICE", "AUDIO_DRAIN_FIX", "AUDIO_OFF", "AUDIO_PREFILL_MS",
|
||||
"BACKGROUND_WINDOW", "BIND_A", "BIND_B", "BIND_DOWN", "BIND_L", "BIND_LCLICK", "BIND_LEFT", "BIND_LSTICK_DOWN", "BIND_LSTICK_LEFT",
|
||||
"BIND_LSTICK_RIGHT", "BIND_LSTICK_UP", "BIND_MINUS",
|
||||
"BIND_PLUS", "BIND_R", "BIND_RCLICK", "BIND_RIGHT", "BIND_RSTICK_DOWN", "BIND_RSTICK_LEFT", "BIND_RSTICK_RIGHT", "BIND_RSTICK_UP",
|
||||
@@ -44,7 +44,7 @@ static const char *const known[] = {
|
||||
"DESC_TEMPLATE", "DESWIZZLE", "DEVICE_PROFILE", "DIALOGUE_CLICK", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_CAM_JITTER", "DLAA_EFFECTS_AFTER", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_FIXED_EXPOSURE", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
|
||||
"DUMP_LOG", "DYNAMIC_RES", "DYN_DELTA", "EXEFS", "FEEDBACK", "FG_DEBUG", "FG_OBJECTS", "FG_SHOT", "FG_SHOT_DIR", "FG_TEST", "FG_TIMES", "FIXED_RES_PATCH", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES",
|
||||
"FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FLUSH_SPAN", "FOV", "FOV_PATCH", "FPS60", "FPS_LIMIT", "FRAME_GEN", "FRAME_QUEUE", "FREECAM_KEY", "FREECAM_PAD", "FREECAM_PATCH",
|
||||
"FREEZE_IDLE", "FREE_CORES", "FSR3_DEBUG", "FSR3_VIEW", "FSR_SHARPNESS",
|
||||
"FREEZE_IDLE", "FREE_CORES", "FSR3_DEBUG", "FSR3_VIEW", "FSR4_DEBUG", "FSR_SHARPNESS",
|
||||
"FULLSCREEN", "FXAA",
|
||||
"GAMEPLAY_DISTANCE_SENSITIVITY", "GAMEPLAY_ITEM_AD", "GAMEPLAY_ITEM_SENSITIVITY", "GAMEPLAY_ITEM_WHEEL",
|
||||
"GAMEPLAY_MAP_ZOOM", "GAMEPLAY_MAP_ZOOM_SENSITIVITY", "GAMEPLAY_ROTATION_SENSITIVITY", "GAMEPLAY_TWEAKS_ENABLED",
|
||||
@@ -53,20 +53,20 @@ static const char *const known[] = {
|
||||
"GPL", "GPL_DRAW_BUILD", "GPU", "GPU_INDEX", "GPU_NAME", "GRASS_RANGE",
|
||||
"GYRO_AUTO_BIAS", "GYRO_BIAS_PAD", "GYRO_BIAS_X", "GYRO_BIAS_Y", "GYRO_BIAS_Z", "GYRO_CALIBRATION", "HDR", "HDR_GAME_NITS", "HDR_HUE",
|
||||
"HDR_PEAK_NITS", "HDR_UI_NITS", "HEAP_LAZY", "HIGHFPS_FIX", "HUD_WIDTH", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "KSPIN_US", "LANG", "LIB_PREBUILD",
|
||||
"LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "LOD_STEADY", "LSTICK_DEADZONE", "MAP_CLICK", "MEMORY", "MEMX", "MENU_LANG", "MENU_TEST", "MENU_FONT_FONTCONFIG",
|
||||
"LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LIGHTNING_FIX", "LOCALE", "LOD_GUARD", "LOD_STEADY", "LSTICK_DEADZONE", "MAP_CLICK", "MEMORY", "MEMX", "MENU_LANG", "MENU_TEST", "MENU_FONT_FONTCONFIG",
|
||||
"MEM_RESERVE_MIB", "MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_NO_CODE", "MODS_ORDER", "MODS_REBUILD", "MODS_WITHOUT_CODE", "MOTION", "MOUSE_AIM_SCALE", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_ASPECT", "MOVIE_HOST", "MOVIE_PACE",
|
||||
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
|
||||
"MV_SURVEY",
|
||||
"MV_SURVEY", "NULL_ATTACH",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OPTREF_GUARD", "OUTPUT_RES", "PAD_LAYOUT", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_SCENE", "PCORE", "PCSS", "PCSS_K", "PERF_CENSUS", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "PLUGIN_TICK_OFFSET", "PLUGIN_TRACE", "POINTER_IMAGE",
|
||||
"PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_BENCH", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "QUICKLOAD_KEY", "QUICKSAVE", "QUICKSAVE_KEY", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REC_ASYNC", "REC_END", "REC_SPIN_US", "REEXEC", "REFLEX",
|
||||
"RENDER_SCALE", "REPLAY_ASYNC", "REPLAY_CHUNKS", "REPLAY_CHUNK_DRAWS", "REPLAY_SKEW_US", "REPLAY_STATE_CHECK", "REPLAY_WORKERS",
|
||||
"REPLAY_CHECK", "REPORT_GUARD", "RESOLVE_CHECK", "RESTART_WAIT", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES",
|
||||
"REPLAY_CHECK", "REPORT_GUARD", "RESOLVE_CHECK", "RESTART_WAIT", "RESTBL_CACHE", "ROMFS", "ROMFS_INDEX", "ROMFS_MMAP", "ROMFS_MODS", "ROMFS_PATCHES",
|
||||
"ROMFS_PROOF_DIR", "ROMFS_VERIFY", "RSTICK_DEADZONE", "RUMBLE", "RUMBLE_CURVE", "RUMBLE_STRENGTH", "RUMBLE_TRIGGERS", "SCENE_UPSCALER", "SHADER_CACHE",
|
||||
"SHADER_MEMO", "SHADOW", "SHADOW_DEFER", "SHADOW_RANGE", "SHADOW_RES", "SHADOW_SCALE", "SHADOW_SNAP", "SHARED_FONTS", "SHARPNESS", "SHOTS", "SHOTS_DIR", "SHUTTER_FIX",
|
||||
"SHOTS_FULL", "SPEED_PROBE", "SPIN", "SPIN_HANDOFF_US", "SPLIT_DRAWS", "SPLIT_US", "STICK_DEADZONE", "STICK_SENS",
|
||||
"SWKBD_ANSWER", "SYNC_AHEAD",
|
||||
"SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PAD_RUMBLE_MS", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64",
|
||||
"SWKBD_TEST", "TEST_OOM", "TEST_PAD", "TEST_PAD_RUMBLE_MS", "TEST_PREPARE_SHADERS", "TEX_ALIAS", "TEX_BLOCK_MIB", "TEX_HEAP_EXTRA_MB", "TEX_MEMO", "TEX_RELEASED_MIB", "TEX_VRAM_PRESSURE", "TIMER_1MS", "TRACE", "TXD_TRANSPOSE", "UBO_SNAPSHOT", "UB_OVERLAY", "UB_OVERLAY_OUT", "UPSCALER", "VB_USED", "VK_DYN_A2C", "VK_DYN_VERTEX", "VK_NO_FLOAT64", "VK_NO_HOST_IMPORT",
|
||||
"VK_PRESENT", "VK_RECORDER", "VK_SSBO_ALIGN", "VK_SUBGROUP", "VK_SUBGROUP_PIN", "VK_VALIDATION", "VMA_BLOCK_MIB", "VOLUME", "VOLUME_MASK_BIAS", "VOLUME_MUSIC", "VOLUME_SFX", "VOLUME_VOICE", "VRAM_HEADROOM", "VRAM_LIMIT_MIB", "VS_OUTS",
|
||||
"WALK_KEY", "WALK_SCALE", "WB_EAGER", "WB_EXACT", "WB_FENCE_LIMIT", "WB_MERGE", "WINDOW_SIZE", "XLATE", "XLATE_ID", "XLATE_KEEP", "XLATE_PROCS",
|
||||
"ZSTD_CHECK", "ZSTD_NATIVE",
|
||||
@@ -77,6 +77,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"FPS_LIMIT", "frame rate"}, {"FPS60", "frame rate"}, {"FRAME_QUEUE", "frame rate"}, {"FRAME_GEN", "frame rate"},
|
||||
{"REALTIME", "frame rate"}, {"CLOTH_REALTIME", "frame rate"}, {"HIGHFPS_FIX", "frame rate"},
|
||||
{"CLIMB_FIX", "frame rate"}, {"AUDIO_DRAIN_FIX", "frame rate"}, {"SHUTTER_FIX", "frame rate"},
|
||||
{"LIGHTNING_FIX", "frame rate"},
|
||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||
{"HUD_WIDTH", "display"},
|
||||
@@ -141,11 +142,11 @@ static const CfgMeta metas[] = {
|
||||
{"HUD_WIDTH", "full", "full|21:9|16:9", RESTART},
|
||||
{"DYNAMIC_RES", "1", "0|1", LIVE}, // resolution.c res_dynres_live
|
||||
{"UPSCALER", "fsr", "fsr|bilinear", LIVE}, {"SHARPNESS", "80", "0..100", LIVE},
|
||||
{"SCENE_UPSCALER", "off", "off|dlss|fsr3", RESTART}, {"DLAA", "0", "0|1", RESTART},
|
||||
{"SCENE_UPSCALER", "off", "off|dlss|fsr3|fsr4", RESTART}, {"DLAA", "0", "0|1", RESTART},
|
||||
{"DLSS", "dlaa", "dlaa|quality|balanced|performance|ultra_performance", LIVE},
|
||||
{"FSR_SHARPNESS", "80", "0..100", LIVE}, // vk_dlaa.c fsr_evaluate
|
||||
{"DLSS_PRESET", "default", "default|k|j", LIVE}, {"DLSS_FIXED_EXPOSURE", "0", "0|1", LIVE}, {"DLAA_EFFECTS_AFTER", "0", "0|1", LIVE},
|
||||
{"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"REFLEX", "off", "off|on|boost", RESTART}, {"FXAA", "1", "0|1", LIVE},
|
||||
{"DLSS_CHAR_MASK", "65", "0|35|65|100", LIVE}, {"REFLEX", "off", "off|auto|on|boost", RESTART}, {"FXAA", "1", "0|1", LIVE},
|
||||
{"LOD_STEADY", "0", "0|1", RESTART}, // sets steady
|
||||
{"ASPECT", "fit", "fit|stretch", LIVE}, {"MOVIE_ASPECT", "keep", "keep|stretch", LIVE}, {"FOV", "100", "70..140", LIVE},
|
||||
{"ANISO", "game", "game|2|4|8|16", RESTART}, // vk_texture.c sampler_features
|
||||
@@ -168,7 +169,7 @@ static const CfgMeta metas[] = {
|
||||
{"MODS_REBUILD", "auto", "auto|off", RESTART},
|
||||
{"MODS_WITHOUT_CODE", "0", "0|1", RESTART}, // 1: a mod is used without the code module it cannot run (mods.c)
|
||||
{"HIGHFPS_FIX", "1", "0|1", RESTART}, {"CLIMB_FIX", "1", "0|1", RESTART}, {"AUDIO_DRAIN_FIX", "1", "0|1", RESTART},
|
||||
{"SHUTTER_FIX", "1", "0|1", RESTART},
|
||||
{"SHUTTER_FIX", "1", "0|1", RESTART}, {"LIGHTNING_FIX", "1", "0|1", RESTART},
|
||||
{"LANG", "", "ja|en-US|fr|de|it|es|zh-CN|ko|nl|pt|ru|zh-TW|en-GB|fr-CA|es-419|zh-Hans|zh-Hant|pt-BR", RESTART},
|
||||
{"OPERATION_MODE", "docked", "docked|handheld", RESTART},
|
||||
{"ASSUME_FOCUS", "1", "0|1", LIVE}, // read on every focus change (ov_system.c)
|
||||
@@ -203,7 +204,7 @@ static const CfgMeta metas[] = {
|
||||
{"GAMEPLAY_MAP_ZOOM_SENSITIVITY", "1", "0.25..4", LIVE}, {"GAMEPLAY_ROTATION_SENSITIVITY", "1", "0.25..4", LIVE},
|
||||
{"GAMEPLAY_DISTANCE_SENSITIVITY", "1", "0.25..4", LIVE}, {"GAMEPLAY_ITEM_SENSITIVITY", "1", "0.25..4", LIVE},
|
||||
{"GAMEPLAY_WEAPON_WHEEL", "1", "0|1", LIVE}, {"GAMEPLAY_WEAPON_SENSITIVITY", "1", "0.25..4", LIVE},
|
||||
{"MENU_LANG", "", "en|ru|pt-BR|zh-Hans", LIVE},
|
||||
{"MENU_LANG", "", "en|ru|pt-BR|zh-Hans|de|fr|es|it|nl|ja|ko|vi", LIVE},
|
||||
// plat_font_path on Linux: 1 asks fontconfig which file draws the language, 0 keeps the fixed distribution
|
||||
// paths. A rebuild of the atlas reads it, so a change shows on the next window size or language switch.
|
||||
{"MENU_FONT_FONTCONFIG", "1", "0|1", LIVE},
|
||||
@@ -862,9 +863,9 @@ void cfg_init(void) {
|
||||
}
|
||||
|
||||
// scene_upscaler, or for a totk.ini that predates it the dlaa switch it replaced: dlaa = 1 is DLSS, anything else off.
|
||||
// FSR 3.1 is never the answer for a player who did not pick it. An unknown value is off.
|
||||
// FSR is never the answer for a player who did not pick it. An unknown value is off.
|
||||
const char *cfg_scene_upscaler(void) {
|
||||
if (!cfg_is_set("TOTK_SCENE_UPSCALER")) return cfg_bool("TOTK_DLAA") ? "dlss" : "off";
|
||||
const char *v = cfg_value("TOTK_SCENE_UPSCALER");
|
||||
return !strcmp(v, "dlss") ? "dlss" : !strcmp(v, "fsr3") ? "fsr3" : "off";
|
||||
return !strcmp(v, "dlss") ? "dlss" : !strcmp(v, "fsr3") ? "fsr3" : !strcmp(v, "fsr4") ? "fsr4" : "off";
|
||||
}
|
||||
+5
-3
@@ -69,14 +69,16 @@ const char *cfg_value(const char *name);
|
||||
int cfg_int(const char *name);
|
||||
double cfg_double(const char *name);
|
||||
int cfg_bool(const char *name);
|
||||
// The 3D scene upscaler the settings name now: "off", "dlss" or "fsr3" (scene_upscaler; without it dlaa = 1 is "dlss").
|
||||
// The 3D scene upscaler the settings name now: "off", "dlss", "fsr3" or "fsr4" (scene_upscaler; without it dlaa = 1 is
|
||||
// "dlss").
|
||||
// The engine in use is the one named at start (vk_dlaa.c vk_upscaler_engine).
|
||||
const char *cfg_scene_upscaler(void);
|
||||
// vk_dlaa.c, the 3D scene upscaler (scene_upscaler): the engine picked at start (UPSCALER_*),
|
||||
// 1 while the settings still name it (the menu switches it off at once), the engine that is running (it
|
||||
// ran and has not failed; 0 none), and why an engine cannot run here (UPSCALER_MISSING_*, 0 it can).
|
||||
enum { UPSCALER_OFF, UPSCALER_DLSS, UPSCALER_FSR3 };
|
||||
enum { UPSCALER_MISSING_GPU = 1, UPSCALER_MISSING_DLL };
|
||||
// UPSCALER_FSR4 is AMD's FSR 4 from its FSR SDK libraries (vk_ffx.c), Windows only (UPSCALER_MISSING_OS elsewhere).
|
||||
enum { UPSCALER_OFF, UPSCALER_DLSS, UPSCALER_FSR3, UPSCALER_FSR4 };
|
||||
enum { UPSCALER_MISSING_GPU = 1, UPSCALER_MISSING_DLL, UPSCALER_MISSING_OS };
|
||||
int vk_upscaler_engine(void);
|
||||
int vk_upscaler_on(void);
|
||||
int vk_upscaler_running(void);
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
// The part of AMD's FSR API (ffx-api) that vk_ffx.c uses: the entry points of amd_fidelityfx_loader_vk.dll, the
|
||||
// Vulkan backend descriptor and the upscaler's create and dispatch descriptors. Copied from the FidelityFX SDK v2.4.0
|
||||
// (GPUOpen-LibrariesAndSDKs/FidelityFX-SDK, Kits/FidelityFX/api/include/ffx_api.h, ffx_api_types.h, vk/ffx_api_vk.h
|
||||
// and Kits/FidelityFX/upscalers/include/ffx_upscale.h), trimmed to those declarations; the layouts and values are
|
||||
// unchanged. The SDK's headers use a C++ attribute for deprecations, so they are not included as they are.
|
||||
//
|
||||
// This file is part of the FidelityFX SDK.
|
||||
//
|
||||
// Copyright (C) 2026 Advanced Micro Devices, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files(the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and /or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions :
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
// ---- ffx_api.h
|
||||
enum FfxApiReturnCodes {
|
||||
FFX_API_RETURN_OK = 0,
|
||||
FFX_API_RETURN_ERROR = 1,
|
||||
FFX_API_RETURN_ERROR_UNKNOWN_DESCTYPE = 2,
|
||||
FFX_API_RETURN_ERROR_RUNTIME_ERROR = 3,
|
||||
FFX_API_RETURN_NO_PROVIDER = 4,
|
||||
FFX_API_RETURN_ERROR_MEMORY = 5,
|
||||
FFX_API_RETURN_ERROR_PARAMETER = 6,
|
||||
FFX_API_RETURN_PROVIDER_NO_SUPPORT_NEW_DESCTYPE = 7,
|
||||
};
|
||||
|
||||
typedef void *ffxContext;
|
||||
typedef uint32_t ffxReturnCode_t;
|
||||
|
||||
#define FFX_API_EFFECT_MASK 0x00ff0000u
|
||||
#define FFX_API_BACKEND_MASK 0xff000000u
|
||||
|
||||
typedef uint64_t ffxStructType_t;
|
||||
typedef struct ffxApiHeader {
|
||||
ffxStructType_t type;
|
||||
struct ffxApiHeader *pNext;
|
||||
} ffxApiHeader;
|
||||
|
||||
typedef ffxApiHeader ffxCreateContextDescHeader;
|
||||
typedef ffxApiHeader ffxConfigureDescHeader;
|
||||
typedef ffxApiHeader ffxQueryDescHeader;
|
||||
typedef ffxApiHeader ffxDispatchDescHeader;
|
||||
|
||||
enum FfxApiMsgType { FFX_API_MESSAGE_TYPE_ERROR = 0, FFX_API_MESSAGE_TYPE_WARNING = 1 };
|
||||
typedef void (*ffxApiMessage)(uint32_t type, const wchar_t *message);
|
||||
|
||||
#define FFX_API_QUERY_DESC_TYPE_GET_VERSIONS 4u
|
||||
struct ffxQueryDescGetVersions {
|
||||
ffxQueryDescHeader header;
|
||||
uint64_t createDescType;
|
||||
void *device; // Vulkan: a VkDeviceContext *
|
||||
uint64_t *outputCount;
|
||||
uint64_t *versionIds;
|
||||
const char **versionNames;
|
||||
};
|
||||
|
||||
#define FFX_API_DESC_TYPE_OVERRIDE_VERSION 5u
|
||||
struct ffxOverrideVersion {
|
||||
ffxApiHeader header;
|
||||
uint64_t versionId;
|
||||
};
|
||||
|
||||
#define FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION 6u
|
||||
struct ffxQueryGetProviderVersion {
|
||||
ffxQueryDescHeader header;
|
||||
uint64_t versionId;
|
||||
const char *versionName;
|
||||
};
|
||||
|
||||
typedef struct ffxAllocationCallbacks ffxAllocationCallbacks;
|
||||
typedef ffxReturnCode_t (*PfnFfxCreateContext)(ffxContext *context, ffxCreateContextDescHeader *desc,
|
||||
const ffxAllocationCallbacks *memCb);
|
||||
typedef ffxReturnCode_t (*PfnFfxDestroyContext)(ffxContext *context, const ffxAllocationCallbacks *memCb);
|
||||
typedef ffxReturnCode_t (*PfnFfxQuery)(ffxContext *context, ffxQueryDescHeader *desc);
|
||||
typedef ffxReturnCode_t (*PfnFfxDispatch)(ffxContext *context, const ffxDispatchDescHeader *desc);
|
||||
|
||||
#define FFX_API_EFFECT_ID_UPSCALE 0x00010000u
|
||||
#define FFX_API_MAKE_EFFECT_SUB_ID(effectId, subversion) ((effectId & FFX_API_EFFECT_MASK) | (subversion & ~FFX_API_EFFECT_MASK))
|
||||
#define FFX_API_BACKEND_ID_VK 0x01000000u
|
||||
#define FFX_API_MAKE_BACKEND_SUB_ID(backendId, subversion) ((backendId & FFX_API_BACKEND_MASK) | (subversion & ~FFX_API_BACKEND_MASK))
|
||||
|
||||
// ---- ffx_api_types.h
|
||||
enum FfxApiSurfaceFormat {
|
||||
FFX_API_SURFACE_FORMAT_UNKNOWN,
|
||||
FFX_API_SURFACE_FORMAT_R32G32B32A32_TYPELESS,
|
||||
FFX_API_SURFACE_FORMAT_R32G32B32A32_UINT,
|
||||
FFX_API_SURFACE_FORMAT_R32G32B32A32_FLOAT,
|
||||
FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT,
|
||||
FFX_API_SURFACE_FORMAT_R32G32B32_FLOAT,
|
||||
FFX_API_SURFACE_FORMAT_R32G32_FLOAT,
|
||||
FFX_API_SURFACE_FORMAT_R8_UINT,
|
||||
FFX_API_SURFACE_FORMAT_R32_UINT,
|
||||
FFX_API_SURFACE_FORMAT_R8G8B8A8_TYPELESS,
|
||||
FFX_API_SURFACE_FORMAT_R8G8B8A8_UNORM,
|
||||
FFX_API_SURFACE_FORMAT_R8G8B8A8_SNORM,
|
||||
FFX_API_SURFACE_FORMAT_R8G8B8A8_SRGB,
|
||||
FFX_API_SURFACE_FORMAT_B8G8R8A8_TYPELESS,
|
||||
FFX_API_SURFACE_FORMAT_B8G8R8A8_UNORM,
|
||||
FFX_API_SURFACE_FORMAT_B8G8R8A8_SRGB,
|
||||
FFX_API_SURFACE_FORMAT_R11G11B10_FLOAT,
|
||||
FFX_API_SURFACE_FORMAT_R10G10B10A2_UNORM,
|
||||
FFX_API_SURFACE_FORMAT_R16G16_FLOAT,
|
||||
FFX_API_SURFACE_FORMAT_R16G16_UINT,
|
||||
FFX_API_SURFACE_FORMAT_R16G16_SINT,
|
||||
FFX_API_SURFACE_FORMAT_R16_FLOAT,
|
||||
FFX_API_SURFACE_FORMAT_R16_UINT,
|
||||
FFX_API_SURFACE_FORMAT_R16_UNORM,
|
||||
FFX_API_SURFACE_FORMAT_R16_SNORM,
|
||||
FFX_API_SURFACE_FORMAT_R8_UNORM,
|
||||
FFX_API_SURFACE_FORMAT_R8G8_UNORM,
|
||||
FFX_API_SURFACE_FORMAT_R8G8_UINT,
|
||||
FFX_API_SURFACE_FORMAT_R32_FLOAT,
|
||||
};
|
||||
|
||||
enum FfxApiResourceUsage {
|
||||
FFX_API_RESOURCE_USAGE_READ_ONLY = 0,
|
||||
FFX_API_RESOURCE_USAGE_RENDERTARGET = (1 << 0),
|
||||
FFX_API_RESOURCE_USAGE_UAV = (1 << 1),
|
||||
FFX_API_RESOURCE_USAGE_DEPTHTARGET = (1 << 2),
|
||||
};
|
||||
|
||||
enum FfxApiResourceState {
|
||||
FFX_API_RESOURCE_STATE_COMMON = (1 << 0),
|
||||
FFX_API_RESOURCE_STATE_UNORDERED_ACCESS = (1 << 1),
|
||||
FFX_API_RESOURCE_STATE_COMPUTE_READ = (1 << 2),
|
||||
FFX_API_RESOURCE_STATE_PIXEL_READ = (1 << 3),
|
||||
FFX_API_RESOURCE_STATE_COPY_SRC = (1 << 4),
|
||||
FFX_API_RESOURCE_STATE_GENERIC_READ = (FFX_API_RESOURCE_STATE_COPY_SRC | FFX_API_RESOURCE_STATE_COMPUTE_READ),
|
||||
};
|
||||
|
||||
enum FfxApiResourceType { FFX_API_RESOURCE_TYPE_BUFFER, FFX_API_RESOURCE_TYPE_TEXTURE1D, FFX_API_RESOURCE_TYPE_TEXTURE2D };
|
||||
|
||||
struct FfxApiDimensions2D {
|
||||
uint32_t width, height;
|
||||
};
|
||||
struct FfxApiFloatCoords2D {
|
||||
float x, y;
|
||||
};
|
||||
|
||||
struct FfxApiResourceDescription {
|
||||
uint32_t type;
|
||||
uint32_t format;
|
||||
uint32_t width; // union with size (buffers)
|
||||
uint32_t height; // union with stride
|
||||
uint32_t depth; // union with alignment
|
||||
uint32_t mipCount;
|
||||
uint32_t flags;
|
||||
uint32_t usage;
|
||||
};
|
||||
|
||||
struct FfxApiResource {
|
||||
void *resource; // Vulkan: the VkImage
|
||||
struct FfxApiResourceDescription description;
|
||||
uint32_t state;
|
||||
};
|
||||
|
||||
// ---- vk/ffx_api_vk.h
|
||||
typedef struct VkDeviceContext {
|
||||
VkDevice vkDevice;
|
||||
VkPhysicalDevice vkPhysicalDevice;
|
||||
PFN_vkGetDeviceProcAddr vkDeviceProcAddr;
|
||||
} VkDeviceContext;
|
||||
|
||||
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_VK FFX_API_MAKE_BACKEND_SUB_ID(FFX_API_BACKEND_ID_VK, 0x03)
|
||||
struct ffxCreateBackendVKDesc {
|
||||
ffxCreateContextDescHeader header;
|
||||
VkDeviceContext deviceContext;
|
||||
};
|
||||
|
||||
// ---- upscalers/include/ffx_upscale.h
|
||||
#define FFX_UPSCALER_MAKE_VERSION(major, minor, patch) (((major) << 22) | ((minor) << 12) | (patch))
|
||||
#define FFX_UPSCALER_VERSION FFX_UPSCALER_MAKE_VERSION(4, 1, 2)
|
||||
|
||||
enum FfxApiCreateContextUpscaleFlags {
|
||||
FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE = (1 << 0),
|
||||
FFX_UPSCALE_ENABLE_DISPLAY_RESOLUTION_MOTION_VECTORS = (1 << 1),
|
||||
FFX_UPSCALE_ENABLE_MOTION_VECTORS_JITTER_CANCELLATION = (1 << 2),
|
||||
FFX_UPSCALE_ENABLE_DEPTH_INVERTED = (1 << 3),
|
||||
FFX_UPSCALE_ENABLE_DEPTH_INFINITE = (1 << 4),
|
||||
FFX_UPSCALE_ENABLE_AUTO_EXPOSURE = (1 << 5),
|
||||
FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION = (1 << 6),
|
||||
FFX_UPSCALE_ENABLE_DEBUG_CHECKING = (1 << 7),
|
||||
};
|
||||
|
||||
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_UPSCALE, 0x00)
|
||||
struct ffxCreateContextDescUpscale {
|
||||
ffxCreateContextDescHeader header;
|
||||
uint32_t flags;
|
||||
struct FfxApiDimensions2D maxRenderSize;
|
||||
struct FfxApiDimensions2D maxUpscaleSize;
|
||||
ffxApiMessage fpMessage;
|
||||
};
|
||||
|
||||
#define FFX_API_DISPATCH_DESC_TYPE_UPSCALE FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_UPSCALE, 0x01)
|
||||
struct ffxDispatchDescUpscale {
|
||||
ffxDispatchDescHeader header;
|
||||
void *commandList; // Vulkan: the VkCommandBuffer
|
||||
struct FfxApiResource color;
|
||||
struct FfxApiResource depth;
|
||||
struct FfxApiResource motionVectors;
|
||||
struct FfxApiResource exposure;
|
||||
struct FfxApiResource reactive;
|
||||
struct FfxApiResource transparencyAndComposition;
|
||||
struct FfxApiResource output;
|
||||
struct FfxApiFloatCoords2D jitterOffset;
|
||||
struct FfxApiFloatCoords2D motionVectorScale;
|
||||
struct FfxApiDimensions2D renderSize;
|
||||
struct FfxApiDimensions2D upscaleSize;
|
||||
bool enableSharpening;
|
||||
float sharpness;
|
||||
float frameTimeDelta; // milliseconds
|
||||
float preExposure;
|
||||
bool reset;
|
||||
float cameraNear;
|
||||
float cameraFar;
|
||||
float cameraFovAngleVertical; // radians
|
||||
float viewSpaceToMetersFactor;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
#define FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE_VERSION FFX_API_MAKE_EFFECT_SUB_ID(FFX_API_EFFECT_ID_UPSCALE, 0x0b)
|
||||
struct ffxCreateContextDescUpscaleVersion {
|
||||
ffxCreateContextDescHeader header;
|
||||
uint32_t version; // FFX_UPSCALER_VERSION
|
||||
};
|
||||
+15
-1
@@ -11,6 +11,8 @@
|
||||
// <profile>/save-backup/<time>/ the three committed saves before the current one
|
||||
// <profile>/temp/ emptied at start
|
||||
// <profile>/cache/<index>/ cache storage
|
||||
// <profile>/sdcard/ the SD card a mod plugin mounts (MountSdCard, under any mount name: Zonai
|
||||
// Fieldworks keeps its settings and logs there); the game never mounts it
|
||||
//
|
||||
// The save mount is journaled as on Horizon: changes go to a working copy and become the committed save atomically at
|
||||
// Commit; a crash or an Unmount before Commit leaves the previous committed save. Commit returns at once and the copy
|
||||
@@ -33,7 +35,8 @@
|
||||
#define NMOUNTS 16
|
||||
#define PATH_CAP 1100
|
||||
|
||||
enum { M_FREE, M_SAVE, M_TEMP, M_CACHE, M_SAVE_RO }; // M_SAVE: the working copy; M_SAVE_RO: the committed save
|
||||
// M_SAVE: the working copy; M_SAVE_RO: the committed save; M_SDCARD: <profile>/sdcard
|
||||
enum { M_FREE, M_SAVE, M_TEMP, M_CACHE, M_SAVE_RO, M_SDCARD };
|
||||
|
||||
typedef struct { int kind; char name[32]; char root[1024]; } Mount;
|
||||
typedef struct { PlatFile *h; int mode, save; } File; // h NULL = free; save: on a save-data mount
|
||||
@@ -800,6 +803,14 @@ static uint32_t mount_temp(const char *name) {
|
||||
return mount_add(name, M_TEMP, p);
|
||||
}
|
||||
|
||||
static uint32_t mount_sdcard(const char *name) {
|
||||
ready();
|
||||
char p[PATH_CAP];
|
||||
snprintf(p, sizeof p, "%s/sdcard", profile);
|
||||
make_dirs(p);
|
||||
return mount_add(name, M_SDCARD, p);
|
||||
}
|
||||
|
||||
static void cache_dir(int index, char *out, size_t cap) { snprintf(out, cap, "%s/cache/%d", profile, index); }
|
||||
|
||||
static uint32_t create_cache(int index, int64_t size, int64_t journal) {
|
||||
@@ -1211,6 +1222,7 @@ static void ov_mount_save(Cpu *c) { ret_x(c, mount_save(arg_p(c, 0), arg_p(c, 1)
|
||||
static void ov_mount_save_ro(Cpu *c) { ret_x(c, mount_save_ro(arg_p(c, 0), arg_x(c, 1), arg_p(c, 2))); }
|
||||
static void ov_save_exists(Cpu *c) { ret_x(c, save_exists(arg_x(c, 0), arg_p(c, 1))); }
|
||||
static void ov_mount_temp(Cpu *c) { ret_x(c, mount_temp(arg_p(c, 0))); }
|
||||
static void ov_mount_sdcard(Cpu *c) { ret_x(c, mount_sdcard(arg_p(c, 0))); }
|
||||
static void ov_unmount(Cpu *c) { unmount(arg_p(c, 0)); }
|
||||
static void ov_commit(Cpu *c) { ret_x(c, commit(arg_p(c, 0))); }
|
||||
static void ov_create_cache(Cpu *c) { ret_x(c, create_cache(I32(0), I64(1), I64(2))); }
|
||||
@@ -1246,6 +1258,7 @@ static void ov_set_priority(Cpu *c) { (void)c; }
|
||||
#define S_MOUNT_SAVE_RO "_ZN2nn2fs21MountSaveDataReadOnlyEPKcNS_13ApplicationIdERKNS_7account3UidE"
|
||||
#define S_SAVE_EXISTS "_ZN2nn2fs18IsSaveDataExistingENS_13ApplicationIdERKNS_7account3UidE"
|
||||
#define S_MOUNT_TEMP "_ZN2nn2fs21MountTemporaryStorageEPKc"
|
||||
#define S_MOUNT_SDCARD "_ZN2nn2fs11MountSdCardEPKc"
|
||||
#define S_UNMOUNT "_ZN2nn2fs7UnmountEPKc"
|
||||
#define S_COMMIT "_ZN2nn2fs6CommitEPKc"
|
||||
#define S_CREATE_CACHE "_ZN2nn2fs18CreateCacheStorageEill"
|
||||
@@ -1282,6 +1295,7 @@ HOST_OVERRIDE(S_MOUNT_SAVE, ov_mount_save);
|
||||
HOST_OVERRIDE(S_MOUNT_SAVE_RO, ov_mount_save_ro);
|
||||
HOST_OVERRIDE(S_SAVE_EXISTS, ov_save_exists);
|
||||
HOST_OVERRIDE(S_MOUNT_TEMP, ov_mount_temp);
|
||||
HOST_OVERRIDE(S_MOUNT_SDCARD, ov_mount_sdcard);
|
||||
HOST_OVERRIDE(S_UNMOUNT, ov_unmount);
|
||||
HOST_OVERRIDE(S_COMMIT, ov_commit);
|
||||
HOST_OVERRIDE(S_CREATE_CACHE, ov_create_cache);
|
||||
|
||||
@@ -33,6 +33,10 @@ void vk_reflex_marker(int marker, uint64_t present_id); // present_id: the fra
|
||||
uint64_t vk_reflex_frame_begin(void); // SIMULATION_START: the new frame's present ID
|
||||
uint64_t vk_reflex_frame(void); // the ID of the frame the game simulates now
|
||||
void vk_reflex_sleep(void); // before SIMULATION_START: the driver's latency sleep
|
||||
// AMD Anti-Lag 2 (gfx_present.c, VK_AMD_anti_lag): the driver paces the CPU from the INPUT call to the PRESENT call of a
|
||||
// frame. Both return at once unless reflex = auto turned Anti-Lag on at device creation (vk_device.c create_device).
|
||||
void vk_antilag_input(uint64_t frame); // before the frame's input and simulation; may sleep
|
||||
void vk_antilag_present(uint64_t frame); // right before the frame's vkQueuePresentKHR
|
||||
|
||||
// ---- shader service client (gfx_shader.c)
|
||||
enum { GFX_STAGE_VS, GFX_STAGE_TCS, GFX_STAGE_TES, GFX_STAGE_GS, GFX_STAGE_FS, GFX_STAGE_CS };
|
||||
|
||||
+33
-3
@@ -390,8 +390,9 @@ static void latency_note(VkCtx *c, uint64_t pid) {
|
||||
"end %.2f ms", full, gi.timingCount, full ? sum / full / 1000.0 : 0.0);
|
||||
}
|
||||
}
|
||||
rt_log("reflex: frame start to present %.2f ms over %llu frames (reflex %s)%s", g_lat.n ? g_lat.ns / 1e6 / g_lat.n : 0.0,
|
||||
(unsigned long long)g_lat.n, g_reflex_mode == 2 ? "boost" : g_reflex_mode == 1 ? "on" : "off", drv);
|
||||
rt_log("reflex: frame start to present %.2f ms over %llu frames (reflex %s%s)%s", g_lat.n ? g_lat.ns / 1e6 / g_lat.n : 0.0,
|
||||
(unsigned long long)g_lat.n, g_reflex_mode == 2 ? "boost" : g_reflex_mode == 1 ? "on" : "off",
|
||||
c->has_amd_antilag ? ", anti-lag on" : "", drv);
|
||||
g_lat.n = g_lat.ns = 0;
|
||||
}
|
||||
|
||||
@@ -405,7 +406,8 @@ uint64_t vk_reflex_submit_id(void) { return t_reflex_submit ? t_reflex_submit :
|
||||
void vk_reflex_present_frame(uint64_t id) {
|
||||
// g_blit_pid feeds flip_locked's VkPresentIdKHR (Reflex) and latency_note (TOTK_TRACE=perf); with neither, the
|
||||
// present skips the lock
|
||||
if (!vk_has_reflex() && !(rt_trace & RT_TRACE_PERF)) return;
|
||||
VkCtx *c = vk_ctx();
|
||||
if (!vk_has_reflex() && !(c && c->has_amd_antilag) && !(rt_trace & RT_TRACE_PERF)) return;
|
||||
plat_rmutex_lock(&g_pl);
|
||||
g_blit_pid = id;
|
||||
plat_rmutex_unlock(&g_pl);
|
||||
@@ -452,6 +454,33 @@ void vk_reflex_sleep(void) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- AMD Anti-Lag 2 (VK_AMD_anti_lag)
|
||||
static PFN_vkAntiLagUpdateAMD g_antilag_update;
|
||||
|
||||
// The INPUT call runs on the game thread (nvnWindowAcquireTexture), the PRESENT call on the present thread (flip_one,
|
||||
// g_pl held): both carry the frame's ID, as the spec asks of a frame's two calls. The first call of either thread loads
|
||||
// the entry point; the atomics keep that load race-free.
|
||||
static void antilag_update(VkAntiLagStageAMD stage, uint64_t frame) {
|
||||
VkCtx *c = vk_ctx();
|
||||
if (!c || !c->has_amd_antilag || !frame) return;
|
||||
PFN_vkAntiLagUpdateAMD fn = __atomic_load_n(&g_antilag_update, __ATOMIC_ACQUIRE);
|
||||
if (!fn) {
|
||||
fn = (PFN_vkAntiLagUpdateAMD)vkGetDeviceProcAddr(c->device, "vkAntiLagUpdateAMD");
|
||||
if (!fn) return;
|
||||
__atomic_store_n(&g_antilag_update, fn, __ATOMIC_RELEASE);
|
||||
}
|
||||
// the driver holds frames to the pacer's frame limit, as Reflex's minimum interval does (0: no limit known)
|
||||
double hz = frame_step_limit_hz();
|
||||
VkAntiLagPresentationInfoAMD pi = {
|
||||
.sType = VK_STRUCTURE_TYPE_ANTI_LAG_PRESENTATION_INFO_AMD, .stage = stage, .frameIndex = frame};
|
||||
VkAntiLagDataAMD d = {.sType = VK_STRUCTURE_TYPE_ANTI_LAG_DATA_AMD, .mode = VK_ANTI_LAG_MODE_ON_AMD,
|
||||
.maxFPS = hz > 0 ? (uint32_t)(hz + 0.5) : 0, .pPresentationInfo = &pi};
|
||||
fn(c->device, &d);
|
||||
}
|
||||
|
||||
void vk_antilag_input(uint64_t frame) { antilag_update(VK_ANTI_LAG_STAGE_INPUT_AMD, frame); }
|
||||
void vk_antilag_present(uint64_t frame) { antilag_update(VK_ANTI_LAG_STAGE_PRESENT_AMD, frame); }
|
||||
|
||||
// ---- swapchain
|
||||
static const char *g_present_got = ""; // the TOTK_VK_PRESENT value of the mode the swapchain got; "" before one
|
||||
|
||||
@@ -503,6 +532,7 @@ static void flip_one(void) {
|
||||
pid_info.pPresentIds = &pid;
|
||||
vk_reflex_marker(4, pid); // VK_LATENCY_MARKER_PRESENT_START_NV
|
||||
}
|
||||
if (!generated) vk_antilag_present(frame_pid);
|
||||
VkPresentInfoKHR pi = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||
.pNext = with_id ? &pid_info : NULL,
|
||||
.waitSemaphoreCount = 1,
|
||||
|
||||
@@ -315,6 +315,7 @@ void res_init(void); // after rt_patches_i
|
||||
float res_dlss_lod_bias(void); // TOTK_DLSS upscaling: texture LOD bias (<= 0)
|
||||
int res_dlss_mode(const char *mode); // TOTK_DLSS changed while running: new scene size
|
||||
int res_dlss_dll(void); // the DLSS library is next to the executable
|
||||
int res_ffx_dlls(void); // AMD's two FSR 4 libraries are (Windows; 0 elsewhere)
|
||||
void res_fn_hit(uint64_t addr, uint64_t x0); // main.c fnprof_hit: catches the renderer at start
|
||||
void res_present(Cpu *c); // nvnQueuePresentTexture: applies a pending scene size
|
||||
void res_sizes(unsigned out[2], unsigned scene[2]); // the output and scene sizes in effect (the game's own
|
||||
|
||||
@@ -688,7 +688,9 @@ NVN_API(nvnWindowAcquireTexture) {
|
||||
perf_end(PERF_PACE, p0);
|
||||
}
|
||||
vk_reflex_sleep();
|
||||
vk_reflex_marker(0, vk_reflex_frame_begin()); // VK_LATENCY_MARKER_SIMULATION_START_NV: a new frame and its ID
|
||||
uint64_t fid = vk_reflex_frame_begin();
|
||||
vk_reflex_marker(0, fid); // VK_LATENCY_MARKER_SIMULATION_START_NV: a new frame and its ID
|
||||
vk_antilag_input(fid);
|
||||
// The sync means "the display no longer reads this image". Presents are copies queued in submit order, so it is
|
||||
// already satisfied: fenced = 3 with fence 0.
|
||||
if (s) {
|
||||
|
||||
+34
-11
@@ -1012,31 +1012,45 @@ static void probe_fonts(void) {
|
||||
(unsigned long long)addr, (unsigned long long)size, path);
|
||||
}
|
||||
|
||||
// The host catalog (ui_text.c): every menu id has its own English, Russian, Brazilian Portuguese and Simplified
|
||||
// Chinese text, the software keyboard keeps its game-language rows, and menu_text follows TOTK_MENU_LANG.
|
||||
// The host catalog (ui_text.c): every menu id has its own English, Russian, Brazilian Portuguese, Simplified Chinese
|
||||
// and Vietnamese text, every menu language's text fits the description pane and keeps the English conversions of the
|
||||
// overlay formats, the software keyboard keeps its game-language rows, and menu_text follows TOTK_MENU_LANG.
|
||||
static void probe_menu_text(void) {
|
||||
static const char *const langs[] = {"en", "ja", "fr", "de", "it", "es", "nl", "pt", "ru", "zh-Hans", "zh-Hant", "ko",
|
||||
"pt-BR"};
|
||||
"pt-BR", "vi"};
|
||||
static const char *const menu_langs[] = {"de", "fr", "es", "it", "nl", "ja", "ko", "vi"};
|
||||
for (int id = UI_MENU_FIRST; id <= UI_MENU_LAST_ID; id++) {
|
||||
CHECK(ui_text_defined("en", (UiTextId)id) && ui_text_defined("ru", (UiTextId)id) &&
|
||||
ui_text_defined("pt-BR", (UiTextId)id), "menu text id %d lacks en, ru or pt-BR", id);
|
||||
ui_text_defined("pt-BR", (UiTextId)id) && ui_text_defined("vi", (UiTextId)id),
|
||||
"menu text id %d lacks en, ru, pt-BR or vi", id);
|
||||
CHECK(*ui_text_in("en", (UiTextId)id) && *ui_text_in("ru", (UiTextId)id) && *ui_text_in("pt-BR", (UiTextId)id),
|
||||
"menu text id %d is empty", id);
|
||||
// the description pane keeps the whole text and a note after it (option_rows.cpp desc_set)
|
||||
CHECK(strlen(ui_text_in("en", (UiTextId)id)) + 256 < UI_DESC_BYTES &&
|
||||
strlen(ui_text_in("ru", (UiTextId)id)) + 256 < UI_DESC_BYTES &&
|
||||
strlen(ui_text_in("pt-BR", (UiTextId)id)) + 256 < UI_DESC_BYTES &&
|
||||
strlen(ui_text_in("zh-Hans", (UiTextId)id)) + 256 < UI_DESC_BYTES,
|
||||
strlen(ui_text_in("zh-Hans", (UiTextId)id)) + 256 < UI_DESC_BYTES &&
|
||||
strlen(ui_text_in("vi", (UiTextId)id)) + 256 < UI_DESC_BYTES,
|
||||
"menu text id %d is too long for the description pane", id);
|
||||
for (size_t i = 0; i < sizeof menu_langs / sizeof *menu_langs; i++)
|
||||
CHECK(strlen(ui_text_in(menu_langs[i], (UiTextId)id)) + 256 < UI_DESC_BYTES,
|
||||
"menu text id %d is too long for the description pane in %s", id, menu_langs[i]);
|
||||
CHECK(ui_text_defined("zh-Hans", (UiTextId)id), "menu text id %d lacks Simplified Chinese", id);
|
||||
}
|
||||
CHECK(!ui_text_defined("en", UI_TEXT_COUNT) && !*ui_text_in("ru", UI_TEXT_COUNT), "an id past the catalog gives text");
|
||||
// other languages fall back to English for the menu, and keep their own keyboard texts
|
||||
CHECK(!strcmp(ui_text_in("ja", UI_MENU_CONTINUE), ui_text_in("en", UI_MENU_CONTINUE)), "ja menu text is not English");
|
||||
// the other game languages have their own menu text; Traditional Chinese falls back to English in the catalog
|
||||
for (size_t i = 0; i < sizeof menu_langs / sizeof *menu_langs; i++) {
|
||||
CHECK(ui_text_defined(menu_langs[i], UI_MENU_TITLE) && ui_text_defined(menu_langs[i], UI_MENU_CONTINUE),
|
||||
"%s has no menu text", menu_langs[i]);
|
||||
CHECK(strstr(ui_text_in(menu_langs[i], UI_MENU_OV_GAME_PCT), "%.0f%%"), "%s overlay format lost its conversion",
|
||||
menu_langs[i]);
|
||||
}
|
||||
CHECK(!strcmp(ui_text_in("zh-Hant", UI_MENU_CONTINUE), ui_text_in("en", UI_MENU_CONTINUE)),
|
||||
"zh-Hant menu text is not English");
|
||||
CHECK(!strcmp(ui_text_in("ru", UI_SWKBD_OK), "ОК") && !strcmp(ui_text_in("de", UI_SWKBD_CANCEL), "Abbrechen") &&
|
||||
!strcmp(ui_text_in("en", UI_SWKBD_OK), "OK"), "keyboard texts changed");
|
||||
// language names: the same string in every row
|
||||
for (int id = UI_MENU_LANGNAME_EN; id <= UI_MENU_LANGNAME_ES_419; id++)
|
||||
for (int id = UI_MENU_LANGNAME_EN; id <= UI_MENU_LANGNAME_VI; id++)
|
||||
for (size_t i = 1; i < sizeof langs / sizeof *langs; i++)
|
||||
CHECK(!strcmp(ui_text_in(langs[i], (UiTextId)id), ui_text_in("en", (UiTextId)id)), "language name %d differs in %s", id, langs[i]);
|
||||
CHECK(!strcmp(ui_text_in("en", UI_MENU_LANGNAME_RU), "Русский"), "Russian is not shown as Russian");
|
||||
@@ -1075,15 +1089,24 @@ static void probe_menu_text(void) {
|
||||
CHECK(menu_text(UI_MENU_CONTINUE) == ui_text_in("en", UI_MENU_CONTINUE), "menu_text did not follow MENU_LANG=en");
|
||||
cfg_set("TOTK_MENU_LANG", "zh-Hans");
|
||||
CHECK(menu_text(UI_MENU_TITLE) == ui_text_in("zh-Hans", UI_MENU_TITLE), "menu_text ignores MENU_LANG=zh-Hans");
|
||||
cfg_set("TOTK_MENU_LANG", "ja");
|
||||
CHECK(menu_text(UI_MENU_TITLE) == ui_text_in("ja", UI_MENU_TITLE), "menu_text ignores MENU_LANG=ja");
|
||||
cfg_set("TOTK_MENU_LANG", "de-DE");
|
||||
CHECK(menu_text(UI_MENU_TITLE) == ui_text_in("de", UI_MENU_TITLE), "menu_text ignores MENU_LANG=de-DE");
|
||||
// Traditional Chinese (zh-TW, zh-HK) reads the Simplified Chinese menu
|
||||
cfg_set("TOTK_MENU_LANG", "zh-TW");
|
||||
CHECK(menu_text(UI_MENU_TITLE) == ui_text_in("zh-Hans", UI_MENU_TITLE), "zh-TW does not get the zh-Hans menu");
|
||||
cfg_set("TOTK_MENU_LANG", "");
|
||||
// the system language as ui_text.c resolve_menu_lang takes it: the tag, else its base language (ru-RU: ru), else en
|
||||
// the system language as ui_text.c resolve_menu_lang takes it: the tag, else its base language (ru-RU: ru), else
|
||||
// Simplified Chinese for any Chinese, else en
|
||||
const char *sys_lang = ui_text_lang(plat_ui_language());
|
||||
char sys_base[16] = "";
|
||||
size_t base_n = strcspn(sys_lang, "-");
|
||||
if (sys_lang[base_n] && base_n < sizeof sys_base) memcpy(sys_base, sys_lang, base_n);
|
||||
const char *auto_lang = ui_text_defined(sys_lang, UI_MENU_TITLE) ? sys_lang
|
||||
const char *auto_lang = ui_text_defined(sys_lang, UI_MENU_TITLE) ? sys_lang
|
||||
: *sys_base && ui_text_defined(sys_base, UI_MENU_TITLE) ? sys_base
|
||||
: "en";
|
||||
: !strncmp(sys_lang, "zh", 2) ? "zh-Hans"
|
||||
: "en";
|
||||
CHECK(menu_text(UI_MENU_CONTINUE) == ui_text_in(auto_lang, UI_MENU_CONTINUE), "menu_text auto ignores the system language");
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,18 @@ static void ov_desired_language(Cpu *c) {
|
||||
ret_x(c, v);
|
||||
}
|
||||
|
||||
// nn::settings::detail::GetLanguageCode(LanguageCode *out): the system language, the one GetDesiredLanguage gives.
|
||||
// The game never calls it; Material Columns picks its text by it. x0 = 0 for the callers that read a Result.
|
||||
static void ov_settings_language(Cpu *c) {
|
||||
const char *code = ov_language();
|
||||
uint8_t *out = arg_p(c, 0);
|
||||
if (out) {
|
||||
memset(out, 0, 8);
|
||||
memcpy(out, code, strlen(code));
|
||||
}
|
||||
ret_x(c, 0);
|
||||
}
|
||||
|
||||
static void ov_oe_initialize(Cpu *c) { (void)c; rt_log("oe: application environment: a local host process"); }
|
||||
|
||||
// void SetPerformanceConfiguration(PerformanceMode mode, int config)
|
||||
@@ -872,6 +884,7 @@ static void ov_font_size(Cpu *c) {
|
||||
// ==== registration
|
||||
HOST_OVERRIDE("_ZN2nn2oe10InitializeEv", ov_oe_initialize);
|
||||
HOST_OVERRIDE("_ZN2nn2oe18GetDesiredLanguageEv", ov_desired_language);
|
||||
HOST_OVERRIDE("_ZN2nn8settings6detail15GetLanguageCodeEPNS0_12LanguageCodeE", ov_settings_language);
|
||||
HOST_OVERRIDE("_ZN2nn2oe27SetPerformanceConfigurationENS0_15PerformanceModeEi", ov_performance_config);
|
||||
HOST_OVERRIDE("_ZN2nn2oe15SetCpuBoostModeENS0_12CpuBoostModeE", ov_cpu_boost);
|
||||
HOST_OVERRIDE("_ZN2nn2oe16GetOperationModeEv", ov_operation_mode);
|
||||
|
||||
+32
-13
@@ -38,9 +38,15 @@
|
||||
// hook branches reach main's .text.
|
||||
// - nn::oe::GetDisplayVersion is answered with this build's game version, so the plugin picks its table for the
|
||||
// installed game without the applet services.
|
||||
// Only svcs the init needs are allowed (QueryMemory, GetSystemTick, OutputDebugString, GetInfo 2-5, 12-15 and 65001,
|
||||
// Map/UnmapProcessMemory); any other one, such as CreateSession and ReplyAndReceive of exlaunch's process-handle
|
||||
// fallback, ends the run with the reason in the record.
|
||||
// - GetInfo 6, 16 and 17, the total memory and the system resource size and use, are constants (memory.c
|
||||
// mem_info); 7, the memory in use, is the same at the same point of the same init. Zonai Fieldworks asks them
|
||||
// after its hooks are in.
|
||||
// - SetHeapSize grows the process heap past the size the game's nninitStartup set before the init runs (Zonai
|
||||
// Fieldworks keeps a pool in the tail). The heap base is fixed and the game asked its size the same way at every
|
||||
// start, so the init gets the same answer each time.
|
||||
// Only svcs the init needs are allowed (SetHeapSize, QueryMemory, GetSystemTick, OutputDebugString, GetInfo 2-7,
|
||||
// 12-17 and 65001, Map/UnmapProcessMemory); any other one, such as CreateSession and ReplyAndReceive of exlaunch's
|
||||
// process-handle fallback, ends the run with the reason in the record.
|
||||
//
|
||||
// The record, in DIR: record.json (modules, which plugins' inits ran, the writes into every game module as words, the
|
||||
// alias calls, svc and import counts, the tick offset, a refusal), plugin<N>.img (the plugin's image after its init,
|
||||
@@ -69,7 +75,9 @@
|
||||
#define POOL_SIZE (64 * GiB)
|
||||
#define POOL_ALIGN (4 * GiB)
|
||||
#define RTLD_ALIGN 0x200000ull
|
||||
#define MAX_ALIASES 256
|
||||
// exlaunch maps a page alias for every patch it writes and unmaps it after; Zonai Fieldworks makes over 211 in its
|
||||
// init. Each slot is 48 bytes, and only the live aliases hold a copy of their pages.
|
||||
#define MAX_ALIASES 2048
|
||||
#define MAX_IMPORTS 64
|
||||
#define CUR_PROCESS 0xFFFF8001u
|
||||
// Horizon memory states and permissions of QueryMemory, and results.
|
||||
@@ -94,7 +102,7 @@ static uint64_t pool_base;
|
||||
static int running; // a plugin's init runs: svcs and imports are counted
|
||||
static int play; // plugins_start: a refused SVC fails the plugin instead of ending the process
|
||||
static char failed[256]; // play: why the running init was refused
|
||||
static uint64_t svc_count[0x80], info_count[16], info_65001;
|
||||
static uint64_t svc_count[0x80], info_count[18], info_65001;
|
||||
static struct { const char *name; uint64_t calls; } imports[MAX_IMPORTS];
|
||||
static int nimports;
|
||||
static uint8_t **pre; // per loaded module: its image before the plugins' inits
|
||||
@@ -198,11 +206,22 @@ static uint32_t process_memory(int unmap, uint64_t dst, uint32_t process, uint64
|
||||
}
|
||||
return R_INVALID_STATE;
|
||||
}
|
||||
if (!module_holding(src, size)) return R_INVALID_STATE; // only the modules' own memory
|
||||
if (!module_holding(src, size)) { // only the modules' own memory
|
||||
rt_log("plugin-init: MapProcessMemory refused: the source %#llx+%#llx is no module's memory",
|
||||
(unsigned long long)src, (unsigned long long)size);
|
||||
return R_INVALID_STATE;
|
||||
}
|
||||
RtMemoryInfo q;
|
||||
mem_query(dst, &q);
|
||||
if (q.state != ST_FREE || dst + size > q.base + q.size) return R_INVALID_STATE;
|
||||
if (naliases == MAX_ALIASES) return R_LIMIT_REACHED;
|
||||
if (q.state != ST_FREE || dst + size > q.base + q.size) {
|
||||
rt_log("plugin-init: MapProcessMemory refused: the destination %#llx+%#llx is not free (state %#x)",
|
||||
(unsigned long long)dst, (unsigned long long)size, q.state);
|
||||
return R_INVALID_STATE;
|
||||
}
|
||||
if (naliases == MAX_ALIASES) {
|
||||
rt_log("plugin-init: MapProcessMemory refused: all %d alias slots used", MAX_ALIASES);
|
||||
return R_LIMIT_REACHED;
|
||||
}
|
||||
if (!plat_mem_commit(dst, size)) return R_INVALID_STATE; // not inside one of our reservations
|
||||
Alias *al = &aliases[naliases];
|
||||
al->snap = malloc(size);
|
||||
@@ -235,10 +254,10 @@ static int plugin_svc(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
svc_count[imm & 0x7F]++;
|
||||
char why[256], at[128];
|
||||
switch (imm) {
|
||||
case 0x06: case 0x1E: case 0x27: case 0x74: case 0x75: return 0;
|
||||
case 0x01: case 0x06: case 0x1E: case 0x27: case 0x74: case 0x75: return 0;
|
||||
case 0x29: {
|
||||
uint32_t id = (uint32_t)c->x[1];
|
||||
if ((id >= 2 && id <= 5) || (id >= 12 && id <= 15)) {
|
||||
if ((id >= 2 && id <= 7) || (id >= 12 && id <= 17)) {
|
||||
info_count[id]++;
|
||||
return 0;
|
||||
}
|
||||
@@ -252,8 +271,8 @@ static int plugin_svc(Cpu *c, uint32_t imm, uint64_t pc) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
snprintf(why, sizeof why, "svc %#x at %s (only QueryMemory, GetSystemTick, OutputDebugString, GetInfo 2-5, 12-15 "
|
||||
"and 65001, Map/UnmapProcessMemory are served)", imm, ldr_describe(pc, at, sizeof at));
|
||||
snprintf(why, sizeof why, "svc %#x at %s (only SetHeapSize, QueryMemory, GetSystemTick, OutputDebugString, "
|
||||
"GetInfo 2-7, 12-17 and 65001, Map/UnmapProcessMemory are served)", imm, ldr_describe(pc, at, sizeof at));
|
||||
refuse(why);
|
||||
c->x[0] = R_NOT_IMPLEMENTED;
|
||||
return 1;
|
||||
@@ -392,7 +411,7 @@ static void write_record(const char *refused) {
|
||||
if (svc_count[i]) fprintf(f, "%s\"%#x\": %llu", first ? "" : ", ", i, (unsigned long long)svc_count[i]), first = 0;
|
||||
fputs("},\n\"get_info\": {", f);
|
||||
first = 1;
|
||||
for (int i = 0; i < 16; i++)
|
||||
for (int i = 0; i < 18; i++)
|
||||
if (info_count[i]) fprintf(f, "%s\"%d\": %llu", first ? "" : ", ", i, (unsigned long long)info_count[i]), first = 0;
|
||||
if (info_65001) fprintf(f, "%s\"65001\": %llu", first ? "" : ", ", (unsigned long long)info_65001);
|
||||
fputs("},\n\"imports\": {", f);
|
||||
|
||||
+39
-10
@@ -102,11 +102,35 @@ int res_dlss_dll(void) {
|
||||
return dll;
|
||||
}
|
||||
|
||||
// The engine picked at start can run, as far as is known before the device exists: DLSS needs its DLL (dlss_dll); FSR
|
||||
// 3.1 is built in (vk_fsr3.cpp). Off: nothing to run.
|
||||
// AMD's FSR 4 (vk_ffx.c) loads amd_fidelityfx_loader_vk.dll from the folder of totk.exe, which finds
|
||||
// amd_fidelityfx_upscaler_vk.dll next to itself; both come from the setup's FSR step. Windows only: AMD ships no Linux
|
||||
// libraries.
|
||||
static int ffx_dlls(void) {
|
||||
#ifdef _WIN32
|
||||
char exe[1024], path[1024 + 48];
|
||||
if (!plat_exe_path(exe, sizeof exe)) return 1;
|
||||
char *last = plat_last_sep(exe);
|
||||
if (!last) return 1;
|
||||
snprintf(path, sizeof path, "%.*s/amd_fidelityfx_loader_vk.dll", (int)(last - exe), exe);
|
||||
if (!plat_file_exists(path)) return 0;
|
||||
snprintf(path, sizeof path, "%.*s/amd_fidelityfx_upscaler_vk.dll", (int)(last - exe), exe);
|
||||
return plat_file_exists(path);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int res_ffx_dlls(void) {
|
||||
static int dlls = -1;
|
||||
if (dlls < 0) dlls = ffx_dlls();
|
||||
return dlls;
|
||||
}
|
||||
|
||||
// The engine picked at start can run, as far as is known before the device exists: DLSS needs its DLL (dlss_dll), FSR
|
||||
// 4 AMD's two libraries (ffx_dlls); FSR 3.1 is built in (vk_fsr3.cpp). Off: nothing to run.
|
||||
static int upscaler_ready(void) {
|
||||
int e = vk_upscaler_engine();
|
||||
return e == UPSCALER_DLSS ? res_dlss_dll() : e == UPSCALER_FSR3;
|
||||
return e == UPSCALER_DLSS ? res_dlss_dll() : e == UPSCALER_FSR4 ? res_ffx_dlls() : e == UPSCALER_FSR3;
|
||||
}
|
||||
|
||||
static uint64_t shadow_kib(void);
|
||||
@@ -143,8 +167,12 @@ static double dlss_share(const char *m) {
|
||||
int ready = upscaler_ready();
|
||||
if (!ready && !told++) {
|
||||
#ifdef _WIN32
|
||||
rt_log("resolution: DLSS %s needs nvngx_dlss.dll next to totk.exe, which is missing: the scene follows "
|
||||
"render_scale", m);
|
||||
if (vk_upscaler_engine() == UPSCALER_FSR4)
|
||||
rt_log("resolution: FSR 4 %s needs amd_fidelityfx_loader_vk.dll and amd_fidelityfx_upscaler_vk.dll "
|
||||
"next to totk.exe, which are missing: the scene follows render_scale", m);
|
||||
else
|
||||
rt_log("resolution: DLSS %s needs nvngx_dlss.dll next to totk.exe, which is missing: the scene "
|
||||
"follows render_scale", m);
|
||||
#else
|
||||
rt_log("resolution: DLSS %s needs libnvidia-ngx-dlss.so.<version> next to totk, which is missing: the "
|
||||
"scene follows render_scale", m);
|
||||
@@ -208,7 +236,7 @@ static void decide(void) {
|
||||
else rt_log("resolution: TOTK_SHADOW_RES=%s is not game or a size 256..4096 (a multiple of 8); game", sr);
|
||||
}
|
||||
// A DLSS mode other than dlaa sets the scene size instead. On 1.4.3 with the scene upscaler able to run (DLSS with
|
||||
// its DLL there, or FSR 3.1 in the build)
|
||||
// its DLL there, FSR 4 with AMD's libraries there, or FSR 3.1 in the build)
|
||||
// the mode can change while the game runs (res_dlss_mode): the scene patch is then always on and the heap is sized
|
||||
// for the largest scene the modes ask for. Everyone else keeps the game's own scene size and its dynamic resolution
|
||||
// unless render_scale or a DLSS mode asks for another, and a heap sized for that scene alone.
|
||||
@@ -674,8 +702,8 @@ void res_fov_live(void) {
|
||||
// 2867-wide scene stays at 100 %, one wider than about 2970 does not, and a 4267-wide one (5120x1440 at render_scale
|
||||
// 83) fits no tier and falls back to 80 % every frame, whatever the GPU's load. 1 (the default) leaves the game's own
|
||||
// stepping and the set off. Runs on a settings change (gfx_present.c window_settings_live), like res_fov_live.
|
||||
// FSR 3.1 as the scene upscaler holds it at 100 % whatever dynamic_res says, as codexx-dev's pull request #1245 does
|
||||
// for its FSR: each tier is a scene of another size, so every step starts FSR's history again, and below 100 % the
|
||||
// FSR 3.1 or FSR 4 as the scene upscaler holds it at 100 % whatever dynamic_res says, as codexx-dev's pull request
|
||||
// #1245 does for its FSR: each tier is a scene of another size, so every step starts FSR's history again, and below 100 % the
|
||||
// game ends its frame another way (a frame log on 1.4.3: its copy shader scales the scene straight into the
|
||||
// output-sized target instead of the scaling FXAA draw), which #1245 measured as a picture that went soft and sharp in
|
||||
// turns at a 2560x1440 scene. A 1280x720 scene (1080p, quality) stayed at 100 % through a 70 s town run, so it gains
|
||||
@@ -683,7 +711,8 @@ void res_fov_live(void) {
|
||||
void res_dynres_live(void) {
|
||||
static int set = -2, shown = -1;
|
||||
if (set == -2) set = rt_patch_set("fixres");
|
||||
int fsr = vk_upscaler_on() && vk_upscaler_engine() == UPSCALER_FSR3;
|
||||
int e = vk_upscaler_engine();
|
||||
int fsr = vk_upscaler_on() && (e == UPSCALER_FSR3 || e == UPSCALER_FSR4);
|
||||
int dyn = cfg_bool("TOTK_DYNAMIC_RES") && !fsr;
|
||||
int state = dyn | fsr << 1;
|
||||
if (state == shown) return;
|
||||
@@ -695,7 +724,7 @@ void res_dynres_live(void) {
|
||||
rt_patch_switch(set, !dyn);
|
||||
rt_log("resolution: dynamic resolution %s",
|
||||
dyn ? "on: the game's own 100, 90 or 80 %"
|
||||
: fsr ? "off while FSR 3.1 upscales the scene: the scene stays at 100 %"
|
||||
: fsr ? "off while FSR upscales the scene: the scene stays at 100 %"
|
||||
: "off: the scene stays at 100 %");
|
||||
}
|
||||
|
||||
|
||||
+135
-2
@@ -25,7 +25,8 @@
|
||||
//
|
||||
// The resource size table: with a player mod enabled, the game's table is rebuilt at start with the tables the mods
|
||||
// ship merged in and the entries of the mods' files raised to what they need (restbl_overlay), the members of their
|
||||
// packs too (restbl_packs), and served from <profile>/mods/ in place of the game's or a mod's table.
|
||||
// packs too (restbl_packs), and served from <profile>/mods/ in place of the game's or a mod's table. TOTK_RESTBL_CACHE=1
|
||||
// serves the table of the last start instead when every input of the build is the same (restbl_cache_key).
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -761,6 +762,127 @@ static int restbl_packs(Restbl *out, const Restbl *base, int *packs, int *lines)
|
||||
return raised;
|
||||
}
|
||||
|
||||
// ---- the merged table across starts (TOTK_RESTBL_CACHE=1, off by default). Building it opens every mod file and
|
||||
// unpacks the mods' packs. A start whose inputs are the same as the last one's serves the table that start wrote.
|
||||
// The key is a SHA-256 over every input restbl_overlay reads:
|
||||
// - the running totk.exe's path and identity: a new build may merge differently, and it carries the port version, the
|
||||
// game version and the RomFS index's SHA-256 (romfs_config.h);
|
||||
// - the RomFS image's path and identity and the game table's index entry: the base table, the game's copies of the
|
||||
// mods' packs and Pack/ZsDic.pack.zs come from the image;
|
||||
// - every shipped table (restbl_collect, mod_walk_cb; also the ones overlay_contest drops) with its owner and identity;
|
||||
// - every overlay overlay_contest kept (player mods, the TOTK_ROMFS_MODS manifest, the port's folders) with its RomFS
|
||||
// path, file path, place in the order (index, prio, mod) and identity.
|
||||
// Identity is the volume, file id, size, last write and creation time. A file's bytes are not hashed: identity is
|
||||
// what the overlay layer already trusts (romfs_open stops the game on a file whose identity changed after the start
|
||||
// check), and hashing a texture pack would cost more than the merge does. <profile>/mods/<table>.key holds the key,
|
||||
// what the build gave (a table or none) and the SHA-256 of the table it wrote; it is replaced atomically after the
|
||||
// table is written. A key file of another size, magic or version, another key, or a table of another SHA-256 is a
|
||||
// miss: the table is built again and both files are replaced, so the cache stays two files.
|
||||
#define RESTBL_CACHE_VERSION 3
|
||||
typedef struct { char magic[8]; uint32_t version, outcome; uint8_t key[32], table[32]; } RestblCache;
|
||||
enum { RESTBL_NONE = 1, RESTBL_TABLE = 2 };
|
||||
|
||||
static void restbl_cache_paths(char *key, size_t key_cap, char *table, size_t table_cap) {
|
||||
const char *leaf = strrchr(restbl_rel, '/') ? strrchr(restbl_rel, '/') + 1 : restbl_rel;
|
||||
need(snprintf(table, table_cap, "%s/mods/%s", rt_config()->profile, leaf) < (int)table_cap, "table path");
|
||||
need(snprintf(key, key_cap, "%s.key", table) < (int)key_cap, "table key path");
|
||||
}
|
||||
|
||||
static void hash_identity(Sha256 *h, const char *path, const Identity *id) {
|
||||
sha256_update(h, path, strlen(path) + 1);
|
||||
sha256_update(h, id, sizeof *id);
|
||||
}
|
||||
|
||||
// 0 when path cannot be opened.
|
||||
static int hash_file_id(Sha256 *h, const char *path) {
|
||||
PlatFile *f = open_read(path);
|
||||
Identity id = {0};
|
||||
if (f) id = identity_of(f), plat_file_close(f);
|
||||
hash_identity(h, path, &id);
|
||||
return f != NULL;
|
||||
}
|
||||
|
||||
// The key of this start's inputs into out; 0 when the running exe cannot be opened (no key: the table is built).
|
||||
static int restbl_cache_key(uint64_t gi, uint8_t out[32]) {
|
||||
char exe[2100];
|
||||
Sha256 h;
|
||||
sha256_init(&h);
|
||||
static const char tag[] = "totk restbl cache";
|
||||
uint32_t v = RESTBL_CACHE_VERSION;
|
||||
sha256_update(&h, tag, sizeof tag);
|
||||
sha256_update(&h, &v, sizeof v);
|
||||
sha256_update(&h, rt_port_version, strlen(rt_port_version) + 1);
|
||||
if (!plat_exe_path(exe, sizeof exe) || !hash_file_id(&h, exe)) return 0;
|
||||
Identity img = identity_of(image);
|
||||
hash_identity(&h, image_file, &img);
|
||||
Entry ge = entry(gi);
|
||||
sha256_update(&h, &ge, sizeof ge);
|
||||
uint64_t n = nshipped;
|
||||
sha256_update(&h, &n, sizeof n);
|
||||
for (size_t s = 0; s < nshipped; s++) {
|
||||
int32_t m[2] = {shipped[s].mod, shipped[s].other};
|
||||
sha256_update(&h, m, sizeof m);
|
||||
hash_file_id(&h, shipped[s].file);
|
||||
}
|
||||
n = noverlay;
|
||||
sha256_update(&h, &n, sizeof n);
|
||||
for (size_t k = 0; k < noverlay; k++) {
|
||||
const Overlay *o = &overlays[k];
|
||||
int64_t place[3] = {o->index == ADDED ? -1 : (int64_t)o->index, o->prio, o->mod};
|
||||
sha256_update(&h, o->name, strlen(o->name) + 1);
|
||||
sha256_update(&h, place, sizeof place);
|
||||
hash_identity(&h, o->path, &o->id);
|
||||
}
|
||||
sha256_final(&h, out);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Records the build's result for key: RESTBL_NONE, or RESTBL_TABLE with the SHA-256 of the table it wrote.
|
||||
static void restbl_cache_store(const uint8_t key[32], int outcome, const uint8_t table[32]) {
|
||||
char kp[2300], tp[2300];
|
||||
restbl_cache_paths(kp, sizeof kp, tp, sizeof tp);
|
||||
RestblCache c = {.magic = {'T', 'O', 'T', 'K', 'R', 'S', 'Z', 'C'}, .version = RESTBL_CACHE_VERSION,
|
||||
.outcome = (uint32_t)outcome};
|
||||
memcpy(c.key, key, 32);
|
||||
if (table) memcpy(c.table, table, 32);
|
||||
if (!plat_file_write_atomic(kp, &c, sizeof c))
|
||||
rt_log("RomFS: cannot write %s; the resource size table is built at every start", kp);
|
||||
}
|
||||
|
||||
// 1 when the last start's result fits: its table is served again (or none, as then). A miss logs why.
|
||||
static int restbl_cache_use(const uint8_t key[32], Overlay *served, const char *keeps, double t0) {
|
||||
char kp[2300], tp[2300];
|
||||
restbl_cache_paths(kp, sizeof kp, tp, sizeof tp);
|
||||
uint64_t n = 0;
|
||||
RestblCache *c = (RestblCache *)plat_file_read(kp, &n);
|
||||
const char *miss = NULL;
|
||||
if (!c || n != sizeof *c || memcmp(c->magic, "TOTKRSZC", 8) || c->version != RESTBL_CACHE_VERSION ||
|
||||
(c->outcome != RESTBL_NONE && c->outcome != RESTBL_TABLE))
|
||||
miss = "no usable key from an earlier start";
|
||||
else if (memcmp(c->key, key, 32))
|
||||
miss = "the mods, the game files or the build changed since the last start";
|
||||
if (!miss && c->outcome == RESTBL_TABLE) {
|
||||
uint64_t zn = 0;
|
||||
uint8_t *z = plat_file_read(tp, &zn), sum[32];
|
||||
if (z) sha256(z, (size_t)zn, sum);
|
||||
if (!z || memcmp(sum, c->table, 32)) {
|
||||
free(z);
|
||||
miss = "the kept table is missing or damaged";
|
||||
} else if (!serve_generated(restbl_rel, served, z, (size_t)zn, "mods", // frees z
|
||||
"merged resource sizes, kept from the last start", keeps)) {
|
||||
miss = "the kept table cannot be served";
|
||||
}
|
||||
}
|
||||
if (miss)
|
||||
rt_log("RomFS: resource size table: built again: %s", miss);
|
||||
else
|
||||
rt_log("RomFS: resource size table: the mods' files are the ones of the last start: %s (%.0f ms)",
|
||||
c->outcome == RESTBL_TABLE ? "its merged table is used" : "they fit the game's entries",
|
||||
(now_s() - t0) * 1000);
|
||||
free(c);
|
||||
return !miss;
|
||||
}
|
||||
|
||||
// With a player mod (or the TOTK_ROMFS_MODS manifest) serving files: the game's table with every shipped table of this
|
||||
// version merged in (an entry larger than the game's wins), the entries a mod's table for another version gives for
|
||||
// that mod's files, and each served mod file's entry raised to what its size needs (restbl_grow for a file the game
|
||||
@@ -773,6 +895,12 @@ static void restbl_overlay(void) {
|
||||
static const char keeps[] = "mod files that grew may fail to load";
|
||||
double t0 = now_s();
|
||||
uint64_t gi = lower(restbl_rel);
|
||||
uint8_t cache_key[32];
|
||||
Overlay *served_now = NULL;
|
||||
for (size_t k = 0; k < noverlay; k++)
|
||||
if (overlays[k].index == gi) served_now = &overlays[k];
|
||||
int cached = rt_knob("RESTBL_CACHE", "0") && restbl_cache_key(gi, cache_key);
|
||||
if (cached && restbl_cache_use(cache_key, served_now, keeps, t0)) return;
|
||||
Entry ge = entry(gi);
|
||||
void *gz = ge.size < (64u << 20) ? malloc((size_t)ge.size) : NULL;
|
||||
Restbl *base = NULL, *out = NULL;
|
||||
@@ -838,6 +966,7 @@ static void restbl_overlay(void) {
|
||||
if (!merged && !raised && !members && !served) {
|
||||
restbl_free(out);
|
||||
rt_log("RomFS: resource size table: the mods' files fit the game's entries (%.0f ms)", (now_s() - t0) * 1000);
|
||||
if (cached) restbl_cache_store(cache_key, RESTBL_NONE, NULL);
|
||||
return;
|
||||
}
|
||||
size_t rn = 0, zn = 0;
|
||||
@@ -852,10 +981,14 @@ static void restbl_overlay(void) {
|
||||
rt_log("RomFS: cannot pack the merged resource size table; %s", keeps);
|
||||
return;
|
||||
}
|
||||
if (serve_generated(restbl_rel, served, z, zn, "mods", "merged resource sizes", keeps))
|
||||
uint8_t sum[32];
|
||||
if (cached) sha256(z, zn, sum); // before serve_generated frees z
|
||||
if (serve_generated(restbl_rel, served, z, zn, "mods", "merged resource sizes", keeps)) {
|
||||
rt_log("RomFS: resource size table: %d tables merged (%d entries), %d entries raised for mod files (%d "
|
||||
"added files estimated), %d for members of %d mod packs, %.0f ms", tables, merged, raised, estimated,
|
||||
members, packs, (now_s() - t0) * 1000);
|
||||
if (cached) restbl_cache_store(cache_key, RESTBL_TABLE, sum);
|
||||
}
|
||||
}
|
||||
|
||||
// The HeapDef table a bigger game resolution or TOTK_TEX_HEAP_EXTRA_MB needs (resolution.c): its texture heaps and
|
||||
|
||||
+6
@@ -43,3 +43,9 @@ Changes of our own (marked "TotK Recomp"):
|
||||
- `sdk/include/FidelityFX/gpu/fsr3upscaler/ffx_fsr3upscaler_callbacks_glsl.h`: the luma history's storage image is
|
||||
declared `rgba16f`, the format of its images (R16G16B16A16_FLOAT in `ffx_fsr3upscaler.cpp`). It was `rgba8`, which
|
||||
the Vulkan validation layer reports as a format mismatch with undefined loads and stores.
|
||||
- `sdk/src/backends/vk/ffx_vk.cpp` `findMemoryTypeIndex`: memory types with `PROTECTED`, `DEVICE_COHERENT_AMD` or
|
||||
`DEVICE_UNCACHED_AMD` are skipped, since the runtime enables neither protected memory nor device-coherent memory. The
|
||||
function keeps the last matching type, and RADV lists those types after the plain device-local ones, so on a Radeon
|
||||
780M (Mesa 26.3) FSR 3.1's images were allocated in them and its whole output was noise. When no device-local type
|
||||
without `HOST_VISIBLE` exists (unified-memory GPUs: Adreno under Turnip) it takes a host-visible device-local one
|
||||
instead of failing every texture allocation.
|
||||
@@ -402,14 +402,28 @@ uint32_t findMemoryTypeIndex(VkPhysicalDevice physicalDevice, VkMemoryRequiremen
|
||||
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &memProperties);
|
||||
|
||||
uint32_t bestCandidate = UINT32_MAX;
|
||||
// TotK Recomp: unified-memory GPUs (Adreno under Turnip) have no device-local type without HOST_VISIBLE: the first
|
||||
// host-visible one is taken rather than failing when no invisible type exists.
|
||||
uint32_t visibleCandidate = UINT32_MAX;
|
||||
VkMemoryPropertyFlags visibleProperties = 0;
|
||||
|
||||
for (uint32_t i = 0; i < memProperties.memoryTypeCount; i++) {
|
||||
if ((memRequirements.memoryTypeBits & (1 << i)) && (memProperties.memoryTypes[i].propertyFlags & requestedProperties)) {
|
||||
|
||||
// if just device-local memory is requested, make sure this is the invisible heap to prevent over-subscribing the local heap
|
||||
if (requestedProperties == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT && (memProperties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
|
||||
// TotK Recomp: types that need a device feature the application did not enable are skipped. The loop keeps
|
||||
// the last match, and RADV lists protected (TMZ) and AMD device-coherent/uncached device-local types after
|
||||
// the plain ones: FSR 3.1's images landed in them and every pass read noise.
|
||||
if (memProperties.memoryTypes[i].propertyFlags & (VK_MEMORY_PROPERTY_PROTECTED_BIT | VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD |
|
||||
VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD))
|
||||
continue;
|
||||
|
||||
// if just device-local memory is requested, make sure this is the invisible heap to prevent over-subscribing the local heap
|
||||
if (requestedProperties == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT && (memProperties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) {
|
||||
if (visibleCandidate == UINT32_MAX)
|
||||
visibleCandidate = i, visibleProperties = memProperties.memoryTypes[i].propertyFlags;
|
||||
continue;
|
||||
}
|
||||
|
||||
bestCandidate = i;
|
||||
outProperties = memProperties.memoryTypes[i].propertyFlags;
|
||||
|
||||
@@ -419,6 +433,10 @@ uint32_t findMemoryTypeIndex(VkPhysicalDevice physicalDevice, VkMemoryRequiremen
|
||||
}
|
||||
}
|
||||
|
||||
if (bestCandidate == UINT32_MAX && visibleCandidate != UINT32_MAX) {
|
||||
bestCandidate = visibleCandidate;
|
||||
outProperties = visibleProperties;
|
||||
}
|
||||
return bestCandidate;
|
||||
}
|
||||
|
||||
|
||||
+39
-24
@@ -67,7 +67,7 @@ int playtime_get(uint64_t *total_s, uint64_t *session_s); // playtime.c
|
||||
bool amiibo_check_font_rebuild(void); // ui/amiibo_page.cpp; check and clear font rebuild request
|
||||
}
|
||||
|
||||
// Roboto Medium (Apache-2.0, ui/fonts/LICENSE-Roboto.txt) with Latin and Cyrillic glyphs.
|
||||
// Roboto Medium (Apache-2.0, ui/fonts/LICENSE-Roboto.txt) with Latin, Vietnamese and Cyrillic glyphs.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wc23-extensions" // #embed in C++
|
||||
static const unsigned char roboto_ttf[] = {
|
||||
@@ -276,12 +276,14 @@ static int vk_up(const MenuTarget *t) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Roboto Medium (Latin, Cyrillic, dashes and quotes) at 26 px per 1080 lines, with the glyphs of the Japanese, Korean
|
||||
// and Chinese language names merged in from a system font when there is one (each language is named in its own script).
|
||||
// A catalog row also holds menu text (Simplified Chinese), so every string of the row goes into the builder: the merged
|
||||
// font must cover the whole menu of that language, not only its name. Made again when the window height changes; the old
|
||||
// texture goes after the queue is idle (CreateFontsTexture).
|
||||
static const ImWchar kRanges[] = {0x0020, 0x00FF, 0x0400, 0x052F, 0x2010, 0x2027, 0};
|
||||
// Roboto Medium (Latin with Latin Extended-A for the French oe and the Vietnamese letters Latin-1 lacks:
|
||||
// 0x0100-0x01B0, the combining marks 0x0300-0x0323 and 0x1EA0-0x1EF9; Cyrillic, dashes and quotes) at 26 px per
|
||||
// 1080 lines, with the glyphs of the Japanese, Korean and Chinese language names merged in from a system font when
|
||||
// there is one (each language is named in its own script). A catalog row also holds menu text (Japanese, Korean,
|
||||
// Simplified Chinese), so every string of the row goes into the builder: the merged font must cover the whole menu
|
||||
// of that language, not only its name. Made again when the window height changes; the old texture goes after the
|
||||
// queue is idle (CreateFontsTexture).
|
||||
static const ImWchar kRanges[] = {0x0020, 0x01B0, 0x0300, 0x0323, 0x0400, 0x052F, 0x1EA0, 0x1EF9, 0x2010, 0x2027, 0};
|
||||
static const struct { const char *lang; UiTextId name; } kCjk[] = {
|
||||
{"ja", UI_MENU_LANGNAME_JA}, {"ko", UI_MENU_LANGNAME_KO}, {"zh-Hans", UI_MENU_LANGNAME_ZH_HANS},
|
||||
{"zh-Hant", UI_MENU_LANGNAME_ZH_HANT},
|
||||
@@ -616,22 +618,30 @@ static void row_hud_width(void) {
|
||||
opt_choice_list("TOTK_HUD_WIDTH", UI_MENU_HUD_WIDTH, vals, names, n, UI_MENU_HUD_WIDTH_DESC);
|
||||
}
|
||||
|
||||
// The 3D scene upscaler (vk_dlaa.c): off, NVIDIA DLSS or AMD FSR 3.1. An engine that cannot run here is left out of
|
||||
// the steps, and the note under the value says why; a totk.ini that names it anyway shows it, with the same note.
|
||||
// Returns the value the settings name ("off", "dlss", "fsr3"; without scene_upscaler, dlaa = 1 is "dlss").
|
||||
// The 3D scene upscaler (vk_dlaa.c): off, NVIDIA DLSS, AMD FSR 3.1 or AMD FSR 4. An engine that cannot run here is
|
||||
// left out of the steps, and the note under the value says why; a totk.ini that names it anyway shows it, with the
|
||||
// same note. FSR 4 is Windows only (AMD ships no Linux libraries): elsewhere it is left out without a note.
|
||||
// Returns the value the settings name ("off", "dlss", "fsr3", "fsr4"; without scene_upscaler, dlaa = 1 is "dlss").
|
||||
static const char *row_scene_upscaler(void) {
|
||||
static const char *const all[] = {"off", "dlss", "fsr3"};
|
||||
static const int engines[] = {UPSCALER_OFF, UPSCALER_DLSS, UPSCALER_FSR3};
|
||||
static const UiTextId ids[] = {UI_MENU_SCENE_UPSCALER_OFF, UI_MENU_SCENE_UPSCALER_DLSS, UI_MENU_SCENE_UPSCALER_FSR3};
|
||||
enum { N = 4 };
|
||||
static const char *const all[N] = {"off", "dlss", "fsr3", "fsr4"};
|
||||
static const int engines[N] = {UPSCALER_OFF, UPSCALER_DLSS, UPSCALER_FSR3, UPSCALER_FSR4};
|
||||
static const UiTextId ids[N] = {UI_MENU_SCENE_UPSCALER_OFF, UI_MENU_SCENE_UPSCALER_DLSS, UI_MENU_SCENE_UPSCALER_FSR3,
|
||||
UI_MENU_SCENE_UPSCALER_FSR4};
|
||||
const char *now = cfg_scene_upscaler();
|
||||
const char *vals[3], *names[3];
|
||||
const char *vals[N], *names[N];
|
||||
static char note[256];
|
||||
note[0] = 0;
|
||||
int n = 0, cur = -1;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < N; i++) {
|
||||
int why = vk_upscaler_missing(engines[i]);
|
||||
if (why) {
|
||||
UiTextId t = why == UPSCALER_MISSING_DLL ? UI_MENU_SCENE_UPSCALER_NO_DLSS_DLL : UI_MENU_SCENE_UPSCALER_NO_DLSS_GPU;
|
||||
if (why && (why != UPSCALER_MISSING_OS || !strcmp(now, all[i]))) {
|
||||
UiTextId t = engines[i] == UPSCALER_FSR4
|
||||
? (why == UPSCALER_MISSING_DLL ? UI_MENU_SCENE_UPSCALER_NO_FSR4_DLL
|
||||
: why == UPSCALER_MISSING_OS ? UI_MENU_SCENE_UPSCALER_NO_FSR4_OS
|
||||
: UI_MENU_SCENE_UPSCALER_NO_FSR4_GPU)
|
||||
: why == UPSCALER_MISSING_DLL ? UI_MENU_SCENE_UPSCALER_NO_DLSS_DLL
|
||||
: UI_MENU_SCENE_UPSCALER_NO_DLSS_GPU;
|
||||
size_t k = strlen(note);
|
||||
snprintf(note + k, sizeof note - k, "%s%s", k ? "; " : "", menu_text(t));
|
||||
}
|
||||
@@ -827,9 +837,9 @@ static void tab_screen(float scale) {
|
||||
UI_MENU_DLSS_PERFORMANCE, UI_MENU_DLSS_ULTRA};
|
||||
opt_choice("TOTK_DLSS", UI_MENU_DLSS, dlss, 5, UI_MENU_DLSS_DESC);
|
||||
}
|
||||
if (!strcmp(engine, "fsr3")) // FSR 3.1's own sharpening (vk_dlaa.c fsr_evaluate)
|
||||
opt_slider("TOTK_FSR_SHARPNESS", UI_MENU_FSR3_SHARPNESS, 0, 100, UI_MENU_FSR3_SHARPNESS_DESC, 5, "%.0f %%");
|
||||
if (!strcmp(engine, "dlss")) { // DLSS's model, its characters' mask and its other switches (FSR 3.1 has none)
|
||||
if (!strcmp(engine, "fsr3") || !strcmp(engine, "fsr4")) // FSR's own sharpening (vk_dlaa.c fsr_evaluate)
|
||||
opt_slider("TOTK_FSR_SHARPNESS", UI_MENU_FSR_SHARPNESS, 0, 100, UI_MENU_FSR_SHARPNESS_DESC, 5, "%.0f %%");
|
||||
if (!strcmp(engine, "dlss")) { // DLSS's model, its characters' mask and its other switches (FSR has none)
|
||||
static const UiTextId preset[] = {UI_MENU_DLSS_PRESET_DEFAULT, UI_MENU_DLSS_PRESET_K, UI_MENU_DLSS_PRESET_J};
|
||||
opt_choice("TOTK_DLSS_PRESET", UI_MENU_DLSS_PRESET, preset, 3, UI_MENU_DLSS_PRESET_DESC);
|
||||
static const UiTextId chars[] = {UI_MENU_DLSS_CHARS_OFF, UI_MENU_DLSS_CHARS_LIGHT, UI_MENU_DLSS_CHARS_MEDIUM,
|
||||
@@ -838,8 +848,8 @@ static void tab_screen(float scale) {
|
||||
opt_toggle("TOTK_DLSS_FIXED_EXPOSURE", UI_MENU_DLSS_FIXED_EXPOSURE, UI_MENU_DLSS_FIXED_EXPOSURE_DESC);
|
||||
opt_toggle("TOTK_DLAA_EFFECTS_AFTER", UI_MENU_DLAA_EFFECTS_AFTER, UI_MENU_DLAA_EFFECTS_AFTER_DESC);
|
||||
}
|
||||
static const UiTextId reflex[] = {UI_MENU_REFLEX_OFF, UI_MENU_REFLEX_ON, UI_MENU_REFLEX_BOOST};
|
||||
opt_choice("TOTK_REFLEX", UI_MENU_REFLEX, reflex, 3, UI_MENU_REFLEX_DESC);
|
||||
static const UiTextId reflex[] = {UI_MENU_REFLEX_OFF, UI_MENU_REFLEX_AUTO, UI_MENU_REFLEX_ON, UI_MENU_REFLEX_BOOST};
|
||||
opt_choice("TOTK_REFLEX", UI_MENU_REFLEX, reflex, 4, UI_MENU_REFLEX_DESC);
|
||||
opt_toggle("TOTK_FXAA", UI_MENU_FXAA, UI_MENU_FXAA_DESC);
|
||||
rows_color();
|
||||
opt_group(UI_MENU_HDR_GROUP);
|
||||
@@ -1179,7 +1189,10 @@ static void tab_controls(float scale) {
|
||||
static void tab_menu(float scale) {
|
||||
opt_begin("##menu", scale);
|
||||
static const UiTextId langs[] = {UI_MENU_MENU_LANG_AUTO, UI_MENU_LANGNAME_EN, UI_MENU_LANGNAME_RU,
|
||||
UI_MENU_LANGNAME_PT_BR, UI_MENU_LANGNAME_ZH_HANS};
|
||||
UI_MENU_LANGNAME_PT_BR, UI_MENU_LANGNAME_ZH_HANS, UI_MENU_LANGNAME_DE,
|
||||
UI_MENU_LANGNAME_FR, UI_MENU_LANGNAME_ES, UI_MENU_LANGNAME_IT,
|
||||
UI_MENU_LANGNAME_NL, UI_MENU_LANGNAME_JA, UI_MENU_LANGNAME_KO,
|
||||
UI_MENU_LANGNAME_VI};
|
||||
opt_choice("TOTK_MENU_LANG", UI_MENU_MENU_LANG, langs, sizeof langs / sizeof *langs, UI_MENU_MENU_LANG_DESC);
|
||||
opt_toggle("TOTK_DISCORD_RPC", UI_MENU_DISCORD_RPC, UI_MENU_DISCORD_RPC_DESC);
|
||||
opt_end();
|
||||
@@ -1779,7 +1792,9 @@ static void perf_picture(const MenuTarget *t, const ImVec4 &c) {
|
||||
: !strcmp(m, "ultra_performance") ? UI_MENU_DLSS_ULTRA
|
||||
: UI_MENU_DLSS_DLAA;
|
||||
snprintf(v[6], sizeof v[6], "%s, %s",
|
||||
menu_text(up == UPSCALER_FSR3 ? UI_MENU_SCENE_UPSCALER_FSR3 : UI_MENU_SCENE_UPSCALER_DLSS),
|
||||
menu_text(up == UPSCALER_FSR4 ? UI_MENU_SCENE_UPSCALER_FSR4
|
||||
: up == UPSCALER_FSR3 ? UI_MENU_SCENE_UPSCALER_FSR3
|
||||
: UI_MENU_SCENE_UPSCALER_DLSS),
|
||||
menu_text(mt));
|
||||
}
|
||||
// with frame generation: the pictures shown a second, of which the FPS row above counts the ones the game drew
|
||||
|
||||
+6717
-36
File diff suppressed because it is too large.
Load diff
+10
-9
@@ -11,8 +11,8 @@ typedef enum {
|
||||
UI_SWKBD_CANCEL,
|
||||
UI_SWKBD_PAD_HINT, // how a controller answers
|
||||
|
||||
// Menu: window, tabs, bottom row. UI_MENU_FIRST..UI_MENU_LAST_ID carry English, Russian, Brazilian Portuguese and
|
||||
// Simplified Chinese texts.
|
||||
// Menu: window, tabs, bottom row. UI_MENU_FIRST..UI_MENU_LAST_ID carry English, Russian, Brazilian Portuguese,
|
||||
// Simplified Chinese, German, French, Spanish, Italian, Dutch, Japanese, Korean and Vietnamese texts.
|
||||
UI_MENU_FIRST,
|
||||
UI_MENU_TITLE = UI_MENU_FIRST,
|
||||
UI_MENU_TAB_SCREEN, UI_MENU_TAB_GAME, UI_MENU_TAB_MODS, UI_MENU_TAB_SOUND, UI_MENU_TAB_CONTROLS, UI_MENU_TAB_AMIIBO,
|
||||
@@ -63,10 +63,11 @@ typedef enum {
|
||||
UI_MENU_DLSS_BALANCED, UI_MENU_DLSS_PERFORMANCE, UI_MENU_DLSS_ULTRA, UI_MENU_DLSS_PRESET, UI_MENU_DLSS_PRESET_DESC,
|
||||
UI_MENU_DLSS_PRESET_DEFAULT, UI_MENU_DLSS_PRESET_K, UI_MENU_DLSS_PRESET_J, UI_MENU_DLSS_CHARS, UI_MENU_DLSS_CHARS_DESC,
|
||||
UI_MENU_DLSS_CHARS_OFF, UI_MENU_DLSS_CHARS_LIGHT, UI_MENU_DLSS_CHARS_MEDIUM, UI_MENU_DLSS_CHARS_FULL, UI_MENU_FXAA, UI_MENU_FXAA_DESC,
|
||||
UI_MENU_REFLEX, UI_MENU_REFLEX_DESC, UI_MENU_REFLEX_OFF, UI_MENU_REFLEX_ON, UI_MENU_REFLEX_BOOST,
|
||||
UI_MENU_REFLEX, UI_MENU_REFLEX_DESC, UI_MENU_REFLEX_AUTO, UI_MENU_REFLEX_OFF, UI_MENU_REFLEX_ON, UI_MENU_REFLEX_BOOST,
|
||||
UI_MENU_SCENE_UPSCALER, UI_MENU_SCENE_UPSCALER_DESC, UI_MENU_SCENE_UPSCALER_OFF, UI_MENU_SCENE_UPSCALER_DLSS,
|
||||
UI_MENU_SCENE_UPSCALER_FSR3, UI_MENU_SCENE_UPSCALER_NO_DLSS_GPU, UI_MENU_SCENE_UPSCALER_NO_DLSS_DLL, UI_MENU_FSR3_SHARPNESS,
|
||||
UI_MENU_FSR3_SHARPNESS_DESC,
|
||||
UI_MENU_SCENE_UPSCALER_FSR3, UI_MENU_SCENE_UPSCALER_NO_DLSS_GPU, UI_MENU_SCENE_UPSCALER_NO_DLSS_DLL, UI_MENU_FSR_SHARPNESS,
|
||||
UI_MENU_FSR_SHARPNESS_DESC, UI_MENU_SCENE_UPSCALER_FSR4, UI_MENU_SCENE_UPSCALER_NO_FSR4_GPU,
|
||||
UI_MENU_SCENE_UPSCALER_NO_FSR4_DLL, UI_MENU_SCENE_UPSCALER_NO_FSR4_OS,
|
||||
|
||||
// Game
|
||||
UI_MENU_FPS_LIMIT, UI_MENU_FPS_LIMIT_DESC, UI_MENU_FPS_30, UI_MENU_FPS_40, UI_MENU_FPS_45, UI_MENU_FPS_60, UI_MENU_FPS_90,
|
||||
@@ -228,7 +229,7 @@ typedef enum {
|
||||
UI_MENU_LANGNAME_EN, UI_MENU_LANGNAME_JA, UI_MENU_LANGNAME_FR, UI_MENU_LANGNAME_DE, UI_MENU_LANGNAME_IT,
|
||||
UI_MENU_LANGNAME_ES, UI_MENU_LANGNAME_NL, UI_MENU_LANGNAME_RU, UI_MENU_LANGNAME_ZH_HANS,
|
||||
UI_MENU_LANGNAME_ZH_HANT, UI_MENU_LANGNAME_KO, UI_MENU_LANGNAME_PT_BR, UI_MENU_LANGNAME_EN_GB,
|
||||
UI_MENU_LANGNAME_FR_CA, UI_MENU_LANGNAME_ES_419,
|
||||
UI_MENU_LANGNAME_FR_CA, UI_MENU_LANGNAME_ES_419, UI_MENU_LANGNAME_VI,
|
||||
|
||||
// Advanced
|
||||
UI_MENU_ADV_WARNING,
|
||||
@@ -331,7 +332,7 @@ const char *ui_text_lang(const char *switch_code);
|
||||
typedef struct { const char *code; UiTextId name; } UiGameLang;
|
||||
int ui_text_game_langs(int game_version, UiGameLang *out, int max);
|
||||
|
||||
// Menu text: ui_text_in(menu language, id). The menu language is TOTK_MENU_LANG ("en", "ru", "pt-BR", "zh-Hans");
|
||||
// unset, the system UI language when the catalog has menu text for it (English, Russian, Brazilian Portuguese,
|
||||
// Simplified Chinese), else English. Follows a live change of the setting.
|
||||
// Menu text: ui_text_in(menu language, id). The menu language is TOTK_MENU_LANG ("en", "ru", "pt-BR", "zh-Hans", "de",
|
||||
// "fr", "es", "it", "nl", "ja", "ko"); unset, the system UI language when the catalog has menu text for it, Simplified
|
||||
// Chinese for Traditional Chinese, else English. Follows a live change of the setting.
|
||||
const char *menu_text(UiTextId id);
|
||||
+14
-4
@@ -11,7 +11,7 @@
|
||||
#include "vk_ahead.h" // TOTK_SYNC_AHEAD=check hooks (vk_ahead_on)
|
||||
|
||||
// Required (device choice fails without them): Vulkan 1.3; VK_KHR_swapchain, VK_KHR_push_descriptor,
|
||||
// VK_EXT_depth_clip_control, VK_EXT_external_memory_host; features timelineSemaphore, dynamicRendering,
|
||||
// VK_EXT_depth_clip_control; features timelineSemaphore, dynamicRendering,
|
||||
// synchronization2, shaderStorageImageWriteWithoutFormat, depthClipControl, shaderInt64, samplerAnisotropy,
|
||||
// independentBlend, geometryShader, textureCompressionBC.
|
||||
// Optional (flag set in VkCtx when enabled): the has_* members.
|
||||
@@ -38,13 +38,16 @@ typedef struct VkCtx {
|
||||
has_astc_ldr, // textureCompressionASTC_LDR (enabled when reported)
|
||||
has_calibrated, // VK_KHR/EXT_calibrated_timestamps (GPU idle split in the perf line)
|
||||
has_hdr_metadata, // VK_EXT_hdr_metadata (vk_hdr.c vk_hdr_metadata)
|
||||
has_nv_reflex; // VK_NV_low_latency2 (NVIDIA Reflex Low Latency)
|
||||
has_nv_reflex, // VK_NV_low_latency2 (NVIDIA Reflex Low Latency)
|
||||
has_amd_antilag; // VK_AMD_anti_lag (AMD Anti-Lag 2)
|
||||
// Feedback loops (maxwell.md 1.9, vk_exec_draw.c feedback_prepare): a draw samples a target of its open pass that
|
||||
// an earlier draw of the pass wrote. TOTK_FEEDBACK=0: VK_FEEDBACK_OFF (sampled in GENERAL without a barrier, the
|
||||
// old behaviour); VK_FEEDBACK_LAYOUT with VK_EXT_attachment_feedback_loop_layout and dynamicRenderingLocalRead
|
||||
// (attachable images get feedback usage, a by-region barrier inside the pass); else (or TOTK_FEEDBACK=restart)
|
||||
// VK_FEEDBACK_RESTART (the pass ends and restarts behind the full barrier).
|
||||
int feedback; // VK_FEEDBACK_*
|
||||
int has_external_memory_host; // VK_EXT_external_memory_host; without it CPU-visible pools get shadow
|
||||
// storage (vk_memory.c mirror_mode), as under Wine
|
||||
uint32_t min_imported_host_alignment; // VK_EXT_external_memory_host
|
||||
VkDeviceSize vma_block; // VMA's block size for heaps over 1 GiB (TOTK_VMA_BLOCK_MIB, vk_device.c)
|
||||
int device_index; // index in vkEnumeratePhysicalDevices
|
||||
@@ -63,6 +66,7 @@ typedef struct {
|
||||
int mesa; // a Mesa driver the game runs on: RADV, ANV or NVK
|
||||
int intel_igpu_win; // Intel's Windows driver on an integrated GPU (UHD, Iris Xe, Core Ultra graphics)
|
||||
int demote; // shaderDemoteToHelperInvocation enabled: modules may use OpDemoteToHelperInvocation
|
||||
int null_attach; // TOTK_NULL_ATTACH=1: empty colour slots get a dummy attachment (vk_exec.c null_attach_view)
|
||||
} VkCaps;
|
||||
extern VkCaps vk_caps;
|
||||
void vk_caps_driver(VkPhysicalDevice p); // first, before vkCreateDevice: vk_caps.amd, amd_sc, mesa, intel_igpu_win
|
||||
@@ -209,7 +213,8 @@ long vk_validation_errors_total(void); // validation errors since th
|
||||
// Guest or host threads; every call needs vk_init(). The first nine have the GfxBackend signatures of gfx.h; vk_backend.c builds
|
||||
// gfx_vulkan_backend from them.
|
||||
int vk_pool_init(pool_t *p); // CPU-visible: guest storage imported (VK_EXT_external_memory_host) as one
|
||||
// VkBuffer; physical: device-local memory; virtual: a 64 KiB page table
|
||||
// VkBuffer, or its shadow copy (vk_memory.c mirror_mode); physical:
|
||||
// device-local memory; virtual: a 64 KiB page table
|
||||
void vk_pool_fini(pool_t *p); // drops images cut from the pool; waits for the GPU if it used the pool
|
||||
int vk_pool_map_virtual(pool_t *v, int n, const void *requests); // nvn_mapping_t[n], checked by the front end
|
||||
void vk_texture_register(int id, const tex_t *t, const view_t *v); // texture descriptor slot (copied)
|
||||
@@ -343,7 +348,8 @@ int vk_mem_flush_add_probe(void); // --probe-vkexec: the flush range list
|
||||
uint64_t vk_mem_mirror_uploaded(void); // --probe-vkexec: bytes copied into mirrors since the last summary line
|
||||
int vk_mem_mirror_probe(uint64_t addr); // --probe-vkexec: the pool at addr gets its mirror as on a first buffer use;
|
||||
// 1 when it has one
|
||||
void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDeviceMemoryProperties *m); // once
|
||||
void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDeviceMemoryProperties *m,
|
||||
int host_import); // once; host_import: VK_EXT_external_memory_host is enabled
|
||||
int vk_mem_class_of(uint64_t addr); // VK_MCLS_* of the pool at addr (NONE when unbacked)
|
||||
void vk_mem_census(uint64_t frame); // at each present: pool census and traffic, logged at frame 1800 and,
|
||||
// with TOTK_TRACE=perf, every 1800 frames
|
||||
@@ -502,6 +508,10 @@ typedef struct {
|
||||
// into it, when the last draw into it was that copy and the swapchain is HDR10.
|
||||
void vk_hdr_present_source(const VkTexImage *win, VkImage *image, VkFormat *format);
|
||||
void vk_hdr_image_gone(VkImage image);
|
||||
// vk_caps.null_attach: empty colour slots of a pass get a dummy VK_EXEC_NULL_ATTACH_FMT attachment, and the pipelines
|
||||
// name that format for them with writes masked off (vk_exec.c null_attach_view, vk_pipeline.c gkey_fill).
|
||||
#define VK_EXEC_NULL_ATTACH_FMT VK_FORMAT_R8_UNORM
|
||||
void vk_exec_null_attach_release(void); // vk_device.c, before the device goes: frees the dummy attachments
|
||||
const VkTexImage *vk_texture_get(const tex_t *t); // created and made current; NULL for BUFFER or unmapped formats
|
||||
const VkTexImage *vk_texture_revive(const tex_t *t, uint32_t pos); // the entry vk_texture_get would return if it exists, made live at op pos
|
||||
// A texture slot; a slot whose texture was finalized follows the live texture at the same storage (hle_nvn.c).
|
||||
|
||||
@@ -123,6 +123,9 @@ void vk_caps_init(VkCtx *c) {
|
||||
uint32_t zero_locals = env_u32("TOTK_ZERO_LOCALS", (uint32_t)vk_caps.mesa);
|
||||
gfx_shader_set_host(vk_caps.float64, vk_caps.sbuf_align, told, gather, zero_locals != 0);
|
||||
if (gather) rt_log("vk caps: gather coordinates biased for %u sub-texel bits (TOTK_GATHER_BIAS)", gather);
|
||||
// Read here, before any pipeline key is made: the pipelines' colour formats depend on it (vk_pipeline.c gkey_fill)
|
||||
vk_caps.null_attach = rt_knob("NULL_ATTACH", "0") == 1;
|
||||
if (vk_caps.null_attach) rt_log("vk caps: empty colour slots get a dummy attachment (TOTK_NULL_ATTACH=1)");
|
||||
|
||||
char dv[32];
|
||||
driver_version(dv, sizeof dv, c->props.vendorID, c->props.driverVersion);
|
||||
|
||||
+45
-7
@@ -13,6 +13,7 @@
|
||||
#include "platform/platform.h"
|
||||
#include "vk_dlaa.h"
|
||||
#include "vk_fg.h"
|
||||
#include "vk_ffx.h"
|
||||
#include "vk_fsr3.h"
|
||||
|
||||
static VkCtx g_vk;
|
||||
@@ -174,8 +175,7 @@ static int create_instance(void) {
|
||||
}
|
||||
|
||||
static const char *const k_required_ext[] = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME,
|
||||
VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME};
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME};
|
||||
|
||||
// Name of the first missing required extension, or NULL.
|
||||
static const char *missing_required(VkPhysicalDevice pd) {
|
||||
@@ -263,7 +263,6 @@ static int pick_device(void) {
|
||||
}
|
||||
free(qp);
|
||||
rt_log("vk: using gpu %d: %s", best, g_vk.props.deviceName);
|
||||
vk_mem_class_log(&g_vk.props, &g_vk.mem_props);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -289,6 +288,11 @@ typedef struct {
|
||||
VkPhysicalDeviceDynamicRenderingLocalReadFeaturesKHR lr;
|
||||
VkPhysicalDeviceAddressBindingReportFeaturesEXT abr;
|
||||
VkPhysicalDevicePresentIdFeaturesKHR pid;
|
||||
VkPhysicalDeviceCooperativeMatrixFeaturesKHR coop; // FSR 4 (vk_ffx.c)
|
||||
#ifdef VK_EXT_SHADER_FLOAT8_EXTENSION_NAME
|
||||
VkPhysicalDeviceShaderFloat8FeaturesEXT f8; // FSR 4 (vk_ffx.c)
|
||||
#endif
|
||||
VkPhysicalDeviceAntiLagFeaturesAMD al;
|
||||
} FeatureChain;
|
||||
|
||||
static int create_device(void) {
|
||||
@@ -299,6 +303,13 @@ static int create_device(void) {
|
||||
const char *ext[52];
|
||||
uint32_t n_ext = 0;
|
||||
for (size_t i = 0; i < sizeof k_required_ext / sizeof *k_required_ext; i++) ext[n_ext++] = k_required_ext[i];
|
||||
// VK_EXT_external_memory_host is optional: without it (or with TOTK_VK_NO_HOST_IMPORT=1, which tests that path on
|
||||
// any GPU) CPU-visible pools get shadow storage (vk_memory.c mirror_mode).
|
||||
const char *no_import = cfg_get("TOTK_VK_NO_HOST_IMPORT");
|
||||
g_vk.has_external_memory_host = has_ext(ep, ne, VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME) &&
|
||||
!(no_import && *no_import && strcmp(no_import, "0"));
|
||||
if (g_vk.has_external_memory_host) ext[n_ext++] = VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME;
|
||||
vk_mem_class_log(&g_vk.props, &g_vk.mem_props, g_vk.has_external_memory_host);
|
||||
|
||||
FeatureChain *c = calloc(1, sizeof *c);
|
||||
void **tail = &c->f2.pNext;
|
||||
@@ -340,7 +351,16 @@ static int create_device(void) {
|
||||
CHAIN(fbl, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT);
|
||||
CHAIN(lr, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_LOCAL_READ_FEATURES_KHR);
|
||||
}
|
||||
vk_dlaa_device_exts(ep, ne, ext, &n_ext, 40); // NGX's; the twelve slots after it stay for the nine below
|
||||
vk_dlaa_device_exts(ep, ne, ext, &n_ext, 40); // NGX's or FSR 4's; the twelve slots after it stay for the nine below
|
||||
// FSR 4's shader extensions (vk_ffx_device_exts) are enabled with their features, as far as the driver reports them
|
||||
for (uint32_t i = 0; i < n_ext; i++) {
|
||||
if (!strcmp(ext[i], VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME))
|
||||
CHAIN(coop, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR);
|
||||
#ifdef VK_EXT_SHADER_FLOAT8_EXTENSION_NAME
|
||||
else if (!strcmp(ext[i], VK_EXT_SHADER_FLOAT8_EXTENSION_NAME))
|
||||
CHAIN(f8, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT8_FEATURES_EXT);
|
||||
#endif
|
||||
}
|
||||
if (has_ext(ep, ne, VK_EXT_MEMORY_BUDGET_EXTENSION_NAME)) { g_vk.has_memory_budget = 1; ext[n_ext++] = VK_EXT_MEMORY_BUDGET_EXTENSION_NAME; }
|
||||
// GPU timestamps on the CPU clock (vk_sync.c): the perf line splits GPU idle time into waiting for a submission or not.
|
||||
if (has_ext(ep, ne, VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME)) { g_vk.has_calibrated = 2; ext[n_ext++] = VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME; }
|
||||
@@ -357,14 +377,24 @@ static int create_device(void) {
|
||||
g_vk.has_nv_checkpoints = 1;
|
||||
ext[n_ext++] = VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME;
|
||||
}
|
||||
// NVIDIA Reflex Low Latency (VK_NV_low_latency2 requires VK_KHR_present_id)
|
||||
// Low latency (the reflex setting). on and boost: NVIDIA Reflex (VK_NV_low_latency2, which requires
|
||||
// VK_KHR_present_id), as before Anti-Lag came in, so a GPU without Reflex still gets nothing new from them. auto:
|
||||
// Reflex, or AMD Anti-Lag 2 (VK_AMD_anti_lag: RADV and AMD's Windows driver) on a GPU without Reflex. Only one of
|
||||
// the two runs. off (the default) enables neither extension.
|
||||
const char *rv = cfg_value("TOTK_REFLEX");
|
||||
if (rv && strcmp(rv, "off") != 0 && strcmp(rv, "0") != 0) {
|
||||
if (strcmp(rv, "off") != 0 && strcmp(rv, "0") != 0) {
|
||||
int want_antilag = !strcmp(rv, "auto");
|
||||
if (has_ext(ep, ne, VK_KHR_PRESENT_ID_EXTENSION_NAME) && has_ext(ep, ne, "VK_NV_low_latency2")) {
|
||||
g_vk.has_nv_reflex = 1;
|
||||
ext[n_ext++] = VK_KHR_PRESENT_ID_EXTENSION_NAME;
|
||||
ext[n_ext++] = "VK_NV_low_latency2";
|
||||
CHAIN(pid, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR);
|
||||
} else if (want_antilag && has_ext(ep, ne, VK_AMD_ANTI_LAG_EXTENSION_NAME)) {
|
||||
g_vk.has_amd_antilag = 1;
|
||||
ext[n_ext++] = VK_AMD_ANTI_LAG_EXTENSION_NAME;
|
||||
CHAIN(al, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ANTI_LAG_FEATURES_AMD);
|
||||
} else if (want_antilag) {
|
||||
rt_log("Low latency: neither VK_NV_low_latency2 nor VK_AMD_anti_lag is available");
|
||||
} else {
|
||||
rt_log("Reflex: VK_NV_low_latency2 not available");
|
||||
}
|
||||
@@ -418,6 +448,11 @@ static int create_device(void) {
|
||||
g_vk.has_nv_reflex = 0;
|
||||
rt_log("Reflex: VK_NV_low_latency2 not available (no presentId feature)");
|
||||
}
|
||||
if (g_vk.has_amd_antilag && !c->al.antiLag) {
|
||||
g_vk.has_amd_antilag = 0;
|
||||
rt_log("Anti-Lag: VK_AMD_anti_lag not available (no antiLag feature)");
|
||||
}
|
||||
if (g_vk.has_amd_antilag) rt_log("Anti-Lag: AMD Anti-Lag 2 on (VK_AMD_anti_lag)");
|
||||
g_vk.has_astc_ldr = h->textureCompressionASTC_LDR;
|
||||
{
|
||||
const char *e = cfg_get("TOTK_FEEDBACK");
|
||||
@@ -450,7 +485,8 @@ static int create_device(void) {
|
||||
else { g_vk.xfer_queue = g_vk.gfx_queue; g_vk.xfer_shared = 1; }
|
||||
|
||||
VkPhysicalDeviceExternalMemoryHostPropertiesEXT emh = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT};
|
||||
VkPhysicalDeviceProperties2 p2 = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .pNext = &emh};
|
||||
VkPhysicalDeviceProperties2 p2 = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
|
||||
.pNext = g_vk.has_external_memory_host ? &emh : NULL};
|
||||
vkGetPhysicalDeviceProperties2(g_vk.phys, &p2);
|
||||
g_vk.min_imported_host_alignment = (uint32_t)emh.minImportedHostPointerAlignment;
|
||||
vk_caps_init(&g_vk);
|
||||
@@ -486,9 +522,11 @@ static void destroy_all(void) {
|
||||
if (g_vk.device) vkDeviceWaitIdle(g_vk.device);
|
||||
if (g_vk.device) vk_fg_release();
|
||||
if (g_vk.device) fsr3_release();
|
||||
if (g_vk.device) vk_ffx_release();
|
||||
if (g_vk.device) vk_astc_release();
|
||||
if (g_vk.device) vk_deswz_release();
|
||||
if (g_vk.device) vk_crumbs_release();
|
||||
if (g_vk.device) vk_exec_null_attach_release();
|
||||
if (g_vk.timeline) vkDestroySemaphore(g_vk.device, g_vk.timeline, NULL);
|
||||
vk_headroom_stop();
|
||||
if (g_vk.vma) vmaDestroyAllocator(g_vk.vma);
|
||||
|
||||
+114
-49
@@ -11,6 +11,10 @@
|
||||
// layout with a set-then-get round trip before anything relies on it.
|
||||
//
|
||||
// Where DLAA runs in the frame, the jitter and the motion vectors: see the sections below.
|
||||
//
|
||||
// The scene upscaler (scene_upscaler) is DLSS, AMD FSR 3.1 (vk_fsr3.cpp, built from the FidelityFX SDK 1.1.4 sources)
|
||||
// or AMD FSR 4 (vk_ffx.c, AMD's FSR SDK 2.4 libraries, Windows): the arming, the jitter, the motion vectors and the
|
||||
// copy of the result below are shared, and only the call that upscales differs (evaluate, fsr_evaluate).
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -25,6 +29,7 @@
|
||||
#include "input.h"
|
||||
#include "nvn_api.h"
|
||||
#include "vk_exec.h"
|
||||
#include "vk_ffx.h"
|
||||
#include "vk_fg.h"
|
||||
#include "vk_fsr3.h"
|
||||
#include "vk_rec.h"
|
||||
@@ -105,25 +110,43 @@ static int p_getp(const NgxParam *p, const char *n, void **v) { return NGX_OK(((
|
||||
#endif
|
||||
|
||||
// The scene upscaler picked at start (scene_upscaler; without it dlaa = 1 is DLSS): a restart applies another. AMD FSR
|
||||
// 3.1 (vk_fsr3.cpp) takes the same inputs at the same point of the frame as DLSS and runs on any GPU.
|
||||
// 3.1 (vk_fsr3.cpp) and FSR 4 (vk_ffx.c) take the same inputs at the same point of the frame as DLSS; FSR 3.1 runs on
|
||||
// any GPU, FSR 4 on Windows where AMD's libraries offer it for the GPU (vk_ffx_init). AMD ships those libraries for
|
||||
// Windows only, so elsewhere fsr4 is off.
|
||||
int vk_upscaler_engine(void) {
|
||||
static int e = -1;
|
||||
if (e < 0) {
|
||||
const char *v = cfg_scene_upscaler();
|
||||
e = !strcmp(v, "dlss") ? UPSCALER_DLSS : !strcmp(v, "fsr3") ? UPSCALER_FSR3 : UPSCALER_OFF;
|
||||
e = !strcmp(v, "dlss") ? UPSCALER_DLSS : !strcmp(v, "fsr3") ? UPSCALER_FSR3
|
||||
: !strcmp(v, "fsr4") ? UPSCALER_FSR4 : UPSCALER_OFF;
|
||||
#ifndef _WIN32
|
||||
if (e == UPSCALER_FSR4) {
|
||||
rt_log("dlaa: scene_upscaler = fsr4 runs on Windows only (AMD's FSR SDK has no Linux libraries): off");
|
||||
e = UPSCALER_OFF;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
// The setting's name of an engine, and the name the log gives it.
|
||||
static const char *engine_value(int e) {
|
||||
return e == UPSCALER_DLSS ? "dlss" : e == UPSCALER_FSR3 ? "fsr3" : e == UPSCALER_FSR4 ? "fsr4" : "off";
|
||||
}
|
||||
static const char *engine_name(int e) {
|
||||
return e == UPSCALER_DLSS ? "DLSS" : e == UPSCALER_FSR3 ? "FSR 3.1" : e == UPSCALER_FSR4 ? "FSR 4" : "none";
|
||||
}
|
||||
|
||||
// The engine picked at start while the settings still name it (the menu turns it off at once, as dlaa did).
|
||||
int vk_upscaler_on(void) {
|
||||
int e = vk_upscaler_engine();
|
||||
return e && !strcmp(cfg_scene_upscaler(), e == UPSCALER_DLSS ? "dlss" : "fsr3");
|
||||
return e && !strcmp(cfg_scene_upscaler(), engine_value(e));
|
||||
}
|
||||
|
||||
// NGX is brought up only when DLSS is the scene upscaler at start: its device extensions can only be asked for at
|
||||
// device creation, and loading the driver's NGX core on every NVIDIA machine would cost start time and change the device
|
||||
// with DLSS off. So the choice applies after a restart; with DLSS not picked (off or FSR 3.1), nothing of NGX runs.
|
||||
// with DLSS off. So the choice applies after a restart; with DLSS not picked (off or FSR), nothing of NGX runs. FSR
|
||||
// 4's device extensions are chosen at device creation as well (vk_ffx_device_exts).
|
||||
int vk_dlaa_wanted(void) {
|
||||
static int wanted = -1;
|
||||
if (wanted < 0) wanted = vk_upscaler_engine() == UPSCALER_DLSS;
|
||||
@@ -182,6 +205,7 @@ void vk_dlaa_device_exts(const VkExtensionProperties *have, uint32_t nhave, cons
|
||||
uint32_t max) {
|
||||
unsigned ni = 0, nd = 0;
|
||||
const char **ie = NULL, **de = NULL;
|
||||
vk_ffx_device_exts(have, nhave, ext, n, max); // FSR 4's, when it is the engine
|
||||
if (!vk_dlaa_wanted() || !core_load() || !NGX_OK(N.req_ext(&ni, &ie, &nd, &de))) return;
|
||||
for (unsigned i = 0; i < nd; i++) {
|
||||
int ok = 0;
|
||||
@@ -210,12 +234,18 @@ static int vtable_ok(void) {
|
||||
}
|
||||
|
||||
// The upscaler's half of the per-object motion's gate (vk_objmv_wanted, below the frame state): DLSS once NGX came up
|
||||
// with it (vk_dlaa_available), FSR 3.1 whenever it is the scene upscaler picked at start. Latched in vk_dlaa_init,
|
||||
// before the first frame: with no upscaler, or DLSS without NGX, it stays 0 as vk_dlaa_available does.
|
||||
// with it (vk_dlaa_available), FSR 3.1 whenever it is the scene upscaler picked at start, FSR 4 once AMD's libraries
|
||||
// offered it for the device (vk_ffx_available). Latched in vk_dlaa_init, before the first frame: with no upscaler, or
|
||||
// one that did not come up, it stays 0.
|
||||
static int objmv;
|
||||
|
||||
void vk_dlaa_init(void) {
|
||||
objmv = vk_upscaler_engine() == UPSCALER_FSR3;
|
||||
if (vk_upscaler_engine() == UPSCALER_FSR4) {
|
||||
vk_ffx_init();
|
||||
objmv = vk_ffx_available();
|
||||
return;
|
||||
}
|
||||
if (!vk_dlaa_wanted() || !core_load()) return;
|
||||
// The executable's folder, where NGX looks for the DLSS model library and writes its logs.
|
||||
wchar_t wdir[PLAT_PATH_MAX];
|
||||
@@ -338,26 +368,38 @@ static struct {
|
||||
VkExecTarget hud_t, win; // the output-sized target the scene is scaled into; the window texture
|
||||
float cam_dr[2]; // the viewport depth range of the draw cam_addr was noted at
|
||||
int fg_mv_ok; // the frame's motion is in the motion image (fg_motion)
|
||||
int fsr; // the engine is AMD FSR 3.1 (scene_upscaler = fsr3 at start), else DLSS
|
||||
int fsr; // the AMD FSR engine (UPSCALER_FSR3 or UPSCALER_FSR4, picked at start), 0: DLSS
|
||||
} D = {.mv_ok = -1, .cfg_seen = ~0u};
|
||||
#define DLSS_SIZES (sizeof D.sizes / sizeof D.sizes[0])
|
||||
|
||||
const VkTexImage *vk_dlaa_swap_img;
|
||||
VkImageView vk_dlaa_swap_view;
|
||||
|
||||
// DLSS needs NGX and its model, FSR 3.1 runs on any GPU the back end runs on: on already says the engine is there.
|
||||
// DLSS needs NGX and its model, FSR 4 AMD's libraries with FSR 4 for the GPU, FSR 3.1 runs on any GPU the back end
|
||||
// runs on: on already says the engine is there (vk_dlaa_frame).
|
||||
static int dl_active(void) { return !D.failed && D.on; }
|
||||
// The scene is followed (its G-buffer, light target, end and camera): for DLSS, or with DLSS off for frame generation.
|
||||
static int track(void) { return dl_active() || D.fg; }
|
||||
int vk_dlaa_fg_on; // D.fg for vk_exec_draw.c's per-draw test (vk_dlaa_hud)
|
||||
|
||||
int vk_upscaler_running(void) {
|
||||
return dl_active() && D.evals ? (D.fsr ? UPSCALER_FSR3 : UPSCALER_DLSS) : UPSCALER_OFF;
|
||||
return dl_active() && D.evals ? (D.fsr ? D.fsr : UPSCALER_DLSS) : UPSCALER_OFF;
|
||||
}
|
||||
|
||||
// For the menu. DLSS: after a start with it picked, what NGX said; before, an NVIDIA GPU and the DLL (an NVIDIA GPU
|
||||
// without RTX shows only once NGX came up). FSR 3.1 is built in.
|
||||
// without RTX shows only once NGX came up). FSR 4 likewise: Windows, AMD's two libraries, then after a start with it
|
||||
// picked what they offered for the device (vk_ffx_init), before one an AMD GPU (the libraries decide which Radeons get
|
||||
// FSR 4, so another Radeon shows only after that start). FSR 3.1 is built in.
|
||||
int vk_upscaler_missing(int engine) {
|
||||
if (engine == UPSCALER_FSR4) {
|
||||
#ifndef _WIN32
|
||||
return UPSCALER_MISSING_OS;
|
||||
#else
|
||||
if (!res_ffx_dlls()) return UPSCALER_MISSING_DLL;
|
||||
if (vk_ffx_tried()) return vk_ffx_available() ? 0 : UPSCALER_MISSING_GPU;
|
||||
return vk_ctx()->props.vendorID == 0x1002 ? 0 : UPSCALER_MISSING_GPU;
|
||||
#endif
|
||||
}
|
||||
if (engine != UPSCALER_DLSS) return 0;
|
||||
if (!res_dlss_dll()) return UPSCALER_MISSING_DLL;
|
||||
if (N.tried) return N.available ? 0 : UPSCALER_MISSING_GPU;
|
||||
@@ -377,7 +419,8 @@ static int fg_objects(void) {
|
||||
int vk_fg_objects_on(void) { return D.fg && fg_objects(); }
|
||||
|
||||
// The per-object motion's gates (vk_mvprev.c's tables, vk_usnap.c's host copy, vk_exec_draw.c's motion draws and
|
||||
// lock): the upscaler that reads the motion image (objmv: DLSS once NGX came up, or FSR 3.1 picked at start), or frame
|
||||
// lock): the upscaler that reads the motion image (objmv: DLSS once NGX came up, FSR 3.1 picked at start, or FSR 4
|
||||
// once it came up), or frame
|
||||
// generation following the scene with its objects. Frame generation is off with either upscaler, so the second term is
|
||||
// 0 whenever one runs.
|
||||
int vk_objmv_wanted(void) { return objmv || vk_fg_objects_on(); }
|
||||
@@ -1303,18 +1346,18 @@ static int scene_shaped(const VkExecTarget *c) {
|
||||
return a * 20 >= b * 19 && b * 20 >= a * 19;
|
||||
}
|
||||
|
||||
// FSR 3.1's half of evaluate (vk_fsr3.cpp), after the motion vectors and the recorder's drain: the camera, the time step
|
||||
// and the history reset, then the dispatch into e->out. 0 when it failed (DLAA is then off for the run). The camera
|
||||
// comes from the scene camera block's rows 0-10 (vk_fg.cpp vk_fg_camera, which frame generation reads too: FSR 3.1
|
||||
// wants the near and far planes and the vertical field of view for its depth tests); a cut there (a cutscene's camera
|
||||
// jump) starts a new history. The block's bytes are the snapshot's host copy, which vk_usnap.c keeps while the
|
||||
// per-object motion runs (vk_objmv_wanted, so with FSR 3.1).
|
||||
// FSR's half of evaluate (FSR 3.1: vk_fsr3.cpp, FSR 4: vk_ffx.c), after the motion vectors and the recorder's drain:
|
||||
// the camera, the time step and the history reset, then the dispatch into e->out. Both engines get the same inputs.
|
||||
// 0 when it failed (DLAA is then off for the run). The camera comes from the scene camera block's rows 0-10 (vk_fg.cpp
|
||||
// vk_fg_camera, which frame generation reads too: FSR wants the near and far planes and the vertical field of view
|
||||
// for its depth tests); a cut there (a cutscene's camera jump) starts a new history. The block's bytes are the
|
||||
// snapshot's host copy, which vk_usnap.c keeps while the per-object motion runs (vk_objmv_wanted, so with FSR).
|
||||
static int fsr_evaluate(VkExec *ex, struct Size *e, const VkExecTarget *t, const VkExecTarget *z, uint32_t ow,
|
||||
uint32_t oh, float jx, float jy, int timed) {
|
||||
static VkFgScene cam = {.near_m = 0.1f, .far_m = 25000.0f, .fov_y = 0.8727f}; // until the first camera read
|
||||
// the SDK takes whole images: the scene's targets are level 0, layer 0 of their own images
|
||||
if (t->level || t->base_layer || z->level || z->base_layer || z->format != VK_FORMAT_D32_SFLOAT)
|
||||
return dl_fail("FSR 3.1 input (not level 0, layer 0 of a colour and a D32F depth image)", 0), 0;
|
||||
return dl_fail("FSR input (not level 0, layer 0 of a colour and a D32F depth image)", 0), 0;
|
||||
const float *rows = D.cam_addr ? (const float *)vk_usnap_bytes(D.cam_addr, 11 * 16) : NULL;
|
||||
int cut = rows && vk_fg_camera(rows, nvn_depth_minus_w(), D.cam_dr, &cam);
|
||||
if (D.last_color != t->image) D.reset = 1, D.why[2]++, D.last_color = t->image;
|
||||
@@ -1326,19 +1369,31 @@ static int fsr_evaluate(VkExec *ex, struct Size *e, const VkExecTarget *t, const
|
||||
// without (vk_dlaa_skip_draw), so without it FSR's picture is softer than the game's own
|
||||
int sharp = cfg_int("TOTK_FSR_SHARPNESS");
|
||||
sharp = sharp < 0 ? 0 : sharp > 100 ? 100 : sharp;
|
||||
Fsr3Frame fr = {.color = t->image, .color_format = t->format, .depth = z->image, .mv = e->mv, .out = e->out,
|
||||
.w = t->width, .h = t->height, .ow = ow, .oh = oh, .jx = jx, .jy = jy, .near_m = cam.near_m,
|
||||
.far_m = cam.infinite || cam.far_m <= cam.near_m ? 1e5f : cam.far_m, .fov_y = cam.fov_y,
|
||||
.dt_ms = dt > 0 && dt < 100 ? (float)dt : 16.67f, .reset = D.reset, .sharpness = sharp / 100.0f,
|
||||
.fence = ex->fence};
|
||||
float far_m = cam.infinite || cam.far_m <= cam.near_m ? 1e5f : cam.far_m;
|
||||
float dt_ms = dt > 0 && dt < 100 ? (float)dt : 16.67f;
|
||||
uint64_t c0 = timed ? kern_now_ns() : 0;
|
||||
int ok = fsr3_dispatch(ex->cb, &fr);
|
||||
int ok;
|
||||
if (D.fsr == UPSCALER_FSR4) {
|
||||
VkFfxDispatch fd = {.color = {t->image, t->format, t->width, t->height},
|
||||
.depth = {z->image, z->format, t->width, t->height},
|
||||
.mv = {e->mv, VK_FORMAT_R16G16_SFLOAT, t->width, t->height},
|
||||
.out = {e->out, VK_FORMAT_R16G16B16A16_SFLOAT, ow, oh}, .jx = jx, .jy = jy,
|
||||
.dt_ms = dt_ms, .cam_near = cam.near_m, .cam_far = far_m, .fov_y = cam.fov_y,
|
||||
.sharpness = sharp / 100.0f, .reset = D.reset, .fence = ex->fence};
|
||||
ok = vk_ffx_dispatch(ex->cb, &fd);
|
||||
} else {
|
||||
Fsr3Frame fr = {.color = t->image, .color_format = t->format, .depth = z->image, .mv = e->mv, .out = e->out,
|
||||
.w = t->width, .h = t->height, .ow = ow, .oh = oh, .jx = jx, .jy = jy, .near_m = cam.near_m,
|
||||
.far_m = far_m, .fov_y = cam.fov_y, .dt_ms = dt_ms, .reset = D.reset,
|
||||
.sharpness = sharp / 100.0f, .fence = ex->fence};
|
||||
ok = fsr3_dispatch(ex->cb, &fr);
|
||||
}
|
||||
if (timed) T.cpu_ngx += kern_now_ns() - c0;
|
||||
if (!ok) {
|
||||
// the SDK may have bound a pipeline or descriptor sets of its own before it failed: the next draw binds
|
||||
// everything again, and the game's own scaling and FXAA run from the next frame (DLAA off for the run)
|
||||
vk_exec_draw_new_cb(ex);
|
||||
return dl_fail("FSR 3.1 dispatch", 0), 0;
|
||||
return dl_fail(D.fsr == UPSCALER_FSR4 ? "FSR 4 dispatch" : "FSR 3.1 dispatch", 0), 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -1487,7 +1542,7 @@ engine_done:
|
||||
rt_log("dlaa: %llu frames anti-aliased%s (scene %ux%u, output %ux%u; %llu before the effects, %llu frames without the "
|
||||
"DLAA point, %llu with camera motion, %llu with the characters' mask, %llu without a camera, %llu jitter "
|
||||
"holds; resets: %llu size, %llu camera, %llu target; reactive mask %llu, without its copy %llu)",
|
||||
(unsigned long long)D.evals, D.fsr ? " by FSR 3.1" : "", w, h, ow, oh, (unsigned long long)D.fx_frames, (unsigned long long)D.frames_missed,
|
||||
(unsigned long long)D.evals, D.fsr == UPSCALER_FSR4 ? " by FSR 4" : D.fsr ? " by FSR 3.1" : "", w, h, ow, oh, (unsigned long long)D.fx_frames, (unsigned long long)D.frames_missed,
|
||||
(unsigned long long)D.mv_frames, (unsigned long long)D.masked, (unsigned long long)D.mv_none,
|
||||
(unsigned long long)D.holds, (unsigned long long)D.why[0], (unsigned long long)D.why[1],
|
||||
(unsigned long long)D.why[2], (unsigned long long)R.made, (unsigned long long)R.missed);
|
||||
@@ -1832,9 +1887,9 @@ void vk_dlaa_pass(VkExec *ex) {
|
||||
}
|
||||
|
||||
// TOTK_DLSS, read at each present (the menu switches it live): the scene size of the mode (resolution.c) and the
|
||||
// texture bias that goes with it while the upscaler runs. DLSS takes NVIDIA's log2(scene / output); FSR 3.1 takes AMD's
|
||||
// log2(scene / output) - 1 (FidelityFX FSR 3 upscaler docs, "Mipmap biasing"), so -1 also in place. The bias follows
|
||||
// the mode and the upscaler going on or off; the engine is fixed for the run.
|
||||
// texture bias that goes with it while the upscaler runs. DLSS takes NVIDIA's log2(scene / output); FSR 3.1 and FSR 4
|
||||
// take AMD's log2(scene / output) - 1 (FidelityFX FSR 3 upscaler docs, "Mipmap biasing"), so -1 also in place. The
|
||||
// bias follows the mode and the upscaler going on or off; the engine is fixed for the run.
|
||||
static void dlss_mode(void) {
|
||||
static char mode[32];
|
||||
static float bias; // what the material samplers have (vk_texture.c starts at 0)
|
||||
@@ -1844,7 +1899,8 @@ static void dlss_mode(void) {
|
||||
res_dlss_mode(m);
|
||||
}
|
||||
float b = 0.0f;
|
||||
if (dl_active()) b = res_dlss_lod_bias() - (vk_upscaler_engine() == UPSCALER_FSR3 ? 1.0f : 0.0f);
|
||||
int e = vk_upscaler_engine();
|
||||
if (dl_active()) b = res_dlss_lod_bias() - (e == UPSCALER_FSR3 || e == UPSCALER_FSR4 ? 1.0f : 0.0f);
|
||||
if (b != bias) bias = b, vk_sampler_dlss_bias(b);
|
||||
}
|
||||
|
||||
@@ -1870,17 +1926,24 @@ void vk_dlaa_frame(void) {
|
||||
vk_dlaa_swap_img = NULL, vk_dlaa_swap_view = VK_NULL_HANDLE;
|
||||
dlss_mode();
|
||||
preset_check();
|
||||
int fsr = vk_upscaler_engine() == UPSCALER_FSR3; // fixed for the run: D.fsr never changes while on
|
||||
int on = (fsr || N.available) && vk_upscaler_on();
|
||||
// the engine is fixed for the run: D.fsr never changes while on. FSR 4 runs once AMD's libraries offered it for
|
||||
// the device (vk_ffx_init said why not otherwise, and the upscaler stays off)
|
||||
int e = vk_upscaler_engine();
|
||||
int fsr = e == UPSCALER_FSR3 || e == UPSCALER_FSR4 ? e : 0;
|
||||
int ready = e == UPSCALER_FSR3 || (e == UPSCALER_FSR4 ? vk_ffx_available() : N.available);
|
||||
int on = ready && vk_upscaler_on();
|
||||
vk_fg_frame();
|
||||
// frame generation with an upscaler is not built yet: with FSR 3.1 picked it stays off (said once)
|
||||
// frame generation with an upscaler is not built yet: with FSR picked it stays off (said once)
|
||||
static int fg_said;
|
||||
if (fsr && on && vk_fg_engine() != VK_FG_OFF && !fg_said++)
|
||||
rt_log("fg: frame generation off while FSR 3.1 upscales the scene (scene_upscaler = fsr3)");
|
||||
rt_log("fg: frame generation off while %s upscales the scene (scene_upscaler = %s)", engine_name(fsr),
|
||||
engine_value(fsr));
|
||||
int fg = fsr && on ? 0 : vk_fg_wanted(on && !D.failed);
|
||||
D.bloom = D.hud = D.hud_wait = D.fin = D.gen = D.fg_mv_ok = 0;
|
||||
if (on != D.on || fg != D.fg) {
|
||||
if (on != D.on) rt_log("dlaa: %s", on ? (fsr ? "on with FSR 3.1" : "on") : "off");
|
||||
if (on != D.on)
|
||||
rt_log("dlaa: %s%s%s", on ? "on" : "off", on && fsr ? " with " : "",
|
||||
on && fsr == UPSCALER_FSR4 ? vk_ffx_version() : on && fsr ? "FSR 3.1" : "");
|
||||
if (fg != D.fg) rt_log("dlaa: the scene is %s for frame generation", fg ? "followed" : "no longer followed");
|
||||
D.on = on, D.fg = vk_dlaa_fg_on = fg, D.fsr = fsr;
|
||||
// either way the next DLAA frame starts a new history from an unjittered frame
|
||||
@@ -1922,10 +1985,12 @@ void vk_dlaa_frame(void) {
|
||||
// stretched over the whole screen.
|
||||
static const uint64_t FXAA_FS[] = {0xf450003ebeb3dc52ull, 0x0a12f4bc2a9a4fbeull, 0x5c43ae18948d52cbull,
|
||||
0xaad42238801d31d8ull, 0xde20aef90fea4ce6ull, 0x755964e8dce7f34dull};
|
||||
// The fragment shader of the FXAA's first pass, the copy of the scene target into the scratch target (this build's
|
||||
// translator, seen in 1.4.3 frame logs; another hash leaves the draw alone). See vk_dlaa_skip_draw for why FSR 3.1's
|
||||
// frames skip it where it copies the scene target onto itself.
|
||||
static const uint64_t FXAA_COPY_FS[] = {0xa0fd34391f2af811ull};
|
||||
// The fragment shader of the FXAA's first pass, the copy of the scene target into the scratch target (another hash
|
||||
// leaves the draw alone): this build's translator, seen in 1.4.3 frame logs, and the one with patch 0017, whose two
|
||||
// support buffer fields change every fragment shader's hash (as with FXAA_FS above), read by codexx-dev from a 1.4.3
|
||||
// run with FSR on (pull request #1245). See vk_dlaa_skip_draw for why FSR's frames skip it where it copies the scene
|
||||
// target onto itself.
|
||||
static const uint64_t FXAA_COPY_FS[] = {0xa0fd34391f2af811ull, 0x9d065204aac9766bull};
|
||||
|
||||
// Chunks of one submission look shaders up side by side: an entry's hash is stored before its shader, and entries are
|
||||
// added under the lock.
|
||||
@@ -1970,14 +2035,14 @@ int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) {
|
||||
"FXAA_FS): the FXAA stays on", (unsigned long long)fx_off_frames);
|
||||
}
|
||||
}
|
||||
// FSR 3.1 in place (the scene as large as the output, so no scaling draw follows) goes without the game's FXAA
|
||||
// and its copy of the scene target onto itself on every frame, as codexx-dev found for FSR (pull request #1245,
|
||||
// vk_dlaa.c vk_dlaa_skip_draw there). Measured there on 1.4.3 at a 2560x1440 scene and output: with the upscaler on
|
||||
// the game ran its FXAA, which also sharpens, on 17 frames in every 96 and on the others drew its copy shader from
|
||||
// the scene target onto itself, so the picture went soft and sharp in turns. Here the dynamic resolution stays at
|
||||
// 100 % while FSR 3.1 runs (resolution.c res_dynres_live) and FSR sharpens its own output (fsr_sharpness,
|
||||
// fsr_evaluate) in place of the FXAA's sharpening. Scaled frames (D.up) need nothing more: there FSR's picture
|
||||
// already replaces the scaling FXAA draw below.
|
||||
// FSR 3.1 or FSR 4 in place (the scene as large as the output, so no scaling draw follows) goes without the game's
|
||||
// FXAA and its copy of the scene target onto itself on every frame, as codexx-dev found for FSR (pull request
|
||||
// #1245, vk_dlaa.c vk_dlaa_skip_draw there). Measured there on 1.4.3 at a 2560x1440 scene and output: with the
|
||||
// upscaler on the game ran its FXAA, which also sharpens, on 17 frames in every 96 and on the others drew its copy
|
||||
// shader from the scene target onto itself, so the picture went soft and sharp in turns. Here the dynamic
|
||||
// resolution stays at 100 % while FSR runs (resolution.c res_dynres_live) and FSR sharpens its own output
|
||||
// (fsr_sharpness, fsr_evaluate) in place of the FXAA's sharpening. Scaled frames (D.up) need nothing more: there
|
||||
// FSR's picture already replaces the scaling FXAA draw below.
|
||||
int fsr_in_place = D.done && !D.up && D.fsr;
|
||||
if (fxaa && !D.up && !fsr_in_place) return 0; // nothing to skip: no shader lookup per draw at the defaults
|
||||
if (!fs) return 0;
|
||||
@@ -2003,7 +2068,7 @@ int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) {
|
||||
static int logged_fxaa, logged_copy;
|
||||
if (known && ex->depth.image) {
|
||||
if (!logged_fxaa)
|
||||
logged_fxaa = 1, rt_log("dlaa: FSR 3.1 skips the game's FXAA (fragment shader %016llx) and sharpens its "
|
||||
logged_fxaa = 1, rt_log("dlaa: FSR skips the game's FXAA (fragment shader %016llx) and sharpens its "
|
||||
"own picture (fsr_sharpness)", (unsigned long long)h);
|
||||
return 1;
|
||||
}
|
||||
@@ -2011,7 +2076,7 @@ int vk_dlaa_skip_draw(VkExec *ex, const GfxShader *fs) {
|
||||
for (size_t i = 0; i < sizeof FXAA_COPY_FS / sizeof FXAA_COPY_FS[0]; i++) copy |= h == FXAA_COPY_FS[i];
|
||||
if (copy && ex->color[0].image == D.color.image && vk_exec_draw_samples(ex, fs, D.color.img)) {
|
||||
if (!logged_copy)
|
||||
logged_copy = 1, rt_log("dlaa: FSR 3.1 skips the game's copy of the scene target onto itself (fragment "
|
||||
logged_copy = 1, rt_log("dlaa: FSR skips the game's copy of the scene target onto itself (fragment "
|
||||
"shader %016llx)", (unsigned long long)h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,5 +1,5 @@
|
||||
// DLAA (vk_dlaa.c): the scene upscaler, NVIDIA DLSS or AMD FSR 3.1 (vk_fsr3.cpp), behind scene_upscaler (dlaa = 1 without
|
||||
// it: DLSS).
|
||||
// DLAA (vk_dlaa.c): the scene upscaler, NVIDIA DLSS, AMD FSR 3.1 (vk_fsr3.cpp) or AMD FSR 4 (vk_ffx.c, Windows), behind
|
||||
// scene_upscaler (dlaa = 1 without it: DLSS).
|
||||
#pragma once
|
||||
#include "vk.h"
|
||||
|
||||
@@ -15,9 +15,10 @@ void vk_dlaa_device_exts(const VkExtensionProperties *have, uint32_t nhave, cons
|
||||
void vk_dlaa_init(void);
|
||||
// 1 when dlaa is on and NGX came up with DLSS (after vk_dlaa_init): a DLSS mode's smaller scene is scaled up by DLSS.
|
||||
int vk_dlaa_available(void);
|
||||
// 1 when the per-object motion runs (DLSS's and FSR 3.1's half after vk_dlaa_init, frame generation's live): DLSS
|
||||
// with NGX up (vk_dlaa_available), FSR 3.1 picked as the scene upscaler, or frame generation following the scene with
|
||||
// its objects (vk_fg_objects_on: TOTK_FG_OBJECTS, default 1).
|
||||
// 1 when the per-object motion runs (the upscaler's half after vk_dlaa_init, frame generation's live): DLSS with NGX
|
||||
// up (vk_dlaa_available), FSR 3.1 picked as the scene upscaler, FSR 4 picked and offered for the device
|
||||
// (vk_ffx_available), or frame generation following the scene with its objects (vk_fg_objects_on: TOTK_FG_OBJECTS,
|
||||
// default 1).
|
||||
int vk_objmv_wanted(void);
|
||||
int vk_fg_objects_on(void);
|
||||
// vk_exec.c vk_exec_pass_begin, once the pass's targets are resolved and before its barrier: arms the frame on the
|
||||
|
||||
+94
-1
@@ -674,6 +674,85 @@ static void barrier_to(VkExec *ex, const VkImage *want, const VkImageAspectFlags
|
||||
|
||||
void vk_exec_barrier(VkExec *ex) { barrier_to(ex, NULL, NULL, 0); }
|
||||
|
||||
// TOTK_NULL_ATTACH=1 (null_attach, default 0; vk_caps.null_attach): colour slots of a pass that hold no target get a
|
||||
// view of a dummy image instead of VK_NULL_HANDLE. Leaving a slot's imageView null is valid Vulkan, but Intel's legacy
|
||||
// Windows driver for 6th-10th generation graphics (HD 520, UHD 620; driver 101.21xx, Vulkan 1.3.215) faulted inside
|
||||
// vkCmdBeginRendering reading an attachment entry of the pass, at the first scene passes after the logo (issue #1343);
|
||||
// whether the empty slots are the cause is untested on that driver. The pipelines then name NULL_ATTACH_FMT for those
|
||||
// slots, with their writes masked off (vk_pipeline.c gkey_fill, target_wmask), so the views match the pipelines'
|
||||
// formats. Only slots below the last one with a target get a dummy: the pipelines' colorAttachmentCount ends there
|
||||
// (vk_pipeline.c target_count), and a pass without colour targets keeps none. All empty slots of a pass share one
|
||||
// view; an image serves every pass it covers (size, layers) with its sample count, so TotK makes one or two per scene
|
||||
// resolution. Each is moved to GENERAL in the upload batch and kept until the device goes (vk_exec_null_attach_release);
|
||||
// loads and stores are DONT_CARE, so the slots cost no bandwidth.
|
||||
#define NULL_ATTACH_MAX 24
|
||||
typedef struct { uint32_t w, h, layers, samples; VkImage img; VmaAllocation alloc; VkImageView view; } NullAttach;
|
||||
static NullAttach null_att[NULL_ATTACH_MAX];
|
||||
static int nnull_att;
|
||||
static PlatMutex null_att_lock = PLAT_MUTEX_INIT;
|
||||
|
||||
void vk_exec_null_attach_release(void) {
|
||||
VkCtx *c = vk_ctx();
|
||||
plat_mutex_lock(&null_att_lock);
|
||||
for (int i = 0; c && i < nnull_att; i++) {
|
||||
vkDestroyImageView(c->device, null_att[i].view, NULL);
|
||||
vmaDestroyImage(c->vma, null_att[i].img, null_att[i].alloc);
|
||||
}
|
||||
nnull_att = 0;
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
}
|
||||
|
||||
static VkImageView null_attach_view(uint32_t w, uint32_t h, uint32_t layers, uint32_t samples) {
|
||||
plat_mutex_lock(&null_att_lock);
|
||||
for (int i = 0; i < nnull_att; i++) { // a view may be larger than the render area (VkRenderingInfo needs it to cover it)
|
||||
const NullAttach *a = &null_att[i];
|
||||
if (a->w >= w && a->h >= h && a->layers >= layers && a->samples == samples) {
|
||||
VkImageView v = a->view;
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
static int warned;
|
||||
if (nnull_att == NULL_ATTACH_MAX) {
|
||||
if (!warned++) rt_log("vk_exec: more than %d dummy attachment shapes: further empty slots stay empty", NULL_ATTACH_MAX);
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
VkCtx *c = vk_ctx();
|
||||
NullAttach a = {w, h, layers, samples, VK_NULL_HANDLE, NULL, VK_NULL_HANDLE};
|
||||
VkImageCreateInfo ci = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = VK_EXEC_NULL_ATTACH_FMT, .extent = {w, h, 1}, .mipLevels = 1, .arrayLayers = layers,
|
||||
.samples = (VkSampleCountFlagBits)samples, .tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
||||
VmaAllocationCreateInfo ai = {.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE};
|
||||
VmaAllocationInfo info = {0};
|
||||
if (vmaCreateImage(c->vma, &ci, &ai, &a.img, &a.alloc, &info) != VK_SUCCESS) {
|
||||
if (!warned++) rt_log("vk_exec: a %ux%u x %u dummy attachment could not be created: the slot stays empty", w, h, layers);
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
VkImageViewCreateInfo vi = {.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = a.img,
|
||||
.viewType = layers > 1 ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D,
|
||||
.format = VK_EXEC_NULL_ATTACH_FMT,
|
||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, layers}};
|
||||
if (vkCreateImageView(c->device, &vi, NULL, &a.view) != VK_SUCCESS) {
|
||||
vmaDestroyImage(c->vma, a.img, a.alloc);
|
||||
if (!warned++) rt_log("vk_exec: a dummy attachment view could not be created: the slot stays empty");
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
// In the upload batch, which goes to the queue before the part that records this pass (as the BC stand-ins)
|
||||
VkCommandBuffer cb = vk_upload_begin();
|
||||
image_barrier(cb, a.img, VK_IMAGE_LAYOUT_UNDEFINED, layers);
|
||||
vk_upload_end();
|
||||
null_att[nnull_att++] = a;
|
||||
int n = nnull_att;
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
rt_log("vk_exec: dummy attachment %ux%u x %u, %u samples, for empty colour slots: %.2f MiB (%d of %d)", w, h, layers,
|
||||
samples, info.size / 1048576.0, n, NULL_ATTACH_MAX);
|
||||
return a.view;
|
||||
}
|
||||
|
||||
void vk_exec_pass_begin(VkExec *ex) {
|
||||
if (ex->in_pass) return;
|
||||
resolve_rt(ex);
|
||||
@@ -696,10 +775,24 @@ void vk_exec_pass_begin(VkExec *ex) {
|
||||
ex->fb_dirty = 0;
|
||||
ex->pass_serial++;
|
||||
VkRenderingAttachmentInfo ca[8], da = {0}, sa = {0};
|
||||
uint32_t dummies = 0; // null_attach: empty slots below this get a dummy (the pipelines' colorAttachmentCount)
|
||||
VkImageView dummy = VK_NULL_HANDLE;
|
||||
if (vk_caps.null_attach)
|
||||
for (uint32_t i = 0; i < ex->pass_ncolor; i++)
|
||||
if (ex->color[i].image) dummies = i + 1;
|
||||
for (uint32_t i = 0; i < ex->pass_ncolor; i++) {
|
||||
const VkExecTarget *t = &ex->color[i];
|
||||
ca[i] = (VkRenderingAttachmentInfo){.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO};
|
||||
if (!t->image) continue;
|
||||
if (!t->image) {
|
||||
if (i < dummies) { // a dummy for the empty slot, which the pipelines name too (null_attach_view)
|
||||
if (!dummy) dummy = null_attach_view(ex->pass_w, ex->pass_h, ex->pass_layers, ex->pass_samples);
|
||||
ca[i].imageView = dummy;
|
||||
ca[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
ca[i].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
ca[i].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ca[i].imageView = view_of(ex, t);
|
||||
ca[i].imageLayout = fbl >> i & 1 ? VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT : VK_IMAGE_LAYOUT_GENERAL;
|
||||
ca[i].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
|
||||
@@ -3328,6 +3328,22 @@ static void bi_done(VkExec *ex, const VkPipeInfo *info, const VkPipeState *s, co
|
||||
D->B.bi_valid = 1;
|
||||
}
|
||||
|
||||
// Mesa ANV (Intel iGPU, Linux): a draw whose vertex shader reads a storage buffer reads stale data inside a pass unless
|
||||
// the sampler cache is invalidated first: the half-resolution particle pass drew campfire smoke and clouds as white or
|
||||
// dark blobs and turned the sky white for single frames (#927). A by-region barrier before such a draw removes it
|
||||
// (0 of 1460 frames broken against 57 of 779, about 2 fps of 40 on an Iris Xe); a stall alone or the attachment flush
|
||||
// alone does not. The barrier costs about 5% of the frame rate on an Iris Xe and was only tested there, so it is off
|
||||
// on every GPU by default; TOTK_ANV_VS_BARRIER=1 (ini: anv_vs_barrier = 1) turns it on, 0 keeps it off.
|
||||
static int anv_vs_barrier(void) {
|
||||
static int on = -1;
|
||||
if (on < 0) {
|
||||
const char *e = cfg_get("TOTK_ANV_VS_BARRIER");
|
||||
on = e && *e && strcmp(e, "0") != 0;
|
||||
rt_log("vk_exec: barrier before vertex-stage storage reads in a pass %s", on ? "on" : "off");
|
||||
}
|
||||
return on;
|
||||
}
|
||||
|
||||
// Pass, shaders, pipeline, fixed state and resources for a draw. 0: the draw is skipped.
|
||||
static int prepare_draw(VkExec *ex, int prim, int32_t count, int restart) {
|
||||
VkExecDraw *D = ex->draw;
|
||||
@@ -3540,6 +3556,8 @@ static int prepare_draw(VkExec *ex, int prim, int32_t count, int restart) {
|
||||
if (bim == 2) bi_census(ex, info, sp, bgt, bgb, bsg, sm_hit); // on counts nothing: it is what gets timed
|
||||
bind_resources(ex, info, bim ? bgt : NULL, bgb);
|
||||
if (fbl & ex->fb_dirty) feedback_barrier(ex);
|
||||
else if (ex->in_pass && anv_vs_barrier() && gfx_shader_resources(vs, GFX_RES_SSBO, &(const GfxShaderRes *){0}))
|
||||
{ uint32_t keep = ex->fb_dirty; feedback_barrier(ex); ex->fb_dirty = keep; } // keep fb_dirty: feedback_prepare learns from it
|
||||
feedback_written(ex, sp);
|
||||
bind_vertex_buffers(ex);
|
||||
if (vk_dump_armed) vk_dump_draw(ex, sp, p, info);
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
// AMD FSR 4 for the scene upscaler (vk_ffx.h). The FSR SDK 2.4 ships its Vulkan effects as signed DLLs behind a
|
||||
// loader: amd_fidelityfx_loader_vk.dll exports the ffx-api entry points and finds the effect DLL
|
||||
// (amd_fidelityfx_upscaler_vk.dll) next to itself. Both are loaded from the executable's folder at run time; no SDK
|
||||
// code is compiled in, only the descriptor layouts of ffx_api_min.h.
|
||||
//
|
||||
// The upscaler DLL offers several versions (FSR 4.x, FSR 3.1.x) and decides by itself which ones a device can run:
|
||||
// vk_ffx_init lists them and pins the newest 4.x. A device the DLL offers no FSR 4 for runs without the upscaler (the
|
||||
// log and the menu say so): FSR 3.1 is scene_upscaler = fsr3, built from the SDK 1.1.4 sources (vk_fsr3.cpp), not a
|
||||
// fallback of this DLL. Every context is created with the pinned version (ffxOverrideVersion).
|
||||
//
|
||||
// What FSR 4 gets is what FSR 3.1 gets (vk_dlaa.c fsr_evaluate): the R11G11B10F light target as linear HDR colour, the
|
||||
// D32F scene depth (standard direction, the far plane finite), motion vectors at the render size in render pixels
|
||||
// pointing from this frame's position to last frame's without the jitter (motionVectorScale 1), the jitter the scene
|
||||
// was drawn with, the camera's planes and field of view. That is FSR's own convention: its guide derives the
|
||||
// projection offset as (2 jx / w, -2 jy / h), which moves the picture by (jx, jy) window pixels with y down, the way
|
||||
// vk_dlaa_viewport moves the viewport. The exposure is FSR's own (AUTO_EXPOSURE), as codexx-dev's pull request #1245
|
||||
// ran it on an RX 9070 XT.
|
||||
#include "vk_ffx.h"
|
||||
|
||||
#include "cfg.h"
|
||||
#include "host.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
int vk_ffx_wanted(void) { return 0; }
|
||||
void vk_ffx_device_exts(const VkExtensionProperties *have, uint32_t nhave, const char **ext, uint32_t *n, uint32_t max) {
|
||||
(void)have, (void)nhave, (void)ext, (void)n, (void)max;
|
||||
}
|
||||
void vk_ffx_init(void) {}
|
||||
int vk_ffx_tried(void) { return 0; }
|
||||
int vk_ffx_available(void) { return 0; }
|
||||
int vk_ffx_dispatch(VkCommandBuffer cb, const VkFfxDispatch *d) { return (void)cb, (void)d, 0; }
|
||||
void vk_ffx_release(void) {}
|
||||
const char *vk_ffx_version(void) { return ""; }
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ffx_api_min.h"
|
||||
|
||||
#define FFX_LOADER L"amd_fidelityfx_loader_vk.dll"
|
||||
#define FFX_MAX_VERSIONS 16
|
||||
// The SDK's Vulkan backend writes a dispatch's descriptor sets and constants into rings this deep and frees the views
|
||||
// of the dispatch that many back without knowing the GPU (FFX_MAX_QUEUED_FRAMES in the SDK's ffx_types.h, as
|
||||
// vk_fsr3.cpp wait_ring reads it for SDK 1.1.4).
|
||||
#define FFX_QUEUED 4
|
||||
|
||||
static struct {
|
||||
HMODULE dll;
|
||||
PfnFfxCreateContext create;
|
||||
PfnFfxDestroyContext destroy;
|
||||
PfnFfxQuery query;
|
||||
PfnFfxDispatch dispatch;
|
||||
int tried, loaded, available, failed;
|
||||
VkDeviceContext dev;
|
||||
uint64_t version_id;
|
||||
char version[48];
|
||||
ffxContext ctx; // the live context, made for ow x oh
|
||||
uint32_t ow, oh;
|
||||
uint64_t ring[FFX_QUEUED], n, waits; // the fences of the last dispatches (wait_ring)
|
||||
} F;
|
||||
|
||||
int vk_ffx_wanted(void) { return vk_upscaler_engine() == UPSCALER_FSR4; }
|
||||
|
||||
static int loader_load(void) {
|
||||
if (F.tried) return F.loaded;
|
||||
F.tried = 1;
|
||||
wchar_t path[MAX_PATH + 64];
|
||||
DWORD len = GetModuleFileNameW(NULL, path, MAX_PATH);
|
||||
while (len && path[len - 1] != L'\\') len--;
|
||||
path[len] = 0;
|
||||
wcscat(path, FFX_LOADER);
|
||||
// LOAD_WITH_ALTERED_SEARCH_PATH: the loader's own imports and the effect DLL resolve from the executable's folder
|
||||
F.dll = LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
if (!F.dll) {
|
||||
rt_log("fsr4: cannot load amd_fidelityfx_loader_vk.dll next to totk.exe (error %lu): the scene upscaler is off",
|
||||
GetLastError());
|
||||
return 0;
|
||||
}
|
||||
F.create = (PfnFfxCreateContext)(void *)GetProcAddress(F.dll, "ffxCreateContext");
|
||||
F.destroy = (PfnFfxDestroyContext)(void *)GetProcAddress(F.dll, "ffxDestroyContext");
|
||||
F.query = (PfnFfxQuery)(void *)GetProcAddress(F.dll, "ffxQuery");
|
||||
F.dispatch = (PfnFfxDispatch)(void *)GetProcAddress(F.dll, "ffxDispatch");
|
||||
if (!F.create || !F.destroy || !F.query || !F.dispatch) {
|
||||
rt_log("fsr4: amd_fidelityfx_loader_vk.dll lacks the ffx-api entry points: the scene upscaler is off");
|
||||
return 0;
|
||||
}
|
||||
return F.loaded = 1;
|
||||
}
|
||||
|
||||
static int has(const VkExtensionProperties *have, uint32_t nhave, const char *name) {
|
||||
for (uint32_t i = 0; i < nhave; i++)
|
||||
if (!strcmp(have[i].extensionName, name)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void add(const VkExtensionProperties *have, uint32_t nhave, const char **ext, uint32_t *n, uint32_t max,
|
||||
const char *name) {
|
||||
for (uint32_t i = 0; i < *n; i++)
|
||||
if (!strcmp(ext[i], name)) return;
|
||||
if (has(have, nhave, name) && *n < max) ext[(*n)++] = name;
|
||||
}
|
||||
|
||||
// The extensions the FSR SDK's own sample enables for its effects (Cauldron2 device_vk.cpp): cooperative matrix and
|
||||
// 8-bit floats for FSR 4's network where the device has them. The rest it uses (16-bit floats and storage, integer
|
||||
// dot products, subgroup size control) is core Vulkan 1.3, which vk_device.c enables as far as the driver reports it.
|
||||
void vk_ffx_device_exts(const VkExtensionProperties *have, uint32_t nhave, const char **ext, uint32_t *n, uint32_t max) {
|
||||
if (!vk_ffx_wanted()) return;
|
||||
add(have, nhave, ext, n, max, VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME);
|
||||
#ifdef VK_EXT_SHADER_FLOAT8_EXTENSION_NAME
|
||||
add(have, nhave, ext, n, max, VK_EXT_SHADER_FLOAT8_EXTENSION_NAME);
|
||||
#endif
|
||||
}
|
||||
|
||||
void vk_ffx_init(void) {
|
||||
if (!vk_ffx_wanted() || !loader_load()) return;
|
||||
const VkCtx *c = vk_ctx();
|
||||
F.dev = (VkDeviceContext){c->device, c->phys, vkGetDeviceProcAddr};
|
||||
uint64_t count = FFX_MAX_VERSIONS, ids[FFX_MAX_VERSIONS] = {0};
|
||||
const char *names[FFX_MAX_VERSIONS] = {0};
|
||||
struct ffxQueryDescGetVersions q = {.header = {FFX_API_QUERY_DESC_TYPE_GET_VERSIONS, NULL},
|
||||
.createDescType = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE, .device = &F.dev,
|
||||
.outputCount = &count, .versionIds = ids, .versionNames = names};
|
||||
ffxReturnCode_t r = F.query(NULL, &q.header);
|
||||
if (r != FFX_API_RETURN_OK || !count) {
|
||||
rt_log("fsr4: no upscaler for this device (query %u, %llu versions; is amd_fidelityfx_upscaler_vk.dll next to "
|
||||
"totk.exe?): the scene upscaler is off", (unsigned)r, (unsigned long long)count);
|
||||
return;
|
||||
}
|
||||
if (count > FFX_MAX_VERSIONS) count = FFX_MAX_VERSIONS;
|
||||
char list[256] = "";
|
||||
// The newest 4.x the DLL offers for this device; the DLL leaves FSR 4 out for GPUs it does not run on
|
||||
int best = -1, best_minor = 0, best_patch = 0;
|
||||
for (uint64_t i = 0; i < count; i++) {
|
||||
const char *nm = names[i] ? names[i] : "?";
|
||||
size_t used = strlen(list);
|
||||
snprintf(list + used, sizeof list - used, "%s%s", i ? ", " : "", nm);
|
||||
int ma = 0, mi = 0, pa = 0;
|
||||
if (sscanf(nm, "%d.%d.%d", &ma, &mi, &pa) < 1 || ma != 4) continue;
|
||||
if (best < 0 || mi > best_minor || (mi == best_minor && pa > best_patch))
|
||||
best = (int)i, best_minor = mi, best_patch = pa;
|
||||
}
|
||||
if (best < 0) {
|
||||
rt_log("fsr4: the FSR libraries offer %s for this device, no FSR 4: the scene upscaler is off", list);
|
||||
return;
|
||||
}
|
||||
F.version_id = ids[best];
|
||||
snprintf(F.version, sizeof F.version, "FSR %s", names[best]);
|
||||
F.available = 1;
|
||||
rt_log("fsr4: upscaler versions for this device: %s; using %s", list, F.version);
|
||||
}
|
||||
|
||||
int vk_ffx_tried(void) { return F.tried; }
|
||||
|
||||
int vk_ffx_available(void) { return vk_ffx_wanted() && F.available; }
|
||||
|
||||
const char *vk_ffx_version(void) { return F.available ? F.version : ""; }
|
||||
|
||||
// Messages from the upscaler (errors and warnings), in UTF-16; into the log as UTF-8.
|
||||
static void on_message(uint32_t type, const wchar_t *msg) {
|
||||
char s[512];
|
||||
if (!msg || !WideCharToMultiByte(CP_UTF8, 0, msg, -1, s, (int)sizeof s, NULL, NULL)) return;
|
||||
rt_log("fsr4: %s: %s", type == FFX_API_MESSAGE_TYPE_ERROR ? "error" : "warning", s);
|
||||
}
|
||||
|
||||
// The context for an ow x oh output, any scene up to that size (DYNAMIC_RESOLUTION: the modes and the game's tiers
|
||||
// change the scene without a new context), as vk_fsr3.cpp create makes FSR 3.1's.
|
||||
static int create(uint32_t ow, uint32_t oh) {
|
||||
struct ffxOverrideVersion ov = {.header = {FFX_API_DESC_TYPE_OVERRIDE_VERSION, NULL}, .versionId = F.version_id};
|
||||
struct ffxCreateContextDescUpscaleVersion ver = {
|
||||
.header = {FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE_VERSION, &ov.header}, .version = FFX_UPSCALER_VERSION};
|
||||
struct ffxCreateBackendVKDesc be = {.header = {FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_VK, &ver.header},
|
||||
.deviceContext = F.dev};
|
||||
// Linear HDR scene light with the upscaler's own exposure; standard depth with a finite far plane, as FSR 3.1's
|
||||
uint32_t flags = FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE | FFX_UPSCALE_ENABLE_AUTO_EXPOSURE |
|
||||
FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION;
|
||||
if (rt_knob("FSR4_DEBUG", "0")) flags |= FFX_UPSCALE_ENABLE_DEBUG_CHECKING; // TOTK_FSR4_DEBUG=1: API checks
|
||||
struct ffxCreateContextDescUpscale cd = {.header = {FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE, &be.header},
|
||||
.flags = flags, .maxRenderSize = {ow, oh}, .maxUpscaleSize = {ow, oh},
|
||||
.fpMessage = on_message};
|
||||
ffxContext ctx = NULL;
|
||||
ffxReturnCode_t r = F.create(&ctx, &cd.header, NULL);
|
||||
if (r != FFX_API_RETURN_OK || !ctx) {
|
||||
rt_log("fsr4: context creation failed (%u) at %ux%u: FSR 4 off for this run", (unsigned)r, ow, oh);
|
||||
return 0;
|
||||
}
|
||||
struct ffxQueryGetProviderVersion pv = {.header = {FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION, NULL}};
|
||||
F.query(&ctx, &pv.header);
|
||||
rt_log("fsr4: context up to %ux%u -> %ux%u with %s (flags %#x)", ow, oh, ow, oh,
|
||||
pv.versionName ? pv.versionName : F.version, flags);
|
||||
F.ctx = ctx, F.ow = ow, F.oh = oh, F.n = 0;
|
||||
memset(F.ring, 0, sizeof F.ring);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void destroy(void) {
|
||||
if (F.ctx) F.destroy(&F.ctx, NULL);
|
||||
F.ctx = NULL;
|
||||
}
|
||||
|
||||
static uint32_t surface_format(VkFormat f) {
|
||||
switch (f) {
|
||||
case VK_FORMAT_B10G11R11_UFLOAT_PACK32: return FFX_API_SURFACE_FORMAT_R11G11B10_FLOAT;
|
||||
case VK_FORMAT_R16G16B16A16_SFLOAT: return FFX_API_SURFACE_FORMAT_R16G16B16A16_FLOAT;
|
||||
case VK_FORMAT_R16G16_SFLOAT: return FFX_API_SURFACE_FORMAT_R16G16_FLOAT;
|
||||
case VK_FORMAT_D32_SFLOAT: return FFX_API_SURFACE_FORMAT_R32_FLOAT;
|
||||
default: return FFX_API_SURFACE_FORMAT_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// Every image of the scene upscaler stays in VK_IMAGE_LAYOUT_GENERAL: GENERIC_READ and UNORDERED_ACCESS are the
|
||||
// states the Vulkan backend maps to that layout (ffx_vk.cpp getVKImageLayoutFromResourceState), and it puts each
|
||||
// resource back into the state it was given at the end of the dispatch.
|
||||
static struct FfxApiResource resource(const VkFfxImage *im, uint32_t usage, uint32_t state) {
|
||||
struct FfxApiResource r;
|
||||
memset(&r, 0, sizeof r);
|
||||
if (!im->image) return r;
|
||||
r.resource = (void *)im->image;
|
||||
r.description = (struct FfxApiResourceDescription){.type = FFX_API_RESOURCE_TYPE_TEXTURE2D,
|
||||
.format = surface_format(im->format), .width = im->width,
|
||||
.height = im->height, .depth = 1, .mipCount = 1, .usage = usage};
|
||||
r.state = state;
|
||||
return r;
|
||||
}
|
||||
|
||||
// With the game's two or three frames in flight the dispatch FFX_QUEUED - 1 back is long done; should it not be, its
|
||||
// submission is waited for here (counted), as vk_fsr3.cpp wait_ring does for FSR 3.1.
|
||||
static void wait_ring(uint64_t fence) {
|
||||
if (F.n >= FFX_QUEUED - 1) {
|
||||
uint64_t back = F.ring[(F.n + 1) % FFX_QUEUED];
|
||||
if (back && vk_sync_fence_done() < back) {
|
||||
if (!F.waits++) rt_log("fsr4: waiting for the submission of a dispatch %d back (more frames in flight than "
|
||||
"the SDK's rings hold)", FFX_QUEUED - 1);
|
||||
vk_sync_fence_wait(back, 2000000000ull);
|
||||
}
|
||||
}
|
||||
F.ring[F.n % FFX_QUEUED] = fence;
|
||||
}
|
||||
|
||||
int vk_ffx_dispatch(VkCommandBuffer cb, const VkFfxDispatch *d) {
|
||||
if (!F.available || F.failed) return 0;
|
||||
uint32_t ow = d->out.width, oh = d->out.height;
|
||||
if (!F.ctx || ow != F.ow || oh != F.oh) {
|
||||
if (F.ctx) {
|
||||
vkDeviceWaitIdle(vk_ctx()->device); // what the old context recorded is queued or submitted
|
||||
destroy();
|
||||
}
|
||||
if (!create(ow, oh)) return F.failed = 1, 0;
|
||||
}
|
||||
if (d->color.width > F.ow || d->color.height > F.oh) {
|
||||
rt_log("fsr4: a %ux%u scene is larger than the %ux%u output: FSR 4 off for this run", d->color.width,
|
||||
d->color.height, F.ow, F.oh);
|
||||
return F.failed = 1, 0;
|
||||
}
|
||||
wait_ring(d->fence);
|
||||
struct ffxDispatchDescUpscale u;
|
||||
memset(&u, 0, sizeof u);
|
||||
u.header.type = FFX_API_DISPATCH_DESC_TYPE_UPSCALE;
|
||||
u.commandList = (void *)cb;
|
||||
u.color = resource(&d->color, FFX_API_RESOURCE_USAGE_READ_ONLY, FFX_API_RESOURCE_STATE_GENERIC_READ);
|
||||
u.depth = resource(&d->depth, FFX_API_RESOURCE_USAGE_DEPTHTARGET, FFX_API_RESOURCE_STATE_GENERIC_READ);
|
||||
u.motionVectors = resource(&d->mv, FFX_API_RESOURCE_USAGE_READ_ONLY, FFX_API_RESOURCE_STATE_GENERIC_READ);
|
||||
u.output = resource(&d->out, FFX_API_RESOURCE_USAGE_UAV, FFX_API_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
// (no reactive or transparency mask: FSR 3.1 gets none either)
|
||||
u.jitterOffset = (struct FfxApiFloatCoords2D){d->jx, d->jy};
|
||||
u.motionVectorScale = (struct FfxApiFloatCoords2D){1.0f, 1.0f}; // render pixels already
|
||||
u.renderSize = (struct FfxApiDimensions2D){d->color.width, d->color.height};
|
||||
u.upscaleSize = (struct FfxApiDimensions2D){ow, oh};
|
||||
u.enableSharpening = d->sharpness > 0;
|
||||
u.sharpness = d->sharpness > 1.0f ? 1.0f : d->sharpness;
|
||||
u.frameTimeDelta = d->dt_ms;
|
||||
u.preExposure = 1.0f;
|
||||
u.reset = d->reset != 0;
|
||||
u.cameraNear = d->cam_near;
|
||||
u.cameraFar = d->cam_far;
|
||||
u.cameraFovAngleVertical = d->fov_y;
|
||||
u.viewSpaceToMetersFactor = 1.0f; // TotK's world units are metres
|
||||
ffxReturnCode_t r = F.dispatch(&F.ctx, &u.header);
|
||||
F.n++;
|
||||
if (r != FFX_API_RETURN_OK) {
|
||||
rt_log("fsr4: dispatch failed (%u) at %ux%u -> %ux%u: FSR 4 off for this run", (unsigned)r, d->color.width,
|
||||
d->color.height, ow, oh);
|
||||
return F.failed = 1, 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void vk_ffx_release(void) {
|
||||
const VkCtx *c = vk_ctx();
|
||||
if (!F.ctx || !c || !c->device) return;
|
||||
vkDeviceWaitIdle(c->device);
|
||||
if (F.waits) rt_log("fsr4: %llu dispatches waited for an earlier one's submission", (unsigned long long)F.waits);
|
||||
destroy();
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
// AMD FSR 4 (vk_ffx.c), the fourth engine of vk_dlaa.c's scene upscaler (scene_upscaler = fsr4): the frame DLSS and
|
||||
// FSR 3.1 get goes to FSR 4 through AMD's FSR SDK 2.4 signed libraries, amd_fidelityfx_loader_vk.dll and
|
||||
// amd_fidelityfx_upscaler_vk.dll next to the executable. Windows only; elsewhere every call does nothing.
|
||||
#pragma once
|
||||
#include "vk.h"
|
||||
|
||||
// FSR 4 is the scene upscaler picked at start (vk_dlaa.c vk_upscaler_engine); the device may still lack it.
|
||||
int vk_ffx_wanted(void);
|
||||
// vk_device.c, while it builds the device: the extensions FSR 4's shaders use (cooperative matrix, 8-bit floats) join
|
||||
// the list when the device has them; their feature structures are chained there.
|
||||
void vk_ffx_device_exts(const VkExtensionProperties *have, uint32_t nhave, const char **ext, uint32_t *n, uint32_t max);
|
||||
void vk_ffx_init(void); // vk_dlaa.c vk_dlaa_init, after the device exists: loads the loader and pins FSR 4
|
||||
int vk_ffx_tried(void); // vk_ffx_init ran (FSR 4 picked at start, on Windows)
|
||||
int vk_ffx_available(void); // vk_ffx_init found FSR 4 for this device
|
||||
|
||||
typedef struct { // one image FSR reads or writes, in VK_IMAGE_LAYOUT_GENERAL, level 0 and layer 0
|
||||
VkImage image;
|
||||
VkFormat format;
|
||||
uint32_t width, height;
|
||||
} VkFfxImage;
|
||||
|
||||
typedef struct {
|
||||
VkFfxImage color; // the scene's light (R11G11B10F or RGBA16F, linear), the render size
|
||||
VkFfxImage depth; // its D32F depth, standard direction (0 near), finite far plane
|
||||
VkFfxImage mv; // RG16F motion vectors as vk_fsr3.h Fsr3Frame.mv (render pixels, without the jitter)
|
||||
VkFfxImage out; // RGBA16F with storage, the output size
|
||||
float jx, jy; // this frame's jitter, render pixels (window x right, y down), as the scene was drawn
|
||||
float dt_ms; // time since the previous dispatch
|
||||
float cam_near, cam_far; // the camera's planes (m)
|
||||
float fov_y; // vertical field of view, radians
|
||||
float sharpness; // FSR's own sharpening pass (RCAS) on its output, 0..1; 0: none
|
||||
int reset; // a new history
|
||||
uint64_t fence; // the submission's timeline value (VkExec.fence)
|
||||
} VkFfxDispatch;
|
||||
|
||||
// Records FSR 4 into cb (every image in GENERAL, left so; no render pass open; recorder drained by the caller). The
|
||||
// context is made at the first call and again when the output size changes; the scene may be any size up to the
|
||||
// output. 0 when it failed (logged; FSR 4 stays off for the run). FSR binds pipelines and descriptors of its own.
|
||||
int vk_ffx_dispatch(VkCommandBuffer cb, const VkFfxDispatch *d);
|
||||
void vk_ffx_release(void); // vk_device.c destroy_all, before the device goes away; harmless when nothing was made
|
||||
const char *vk_ffx_version(void); // "FSR 4.1.2" once vk_ffx_init pinned it, "" before or without
|
||||
+11
-3
@@ -1871,7 +1871,7 @@ static PlatMutex mirror_stat_lock = PLAT_MUTEX_INIT;
|
||||
static volatile int64_t m_live_n, m_live_bytes, m_refused_n[MR_N], m_refused_bytes[MR_N];
|
||||
static volatile int64_t m_flush_calls, m_flush_bytes, v_pages, v_skipped, v_mismatch;
|
||||
|
||||
static void mirror_mode(int discrete) {
|
||||
static void mirror_mode(int discrete, int host_import) {
|
||||
const char *e = cfg_value("TOTK_MEMORY");
|
||||
int mode = discrete ? 1 : 0; // 0 import, 1 mirror, 2 verify
|
||||
const char *why = discrete ? "auto, discrete gpu" : "auto, uma";
|
||||
@@ -1906,6 +1906,14 @@ static void mirror_mode(int discrete) {
|
||||
#else
|
||||
shadow_on = !sh || !*sh || strcmp(sh, "0");
|
||||
#endif
|
||||
// Without VK_EXT_external_memory_host (Qualcomm Adreno's Windows driver, some mobile and older drivers, or
|
||||
// TOTK_VK_NO_HOST_IMPORT=1) guest memory cannot be imported: every CPU-visible pool gets shadow storage, the path
|
||||
// Wine already takes (import_pool -> shadow_pool), whatever TOTK_SHADOW says.
|
||||
if (!host_import) {
|
||||
if (!shadow_on) rt_log("mem: no host import (VK_EXT_external_memory_host): shadow storage%s",
|
||||
sh && *sh ? ", TOTK_SHADOW=0 overridden" : "");
|
||||
shadow_on = 1;
|
||||
}
|
||||
defer_on = shadow_on && cfg_bool("TOTK_SYNC_AHEAD") && strcmp(cfg_value("TOTK_SYNC_AHEAD"), "check") &&
|
||||
cfg_bool("TOTK_SHADOW_DEFER"); // check: the wait stays exact, nothing is deferred
|
||||
if (defer_on) rt_log("mem: TOTK_SHADOW_DEFER: shadow updates that wait for a reader are queued for the GPU instead");
|
||||
@@ -2935,7 +2943,7 @@ static void vram_log(uint64_t frame) {
|
||||
|
||||
// Device class: INTEGRATED -> uma; a discrete GPU with a DEVICE_LOCAL heap of 1 GiB or more beside a
|
||||
// heap that is not device-local (host memory) -> discrete; otherwise uma (import everywhere). Sets the mirror mode.
|
||||
void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDeviceMemoryProperties *m) {
|
||||
void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDeviceMemoryProperties *m, int host_import) {
|
||||
int big_local = -1, host_heap = -1;
|
||||
for (uint32_t h = 0; h < m->memoryHeapCount; h++) {
|
||||
if (m->memoryHeaps[h].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) {
|
||||
@@ -2977,7 +2985,7 @@ void vk_mem_class_log(const VkPhysicalDeviceProperties *p, const VkPhysicalDevic
|
||||
if (host_backed == HB_UMA)
|
||||
rt_log("mem: device memory against system memory: commit and physical memory (uma), reserve %llu MiB "
|
||||
"(TOTK_MEM_RESERVE_MIB)", (unsigned long long)(room_reserve >> 20));
|
||||
mirror_mode(discrete);
|
||||
mirror_mode(discrete, host_import);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- upload batches and deferred destruction
|
||||
|
||||
@@ -1345,6 +1345,7 @@ static uint32_t target_wmask(const VkPipeState *s, int i) {
|
||||
uint32_t m = s->chmask.mask >> (4 * i) & 0xf;
|
||||
if (s->fs && !(gfx_shader_outputs(s->fs, NULL) >> i & 1)) m = 0;
|
||||
if (i == 1 && s->fs && P.f_dual_src && uses_src1(s)) m = 0; // output 1 is the second blend source (spirv_dual_source)
|
||||
if (!s->color_fmt[i] && vk_caps.null_attach) m = 0; // an empty slot's dummy attachment (vk_exec.c) takes no writes
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -1380,6 +1381,9 @@ static void gkey_fill(const VkPipeState *s, GKey *k) {
|
||||
o[3] = (uint8_t)blend_factor(b->src_a), o[4] = (uint8_t)blend_factor(b->dst_a), o[5] = (uint8_t)blend_op(b->eq_a);
|
||||
}
|
||||
}
|
||||
if (vk_caps.null_attach) // empty slots get the dummy attachment's format (vk_exec.c null_attach_view)
|
||||
for (int i = 0; i < k->n_color; i++)
|
||||
if (k->color[i] == VK_FORMAT_UNDEFINED) k->color[i] = VK_EXEC_NULL_ATTACH_FMT;
|
||||
if (!P.dyn_vi) {
|
||||
VtxInput v;
|
||||
vertex_input(s, &v);
|
||||
|
||||
Reference in new issue
Block a user