mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 09:39:58 -04:00
Merge remote-tracking branch 'nx2navi/main' into ra-all-test
This commit is contained in:
31
docs/releases/v0.9.2.md
Normal file
31
docs/releases/v0.9.2.md
Normal file
@@ -0,0 +1,31 @@
|
||||
## Fixed
|
||||
|
||||
- **FSR and DLSS showed a blocky, shaking picture with the HUD hidden.** The upscaler's picture was put where the
|
||||
game draws its HUD. With the HUD off the game skips that step, and the frame's last step then drew the game's own
|
||||
plainly scaled scene over it: the screen showed the scene at its render size (a third of the picture at Ultra
|
||||
Performance) in visible blocks, shaking by up to one render pixel from frame to frame, with a white line along the
|
||||
bottom or right edge in about half the frames, while the upscaler's work was thrown away. Native AA was affected
|
||||
as well as the scaling modes. The upscaler now runs where the game's own upscaler does, HUD or not. On a save with
|
||||
the HUD off at FSR 4 Ultra Performance: fine detail is back, the picture moves 0.02 pixels between screenshots of a
|
||||
still view instead of jumping by 3, and no screenshot has the white line (half had it).
|
||||
- **A crash after switching FSR modes.** One FSR context served every mode, with another render size at each switch,
|
||||
and the first frame after a switch from Quality to Native AA could end the game inside AMD's driver. Each render size
|
||||
now gets a context of its own, as AMD's own sample makes them, and the one before goes a few frames later (a mode
|
||||
switch takes about 50 ms more); with dynamic resolution on, one context made for changing sizes takes every step.
|
||||
- **Bright patches along the bottom edge over water, and a light line at the edge, with FSR or DLSS.** To let the
|
||||
upscaler build a smoother picture the scene is drawn moved by a fraction of a pixel, and AMD's driver then leaves
|
||||
the last row or column undrawn. Those are now filled from their neighbours as soon as each step of the scene is
|
||||
drawn, before the water, the bloom or the upscaler read them.
|
||||
- **A new start for the upscaler at every frame of a quick camera swing.** A fast swing of the camera around Link (11
|
||||
to 18 degrees a frame) was taken for a cut to a new view. Only a jump of the camera or a turn of 30 degrees or more
|
||||
in one frame counts as a cut now.
|
||||
|
||||
## Known issues
|
||||
|
||||
- At FSR's and DLSS's smaller modes, Link and other characters look a little coarser while they move: the upscaler
|
||||
gets only the camera's motion for them, not their own.
|
||||
- Ultra Performance gains little frame rate over Quality with FSR 4. Most of a frame is the replay of the game's draws
|
||||
on the CPU, which does not shrink with the render size, and FSR 4 itself takes 3.1 ms of the GPU's time at Ultra
|
||||
Performance and 3.9 ms at Native AA on a Radeon RX 7900 XT (FSR 3.1: 0.5 ms). Measured standing in Hyrule Field at
|
||||
3416x1440: FSR 4 Native AA 52 fps, Quality 53, Ultra Performance 55; FSR 3.1 Native AA 55, Ultra Performance 66;
|
||||
without an upscaler 70.
|
||||
@@ -44,7 +44,7 @@ static const char *const known[] = {
|
||||
"BIND_SKIP", "BIND_STATS", "BIND_UP", "BIND_X", "BIND_Y",
|
||||
"BIND_ZL", "BIND_ZR", "BLOCK_VIEWS_3D", "CACHE_DIE", "CLOTH_REALTIME", "COLOR_BRIGHTNESS", "COMPUTE_KEEP", "COLOR_CONTRAST", "COLOR_GAMMA",
|
||||
"COLOR_PRESET", "COLOR_SATURATION", "CONTACT_DEBUG", "CONTACT_SHADOWS", "CORE_DIAG", "CRIT", "CRIT_OUT",
|
||||
"DESC_TEMPLATE", "DEVICE_PROFILE", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_CAM_KEEP", "DLAA_CUT", "DLSS_IDLE_FREE", "DLAA_EDGE_FILL", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TARGET_KEEP", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
|
||||
"DESC_TEMPLATE", "DEVICE_PROFILE", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_CAM_KEEP", "DLAA_CUT", "DLSS_IDLE_FREE", "DLAA_EDGE_FILL", "DLAA_AT_UPSCALER", "FFX_DEBUG", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TARGET_KEEP", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
|
||||
"DUMP_LOG", "DUMP_RAW", "DUMP_SHADERS", "DUMP_FILE", "DS3", "LOG_CS_BINDS", "LOG_TEX_FLAGS", "LOG_MESH", "MESH", "POOL", "NATIVE_TENSOR", "LOG_RCOND", "LOG_RT_SIZES", "DUMP_WHITE", "DUMP_AFTER", "DUMP_MOVIE", "SUBMIT_FINISH", "ACQUIRE_WAIT", "CRASH_FILTER_GUARD", "CS_FALLBACK", "EXEFS", "FEEDBACK", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES", "GPU_TIMELINE",
|
||||
"FFX_PIPE_CACHE", "FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FLIGHT_EVERY", "FLUSH_SPAN", "FLUSH_UPLOAD", "FOG_CULL", "FOLIAGE_SHADOW_CULL", "FOLIAGE_SHADOW_VRS", "FOV", "FOV_PATCH", "FG_HUDLESS_SHOW", "FG_MULT", "FPS60", "FPS_LIMIT", "FRAMEGEN", "FRAMEGEN_MULTIPLIER", "FREEZE_IDLE", "FREEZE_ASYNC", "FREEZE_BUDGET_US", "FREE_CORES",
|
||||
"FULLSCREEN", "FXAA", "GAME_ASPECT", "GAME_RES", "GPA", "GPA_EMPTY", "GPA_TWIN", "GPA_TWIN_MAX_KB", "MIRROR_CAPTURE_KB", "WB_SKIP_MB", "GPL", "GPL_DRAW_BUILD", "GPL_FEEDBACK", "PIPE_AHEAD", "PIPE_FAST_WORKERS", "PIPE_FRAME_WAIT_MS", "PIPE_LINK_DRAW_MS", "PIPE_SKIP_STEADY", "PROG_LEAD", "GPU", "GPU_INDEX", "GPU_PASSES", "GPU_NAME", "HDR",
|
||||
|
||||
@@ -1070,9 +1070,13 @@ static void cam_note(int view, int kept) {
|
||||
// that jumped: an area load or a spawn moves it 5 to 180 m in one frame. Such a frame now starts a new history, as
|
||||
// NVIDIA's DLSS guide asks for a camera cut: a move over 5 m, or a turn over 10 degrees together with a move over 0.5 m,
|
||||
// both per 60 Hz frame and scaled by the time since the last camera. Camera traces of play in the Fire Temple
|
||||
// (NX2NAVI_MOUSE_TRACE) had a median of 0.05 m and 0.08 degrees a frame; the second test took only the area loads and a
|
||||
// swing of the camera through a doorway at 12 to 18 degrees and 0.7 to 1.4 m a frame. A turn alone (the mouse camera,
|
||||
// which orbits about 3 m from Link) does not count. Each cut is logged, up to 24.
|
||||
// (NX2NAVI_MOUSE_TRACE) had a median of 0.05 m and 0.08 degrees a frame. A turn alone (the mouse camera, which orbits
|
||||
// about 3 m from Link) does not count, and the turn with a move counts only from CUT_TURN degrees: a quick swing of the
|
||||
// orbiting camera turns 11 to 18 degrees and moves 0.9 to 1.4 m a frame, and taken for a cut at 10 degrees it started a
|
||||
// new history at every frame of the swing (nine in a row in Hyrule Field), which at FSR's or DLSS's smaller modes showed
|
||||
// the scene at its render size for those frames, blocky and flickering. Its motion vectors carry it as well as any other
|
||||
// turn. Each cut is logged, up to 24.
|
||||
#define CUT_TURN 30.0
|
||||
// v: the Ocarina scene context's rows 0-2, the view (fg_camera).
|
||||
static void cam_cut(const float *v) {
|
||||
static int on = -1;
|
||||
@@ -1091,7 +1095,7 @@ static void cam_cut(const float *v) {
|
||||
double k = (now - D.cut_ns) / 1e6 / (1000.0 / 60); // 60 Hz frames since the last camera
|
||||
if (k < 0.25) k = 0.25;
|
||||
if (k > 4) k = 4;
|
||||
if (move > 5.0 * k || (turn > 10.0 * k && move > 0.5 * k)) {
|
||||
if (move > 5.0 * k || (turn > CUT_TURN * k && move > 0.5 * k)) {
|
||||
D.reset = 1, D.cuts++;
|
||||
if (D.cut_logged < 24)
|
||||
D.cut_logged++, rt_log("dlaa: frame %llu: camera cut (moved %.2f m, turned %.1f degrees in %.1f ms): new "
|
||||
@@ -1571,6 +1575,7 @@ static int jitter_draw(const VkExec *ex) {
|
||||
void vk_dlaa_viewport(VkExec *ex, VkViewport *v) {
|
||||
ex->vp_jittered = jitter_draw(ex);
|
||||
if (!ex->vp_jittered) return;
|
||||
ex->pass_jit = 1;
|
||||
v->x += D.jx, v->y += D.jy;
|
||||
D.ux = D.jx, D.uy = D.jy, D.jit_used = 1;
|
||||
}
|
||||
@@ -1816,38 +1821,72 @@ static void release_kept(const struct Size *making, int all) {
|
||||
making->w, making->h, all ? "after a release" : "larger inputs");
|
||||
}
|
||||
|
||||
// The scene's last column and row after a jitter to the left or up. The jitter moves the scene's viewport by under half a
|
||||
// pixel (vk_dlaa_viewport), which keeps every pixel centre inside it, yet on an RX 7900 XT (AMD's Windows driver) the
|
||||
// draws of a viewport moved left left the last column out, and of one moved up the last row: the driver evidently limits
|
||||
// drawing to the whole pixels inside the viewport. In a frame dump (NX2NAVI_DUMP, Hyrule Field, 3416x1440, FSR 4 Native
|
||||
// AA) the depth's last row kept its clear value through every scene pass and the light target held the fog's colour
|
||||
// there, which the upscaler blended into a grey line along the bottom and right edges of the picture that flickered with
|
||||
// the jitter; with NX2NAVI_DLAA_JITTER=0, and without DLSS or FSR, there was no line. Before DLSS or FSR reads the scene,
|
||||
// such a column or row of the light target and of the depth (which the motion vectors are made from) is filled from the
|
||||
// one next to it. NX2NAVI_DLAA_EDGE_FILL=0 (test): not filled.
|
||||
static void edge_fill(VkCommandBuffer cb, const VkExecTarget *t, const VkExecTarget *z, float jx, float jy) {
|
||||
// The outer columns and rows of what a jittered pass draws into. The jitter moves the scene's viewport by under half a
|
||||
// pixel (vk_dlaa_viewport), which keeps every pixel centre inside it, yet on an RX 7900 XT (AMD's Windows driver) the draws
|
||||
// of a viewport moved left left the last column out, and of one moved up the last row: the driver evidently limits
|
||||
// drawing to the whole pixels inside the viewport. Those pixels keep what was there before the pass: in a frame dump
|
||||
// (NX2NAVI_DUMP, Hyrule Field) the depth's last row kept its clear value through every scene pass and the light target the
|
||||
// sky's colour, and in a village the light target's clear colour, white. With NX2NAVI_DLAA_JITTER=0, and without DLSS or
|
||||
// FSR, every row is drawn.
|
||||
// So when a pass that took the jitter ends (vk_exec.c vk_exec_pass_end), the outermost row and column on each side of
|
||||
// its colour targets and its depth are filled from the ones next to them, before anything reads them. Filling only the
|
||||
// armed pair right before the upscaler read it (evaluate, which still does it for a target a dispatch wrote) was too
|
||||
// late for whatever reads the scene in between: water reads the scene behind it and showed bright patches along the
|
||||
// bottom in a fifth of the shots of a run through a stream (none with the jitter off), and the bloom and the
|
||||
// anti-aliasing pass read the row too. (The white line in a player's clips had a second cause, the upscaler's picture
|
||||
// never reaching the screen with the HUD hidden: vk_dlaa_upscaler.)
|
||||
// A copied edge is one render pixel at the picture's border, which the upscaler blends with its history.
|
||||
// NX2NAVI_DLAA_EDGE_FILL: 1 (default) at each jittered pass's end and before the upscaler; 2 only before the upscaler (as
|
||||
// 0.9.1 did, for comparison); 0 not at all.
|
||||
static int edge_fill_mode(void) {
|
||||
static int on = -1;
|
||||
if (on < 0) on = rt_knob("DLAA_EDGE_FILL", "1");
|
||||
uint32_t w = t->width, h = t->height;
|
||||
if (!on || w < 2 || h < 2 || (jx >= 0 && jy >= 0)) return;
|
||||
return on;
|
||||
}
|
||||
|
||||
// One image's border from the texels next to it, in one copy: the columns and rows without their ends, then the four
|
||||
// corners from their diagonal neighbours. Every source is inside the border and every destination on it, so no region
|
||||
// reads what another writes. The image is in GENERAL and nothing is still drawing into it.
|
||||
static void edge_copy(VkCommandBuffer cb, const VkExecTarget *g, VkImageAspectFlags aspect) {
|
||||
int32_t w = (int32_t)g->width, h = (int32_t)g->height;
|
||||
if (w < 4 || h < 4) return;
|
||||
const VkImageSubresourceLayers sl = {aspect, g->level, g->base_layer, 1};
|
||||
#define EDGE(sx, sy, dx, dy, ew, eh) \
|
||||
{.srcSubresource = sl, .srcOffset = {sx, sy, 0}, .dstSubresource = sl, .dstOffset = {dx, dy, 0}, \
|
||||
.extent = {(uint32_t)(ew), (uint32_t)(eh), 1}}
|
||||
const VkImageCopy r[8] = {EDGE(1, 1, 0, 1, 1, h - 2), EDGE(w - 2, 1, w - 1, 1, 1, h - 2),
|
||||
EDGE(1, 1, 1, 0, w - 2, 1), EDGE(1, h - 2, 1, h - 1, w - 2, 1),
|
||||
EDGE(1, 1, 0, 0, 1, 1), EDGE(w - 2, 1, w - 1, 0, 1, 1),
|
||||
EDGE(1, h - 2, 0, h - 1, 1, 1), EDGE(w - 2, h - 2, w - 1, h - 1, 1, 1)};
|
||||
#undef EDGE
|
||||
vkCmdCopyImage(cb, g->image, VK_IMAGE_LAYOUT_GENERAL, g->image, VK_IMAGE_LAYOUT_GENERAL, 8, r);
|
||||
}
|
||||
|
||||
static int edge_target(const VkExecTarget *g) { return g->image && g->samples <= 1 && !g->is3d && !g->blocks; }
|
||||
|
||||
void vk_dlaa_pass_end(VkExec *ex) {
|
||||
if (!ex->pass_jit) return;
|
||||
ex->pass_jit = 0;
|
||||
if (edge_fill_mode() != 1) return;
|
||||
int any = edge_target(&ex->depth) && (ex->depth.aspect & VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
for (uint32_t i = 0; i < ex->pass_ncolor && i < 8; i++) any |= edge_target(&ex->color[i]);
|
||||
if (!any) return;
|
||||
static int told;
|
||||
if (!told++) rt_log("dlaa: the scene's last column or row after a jitter to the left or up is filled from the one before it");
|
||||
// the column first, then the row over the whole width, so the corner comes from the filled column
|
||||
for (int pass = 0; pass < 2; pass++) {
|
||||
if (pass ? jy >= 0 : jx >= 0) continue;
|
||||
VkOffset3D from = pass ? (VkOffset3D){0, (int32_t)h - 2, 0} : (VkOffset3D){(int32_t)w - 2, 0, 0};
|
||||
VkOffset3D to = pass ? (VkOffset3D){0, (int32_t)h - 1, 0} : (VkOffset3D){(int32_t)w - 1, 0, 0};
|
||||
VkExtent3D ext = pass ? (VkExtent3D){w, 1, 1} : (VkExtent3D){1, h, 1};
|
||||
for (int i = 0; i < 2; i++) {
|
||||
const VkExecTarget *g = i ? z : t;
|
||||
if (!g->image || g->width != w || g->height != h) continue;
|
||||
VkImageAspectFlags a = i ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
VkImageCopy r = {.srcSubresource = {a, g->level, g->base_layer, 1}, .srcOffset = from,
|
||||
.dstSubresource = {a, g->level, g->base_layer, 1}, .dstOffset = to, .extent = ext};
|
||||
vkCmdCopyImage(cb, g->image, VK_IMAGE_LAYOUT_GENERAL, g->image, VK_IMAGE_LAYOUT_GENERAL, 1, &r);
|
||||
}
|
||||
full_barrier(cb);
|
||||
}
|
||||
if (!told++) rt_log("dlaa: the outer rows and columns of each jittered pass's targets are filled from the ones next to them");
|
||||
vk_exec_barrier(ex); // the pass's draws are done, and its targets are in GENERAL
|
||||
for (uint32_t i = 0; i < ex->pass_ncolor && i < 8; i++)
|
||||
if (edge_target(&ex->color[i])) edge_copy(ex->cb, &ex->color[i], VK_IMAGE_ASPECT_COLOR_BIT), ex->recorded++;
|
||||
if (edge_target(&ex->depth) && (ex->depth.aspect & VK_IMAGE_ASPECT_DEPTH_BIT))
|
||||
edge_copy(ex->cb, &ex->depth, VK_IMAGE_ASPECT_DEPTH_BIT), ex->recorded++;
|
||||
}
|
||||
|
||||
// Before the upscaler reads the armed pair (evaluate): once more, for a light target a dispatch wrote after its last
|
||||
// pass. The pair is at level 0 of the scene's size.
|
||||
static void edge_fill(VkCommandBuffer cb, const VkExecTarget *t, const VkExecTarget *z, int jittered) {
|
||||
if (!edge_fill_mode() || !jittered) return;
|
||||
if (edge_target(t)) edge_copy(cb, t, VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
if (edge_target(z) && z->width == t->width && z->height == t->height) edge_copy(cb, z, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||
full_barrier(cb);
|
||||
}
|
||||
|
||||
// Set when the scene the upscaler runs on has another size than the last one; vk_dlaa_resized_take reads it.
|
||||
@@ -1880,7 +1919,7 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) {
|
||||
VkImageView zv = vk_exec_target_view(z->img, z->format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_DEPTH_BIT, z->level,
|
||||
z->base_layer, 1, 0);
|
||||
float jx = D.jit_used ? D.ux : 0.0f, jy = D.jit_used ? D.uy : 0.0f;
|
||||
edge_fill(cb, t, z, jx, jy); // before the motion vectors read the depth
|
||||
edge_fill(cb, t, z, D.jit_used); // before the motion vectors read the depth
|
||||
static int no_mv = -1;
|
||||
if (no_mv < 0) no_mv = !rt_knob("DLAA_MV", "1"); // NX2NAVI_DLAA_MV=0: zero motion (test)
|
||||
int masked = 0, mv = no_mv ? 0 : mv_pass(ex, e, zv, jx, jy, char_bias(), &masked);
|
||||
@@ -2131,6 +2170,37 @@ static int output_target(VkFormat f) { return srgb8(f) || vk_hdr_native_picture(
|
||||
|
||||
double wide_dlss_share(void); // widescreen.c: the DLSS mode's share of the picture (1 DLAA), 0 off
|
||||
|
||||
// Ocarina's own upscaler is the place for DLSS or FSR: its stand-in (vk_exec_draw.c untranslated_dispatch_fallback) has
|
||||
// just scaled the scene into the image the rest of the frame shows, and the upscaler's picture goes over it there.
|
||||
// Until this hook the upscaler ran at the pass after it (vk_dlaa_pass below), which was taken for the pass the HUD is
|
||||
// drawn into, the stand-in's output image as its target. With the HUD hidden the game draws no such pass: the next pass
|
||||
// is the frame's last, which encodes the stand-in's image into the 8-bit output. DLSS's or FSR's picture was then
|
||||
// written into that 8-bit target and the last draw drew the stand-in's picture over it: the screen showed the
|
||||
// jittered scene at its render size, scaled with a plain filter. On a player's save with the HUD off that was every
|
||||
// frame: blocks of render pixels, a picture that shook with the jitter by up to one render pixel, the undrawn edge
|
||||
// row in white, and the upscaler's cost for nothing; with the HUD on (every test save until then) the same settings
|
||||
// gave the upscaler's picture. Found by dumping the same frame of both saves (NX2NAVI_DUMP): three HUD passes before the
|
||||
// last one in one, none in the other.
|
||||
// The image is the stand-in's output when it has the light target's format and the scene's shape and is no smaller
|
||||
// than the scene (the movie network's and other tensor programs' outputs are RGBA8 or smaller). A frame without the
|
||||
// dispatch (NX2NAVI_CS_FALLBACK=0, another engine) still ends at vk_dlaa_pass. NX2NAVI_DLAA_AT_UPSCALER=0 (test): as before.
|
||||
void vk_dlaa_upscaler(VkExec *ex, VkImage out, VkFormat fmt, uint32_t w, uint32_t h) {
|
||||
static int on = -1;
|
||||
if (on < 0) on = rt_knob("DLAA_AT_UPSCALER", "1");
|
||||
if (!on || !dl_active() || !D.armed || D.done || D.gbuf || !out || fmt != VK_FORMAT_B10G11R11_UFLOAT_PACK32) return;
|
||||
uint32_t sw = D.color.width, sh = D.color.height;
|
||||
if (w < sw || h < sh || out == D.color.image) return;
|
||||
if ((double)w * sh > 1.03 * (double)h * sw || (double)h * sw > 1.03 * (double)w * sh) return; // not the scene's shape
|
||||
static int told;
|
||||
if (!told++)
|
||||
rt_log("dlaa: the upscaler runs where the game's own does: scene %ux%u into its %ux%u output", sw, sh, w, h);
|
||||
VkExecTarget dst = {.image = out, .format = fmt, .aspect = VK_IMAGE_ASPECT_COLOR_BIT, .layers = 1, .width = w,
|
||||
.height = h, .samples = 1};
|
||||
vk_exec_hook_turn(); // as in vk_dlaa_pass: the replay workers' draws read the jitter and its end
|
||||
D.ended = D.done = D.up = 1;
|
||||
evaluate(ex, &dst);
|
||||
}
|
||||
|
||||
void vk_dlaa_pass(VkExec *ex) {
|
||||
const VkExecTarget *c = &ex->color[0], *z = &ex->depth;
|
||||
if (!dl_active()) return;
|
||||
|
||||
@@ -65,6 +65,9 @@ int64_t vk_dlaa_vram(void);
|
||||
// frame (vk_dlaa_frame).
|
||||
typedef struct VkExec VkExec;
|
||||
void vk_dlaa_pass(VkExec *ex);
|
||||
// vk_exec_draw.c untranslated_dispatch_fallback, after the stand-in of the game's own upscaler wrote its output image
|
||||
// (in GENERAL, of format fmt and w x h): DLSS or FSR runs there on the armed scene and its picture goes over it.
|
||||
void vk_dlaa_upscaler(VkExec *ex, VkImage out, VkFormat fmt, uint32_t w, uint32_t h);
|
||||
void vk_dlaa_frame(void);
|
||||
// 1 once, at the present of the first frame whose scene has a new size after a setting changed (vk_dlaa.c).
|
||||
int vk_dlaa_resized_take(void);
|
||||
@@ -72,6 +75,7 @@ int vk_dlaa_resized_take(void);
|
||||
// the viewport of the scene's draws by the frame's jitter (vk_dlaa_viewport, when the viewport is recorded).
|
||||
void vk_dlaa_draw(VkExec *ex);
|
||||
void vk_dlaa_viewport(VkExec *ex, VkViewport *v);
|
||||
void vk_dlaa_pass_end(VkExec *ex); // vk_exec.c, a pass just ended: the edges of a jittered pass's targets are filled
|
||||
void vk_dlaa_jitter_check(VkExec *ex); // before each draw's fixed state: records the viewport again where its jitter changes
|
||||
// vk_mvsurvey.c (NX2NAVI_MV_SURVEY): notes the uniform blocks of each scene draw, beside vk_dlaa_draw; each present
|
||||
// compares them with the previous frames' and logs a summary now and then.
|
||||
|
||||
@@ -919,6 +919,7 @@ void vk_exec_pass_end(VkExec *ex) {
|
||||
tfr_note(&ft, stamp);
|
||||
}
|
||||
if (lk) plat_mutex_unlock(&tfr_lock);
|
||||
vk_dlaa_pass_end(ex); // a jittered pass left its targets' outer rows or columns undrawn
|
||||
}
|
||||
|
||||
VkCommandBuffer vk_exec_inline_begin(int *reopen) {
|
||||
|
||||
@@ -74,6 +74,7 @@ typedef struct VkExec {
|
||||
float vp[16][6]; // OP_VIEWPORTS: x, y, w, h, near, far
|
||||
int has_vp; // a viewport was set; else the render area
|
||||
int vp_jittered; // the viewport recorded last took the DLAA jitter (vk_dlaa.c vk_dlaa_viewport)
|
||||
int pass_jit; // a viewport of the pass open now took it: its targets' edges are filled at its end (vk_dlaa_pass_end)
|
||||
p_scissor scissor; // OP_SCISSOR (scissor 0)
|
||||
int has_scissor; // a scissor was set; else unbounded
|
||||
float depth_range[2]; // OP_DEPTH_RANGE: overrides the viewports' near and far
|
||||
|
||||
@@ -6360,6 +6360,7 @@ static void untranslated_dispatch_fallback(VkExec *ex) {
|
||||
}
|
||||
ex->recorded++;
|
||||
vk_exec_barrier(ex);
|
||||
vk_dlaa_upscaler(ex, di, df, dw, dh); // the scene upscaler's output: DLSS's or FSR's picture goes there (vk_dlaa.c)
|
||||
}
|
||||
|
||||
static void op_dispatch(VkExec *ex, const p_dispatch *d) {
|
||||
|
||||
@@ -112,14 +112,20 @@ ffxReturnCode_t create_counted(ffxContext *ctx, ffxCreateContextDescHeader *desc
|
||||
return r;
|
||||
}
|
||||
|
||||
// One upscaling context per output size, made for render sizes up to the output's: every render scale the menu sets
|
||||
// runs on it with its own render size at each dispatch (the API's dynamic resolution, up to maxRenderSize), and the
|
||||
// game's second scenes, of another output size, get their own. When all are taken, the least recently used one is
|
||||
// destroyed for the new size once the GPU is idle, as vk_dlaa.c free_size does for DLSS. One per render size, as
|
||||
// before, kept a context for each mode tried, each with its own video memory, and the seventh size found none.
|
||||
// One upscaling context per render size and output size, as AMD's own sample keeps them: it waits for the GPU and makes
|
||||
// the context anew whenever the render resolution changes, and sets FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION only for its
|
||||
// dynamic resolution mode. One context per output size that every mode of the menu ran on, with another render size at
|
||||
// each dispatch and without that flag, preceded an access violation in AMD's driver inside FSR 4's dispatch at the
|
||||
// first frame after a switch from 67 % to 100 % (vk_ffx4.cpp keeps its contexts the same way). With the game's dynamic
|
||||
// resolution on (NX2NAVI_DYN_RES, dynres.c), whose steps change the render size every few seconds, one context with
|
||||
// that flag takes them all. A context of another render size goes once no command buffer can still hold it
|
||||
// (UP_RECENT), so a switch keeps at most two of an output size for a few frames, and the game's second scenes, of
|
||||
// another output size, keep their own. When all slots are taken, the least recently used one is destroyed for the new
|
||||
// size once the GPU is idle, as vk_dlaa.c free_size does for DLSS.
|
||||
struct Up {
|
||||
ffxContext ctx = nullptr;
|
||||
uint32_t mw = 0, mh = 0, ow = 0, oh = 0; // the largest render size it takes; the output size
|
||||
uint32_t mw = 0, mh = 0, ow = 0, oh = 0; // the render size it was made for (the largest it takes with drs); the output size
|
||||
bool drs = false; // made for dynamic resolution (FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION)
|
||||
uint64_t used = 0, used_ns = 0; // up_tick and the time when context_for last returned it
|
||||
} U[4];
|
||||
uint64_t up_tick;
|
||||
@@ -157,15 +163,22 @@ FfxApiResource image(const VkFfxImage *i, uint32_t state, uint32_t usage) {
|
||||
Up *context_for(uint32_t w, uint32_t h, uint32_t ow, uint32_t oh) {
|
||||
up_tick++;
|
||||
uint64_t now = plat_now_ns();
|
||||
Up *small = nullptr; // a context of this output size made for smaller render sizes
|
||||
const bool drs = cfg_bool("NX2NAVI_DYN_RES");
|
||||
Up *found = nullptr;
|
||||
for (Up &u : U)
|
||||
if (u.ctx && u.ow == ow && u.oh == oh) {
|
||||
if (w <= u.mw && h <= u.mh) {
|
||||
u.used = up_tick, u.used_ns = now;
|
||||
return &u;
|
||||
}
|
||||
small = &u;
|
||||
if (u.ctx && u.ow == ow && u.oh == oh && u.drs == drs && (drs ? w <= u.mw && h <= u.mh : w == u.mw && h == u.mh))
|
||||
found = &u;
|
||||
const VkCtx *c = vk_ctx();
|
||||
int waited = 0;
|
||||
for (Up &u : U) // the contexts of this output size for another render size, once no command buffer holds them
|
||||
if (u.ctx && &u != found && u.ow == ow && u.oh == oh && up_tick - u.used >= UP_RECENT) {
|
||||
if (!waited++) vk_queue_lock(), vkDeviceWaitIdle(c->device), vk_queue_unlock(); // their work may be in flight
|
||||
destroy_up(&u, "the render size changed");
|
||||
}
|
||||
if (found) {
|
||||
found->used = up_tick, found->used_ns = now;
|
||||
return found;
|
||||
}
|
||||
Up *slot = nullptr, *lru = nullptr;
|
||||
for (Up &u : U) {
|
||||
if (!u.ctx) {
|
||||
@@ -174,16 +187,14 @@ Up *context_for(uint32_t w, uint32_t h, uint32_t ow, uint32_t oh) {
|
||||
}
|
||||
if (up_tick - u.used >= UP_RECENT && (!lru || u.used < lru->used)) lru = &u;
|
||||
}
|
||||
if (small && up_tick - small->used >= UP_RECENT) slot = nullptr, lru = small; // a larger one takes its place
|
||||
const VkCtx *c = vk_ctx();
|
||||
if (!slot && lru) {
|
||||
vk_queue_lock(), vkDeviceWaitIdle(c->device), vk_queue_unlock(); // its work may still be in flight
|
||||
destroy_up(lru, lru == small ? "a larger render size came" : "its slot went to another output size");
|
||||
destroy_up(lru, "its slot went to another output size");
|
||||
slot = lru;
|
||||
}
|
||||
if (!slot) return nullptr;
|
||||
// the render size up to the output size: every mode of the menu, and a scene drawn at the output size itself
|
||||
uint32_t mw = w > ow ? w : ow, mh = h > oh ? h : oh;
|
||||
// the render size itself; for dynamic resolution, every size up to the output's (and a scene at the output size)
|
||||
uint32_t mw = !drs ? w : w > ow ? w : ow, mh = !drs ? h : h > oh ? h : oh;
|
||||
ffxCreateBackendVKDesc be = {};
|
||||
be.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_BACKEND_VK;
|
||||
be.vkDevice = c->device;
|
||||
@@ -194,6 +205,9 @@ Up *context_for(uint32_t w, uint32_t h, uint32_t ow, uint32_t oh) {
|
||||
d.header.pNext = &be.header;
|
||||
// no infinite-depth flag: the game's far plane is finite (vk_dlaa.c proj_planes) and each dispatch gives it
|
||||
d.flags = FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE | FFX_UPSCALE_ENABLE_AUTO_EXPOSURE;
|
||||
// NX2NAVI_FFX_DEBUG=1 (test): the library checks the values of each dispatch and says what it finds (message)
|
||||
if (rt_knob("FFX_DEBUG", "0")) d.flags |= FFX_UPSCALE_ENABLE_DEBUG_CHECKING;
|
||||
if (drs) d.flags |= FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION;
|
||||
d.maxRenderSize = {mw, mh};
|
||||
d.maxUpscaleSize = {ow, oh};
|
||||
d.fpMessage = message;
|
||||
@@ -203,7 +217,7 @@ Up *context_for(uint32_t w, uint32_t h, uint32_t ow, uint32_t oh) {
|
||||
slot->ctx = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
slot->mw = mw, slot->mh = mh, slot->ow = ow, slot->oh = oh, slot->used = up_tick, slot->used_ns = now;
|
||||
slot->mw = mw, slot->mh = mh, slot->ow = ow, slot->oh = oh, slot->drs = drs, slot->used = up_tick, slot->used_ns = now;
|
||||
ffxQueryGetProviderVersion v = {};
|
||||
v.header.type = FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION;
|
||||
A.query(&slot->ctx, &v.header);
|
||||
|
||||
@@ -178,15 +178,18 @@ int probe(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// One context per output size, made for render sizes up to the output's, as vk_ffx.cpp keeps them for FSR 3.1: every
|
||||
// render scale of the menu runs on it with its own render size at each dispatch, which the API allows up to the
|
||||
// context's maxRenderSize. With one context per render and output size, each mode tried made a context of its own,
|
||||
// about 217 MiB of video memory and 50 to 70 ms each, up to six were kept beside FSR 3.1's, and three creations that
|
||||
// failed (the card out of memory) turned FSR 4 off for the run. The descriptors a context was made from stay with it,
|
||||
// as the API asks ("must remain live until ffxDestroyContext").
|
||||
// One context per render size and output size, kept as vk_ffx.cpp keeps FSR 3.1's (see there): a new render size
|
||||
// makes a context of its own (50 to 70 ms and up to about 217 MiB of video memory) and the one before goes a few frames
|
||||
// later, so a mode change costs a creation; with the game's dynamic resolution on one context with
|
||||
// FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION takes every step. Contexts kept for every mode tried, as once, piled up to six
|
||||
// beside FSR 3.1's and three creations that failed (the card out of memory) turned FSR 4 off for the run; one context
|
||||
// for every render size, as next, preceded an access violation in AMD's driver inside the dispatch after a switch from
|
||||
// 67 % to 100 %. The descriptors a context was made from stay with it, as the API asks ("must remain live until
|
||||
// ffxDestroyContext").
|
||||
struct Up {
|
||||
ffxContext ctx = nullptr;
|
||||
uint32_t mw = 0, mh = 0, ow = 0, oh = 0; // the largest render size it takes; the output size
|
||||
uint32_t mw = 0, mh = 0, ow = 0, oh = 0; // the render size it was made for (the largest it takes with drs); the output size
|
||||
bool drs = false; // made for dynamic resolution (FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION)
|
||||
uint64_t used = 0, used_ns = 0; // up_tick and the time when context_for last returned it
|
||||
ffxCreateContextDescUpscale desc = {};
|
||||
ffxCreateBackendVKDesc backend = {};
|
||||
@@ -218,7 +221,7 @@ FfxApiResource image(const VkFfxImage *i, uint32_t state, uint32_t usage) {
|
||||
}
|
||||
|
||||
// A context in slot for render sizes up to mw x mh and the output size ow x oh; NULL when it is not made.
|
||||
Up *create(Up *slot, uint32_t mw, uint32_t mh, uint32_t ow, uint32_t oh) {
|
||||
Up *create(Up *slot, uint32_t mw, uint32_t mh, uint32_t ow, uint32_t oh, bool drs) {
|
||||
const VkCtx *c = vk_ctx();
|
||||
*slot = Up();
|
||||
slot->built.header.type = FFX_API_CREATE_CONTEXT_DESC_TYPE_UPSCALE_VERSION;
|
||||
@@ -233,6 +236,9 @@ Up *create(Up *slot, uint32_t mw, uint32_t mh, uint32_t ow, uint32_t oh) {
|
||||
slot->desc.header.pNext = &slot->backend.header;
|
||||
slot->desc.flags =
|
||||
FFX_UPSCALE_ENABLE_HIGH_DYNAMIC_RANGE | FFX_UPSCALE_ENABLE_AUTO_EXPOSURE; // a finite far plane, as FSR 3.1's
|
||||
// NX2NAVI_FFX_DEBUG=1 (test): the library checks the values of each dispatch and says what it finds (message)
|
||||
if (rt_knob("FFX_DEBUG", "0")) slot->desc.flags |= FFX_UPSCALE_ENABLE_DEBUG_CHECKING;
|
||||
if (drs) slot->desc.flags |= FFX_UPSCALE_ENABLE_DYNAMIC_RESOLUTION;
|
||||
slot->desc.maxRenderSize = {mw, mh};
|
||||
slot->desc.maxUpscaleSize = {ow, oh};
|
||||
slot->desc.fpMessage = message;
|
||||
@@ -244,7 +250,7 @@ Up *create(Up *slot, uint32_t mw, uint32_t mh, uint32_t ow, uint32_t oh) {
|
||||
*slot = Up();
|
||||
return nullptr;
|
||||
}
|
||||
slot->mw = mw, slot->mh = mh, slot->ow = ow, slot->oh = oh;
|
||||
slot->mw = mw, slot->mh = mh, slot->ow = ow, slot->oh = oh, slot->drs = drs;
|
||||
ffxQueryGetProviderVersion v = {};
|
||||
v.header.type = FFX_API_QUERY_DESC_TYPE_GET_PROVIDER_VERSION;
|
||||
A.query(&slot->ctx, &v.header);
|
||||
@@ -266,22 +272,29 @@ Up *create(Up *slot, uint32_t mw, uint32_t mh, uint32_t ow, uint32_t oh) {
|
||||
return slot;
|
||||
}
|
||||
|
||||
// The context for a render size and an output size: the one of that output size that takes the render size, else a
|
||||
// new one, in a free slot or in place of the least recently used one, with the device idle first. A creation that
|
||||
// fails is tried once more after every context not in use has gone, FSR 3.1's idle ones too (vk_ffx_trim_idle): what
|
||||
// it lacked was most often video memory.
|
||||
// The context for a render size and an output size: the one made for them, else a new one, in a free slot or in place
|
||||
// of the least recently used one, with the device idle first; the others of that output size go once no command
|
||||
// buffer can hold them. A creation that fails is tried once more after every context not in use has gone, FSR 3.1's
|
||||
// idle ones too (vk_ffx_trim_idle): what it lacked was most often video memory.
|
||||
Up *context_for(uint32_t w, uint32_t h, uint32_t ow, uint32_t oh) {
|
||||
up_tick++;
|
||||
uint64_t now = plat_now_ns();
|
||||
Up *small = nullptr; // a context of this output size made for smaller render sizes
|
||||
const bool drs = cfg_bool("NX2NAVI_DYN_RES");
|
||||
Up *found = nullptr;
|
||||
for (Up &u : U)
|
||||
if (u.ctx && u.ow == ow && u.oh == oh) {
|
||||
if (w <= u.mw && h <= u.mh) {
|
||||
u.used = up_tick, u.used_ns = now;
|
||||
return &u;
|
||||
}
|
||||
small = &u;
|
||||
if (u.ctx && u.ow == ow && u.oh == oh && u.drs == drs && (drs ? w <= u.mw && h <= u.mh : w == u.mw && h == u.mh))
|
||||
found = &u;
|
||||
const VkCtx *c = vk_ctx();
|
||||
int waited = 0;
|
||||
for (Up &u : U) // the contexts of this output size for another render size, once no command buffer holds them
|
||||
if (u.ctx && &u != found && u.ow == ow && u.oh == oh && up_tick - u.used >= UP_RECENT) {
|
||||
if (!waited++) vk_queue_lock(), vkDeviceWaitIdle(c->device), vk_queue_unlock(); // their work may be in flight
|
||||
destroy_up(&u, "the render size changed");
|
||||
}
|
||||
if (found) {
|
||||
found->used = up_tick, found->used_ns = now;
|
||||
return found;
|
||||
}
|
||||
Up *slot = nullptr, *lru = nullptr;
|
||||
for (Up &u : U) {
|
||||
if (!u.ctx) {
|
||||
@@ -290,24 +303,22 @@ Up *context_for(uint32_t w, uint32_t h, uint32_t ow, uint32_t oh) {
|
||||
}
|
||||
if (up_tick - u.used >= UP_RECENT && (!lru || u.used < lru->used)) lru = &u;
|
||||
}
|
||||
if (small && up_tick - small->used >= UP_RECENT) slot = nullptr, lru = small; // a larger one takes its place
|
||||
const VkCtx *c = vk_ctx();
|
||||
if (!slot && lru) {
|
||||
vk_queue_lock(), vkDeviceWaitIdle(c->device), vk_queue_unlock(); // its work may still be in flight
|
||||
destroy_up(lru, lru == small ? "a larger render size came" : "its slot went to another output size");
|
||||
destroy_up(lru, "its slot went to another output size");
|
||||
slot = lru;
|
||||
}
|
||||
if (!slot) return nullptr;
|
||||
// the render size up to the output size: every mode of the menu, and a scene drawn at the output size itself
|
||||
uint32_t mw = w > ow ? w : ow, mh = h > oh ? h : oh;
|
||||
Up *u = create(slot, mw, mh, ow, oh);
|
||||
// the render size itself; for dynamic resolution, every size up to the output's (and a scene at the output size)
|
||||
uint32_t mw = !drs ? w : w > ow ? w : ow, mh = !drs ? h : h > oh ? h : oh;
|
||||
Up *u = create(slot, mw, mh, ow, oh, drs);
|
||||
if (!u) {
|
||||
int freed = 0;
|
||||
vk_queue_lock(), vkDeviceWaitIdle(c->device), vk_queue_unlock();
|
||||
for (Up &o : U)
|
||||
if (o.ctx && up_tick - o.used >= UP_RECENT) destroy_up(&o, "room for a context whose creation failed"), freed++;
|
||||
freed += vk_ffx_trim_idle(UP_RECENT);
|
||||
if (freed) u = create(slot, mw, mh, ow, oh);
|
||||
if (freed) u = create(slot, mw, mh, ow, oh, drs);
|
||||
}
|
||||
if (u) u->used = up_tick, u->used_ns = now;
|
||||
return u;
|
||||
|
||||
Reference in New Issue
Block a user