Skip to content

Conversation

@andyleiserson
Copy link
Contributor

@andyleiserson andyleiserson commented Jul 24, 2025

Fix one more nightly compile warning like the ones in #7964 that I didn't see before because I wasn't building Vulkan. (The compiler suggests the '_ lifetime but 'a seemed more appropriate, however, I don't claim to fully understand what's going on here.)

Reduce the value for an "unlimited" maximum buffer size from u64::MAX to 1 << 52 to avoid problems when the limit values are round-tripped through JS.

Although these changes both involve buffers, they are unrelated.

Testing
For the first change, just that it compiles. The second change resolves a problem running the CTS on Mac with the vulkan-portability feature enabled. (The problem might also be reproducible on Linux systems with NVIDIA GPUs.)

Squash or Rebase? Squash

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@andyleiserson andyleiserson requested a review from a team as a code owner July 24, 2025 17:38
i32::MAX as u64
} else {
u64::MAX
1u64 << 52
Copy link
Member

Choose a reason for hiding this comment

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

4 PiB should be enough for somebody driving Vulkan, eh? 🤡

@ErichDonGubler
Copy link
Member

Just needs a CHANGELOG entry, and I think this should be good to go.

Wish we had a way to test this…🤔

@andyleiserson
Copy link
Contributor Author

Do you foresee a way that this change is user-facing? My thought was that 4 PiB and 2**64 are functionally indistinguishable on any existing hardware. I'm not sure if you want a changelog entry because that's not your assessment, or if you want a changelog entry on the principle of noting even changes that we don't think have any impact, just so users may be aware of a change in that area if we happen to break something.

A different question, that relates to this code but not the change in this PR, is whether we really want to disallow any buffer over 2**31 bytes on desktop Linux systems without NVIDIA hardware. Still unlikely to matter for WebGPU given limits set elsewhere in the system, but possibly something that some wgpu use case might care about.

@ErichDonGubler
Copy link
Member

Do you foresee a way that this change is user-facing? My thought was that 4 PiB and 2**64 are functionally indistinguishable on any existing hardware. I'm not sure if you want a changelog entry because that's not your assessment, or if you want a changelog entry on the principle of noting even changes that we don't think have any impact, just so users may be aware of a change in that area if we happen to break something.

I'm definitely erring on the side of Hyrum's law here, nothing more intelligent than that. If you feel strongly about not including a CHANGELOG entry, then 🤷🏻‍♂️ I've already approved, feel free to merge.

A different question, that relates to this code but not the change in this PR, is whether we really want to disallow any buffer over 2**31 bytes on desktop Linux systems without NVIDIA hardware. Still unlikely to matter for WebGPU given limits set elsewhere in the system, but possibly something that some wgpu use case might care about.

Let's raise this in an issue or in community chat; I'm concerned about that question getting lost here, and I unfortunately don't feel like I can speculate without more time after the EOD I'm currently at. 😅

@andyleiserson andyleiserson merged commit bf86ac3 into gfx-rs:trunk Jul 25, 2025
40 checks passed
@andyleiserson andyleiserson deleted the vulkan branch July 25, 2025 18:17
buffer: &'a super::Buffer,
ranges: I,
) -> Option<impl 'a + Iterator<Item = vk::MappedMemoryRange>> {
) -> Option<impl 'a + Iterator<Item = vk::MappedMemoryRange<'a>>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

(The compiler suggests the '_ lifetime but 'a seemed more appropriate, however, I don't claim to fully understand what's going on here.)

What is going on is that vk::MappedMemoryRange contains a single CPU-side pointer, p_next, whose lifetime is tracked here.

Since nothing assigns anything borrowed to p_next, realistically this should have been 'static 1. However, since it holds a vk::DeviceMemory handle in there from buffer: &'a Buffer it might make sense to "cheat" and pretend it borrows something from buffer :)

Footnotes

  1. And ash / the Rust compiler allows that, because ::default() creates a 'static which will only be specialized when using a builder function that takes a borrow.

sharmajai pushed a commit to sharmajai/wgpu that referenced this pull request Oct 12, 2025
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