From 270bd5d3ad35fbfff1917ffbd8503f05e15c8a9e Mon Sep 17 00:00:00 2001 From: Daniel Lehmann <59584561+danlehmann@users.noreply.github.com> Date: Mon, 6 Jul 2026 20:51:13 -0700 Subject: [PATCH] [hal] Add `BufferBinding::buffer` read accessor (#9820) --- CHANGELOG.md | 6 ++++++ wgpu-hal/src/lib.rs | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdd5e0d94..afc5cc932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,12 @@ Bottom level categories: ## Unreleased +### Added/New Features + +#### Hal + +- Add `BufferBinding::buffer`, a public read accessor for the bound buffer, which was previously inaccessible to out-of-tree `wgpu_hal::Api` implementations. By @danlehmann in [#9820](https://github.com/gfx-rs/wgpu/pull/9820). + ### Bug Fixes #### GLES diff --git a/wgpu-hal/src/lib.rs b/wgpu-hal/src/lib.rs index d4bfc287c..34f0d68d3 100644 --- a/wgpu-hal/src/lib.rs +++ b/wgpu-hal/src/lib.rs @@ -2344,7 +2344,8 @@ pub struct BufferBinding<'a, B: DynBuffer + ?Sized> { /// /// This is not fully `pub` to prevent direct construction of /// `BufferBinding`s, while still allowing public read access to the `offset` - /// and `size` properties. + /// and `size` properties. Read access to the buffer is available via + /// [`Self::buffer`]. pub(crate) buffer: &'a B, /// The offset at which the bound region starts. @@ -2427,6 +2428,11 @@ impl<'a, B: DynBuffer + ?Sized> BufferBinding<'a, B> { size: size.into(), } } + + /// The buffer being bound. + pub fn buffer(&self) -> &'a B { + self.buffer + } } #[derive(Debug)]