nvnCommandBufferReportValue has no handler, so the report words it should write are never written #1513

Open
opened 2026-11-18 01:46:13 +00:00 by mooki · 1 comment
Member

Type: correctness · Area: NVN host layer, conditional rendering · Part of: #1493

TL;DR

The NVN call nvnCommandBufferReportValue has no handler in the port. When the game calls it, the host logs one line, answers 0 and records nothing, so the report word the console would have written keeps its old contents. Conditional rendering compares two such words, so a missing write can switch a clear or a draw on or off wrongly and change pixels. We propose to record the call and write the value and a timestamp when the replay reaches it, the way report counters are written today.

Breakdown

  • Who it affects: any scene where the game reaches one of its ReportValue calls. The game calls it from several places (12 in the study). Whether a given scene reaches one has not been counted in a run yet.
  • What is wrong: the call has no entry in the host's NVN table. It falls to the "not implemented" stub, which does nothing. The report word that should hold the value is never written.
  • What the console does: it writes the 32-bit value at the start of the 16-byte report at the given address and a timestamp into the second half. The write is in command order, after earlier work.
  • What we propose: record the call, and write the same 16 bytes when the replay reaches it. Same pass and same ordering rules as nvnCommandBufferReportCounter.
  • What does not change: report counters, nvnCommandBufferResetCounter, the conditional-render compare itself, the fixed samples-passed value, and every call that already has a handler.
  • How we would prove it: a game-free test that fails today (no handler, nothing written), then one game run where the "not implemented" log line is present before and absent after, with the compared words shown by the replay dump.

Evidence

Port code is on forge/main at 310e7c9df. Nothing here was run in a game.

What the port does today

  • gpu/render/nvn_api.h:1678 is the only mention of ReportValue: a function pointer type. There is no handler in host/nvn_native.c and no entry in its proc table (nvnCommandBufferReportCounter is entry :3004).
  • A proc with no handler gets the stub at host/nvn_native.c:3214-3236: the first call logs nvn: <name> is not implemented: answered 0, every call answers 0, and the game goes on. With HOS_NVN_STRICT=1 the game stops instead. The stub is handed out at :3258-3266.
  • Report counters are handled. host/nvn_native.c:1852-1866 records them. gpu/vk/vk_replay.cpp:1534-1580 writes the 16-byte report ({count, timestamp}) into guest memory in stream order, "not on the GPU timeline", because conditional rendering reads those words (:1568-1572).
  • Conditional rendering compares the counter at the address with the counter at address + 16: host/nvn_native.c:1990-2006, replay at gpu/vk/vk_replay.cpp:1855-1878. The comments there describe how some games gate clears with it: the CPU writes 1 to ask for a clear, and a report written after the clear resets the word. A game that resets or sets such a word with ReportValue instead would need that write too.

What the console does (behaviour only)

  • nvnCommandBufferReportValue(cmdbuf, value, address) writes the value into the first four bytes of the 16-byte report (the low half of the counter field) and a timestamp into the second half (the timestamp field), in command order once the GPU reaches it. It writes the whole 16-byte report and no other memory. What the other four bytes of counter hold is not established by the study; the GPU's report layout puts zero there [inference, not run].

