mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 21:39:58 -04:00
Free the images of HDR, FSR 1 and SMAA once they are no longer used, instead of keeping them for the process.
Each made its images at the picture's or the scene's size the first time it ran and kept them until the process ended, also after the menu switched it off: - the HDR encode's picture and menu image (28 and 14 MiB at 2560x1440, 63 and 32 MiB at 2160 lines) now go when the swapchain is made without HDR, after a wait for the presents that may still read them; - FSR 1's two images (56 MiB, 127 MiB at 2160 lines) go after 300 presents it did not scale, with the same wait; - SMAA's three work images (35 MiB, 79 MiB at 2160 lines) go after 600 frames of another anti-aliasing, deferred past the submission being recorded. Each makes them anew when it runs again; one log line says when they go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -75,10 +75,13 @@ static struct {
|
||||
int none_told;
|
||||
} A = {.frame_read = ~0ull, .composed = 1};
|
||||
|
||||
static void smaa_idle(int mode);
|
||||
|
||||
int vk_aa_mode(void) {
|
||||
uint64_t f = __atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED);
|
||||
if (f == A.frame_read) return A.mode;
|
||||
A.frame_read = f;
|
||||
smaa_idle(A.mode); // the frame before's mode
|
||||
const char *v = cfg_value("NX2NAVI_AA");
|
||||
int want = VK_AA_GAME;
|
||||
for (int i = 1; i < 4; i++)
|
||||
@@ -262,6 +265,22 @@ static int tables_make(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// SMAA's work images (35 MiB at a 2560x1440 scene, 79 MiB at 2160 lines) were kept for the process once SMAA had run.
|
||||
// After SMAA_IDLE_FRAMES frames of another mode they go, once the GPU is past the submission being recorded
|
||||
// (img_free defers); SMAA chosen again makes them anew. The lookup textures, a few hundred KiB, stay.
|
||||
#define SMAA_IDLE_FRAMES 600
|
||||
static void smaa_idle(int mode) {
|
||||
static unsigned idle;
|
||||
if (mode == VK_AA_SMAA || !P.luma.img) {
|
||||
idle = 0;
|
||||
return;
|
||||
}
|
||||
if (++idle < SMAA_IDLE_FRAMES) return;
|
||||
img_free(&P.luma), img_free(&P.edges), img_free(&P.weights);
|
||||
P.w = P.h = 0, idle = 0;
|
||||
rt_log("aa: SMAA has not run for %d frames: its work images are freed", SMAA_IDLE_FRAMES);
|
||||
}
|
||||
|
||||
// SMAA's work images at the scene's size, made again when it changes
|
||||
static int work_images(VkCommandBuffer cb, uint32_t w, uint32_t h) {
|
||||
if (P.luma.img && P.w == w && P.h == h) return 1;
|
||||
|
||||
Reference in New Issue
Block a user