Skip to content

Conversation

@y0usaf
Copy link

@y0usaf y0usaf commented Dec 4, 2025

Summary

Fixes rounded corner rendering for y-inverted Wayland buffers (dmabuf media players, certain GPU configurations).

Changes

  • Add buffer_y_inverted() helper to detect y-inverted buffers via Smithay's API
  • Apply Y-axis coordinate transformation in clipped surface shader
  • Convert lazy iterators to eager Vec materialization in tile.rs and mru.rs for renderer access

Files Modified

  • src/render_helpers/clipped_surface.rs
  • src/layout/tile.rs
  • src/ui/mru.rs

When a Wayland buffer is marked as y-inverted (common with dmabuf media
players and certain GPU configurations), the rounded corner clipping shader
was computing coordinates in the wrong coordinate space, resulting in
misaligned or upside-down corner rendering.

The fix adds proper Y-axis coordinate transformation for y-inverted buffers:

1. Add ClippedSurfaceRenderElement::buffer_y_inverted() helper to detect
   if a render element's underlying buffer is y-inverted by querying Smithay's
   buffer_y_inverted() function.

2. Pass y_inverted flag to ClippedSurfaceRenderElement::new() as a parameter.

3. Apply a Y-axis flip matrix to input_to_geo when y_inverted=true:
   - Translate to center (0.5, 0.5)
   - Scale Y by -1 to flip
   - Translate back to original position

This keeps clipping coordinates synchronized with how Smithay's renderer
already handles the texture coordinates for y-inverted buffers, ensuring
the shader's rounding calculations are in the correct coordinate space.

Implementation required converting lazy .map() iterators to eager Vec
materialization in tile.rs and mru.rs to access &mut renderer for
computing the y_inverted flag. This is the standard Smithay pattern for
renderer-dependent render element metadata.

Fixes: Round corners render incorrectly on y-inverted buffers
Tests: All 189 unit tests pass
@YaLTeR
Copy link
Owner

YaLTeR commented Dec 4, 2025

What's a test client I could use for this?

@y0usaf
Copy link
Author

y0usaf commented Dec 9, 2025

Will have to transition to draft, my apologies. It was briefly working but something seems to have mucked it up. I typically test with mpv --hwdec=auto <video>.

@y0usaf y0usaf marked this pull request as draft December 9, 2025 03:09
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