Refine GVFG preview pacing and error reporting

- Replace non-blocking Present retries with Present(0, 0), allowing DXGI to
  wait for presentation dependencies on the dedicated preview worker.
- Change preview admission from newest-frame replacement to bounded FIFO
  delivery with three pending/upload reservations and one presenting slot.
- Expire queued preview frames after 50 ms before GPU processing and skip new
  preview submissions only when the bounded slot capacity is full.
- Track queue order and queue age without retaining SDK-owned frame memory;
  capture continues releasing each SDK frame after the synchronous upload.
- Service only synchronous Windows sent messages while waiting for preview
  mutexes, worker shutdown, idle drain, and capture-thread join to avoid an
  HWND-owner/DXGI deadlock without dispatching queued application callbacks.
- Preserve internal preview pacing and audio queue counters while removing
  expected busy, expired, and audio-eviction reports from the normal UI log.
- Reserve delivery error logs for preview/render failures, video or audio
  frame-ID anomalies, audio write failures, and final accounting mismatches.
- Remove the normal stop summary and the audio queue-drop field from the
  status display so expected pacing adjustments are not presented as faults.
- Update the public preview comments and diagnostic documentation for the FIFO
  capacity, queue-age boundary, blocking Present behavior, and log policy.
- Keep the capture SDK, driver interfaces, frame ownership, GPU conversion
  precision, and public delivery-statistics structure unchanged.

Validation:
- User testing reported approximately 18% GPU utilization for one 1920x1080
  Y210 10-bit preview channel. This was not independently benchmarked.
- A user-provided long-run log contained 13,715,695 received video frames with
  no preview render failures; periodic preview skips matched the confirmed
  60.000 FPS versus 59.94 Hz pacing difference.
- The same log showed periodic audio playback-queue eviction without audio
  frame-ID gaps or write failures; this is retained as internal diagnostic
  accounting rather than reported as a source-delivery error.
- Static source review and git diff --check passed. No application, shader, or
  driver build was performed by the agent, and runtime deadlock behavior has
  not been independently reproduced or validated.
This commit is contained in:
Mark.lin
2026-09-07 10:28:03 +08:00
parent 29b449fc6e
commit d03f064b4f
7 changed files with 161 additions and 169 deletions
+8 -6
View File
@@ -67,9 +67,9 @@ typedef struct
/*
* Preview presentation statistics.
*
* present_fps counts only frames accepted by DXGI Present. A frame skipped
* because the non-blocking swapchain is busy is excluded. The rate uses
* successful presents from the most recent five seconds.
* present_fps counts only frames accepted by DXGI Present, not physical
* scanout. The rate uses successful presents from the most recent five
* seconds. Pending preview replacements are excluded from this rate.
*/
typedef struct
{
@@ -87,7 +87,7 @@ typedef struct
{
uint64_t submitted;
uint64_t presented;
uint64_t replaced;
uint64_t replaced; /* Queued frames discarded after the 50 ms age limit. */
uint64_t busy;
uint64_t failed;
uint64_t cancelled;
@@ -133,8 +133,10 @@ GVFG_PREVIEW_API gvfg_preview_status_t gvfg_preview_prepare(
*
* The frame memory remains owned by the caller and must remain valid until
* this function returns. GPU conversion and Present continue on the internal
* preview worker. If preview falls behind, an older queued preview frame may
* be replaced; capture ownership and capture-frame delivery are unaffected.
* preview worker. Up to three pending frames are retained in FIFO order.
* Frames waiting longer than 50 ms are discarded; if the queue is full,
* the incoming frame is skipped. No SDK frame is retained for queueing.
* The age limit excludes time spent rendering or waiting inside Present.
*/
GVFG_PREVIEW_API gvfg_preview_status_t gvfg_preview_render_frame(
gvfg_preview_handle handle,