Skip to content

Commit

Permalink
Remove Arc from the WGPU types
Browse files Browse the repository at this point in the history
This isn't necessary anymore with the 0.24 release, as those types implement Clone.
  • Loading branch information
tronical committed Jan 17, 2025
1 parent 25c81a3 commit 0c29556
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
8 changes: 2 additions & 6 deletions examples/helpers/wgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use winit::{event_loop::EventLoop, window::WindowBuilder};
use super::{run, WindowSurface};

pub struct DemoSurface {
device: Arc<wgpu::Device>,
queue: Arc<wgpu::Queue>,
device: wgpu::Device,
queue: wgpu::Queue,
surface_config: wgpu::SurfaceConfiguration,
surface: wgpu::Surface<'static>,
}
Expand Down Expand Up @@ -136,10 +136,6 @@ pub async fn start_wgpu(
surface_config.format = swapchain_format;
surface.configure(&device, &surface_config);

let device = Arc::new(device);

let queue = Arc::new(queue);

let demo_surface = DemoSurface {
device: device.clone(),
queue: queue.clone(),
Expand Down
15 changes: 7 additions & 8 deletions src/renderer/wgpu.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use std::sync::Arc;

use rgb::bytemuck;
use wgpu::util::DeviceExt;
Expand Down Expand Up @@ -151,8 +150,8 @@ struct CachedPipeline {

/// WGPU renderer.
pub struct WGPURenderer {
device: Arc<wgpu::Device>,
queue: Arc<wgpu::Queue>,
device: wgpu::Device,
queue: wgpu::Queue,

shader_module: Rc<wgpu::ShaderModule>,

Expand All @@ -170,7 +169,7 @@ pub struct WGPURenderer {

impl WGPURenderer {
/// Creates a new renderer for the device.
pub fn new(device: Arc<wgpu::Device>, queue: Arc<wgpu::Queue>) -> Self {
pub fn new(device: wgpu::Device, queue: wgpu::Queue) -> Self {
let module = wgpu::include_wgsl!("wgpu/shader.wgsl");
let shader_module = Rc::new(device.create_shader_module(module));

Expand Down Expand Up @@ -1319,7 +1318,7 @@ impl BindGroupState {
}

struct RenderPassBuilder<'a> {
device: Arc<wgpu::Device>,
device: wgpu::Device,
encoder: &'a mut wgpu::CommandEncoder,
surface_view: std::rc::Rc<wgpu::TextureView>,
surface_format: wgpu::TextureFormat,
Expand All @@ -1340,7 +1339,7 @@ struct RenderPassBuilder<'a> {

impl<'a> RenderPassBuilder<'a> {
fn new(
device: Arc<wgpu::Device>,
device: wgpu::Device,
encoder: &'a mut wgpu::CommandEncoder,
screen_surface_format: wgpu::TextureFormat,
screen_view: [f32; 2],
Expand Down Expand Up @@ -1550,7 +1549,7 @@ impl<'a> RenderPassBuilder<'a> {
}

struct CommandToPipelineAndBindGroupMapper {
device: Arc<wgpu::Device>,
device: wgpu::Device,
empty_texture: Rc<wgpu::Texture>,
shader_module: Rc<wgpu::ShaderModule>,

Expand All @@ -1563,7 +1562,7 @@ struct CommandToPipelineAndBindGroupMapper {

impl CommandToPipelineAndBindGroupMapper {
fn new(
device: Arc<wgpu::Device>,
device: wgpu::Device,
empty_texture: Rc<wgpu::Texture>,
shader_module: Rc<wgpu::ShaderModule>,
bind_group_layout: Rc<wgpu::BindGroupLayout>,
Expand Down

0 comments on commit 0c29556

Please sign in to comment.