mirror of
https://github.com/seedds/nxnative.git
synced 2026-11-23 11:39:42 -10:00
gfx/nvn: sparse texture views count levels from level 0; type marks go when an ID changes type
Three red lines from Resident Evil 4's opening, traced with diagnostic runs:
- A sparse texture whose finer levels are not mapped is bound as the view
of its levels from the first mapped one (sparse_view), and tex_by_id took
a texture view's levels as that host texture's. RE4 samples its streamed
textures through views of levels 1 + 0 and 2 + 0: the level 2 views were
left out ("texture view id … starts at mip 2 beyond 1 levels") and the
level 1 views read level 2. tex_level_shift counts them from NVN's
level 0; finer levels than the first mapped one read it.
- The read bitmap's per-type marks stayed when the game put a texture of
another type into an ID, so the next walk reported the new texture as
read through the old one's type ("[pool-type] … read through a type 5
texture pool table", RE4's 1x1 default texture in the IDs of cubes it
lets go). mtl_reg_tex clears an ID's typed marks on a target change
(pool_seen_retype); the read mark and same-type marks stay.
- A buffer address pushed on an unmapped page of a sparse pool's
reservation reads 0, as on the GPU: noted once, no longer red
(nvn_vpool_unmapped).
Checks: t_sparse_pool_cache (35, 2 fail without the fix) and
t_pool_typebridge (40, 2 fail without it); RE4's title-to-forest route on
the Mac before and after: seven [pool-type] lines and a mip-view line
before, none after.
This commit is contained in:
1 parent
d677760fa4
commit
e5fb15561e
8 files changed
+115
-7
No files matched your search
@@ -36,10 +36,14 @@ Measured on the M6 (16 GB), in a 1280x720 window: 60 fps at the title (frame tim
|
||||
- LDTRAM ([an attribute at each vertex of the triangle](../../../docs/reference/shaders.md#ldtram-an-attribute-at-each-vertex-of-the-triangle)); its shaders read the third perspective barycentric coordinate, which the translator had computed as 1 - x - y ([the barycentric coordinates](../../../docs/reference/shaders.md#ipa-at-an-offset-and-the-barycentric-coordinates)).
|
||||
- [YIELD](../../../docs/reference/shaders.md#yield) in 21 compute shaders.
|
||||
- `nvnCommandBufferSetRepresentativeFragmentTest` was unimplemented ([Representative fragment test](../../../docs/reference/nvn-objects.md#representative-fragment-test-nvncommandbuffersetrepresentativefragmenttest)).
|
||||
- Its streamed textures are sampled through views from level 1 or 2 while only their smallest levels are mapped; the host counted those levels from the first mapped one, so the views were left out or read a smaller level ([Texture views of a sparse texture bound from a later level](../../../docs/reference/rendering.md#texture-views-of-a-sparse-texture-bound-from-a-later-level)).
|
||||
- It puts its 1x1 default texture into the IDs of cubes it lets go, which the host reported as read through a cube table ([Read marks of a texture type kept when an ID changes type](../../../docs/reference/nvn-objects.md#read-marks-of-a-texture-type-kept-when-an-id-changes-type)).
|
||||
- At frame 5 one shader is pushed a buffer address on a page of a sparse pool the game has not mapped yet: it reads 0, as on the console ([A buffer address on an unmapped page of a sparse pool](../../../docs/reference/nvn-objects.md#a-buffer-address-on-an-unmapped-page-of-a-sparse-pool)).
|
||||
- Its first command buffer draws with constant buffer 1 of a pixel shader not bound (`stage 5 cb1 has no uniform buffer bound`, frame 0): the game's own, read as the zero bank ([An unbound uniform slot reads the zero bank](../../../docs/reference/rendering.md#an-unbound-uniform-slot-reads-the-zero-bank)).
|
||||
|
||||
## Open
|
||||
|
||||
- Gameplay beyond the first minutes of the forest path: the village, combat, the menus in play, sound by ear.
|
||||
- The red lines left in play, each once: `nvnCommandBufferSetFloatBlendClamp 1` (as on [PRAGMATA](../0400C76024710000/README.md)), a texture view that starts at mip 2 of a one-level texture, a constant buffer 1 not bound for one shader at frame 0, a pushed buffer address in no memory pool, and textures read through a pool table of another type, which the host leaves out (a 64x64 one; 1x1 placeholders, nine times in the opening cutscenes).
|
||||
- The red lines left in play, each once: `nvnCommandBufferSetFloatBlendClamp 1` (as on [PRAGMATA](../0400C76024710000/README.md)) and the unbound constant buffer 1 at frame 0 (above, the game's own).
|
||||
- The iPhone: no IPA has been built. Its 7,225 LDTRAM pixel shaders compile as MSL 4.0, which needs iOS 26.
|
||||
- The prewarm list (`pso_manifest.tsv`) is empty.
|
||||
@@ -2766,6 +2766,14 @@ void nvn_vpool_note(uint64_t a, char *note, size_t n) {
|
||||
break; }
|
||||
pthread_mutex_unlock(&g_vp_mu);
|
||||
}
|
||||
// An address in a sparse pool's reservation whose page nothing is mapped to: the GPU reads such a page as 0 and drops stores to it (a buffer bound there is the zero buffer, nvn_mtl.m)
|
||||
int nvn_vpool_unmapped(uint64_t a) {
|
||||
int r = 0; pthread_mutex_lock(&g_vp_mu);
|
||||
for (int i = 0; i < g_nvp; i++) { const struct vpool *v = g_vp[i]; uint64_t b = (uint64_t)(uintptr_t)v->base;
|
||||
if (a < b || a - b >= v->size) continue;
|
||||
const vpte *e = vpt_get(v, a - b); r = !e || !e->phys; break; }
|
||||
pthread_mutex_unlock(&g_vp_mu); return r;
|
||||
}
|
||||
static void vpt_set(struct vpool *v, uint64_t voff, uint64_t size, const uint8_t *phys) {
|
||||
uint64_t gen = atomic_fetch_add(&g_vp_gen, 1) + 1;
|
||||
g_vnote[gen % VNOTE_N].gen = gen; g_vnote[gen % VNOTE_N].lo = (uint64_t)(uintptr_t)v->base + voff; g_vnote[gen % VNOTE_N].hi = (uint64_t)(uintptr_t)v->base + voff + size;
|
||||
|
||||
+38
-5
@@ -4394,6 +4394,13 @@ static id<MTLTexture> tex_made(const tex_t *t) {
|
||||
if ([have isKindOfClass:[NvPkg class]]) { NvPkg *pk = have; return pk->view ? pk->view : pk->tex; }
|
||||
return have;
|
||||
}
|
||||
// The NVN level that level 0 of base, the host texture tex_made or tex_mtl gave for t, stands for: a sparse texture whose finer levels are not mapped is bound as the view of its levels
|
||||
// from the first mapped one on (sparse_view), so NVN level l is that view's level l - vbase. 0 for every other texture
|
||||
static unsigned tex_level_shift(const tex_t *t, id<MTLTexture> base) {
|
||||
id have = tex_get(t->serial);
|
||||
if (![have isKindOfClass:[NvPkg class]]) return 0;
|
||||
NvPkg *pk = have; return pk->view && pk->view == base ? (unsigned)pk->vbase : 0;
|
||||
}
|
||||
// NVN formats whose Metal format is the other one of an sRGB / linear pair (g_pfv_srgb) of a format's Metal format: up to 4, zero-terminated (an RGBA8 texture has RGBA8_SRGB and RGBX8_SRGB)
|
||||
static const uint8_t *srgb_twins(uint32_t f) {
|
||||
static uint8_t tw[256][5]; static dispatch_once_t once;
|
||||
@@ -6701,6 +6708,20 @@ static void pool_seen_clear(int id_) {
|
||||
if (g_seen_buf) atomic_fetch_and((_Atomic uint32_t *)g_seen_buf.contents + s_ * POOL_SEEN_WORDS + ((unsigned)id_ >> 5), ~b);
|
||||
}
|
||||
}
|
||||
// The ID now holds a texture of another type: the marks of the types shaders read it through were the old texture's, and kept they made the next walk report the new one as read
|
||||
// through them (Resident Evil 4 puts its 1x1 default texture into the IDs of the 256x256 cubes it lets go, and a 3D texture into an ID a 2D one had: "[pool-type] … read through a
|
||||
// type 5 texture pool table" the frame after, nine times over the opening). The read mark itself stays (see mtl_reg_tex); a shader that reads the new texture through a type marks it again
|
||||
static void pool_seen_retype(int id_) {
|
||||
if (id_ < 0 || id_ >= (int)(POOL_SEEN_WORDS * 32)) return;
|
||||
uint32_t b = 1u << (id_ & 31);
|
||||
for (unsigned s_ = 0; s_ < POOL_SEEN_TYPES; s_++) {
|
||||
g_seen_typed[s_][(unsigned)id_ >> 5] &= ~b;
|
||||
if (g_seen_buf) atomic_fetch_and((_Atomic uint32_t *)g_seen_buf.contents + s_ * POOL_SEEN_WORDS + ((unsigned)id_ >> 5), ~b);
|
||||
}
|
||||
}
|
||||
// The NVN target a registration is read as: its view's, if the view sets one
|
||||
static int tex_reg_target_of(const tex_t *t, const view_t *v) { return v && v->set_target ? (int)v->target : t->d.target; }
|
||||
static int tex_reg_target(const treg_t *r) { return tex_reg_target_of(&r->t, r->has_v ? &r->v : NULL); }
|
||||
void mtl_reg_tex_gone(int tid) {
|
||||
os_unfair_lock_lock(&g_rmu);
|
||||
if (tid >= 0 && tid < g_ntreg && g_treg[tid].ok) treg_gone(&g_treg[tid]);
|
||||
@@ -6721,7 +6742,7 @@ void mtl_reg_tex(int tid, const tex_t *t, const view_t *v) {
|
||||
// Ocarina of Time allocates 15-18 GB against a 909 MB budget on a 24 GB Mac, and when its streaming replaced the 17 textures of the castle town wall's material set (3-7 MB each,
|
||||
// each step registered twice, 4-5 frames apart), each registration's first read found the dummy, and the wall, the rocks and the trees drew black for one frame, twice (PR #2022).
|
||||
// A render target no pass has written stays the dummy all the same (pool_unwritten_target). A texture streamed into an ID no shader has read yet holds its stand-in until its first read (pool_stand, issue #1969)
|
||||
reg_bump(id_, 0); if (!t) pool_seen_clear(id_);
|
||||
reg_bump(id_, 0); if (!t) pool_seen_clear(id_); else if (rr->ok && tex_reg_target(rr) != tex_reg_target_of(t, v)) pool_seen_retype(id_);
|
||||
treg_unlink(id_); treg_drop_views(rr); treg_drop_stand(rr);
|
||||
rr->tt1 = 0; rr->reg_frame = atomic_load(&g_cur_frame);
|
||||
rr->ok = t != NULL; if (t) rr->t = *t; rr->has_v = v != NULL; if (v) rr->v = *v;
|
||||
@@ -6883,11 +6904,18 @@ static id<MTLTexture> tex_by_id(int tid) { // Caller holds g_rmu
|
||||
base = tex_upgrade_pfv(&rp->t, base, (MTLPixelFormat)pf);
|
||||
sg = treg_ep();
|
||||
}
|
||||
NSUInteger l0 = r.v.set_levels ? r.v.base_level : 0, nl = r.v.set_levels && r.v.nlevels ? r.v.nlevels : base.mipmapLevelCount - l0;
|
||||
if (l0 >= base.mipmapLevelCount) { RED_ONCE(109, "texture view id %d starts at mip %lu beyond %lu levels", tid, (unsigned long)l0, (unsigned long)base.mipmapLevelCount); return nil; }
|
||||
// The view's levels count from the texture's level 0, which a sparse texture's host texture may start past (tex_level_shift): Resident Evil 4's streamed 512x512 and 1024x1024
|
||||
// textures, with only their two or three smallest levels mapped, are sampled through views of levels 1 + 0 and 2 + 0, which read past the host texture's one level and were left out
|
||||
NSUInteger lb = tex_level_shift(&rp->t, base), n = base.mipmapLevelCount + lb;
|
||||
NSUInteger l0 = r.v.set_levels ? r.v.base_level : 0;
|
||||
if (l0 >= n) { RED_ONCE(109, "texture view id %d starts at mip %lu beyond %lu levels", tid, (unsigned long)l0, (unsigned long)n); return nil; }
|
||||
NSUInteger nl = r.v.set_levels && r.v.nlevels ? r.v.nlevels : n - l0;
|
||||
// A level count past the texture's levels is cut to those it has, as deko3d's Tegra descriptor writer clips the maximum level (Echoes of Wisdom: levels 1 + 7 of a seven-level texture,
|
||||
// which Metal's validation refuses)
|
||||
if (nl > base.mipmapLevelCount - l0) nl = base.mipmapLevelCount - l0;
|
||||
if (nl > n - l0) nl = n - l0;
|
||||
// Levels finer than the first mapped one are sampled from it, as the texture's own binding is (sparse_view)
|
||||
if (l0 < lb) { NSUInteger end = l0 + nl; l0 = lb; nl = end > lb ? end - lb : 1; }
|
||||
l0 -= lb;
|
||||
NSUInteger s0 = r.v.set_layers ? r.v.min_layer : 0;
|
||||
NSUInteger ns = base.textureType == MTLTextureType3D ? 1 : (r.v.set_layers && r.v.nlayers ? r.v.nlayers : base.arrayLength * (base.textureType == MTLTextureTypeCube || base.textureType == MTLTextureTypeCubeArray ? 6 : 1) - s0);
|
||||
MTLTextureType tt = r.v.set_target ? ttype(r.v.target, base.textureType) : base.textureType;
|
||||
@@ -11686,7 +11714,12 @@ static int encode_args_(id<MTLCommandEncoder> en, NvShader *sh, int nvn_stage, i
|
||||
void *mb; uint64_t mo, gpu;
|
||||
if (addr && mtl_gpu_addr(addr, 1, &mb, &mo, &gpu)) { slots[aid] = gpu; USE((__bridge id<MTLBuffer>)mb, b->rw ? MTLResourceUsageRead | MTLResourceUsageWrite : MTLResourceUsageRead); if (b->rw) sbw_note(addr, sbw_len(0, mb, mo), SBW_GPU); }
|
||||
else { slots[aid] = dummy_buf_gpu(); USE(dummy_buf(), MTLResourceUsageRead);
|
||||
if (!g_red_once[165]) { char note[400]; dm_gfx_addr_note(addr, note, sizeof note); // what is known of it: a sparse pool's page, a texture's storage
|
||||
// An unmapped page of a sparse pool's reservation reads 0 on the GPU, as the dummy does: Resident Evil 4's 0ee0c5f004239ce2 at frame 5 is pushed an address 0x4400000 into
|
||||
// a 1 GB sparse pool, on a page the game has not mapped by then. Noted once, not red; any other address is
|
||||
static int sp_noted; int nvn_vpool_unmapped(uint64_t); int sp = (!sp_noted || !g_red_once[165]) && nvn_vpool_unmapped(addr);
|
||||
if (sp && !sp_noted) { sp_noted = 1; MLOG("shader %s: the buffer address the game pushed at c[24] + %#x, %#llx, is an unmapped page of a sparse pool: bound to the zero buffer, as the GPU reads such a page as 0 (frame %llu)",
|
||||
sh->key, b->off, (unsigned long long)addr, (unsigned long long)atomic_load(&g_cur_frame)); }
|
||||
else if (!sp && !g_red_once[165]) { char note[400]; dm_gfx_addr_note(addr, note, sizeof note); // what is known of it: a sparse pool's page, a texture's storage
|
||||
RED_ONCE(165,"shader %s: the buffer address the game pushed at c[24] + %#x is %#llx, in no memory pool: bound to a dummy buffer (frame %llu;%s)", sh->key, b->off, (unsigned long long)addr, (unsigned long long)atomic_load(&g_cur_frame), note); } }
|
||||
if (bl) PD("B %llu st%d sbufq push+%#x addr=%#llx %s", g_stat_pass, nvn_stage, b->off, (unsigned long long)addr, b->rw ? "rw" : "ro");
|
||||
} else if (b->kind == NVN_RB_C1) { // B: the shader's own constant segment, built when the shader is fetched
|
||||
|
||||
@@ -126,6 +126,18 @@ int main(void) { @autoreleasepool {
|
||||
uint64_t r1 = pool_fit(10, cur, A); void *v1 = g_treg[10].palt[pool_lk(A)]; uint64_t r2 = pool_fit(10, cur, A);
|
||||
os_unfair_lock_unlock(&g_rmu);
|
||||
CHECK(r1 && r1 == r2 && g_treg[10].palt[pool_lk(A)] == v1, "the view is cached: no new view for the same texels");
|
||||
// An ID given a texture of another type: the marks of the types shaders read the old one through go, the read mark stays (Resident Evil 4 puts its 1x1 default 2D texture into
|
||||
// the IDs of cubes it lets go). Kept, the next cube table reported the 2D texture as read through it, with no shader reading it. One of the same type keeps them (the bridges stand)
|
||||
mtl_reg_tex(12, &t[5], NULL);
|
||||
CHECK(pool_seen_t(12, D2), "a 2D array replaced by a 2D array: its 2D read mark stays");
|
||||
unsigned logged = g_pool_tlog_n;
|
||||
mtl_reg_tex(14, &t[8], NULL);
|
||||
CHECK(!pool_seen_t(14, C) && !pool_seen_t(14, A) && !pool_seen_t(14, D2) && pool_seen(14), "a cube replaced by a 2D texture: its typed marks go, its read mark stays");
|
||||
id<MTLBuffer> c2 = table(C);
|
||||
CHECK(entry(c2, 14) == dummy(c2) && g_pool_tlog_n == logged, "the cube table holds the dummy for it and reports nothing: no shader read the 2D texture as a cube");
|
||||
read_mark(14, C);
|
||||
id<MTLBuffer> c3 = table(C);
|
||||
CHECK(entry(c3, 14) == dummy(c3) && g_pool_tlog_n == logged + 1 && (g_pool_tlog[0] >> 14 & 1), "a shader that does read it as a cube marks it again, and that is reported");
|
||||
// Emptying the ID lets the view go, and its typed marks
|
||||
mtl_reg_tex(10, NULL, NULL);
|
||||
CHECK(!palt(10, A) && !prid(10, A) && !pool_seen_t(10, A) && !pool_seen_t(10, D2), "an emptied ID drops its view and its read marks");
|
||||
|
||||
@@ -106,6 +106,31 @@ int main(void) { @autoreleasepool {
|
||||
pool_gpu(0, MTLTextureType2D, NVN_DPF_FLOAT, 0, &table);
|
||||
CHECK(gpu_read(table, 1) == C, "so does the pool table");
|
||||
|
||||
// Views of a sparse texture whose finest level is not mapped. Its host texture is the view of levels [1, 3) (sparse_view), and a texture view's levels count from NVN's level 0:
|
||||
// Resident Evil 4 samples its streamed textures through views of levels 1 + 0 and 2 + 0. The level 2 view started past the host texture's two levels and was left out (the
|
||||
// dummy); the level 1 view read level 2
|
||||
const uint32_t D = 0xff0a0b0c, E = 0xff0d0e0f; const uint64_t VO = 0x100000, PO = 0x80000;
|
||||
NVNtexture tm; h_nvnTextureBuilderSetDefaults(&tb);
|
||||
h_nvnTextureBuilderSetTarget(&tb, NVN_TEXTURE_TARGET_2D); h_nvnTextureBuilderSetWidth(&tb, 256); h_nvnTextureBuilderSetHeight(&tb, 256); h_nvnTextureBuilderSetLevels(&tb, 3);
|
||||
h_nvnTextureBuilderSetFormat(&tb, NVN_FORMAT_RGBA8); h_nvnTextureBuilderSetFlags(&tb, NVN_TEXTURE_FLAGS_SPARSE);
|
||||
h_nvnTextureBuilderSetStorage(&tb, (NVNmemoryPool *)&virt, VO);
|
||||
CHECK(h_nvnTextureInitialize(&tm, &tb), "sparse texture of three levels");
|
||||
const tex_t *mt = (const tex_t *)&tm;
|
||||
uint64_t l1 = nvn_tex_level_offset(&mt->d, 1), l2 = nvn_tex_level_offset(&mt->d, 2), lend = (mt->L.size + 0xFFF) & ~0xFFFull;
|
||||
CHECK(l1 && !(l1 & 0xFFF) && l2 > l1 && PO + lend - l1 <= 0x100000, "level 1 starts on a page, and levels 1 and 2 fit the physical pool");
|
||||
for (uint64_t o = l1; o < lend; o += 4) *(uint32_t *)(mem + PO + o - l1) = o < l2 ? D : E;
|
||||
CHECK(map(&virt, &phys, VO + l1, PO, lend - l1), "levels 1 and 2 mapped, level 0 not");
|
||||
view_t v1 = {.set_levels = 1, .base_level = 1}, v2 = {.set_levels = 1, .base_level = 2}, v0 = {.set_levels = 1, .base_level = 0, .nlevels = 1};
|
||||
mtl_reg_tex(2, mt, &v1); mtl_reg_tex(3, mt, &v2); mtl_reg_tex(4, mt, &v0);
|
||||
g_seen_done[0] |= 0x1c; g_seen_typed[0][0] |= 0x1c;
|
||||
next_sub();
|
||||
pool_gpu(0, MTLTextureType2D, NVN_DPF_FLOAT, 0, &table);
|
||||
CHECK(gpu_read(table, 2) == D, "a view from level 1 reads level 1");
|
||||
CHECK(gpu_read(table, 3) == E, "a view from level 2 reads level 2, not the dummy");
|
||||
CHECK(gpu_read(table, 4) == D, "a view of the unmapped level 0 reads the first mapped level, as the texture's own binding does");
|
||||
mtl_reg_tex(2, NULL, NULL); mtl_reg_tex(3, NULL, NULL); mtl_reg_tex(4, NULL, NULL);
|
||||
h_nvnTextureFinalize(&tm);
|
||||
|
||||
h_nvnTextureFinalize(&tx);
|
||||
h_nvnMemoryPoolFinalize((NVNmemoryPool *)&virt); h_nvnMemoryPoolFinalize((NVNmemoryPool *)&phys);
|
||||
mtl_sub_commit(); mtl_drain(); free(mem);
|
||||
|
||||
@@ -611,6 +611,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- `[RED] virtual pool …: more than 1024 separate mapped runs`, then a GPU hang minutes later: `[RED] the host has waited 10 s for GPU work`, an indirect dispatch of absurd size (`283343572 x 965150577 x 1006648320 groups`), and the game aborts once its 15 s `nvnSyncWait` expires. → [More than 1,024 mapped runs in a sparse pool](../reference/nvn-objects.md#more-than-1024-mapped-runs-in-a-sparse-pool)
|
||||
- in a game that maps and unmaps sparse pages while it runs: an indirect dispatch of absurd size, a GPU hang, then a crash in the game's own code reading a command list that holds another object's data. → [Pages changed under a buffer the GPU still uses](../reference/nvn-objects.md#pages-changed-under-a-buffer-the-gpu-still-uses)
|
||||
- `[RED] shader <key>: the buffer address the game pushed at c[24] + … is …, in no memory pool: bound to a dummy buffer`, once or twice in minutes, for an address inside a mapped run of a sparse pool; the draw or dispatch of that frame reads zeros. → [A sparse pool's runs replaced in two steps](../reference/nvn-objects.md#a-sparse-pools-runs-replaced-in-two-steps)
|
||||
- `[RED] shader <key>: the buffer address the game pushed at c[24] + … is …, in no memory pool: bound to a dummy buffer (…; sparse pool … (+… of … reserved, … runs): page not mapped…, in no run)`. → [A buffer address on an unmapped page of a sparse pool](../reference/nvn-objects.md#a-buffer-address-on-an-unmapped-page-of-a-sparse-pool)
|
||||
- `[RED] MapVirtual: non-contiguous mapping (true sparse) not implemented`, on small virtual pools; streamed textures black or missing (OCTOPATH TRAVELER's village ground and plants). → [Virtual pools of one texture each, mapped before and after the texture](../reference/nvn-objects.md#virtual-pools-of-one-texture-each-mapped-before-and-after-the-texture)
|
||||
- none seen in a game yet. The failure it prevents is a texture, buffer, event or command memory made on a virtual pool before its first mapping pointing into address space the host has given back (`CRASH sig=10/11` at an address in no pool, or a texture that reads nothing), once a whole-pool mapping aliases the pool. → [A virtual pool aliased after objects were made on it](../reference/nvn-objects.md#a-virtual-pool-aliased-after-objects-were-made-on-it)
|
||||
- `[RED] sampler ID 4095 not registered`, beside `texture ID 1048575 outside the pool … treated as an empty slot: reads 0`. → [Sampler IDs past the sampler pool](../reference/nvn-objects.md#sampler-ids-past-the-sampler-pool)
|
||||
@@ -629,6 +630,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- while a game streams an area in, frames of 100 ms to about 1 s with the GPU at its usual time, no new pipelines and no texture uploads in them: the `[longframe]` lines put the whole frame in `submit+present`, and a long session falls into slow motion for a minute or two at a time. In the `[nvn-mtl] memory up to frame` line, `finalized textures still referenced 512 (small table, N put in total)` stays at 512 and N jumps by millions in one report (651 to 3,669,055 in 300 frames at an area transition; 43 million in one window riding into Hyrule Field), and `deferred-release queue` reaches tens of thousands. After the same game's pause menu, which it streams behind, 50 to 55 fps for about five seconds with `[nvn] pool tables … built whole` at 1.4 to 1.6 a frame (9 ms each) and the pool line's `a new submission over too many retired IDs` counting nearly every build. → [More finalized textures in use than their table held](../reference/nvn-objects.md#more-finalized-textures-in-use-than-their-table-held)
|
||||
- a pool table keeps naming an sRGB / linear twin's view after the texture it is a view of left the sharing table and, 17 submissions later, the residency set: a texture ID with no residency behind it, which gives GPU address faults in the shaders that sample it (as in issue #1326), and a view that no longer shares its storage's bytes with anything. Seen in `t_pool_notes` only, in no game. → [A view's entry did not hold its parent](../reference/nvn-objects.md#a-views-entry-did-not-hold-its-parent)
|
||||
- surfaces that read textures by handle through a texture pool come out black or unlit. PRAGMATA: Cabin's monitor in the Shelter stays black (the console shows a cyan animated face), and every cube map read through the pool samples zero (environment reflections and light). No `[RED]` line. → [Pool tables that held only their own texture type](../reference/nvn-objects.md#pool-tables-that-held-only-their-own-texture-type)
|
||||
- `[RED] [pool-type] texture ID … (ser=… 1x1 format 0x25 target 1) is Metal type 2, read through a type 5 texture pool table: left out (dummy), no view serves it`, or a 3D texture `read through a type 2 texture pool table`, in the frame after a scene change, with a different ID each run. → [Read marks of a texture type kept when an ID changes type](../reference/nvn-objects.md#read-marks-of-a-texture-type-kept-when-an-id-changes-type)
|
||||
- the serial table grows by about 10 entries a frame (276,000 after 25,000 frames). → [Dead texture serials kept in a ghost table](../reference/nvn-objects.md#dead-texture-serials-kept-in-a-ghost-table)
|
||||
- none seen on a game. A finalized texture could resolve to an sRGB / linear view of storage that no longer held its bytes. → [A finalized twin view left in the ghost ring](../reference/nvn-objects.md#a-finalized-twin-view-left-in-the-ghost-ring)
|
||||
- none seen on a game. Windows in which a texture serial could resolve to a texture the sharing table had already let go, or two serials over one storage to two textures. → [Sharing-table lookups and registrations in separate holds](../reference/nvn-objects.md#sharing-table-lookups-and-registrations-in-separate-holds)
|
||||
@@ -761,6 +763,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
|
||||
- crashes that move between runs (30–70% of boots, in the first minute): in the allocator, on bogus pointers, in unrelated threads. Unreal's purgatory proxy (05-debugging) finds freed 64 KB-aligned blocks modified; with the parked blocks read-only, the faulting store is a `memcpy` of texture mip data from the texture streamer into the buffer `RHILockTexture2D` returned. → [Sparse textures of 8- and 16-byte blocks: blocks at most 8 GOBs high](../reference/rendering.md#sparse-textures-of-8--and-16-byte-blocks-blocks-at-most-8-gobs-high)
|
||||
- a small CPU-filled sparse texture shows part of its image beside fragments, cut off at the bottom (Yoshi's Crafted World's loading icon: the left half of a chalk drawing and two stray strokes). → [Sparse textures smaller than a tile keep the automatic block height](../reference/rendering.md#sparse-textures-smaller-than-a-tile-keep-the-automatic-block-height)
|
||||
- streamed textures read 0 (magenta on Monster Hunter Rise's title screen's clothes). → [Sparse textures bound from their first mapped level](../reference/rendering.md#sparse-textures-bound-from-their-first-mapped-level)
|
||||
- `[RED] texture view id … starts at mip 2 beyond 1 levels` (or mip 1), once per run, for a streamed texture; views from level 1 of such a texture read the level after it. → [Texture views of a sparse texture bound from a later level](../reference/rendering.md#texture-views-of-a-sparse-texture-bound-from-a-later-level)
|
||||
- textures a mip level sharper or blurrier than on the Switch where the game biases its sampler; in the Vulkan layer, a red line `sampler LOD bias … not implemented`. → [Sampler LOD bias](../reference/rendering.md#sampler-lod-bias)
|
||||
- whatever a game keeps in a texture that it samples past its edge with clamp-to-border reads the wrong value there: grass flattened along Link's path in Tears of the Kingdom, its bend map filled with "bent" wherever the window scrolled. → [Border colours Metal has no sampler state for](../reference/rendering.md#border-colours-metal-has-no-sampler-state-for)
|
||||
- material pipelines spill registers even when every sampler uses a native Metal border colour. → [Unused border corrections retain sample registers](../reference/rendering.md#unused-border-corrections-retain-sample-registers)
|
||||
|
||||
@@ -104,6 +104,13 @@ A game may tell NVN objects apart by their bytes, without an NVN call. A host re
|
||||
- **Fix:** `vrun_set` (`hle_nvn.c`) hands the runs it removes and the runs it adds to `mtl_pool_replace` (`nvn_mtl.m`), which makes the new runs' buffers first and then takes the old ones out and puts the new ones in under one hold of `g_mu`, so every lookup sees the old runs or the new.
|
||||
- **Found on:** [PRAGMATA](../../dm/games/0400C76024710000/README.md): its mesh shaders `765e6d9d2588ce70` and `5aab38bb5ba67ef7` read a buffer 0x3000000 into a sparse pool whose one run keeps growing; the miss came at frames 2971 and 4484, the frames the run was replaced in; none in a run with the fix.
|
||||
|
||||
### A buffer address on an unmapped page of a sparse pool
|
||||
|
||||
- **Symptom:** `[RED] shader <key>: the buffer address the game pushed at c[24] + … is …, in no memory pool: bound to a dummy buffer (…; sparse pool … (+… of … reserved, … runs): page not mapped…, in no run)`.
|
||||
- **Cause:** none in the host. The game pushes the address of a page in a sparse pool's reservation that it has not mapped (Resident Evil 4's `0ee0c5f004239ce2` at frame 5, 0x4400000 into a 1 GB pool where nothing is mapped there yet; a diagnostic host logged every mapping request before it). The GPU reads an unmapped sparse page as 0 and drops stores to it, and the host binds the zero buffer.
|
||||
- **Fix:** the case is noted once without `[RED]` (`unmapped page of a sparse pool: bound to the zero buffer`, `hle_nvn.c` `nvn_vpool_unmapped`); an address in no pool and no reservation is still red. The zero buffer is shared and 64 KB: a store through it is kept, not dropped (no game is known to store there).
|
||||
- **Found on:** [Resident Evil 4](../../dm/games/0400569027BF4000/README.md).
|
||||
|
||||
### Virtual pools of one texture each, mapped before and after the texture
|
||||
|
||||
- **Symptom:** `[RED] MapVirtual: non-contiguous mapping (true sparse) not implemented`, on small virtual pools; streamed textures black or missing (OCTOPATH TRAVELER's village ground and plants).
|
||||
@@ -264,6 +271,14 @@ A game may tell NVN objects apart by their bytes, without an NVN call. A host re
|
||||
- **Check:** `make -C dm/gfx/tests GAME=<id> check_t_pool_typebridge`: each pair, read on the GPU through the table at a given layer or face; an ID read only through its own type gets no view; an ID read later through a second type goes into that table in place; a table's view of an ID stays when a table of a third type takes the ID; the view is kept and goes when the ID is emptied; the unserved reads are reported once. Without the bridge 10 of its 32 checks fail; with one view per ID for every type, 2. In play, PRAGMATA's Shelter on the Mac: Cabin's face and the reflections match the console.
|
||||
- **Found on:** [PRAGMATA](../../dm/games/0400C76024710000/README.md).
|
||||
|
||||
### Read marks of a texture type kept when an ID changes type
|
||||
|
||||
- **Symptom:** `[RED] [pool-type] texture ID … (ser=… 1x1 format 0x25 target 1) is Metal type 2, read through a type 5 texture pool table: left out (dummy), no view serves it`, or a 3D texture `read through a type 2 texture pool table`, in the frame after a scene change, with a different ID each run.
|
||||
- **Cause:** the read bitmap's sections (see [Pool tables that held only their own texture type](#pool-tables-that-held-only-their-own-texture-type)) are an ID's, and stayed when the game put a texture of another type into the ID. The marks were the old texture's: the next walk found the new texture marked as read through the old one's type and reported it, though no shader had read it so. Resident Evil 4 puts its 1x1 default 2D texture into the IDs of the 256x256 cubes it lets go, and a 3D texture into an ID a 2D texture had; a diagnostic host showed every report in the frame after such a change, with only the old type's mark set.
|
||||
- **Fix:** `mtl_reg_tex` clears an ID's typed marks, on the host and in the GPU's bitmap, when it registers a texture of another NVN target (the view's, if it sets one) there (`pool_seen_retype`). The read mark itself stays, for the read budget (PR #2022), and so do the typed marks when the type is the same, which keeps the bridges of a game that cycles textures of one type through its IDs. A shader that does read the new texture through another type marks it again, and that is reported.
|
||||
- **Check:** `make -C dm/gfx/tests GAME=<id> check_t_pool_typebridge`: a cube replaced by a 2D texture loses its typed marks and keeps its read mark; the cube table then holds the dummy and reports nothing; a cube read of it after that is reported; a 2D array replaced by another keeps its 2D mark. Without the fix 2 of its 40 checks fail. Resident Evil 4's opening to the forest path on the Mac (Apple M6, 2026-11-13): nine such lines before, none after.
|
||||
- **Found on:** [Resident Evil 4](../../dm/games/0400569027BF4000/README.md).
|
||||
|
||||
### Memory-pool tracking table grows in blocks
|
||||
|
||||
- **Cause:** the memory-pool tracking table had a fixed 4,096 slots; a pool past the end would have its textures re-uploaded at every use.
|
||||
|
||||
@@ -287,6 +287,14 @@ The replay on Metal (`dm/gfx/nvn/nvn_mtl.m`) and the Vulkan and OpenGL layers. E
|
||||
- **Fix:** a sparse texture is bound as a view starting at its first level whose pages, and those of every smaller level, are all mapped (`sparse_view` in `nvn_mtl.m`). That samples exactly as a minimum LOD would; the view follows each upload.
|
||||
- **Found on:** [Monster Hunter Rise](../../dm/games/0100B04011742000/README.md).
|
||||
|
||||
### Texture views of a sparse texture bound from a later level
|
||||
|
||||
- **Symptom:** `[RED] texture view id … starts at mip 2 beyond 1 levels` (or mip 1), once per run, for a streamed texture; views from level 1 of such a texture read the level after it.
|
||||
- **Cause:** a sparse texture is bound as the view of its levels from the first mapped one on ([Sparse textures bound from their first mapped level](#sparse-textures-bound-from-their-first-mapped-level)), so its host texture's level 0 is NVN level `vbase`. A texture view's levels count from NVN's level 0, and `tex_by_id` took them as the host texture's: a view from a level past the host texture's levels was left out (an empty slot), and one from an earlier level read a smaller one. Resident Evil 4 samples its streamed 512x512 and 1024x1024 textures, with only their two or three smallest levels mapped as the title loads, through views of levels 1 + 0 and 2 + 0 (30 such views at frame 1530, all of them sparse).
|
||||
- **Fix:** `tex_by_id` counts the view's levels from NVN's level 0 (`tex_level_shift`) and samples levels finer than the first mapped one from it, as the texture's own binding does.
|
||||
- **Check:** `make -C dm/gfx/tests GAME=<id> check_t_sparse_pool_cache`: a three-level sparse texture with level 0 unmapped, read on the GPU through views from levels 1, 2 and 0. Without the fix the first two fail (the level 1 view reads level 2, the level 2 view the dummy). Resident Evil 4's opening to the forest path on the Mac (Apple M6, 2026-11-13): no such line.
|
||||
- **Found on:** [Resident Evil 4](../../dm/games/0400569027BF4000/README.md).
|
||||
|
||||
### Sampler reduction (min / max)
|
||||
|
||||
- **Cause:** a sampler built with `SamplerBuilderSetReductionFilter` (min / max) was averaged by the host. Metal 26 has the same thing (`MTLSamplerDescriptor.reductionMode`), but ignores it with a nearest or no mip filter.
|
||||
@@ -1437,7 +1445,7 @@ The replay on Metal (`dm/gfx/nvn/nvn_mtl.m`) and the Vulkan and OpenGL layers. E
|
||||
- **Symptom:** `stage 0 cb5 has no uniform buffer bound` (or another stage and slot, such as `stage 0 cb0`), once per run.
|
||||
- **Cause:** the argument buffer kept a null pointer for the unbound slot. The game draws with nothing bound there; the host misses no bind. What the Switch reads from an unbound slot is not known.
|
||||
- **Fix:** the slot now reads the all-zero bank, as an unbound texture slot reads the zero texture.
|
||||
- **Found on:** [Paper Mario: The Thousand-Year Door](../../dm/games/0100ECD018EBE000/README.md) (at the title); [Batman: Arkham Knight](../../dm/games/0100ACD0163D0000/README.md#files-and-shaders) (`stage 0 cb0`, at boot: the first command buffer draws before the game has bound any uniform buffer).
|
||||
- **Found on:** [Paper Mario: The Thousand-Year Door](../../dm/games/0100ECD018EBE000/README.md) (at the title); [Batman: Arkham Knight](../../dm/games/0100ACD0163D0000/README.md#files-and-shaders) (`stage 0 cb0`, at boot: the first command buffer draws before the game has bound any uniform buffer); [Resident Evil 4](../../dm/games/0400569027BF4000/README.md) (`stage 5 cb1`, frame 0).
|
||||
- **Check:** a pass dump of the frame (`DM_NVN_PASSDUMP=<frame>`, frame 0 for the boot) shows the draw (`j` line) and its stage's `K` line with no `B … cb` line, and the frame's `[nvn]` call counts show whether the game called `CommandBufferBindUniformBuffer` at all.
|
||||
|
||||
### Compute dispatches share the copy encoder
|
||||
|
||||
Reference in new issue
Block a user