Skip to content
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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

kvark
Copy link
Member

@kvark kvark commented Jun 26, 2020

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:

  1. size is not zero
  2. alignment is not zero
  3. size is aligned

Now, it's just (3), size is aligned.

@kvark
Copy link
Member Author

kvark commented Jun 26, 2020

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 :)
@rukai @cwfitzgerald do you have a preference, or a strong feeling about this?

@cwfitzgerald
Copy link
Member

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 .get() noise to the code.

Copy link
Contributor

@rukai rukai left a 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(),
Copy link
Contributor

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?

Copy link
Member Author

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.

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.

3 participants