Skip to content

Replace u32 with NonZeroU32 in TextureView#865

Merged
bors[bot] merged 1 commit intogfx-rs:masterfrom
kunalmohan:texture-view
Aug 5, 2020
Merged

Replace u32 with NonZeroU32 in TextureView#865
bors[bot] merged 1 commit intogfx-rs:masterfrom
kunalmohan:texture-view

Conversation

@kunalmohan
Copy link
Copy Markdown
Contributor

Connections
Link to the issues addressed by this PR, or dependent PRs in other repositories

Description
Describe what problem this is solving, and how it's solved.
We now expose separate methods under Global to register error/invalid resources. So the check for mip_level_count = 0 and array_layer_count = 0 can be made on the client-side in Servo, and directly register an error resource instead of trying to create a real one.

Testing
Explain how this change is tested.
Not yet tested. Will be done wgpu-rs examples.

@kunalmohan
Copy link
Copy Markdown
Contributor Author

r?@kvark

Copy link
Copy Markdown
Contributor

@monocodus monocodus bot left a comment

Choose a reason for hiding this comment

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

This is an autogenerated code review.

Checker summary (by rust_clippy):
The tool has found 0 warnings, 1 errors.

@kunalmohan
Copy link
Copy Markdown
Contributor Author

Tested on wgpu-rs examples, works fine!

Copy link
Copy Markdown
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

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

bors r+


pub fn level_count(&mut self, level_count: u32) -> &mut Self {
self.level_count = Some(level_count);
self.level_count = Some(NonZeroU32::new(level_count).unwrap());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

now that I see it, I wonder if we should just do level_count = NonZero::U32(...)

Copy link
Copy Markdown
Contributor Author

@kunalmohan kunalmohan Aug 5, 2020

Choose a reason for hiding this comment

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

We wouldn't be checking for 0 then. Or should we add a separate if for that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah, I mean, it's a builder, and passing 0 explicitly is a weird case
anyhow, we can keep that in mind, no need to do these changes, and there isn't an agreement on it yet :)

@bors
Copy link
Copy Markdown
Contributor

bors bot commented Aug 5, 2020

@bors bors bot merged commit 8057acf into gfx-rs:master Aug 5, 2020
@kunalmohan kunalmohan deleted the texture-view branch August 5, 2020 17:17
bors bot added a commit to gfx-rs/wgpu-rs that referenced this pull request Aug 5, 2020
496: Replace u32 with NonZeroU32 in TextureView r=kvark a=kunalmohan

Includes gfx-rs/wgpu#865

Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
kvark pushed a commit to kvark/wgpu that referenced this pull request Jun 3, 2021
496: Replace u32 with NonZeroU32 in TextureView r=kvark a=kunalmohan

Includes gfx-rs#865

Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
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