Skip to content

Conversation

@bushrat011899
Copy link
Contributor

Objective

no_std support improves compatibility with the Rust ecosystem, in everything from Rust-for-Linux through to embedded and high-compatibility WASM.

Solution

  • Added no_std to image-canvas
  • Added no_std to image-drm
  • Added libm dependency to image-canvas for float operations without std. This is a high-quality library provided by rust-lang themselves.
  • Added a runtime-features feature to image-canvas for performing runtime feature detection (requires std).
  • Added compile-time feature detection, allowing architecture specific optimisations to be used without std.

Notes

  • This PR is mostly inspired by this comment.
  • I've added a little more structure to how ShuffleOps brings in architecture specific optimisations. This helps with feature flags and should be easier to maintain.
  • I chose not to add a libm feature as I suspect it may be required even more-so in the future of this crate. The alternative of inlining a powf implementation or additional conditional compilation seems undesirable to me.

Copy link
Member

@197g 197g left a comment

Choose a reason for hiding this comment

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

I've added a little more structure to how ShuffleOps brings in architecture specific optimisations. This helps with feature flags and should be easier to maintain.

❤️


/// Methods specifically with a dynamic layout.
impl<B> RawImage<B, DynLayout> {
#[expect(dead_code)]
Copy link
Member

@197g 197g May 13, 2025

Choose a reason for hiding this comment

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

Actually I don't expect this, this is an artifact of ongoing development work and should get linted as a nit that it needs to go, or be used (before the next release). Same with the Yuv420p` layout and so on. Rather have those as a separate PR (please amend the commit instead of just adding one on top, to avoid merge conflicts with my branch that does touch some of these lints).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried editing that particular commit directly but I think that didn't work as you'd like. If there's any issues with the history as-is just let me know and I can re-open this PR on a clean branch instead.

Copy link
Member

Choose a reason for hiding this comment

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

I can also squash-and-merge so no worries, it'd just have been neater.

Copy link
Member

Choose a reason for hiding this comment

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

So if you're not comfortable with that workflow in git before you can also just add commits and let me know to squash. We lose the history of individual commits but should be the same result.

@197g 197g merged commit fb94e13 into image-rs:master May 13, 2025
7 checks passed
@197g
Copy link
Member

197g commented May 13, 2025

Thank you a lot for the feedback on no_std needs. Went ahead and did the minor nits. All the activity around me at RustWeek is making me uncharacteristically wired.

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