Skip to content

PR 0002 release owned SDL context and hidden window

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

PR #2 — ENG-2026-523 Fix: release owned SDL context and hidden window

PR #2

Status

  • GitHub state: Merged
  • Disposition at review: Merged
  • Current head at review: b1216d29ba63091b5db68d18451b488ce4861956 (fix/eng-2026-523-gloffscreen-owned-resources-u39e70992)
  • Reviewed head: b1216d29ba63091b5db68d18451b488ce4861956
  • Last reviewed: 2026-09-14 UTC
  • Base: main at ab2f8a8be80725a2c0c7a03050c1c5ee2e45fd35
  • Subsystem: OpenGL / SDL context ownership

Review freshness: this page records the final/known PR head at review time. If the PR is reopened or rewritten, re-review before relying on implementation details.

At a glance

  • What it changes: release owned SDL context and hidden window
  • Why it was attempted: Observed problem: The temporary GPU-properties probe created an SDL GL context and hidden SDL window, but glo context destroy() detached the context and freed only the wrapper. Profiling evidence: This is a lifecycle/resource correctness defect. The old byte-equivalent path leaked on the first cycle; the repaired lifecycle repeatedly returns to the starting window count. Suspected cause: Wrapper-owned SDL resources were never explicitly destroyed. Why thi…
  • Current/final result: Merged focused ownership cleanup with unit coverage for context/window release.
  • Lesson: The offscreen SDL GL context and hidden window are owned resources and must be released in the correct teardown path; lifecycle leaks are correctness/resource bugs even without a performance campaign.

Code impact

Implementation file Δ Why it matters
hw/xbox/nv2a/pgraph/thirdparty/gloffscreen/sdl.c +2/-0 Owned SDL GL context/hidden-window creation and teardown.
tests/unit/meson.build +11/-0 Focused/regression validation for the implementation contract.
tests/unit/test-xbox-gloffscreen.c +81/-0 Focused/regression validation for the implementation contract.

Flow

flowchart LR
    subgraph Before
        A[OpenGL / SDL context ownership input] --> B[Existing path] --> C[Observed limitation/cost] --> D[Guest-visible result]
    end
    subgraph PR_2[PR #2]
        E[OpenGL / SDL context ownership input] --> F[PR #2 change/measurement] --> G[Qualified behavior] --> H[Guest-visible result]
    end
Loading

What changed

Add SDL GL DestroyContext(ctx- context) . - Add SDL DestroyWindow(ctx- window) . - Add opt-in shared-context lifecycle coverage with null destruction, repeated cycles, texture sharing, and window-count validation. - Register the interactive test while keeping runtime execution gated by XEMU TEST GLOFFSCREEN=1 . Main code path: hw/xbox/nv2a/pgraph/thirdparty/gloffscreen/sdl.c , tests/unit/test-xbox-gloffscreen.c , tests/unit/meson.build Commits: exact current-main candidate b1216d29ba63091b5db68d18451b488ce4861956

Result

Merged focused ownership cleanup with unit coverage for context/window release.

Lesson learned

The offscreen SDL GL context and hidden window are owned resources and must be released in the correct teardown path; lifecycle leaks are correctness/resource bugs even without a performance campaign.

Avoid repeating

Do not destroy surrounding renderer state while leaving the owned SDL context/window alive, and do not require a broad performance campaign for an isolated ownership fix unless behavior changes.

Docs / evidence

No dedicated docs/evidence path was identified from the PR file list or PR body. Use the linked PR discussion and commit history as the primary record.

Related architecture

Clone this wiki locally