-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fully use NonZero in gfx-memory #20
base: master
Are you sure you want to change the base?
Conversation
I had a strong desire to try this out, and got the code fully converted. Now I'm not sure if this was worth it :) |
I don't really have strong feelings either way. From an ideological perspective, if the contract is that it needs to be NonZero, it should be NonZero. On the other hand it's a largely internal api and this seems to add a lot of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think being able to specify at the API boundary that sizes must be nonzero is valuable.
I'm happy for this change to go ahead.
Alternatively we could add documentation for each exposed non zero field, but I cant think of a reason we shouldn't use a type for this.
@@ -146,16 +146,13 @@ impl<B: hal::Backend> Heaps<B> { | |||
device, | |||
memory_index as u32, | |||
kind, | |||
requirements.size, | |||
requirements.alignment, | |||
Size::new(requirements.size).unwrap(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we then change gfx::memory::Requirements size/alignment to use NonZeroU64 as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what I've been considering as well. I'm thinking of trying some NonZero in gfx-hal and seeing how it goes.
It's ok to let this PR to sit for a bit.
It could be nice to expose the NonZero contract for the API side when passing down allocation sizes and alignments.
Previously, the conditions on parameters where:
Now, it's just (3), size is aligned.