Skip to content

More map_label changes#9526

Open
andyleiserson wants to merge 4 commits intogfx-rs:trunkfrom
andyleiserson:jj-push-nxst
Open

More map_label changes#9526
andyleiserson wants to merge 4 commits intogfx-rs:trunkfrom
andyleiserson:jj-push-nxst

Conversation

@andyleiserson
Copy link
Copy Markdown
Contributor

@andyleiserson andyleiserson commented May 7, 2026

A few changes that build on #9480 and #9481:

  • Adds a changelog entry for Change map_label_and_view_formats to take view_formats by reference #9481 since it's technically an API change
  • Changes all the map_label-style helpers (except for CreateShaderModuleDescriptorPassthrough) to have explicit lifetimes on references in the arguments. This allows doing foo.map_label(|l| l.as_ref()), with the lifetime passing through.
    • CreateShaderModuleDescriptorPassthrough is excluded because it has a lifetime parameter that is also passed through as a lifetime parameter on embedded structs, which prevents re-borrowing a &CreateShaderModuleDescriptorPassthrough with a shorter lifetime, which makes a mess of things if the lifetimes are bound.
  • Parameterizes the TextureDescriptor passed to create_texture by the view_formats type V: AsRef<[TextureFormat]>. This lets you pass &desc to create_texture when desc has a SmallVec (or other owned type) for view_formats.

The third change seems the most controversial, since it is putting a type parameter in the API in a way that I don't see precedent for. Without this change, applications have to pass &desc.map_label_and_view_formats(Option::clone, |v| v.as_ref()) to create_texture. Which, now that I write this up... doesn't seem that bad given that most of the time the view_formats is &[] anyways. So maybe we take this out.

Testing
Refactoring checked by Rust type system. It builds ⇒ shippit.

Squash or Rebase? Rebase (after squashing fixups)

Checklist

  • I self-reviewed and fully understand this PR.
  • WebGPU implementations built with wgpu may be affected behaviorally.
  • Validation and feature gates are in place to confine behavioral changes.
  • Tests demonstrate the validation and altered logic works.
  • CHANGELOG.md entries for the user-facing effects of this change are present.
  • The PR is minimal, and doesn't make sense to land as multiple PRs.
  • Commits are logically scoped and individually reviewable.
  • The PR description has enough context to understand the motivation and solution implemented.

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.

1 participant