⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@madsmtm
Copy link
Member

@madsmtm madsmtm commented Jan 19, 2026

&mut [u32] as a buffer format is kinda weird and has confusing interactions with endianess, see #109. I'd like to move towards exposing buffer data in different formats instead:

Removing the Deref/DerefMut as done in this PR should make it easier to reduce our "dependency" on u32 as the pixel type in the future. Users would instead explicitly use the new Buffer::pixels or the accessors added in #312 (which this PR builds upon).

Finally, the current Deref[Mut] impls are not zero-cost on all backends (and is kinda hard to make it so on Linux because of BufferDispatch), making them be a potential invisible performance cliff.

(The BorrowStack hack could maybe be used to fix some of this, as was done on Wayland, but it requires the stored state to be &mut T instead of T, and it adds 2*pointer size to Buffer<'_> which is kinda annoying. I've removed it in this PR because I believe it will no longer be necessary).

@madsmtm madsmtm added the enhancement New feature or request label Jan 19, 2026
Base automatically changed from madsmtm/buffer-helpers to master January 19, 2026 16:28
To make it explicit when you're accessing the buffer data as pixels.
@madsmtm madsmtm force-pushed the madsmtm/remove-deref branch 2 times, most recently from 492b336 to 7723663 Compare January 19, 2026 16:31
We want to migrate towards exposing either less structured buffers
(`[u8]`, useful for different formats) or more structured buffers
(`[Pixel]`, useful for ergonomics). `[u32]` is kind of in a weird state
in between these and has confusing interactions with endianess.

Since the current impls are not zero-cost on all backends, making them
be a potential invisible performance cliff for users, we'd prefer for
users to instead explicitly access the buffer's data in the format they
desire.
Serves as documentation for why we don't expose different `pixels` and
`pixels_mut` methods.
No longer really a necessary optimization, as accessing pixel data is an
explicit operation, not invisible inside `Deref[Mut]`.
It is no longer used, and likely won't be necessary in the future
either.
@madsmtm madsmtm force-pushed the madsmtm/remove-deref branch from 7723663 to 2944dc3 Compare January 19, 2026 16:54
@madsmtm madsmtm marked this pull request as ready for review January 19, 2026 16:57
@madsmtm madsmtm added this to the Softbuffer v0.5 milestone Jan 19, 2026
}

/// Pixel helper accessors.
/// Helper accessors for viewing the buffer's data as RGBA pixel data.
Copy link
Member

Choose a reason for hiding this comment

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

"viewing" -> not sure if we have a better word to describe "accessing/writing" as you just discouraged "reading" in the comment above.

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

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

3 participants