play-nvidia: an eight-byte qwMemorySize is decoded, not cast (D3D12-VRAM-BYTES) #3279

Merged
OreoFR merged 2 commits from upstream-pr/3279 into main 2026-12-03 02:52:24 +00:00
OreoFR commented 2026-12-03 02:08:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-03T02:08:40Z.


Item: D3D12-VRAM-BYTES (claimed in #2570). Comes from @merzleckeier's review on #3272.

What changes

play-nvidia.ps1's $vram is the largest HardwareInformation.qwMemorySize of the display class. The script cast that value straight to [uint64]. Some drivers write it as eight little-endian bytes (REG_BINARY): the cast then threw inside the walk's single try, and the walk stopped at that adapter.

Under the Series X 20 GB rule for frame generation with ray tracing, this gave the wrong answer twice. The launcher's card_facts decodes the bytes, so it said the opposite each time:

  • an 8 GB card written as bytes kept 2x;
  • an integer 8 GB adapter followed by a 24 GB one in bytes left frame generation off.

The fix:

  • A byte array of eight or more bytes is now decoded with [BitConverter]::ToUInt64($q, 0).
  • Each adapter has its own try, so an odd value skips that adapter only, not the rest of the walk.

Tested

Windows 11, Windows PowerShell 5.1. Script only, no game run.

  • test_nvidia_frame_generation_with_ray_tracing: the registry stub now takes several adapters, each an integer or a byte array. Four new cases:
    • 8 GB as bytes: off;
    • 24 GB as bytes: kept;
    • integer 8 GB + 24 GB in bytes: kept;
    • 24 GB in bytes + integer 8 GB: kept.
  • python -m unittest discover -s tests -p test_win_launchers.py: 11 tests OK.
  • Counter-test: the new test on main's unpatched script fails exactly as merzleckeier reported (8 GB in bytes keeps 2x; integer 8 GB + 24 GB in bytes leaves it off).
  • tests/test_text_write_line_endings.py OK; scripts/check_no_game_data.py on both files OK.
  • PowerShell 7 is not installed here. merzleckeier checked the same decode in 7.4.21 on a disposable copy.

AI-assisted (oreofr-agent, Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5618408857 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3279). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-03T02:08:40Z. --- Item: **D3D12-VRAM-BYTES** (claimed in #2570). Comes from @merzleckeier's review on #3272. ## What changes `play-nvidia.ps1`'s `$vram` is the largest `HardwareInformation.qwMemorySize` of the display class. The script cast that value straight to `[uint64]`. Some drivers write it as eight little-endian bytes (REG_BINARY): the cast then threw inside the walk's single `try`, and the walk stopped at that adapter. Under the Series X 20 GB rule for frame generation with ray tracing, this gave the wrong answer twice. The launcher's `card_facts` decodes the bytes, so it said the opposite each time: - an 8 GB card written as bytes kept 2x; - an integer 8 GB adapter followed by a 24 GB one in bytes left frame generation off. The fix: - A byte array of eight or more bytes is now decoded with `[BitConverter]::ToUInt64($q, 0)`. - Each adapter has its own `try`, so an odd value skips that adapter only, not the rest of the walk. ## Tested Windows 11, Windows PowerShell 5.1. Script only, no game run. - `test_nvidia_frame_generation_with_ray_tracing`: the registry stub now takes several adapters, each an integer or a byte array. Four new cases: - 8 GB as bytes: off; - 24 GB as bytes: kept; - integer 8 GB + 24 GB in bytes: kept; - 24 GB in bytes + integer 8 GB: kept. - `python -m unittest discover -s tests -p test_win_launchers.py`: 11 tests OK. - **Counter-test:** the new test on main's unpatched script fails exactly as merzleckeier reported (8 GB in bytes keeps 2x; integer 8 GB + 24 GB in bytes leaves it off). - `tests/test_text_write_line_endings.py` OK; `scripts/check_no_game_data.py` on both files OK. - PowerShell 7 is not installed here. merzleckeier checked the same decode in 7.4.21 on a disposable copy. AI-assisted (oreofr-agent, Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ecox982745 commented 2026-12-03 02:11:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-12-03T02:11:31Z.


I reran the eleven synthetic VRAM budget cases from #2600 on main at d15e048a and this PR at beb14940. Both Windows PowerShell 5.1 and PowerShell 7 went from 6/11 to 9/11. Binary 4 GiB now correctly omits both memory budgets, and a short byte array no longer prevents a later valid adapter from being counted.

Two cases still stop the scan before the sole usable 4 GiB reading. A terminating property-read error occurs outside the per-adapter try, and Get-ChildItem with ErrorAction Stop terminates on a nonterminating enumeration error. Both cases leave VRAM unknown and emit the 1,536 MiB card-buffer and 3,072 MiB window budgets.

In a disposable copy of this head, I moved Get-ItemProperty into the per-adapter try with ErrorAction Stop and used ErrorAction SilentlyContinue for the class enumeration. The existing decode and size policy stayed intact. All 11 cases passed in each shell. These were launcher dry runs with simulated registry entries and no game or GPU workload. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365186112 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3279#issuecomment-7365186112). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-12-03T02:11:31Z. --- I reran the eleven synthetic VRAM budget cases from #2600 on main at d15e048a and this PR at beb14940. Both Windows PowerShell 5.1 and PowerShell 7 went from 6/11 to 9/11. Binary 4 GiB now correctly omits both memory budgets, and a short byte array no longer prevents a later valid adapter from being counted. Two cases still stop the scan before the sole usable 4 GiB reading. A terminating property-read error occurs outside the per-adapter try, and Get-ChildItem with ErrorAction Stop terminates on a nonterminating enumeration error. Both cases leave VRAM unknown and emit the 1,536 MiB card-buffer and 3,072 MiB window budgets. In a disposable copy of this head, I moved Get-ItemProperty into the per-adapter try with ErrorAction Stop and used ErrorAction SilentlyContinue for the class enumeration. The existing decode and size policy stayed intact. All 11 cases passed in each shell. These were launcher dry runs with simulated registry entries and no game or GPU workload. AI-assisted with OpenAI Codex.
merzleckeier commented 2026-12-03 02:16:37 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T02:16:37Z.

Review: COMMENTED


Verified beb14940 together with #3272 at db005c43 on d15e048a. The two launcher suites had 110 passes and seven skips with PowerShell 7.7.0 on Linux. For integer or eight-byte VRAM readings, the desktop Settings and the actual PowerShell dry run agree, including one byte below the Series X 20 GiB cutoff, the exact cutoff, and 8 GiB integer followed by 24 GiB binary.

There is a separate parity gap for malformed values. card_memory() accepts short byte arrays and rejects arrays longer than eight bytes and numeric strings. The new PowerShell branch reads the first eight bytes of a longer array, skips short arrays, and still casts numeric strings. For an 8 GiB reading encoded in five bytes the UI greys 2x and PLAY keeps it. For the same value in nine bytes or as a numeric string the UI enables 2x and PLAY drops it. The disagreement also showed up with a valid 8 GiB entry followed by a short or long 24 GiB entry. A disposable variant that treated only integral values and exactly eight binary bytes as VRAM made both paths agree in all eleven cases. The registry values were synthetic. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6162561675 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3279#pullrequestreview-6162561675). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T02:16:37Z. **Review:** COMMENTED --- Verified `beb14940` together with #3272 at `db005c43` on `d15e048a`. The two launcher suites had 110 passes and seven skips with PowerShell 7.7.0 on Linux. For integer or eight-byte VRAM readings, the desktop Settings and the actual PowerShell dry run agree, including one byte below the Series X 20 GiB cutoff, the exact cutoff, and 8 GiB integer followed by 24 GiB binary. There is a separate parity gap for malformed values. `card_memory()` accepts short byte arrays and rejects arrays longer than eight bytes and numeric strings. The new PowerShell branch reads the first eight bytes of a longer array, skips short arrays, and still casts numeric strings. For an 8 GiB reading encoded in five bytes the UI greys 2x and PLAY keeps it. For the same value in nine bytes or as a numeric string the UI enables 2x and PLAY drops it. The disagreement also showed up with a valid 8 GiB entry followed by a short or long 24 GiB entry. A disposable variant that treated only integral values and exactly eight binary bytes as VRAM made both paths agree in all eleven cases. The registry values were synthetic. AI-assisted with OpenAI Codex.
OreoFR commented 2026-12-03 02:20:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-03T02:20:59Z.


Thanks @merzleckeier and @ecox982745. Both are addressed in 7809f10bf.

  • Parity on malformed values. The script and the launcher's card_memory now read only an integer (REG_QWORD/REG_DWORD) or exactly eight little-endian bytes. A shorter or longer array, or a string, is no size on both sides.
  • One bad adapter skips only itself:
    • Get-ItemProperty now runs with -ErrorAction Stop inside the per-adapter try, so a terminating read error skips that adapter;
    • the class is listed with -ErrorAction SilentlyContinue, then walked with a foreach, so a listing error no longer ends the walk.

Seven new dry-run cases:

  • 5-byte, 9-byte and string values;
  • an 8 GB integer followed by a 5-byte or a 9-byte 24 GB value;
  • an adapter whose read throws, before an 8 GB adapter;
  • a listing that reports an error, before an 8 GB adapter.

card_memory's test also gains the 5-byte and 9-byte arrays.

Results:

  • tests/test_win_launchers.py: 11 OK in Windows PowerShell 5.1.
  • tests/test_leonida_launcher.py: OK.
  • Counter-test: on beb149402 the 9-byte, string, 8 GB + 9-byte, throwing-adapter and listing-error cases fail.
  • PowerShell 7 is not installed here.

(oreofr-agent, AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365364861 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3279#issuecomment-7365364861). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-03T02:20:59Z. --- Thanks @merzleckeier and @ecox982745. Both are addressed in 7809f10bf. - **Parity on malformed values.** The script and the launcher's `card_memory` now read only an integer (REG_QWORD/REG_DWORD) or exactly eight little-endian bytes. A shorter or longer array, or a string, is no size on both sides. - **One bad adapter skips only itself:** - `Get-ItemProperty` now runs with `-ErrorAction Stop` inside the per-adapter `try`, so a terminating read error skips that adapter; - the class is listed with `-ErrorAction SilentlyContinue`, then walked with a `foreach`, so a listing error no longer ends the walk. Seven new dry-run cases: - 5-byte, 9-byte and string values; - an 8 GB integer followed by a 5-byte or a 9-byte 24 GB value; - an adapter whose read throws, before an 8 GB adapter; - a listing that reports an error, before an 8 GB adapter. `card_memory`'s test also gains the 5-byte and 9-byte arrays. Results: - `tests/test_win_launchers.py`: 11 OK in Windows PowerShell 5.1. - `tests/test_leonida_launcher.py`: OK. - Counter-test: on beb149402 the 9-byte, string, 8 GB + 9-byte, throwing-adapter and listing-error cases fail. - PowerShell 7 is not installed here. (oreofr-agent, AI-assisted)
merzleckeier commented 2026-12-03 02:23:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T02:23:07Z.


Rechecked 7809f10b with #3272 at 6d9a22f5 on d15e048a. Settings and PowerShell agreed in all eleven cases, including the five previously divergent ones. The launcher suites had 110 passes and seven skips with PowerShell 7.7.0 on Linux, including the new synthetic registry-error cases.

Merge-order note: the two PRs now conflict only in tests/test_leonida_launcher.py. Keeping #3272’s tests and adding #3279’s two short/long-array assertions resolves the conflict. The results above are from that locally resolved tree. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365403067 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3279#issuecomment-7365403067). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T02:23:07Z. --- Rechecked `7809f10b` with #3272 at `6d9a22f5` on `d15e048a`. Settings and PowerShell agreed in all eleven cases, including the five previously divergent ones. The launcher suites had 110 passes and seven skips with PowerShell 7.7.0 on Linux, including the new synthetic registry-error cases. Merge-order note: the two PRs now conflict only in `tests/test_leonida_launcher.py`. Keeping #3272’s tests and adding #3279’s two short/long-array assertions resolves the conflict. The results above are from that locally resolved tree. AI-assisted with OpenAI Codex.
fiestorra commented 2026-12-03 02:26:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T02:26:36Z.


VERIFY-3279 — Windows nativo: la decodificación muerde, y es el caso que pedí

Corrí las dos suites que toca, en el head (7809f10bf):

tests/test_leonida_launcher.py     Ran 87 tests — OK
tests/test_win_launchers.py        Ran 11 tests — OK   (6 subtests)

Control (sintético): quité la decodificación — la línea if ($q -is [byte[]]) { $q = … [BitConverter]::ToUInt64($q, 0) … } sustituida por un comentario — y volví a correr:

pytest tests/test_win_launchers.py -q
  1 failed, 10 passed, 6 subtests passed
  AssertionError: {'S-8…': 'fg=2 with_rt=1', 'X-16': 'fg=2 with_rt=1', '[' …

Muerde, y muerde en la tabla de casos — el test compara un diccionario de perfiles contra lo que el dry run dice de cada uno, así que el control no rompe una aserción sino la tabla entera, que es lo que se quiere de un caso de representación.

Y es exactamente lo que merzleckeier describió en #3272 — "decoding the eight-byte value with [BitConverter]::ToUInt64($q, 0) before the cast made both cases agree" — con la diferencia de que aquí está en el script y probado, en vez de en una copia desechable. Las dos formas que él enumeró (sólo ocho bytes, y entero seguido de ocho bytes) están en la tabla, y el caso del adaptador que lanza al leer el registro ($global:listError, Write-Error 'Requested registry access is not allowed.') también, que es el que evita que un adaptador raro se lleve el recorrido entero.

Lo que no probé: el registro de verdad — el test sustituye Get-CimInstance y el registro por funciones de prueba, así que lo verificado es que el script decodifica lo que le dan y que la tabla de perfiles cuadra, no que un driver concreto escriba esos ocho bytes en esta máquina.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365465792 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3279#issuecomment-7365465792). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T02:26:36Z. --- ## VERIFY-3279 — Windows nativo: la decodificación muerde, y es el caso que pedí **Corrí las dos suites que toca, en el head (`7809f10bf`)**: ``` tests/test_leonida_launcher.py Ran 87 tests — OK tests/test_win_launchers.py Ran 11 tests — OK (6 subtests) ``` **Control (sintético)**: quité la decodificación — **la línea `if ($q -is [byte[]]) { $q = … [BitConverter]::ToUInt64($q, 0) … }` sustituida por un comentario** — y volví a correr: ``` pytest tests/test_win_launchers.py -q 1 failed, 10 passed, 6 subtests passed AssertionError: {'S-8…': 'fg=2 with_rt=1', 'X-16': 'fg=2 with_rt=1', '[' … ``` **Muerde, y muerde en la tabla de casos** — **el test compara un diccionario de perfiles contra lo que el dry run dice de cada uno**, **así que el control no rompe una aserción sino la tabla entera**, **que es lo que se quiere de un caso de representación.** **Y es exactamente lo que merzleckeier describió en `#3272`** — *"decoding the eight-byte value with `[BitConverter]::ToUInt64($q, 0)` before the cast made both cases agree"* — **con la diferencia de que aquí está en el script y probado, en vez de en una copia desechable.** **Las dos formas que él enumeró (sólo ocho bytes, y entero seguido de ocho bytes) están en la tabla**, **y el caso del adaptador que lanza al leer el registro (`$global:listError`, `Write-Error 'Requested registry access is not allowed.'`) también**, **que es el que evita que un adaptador raro se lleve el recorrido entero.** **Lo que no probé**: **el registro de verdad** — **el test sustituye `Get-CimInstance` y el registro por funciones de prueba**, **así que lo verificado es que el script decodifica lo que le dan y que la tabla de perfiles cuadra**, **no que un driver concreto escriba esos ocho bytes en esta máquina.** Written with an AI assistant.
OreoFR commented 2026-12-03 02:43:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-03T02:43:12Z.


Merging (OreoFR's OK): head 7809f10bf on main d15e048a7, CI green on all six checks, the review findings of merzleckeier and ecox982745 addressed in 7809f10bf. Sent to the merge queue. (oreofr-agent, AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365786407 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3279#issuecomment-7365786407). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-03T02:43:12Z. --- Merging (OreoFR's OK): head `7809f10bf` on main `d15e048a7`, CI green on all six checks, the review findings of merzleckeier and ecox982745 addressed in 7809f10bf. Sent to the merge queue. (oreofr-agent, AI-assisted)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3279
No description provided.