mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 16:49:58 -04:00
Check three of this pass's decisions without a device: the automatic texture detail, the device made with DLSS Frame Generation on, and the mesh fallback's depth hold.
Each decision moves into a header the runtime and a test both read, as vk_mesh_path.h does: vk_tex_detail.h (tex_detail_auto), vk_dlssg_device.h (dlssg_card_skipped, dlssg_device_create) and mesh_fb_hold.h (the hold's table). The runtime's behaviour is the same as before the move. tests/tex_detail_check has the budgets from players' logs of 0.10.1 (a handheld's integrated GPU at 10,361 MiB now gets reduced, a 12 GiB card at 11,313 MiB full). tests/dlssg_device_check plays the laptop of the report with stand-ins for the interposer and the loader: the chosen Intel card is skipped, the NVIDIA card is made through the interposer, a card of another vendor is made by the loader without the interposer being asked, and a refusal falls through to the loader. tests/mesh_fb_hold_check holds a list for two presents after its colour draw was skipped, through a wait of 600 frames, and no longer once it is drawn or gone. Built against the rule 0.10.1 had, the first two and mesh_path_check fail (6, 13 and 3 checks). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
84
tests/dlssg_device_check.c
Normal file
84
tests/dlssg_device_check.c
Normal file
@@ -0,0 +1,84 @@
|
||||
// runtime/vk_dlssg_device.h: which card counts as usable while DLSS Frame Generation's interposer is in use, and how
|
||||
// the device is made when the interposer cannot make it (vk_device.c pick_device, vk_dlssg.c vk_dlssg_create_device).
|
||||
// The interposer and the loader are stand-ins that answer as the real ones did in a player's log. Built and run by
|
||||
// tests/dlssg_device_check.py; prints each failed check and exits 1 on any.
|
||||
#include <stdio.h>
|
||||
|
||||
#include "vk_dlssg_device.h"
|
||||
|
||||
#define VENDOR_INTEL 0x8086u
|
||||
#define VENDOR_AMD 0x1002u
|
||||
#define EXT_NOT_PRESENT (-7) // VK_ERROR_EXTENSION_NOT_PRESENT, what the interposer answered on Intel graphics
|
||||
|
||||
static int fails;
|
||||
#define CHECK(c, ...) do { if (!(c)) { fails++; printf("FAIL line %d: ", __LINE__); printf(__VA_ARGS__); printf("\n"); } } while (0)
|
||||
|
||||
// What a run did: the calls each stand-in got, and what each answers.
|
||||
typedef struct { int interposer_calls, loader_calls, interposer_result, loader_result; } Run;
|
||||
static int via_interposer(void *u) {
|
||||
Run *r = u;
|
||||
r->interposer_calls++;
|
||||
return r->interposer_result;
|
||||
}
|
||||
static int via_loader(void *u) {
|
||||
Run *r = u;
|
||||
r->loader_calls++;
|
||||
return r->loader_result;
|
||||
}
|
||||
|
||||
// 0.10.1's creation, for comparison: the interposer alone whenever it is in use.
|
||||
static int create_0101(int interposed, Run *r) { return interposed ? via_interposer(r) : via_loader(r); }
|
||||
|
||||
static const char *const hows[] = {"the loader", "the interposer", "the loader (not an NVIDIA card)",
|
||||
"the loader (the interposer refused)"};
|
||||
|
||||
static void expect(const char *what, int interposed, unsigned vendor, int interposer_result, int loader_result,
|
||||
int want_result, int want_how, int want_interposer_calls, int want_loader_calls) {
|
||||
Run r = {0, 0, interposer_result, loader_result};
|
||||
int how = -1, refused = 0;
|
||||
int got = dlssg_device_create(interposed, vendor, via_interposer, via_loader, &r, &how, &refused);
|
||||
CHECK(got == want_result, "%s: result %d, not %d", what, got, want_result);
|
||||
CHECK(how == want_how, "%s: made by %s, not by %s", what, how >= 0 && how < 4 ? hows[how] : "?", hows[want_how]);
|
||||
CHECK(r.interposer_calls == want_interposer_calls, "%s: the interposer was asked %d times, not %d", what,
|
||||
r.interposer_calls, want_interposer_calls);
|
||||
CHECK(r.loader_calls == want_loader_calls, "%s: the loader was asked %d times, not %d", what, r.loader_calls,
|
||||
want_loader_calls);
|
||||
CHECK((how == DLSSG_DEV_REFUSED) == (refused != 0), "%s: the interposer's result is %d", what, refused);
|
||||
printf(" %s: %s, result %d\n", what, how >= 0 && how < 4 ? hows[how] : "?", got);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
// ---- the laptop of the report: an RTX 3050 (gpu 0) and Intel Iris Xe (gpu 1), framegen = dlss, gpu_index = 1
|
||||
{
|
||||
Run old = {0, 0, EXT_NOT_PRESENT, 0};
|
||||
int r = create_0101(1, &old);
|
||||
CHECK(r == EXT_NOT_PRESENT && !old.loader_calls, "0.10.1 on the Intel card: %d", r);
|
||||
printf(" 0.10.1, the Intel card through the interposer: result %d and nothing else tried (exit code 70)\n", r);
|
||||
}
|
||||
CHECK(dlssg_card_skipped(1, 1, VENDOR_INTEL), "the chosen Intel card is not skipped with the interposer in use");
|
||||
CHECK(!dlssg_card_skipped(1, 1, DLSSG_VENDOR_NVIDIA), "the chosen NVIDIA card is skipped");
|
||||
CHECK(!dlssg_card_skipped(1, 0, DLSSG_VENDOR_NVIDIA), "the NVIDIA card is skipped in the pass without a choice");
|
||||
printf(" pick: the chosen Intel card is skipped, so the pass without a choice takes the NVIDIA card\n");
|
||||
expect("the NVIDIA card, interposer in use", 1, DLSSG_VENDOR_NVIDIA, 0, 0, 0, DLSSG_DEV_INTERPOSER, 1, 0);
|
||||
|
||||
// ---- no NVIDIA card at all (framegen = dlss left in nx2navi.ini): the device is made without frame generation
|
||||
CHECK(!dlssg_card_skipped(1, 0, VENDOR_AMD), "a card is skipped in the pass without a choice");
|
||||
CHECK(!dlssg_card_skipped(1, 0, VENDOR_INTEL), "a card is skipped in the pass without a choice");
|
||||
expect("an AMD card, interposer in use", 1, VENDOR_AMD, EXT_NOT_PRESENT, 0, 0, DLSSG_DEV_NOT_NVIDIA, 0, 1);
|
||||
expect("Intel graphics, interposer in use", 1, VENDOR_INTEL, EXT_NOT_PRESENT, 0, 0, DLSSG_DEV_NOT_NVIDIA, 0, 1);
|
||||
|
||||
// ---- an NVIDIA card the interposer refuses (an old driver): once through it, then the loader
|
||||
expect("an NVIDIA card the interposer refuses", 1, DLSSG_VENDOR_NVIDIA, EXT_NOT_PRESENT, 0, 0, DLSSG_DEV_REFUSED, 1, 1);
|
||||
// ... and when the loader fails too, its result is the one reported
|
||||
expect("an NVIDIA card neither can make a device on", 1, DLSSG_VENDOR_NVIDIA, EXT_NOT_PRESENT, -3, -3,
|
||||
DLSSG_DEV_REFUSED, 1, 1);
|
||||
|
||||
// ---- frame generation off: the loader, whatever the card, and a chosen card of any vendor stands
|
||||
expect("an NVIDIA card, frame generation off", 0, DLSSG_VENDOR_NVIDIA, 0, 0, 0, DLSSG_DEV_LOADER, 0, 1);
|
||||
expect("Intel graphics, frame generation off", 0, VENDOR_INTEL, EXT_NOT_PRESENT, 0, 0, DLSSG_DEV_LOADER, 0, 1);
|
||||
CHECK(!dlssg_card_skipped(0, 1, VENDOR_INTEL), "a chosen Intel card is skipped with frame generation off");
|
||||
CHECK(!dlssg_card_skipped(0, 1, VENDOR_AMD), "a chosen AMD card is skipped with frame generation off");
|
||||
|
||||
printf("dlssg_device_check: %s\n", fails ? "FAILED" : "passed");
|
||||
return fails ? 1 : 0;
|
||||
}
|
||||
41
tests/dlssg_device_check.py
Normal file
41
tests/dlssg_device_check.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""Build and run tests/dlssg_device_check.c: runtime/vk_dlssg_device.h, which card counts as usable while DLSS Frame
|
||||
Generation's interposer is in use and how the device is made when the interposer cannot make it (vk_device.c
|
||||
pick_device, vk_dlssg.c vk_dlssg_create_device), with stand-ins for the interposer and the loader.
|
||||
|
||||
No GPU, no game files, any Python.
|
||||
|
||||
Usage: dlssg_device_check.py
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
MSYS_BIN = Path(r'C:\msys64\ucrt64\bin')
|
||||
|
||||
|
||||
def compiler():
|
||||
"""$CC, else MSYS2 UCRT64's clang, else clang on PATH (as tests/diff/common.py picks it, without its Unicorn)."""
|
||||
if os.environ.get('CC'):
|
||||
return os.environ['CC']
|
||||
if os.name == 'nt' and (MSYS_BIN / 'clang.exe').exists():
|
||||
return str(MSYS_BIN / 'clang.exe')
|
||||
return shutil.which('clang') or 'clang'
|
||||
|
||||
|
||||
def main():
|
||||
work = ROOT / 'build' / 'test' / 'dlssg_device'
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
exe = work / ('dlssg_device_check.exe' if os.name == 'nt' else 'dlssg_device_check')
|
||||
env = dict(os.environ)
|
||||
if os.name == 'nt' and MSYS_BIN.exists():
|
||||
env['PATH'] = str(MSYS_BIN) + os.pathsep + env.get('PATH', '')
|
||||
subprocess.check_call([compiler(), '-std=gnu11', '-O1', '-Wall', '-Werror', '-I', str(ROOT / 'runtime'),
|
||||
str(ROOT / 'tests' / 'dlssg_device_check.c'), '-o', str(exe)], env=env)
|
||||
return subprocess.run([str(exe)], env=env).returncode
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
67
tests/mesh_fb_hold_check.c
Normal file
67
tests/mesh_fb_hold_check.c
Normal file
@@ -0,0 +1,67 @@
|
||||
// runtime/mesh_fb_hold.h: the table behind the mesh fallback's depth hold (vk_exec_draw.c): a list whose colour draw
|
||||
// was skipped for its pipeline holds its depth-only draw for a few presents, and no longer. Built and run by
|
||||
// tests/mesh_fb_hold_check.py; prints each failed check and exits 1 on any.
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mesh_fb_hold.h"
|
||||
|
||||
static int fails;
|
||||
#define CHECK(c, ...) do { if (!(c)) { fails++; printf("FAIL line %d: ", __LINE__); printf(__VA_ARGS__); printf("\n"); } } while (0)
|
||||
|
||||
static volatile uint64_t tab[MFB_HOLD_SLOTS];
|
||||
|
||||
int main(void) {
|
||||
const uint64_t grass = 0x59220f600ull, leaves = 0x26d876000ull; // record addresses as the game's memory has them
|
||||
// ---- a frame's order is depth first, colour after: the stamp of one frame holds the depth draw of the next
|
||||
uint64_t present = 1000;
|
||||
CHECK(!mfb_hold_test(tab, grass, present), "a list nothing stamped is held");
|
||||
mfb_hold_mark(tab, grass, 1, present); // the colour draw waits for its pipeline
|
||||
CHECK(mfb_hold_test(tab, grass, present), "not held in the present of the stamp");
|
||||
CHECK(mfb_hold_test(tab, grass, present + 1), "not held one present later");
|
||||
CHECK(mfb_hold_test(tab, grass, present + MFB_HOLD_PRESENTS), "not held at the last present of the hold");
|
||||
CHECK(!mfb_hold_test(tab, grass, present + MFB_HOLD_PRESENTS + 1), "still held after the hold");
|
||||
CHECK(!mfb_hold_test(tab, leaves, present), "another list is held");
|
||||
// ---- while the colour draw keeps waiting, each frame stamps again and the hold goes on
|
||||
for (int i = 1; i <= 600; i++) {
|
||||
CHECK(mfb_hold_test(tab, grass, present + (uint64_t)i), "frame %d of a wait: not held", i);
|
||||
mfb_hold_mark(tab, grass, 1, present + (uint64_t)i);
|
||||
}
|
||||
present += 600;
|
||||
// ---- the colour draw is drawn: the stamp goes, and the depth draw comes back in the next frame
|
||||
mfb_hold_mark(tab, grass, 0, present + 1);
|
||||
CHECK(!mfb_hold_test(tab, grass, present + 1), "held after the colour draw was drawn");
|
||||
CHECK(!mfb_hold_test(tab, grass, present + 2), "held in the frame after it");
|
||||
// ---- a colour draw that no longer comes (the list left the view): the hold lapses by itself
|
||||
mfb_hold_mark(tab, leaves, 1, present);
|
||||
CHECK(mfb_hold_test(tab, leaves, present + 2) && !mfb_hold_test(tab, leaves, present + 3), "the hold does not lapse");
|
||||
// ---- a draw of one list does not clear another list's stamp, in whatever slot each lies
|
||||
mfb_hold_mark(tab, grass, 1, present);
|
||||
mfb_hold_mark(tab, leaves, 0, present);
|
||||
CHECK(mfb_hold_index(grass) == mfb_hold_index(leaves) || mfb_hold_test(tab, grass, present),
|
||||
"another list's draw cleared the stamp");
|
||||
// ---- the present count's 24 bits wrap (77 hours at 60 fps): the hold counts across the wrap
|
||||
memset((void *)tab, 0, sizeof tab);
|
||||
mfb_hold_mark(tab, grass, 1, MFB_HOLD_MASK);
|
||||
CHECK(mfb_hold_test(tab, grass, MFB_HOLD_MASK + 1) && mfb_hold_test(tab, grass, MFB_HOLD_MASK + 2) &&
|
||||
!mfb_hold_test(tab, grass, MFB_HOLD_MASK + 3), "the hold is wrong across the wrap of the present count");
|
||||
// ---- the highest address the game's memory has keeps its bits above the count
|
||||
const uint64_t top = (1ull << 39) - 4;
|
||||
memset((void *)tab, 0, sizeof tab);
|
||||
mfb_hold_mark(tab, top, 1, 5);
|
||||
CHECK(mfb_hold_test(tab, top, 6) && !mfb_hold_test(tab, top - 4, 6), "the top address is not told from its neighbour");
|
||||
// ---- every index is inside the table, and a field of records spreads over it
|
||||
int used[MFB_HOLD_SLOTS] = {0}, most = 0, slots = 0;
|
||||
for (uint64_t a = 0x59220f600ull; a < 0x59220f600ull + 256 * 12; a += 12) { // 256 records of 12 bytes
|
||||
uint32_t i = mfb_hold_index(a);
|
||||
CHECK(i < MFB_HOLD_SLOTS, "index %u out of the table", i);
|
||||
if (i < MFB_HOLD_SLOTS && !used[i]++) slots++;
|
||||
}
|
||||
for (int i = 0; i < MFB_HOLD_SLOTS; i++)
|
||||
if (used[i] > most) most = used[i];
|
||||
CHECK(slots >= 192 && most <= 4, "256 records fall into %d slots, up to %d in one", slots, most);
|
||||
printf(" 256 neighbouring records fall into %d slots, at most %d in one\n", slots, most);
|
||||
|
||||
printf("mesh_fb_hold_check: %s\n", fails ? "FAILED" : "passed");
|
||||
return fails ? 1 : 0;
|
||||
}
|
||||
40
tests/mesh_fb_hold_check.py
Normal file
40
tests/mesh_fb_hold_check.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Build and run tests/mesh_fb_hold_check.c: runtime/mesh_fb_hold.h, the table behind the mesh fallback's depth hold
|
||||
(vk_exec_draw.c): a list whose colour draw waits for its pipeline holds its depth-only draw, and for how long.
|
||||
|
||||
No GPU, no game files, any Python.
|
||||
|
||||
Usage: mesh_fb_hold_check.py
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
MSYS_BIN = Path(r'C:\msys64\ucrt64\bin')
|
||||
|
||||
|
||||
def compiler():
|
||||
"""$CC, else MSYS2 UCRT64's clang, else clang on PATH (as tests/diff/common.py picks it, without its Unicorn)."""
|
||||
if os.environ.get('CC'):
|
||||
return os.environ['CC']
|
||||
if os.name == 'nt' and (MSYS_BIN / 'clang.exe').exists():
|
||||
return str(MSYS_BIN / 'clang.exe')
|
||||
return shutil.which('clang') or 'clang'
|
||||
|
||||
|
||||
def main():
|
||||
work = ROOT / 'build' / 'test' / 'mesh_fb_hold'
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
exe = work / ('mesh_fb_hold_check.exe' if os.name == 'nt' else 'mesh_fb_hold_check')
|
||||
env = dict(os.environ)
|
||||
if os.name == 'nt' and MSYS_BIN.exists():
|
||||
env['PATH'] = str(MSYS_BIN) + os.pathsep + env.get('PATH', '')
|
||||
subprocess.check_call([compiler(), '-std=gnu11', '-O1', '-Wall', '-Werror', '-I', str(ROOT / 'runtime'),
|
||||
str(ROOT / 'tests' / 'mesh_fb_hold_check.c'), '-o', str(exe)], env=env)
|
||||
return subprocess.run([str(exe)], env=env).returncode
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
53
tests/tex_detail_check.c
Normal file
53
tests/tex_detail_check.c
Normal file
@@ -0,0 +1,53 @@
|
||||
// runtime/vk_tex_detail.h: the level texture_detail = auto picks (vk_texture.c vk_texture_detail_auto), for the cards and
|
||||
// budgets players reported. Built and run by tests/tex_detail_check.py; prints each failed check and exits 1 on any.
|
||||
#include <stdio.h>
|
||||
|
||||
#include "vk_tex_detail.h"
|
||||
|
||||
static int fails;
|
||||
static const char *const names[] = {"full", "reduced", "low"};
|
||||
|
||||
static void expect(long long mb, int shared, int rgba8, int want, const char *what) {
|
||||
int got = tex_detail_auto(mb, shared, rgba8);
|
||||
if (got != want) {
|
||||
fails++;
|
||||
printf("FAIL: %s (budget %lld MiB, integrated %d, uncompressed ASTC %d): %s, not %s\n", what, mb, shared, rgba8,
|
||||
names[got], names[want]);
|
||||
} else {
|
||||
printf(" ok: %-62s budget %5lld MiB -> %s\n", what, mb, names[got]);
|
||||
}
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
// ---- the budgets in players' logs of 0.10.1
|
||||
expect(10361, 1, 0, 1, "ROG Ally X, integrated (0.10.1: full, ended at save load)");
|
||||
expect(7365, 0, 0, 1, "RX 7600, 8 GiB");
|
||||
expect(11313, 0, 0, 0, "RX 7700 XT, 12 GiB");
|
||||
expect(15569, 0, 0, 0, "RX 6800 XT, 16 GiB");
|
||||
expect(31419, 0, 0, 0, "RTX 5090, 32 GiB");
|
||||
// ---- between the old 8,192 MiB and the new 10,240: the cards of 10 GiB
|
||||
expect(9300, 0, 0, 1, "a 10 GiB card (0.10.1: full)");
|
||||
expect(8192, 0, 0, 1, "8,192 MiB, where full started in 0.10.1");
|
||||
expect(10239, 0, 0, 1, "one MiB under the new start of full");
|
||||
expect(10240, 0, 0, 0, "the new start of full");
|
||||
// ---- low under 6,144 MiB, as before
|
||||
expect(6144, 0, 0, 1, "6,144 MiB");
|
||||
expect(6143, 0, 0, 2, "one MiB under it");
|
||||
expect(4730, 0, 0, 2, "an RTX 3060 Laptop, 6 GiB");
|
||||
// ---- an integrated GPU never gets full, and follows the budget below that
|
||||
expect(16000, 1, 0, 1, "integrated with a 16 GiB budget");
|
||||
expect(8034, 1, 0, 1, "Intel Iris Xe (8,034 MiB)");
|
||||
expect(5000, 1, 0, 2, "integrated with a 5 GiB budget");
|
||||
// ---- no budget reported: full, as before, also on an integrated GPU
|
||||
expect(0, 0, 0, 0, "no budget reported");
|
||||
expect(0, 1, 0, 0, "no budget reported, integrated");
|
||||
// ---- uncompressed ASTC textures: one step lower under 20,480 MiB
|
||||
expect(15569, 0, 1, 1, "a 16 GiB card with uncompressed ASTC");
|
||||
expect(7365, 0, 1, 2, "an 8 GiB card with uncompressed ASTC");
|
||||
expect(4730, 0, 1, 2, "a 6 GiB card with uncompressed ASTC (already low)");
|
||||
expect(24000, 0, 1, 0, "a 24 GiB card with uncompressed ASTC");
|
||||
expect(10361, 1, 1, 2, "integrated with uncompressed ASTC");
|
||||
|
||||
printf("tex_detail_check: %s\n", fails ? "FAILED" : "passed");
|
||||
return fails ? 1 : 0;
|
||||
}
|
||||
40
tests/tex_detail_check.py
Normal file
40
tests/tex_detail_check.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Build and run tests/tex_detail_check.c: runtime/vk_tex_detail.h, the level texture_detail = auto picks for a video
|
||||
memory budget, on a card with memory of its own and on an integrated GPU (vk_texture.c vk_texture_detail_auto).
|
||||
|
||||
No GPU, no game files, any Python.
|
||||
|
||||
Usage: tex_detail_check.py
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
MSYS_BIN = Path(r'C:\msys64\ucrt64\bin')
|
||||
|
||||
|
||||
def compiler():
|
||||
"""$CC, else MSYS2 UCRT64's clang, else clang on PATH (as tests/diff/common.py picks it, without its Unicorn)."""
|
||||
if os.environ.get('CC'):
|
||||
return os.environ['CC']
|
||||
if os.name == 'nt' and (MSYS_BIN / 'clang.exe').exists():
|
||||
return str(MSYS_BIN / 'clang.exe')
|
||||
return shutil.which('clang') or 'clang'
|
||||
|
||||
|
||||
def main():
|
||||
work = ROOT / 'build' / 'test' / 'tex_detail'
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
exe = work / ('tex_detail_check.exe' if os.name == 'nt' else 'tex_detail_check')
|
||||
env = dict(os.environ)
|
||||
if os.name == 'nt' and MSYS_BIN.exists():
|
||||
env['PATH'] = str(MSYS_BIN) + os.pathsep + env.get('PATH', '')
|
||||
subprocess.check_call([compiler(), '-std=gnu11', '-O1', '-Wall', '-Werror', '-I', str(ROOT / 'runtime'),
|
||||
str(ROOT / 'tests' / 'tex_detail_check.c'), '-o', str(exe)], env=env)
|
||||
return subprocess.run([str(exe)], env=env).returncode
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user