Skip to content

fix Wayland ghosting using GL_TEXTURE_SWIZZLE_A#535

Merged
nschimme merged 1 commit into
MUME:masterfrom
nschimme:fix-wayland-swizzle-10782420217640554893
Jun 4, 2026
Merged

fix Wayland ghosting using GL_TEXTURE_SWIZZLE_A#535
nschimme merged 1 commit into
MUME:masterfrom
nschimme:fix-wayland-swizzle-10782420217640554893

Conversation

@nschimme

@nschimme nschimme commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Fix window ghosting artifacts on Wayland by forcing the alpha channel of the resolved FBO texture to 1.0, ensuring the final composition is fully opaque to the compositor.

Summary by Sourcery

Bug Fixes:

  • Prevent window ghosting artifacts on Wayland by swizzling the resolved framebuffer texture alpha channel to 1.0 on non-WASM platforms.

Fix window ghosting artifacts on Wayland by forcing the alpha channel
of the resolved FBO texture to 1.0, ensuring the final composition
is fully opaque to the compositor.
@sourcery-ai

sourcery-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Configures the resolved FBO texture so that its alpha channel is forced to 1.0 (except on WebAssembly), eliminating Wayland ghosting artifacts caused by non-opaque alpha being presented to the compositor.

Sequence diagram for updated FBO configuration and alpha swizzle

sequenceDiagram
    participant Functions
    participant FBO
    participant OpenGL

    Functions->>FBO: configure(getPhysicalViewport(), samples)
    Functions->>FBO: resolvedTextureId()
    FBO-->>Functions: textureId
    alt CURRENT_PLATFORM != PlatformEnum::Wasm and textureId != 0
        Functions->>OpenGL: glBindTexture(GL_TEXTURE_2D, textureId)
        Functions->>OpenGL: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ONE)
        Functions->>OpenGL: glBindTexture(GL_TEXTURE_2D, 0)
    end
Loading

File-Level Changes

Change Details Files
Force the resolved FBO texture alpha channel to 1.0 via GL texture swizzle to avoid Wayland window ghosting, with WebAssembly excluded.
  • Include computed config constants header so platform checks (CURRENT_PLATFORM) are available in this translation unit
  • Extend Functions::configureFbo to, after configuring the FBO, fetch the resolved texture ID and if valid bind it and set GL_TEXTURE_SWIZZLE_A to GL_ONE, then unbind
  • Guard the new texture swizzle logic with a compile-time check to skip it on the Wasm platform where WebGL2 does not support texture swizzling
src/opengl/legacy/Legacy.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

Hey - I've left some high level feedback:

  • Binding and unbinding GL_TEXTURE_2D inside configureFbo introduces a new side effect; consider saving/restoring the previously bound texture so callers’ GL state assumptions remain valid.
  • The swizzle parameter is set every time configureFbo runs; if the resolved texture is reused across frames, you could guard this with a small flag or move it to the FBO/texture initialization path to avoid redundant state changes.
  • The workaround currently applies to all non-Wasm platforms; if the ghosting issue is specific to Wayland, consider scoping this behavior behind a more precise platform/window-system check or configuration flag to avoid surprising behavior on other backends.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Binding and unbinding GL_TEXTURE_2D inside configureFbo introduces a new side effect; consider saving/restoring the previously bound texture so callers’ GL state assumptions remain valid.
- The swizzle parameter is set every time configureFbo runs; if the resolved texture is reused across frames, you could guard this with a small flag or move it to the FBO/texture initialization path to avoid redundant state changes.
- The workaround currently applies to all non-Wasm platforms; if the ghosting issue is specific to Wayland, consider scoping this behavior behind a more precise platform/window-system check or configuration flag to avoid surprising behavior on other backends.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.38%. Comparing base (7510a6b) to head (7bbafb4).

Files with missing lines Patch % Lines
src/opengl/legacy/Legacy.cpp 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #535      +/-   ##
==========================================
- Coverage   25.39%   25.38%   -0.01%     
==========================================
  Files         521      521              
  Lines       43178    43183       +5     
  Branches     4708     4709       +1     
==========================================
  Hits        10963    10963              
- Misses      32215    32220       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nschimme nschimme merged commit 21d2fb5 into MUME:master Jun 4, 2026
20 of 21 checks passed
@nschimme nschimme deleted the fix-wayland-swizzle-10782420217640554893 branch June 4, 2026 17:31
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.

1 participant