Merge branch 'master' into theming
This commit is contained in:
commit
fa55dff61d
34 changed files with 444 additions and 337 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "iced_wgpu"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
|
||||
edition = "2021"
|
||||
description = "A wgpu renderer for Iced"
|
||||
|
|
@ -28,8 +28,8 @@ spirv = ["wgpu/spirv"]
|
|||
webgl = ["wgpu/webgl"]
|
||||
|
||||
[dependencies]
|
||||
wgpu = "0.12"
|
||||
wgpu_glyph = "0.16"
|
||||
wgpu = "0.13"
|
||||
wgpu_glyph = "0.17"
|
||||
glyph_brush = "0.7"
|
||||
raw-window-handle = "0.4"
|
||||
log = "0.4"
|
||||
|
|
@ -39,7 +39,7 @@ kamadak-exif = "0.5"
|
|||
bitflags = "1.2"
|
||||
|
||||
[dependencies.bytemuck]
|
||||
version = "1.4"
|
||||
version = "1.9"
|
||||
features = ["derive"]
|
||||
|
||||
[dependencies.iced_native]
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ impl Pipeline {
|
|||
});
|
||||
|
||||
let shader =
|
||||
device.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("iced_wgpu::image::shader"),
|
||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(
|
||||
include_str!("shader/image.wgsl"),
|
||||
|
|
@ -176,7 +176,7 @@ impl Pipeline {
|
|||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
entry_point: "fs_main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[Some(wgpu::ColorTargetState {
|
||||
format,
|
||||
blend: Some(wgpu::BlendState {
|
||||
color: wgpu::BlendComponent {
|
||||
|
|
@ -191,7 +191,7 @@ impl Pipeline {
|
|||
},
|
||||
}),
|
||||
write_mask: wgpu::ColorWrites::ALL,
|
||||
}],
|
||||
})],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState {
|
||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
|
|
@ -406,14 +406,16 @@ impl Pipeline {
|
|||
let mut render_pass =
|
||||
encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("iced_wgpu::image render pass"),
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
view: target,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: true,
|
||||
color_attachments: &[Some(
|
||||
wgpu::RenderPassColorAttachment {
|
||||
view: target,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: true,
|
||||
},
|
||||
},
|
||||
}],
|
||||
)],
|
||||
depth_stencil_attachment: None,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl Pipeline {
|
|||
});
|
||||
|
||||
let shader =
|
||||
device.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("iced_wgpu::quad::shader"),
|
||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(
|
||||
include_str!("shader/quad.wgsl"),
|
||||
|
|
@ -100,7 +100,7 @@ impl Pipeline {
|
|||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
entry_point: "fs_main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[Some(wgpu::ColorTargetState {
|
||||
format,
|
||||
blend: Some(wgpu::BlendState {
|
||||
color: wgpu::BlendComponent {
|
||||
|
|
@ -115,7 +115,7 @@ impl Pipeline {
|
|||
},
|
||||
}),
|
||||
write_mask: wgpu::ColorWrites::ALL,
|
||||
}],
|
||||
})],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState {
|
||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
|
|
@ -211,14 +211,16 @@ impl Pipeline {
|
|||
let mut render_pass =
|
||||
encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("iced_wgpu::quad render pass"),
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
view: target,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: true,
|
||||
color_attachments: &[Some(
|
||||
wgpu::RenderPassColorAttachment {
|
||||
view: target,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: true,
|
||||
},
|
||||
},
|
||||
}],
|
||||
)],
|
||||
depth_stencil_attachment: None,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ impl Settings {
|
|||
impl Default for Settings {
|
||||
fn default() -> Settings {
|
||||
Settings {
|
||||
present_mode: wgpu::PresentMode::Mailbox,
|
||||
present_mode: wgpu::PresentMode::AutoVsync,
|
||||
internal_backend: wgpu::Backends::all(),
|
||||
default_font: None,
|
||||
default_text_size: 20,
|
||||
|
|
|
|||
|
|
@ -16,19 +16,19 @@ var<private> uvs: array<vec2<f32>, 6> = array<vec2<f32>, 6>(
|
|||
vec2<f32>(1.0, 1.0)
|
||||
);
|
||||
|
||||
[[group(0), binding(0)]] var u_sampler: sampler;
|
||||
[[group(1), binding(0)]] var u_texture: texture_2d<f32>;
|
||||
@group(0) @binding(0) var u_sampler: sampler;
|
||||
@group(1) @binding(0) var u_texture: texture_2d<f32>;
|
||||
|
||||
struct VertexInput {
|
||||
[[builtin(vertex_index)]] vertex_index: u32;
|
||||
};
|
||||
@builtin(vertex_index) vertex_index: u32,
|
||||
}
|
||||
|
||||
struct VertexOutput {
|
||||
[[builtin(position)]] position: vec4<f32>;
|
||||
[[location(0)]] uv: vec2<f32>;
|
||||
};
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(0) uv: vec2<f32>,
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
@vertex
|
||||
fn vs_main(input: VertexInput) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
out.uv = uvs[input.vertex_index];
|
||||
|
|
@ -37,7 +37,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
|
|||
return out;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn fs_main(input: VertexOutput) -> [[location(0)]] vec4<f32> {
|
||||
@fragment
|
||||
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return textureSample(u_texture, u_sampler, input.uv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
struct Globals {
|
||||
transform: mat4x4<f32>;
|
||||
};
|
||||
transform: mat4x4<f32>,
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> globals: Globals;
|
||||
[[group(0), binding(1)]] var u_sampler: sampler;
|
||||
[[group(1), binding(0)]] var u_texture: texture_2d_array<f32>;
|
||||
@group(0) @binding(0) var<uniform> globals: Globals;
|
||||
@group(0) @binding(1) var u_sampler: sampler;
|
||||
@group(1) @binding(0) var u_texture: texture_2d_array<f32>;
|
||||
|
||||
struct VertexInput {
|
||||
[[location(0)]] v_pos: vec2<f32>;
|
||||
[[location(1)]] pos: vec2<f32>;
|
||||
[[location(2)]] scale: vec2<f32>;
|
||||
[[location(3)]] atlas_pos: vec2<f32>;
|
||||
[[location(4)]] atlas_scale: vec2<f32>;
|
||||
[[location(5)]] layer: i32;
|
||||
};
|
||||
@location(0) v_pos: vec2<f32>,
|
||||
@location(1) pos: vec2<f32>,
|
||||
@location(2) scale: vec2<f32>,
|
||||
@location(3) atlas_pos: vec2<f32>,
|
||||
@location(4) atlas_scale: vec2<f32>,
|
||||
@location(5) layer: i32,
|
||||
}
|
||||
|
||||
struct VertexOutput {
|
||||
[[builtin(position)]] position: vec4<f32>;
|
||||
[[location(0)]] uv: vec2<f32>;
|
||||
[[location(1)]] layer: f32; // this should be an i32, but naga currently reads that as requiring interpolation.
|
||||
};
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(0) uv: vec2<f32>,
|
||||
@location(1) layer: f32, // this should be an i32, but naga currently reads that as requiring interpolation.
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
@vertex
|
||||
fn vs_main(input: VertexInput) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
|
|||
return out;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn fs_main(input: VertexOutput) -> [[location(0)]] vec4<f32> {
|
||||
@fragment
|
||||
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return textureSample(u_texture, u_sampler, input.uv, i32(input.layer));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,31 @@
|
|||
struct Globals {
|
||||
transform: mat4x4<f32>;
|
||||
scale: f32;
|
||||
};
|
||||
transform: mat4x4<f32>,
|
||||
scale: f32,
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> globals: Globals;
|
||||
@group(0) @binding(0) var<uniform> globals: Globals;
|
||||
|
||||
struct VertexInput {
|
||||
[[location(0)]] v_pos: vec2<f32>;
|
||||
[[location(1)]] pos: vec2<f32>;
|
||||
[[location(2)]] scale: vec2<f32>;
|
||||
[[location(3)]] color: vec4<f32>;
|
||||
[[location(4)]] border_color: vec4<f32>;
|
||||
[[location(5)]] border_radius: f32;
|
||||
[[location(6)]] border_width: f32;
|
||||
};
|
||||
@location(0) v_pos: vec2<f32>,
|
||||
@location(1) pos: vec2<f32>,
|
||||
@location(2) scale: vec2<f32>,
|
||||
@location(3) color: vec4<f32>,
|
||||
@location(4) border_color: vec4<f32>,
|
||||
@location(5) border_radius: f32,
|
||||
@location(6) border_width: f32,
|
||||
}
|
||||
|
||||
struct VertexOutput {
|
||||
[[builtin(position)]] position: vec4<f32>;
|
||||
[[location(0)]] color: vec4<f32>;
|
||||
[[location(1)]] border_color: vec4<f32>;
|
||||
[[location(2)]] pos: vec2<f32>;
|
||||
[[location(3)]] scale: vec2<f32>;
|
||||
[[location(4)]] border_radius: f32;
|
||||
[[location(5)]] border_width: f32;
|
||||
};
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(0) color: vec4<f32>,
|
||||
@location(1) border_color: vec4<f32>,
|
||||
@location(2) pos: vec2<f32>,
|
||||
@location(3) scale: vec2<f32>,
|
||||
@location(4) border_radius: f32,
|
||||
@location(5) border_width: f32,
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
@vertex
|
||||
fn vs_main(input: VertexInput) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
|
||||
|
|
@ -77,10 +77,10 @@ fn distance_alg(
|
|||
}
|
||||
|
||||
|
||||
[[stage(fragment)]]
|
||||
@fragment
|
||||
fn fs_main(
|
||||
input: VertexOutput
|
||||
) -> [[location(0)]] vec4<f32> {
|
||||
) -> @location(0) vec4<f32> {
|
||||
var mixed_color: vec4<f32> = input.color;
|
||||
|
||||
if (input.border_width > 0.0) {
|
||||
|
|
@ -96,7 +96,7 @@ fn fs_main(
|
|||
internal_border
|
||||
);
|
||||
|
||||
var border_mix: f32 = smoothStep(
|
||||
var border_mix: f32 = smoothstep(
|
||||
max(internal_border - 0.5, 0.0),
|
||||
internal_border + 0.5,
|
||||
internal_distance
|
||||
|
|
@ -112,7 +112,7 @@ fn fs_main(
|
|||
input.border_radius
|
||||
);
|
||||
|
||||
var radius_alpha: f32 = 1.0 - smoothStep(
|
||||
var radius_alpha: f32 = 1.0 - smoothstep(
|
||||
max(input.border_radius - 0.5, 0.0),
|
||||
input.border_radius + 0.5,
|
||||
dist);
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
struct Globals {
|
||||
transform: mat4x4<f32>;
|
||||
};
|
||||
transform: mat4x4<f32>,
|
||||
}
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> globals: Globals;
|
||||
@group(0) @binding(0) var<uniform> globals: Globals;
|
||||
|
||||
struct VertexInput {
|
||||
[[location(0)]] position: vec2<f32>;
|
||||
[[location(1)]] color: vec4<f32>;
|
||||
};
|
||||
@location(0) position: vec2<f32>,
|
||||
@location(1) color: vec4<f32>,
|
||||
}
|
||||
|
||||
struct VertexOutput {
|
||||
[[builtin(position)]] position: vec4<f32>;
|
||||
[[location(0)]] color: vec4<f32>;
|
||||
};
|
||||
@builtin(position) position: vec4<f32>,
|
||||
@location(0) color: vec4<f32>,
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
@vertex
|
||||
fn vs_main(input: VertexInput) -> VertexOutput {
|
||||
var out: VertexOutput;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ fn vs_main(input: VertexInput) -> VertexOutput {
|
|||
return out;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn fs_main(input: VertexOutput) -> [[location(0)]] vec4<f32> {
|
||||
@fragment
|
||||
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
||||
return input.color;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ impl Pipeline {
|
|||
});
|
||||
|
||||
let shader =
|
||||
device.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("iced_wgpu::triangle::shader"),
|
||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(
|
||||
include_str!("shader/triangle.wgsl"),
|
||||
|
|
@ -160,22 +160,11 @@ impl Pipeline {
|
|||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
entry_point: "fs_main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[Some(wgpu::ColorTargetState {
|
||||
format,
|
||||
blend: Some(wgpu::BlendState {
|
||||
color: wgpu::BlendComponent {
|
||||
src_factor: wgpu::BlendFactor::SrcAlpha,
|
||||
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
|
||||
operation: wgpu::BlendOperation::Add,
|
||||
},
|
||||
alpha: wgpu::BlendComponent {
|
||||
src_factor: wgpu::BlendFactor::One,
|
||||
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
|
||||
operation: wgpu::BlendOperation::Add,
|
||||
},
|
||||
}),
|
||||
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
||||
write_mask: wgpu::ColorWrites::ALL,
|
||||
}],
|
||||
})],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState {
|
||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
|
|
@ -361,11 +350,13 @@ impl Pipeline {
|
|||
let mut render_pass =
|
||||
encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("iced_wgpu::triangle render pass"),
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
view: attachment,
|
||||
resolve_target,
|
||||
ops: wgpu::Operations { load, store: true },
|
||||
}],
|
||||
color_attachments: &[Some(
|
||||
wgpu::RenderPassColorAttachment {
|
||||
view: attachment,
|
||||
resolve_target,
|
||||
ops: wgpu::Operations { load, store: true },
|
||||
},
|
||||
)],
|
||||
depth_stencil_attachment: None,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ impl Blit {
|
|||
});
|
||||
|
||||
let shader =
|
||||
device.create_shader_module(&wgpu::ShaderModuleDescriptor {
|
||||
device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||
label: Some("iced_wgpu::triangle::blit_shader"),
|
||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(
|
||||
include_str!("../shader/blit.wgsl"),
|
||||
|
|
@ -93,22 +93,13 @@ impl Blit {
|
|||
fragment: Some(wgpu::FragmentState {
|
||||
module: &shader,
|
||||
entry_point: "fs_main",
|
||||
targets: &[wgpu::ColorTargetState {
|
||||
targets: &[Some(wgpu::ColorTargetState {
|
||||
format,
|
||||
blend: Some(wgpu::BlendState {
|
||||
color: wgpu::BlendComponent {
|
||||
src_factor: wgpu::BlendFactor::SrcAlpha,
|
||||
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
|
||||
operation: wgpu::BlendOperation::Add,
|
||||
},
|
||||
alpha: wgpu::BlendComponent {
|
||||
src_factor: wgpu::BlendFactor::One,
|
||||
dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,
|
||||
operation: wgpu::BlendOperation::Add,
|
||||
},
|
||||
}),
|
||||
blend: Some(
|
||||
wgpu::BlendState::PREMULTIPLIED_ALPHA_BLENDING,
|
||||
),
|
||||
write_mask: wgpu::ColorWrites::ALL,
|
||||
}],
|
||||
})],
|
||||
}),
|
||||
primitive: wgpu::PrimitiveState {
|
||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
|
|
@ -178,14 +169,14 @@ impl Blit {
|
|||
let mut render_pass =
|
||||
encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
label: Some("iced_wgpu::triangle::msaa render pass"),
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||
view: target,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: true,
|
||||
},
|
||||
}],
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::{Backend, Color, Error, Renderer, Settings, Viewport};
|
||||
|
||||
use futures::task::SpawnExt;
|
||||
use futures::stream::{self, StreamExt};
|
||||
|
||||
use iced_graphics::compositor;
|
||||
use iced_native::futures;
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
|
|
@ -16,7 +17,6 @@ pub struct Compositor<Theme> {
|
|||
device: wgpu::Device,
|
||||
queue: wgpu::Queue,
|
||||
staging_belt: wgpu::util::StagingBelt,
|
||||
local_pool: futures::executor::LocalPool,
|
||||
format: wgpu::TextureFormat,
|
||||
theme: PhantomData<Theme>,
|
||||
}
|
||||
|
|
@ -62,38 +62,43 @@ impl<Theme> Compositor<Theme> {
|
|||
|
||||
log::info!("Selected: {:#?}", adapter.get_info());
|
||||
|
||||
let format = compatible_surface
|
||||
.as_ref()
|
||||
.and_then(|surface| surface.get_preferred_format(&adapter))?;
|
||||
let format = compatible_surface.as_ref().and_then(|surface| {
|
||||
surface.get_supported_formats(&adapter).first().copied()
|
||||
})?;
|
||||
|
||||
log::info!("Selected format: {:?}", format);
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let limits = wgpu::Limits::downlevel_webgl2_defaults()
|
||||
.using_resolution(adapter.limits());
|
||||
let limits = [wgpu::Limits::downlevel_webgl2_defaults()
|
||||
.using_resolution(adapter.limits())];
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let limits = wgpu::Limits::downlevel_defaults();
|
||||
let limits =
|
||||
[wgpu::Limits::default(), wgpu::Limits::downlevel_defaults()];
|
||||
|
||||
let (device, queue) = adapter
|
||||
.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
label: Some(
|
||||
"iced_wgpu::window::compositor device descriptor",
|
||||
),
|
||||
features: wgpu::Features::empty(),
|
||||
limits: wgpu::Limits {
|
||||
max_bind_groups: 2,
|
||||
..limits
|
||||
let limits = limits.into_iter().map(|limits| wgpu::Limits {
|
||||
max_bind_groups: 2,
|
||||
..limits
|
||||
});
|
||||
|
||||
let (device, queue) = stream::iter(limits)
|
||||
.filter_map(|limits| async {
|
||||
adapter.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
label: Some(
|
||||
"iced_wgpu::window::compositor device descriptor",
|
||||
),
|
||||
features: wgpu::Features::empty(),
|
||||
limits,
|
||||
},
|
||||
},
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.ok()?;
|
||||
None,
|
||||
).await.ok()
|
||||
})
|
||||
.boxed()
|
||||
.next()
|
||||
.await?;
|
||||
|
||||
let staging_belt = wgpu::util::StagingBelt::new(Self::CHUNK_SIZE);
|
||||
let local_pool = futures::executor::LocalPool::new();
|
||||
|
||||
Some(Compositor {
|
||||
instance,
|
||||
|
|
@ -102,7 +107,6 @@ impl<Theme> Compositor<Theme> {
|
|||
device,
|
||||
queue,
|
||||
staging_belt,
|
||||
local_pool,
|
||||
format,
|
||||
theme: PhantomData,
|
||||
})
|
||||
|
|
@ -196,24 +200,26 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
|
|||
label: Some(
|
||||
"iced_wgpu::window::Compositor render pass",
|
||||
),
|
||||
color_attachments: &[wgpu::RenderPassColorAttachment {
|
||||
view,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear({
|
||||
let [r, g, b, a] =
|
||||
background_color.into_linear();
|
||||
color_attachments: &[Some(
|
||||
wgpu::RenderPassColorAttachment {
|
||||
view,
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Clear({
|
||||
let [r, g, b, a] =
|
||||
background_color.into_linear();
|
||||
|
||||
wgpu::Color {
|
||||
r: f64::from(r),
|
||||
g: f64::from(g),
|
||||
b: f64::from(b),
|
||||
a: f64::from(a),
|
||||
}
|
||||
}),
|
||||
store: true,
|
||||
wgpu::Color {
|
||||
r: f64::from(r),
|
||||
g: f64::from(g),
|
||||
b: f64::from(b),
|
||||
a: f64::from(a),
|
||||
}
|
||||
}),
|
||||
store: true,
|
||||
},
|
||||
},
|
||||
}],
|
||||
)],
|
||||
depth_stencil_attachment: None,
|
||||
});
|
||||
|
||||
|
|
@ -231,16 +237,11 @@ impl<Theme> iced_graphics::window::Compositor for Compositor<Theme> {
|
|||
|
||||
// Submit work
|
||||
self.staging_belt.finish();
|
||||
self.queue.submit(Some(encoder.finish()));
|
||||
let _submission = self.queue.submit(Some(encoder.finish()));
|
||||
frame.present();
|
||||
|
||||
// Recall staging buffers
|
||||
self.local_pool
|
||||
.spawner()
|
||||
.spawn(self.staging_belt.recall())
|
||||
.expect("Recall staging belt");
|
||||
|
||||
self.local_pool.run_until_stalled();
|
||||
self.staging_belt.recall();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue