Use a StagingBelt in iced_wgpu for regular buffer uploads
This commit is contained in:
parent
1df1cf82f4
commit
2bb53ad6e7
10 changed files with 113 additions and 41 deletions
|
|
@ -30,6 +30,7 @@ pub struct Backend {
|
|||
pipeline_storage: pipeline::Storage,
|
||||
#[cfg(any(feature = "image", feature = "svg"))]
|
||||
image_pipeline: image::Pipeline,
|
||||
staging_belt: wgpu::util::StagingBelt,
|
||||
}
|
||||
|
||||
impl Backend {
|
||||
|
|
@ -61,6 +62,11 @@ impl Backend {
|
|||
|
||||
#[cfg(any(feature = "image", feature = "svg"))]
|
||||
image_pipeline,
|
||||
|
||||
// TODO: Resize belt smartly (?)
|
||||
// It would be great if the `StagingBelt` API exposed methods
|
||||
// for introspection to detect when a resize may be worth it.
|
||||
staging_belt: wgpu::util::StagingBelt::new(1024 * 100),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,6 +111,8 @@ impl Backend {
|
|||
&layers,
|
||||
);
|
||||
|
||||
self.staging_belt.finish();
|
||||
|
||||
self.render(
|
||||
device,
|
||||
encoder,
|
||||
|
|
@ -123,12 +131,17 @@ impl Backend {
|
|||
self.image_pipeline.end_frame();
|
||||
}
|
||||
|
||||
///
|
||||
pub fn recall(&mut self) {
|
||||
self.staging_belt.recall();
|
||||
}
|
||||
|
||||
fn prepare(
|
||||
&mut self,
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
format: wgpu::TextureFormat,
|
||||
_encoder: &mut wgpu::CommandEncoder,
|
||||
encoder: &mut wgpu::CommandEncoder,
|
||||
scale_factor: f32,
|
||||
target_size: Size<u32>,
|
||||
transformation: Transformation,
|
||||
|
|
@ -144,7 +157,8 @@ impl Backend {
|
|||
if !layer.quads.is_empty() {
|
||||
self.quad_pipeline.prepare(
|
||||
device,
|
||||
queue,
|
||||
encoder,
|
||||
&mut self.staging_belt,
|
||||
&layer.quads,
|
||||
transformation,
|
||||
scale_factor,
|
||||
|
|
@ -157,7 +171,8 @@ impl Backend {
|
|||
|
||||
self.triangle_pipeline.prepare(
|
||||
device,
|
||||
queue,
|
||||
encoder,
|
||||
&mut self.staging_belt,
|
||||
&layer.meshes,
|
||||
scaled,
|
||||
);
|
||||
|
|
@ -171,8 +186,8 @@ impl Backend {
|
|||
|
||||
self.image_pipeline.prepare(
|
||||
device,
|
||||
queue,
|
||||
_encoder,
|
||||
encoder,
|
||||
&mut self.staging_belt,
|
||||
&layer.images,
|
||||
scaled,
|
||||
scale_factor,
|
||||
|
|
@ -184,6 +199,7 @@ impl Backend {
|
|||
self.text_pipeline.prepare(
|
||||
device,
|
||||
queue,
|
||||
encoder,
|
||||
&layer.text,
|
||||
layer.bounds,
|
||||
scale_factor,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue