Skip to content

PR 0085 Vulkan avoid false surface readbacks for adjacent vertex data

github-actions[bot] edited this page Sep 14, 2026 · 1 revision

PR #85 — Vulkan: avoid false surface readbacks for adjacent vertex data

PR #85

Status

  • GitHub state: Open draft
  • Disposition at review: HOLD
  • Current head at review: 0883fb63009c6cc804681cbdb39e4454b44d8456 (fix/vulkan-vertex-surface-freshness)
  • Reviewed head: 0883fb63009c6cc804681cbdb39e4454b44d8456
  • Last reviewed: 2026-09-14 UTC
  • Base: main at 9148241de690617ac0a21a26b41858585c1e3cab
  • Subsystem: Vulkan memory / synchronization

Review freshness: current at the reviewed head. Before acting on this open/draft PR, compare the live GitHub head with Reviewed head below. If it differs, treat implementation details, file impact, flow, and result qualification as stale until re-reviewed. The historical lesson remains valid unless newer evidence explicitly overturns it.

At a glance

  • What it changes: Vulkan: avoid false surface readbacks for adjacent vertex data
  • Why it was attempted: A vertex request is widened to dirty-memory pages for upload. The old code used that wider range to decide whether to download a GPU-authored surface. In the pinned Morrowind snapshot, adjacent pages created false overlaps and expensive SURFACE DOWN waits. This PR checks surface overlap on the pre-alignment request and retains page-aligned dirty tracking and ordered vertex upload. It also marks the vertex mirror dirty after successful readback. Code: vk/v…
  • Current/final result: Open draft/HOLD correctness work: exact vertex-fetch ranges and surface freshness are being repaired and remain prerequisites for later vertex fast paths.
  • Lesson: Before CPU-side vertex decoding/upload, prove guest memory is authoritative for the exact fetched range when GPU-authored surfaces may overlap it; coherency must precede optimization.

Code impact

Implementation file Δ Why it matters
hw/xbox/nv2a/pgraph/vk/draw.c +45/-21 Vulkan draw preparation/recording and the PR hot-path decision.
hw/xbox/nv2a/pgraph/vk/renderer.c +2/-2 Renderer lifecycle, pending work, synchronization, or teardown ownership.
hw/xbox/nv2a/pgraph/vk/renderer.h +5/-2 Renderer-owned state needed by the implementation.
hw/xbox/nv2a/pgraph/vk/surface.c +8/-4 Surface ownership, overlap, readback, upload, or freshness path.
hw/xbox/nv2a/pgraph/vk/vertex-fetch-span.h +52/-0 Vertex range calculation, upload, storage, or command-buffer lifetime path.
hw/xbox/nv2a/pgraph/vk/vertex.c +68/-21 Vertex range calculation, upload, storage, or command-buffer lifetime path.
tests/unit/meson.build +1/-0 Focused/regression validation for the implementation contract.
tests/unit/test-xbox-vk-vertex-fetch-span.c +57/-0 Focused/regression validation for the implementation contract.

Flow

flowchart LR
    subgraph Before
        A[Guest vertex bytes change] --> B[Resolve source/freshness] --> C[Upload/storage ordering] --> D[Draw]
    end
    subgraph PR_85[PR #85]
        E[Guest vertex bytes change] --> F[PR #85 lifetime/bounds rule] --> G[Qualified fast path or safe fallback] --> H[Draw]
    end
Loading

What changed

This PR changes the implementation paths listed in Code impact to implement or test “Vulkan: avoid false surface readbacks for adjacent vertex data”. The file table is the quick source map; use the linked PR diff for line-level mechanics.

Result

Open draft/HOLD correctness work: exact vertex-fetch ranges and surface freshness are being repaired and remain prerequisites for later vertex fast paths.

Lesson learned

Before CPU-side vertex decoding/upload, prove guest memory is authoritative for the exact fetched range when GPU-authored surfaces may overlap it; coherency must precede optimization.

Avoid repeating

Do not skip surface readback from a broad dirty-bit assumption, and do not use oversized overlap ranges that turn correctness checks into unnecessary synchronization.

Docs / evidence

Pointers only; the detailed evidence remains in its original location.

Related architecture

Related PRs referenced by this PR:

Clone this wiki locally