Gfx: [hal] Traits shouldn't accept slices

Created on 21 Oct 2017  路  4Comments  路  Source: gfx-rs/gfx

E.g. Adapter::open accepts a slice, however we

1) first need to collect elements to
2) then create a slice from the Vec in order to
3) let the backend iterate over it and collect filtered and mapped versions of that iterator

Instead, maybe those methods should accept clone-able iterators?

easy hal ready for work api medium

Most helpful comment

I think we briefly touched in with @msiglreith earlier and agreed to move to iterators. Slices served well for simplicity earlier in development, but these days we can't afford the user to collect data into vectors.

All 4 comments

I think we briefly touched in with @msiglreith earlier and agreed to move to iterators. Slices served well for simplicity earlier in development, but these days we can't afford the user to collect data into vectors.

I believe this is most important for command buffer API, which can be used many times a frame and generally expected to be fast. There is just a few places where we accept slices there, so doing this part should be trivial. Device API, on the other hand, is supposed to be heavy, so heap allocation is not as much critical there.

As a workaround I collect iterator into SmallVec (big enough) to pass values into current API as a slice.

Done, see referenced commits

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjadczak picture mjadczak  路  4Comments

kvark picture kvark  路  3Comments

Lokathor picture Lokathor  路  4Comments

kvark picture kvark  路  4Comments

kvark picture kvark  路  3Comments