This comes from a private study of the console driver (read, then confirmed by running the driver's functions alone in an emulator); no code, addresses or game data from it are here.

Can it change pixels? Yes, by reasoning, not seen in a run. If the game uses ReportValue to set or reset a word that a later nvnCommandBufferSetRenderEnableConditional compares, a dropped write leaves the old value, and the compare can come out the other way. Then a clear or a draw that should run is skipped, or one that should be skipped runs. We would see it as a changed compare in the replay dump (vk: dump-op ... RENDER_COND mode N at <addr>: x vs y: on/off) and as a changed picture in a paired image compare. If no scene ever reaches the call, nothing changes in that scene.

Proposed change

  1. host/nvn_native.c: add nvnCommandBufferReportValue(cmdbuf, value, address). It records a new op carrying the value and the address, and goes into the proc table.
  2. gpu/render/rx_nvn.h: a new op kind next to NOP_REPORT_COUNTER (:145) with a small payload (value, address). The other back end ignores it unless it also replays reports.
  3. gpu/vk/vk_replay.cpp: where NOP_REPORT_COUNTER writes its report, write {value in the low four bytes of the counter, upper four bytes zero, timestamp} for the new op: the same timestamp source (RX_VK_TS_SCALE), the same guest_cpu_write plus memory_cpu_owned pair, in the pass and order that report counters use now, so the conditions the parallel replay reads see it.
  4. Log the first hit once, as the report-counter path does, so a run shows whether the game reaches it.
  5. Leave the record-time test switch HOS_COND_RECORD alone (default off).

How we would test it

  • Game-free, fails today (a new tests/test_nvn_report_value.py, built like tests/test_nvn_host_tables.py, which compiles the real functions from host/nvn_native.c):
    1. the proc table has nvnCommandBufferReportValue (today it does not);
    2. the compiled handler records one op with the value and address it was given;
    3. the replay case, cut from vk_replay.cpp with tests/srccut.py, run on a fake guest memory with value 7: bytes 0-7 hold 7, bytes 8-15 hold a non-zero timestamp, bytes 16-31 are untouched;
    4. an equal-mode conditional on two such words comes out on when the counters match and off when they differ.
  • Game run: one run of a scene with the host log on. Before: the log has nvn: nvnCommandBufferReportValue is not implemented. After: the line is gone and the new first-hit line is there. If neither run reaches the call, we say so and keep the issue as a correctness fix for scenes that do.
  • Pictures: for any scene where the call is reached, same save, same spot, image hash before and after, plus the replay dump's compared words. Expect a change only where a gate flips. We accept the new hash only with the flipped gate shown.
  • Speed: no speed claim. A handler that writes 16 bytes per call is not expected to be visible; if a frame-time change is ever claimed, it needs paired timing after a null main-against-main pair.

#1493 (renderer rewrite; this is one of the places where the host answers differently from the console). No thread covers nvnCommandBufferReportValue itself. Searched open and closed issues and pull requests for ReportValue, report value, ReportCounter, samples-passed, nvnCommandBuffer, unimplemented and "NVN not implemented". The nearest are about the other report call: #122 (open: every samples-passed report reads 4096; it notes that one dumped Kokiri Forest frame had no conditional rendering at all, so which scenes reach the conditional compare varies, which is why the first run counts), and the closed #23, #197 and #260, which gave report counters the GPU's counts and reworked how the replay writes them. This change would sit beside that write.

New on this forge; not opened on GitHub.

**Type:** correctness · **Area:** NVN host layer, conditional rendering · **Part of:** #1493 ## TL;DR The NVN call `nvnCommandBufferReportValue` has no handler in the port. When the game calls it, the host logs one line, answers 0 and records nothing, so the report word the console would have written keeps its old contents. Conditional rendering compares two such words, so a missing write can switch a clear or a draw on or off wrongly and change pixels. We propose to record the call and write the value and a timestamp when the replay reaches it, the way report counters are written today. ## Breakdown - **Who it affects:** any scene where the game reaches one of its ReportValue calls. The game calls it from several places (12 in the study). Whether a given scene reaches one has not been counted in a run yet. - **What is wrong:** the call has no entry in the host's NVN table. It falls to the "not implemented" stub, which does nothing. The report word that should hold the value is never written. - **What the console does:** it writes the 32-bit value at the start of the 16-byte report at the given address and a timestamp into the second half. The write is in command order, after earlier work. - **What we propose:** record the call, and write the same 16 bytes when the replay reaches it. Same pass and same ordering rules as `nvnCommandBufferReportCounter`. - **What does not change:** report counters, `nvnCommandBufferResetCounter`, the conditional-render compare itself, the fixed samples-passed value, and every call that already has a handler. - **How we would prove it:** a game-free test that fails today (no handler, nothing written), then one game run where the "not implemented" log line is present before and absent after, with the compared words shown by the replay dump. ## Evidence Port code is on forge/main at 310e7c9df. Nothing here was run in a game. **What the port does today** - `gpu/render/nvn_api.h:1678` is the only mention of ReportValue: a function pointer type. There is no handler in `host/nvn_native.c` and no entry in its proc table (`nvnCommandBufferReportCounter` is entry `:3004`). - A proc with no handler gets the stub at `host/nvn_native.c:3214-3236`: the first call logs `nvn: <name> is not implemented: answered 0`, every call answers 0, and the game goes on. With `HOS_NVN_STRICT=1` the game stops instead. The stub is handed out at `:3258-3266`. - Report counters are handled. `host/nvn_native.c:1852-1866` records them. `gpu/vk/vk_replay.cpp:1534-1580` writes the 16-byte report (`{count, timestamp}`) into guest memory in stream order, "not on the GPU timeline", because conditional rendering reads those words (`:1568-1572`). - Conditional rendering compares the `counter` at the address with the `counter` at address + 16: `host/nvn_native.c:1990-2006`, replay at `gpu/vk/vk_replay.cpp:1855-1878`. The comments there describe how some games gate clears with it: the CPU writes 1 to ask for a clear, and a report written after the clear resets the word. A game that resets or sets such a word with ReportValue instead would need that write too. **What the console does** (behaviour only) - `nvnCommandBufferReportValue(cmdbuf, value, address)` writes the value into the first four bytes of the 16-byte report (the low half of the `counter` field) and a timestamp into the second half (the `timestamp` field), in command order once the GPU reaches it. It writes the whole 16-byte report and no other memory. What the other four bytes of `counter` hold is not established by the study; the GPU's report layout puts zero there [inference, not run]. This comes from a private study of the console driver (read, then confirmed by running the driver's functions alone in an emulator); no code, addresses or game data from it are here. **Can it change pixels?** Yes, by reasoning, not seen in a run. If the game uses ReportValue to set or reset a word that a later `nvnCommandBufferSetRenderEnableConditional` compares, a dropped write leaves the old value, and the compare can come out the other way. Then a clear or a draw that should run is skipped, or one that should be skipped runs. We would see it as a changed compare in the replay dump (`vk: dump-op ... RENDER_COND mode N at <addr>: x vs y: on/off`) and as a changed picture in a paired image compare. If no scene ever reaches the call, nothing changes in that scene. ## Proposed change 1. `host/nvn_native.c`: add `nvnCommandBufferReportValue(cmdbuf, value, address)`. It records a new op carrying the value and the address, and goes into the proc table. 2. `gpu/render/rx_nvn.h`: a new op kind next to `NOP_REPORT_COUNTER` (`:145`) with a small payload (value, address). The other back end ignores it unless it also replays reports. 3. `gpu/vk/vk_replay.cpp`: where `NOP_REPORT_COUNTER` writes its report, write `{value in the low four bytes of the counter, upper four bytes zero, timestamp}` for the new op: the same timestamp source (`RX_VK_TS_SCALE`), the same `guest_cpu_write` plus `memory_cpu_owned` pair, in the pass and order that report counters use now, so the conditions the parallel replay reads see it. 4. Log the first hit once, as the report-counter path does, so a run shows whether the game reaches it. 5. Leave the record-time test switch `HOS_COND_RECORD` alone (default off). ## How we would test it - **Game-free, fails today** (a new `tests/test_nvn_report_value.py`, built like `tests/test_nvn_host_tables.py`, which compiles the real functions from `host/nvn_native.c`): 1. the proc table has `nvnCommandBufferReportValue` (today it does not); 2. the compiled handler records one op with the value and address it was given; 3. the replay case, cut from `vk_replay.cpp` with `tests/srccut.py`, run on a fake guest memory with value 7: bytes 0-7 hold 7, bytes 8-15 hold a non-zero timestamp, bytes 16-31 are untouched; 4. an equal-mode conditional on two such words comes out on when the counters match and off when they differ. - **Game run:** one run of a scene with the host log on. Before: the log has `nvn: nvnCommandBufferReportValue is not implemented`. After: the line is gone and the new first-hit line is there. If neither run reaches the call, we say so and keep the issue as a correctness fix for scenes that do. - **Pictures:** for any scene where the call is reached, same save, same spot, image hash before and after, plus the replay dump's compared words. Expect a change only where a gate flips. We accept the new hash only with the flipped gate shown. - **Speed:** no speed claim. A handler that writes 16 bytes per call is not expected to be visible; if a frame-time change is ever claimed, it needs paired timing after a null main-against-main pair. ## Related #1493 (renderer rewrite; this is one of the places where the host answers differently from the console). No thread covers `nvnCommandBufferReportValue` itself. Searched open and closed issues and pull requests for ReportValue, report value, ReportCounter, samples-passed, nvnCommandBuffer, unimplemented and "NVN not implemented". The nearest are about the other report call: #122 (open: every samples-passed report reads 4096; it notes that one dumped Kokiri Forest frame had no conditional rendering at all, so which scenes reach the conditional compare varies, which is why the first run counts), and the closed #23, #197 and #260, which gave report counters the GPU's counts and reworked how the replay writes them. This change would sit beside that write. New on this forge; not opened on GitHub.
Collaborator

Possibly related, for context:

  • issue #122 Game: on Vulkan the game's occlusion culling never culls (every samples-passed count reads 4096) — Related report-memory and conditional-rendering behavior; this issue is specifically missing ReportValue.
  • issue #1493 Renderer rewrite — Parent renderer rewrite that this NVN host correctness change belongs to.
Possibly related, for context: - issue #122 Game: on Vulkan the game's occlusion culling never culls (every samples-passed count reads 4096) — Related report-memory and conditional-rendering behavior; this issue is specifically missing ReportValue. - issue #1493 Renderer rewrite — Parent renderer rewrite that this NVN host correctness change belongs to.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot#1513
No description provided.