nvnSyncWait on a sync that was never fenced answers timeout, but the console answers failed #1515
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#1515
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, sync objects · Part of: #1493
TL;DR
nvnSyncWaiton a sync object that was initialised but never fenced returnsNVN_SYNC_WAIT_RESULT_TIMEOUT_EXPIREDin the port. The console's driver returnsNVN_SYNC_WAIT_RESULT_FAILEDfor the same call, so the port's own comment "as on the console" is wrong. We propose one changed result code, plus a once-logged line so a run shows whether the game ever takes this path.Breakdown
FAILEDfor a never-fenced sync, fix the comment, and log the first few hits.nvnSyncWaitresult. The study confirmed that the port matches the console for already signalled (0), waited (1) and timed out (2), for the nanosecond timeout (a timeout of 0 is a poll), and for the all-ones infinite timeout.Evidence
Port code is on forge/main at
310e7c9df. Nothing here was run in a game.What the port does today
host/nvn_native.c:1127has the comment "never fenced: times out, as on the console", and:1133isif (!s->fenced) { RET(NVN_SYNC_WAIT_RESULT_TIMEOUT_EXPIRED); return; }.nvnSyncInitializesetsfenced = 0(:1063).nvnQueueFenceSyncsetsfenced = 1(:1105). Window-acquire syncs and syncs made from a native handle are marked 3, "signalled" (:2571,:2681), so they are not touched by this change.gpu/render/nvn_api.h:1045-1048: 0 already signalled, 1 condition satisfied, 2 timeout expired, 3 failed.:1130-1132prints the fence number and the timeout but does not say whether the sync was ever fenced.What the console does (behaviour only)
NVN_SYNC_WAIT_RESULT_FAILEDat once, whatever the timeout. A fenced sync answers 0, 1 or 2 as the port does.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 anything seen? It changes control flow at the call site, so it can change timing (a spin removed) or take a path the port has never run (an error path). It does not change a picture by itself. We would see it as the new log line, and as a frame-pacing change only if the game was spinning on this call.
Proposed change
host/nvn_native.c:1133: returnNVN_SYNC_WAIT_RESULT_FAILEDwhen the sync was never fenced. Fix the comment at:1127.:1837-1839("a sync not fenced yet"), so the log answers "does the game ever do this".nvnSyncWaitchanges.How we would test it
tests/test_nvn_sync_wait.py, built liketests/test_nvn_null_pool.py, which compiles the real function fromhost/nvn_native.cwith stubs for the renderer's wait and the clock):nvnSyncInitialize, never fenced, timeout 0 and timeout infinite: expects 3 (today 2);Only case 1 fails on current main; the other four lock in what already matches.
Related
#1493 (renderer rewrite; this is one of the places where the host answers differently from the console). No thread covers a wait on a never-fenced sync. Searched open and closed issues and pull requests for SyncWait, nvnSyncWait, sync wait, never fenced, fence sync and TIMEOUT_EXPIRED. Threads that touch the same function: #916 (closed, left as a record) changed
nvnSyncWaitfor the frame limiter's call only, and its check built the real function with a fake GPU, which is the fixture this issue's test would use. #1268, #1190 and #1020 (open) are about the time the main thread spends in fencednvnSyncWaitwaits, a different question that this change does not touch. #656 (open) is about another wait, the present poll.New on this forge; not opened on GitHub.
Possibly related, for context: