Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wgpu::Adapter API to users #340

Merged
merged 7 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle + HasRawDisplayHandle>

let pixels = Pixels {
context,
adapter,
surface_size,
present_mode,
render_texture_format,
Expand Down
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub struct Pixels {
surface_texture_format: wgpu::TextureFormat,
blend_state: wgpu::BlendState,
alpha_mode: wgpu::CompositeAlphaMode,
adapter: wgpu::Adapter,

// Pixel buffer
pixels: Vec<u8>,
Expand Down Expand Up @@ -275,6 +276,24 @@ impl Pixels {
self.context.scaling_renderer.clear_color = color;
}

/// Returns a reference of the `wgpu` adapter used by the crate.
///
/// The adapter can be used to retrieve runtime information about the host system
/// or the WGPU backend.
///
/// ```no_run
/// # use pixels::Pixels;
/// # let window = pixels_mocks::Rwh;
/// # let surface_texture = pixels::SurfaceTexture::new(320, 240, &window);
/// let mut pixels = Pixels::new(320, 240, surface_texture)?;
/// let adapter = pixels.adapter();
/// // Do something with the adapter.
/// # Ok::<(), pixels::Error>(())
/// ```
pub fn adapter(&self) -> &wgpu::Adapter {
&self.adapter
}

/// Resize the pixel buffer and zero its contents.
///
/// This does not resize the surface upon which the pixel buffer texture is rendered. Use
Expand Down