From 09a5348740803329c98f6422700569595c2be8c5 Mon Sep 17 00:00:00 2001 From: Poly Date: Wed, 3 Feb 2021 22:38:45 +0100 Subject: [wgpu 0.7] Update integration example --- examples/integration/src/main.rs | 8 ++++---- examples/integration/src/scene.rs | 40 +++++++++++++++++++-------------------- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'examples/integration') diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index 9b52f3a5..ec01c4e6 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -36,7 +36,7 @@ pub fn main() { let (mut device, queue) = futures::executor::block_on(async { let adapter = instance .request_adapter(&wgpu::RequestAdapterOptions { - power_preference: wgpu::PowerPreference::Default, + power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }) .await @@ -45,9 +45,9 @@ pub fn main() { adapter .request_device( &wgpu::DeviceDescriptor { + label: None, features: wgpu::Features::empty(), limits: wgpu::Limits::default(), - shader_validation: false, }, None, ) @@ -63,7 +63,7 @@ pub fn main() { device.create_swap_chain( &surface, &wgpu::SwapChainDescriptor { - usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, + usage: wgpu::TextureUsage::RENDER_ATTACHMENT, format: format, width: size.width, height: size.height, @@ -157,7 +157,7 @@ pub fn main() { swap_chain = device.create_swap_chain( &surface, &wgpu::SwapChainDescriptor { - usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, + usage: wgpu::TextureUsage::RENDER_ATTACHMENT, format: format, width: size.width, height: size.height, diff --git a/examples/integration/src/scene.rs b/examples/integration/src/scene.rs index 03a338c6..36c0a41d 100644 --- a/examples/integration/src/scene.rs +++ b/examples/integration/src/scene.rs @@ -19,6 +19,7 @@ impl Scene { background_color: Color, ) -> wgpu::RenderPass<'a> { encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: None, color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: target, resolve_target: None, @@ -48,10 +49,10 @@ impl Scene { fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline { let vs_module = - device.create_shader_module(wgpu::include_spirv!("shader/vert.spv")); + device.create_shader_module(&wgpu::include_spirv!("shader/vert.spv")); let fs_module = - device.create_shader_module(wgpu::include_spirv!("shader/frag.spv")); + device.create_shader_module(&wgpu::include_spirv!("shader/frag.spv")); let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { @@ -64,34 +65,33 @@ fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline { device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: None, layout: Some(&pipeline_layout), - vertex_stage: wgpu::ProgrammableStageDescriptor { + vertex: wgpu::VertexState { module: &vs_module, entry_point: "main", + buffers: &[], }, - fragment_stage: Some(wgpu::ProgrammableStageDescriptor { + fragment: Some(wgpu::FragmentState { module: &fs_module, entry_point: "main", + targets: &[wgpu::ColorTargetState { + format: wgpu::TextureFormat::Bgra8UnormSrgb, + color_blend: wgpu::BlendState::REPLACE, + alpha_blend: wgpu::BlendState::REPLACE, + write_mask: wgpu::ColorWrite::ALL, + }], }), - rasterization_state: Some(wgpu::RasterizationStateDescriptor { + primitive: wgpu::PrimitiveState { + topology: wgpu::PrimitiveTopology::TriangleList, front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::None, ..Default::default() - }), - primitive_topology: wgpu::PrimitiveTopology::TriangleList, - color_states: &[wgpu::ColorStateDescriptor { - format: wgpu::TextureFormat::Bgra8UnormSrgb, - color_blend: wgpu::BlendDescriptor::REPLACE, - alpha_blend: wgpu::BlendDescriptor::REPLACE, - write_mask: wgpu::ColorWrite::ALL, - }], - depth_stencil_state: None, - vertex_state: wgpu::VertexStateDescriptor { - index_format: wgpu::IndexFormat::Uint16, - vertex_buffers: &[], }, - sample_count: 1, - sample_mask: !0, - alpha_to_coverage_enabled: false, + depth_stencil: None, + multisample: wgpu::MultisampleState { + count: 1, + mask: !0, + alpha_to_coverage_enabled: false, + }, }); pipeline -- cgit From 21971e0037c2ddcb96fd48ea96332445de4137bb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 10 Mar 2021 01:59:02 +0100 Subject: Make `Clipboard` argument in `Widget` trait mutable --- examples/integration/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'examples/integration') diff --git a/examples/integration/src/main.rs b/examples/integration/src/main.rs index ec01c4e6..b57c73d8 100644 --- a/examples/integration/src/main.rs +++ b/examples/integration/src/main.rs @@ -5,7 +5,7 @@ use controls::Controls; use scene::Scene; use iced_wgpu::{wgpu, Backend, Renderer, Settings, Viewport}; -use iced_winit::{conversion, futures, program, winit, Debug, Size}; +use iced_winit::{conversion, futures, program, winit, Clipboard, Debug, Size}; use futures::task::SpawnExt; use winit::{ @@ -28,6 +28,7 @@ pub fn main() { ); let mut cursor_position = PhysicalPosition::new(-1.0, -1.0); let mut modifiers = ModifiersState::default(); + let mut clipboard = Clipboard::connect(&window); // Initialize wgpu let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY); @@ -141,8 +142,8 @@ pub fn main() { cursor_position, viewport.scale_factor(), ), - None, &mut renderer, + &mut clipboard, &mut debug, ); -- cgit From ae517b9fa033ba75df5fc6ce766698fab22504fa Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 11 Mar 2021 03:38:20 +0100 Subject: Add `clipboard` argument to `Application::update` --- examples/integration/src/controls.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'examples/integration') diff --git a/examples/integration/src/controls.rs b/examples/integration/src/controls.rs index 824f9f53..36ee9b7e 100644 --- a/examples/integration/src/controls.rs +++ b/examples/integration/src/controls.rs @@ -1,7 +1,7 @@ use iced_wgpu::Renderer; use iced_winit::{ - slider, Align, Color, Column, Command, Element, Length, Program, Row, - Slider, Text, + slider, Align, Clipboard, Color, Column, Command, Element, Length, Program, + Row, Slider, Text, }; pub struct Controls { @@ -30,8 +30,13 @@ impl Controls { impl Program for Controls { type Renderer = Renderer; type Message = Message; + type Clipboard = Clipboard; - fn update(&mut self, message: Message) -> Command { + fn update( + &mut self, + message: Message, + _clipboard: &mut Clipboard, + ) -> Command { match message { Message::BackgroundColorChanged(color) => { self.background_color = color; -- cgit From 9a2c78c4059d2be37d10adda397fb6e64f38ac02 Mon Sep 17 00:00:00 2001 From: Dispersia Date: Sun, 11 Apr 2021 18:55:57 -0700 Subject: Upgrade wgpu --- examples/integration/src/scene.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'examples/integration') diff --git a/examples/integration/src/scene.rs b/examples/integration/src/scene.rs index 36c0a41d..3e8277c8 100644 --- a/examples/integration/src/scene.rs +++ b/examples/integration/src/scene.rs @@ -20,8 +20,8 @@ impl Scene { ) -> wgpu::RenderPass<'a> { encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: None, - color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { - attachment: target, + color_attachments: &[wgpu::RenderPassColorAttachment { + view: target, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Clear({ @@ -75,15 +75,16 @@ fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline { entry_point: "main", targets: &[wgpu::ColorTargetState { format: wgpu::TextureFormat::Bgra8UnormSrgb, - color_blend: wgpu::BlendState::REPLACE, - alpha_blend: wgpu::BlendState::REPLACE, + blend: Some(wgpu::BlendState { + color: wgpu::BlendComponent::REPLACE, + alpha: wgpu::BlendComponent::REPLACE, + }), write_mask: wgpu::ColorWrite::ALL, }], }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, front_face: wgpu::FrontFace::Ccw, - cull_mode: wgpu::CullMode::None, ..Default::default() }, depth_stencil: None, -- cgit