Mark DLSS and DLSS frame generation feature creates as work under the perf trace, with the device idle wait of releasing the kept features before them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 22:34:54 -05:00
parent ab4bd8f8f9
commit 78223225f4
3 changed files with 10 additions and 4 deletions

View File

@@ -51,9 +51,9 @@ void perf_count(int kind);
// NX2NAVI_TRACE=perf: work on any thread that a frame can wait for besides the render thread's waits above, summed per
// frame and per 60-frame window (perf.c perf_mark_add): RomFS reads, host zstd decodes, pipeline creates (vk_pipeline.c
// pipe_create_in), guest memory maps (heap size, MapPhysicalMemory), NVN memory pool initialize and finalize
// (vk_memory.c vk_pool_init, vk_pool_fini), and device memory VMA allocates (blocks and dedicated memory: count and
// bytes, no time). perf_mark_begin returns 0 while the trace is off, so a normal run pays one branch per site.
enum { PERF_M_FILE, PERF_M_ZSTD, PERF_M_PIPE, PERF_M_GMEM, PERF_M_POOL, PERF_M_DEVMEM, PERF_M_N };
// (vk_memory.c vk_pool_init, vk_pool_fini), device memory VMA allocates (blocks and dedicated memory: count and
// bytes, no time), and DLSS and DLSS frame generation feature creates (vk_dlaa.c). perf_mark_begin returns 0 while the trace is off, so a normal run pays one branch per site.
enum { PERF_M_FILE, PERF_M_ZSTD, PERF_M_PIPE, PERF_M_GMEM, PERF_M_POOL, PERF_M_DEVMEM, PERF_M_NGX, PERF_M_N };
uint64_t perf_mark_begin(void);
void perf_mark_end(int kind, uint64_t t0, uint64_t bytes); // nothing when t0 is 0
void perf_mark_add(int kind, uint64_t ns, uint64_t bytes); // nothing while the trace is off

View File

@@ -121,7 +121,8 @@ void perf_count(int kind) {
// ---- NX2NAVI_TRACE=perf work marks (host.h PERF_M_*): any thread adds; the present takes the frame's sums (mark_frame),
// names them on a slow frame's line and adds them to the 60-frame window's line.
static const char *const mark_name[PERF_M_N] = {"file reads", "zstd decodes", "pipeline creates", "guest memory maps",
"pool init/finalize", "device memory allocations"};
"pool init/finalize", "device memory allocations",
"DLSS feature creates"};
static volatile int64_t mk_ns[PERF_M_N], mk_n[PERF_M_N], mk_bytes[PERF_M_N], mk_max[PERF_M_N]; // since the last present
typedef struct { uint64_t ns[PERF_M_N], n[PERF_M_N], bytes[PERF_M_N], max[PERF_M_N]; } MarkSums;
static MarkSums mk_win; // the 60-frame window's, present thread only

View File

@@ -1643,6 +1643,8 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) {
goto evaluated;
}
if (!e->feat) {
// NX2NAVI_TRACE=perf: the release of the kept features (a device idle wait) and the create, as one mark
uint64_t t0 = perf_mark_begin();
if (idle_free() != 2) release_kept(e, feat_released);
feat_released = 0;
p_setu(p, "CreationNodeMask", 1);
@@ -1667,6 +1669,7 @@ static void evaluate(VkExec *ex, const VkExecTarget *dst) {
p_setu(p, "DLSS.Hint.Render.Preset.Performance", (unsigned)pm);
p_setu(p, "DLSS.Hint.Render.Preset.UltraPerformance", (unsigned)pl);
NgxResult r = N.create(cb, NGX_FEATURE_SUPERSAMPLING, p, &e->feat);
perf_mark_end(PERF_M_NGX, t0, 0);
if (!NGX_OK(r) || !e->feat) return dl_fail("DLSS feature creation", r);
D.reset = 1;
int q = perf_quality(w, ow), pr = q == 0 ? pm : q == 3 ? pl : pk;
@@ -2162,7 +2165,9 @@ int vk_ngxfg_evaluate(VkCommandBuffer cb, const VkNgxImage *bb, const VkNgxImage
p_setu(p, "Width", bb->w);
p_setu(p, "Height", bb->h);
p_setu(p, "DLSSG.BackbufferFormat", (unsigned)bb->fmt);
uint64_t t0 = perf_mark_begin();
NgxResult r = N.create(cb, NGX_FEATURE_FRAME_GENERATION, p, &FG.feat);
perf_mark_end(PERF_M_NGX, t0, 0);
if (!NGX_OK(r) || !FG.feat) {
FG.failed = 1, FG.feat = NULL;
rt_log("ngxfg: DLSS Frame Generation feature creation failed (%08x): frame generation off", (unsigned)r);