[PR #1075] [MERGED] fix(gfx): Stop the swapchain washing colours out #3025

Closed
opened 2026-11-02 16:00:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/1075
Author: @ItsPotatoTime
Created: 10/21/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @ludovic111

Base: main ← Head: fix/washed-title-screen-colors


📝 Commits (1)

  • 6bb6009 fix(gfx): keep the swapchain off the linear float format

📊 Changes

1 file changed (+47 additions, -11 deletions)

View changed files

📝 crates/horizon-client/src/gfx.rs (+47 -11)

📄 Description

Summary

Horizon picked Rgba16Float for its window surface because it was the first non-SRGB format RADV advertises on Wayland. wgpu gives that format the linear ExtendedSrgb colour space, and the renderer writes gamma-encoded values, so the compositor displayed them as linear light and every colour came out washed. This picks an 8-bit non-SRGB format instead and keeps the previous choice as a fallback.

Changes

surface_format in crates/horizon-client/src/gfx.rs prefers Bgra8Unorm then Rgba8Unorm from the surface capabilities, then falls back to the first non-SRGB format. A unit test covers the ordering.

Taking a screenshot on a surface that is not 32-bit now returns an error rather than copying with an 8-bit row stride. The old code panicked in wgpu validation on Rgba16Float; that surface is what exposed this.

Vanilla reference

None: this is platform surface configuration, not game behaviour. Vanilla's blending and tinting in gamma space is why the target must be non-SRGB, which the existing comment already documented.

Test plan

cargo fmt -p horizon-client -- --check
cargo test -p horizon-client --profile fast surface_is_8_bit
cargo clippy -p horizon-client --no-deps --profile fast --all-targets -- -D warnings -A clippy::boxed_local -A clippy::manual_range_contains

All three pass.

Manual: on a RADV Wayland system where the surface previously logged configuring the surface (952x1026 Rgba16Float, Mailbox), it now logs Bgra8Unorm. A windowed screenshot through horizon-ctl screenshot no longer panics, and its pixels match the offscreen render and the source textures (for example, button.png row 112 renders as 112 in both).

Note: a full cargo clippy -D warnings on this machine fails in two files this change does not touch (horizon-world manual_range_contains and streaming.rs boxed_local) with the locally installed Rust 1.97.1. CI's stable on the last main run did not report them.

Generated with Cairn Code · DeepSeek V4.1 Flash


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/1075 **Author:** [@ItsPotatoTime](https://github.com/ItsPotatoTime) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/washed-title-screen-colors` --- ### 📝 Commits (1) - [`6bb6009`](https://github.com/horizon-rust/horizon/commit/6bb600913372b3535467a40c7c021eee0cd37e3e) fix(gfx): keep the swapchain off the linear float format ### 📊 Changes **1 file changed** (+47 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/gfx.rs` (+47 -11) </details> ### 📄 Description ## Summary Horizon picked `Rgba16Float` for its window surface because it was the first non-SRGB format RADV advertises on Wayland. wgpu gives that format the linear `ExtendedSrgb` colour space, and the renderer writes gamma-encoded values, so the compositor displayed them as linear light and every colour came out washed. This picks an 8-bit non-SRGB format instead and keeps the previous choice as a fallback. ## Changes `surface_format` in `crates/horizon-client/src/gfx.rs` prefers `Bgra8Unorm` then `Rgba8Unorm` from the surface capabilities, then falls back to the first non-SRGB format. A unit test covers the ordering. Taking a screenshot on a surface that is not 32-bit now returns an error rather than copying with an 8-bit row stride. The old code panicked in wgpu validation on `Rgba16Float`; that surface is what exposed this. ## Vanilla reference None: this is platform surface configuration, not game behaviour. Vanilla's blending and tinting in gamma space is why the target must be non-SRGB, which the existing comment already documented. ## Test plan ``` cargo fmt -p horizon-client -- --check cargo test -p horizon-client --profile fast surface_is_8_bit cargo clippy -p horizon-client --no-deps --profile fast --all-targets -- -D warnings -A clippy::boxed_local -A clippy::manual_range_contains ``` All three pass. Manual: on a RADV Wayland system where the surface previously logged `configuring the surface (952x1026 Rgba16Float, Mailbox)`, it now logs `Bgra8Unorm`. A windowed screenshot through `horizon-ctl screenshot` no longer panics, and its pixels match the offscreen render and the source textures (for example, `button.png` row 112 renders as 112 in both). Note: a full `cargo clippy -D warnings` on this machine fails in two files this change does not touch (`horizon-world` `manual_range_contains` and `streaming.rs` `boxed_local`) with the locally installed Rust 1.97.1. CI's stable on the last `main` run did not report them. Generated with Cairn Code · DeepSeek V4.1 Flash --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 16:00:54 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3025
No description provided.