Skip to content

Commit 57fed7f

Browse files
committed
render: remove useless Arcs around wgpu objects
1 parent 71e8e31 commit 57fed7f

File tree

7 files changed

+136
-143
lines changed

7 files changed

+136
-143
lines changed

render/wgpu/src/backend.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
656656
);
657657

658658
let handle = BitmapHandle(Arc::new(Texture {
659-
texture: Arc::new(texture),
659+
texture,
660660
bind_linear: Default::default(),
661661
bind_nearest: Default::default(),
662662
copy_count: Cell::new(0),
@@ -912,7 +912,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
912912
| wgpu::TextureUsages::COPY_SRC,
913913
});
914914
BitmapHandle(Arc::new(Texture {
915-
texture: Arc::new(texture),
915+
texture,
916916
bind_linear: Default::default(),
917917
bind_nearest: Default::default(),
918918
copy_count: Cell::new(0),
@@ -1072,7 +1072,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
10721072
| wgpu::TextureUsages::COPY_SRC,
10731073
});
10741074
Ok(BitmapHandle(Arc::new(Texture {
1075-
texture: Arc::new(texture),
1075+
texture,
10761076
bind_linear: Default::default(),
10771077
bind_nearest: Default::default(),
10781078
copy_count: Cell::new(0),
@@ -1170,9 +1170,9 @@ pub enum RenderTargetMode {
11701170
// we will blend with the previous contents of the texture.
11711171
// This is used in `render_offscreen`, as we need to blend with the previous
11721172
// contents of our `BitmapData` texture
1173-
FreshWithTexture(Arc<wgpu::Texture>),
1173+
FreshWithTexture(wgpu::Texture),
11741174
// Use the provided texture as our frame buffer, and clear it with the given color.
1175-
ExistingWithColor(Arc<wgpu::Texture>, wgpu::Color),
1175+
ExistingWithColor(wgpu::Texture, wgpu::Color),
11761176
}
11771177

11781178
impl RenderTargetMode {

render/wgpu/src/context3d/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl WgpuContext3D {
122122
BitmapHandle(Arc::new(Texture {
123123
bind_linear: Default::default(),
124124
bind_nearest: Default::default(),
125-
texture: Arc::new(dummy_texture),
125+
texture: dummy_texture,
126126
copy_count: Cell::new(0),
127127
}))
128128
};
@@ -669,13 +669,13 @@ impl Context3D for WgpuContext3D {
669669
// which is what the Stage rendering code expects. In multisample mode,
670670
// this is our resolve texture.
671671
self.back_buffer_raw_texture_handle = BitmapHandle(Arc::new(Texture {
672-
texture: Arc::new(back_buffer_resolve_texture.unwrap()),
672+
texture: back_buffer_resolve_texture.unwrap(),
673673
bind_linear: Default::default(),
674674
bind_nearest: Default::default(),
675675
copy_count: Cell::new(0),
676676
}));
677677
self.front_buffer_raw_texture_handle = BitmapHandle(Arc::new(Texture {
678-
texture: Arc::new(front_buffer_resolve_texture.unwrap()),
678+
texture: front_buffer_resolve_texture.unwrap(),
679679
bind_linear: Default::default(),
680680
bind_nearest: Default::default(),
681681
copy_count: Cell::new(0),
@@ -685,13 +685,13 @@ impl Context3D for WgpuContext3D {
685685
// so our main texture gets used as the raw texture handle.
686686

687687
self.back_buffer_raw_texture_handle = BitmapHandle(Arc::new(Texture {
688-
texture: Arc::new(back_buffer_texture),
688+
texture: back_buffer_texture,
689689
bind_linear: Default::default(),
690690
bind_nearest: Default::default(),
691691
copy_count: Cell::new(0),
692692
}));
693693
self.front_buffer_raw_texture_handle = BitmapHandle(Arc::new(Texture {
694-
texture: Arc::new(front_buffer_texture),
694+
texture: front_buffer_texture,
695695
bind_linear: Default::default(),
696696
bind_nearest: Default::default(),
697697
copy_count: Cell::new(0),

render/wgpu/src/descriptors.rs

+82-86
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ pub struct Descriptors {
2121
pub bitmap_samplers: BitmapSamplers,
2222
pub bind_layouts: BindLayouts,
2323
pub quad: Quad,
24-
copy_pipeline: Mutex<FnvHashMap<(u32, wgpu::TextureFormat), Arc<wgpu::RenderPipeline>>>,
25-
copy_srgb_pipeline: Mutex<FnvHashMap<(u32, wgpu::TextureFormat), Arc<wgpu::RenderPipeline>>>,
24+
copy_pipeline: Mutex<FnvHashMap<(u32, wgpu::TextureFormat), wgpu::RenderPipeline>>,
25+
copy_srgb_pipeline: Mutex<FnvHashMap<(u32, wgpu::TextureFormat), wgpu::RenderPipeline>>,
2626
pub shaders: Shaders,
2727
pipelines: Mutex<FnvHashMap<(u32, wgpu::TextureFormat), Arc<Pipelines>>>,
2828
pub filters: Filters,
@@ -71,7 +71,7 @@ impl Descriptors {
7171
&self,
7272
format: wgpu::TextureFormat,
7373
msaa_sample_count: u32,
74-
) -> Arc<wgpu::RenderPipeline> {
74+
) -> wgpu::RenderPipeline {
7575
let mut pipelines = self
7676
.copy_srgb_pipeline
7777
.lock()
@@ -91,48 +91,46 @@ impl Descriptors {
9191
],
9292
push_constant_ranges: &[],
9393
});
94-
Arc::new(
95-
self.device
96-
.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
97-
label: create_debug_label!("Copy sRGB pipeline").as_deref(),
98-
layout: Some(copy_texture_pipeline_layout),
99-
vertex: wgpu::VertexState {
100-
module: &self.shaders.copy_srgb_shader,
101-
entry_point: Some("main_vertex"),
102-
buffers: &VERTEX_BUFFERS_DESCRIPTION_POS,
103-
compilation_options: Default::default(),
104-
},
105-
fragment: Some(wgpu::FragmentState {
106-
module: &self.shaders.copy_srgb_shader,
107-
entry_point: Some("main_fragment"),
108-
targets: &[Some(wgpu::ColorTargetState {
109-
format,
110-
// All of our blending has been done by now, so we want
111-
// to overwrite the target pixels without any blending
112-
blend: Some(wgpu::BlendState::REPLACE),
113-
write_mask: Default::default(),
114-
})],
115-
compilation_options: Default::default(),
116-
}),
117-
primitive: wgpu::PrimitiveState {
118-
topology: wgpu::PrimitiveTopology::TriangleList,
119-
strip_index_format: None,
120-
front_face: wgpu::FrontFace::Ccw,
121-
cull_mode: None,
122-
polygon_mode: wgpu::PolygonMode::default(),
123-
unclipped_depth: false,
124-
conservative: false,
125-
},
126-
depth_stencil: None,
127-
multisample: wgpu::MultisampleState {
128-
count: msaa_sample_count,
129-
mask: !0,
130-
alpha_to_coverage_enabled: false,
131-
},
132-
multiview: None,
133-
cache: None,
94+
self.device
95+
.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
96+
label: create_debug_label!("Copy sRGB pipeline").as_deref(),
97+
layout: Some(copy_texture_pipeline_layout),
98+
vertex: wgpu::VertexState {
99+
module: &self.shaders.copy_srgb_shader,
100+
entry_point: Some("main_vertex"),
101+
buffers: &VERTEX_BUFFERS_DESCRIPTION_POS,
102+
compilation_options: Default::default(),
103+
},
104+
fragment: Some(wgpu::FragmentState {
105+
module: &self.shaders.copy_srgb_shader,
106+
entry_point: Some("main_fragment"),
107+
targets: &[Some(wgpu::ColorTargetState {
108+
format,
109+
// All of our blending has been done by now, so we want
110+
// to overwrite the target pixels without any blending
111+
blend: Some(wgpu::BlendState::REPLACE),
112+
write_mask: Default::default(),
113+
})],
114+
compilation_options: Default::default(),
134115
}),
135-
)
116+
primitive: wgpu::PrimitiveState {
117+
topology: wgpu::PrimitiveTopology::TriangleList,
118+
strip_index_format: None,
119+
front_face: wgpu::FrontFace::Ccw,
120+
cull_mode: None,
121+
polygon_mode: wgpu::PolygonMode::default(),
122+
unclipped_depth: false,
123+
conservative: false,
124+
},
125+
depth_stencil: None,
126+
multisample: wgpu::MultisampleState {
127+
count: msaa_sample_count,
128+
mask: !0,
129+
alpha_to_coverage_enabled: false,
130+
},
131+
multiview: None,
132+
cache: None,
133+
})
136134
})
137135
.clone()
138136
}
@@ -141,7 +139,7 @@ impl Descriptors {
141139
&self,
142140
format: wgpu::TextureFormat,
143141
msaa_sample_count: u32,
144-
) -> Arc<wgpu::RenderPipeline> {
142+
) -> wgpu::RenderPipeline {
145143
let mut pipelines = self
146144
.copy_pipeline
147145
.lock()
@@ -161,48 +159,46 @@ impl Descriptors {
161159
],
162160
push_constant_ranges: &[],
163161
});
164-
Arc::new(
165-
self.device
166-
.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
167-
label: create_debug_label!("Copy pipeline").as_deref(),
168-
layout: Some(copy_texture_pipeline_layout),
169-
vertex: wgpu::VertexState {
170-
module: &self.shaders.copy_shader,
171-
entry_point: Some("main_vertex"),
172-
buffers: &VERTEX_BUFFERS_DESCRIPTION_POS,
173-
compilation_options: Default::default(),
174-
},
175-
fragment: Some(wgpu::FragmentState {
176-
module: &self.shaders.copy_shader,
177-
entry_point: Some("main_fragment"),
178-
targets: &[Some(wgpu::ColorTargetState {
179-
format,
180-
// All of our blending has been done by now, so we want
181-
// to overwrite the target pixels without any blending
182-
blend: Some(wgpu::BlendState::REPLACE),
183-
write_mask: Default::default(),
184-
})],
185-
compilation_options: Default::default(),
186-
}),
187-
primitive: wgpu::PrimitiveState {
188-
topology: wgpu::PrimitiveTopology::TriangleList,
189-
strip_index_format: None,
190-
front_face: wgpu::FrontFace::Ccw,
191-
cull_mode: None,
192-
polygon_mode: wgpu::PolygonMode::default(),
193-
unclipped_depth: false,
194-
conservative: false,
195-
},
196-
depth_stencil: None,
197-
multisample: wgpu::MultisampleState {
198-
count: msaa_sample_count,
199-
mask: !0,
200-
alpha_to_coverage_enabled: false,
201-
},
202-
multiview: None,
203-
cache: None,
162+
self.device
163+
.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
164+
label: create_debug_label!("Copy pipeline").as_deref(),
165+
layout: Some(copy_texture_pipeline_layout),
166+
vertex: wgpu::VertexState {
167+
module: &self.shaders.copy_shader,
168+
entry_point: Some("main_vertex"),
169+
buffers: &VERTEX_BUFFERS_DESCRIPTION_POS,
170+
compilation_options: Default::default(),
171+
},
172+
fragment: Some(wgpu::FragmentState {
173+
module: &self.shaders.copy_shader,
174+
entry_point: Some("main_fragment"),
175+
targets: &[Some(wgpu::ColorTargetState {
176+
format,
177+
// All of our blending has been done by now, so we want
178+
// to overwrite the target pixels without any blending
179+
blend: Some(wgpu::BlendState::REPLACE),
180+
write_mask: Default::default(),
181+
})],
182+
compilation_options: Default::default(),
204183
}),
205-
)
184+
primitive: wgpu::PrimitiveState {
185+
topology: wgpu::PrimitiveTopology::TriangleList,
186+
strip_index_format: None,
187+
front_face: wgpu::FrontFace::Ccw,
188+
cull_mode: None,
189+
polygon_mode: wgpu::PolygonMode::default(),
190+
unclipped_depth: false,
191+
conservative: false,
192+
},
193+
depth_stencil: None,
194+
multisample: wgpu::MultisampleState {
195+
count: msaa_sample_count,
196+
mask: !0,
197+
alpha_to_coverage_enabled: false,
198+
},
199+
multiview: None,
200+
cache: None,
201+
})
206202
})
207203
.clone()
208204
}

render/wgpu/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl QueueSyncHandle {
248248

249249
#[derive(Debug)]
250250
pub struct Texture {
251-
pub(crate) texture: Arc<wgpu::Texture>,
251+
pub(crate) texture: wgpu::Texture,
252252
bind_linear: OnceCell<BitmapBinds>,
253253
bind_nearest: OnceCell<BitmapBinds>,
254254
copy_count: Cell<u8>,

0 commit comments

Comments
 (0)