Optimize GVFG GPU preview and clarify delivery diagnostics

- Render preview directly from the FP16 conversion target into the selected
  8-bit or 10-bit swapchain, removing the full-frame scene copy and the
  intermediate BGRA8 preview pass without capture-frame decimation.
- Simplify neutral YUY2/Y210 shaders to one packed texture load per pixel;
  preserve BT.709 conversion, 10-bit unpacking and odd-width chroma handling.
- Cache shader resource views per upload slot and update constant-buffer
  contents only when source dimensions change.
- Allocate only preview resources and skip export-only shader compilation
  for preview; retain the full BGRA8/RGB10A2/NV12 buffer conversion path.
- Unbind render targets before swapchain resize/release and serialize preview
  configuration and resource changes with GPU rendering.
- Bound startup Present retries and retry presentation without redrawing;
  retain actual skipped-frame counts when presentation remains busy.
- Add preview delivery counters for presented, replaced, busy, failed,
  cancelled and pending frames, including busy source and affected frame ID.
- Fix an uncounted pending-frame replacement and drain pending preview work
  at Stop and before a new run to keep per-run accounting separate.
- Track application audio delivery, dropped duration, read/write stalls and
  frame-ID anomalies while retaining the original 10-block audio queue.
- Stop the channel on audio write failure or two seconds of zero-write
  progress; distinguish cancelled data from runtime drops.
- Keep the existing compact UI; aggregate delivery issue logs at most once
  per five seconds and emit a stop summary with accounting errors only.
- Document diagnostic interpretation, GPU changes and validation boundaries.

Validation:
- User testing reported approximately 15% lower GPU utilization after the
  optimization. Baseline/final readings and relative versus percentage-point
  interpretation were not supplied; no independent benchmark was performed.
- Static source checks and git diff --check passed. No application or shader
  build was performed by the agent; 10-bit startup resolution and long-run
  zero-loss behavior have not been confirmed.
- Rebuild the preview DLL with its matching APP; the SDK GPU buffer converter
  also shares the modified shader source. Capture APIs and driver are unchanged.
This commit is contained in:
Mark.lin
2026-09-04 16:02:33 +08:00
parent 2b62a85912
commit 29b449fc6e
8 changed files with 499 additions and 183 deletions
@@ -78,6 +78,34 @@ typedef struct
uint64_t skipped_presents;
} gvfg_preview_stats_t;
/* Lifetime counters (until shutdown); configure/clear do not reset them.
* submitted = presented + replaced + busy + failed + cancelled + in_flight.
* Presented means DXGI accepted Present, not proof of physical scanout.
* Failed render API calls are counted by the caller, not in submitted.
*/
typedef struct
{
uint64_t submitted;
uint64_t presented;
uint64_t replaced;
uint64_t busy;
uint64_t failed;
uint64_t cancelled;
uint64_t in_flight;
uint64_t last_presented_id;
uint64_t present_busy;
uint64_t slots_busy;
uint64_t last_busy_id;
} gvfg_preview_delivery_stats_t;
GVFG_PREVIEW_API gvfg_preview_status_t gvfg_preview_get_delivery_stats(
gvfg_preview_handle handle, gvfg_preview_delivery_stats_t *out_stats);
/* Call after stopping submissions. Wait at most timeout_ms for queued work.
* Returns ESTATE if work remains; does not discard or reset counters. */
GVFG_PREVIEW_API gvfg_preview_status_t gvfg_preview_wait_idle(
gvfg_preview_handle handle, uint32_t timeout_ms);
GVFG_PREVIEW_API gvfg_preview_status_t gvfg_preview_create(
gvfg_preview_handle *out_handle);