Skip to content

GPU: safe, discoverable surface format selection (wide-gamut/HDR) - #33

Open
codymullins wants to merge 1 commit into
mainfrom
feat/surface-format-select
Open

GPU: safe, discoverable surface format selection (wide-gamut/HDR)#33
codymullins wants to merge 1 commit into
mainfrom
feat/surface-format-select

Conversation

@codymullins

Copy link
Copy Markdown
Contributor

Addresses #26.

Scope note

wgpu-native's surface configuration has no explicit color-space, tone-mapping, or gamma field — on WebGPU, wide-gamut and HDR are selected through the surface format (e.g. a float format like Rgba16float for extended range, or an sRGB vs linear 8-bit format for gamut). So the useful, in-platform deliverable is making format selection safe and discoverable. Explicit color-space/gamma knobs are a wgpu-native API limitation, not something Skyline can plumb today — noted here so #26 can be closed or rescoped with that understanding.

What changed (all in Skyline.Gpu)

  • WindowSurfaceCapabilities.Supports(TextureFormat) and ChooseFormat(...preferred) — pick the first supported format from a preference list, falling back to the surface's own preferred format. Mirrors the existing ChoosePresentMode / Supports(PresentMode) / Supports(CompositeAlphaMode) helpers.
  • WindowSurface.Configure now validates the requested format against the surface's capabilities and throws a managed InvalidOperationException — today an unsupported format makes wgpu's SurfaceConfigure abort the process with a non-unwinding panic. This mirrors the alpha-mode validation already there.

Tests

  • Skyline.WindowedTestsSupports/ChooseFormat (supported, preferred-fallback), and that Configure throws a managed error on an unsupported single-channel format (the analog of the existing alpha-mode test).

Verification

  • dotnet build Skyline.slnx clean (0 warnings); headless tests pass; windowed harness passes (92 checks); format-check.sh clean.
  • Coverage: WindowSurfaceCapabilities 100%; my new WindowSurface lines are covered. The only uncovered WindowSurface lines (the stale-swapchain-with-live-texture release path) are pre-existing — clean main shows the identical lines uncovered in this environment (verified by A/B). Overall line coverage matches main.

Note

Isolated to Skyline.Gpu (plus the GPU section of the windowed harness), so no conflict with the open window/input PRs (#30/#31/#32).

Expose surface-format support so a consumer can ask for a wide-gamut or
HDR format and fall back safely, and turn an unsupported format into a
managed error instead of a wgpu process abort.

- WindowSurfaceCapabilities.Supports(TextureFormat) and ChooseFormat,
  mirroring the present-mode and alpha-mode helpers.
- WindowSurface.Configure validates the requested format against the
  surface's capabilities, the way it already does for the alpha mode.

Addresses #26
Copilot AI review requested due to automatic review settings June 16, 2026 23:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants