Repository navigation
alias_take_over notes the sRGB / linear twins' serials when it evicts their parent (fixes #2125) - #2323
Open
dean0396 wants to merge 1 commit into
Open
alias_take_over notes the sRGB / linear twins' serials when it evicts their parent (fixes #2125)#2323dean0396 wants to merge 1 commit into
dean0396 wants to merge 1 commit into
Conversation
…keover evicts the texture its view was made of: since PR seedds#1489 (0c7e88b) alias_take_over records the eviction as ser_note(0), which names none of the twin's IDs, so they kept the cached view on the fast path (tex_fast_rid) and the pool tables, patched or built whole, kept its resource ID, while the parent left the sharing table and, once the takeover's submission completed, the residency set (issue seedds#2125). The stale-view check in tex_mtl_ that the takeover's comment relied on ran only when something named the twin's texture object (a render target, a copy, a clear); before seedds#1489 the takeover's bare g_ser_gen++ sent every ID there. tex_mtl_'s twin path now lists the serial that took the view against its parent (g_twin_par, up to 8, under g_smu), only after checking under the same lock that the parent is still the sharing table's entry for its key; otherwise a takeover on another thread (tex_mtl_ also runs on the present thread and in mtl_read_texels) evicted it in between and found no list, so the view is dropped and the key looked up again. alias_take_over notes each listed serial of a texture it evicts, before alias_del removes its entry, so only those IDs take the slow path, where tex_mtl_ finds the view stale, and the tables are patched for them alone. A list that fills drops its finalized serials (a retired ID's view goes at the submission's end anyway), and one still full of live serials makes the takeover's bump a bare g_ser_gen++. alias_del, which 352e4a6 (PR seedds#2229) made the sharing table's one remover, drops the list of what it removes, so a pool's release (mtl_alias_drop_pool, whose bump already has no note) drops it too; the format-view upgrade, which replaces the texture in place and bumps with no note, drops it and lists the asking serial again for the view it makes on the upgraded texture. The reference entry (A storage takeover notes the serials of an sRGB / linear twin of what it evicts) says so. t_pool_notes's twin case (IDs 7 / 8 / 9) passed only because the note of ID 8's first resolution took ID 8 again in the takeover's walk: it now takes one walk between the two, as the issue proposes, which fails 2 of 83 checks on the old code, and its checks move one walk later, since the takeover's notes reach the walk after it; it keeps ID 8's first entry instead of reading that table's buffer again, which is used again once its submission completes. A new twin list case checks that a list that fills drops its finalized serials (only the live twin is noted) and that one full of live serials makes the bump bare. Checked on 352e4a6 and, after a rebase onto 8b55ebb (shader build tools and docs only), t_pool_notes, t_alias_takeover and t_feedback again there; M3 Max, macOS 26.7.2: t_pool_notes 119 checks, 0 failed, three runs (the twin case alone fails 2 of 83 on unmodified 352e4a6, three runs; taking the twins' notes out of alias_take_over fails 3, the bare-bump fallback 1); t_alias_takeover 45 checks and t_image_alias 337 with and without the encoder thread, 0 failed; make -k -C dm/gfx/tests GAME=0400486024DEC000 run: every test passes but, in some runs, t_feedback's check "with nothing running: a commit" (1 of 278), which fails as often on unmodified main and is unrelated (t_refl and t_rt_range_ro skip the reflection samples this Mac does not have); docs_symptoms.py --check; test_docs; the Mac host builds with main's 58 warnings. Not run: a game (no visible symptom is known, and Ocarina of Time, the only game on this Mac, was not built on main), regress.py (the reach is takeovers of a texture an sRGB / linear twin was made of), iOS
Contributor
Author
|
Rebased onto main (8b55ebb) now that #2229's cell index has landed (352e4a6). The conflict was in the eviction loops, which 352e4a6 replaced with What changed in the resolution:
Checked on 352e4a6, and again on 8b55ebb after the rebase (
No game run, as before. I've updated the description to match. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Fixes #2125.
When a storage takeover (
alias_take_over) evicts a shared texture that an sRGB / linear twin's view was made of (tex_mtl_'ssrgb_twinspath), the twin's texture IDs keep that view. Since #1489 the takeover recordsser_note(0), and that note names none of the twin's IDs. So they stay on the fast path (tex_fast_rid), and the pool tables, patched or built whole, keep the view's resource ID. Meanwhile the parent leaves the sharing table and, once the takeover's submission completes, the residency set. The stale-view check intex_mtl_that the takeover's comment relies on only runs when something names the twin's texture object (a render target, a copy, a clear). Before #1489, the takeover's bareg_ser_gen++sent every ID there.The change, all in
nvn_mtl.m, ported from my fork, where the code around it is different:g_twin_parmaps each shared texture a twin view was made of to the serials that took one (up to 8, underg_smu).tex_mtl_'s twin path adds the serial only after checking, under that lock, that the parent is still the sharing table's entry for its key. Otherwise a takeover on another thread could have evicted it in between and found no list. In that case the view is dropped and the key looked up again (twice at most).alias_take_overnotes each listed serial of a texture it evicts, just beforealias_delremoves its entry. Only those IDs take the slow path,tex_mtl_finds the view stale, and the tables are patched for just those IDs.g_ser_gen++, which builds every table whole, as before A pool table takes again only the IDs a change reaches instead of being walked whole: registrations, memory pool changes, retired IDs at a new submission and storage takeovers each leave a note #1489.alias_del, which 352e4a6 made the sharing table's one remover, drops the list of what it removes. So a pool's release (mtl_alias_drop_pool, whose bump already has no note) drops it too. The format-view upgrade replaces the texture in place and already bumps with no note: it drops the list and lists the asking serial again for the view it makes on the upgraded texture.I haven't seen a visible symptom of this on main. It was found by reading the code and shown with the test below.
Checked
t_pool_notes119/0,t_alias_takeover45/0 andt_feedback278/0 were re-run there):t_pool_notes: the twin case (IDs 7 / 8 / 9) passed only because the note from ID 8's first resolution took ID 8 again in the takeover's walk. It now takes one moretable()walk between the two, as in the issue. With that, unmodified main fails 2 of 83 checks (ID 8 keeps the view, and the patched table names it), three runs out of three. The case's checks move one walk later, because the takeover happens inside a walk and its notes reach the next one. It also keeps ID 8's first entry instead of readingb15again: with the extra walks, that buffer is reused by the time of the check.alias_take_overfails 3 checks, and taking the bare-bump fallback out fails 1.t_alias_takeoverpasses (45 checks), and so doest_image_aliaswith and without the encoder thread (337 checks each).make -k -C dm/gfx/tests GAME=0400486024DEC000 run: everything passes except, in some runs,t_feedback's check "with nothing running: a commit" (1 of 278), which fails just as often on unmodified main and has nothing to do with this change.t_reflandt_rt_range_roskip the checks that need reflection samples, which this Mac doesn't have.test_docspasses, anddocs_symptoms.py --checkreports the index current.make -C dm/host GAME=0400486024DEC000) builds with the same 58 warnings as main.regress.py: no report, for the same reason. The change only reaches takeovers of a texture an sRGB / linear twin was made of: with no list, nothing changes.Overlapping PRs
alias_del, which a pool's release uses too. So the list is dropped inalias_del, and the takeover notes it just before callingalias_del. How candidates are chosen doesn't matter to this change: it only changes what is noted once a texture is evicted. The twin path intex_mtl_is unchanged by 352e4a6.alias_let_go, which the takeover and its new idle sweep share. It already conflicts with main inalias_take_over's candidate loop since 352e4a6. On this branch it also conflicts in the takeover's comment (2 conflicts innvn_mtl.m; its other conflicts are the same as with main). Whichever lands second has to keep the takeover noting the evicted textures' lists beforealias_let_goremoves them. Ifalias_let_goremoves them throughalias_del, the list is dropped there. The sweep's bump is already bare, and it keeps a view's parent anyway. I'm happy to rebase this one on it.nvn-objects.mdand a line at the same place indocs/agents/symptoms.md, so the two conflict there (one hunk in each file, docs only; both entries stay).Docs
docs/reference/nvn-objects.md(A storage takeover notes the serials of an sRGB / linear twin of what it evicts), linked from the takeover bullet of "Pool tables patched instead of built whole" and from the sRGB / linear pair entry inrendering.md.python3 dm/tools/docs_symptoms.pywas run.