Skip to content

More map_label changes#9526

Open
andyleiserson wants to merge 1 commit into
gfx-rs:trunkfrom
andyleiserson:jj-push-nxst
Open

More map_label changes#9526
andyleiserson wants to merge 1 commit into
gfx-rs:trunkfrom
andyleiserson:jj-push-nxst

Conversation

@andyleiserson
Copy link
Copy Markdown
Contributor

@andyleiserson andyleiserson commented May 7, 2026

Small follow-up to #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.

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

Squash or Rebase? Squash

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.

@andyleiserson
Copy link
Copy Markdown
Contributor Author

Originally this PR also included the following change, but (as suggested by @kpreid) I've removed it since it seems significantly more controversial than the others.

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. Without this change, applications that want to pass an owned descriptor to create_texture have to pass &desc.map_label_and_view_formats(Option::clone, |v| v.as_ref()) instead of just &desc.

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