summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Cupnfish <cupnfish@icloud.com>2022-07-02 15:39:42 +0800
committerLibravatar Cupnfish <cupnfish@icloud.com>2022-07-02 15:39:42 +0800
commitc148557cabf1fb9127b00b248479de2eb1d1d477 (patch)
tree1f3fe0a654effa351997e5462fae2536e118f517 /examples
parente6e3eff8762e9e8350f00b340348dc2261dd0053 (diff)
downloadiced-c148557cabf1fb9127b00b248479de2eb1d1d477.tar.gz
iced-c148557cabf1fb9127b00b248479de2eb1d1d477.tar.bz2
iced-c148557cabf1fb9127b00b248479de2eb1d1d477.zip
update `wgpu` to `0.13`
Diffstat (limited to 'examples')
-rw-r--r--examples/integration_wgpu/src/main.rs18
-rw-r--r--examples/integration_wgpu/src/scene.rs12
-rw-r--r--examples/integration_wgpu/src/shader/frag.wgsl4
-rw-r--r--examples/integration_wgpu/src/shader/vert.wgsl4
4 files changed, 15 insertions, 23 deletions
diff --git a/examples/integration_wgpu/src/main.rs b/examples/integration_wgpu/src/main.rs
index 045ee0d3..7235e72b 100644
--- a/examples/integration_wgpu/src/main.rs
+++ b/examples/integration_wgpu/src/main.rs
@@ -7,7 +7,6 @@ use scene::Scene;
use iced_wgpu::{wgpu, Backend, Renderer, Settings, Viewport};
use iced_winit::{conversion, futures, program, winit, Clipboard, Debug, Size};
-use futures::task::SpawnExt;
use winit::{
dpi::PhysicalPosition,
event::{Event, ModifiersState, WindowEvent},
@@ -90,9 +89,7 @@ pub fn main() {
let needed_limits = wgpu::Limits::default();
(
- surface
- .get_preferred_format(&adapter)
- .expect("Get preferred format"),
+ surface.get_supported_formats(&adapter)[0],
adapter
.request_device(
&wgpu::DeviceDescriptor {
@@ -114,15 +111,14 @@ pub fn main() {
format,
width: physical_size.width,
height: physical_size.height,
- present_mode: wgpu::PresentMode::Mailbox,
+ present_mode: wgpu::PresentMode::AutoVsync,
},
);
let mut resized = false;
- // Initialize staging belt and local pool
+ // Initialize staging belt
let mut staging_belt = wgpu::util::StagingBelt::new(5 * 1024);
- let mut local_pool = futures::executor::LocalPool::new();
// Initialize scene and GUI controls
let scene = Scene::new(&mut device, format);
@@ -207,7 +203,7 @@ pub fn main() {
format: format,
width: size.width,
height: size.height,
- present_mode: wgpu::PresentMode::Mailbox,
+ present_mode: wgpu::PresentMode::AutoVsync,
},
);
@@ -262,12 +258,8 @@ pub fn main() {
);
// And recall staging buffers
- local_pool
- .spawner()
- .spawn(staging_belt.recall())
- .expect("Recall staging buffers");
+ staging_belt.recall();
- local_pool.run_until_stalled();
}
Err(error) => match error {
wgpu::SurfaceError::OutOfMemory => {
diff --git a/examples/integration_wgpu/src/scene.rs b/examples/integration_wgpu/src/scene.rs
index fbda1326..af75e67c 100644
--- a/examples/integration_wgpu/src/scene.rs
+++ b/examples/integration_wgpu/src/scene.rs
@@ -23,7 +23,7 @@ impl Scene {
) -> wgpu::RenderPass<'a> {
encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: None,
- color_attachments: &[wgpu::RenderPassColorAttachment {
+ color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: target,
resolve_target: None,
ops: wgpu::Operations {
@@ -39,7 +39,7 @@ impl Scene {
}),
store: true,
},
- }],
+ })],
depth_stencil_attachment: None,
})
}
@@ -55,8 +55,8 @@ fn build_pipeline(
texture_format: wgpu::TextureFormat,
) -> wgpu::RenderPipeline {
let (vs_module, fs_module) = (
- device.create_shader_module(&wgpu::include_wgsl!("shader/vert.wgsl")),
- device.create_shader_module(&wgpu::include_wgsl!("shader/frag.wgsl")),
+ device.create_shader_module(wgpu::include_wgsl!("shader/vert.wgsl")),
+ device.create_shader_module(wgpu::include_wgsl!("shader/frag.wgsl")),
);
let pipeline_layout =
@@ -78,14 +78,14 @@ fn build_pipeline(
fragment: Some(wgpu::FragmentState {
module: &fs_module,
entry_point: "main",
- targets: &[wgpu::ColorTargetState {
+ targets: &[Some(wgpu::ColorTargetState {
format: texture_format,
blend: Some(wgpu::BlendState {
color: wgpu::BlendComponent::REPLACE,
alpha: wgpu::BlendComponent::REPLACE,
}),
write_mask: wgpu::ColorWrites::ALL,
- }],
+ })],
}),
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
diff --git a/examples/integration_wgpu/src/shader/frag.wgsl b/examples/integration_wgpu/src/shader/frag.wgsl
index a6f61336..cf27bb56 100644
--- a/examples/integration_wgpu/src/shader/frag.wgsl
+++ b/examples/integration_wgpu/src/shader/frag.wgsl
@@ -1,4 +1,4 @@
-[[stage(fragment)]]
-fn main() -> [[location(0)]] vec4<f32> {
+@fragment
+fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
}
diff --git a/examples/integration_wgpu/src/shader/vert.wgsl b/examples/integration_wgpu/src/shader/vert.wgsl
index 7ef47fb2..e353e6ba 100644
--- a/examples/integration_wgpu/src/shader/vert.wgsl
+++ b/examples/integration_wgpu/src/shader/vert.wgsl
@@ -1,5 +1,5 @@
-[[stage(vertex)]]
-fn main([[builtin(vertex_index)]] in_vertex_index: u32) -> [[builtin(position)]] vec4<f32> {
+@vertex
+fn main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4<f32> {
let x = f32(1 - i32(in_vertex_index)) * 0.5;
let y = f32(1 - i32(in_vertex_index & 1u) * 2) * 0.5;
return vec4<f32>(x, y, 0.0, 1.0);