nvnCommandBufferReportValue has no handler, so the report words it should write are never written #1513
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot#1513
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: correctness · Area: NVN host layer, conditional rendering · Part of: #1493
TL;DR
The NVN call
nvnCommandBufferReportValuehas 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
nvnCommandBufferReportCounter.nvnCommandBufferResetCounter, the conditional-render compare itself, the fixed samples-passed value, and every call that already has a handler.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:1678is the only mention of ReportValue: a function pointer type. There is no handler inhost/nvn_native.cand no entry in its proc table (nvnCommandBufferReportCounteris entry:3004).host/nvn_native.c:3214-3236: the first call logsnvn: <name> is not implemented: answered 0, every call answers 0, and the game goes on. WithHOS_NVN_STRICT=1the game stops instead. The stub is handed out at:3258-3266.host/nvn_native.c:1852-1866records them.gpu/vk/vk_replay.cpp:1534-1580writes 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).counterat the address with thecounterat address + 16:host/nvn_native.c:1990-2006, replay atgpu/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 thecounterfield) and a timestamp into the second half (thetimestampfield), in command order once the GPU reaches it. It writes the whole 16-byte report and no other memory. What the other four bytes ofcounterhold 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
nvnCommandBufferSetRenderEnableConditionalcompares, 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
host/nvn_native.c: addnvnCommandBufferReportValue(cmdbuf, value, address). It records a new op carrying the value and the address, and goes into the proc table.gpu/render/rx_nvn.h: a new op kind next toNOP_REPORT_COUNTER(:145) with a small payload (value, address). The other back end ignores it unless it also replays reports.gpu/vk/vk_replay.cpp: whereNOP_REPORT_COUNTERwrites 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 sameguest_cpu_writeplusmemory_cpu_ownedpair, in the pass and order that report counters use now, so the conditions the parallel replay reads see it.HOS_COND_RECORDalone (default off).How we would test it
tests/test_nvn_report_value.py, built liketests/test_nvn_host_tables.py, which compiles the real functions fromhost/nvn_native.c):nvnCommandBufferReportValue(today it does not);vk_replay.cppwithtests/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;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.Related
#1493 (renderer rewrite; this is one of the places where the host answers differently from the console). No thread covers
nvnCommandBufferReportValueitself. 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.
Possibly related, for context: