ash icon indicating copy to clipboard operation
ash copied to clipboard

Support for no-std

Open nyovaya opened this issue 5 years ago • 13 comments

Can this crate be changed in a way that it supports no-std(as Vulkan explicitly supports embedded devices) or does it depend on std exclusive stuff?

nyovaya avatar Jul 12 '20 16:07 nyovaya

Instead of Vec<T> we could use the crate 'smallvec' for no_std.

nyovaya avatar Jul 12 '20 18:07 nyovaya

Vec is available via the alloc crate in no_std. You could cfg out the high level wrappers if you want no-alloc support as well.

Ralith avatar Jul 12 '20 18:07 Ralith

I haven't looked at no_std at all yet. ash also fetches all the function pointers at runtime, is that a problem for embedded devices?

MaikKlein avatar Jul 12 '20 19:07 MaikKlein

Ok it seems like dynamic function loading is not trivial on no_std.

nyovaya avatar Jul 12 '20 19:07 nyovaya

Dynamic function loading is intrinsic to Vulkan, minimal entry points aside.

Ralith avatar Jul 12 '20 20:07 Ralith

Which "embedded devices" do you want to run vulkan on?

MaikKlein avatar Jul 13 '20 14:07 MaikKlein

Dont have anything explicit in mind but I think it would be some device with an RTOS or with a statically linked vulkan driver.

nyovaya avatar Jul 13 '20 15:07 nyovaya

Also, CStr is only in libstd. Hopefully Rust gets better null-terminated strings eventually...

anyputer avatar Dec 28 '20 03:12 anyputer

I do have some interest in this, there are few things I can think of to make moving towards being no_std capable (probably with alloc given we need dynamic function loading):

  • Make the generator generate types using core and alloc instead of std for imports where possible. This is a change that can be made without any api changes.
  • Regarding CStr(ing) we either need to hope those are moved to liballoc/libc/libcore or make ash depend on https://crates.io/crates/cstr_core when no_std is used.

I imagine there is more than those two things involved with no_std support.

i509VCB avatar Dec 26 '21 02:12 i509VCB

probably with alloc given we need dynamic function loading

Loading functions does not require alloc.

Ralith avatar Dec 26 '21 03:12 Ralith

probably with alloc given we need dynamic function loading

Loading functions does not require alloc.

Well I guess I am mistaken there.

I could make some pull requests to do some of the type import stuff for core and alloc if desired

i509VCB avatar Dec 26 '21 03:12 i509VCB

To help with this, I am implementing the following clippy lint: https://github.com/rust-lang/rust-clippy/pull/9103

The lint should help us ensure we don't forget any types that could be specified in core or alloc instead.

i509VCB avatar Jul 03 '22 02:07 i509VCB

Assuming all goes well for 1.64, CStr and CString will be accessible inside of core and alloc respectively: https://github.com/rust-lang/rust/pull/99277

The new clippy lints are also stabilized in 1.64

i509VCB avatar Aug 17 '22 23:08 i509VCB