From f2d4a4f08491a307c1594d923b2e999cc7655b1d Mon Sep 17 00:00:00 2001 From: JMS55 <47158642+JMS55@users.noreply.github.com> Date: Sun, 28 Feb 2021 18:29:36 -0500 Subject: [PATCH] Upgrade to wgpu 0.7 (#134) Co-authored-by: Jay Oster --- .github/workflows/ci.yml | 4 +- Cargo.toml | 2 +- examples/custom-shader/src/main.rs | 2 +- examples/custom-shader/src/renderers.rs | 75 ++++---- examples/imgui-winit/Cargo.toml | 2 +- examples/imgui-winit/src/gui.rs | 1 + src/builder.rs | 222 ++++++++++++++++-------- src/renderers.rs | 75 ++++---- 8 files changed, 238 insertions(+), 145 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d127dc4..aa905ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: rust: - stable - beta - - 1.46.0 + - 1.48.0 steps: - name: Checkout sources uses: actions/checkout@v2 @@ -40,7 +40,7 @@ jobs: rust: - stable - beta - - 1.46.0 + - 1.48.0 steps: - name: Checkout sources uses: actions/checkout@v2 diff --git a/Cargo.toml b/Cargo.toml index 7abafaf..5f5bd37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ pollster = "0.2" raw-window-handle = "0.3" thiserror = "1.0" ultraviolet = "0.7" -wgpu = "0.6" +wgpu = "0.7" [dev-dependencies] pixels-mocks = { path = "internals/pixels-mocks" } diff --git a/examples/custom-shader/src/main.rs b/examples/custom-shader/src/main.rs index aa745d3..34cb2ec 100644 --- a/examples/custom-shader/src/main.rs +++ b/examples/custom-shader/src/main.rs @@ -153,7 +153,7 @@ fn create_noise_renderer(pixels: &Pixels) -> (wgpu::TextureView, NoiseRenderer) sample_count: 1, dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::Bgra8UnormSrgb, - usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::OUTPUT_ATTACHMENT, + usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::RENDER_ATTACHMENT, }; let scaled_texture = device .create_texture(&texture_descriptor) diff --git a/examples/custom-shader/src/renderers.rs b/examples/custom-shader/src/renderers.rs index 182fcb2..8841565 100644 --- a/examples/custom-shader/src/renderers.rs +++ b/examples/custom-shader/src/renderers.rs @@ -8,8 +8,8 @@ pub(crate) struct NoiseRenderer { impl NoiseRenderer { pub(crate) fn new(device: &wgpu::Device, texture_view: &wgpu::TextureView) -> Self { - let vs_module = device.create_shader_module(wgpu::include_spirv!("../shaders/vert.spv")); - let fs_module = device.create_shader_module(wgpu::include_spirv!("../shaders/frag.spv")); + let vs_module = device.create_shader_module(&wgpu::include_spirv!("../shaders/vert.spv")); + let fs_module = device.create_shader_module(&wgpu::include_spirv!("../shaders/frag.spv")); // Create a texture sampler with nearest neighbor let sampler = device.create_sampler(&wgpu::SamplerDescriptor { @@ -24,6 +24,7 @@ impl NoiseRenderer { lod_max_clamp: 1.0, compare: None, anisotropy_clamp: None, + border_color: None, }); // Create uniform buffer @@ -40,24 +41,28 @@ impl NoiseRenderer { wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { - component_type: wgpu::TextureComponentType::Uint, + ty: wgpu::BindingType::Texture { + sample_type: wgpu::TextureSampleType::Float { filterable: true }, multisampled: false, - dimension: wgpu::TextureViewDimension::D2, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, wgpu::BindGroupLayoutEntry { binding: 1, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::Sampler { comparison: false }, + ty: wgpu::BindingType::Sampler { + filtering: true, + comparison: false, + }, count: None, }, wgpu::BindGroupLayoutEntry { binding: 2, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::UniformBuffer { - dynamic: false, + ty: wgpu::BindingType::Buffer { + ty: wgpu::BufferBindingType::Uniform, + has_dynamic_offset: false, min_binding_size: None, }, count: None, @@ -78,7 +83,11 @@ impl NoiseRenderer { }, wgpu::BindGroupEntry { binding: 2, - resource: wgpu::BindingResource::Buffer(time_buffer.slice(..)), + resource: wgpu::BindingResource::Buffer { + buffer: &time_buffer, + offset: 0, + size: None, + }, }, ], }); @@ -92,37 +101,34 @@ impl NoiseRenderer { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("NoiseRenderer pipeline"), layout: Some(&pipeline_layout), - vertex_stage: wgpu::ProgrammableStageDescriptor { + vertex: wgpu::VertexState { module: &vs_module, entry_point: "main", + buffers: &[], }, - fragment_stage: Some(wgpu::ProgrammableStageDescriptor { - module: &fs_module, - entry_point: "main", - }), - rasterization_state: Some(wgpu::RasterizationStateDescriptor { + primitive: wgpu::PrimitiveState { + topology: wgpu::PrimitiveTopology::TriangleList, + strip_index_format: None, front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::None, - clamp_depth: false, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, - }), - 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: &[], + polygon_mode: wgpu::PolygonMode::Fill, }, - 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, + }, + 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, + }], + }), }); Self { @@ -142,6 +148,7 @@ impl NoiseRenderer { render_target: &wgpu::TextureView, ) { let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("NoiseRenderer render pass"), color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: render_target, resolve_target: None, diff --git a/examples/imgui-winit/Cargo.toml b/examples/imgui-winit/Cargo.toml index a205d28..7621eae 100644 --- a/examples/imgui-winit/Cargo.toml +++ b/examples/imgui-winit/Cargo.toml @@ -12,7 +12,7 @@ default = ["optimize"] [dependencies] env_logger = "0.8" imgui = "0.7" -imgui-wgpu = { git = "https://github.com/parasyte/imgui-wgpu-rs.git", rev = "8da89b3ad1ef54384b7ff4bd550adf9f808df1f8" } +imgui-wgpu = "0.14" imgui-winit-support = "0.7" log = "0.4" pixels = { path = "../.." } diff --git a/examples/imgui-winit/src/gui.rs b/examples/imgui-winit/src/gui.rs index 2cdc768..f11eb22 100644 --- a/examples/imgui-winit/src/gui.rs +++ b/examples/imgui-winit/src/gui.rs @@ -114,6 +114,7 @@ impl Gui { // Render Dear ImGui with WGPU let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("imgui"), color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: render_target, resolve_target: None, diff --git a/src/builder.rs b/src/builder.rs index 0880af2..03b0621 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -5,9 +5,9 @@ use raw_window_handle::HasRawWindowHandle; use std::env; /// A builder to help create customized pixel buffers. -pub struct PixelsBuilder<'req, 'win, W: HasRawWindowHandle> { +pub struct PixelsBuilder<'req, 'dev, 'win, W: HasRawWindowHandle> { request_adapter_options: Option>, - device_descriptor: wgpu::DeviceDescriptor, + device_descriptor: wgpu::DeviceDescriptor<'dev>, backend: wgpu::BackendBit, width: u32, height: u32, @@ -18,7 +18,7 @@ pub struct PixelsBuilder<'req, 'win, W: HasRawWindowHandle> { render_texture_format: wgpu::TextureFormat, } -impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { +impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W> { /// Create a builder that can be finalized into a [`Pixels`] pixel buffer. /// /// # Examples @@ -44,7 +44,7 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { width: u32, height: u32, surface_texture: SurfaceTexture<'win, W>, - ) -> PixelsBuilder<'req, 'win, W> { + ) -> PixelsBuilder<'req, 'dev, 'win, W> { assert!(width > 0); assert!(height > 0); @@ -66,7 +66,7 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { pub fn request_adapter_options( mut self, request_adapter_options: wgpu::RequestAdapterOptions<'req>, - ) -> PixelsBuilder<'req, 'win, W> { + ) -> PixelsBuilder<'req, 'dev, 'win, W> { self.request_adapter_options = Some(request_adapter_options); self } @@ -74,8 +74,8 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { /// Add options for requesting a [`wgpu::Device`]. pub fn device_descriptor( mut self, - device_descriptor: wgpu::DeviceDescriptor, - ) -> PixelsBuilder<'req, 'win, W> { + device_descriptor: wgpu::DeviceDescriptor<'dev>, + ) -> PixelsBuilder<'req, 'dev, 'win, W> { self.device_descriptor = device_descriptor; self } @@ -84,7 +84,7 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { /// /// The default value of this is [`wgpu::BackendBit::PRIMARY`], which enables /// the well supported backends for wgpu. - pub fn wgpu_backend(mut self, backend: wgpu::BackendBit) -> PixelsBuilder<'req, 'win, W> { + pub fn wgpu_backend(mut self, backend: wgpu::BackendBit) -> PixelsBuilder<'req, 'dev, 'win, W> { self.backend = backend; self } @@ -104,7 +104,10 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { /// /// This documentation is hidden because support for pixel aspect ratio is incomplete. #[doc(hidden)] - pub fn pixel_aspect_ratio(mut self, pixel_aspect_ratio: f64) -> PixelsBuilder<'req, 'win, W> { + pub fn pixel_aspect_ratio( + mut self, + pixel_aspect_ratio: f64, + ) -> PixelsBuilder<'req, 'dev, 'win, W> { assert!(pixel_aspect_ratio > 0.0); self.pixel_aspect_ratio = pixel_aspect_ratio; @@ -118,7 +121,7 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { /// The `wgpu` present mode will be set to `Fifo` when Vsync is enabled, or `Immediate` when /// Vsync is disabled. To set the present mode to `Mailbox` or another value, use the /// [`PixelsBuilder::present_mode`] method. - pub fn enable_vsync(mut self, enable_vsync: bool) -> PixelsBuilder<'req, 'win, W> { + pub fn enable_vsync(mut self, enable_vsync: bool) -> PixelsBuilder<'req, 'dev, 'win, W> { self.present_mode = if enable_vsync { wgpu::PresentMode::Fifo } else { @@ -131,7 +134,10 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { /// /// This differs from [`PixelsBuilder::enable_vsync`] by allowing the present mode to be set to /// any value. - pub fn present_mode(mut self, present_mode: wgpu::PresentMode) -> PixelsBuilder<'req, 'win, W> { + pub fn present_mode( + mut self, + present_mode: wgpu::PresentMode, + ) -> PixelsBuilder<'req, 'dev, 'win, W> { self.present_mode = present_mode; self } @@ -144,7 +150,7 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { pub fn texture_format( mut self, texture_format: wgpu::TextureFormat, - ) -> PixelsBuilder<'req, 'win, W> { + ) -> PixelsBuilder<'req, 'dev, 'win, W> { self.texture_format = texture_format; self } @@ -157,7 +163,7 @@ impl<'req, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'win, W> { pub fn render_texture_format( mut self, texture_format: wgpu::TextureFormat, - ) -> PixelsBuilder<'req, 'win, W> { + ) -> PixelsBuilder<'req, 'dev, 'win, W> { self.render_texture_format = texture_format; self } @@ -252,7 +258,7 @@ pub(crate) fn create_swap_chain( device.create_swap_chain( &surface, &wgpu::SwapChainDescriptor { - usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, + usage: wgpu::TextureUsage::RENDER_ATTACHMENT, format, width: surface_size.width, height: surface_size.height, @@ -318,80 +324,152 @@ pub(crate) fn create_backing_texture( ) } +#[rustfmt::skip] #[inline] const fn get_texture_format_size(texture_format: wgpu::TextureFormat) -> f32 { + use wgpu::TextureFormat::*; + + // TODO: Use constant arithmetic when supported. + // See: https://github.com/rust-lang/rust/issues/57241 match texture_format { - // 8-bit formats - wgpu::TextureFormat::R8Unorm - | wgpu::TextureFormat::R8Snorm - | wgpu::TextureFormat::R8Uint - | wgpu::TextureFormat::R8Sint => 1.0, + // 8-bit formats, 8 bits per component + R8Unorm + | R8Snorm + | R8Uint + | R8Sint => 1.0, // 8.0 / 8.0 - // 16-bit formats - wgpu::TextureFormat::R16Uint - | wgpu::TextureFormat::R16Sint - | wgpu::TextureFormat::R16Float - | wgpu::TextureFormat::Rg8Unorm - | wgpu::TextureFormat::Rg8Snorm - | wgpu::TextureFormat::Rg8Uint - | wgpu::TextureFormat::Rg8Sint => 2.0, + // 16-bit formats, 8 bits per component + R16Uint + | R16Sint + | R16Float + | Rg8Unorm + | Rg8Snorm + | Rg8Uint + | Rg8Sint => 2.0, // 16.0 / 8.0 - // 32-bit formats - wgpu::TextureFormat::R32Uint - | wgpu::TextureFormat::R32Sint - | wgpu::TextureFormat::R32Float - | wgpu::TextureFormat::Rg16Uint - | wgpu::TextureFormat::Rg16Sint - | wgpu::TextureFormat::Rg16Float - | wgpu::TextureFormat::Rgba8Unorm - | wgpu::TextureFormat::Rgba8UnormSrgb - | wgpu::TextureFormat::Rgba8Snorm - | wgpu::TextureFormat::Rgba8Uint - | wgpu::TextureFormat::Rgba8Sint - | wgpu::TextureFormat::Bgra8Unorm - | wgpu::TextureFormat::Bgra8UnormSrgb - | wgpu::TextureFormat::Rgb10a2Unorm - | wgpu::TextureFormat::Rg11b10Float - | wgpu::TextureFormat::Depth32Float - | wgpu::TextureFormat::Depth24Plus - | wgpu::TextureFormat::Depth24PlusStencil8 => 4.0, + // 32-bit formats, 8 bits per component + R32Uint + | R32Sint + | R32Float + | Rg16Uint + | Rg16Sint + | Rg16Float + | Rgba8Unorm + | Rgba8UnormSrgb + | Rgba8Snorm + | Rgba8Uint + | Rgba8Sint + | Bgra8Unorm + | Bgra8UnormSrgb + | Rgb10a2Unorm + | Rg11b10Float + | Depth32Float + | Depth24Plus + | Depth24PlusStencil8 => 4.0, // 32.0 / 8.0 - // 64-bit formats - wgpu::TextureFormat::Rg32Uint - | wgpu::TextureFormat::Rg32Sint - | wgpu::TextureFormat::Rg32Float - | wgpu::TextureFormat::Rgba16Uint - | wgpu::TextureFormat::Rgba16Sint - | wgpu::TextureFormat::Rgba16Float => 8.0, + // 64-bit formats, 8 bits per component + Rg32Uint + | Rg32Sint + | Rg32Float + | Rgba16Uint + | Rgba16Sint + | Rgba16Float => 8.0, // 64.0 / 8.0 - // 128-bit formats - wgpu::TextureFormat::Rgba32Uint - | wgpu::TextureFormat::Rgba32Sint - | wgpu::TextureFormat::Rgba32Float => 16.0, + // 128-bit formats, 8 bits per component + Rgba32Uint + | Rgba32Sint + | Rgba32Float => 16.0, // 128.0 / 8.0 // Compressed formats - wgpu::TextureFormat::Bc1RgbaUnorm - | wgpu::TextureFormat::Bc1RgbaUnormSrgb - | wgpu::TextureFormat::Bc4RUnorm - | wgpu::TextureFormat::Bc4RSnorm => 0.5, - wgpu::TextureFormat::Bc2RgbaUnorm - | wgpu::TextureFormat::Bc2RgbaUnormSrgb - | wgpu::TextureFormat::Bc3RgbaUnorm - | wgpu::TextureFormat::Bc3RgbaUnormSrgb - | wgpu::TextureFormat::Bc5RgUnorm - | wgpu::TextureFormat::Bc5RgSnorm - | wgpu::TextureFormat::Bc6hRgbUfloat - | wgpu::TextureFormat::Bc6hRgbSfloat - | wgpu::TextureFormat::Bc7RgbaUnorm - | wgpu::TextureFormat::Bc7RgbaUnormSrgb => 1.0, + // 4x4 blocks, 8 bytes per block + Bc1RgbaUnorm + | Bc1RgbaUnormSrgb + | Bc4RUnorm + | Bc4RSnorm + | Etc2RgbUnorm + | Etc2RgbUnormSrgb + | Etc2RgbA1Unorm + | Etc2RgbA1UnormSrgb + | EacRUnorm + | EacRSnorm => 0.5, // 4.0 * 4.0 / 8.0 + + // 4x4 blocks, 16 bytes per block + Bc2RgbaUnorm + | Bc2RgbaUnormSrgb + | Bc3RgbaUnorm + | Bc3RgbaUnormSrgb + | Bc5RgUnorm + | Bc5RgSnorm + | Bc6hRgbUfloat + | Bc6hRgbSfloat + | Bc7RgbaUnorm + | Bc7RgbaUnormSrgb + | Etc2RgbA8Unorm + | Etc2RgbA8UnormSrgb + | EtcRgUnorm + | EtcRgSnorm + | Astc4x4RgbaUnorm + | Astc4x4RgbaUnormSrgb => 1.0, // 4.0 * 4.0 / 16.0 + + // 5x4 blocks, 16 bytes per block + Astc5x4RgbaUnorm + | Astc5x4RgbaUnormSrgb => 1.25, // 5.0 * 4.0 / 16.0 + + // 5x5 blocks, 16 bytes per block + Astc5x5RgbaUnorm + | Astc5x5RgbaUnormSrgb => 1.5625, // 5.0 * 5.0 / 16.0 + + // 6x5 blocks, 16 bytes per block + Astc6x5RgbaUnorm + | Astc6x5RgbaUnormSrgb => 1.875, // 6.0 * 5.0 / 16.0 + + // 6x6 blocks, 16 bytes per block + Astc6x6RgbaUnorm + | Astc6x6RgbaUnormSrgb => 2.25, // 6.0 * 6.0 / 16.0 + + // 8x5 blocks, 16 bytes per block + Astc8x5RgbaUnorm + | Astc8x5RgbaUnormSrgb => 2.5, // 8.0 * 5.0 / 16.0 + + // 8x6 blocks, 16 bytes per block + Astc8x6RgbaUnorm + | Astc8x6RgbaUnormSrgb => 3.0, // 8.0 * 6.0 / 16.0 + + // 8x8 blocks, 16 bytes per block + Astc8x8RgbaUnorm + | Astc8x8RgbaUnormSrgb => 4.0, // 8.0 * 8.0 / 16.0 + + // 10x5 blocks, 16 bytes per block + Astc10x5RgbaUnorm + | Astc10x5RgbaUnormSrgb => 3.125, // 10.0 * 5.0 / 16.0 + + // 10x6 blocks, 16 bytes per block + Astc10x6RgbaUnorm + | Astc10x6RgbaUnormSrgb => 3.75, // 10.0 * 6.0 / 16.0 + + // 10x8 blocks, 16 bytes per block + Astc10x8RgbaUnorm + | Astc10x8RgbaUnormSrgb => 5.0, // 10.0 * 8.0 / 16.0 + + // 10x10 blocks, 16 bytes per block + Astc10x10RgbaUnorm + | Astc10x10RgbaUnormSrgb => 6.25, // 10.0 * 10.0 / 16.0 + + // 12x10 blocks, 16 bytes per block + Astc12x10RgbaUnorm + | Astc12x10RgbaUnormSrgb => 7.5, // 12.0 * 10.0 / 16.0 + + // 12x12 blocks, 16 bytes per block + Astc12x12RgbaUnorm + | Astc12x12RgbaUnormSrgb => 9.0, // 12.0 * 12.0 / 16.0 } } fn get_default_power_preference() -> wgpu::PowerPreference { env::var("PIXELS_HIGH_PERF").map_or_else( |_| { - env::var("PIXELS_LOW_POWER").map_or(wgpu::PowerPreference::Default, |_| { + env::var("PIXELS_LOW_POWER").map_or(wgpu::PowerPreference::default(), |_| { wgpu::PowerPreference::LowPower }) }, diff --git a/src/renderers.rs b/src/renderers.rs index 90a00bd..55f490f 100644 --- a/src/renderers.rs +++ b/src/renderers.rs @@ -19,8 +19,8 @@ impl ScalingRenderer { texture_size: &wgpu::Extent3d, render_texture_format: wgpu::TextureFormat, ) -> Self { - let vs_module = device.create_shader_module(wgpu::include_spirv!("../shaders/vert.spv")); - let fs_module = device.create_shader_module(wgpu::include_spirv!("../shaders/frag.spv")); + let vs_module = device.create_shader_module(&wgpu::include_spirv!("../shaders/vert.spv")); + let fs_module = device.create_shader_module(&wgpu::include_spirv!("../shaders/frag.spv")); // Create a texture sampler with nearest neighbor let sampler = device.create_sampler(&wgpu::SamplerDescriptor { @@ -35,6 +35,7 @@ impl ScalingRenderer { lod_max_clamp: 1.0, compare: None, anisotropy_clamp: None, + border_color: None, }); // Create uniform buffer @@ -58,24 +59,28 @@ impl ScalingRenderer { wgpu::BindGroupLayoutEntry { binding: 0, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { - component_type: wgpu::TextureComponentType::Uint, + ty: wgpu::BindingType::Texture { + sample_type: wgpu::TextureSampleType::Float { filterable: true }, multisampled: false, - dimension: wgpu::TextureViewDimension::D2, + view_dimension: wgpu::TextureViewDimension::D2, }, count: None, }, wgpu::BindGroupLayoutEntry { binding: 1, visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::Sampler { comparison: false }, + ty: wgpu::BindingType::Sampler { + filtering: true, + comparison: false, + }, count: None, }, wgpu::BindGroupLayoutEntry { binding: 2, visibility: wgpu::ShaderStage::VERTEX, - ty: wgpu::BindingType::UniformBuffer { - dynamic: false, + ty: wgpu::BindingType::Buffer { + ty: wgpu::BufferBindingType::Uniform, + has_dynamic_offset: false, min_binding_size: None, }, count: None, @@ -96,7 +101,11 @@ impl ScalingRenderer { }, wgpu::BindGroupEntry { binding: 2, - resource: wgpu::BindingResource::Buffer(uniform_buffer.slice(..)), + resource: wgpu::BindingResource::Buffer { + buffer: &uniform_buffer, + offset: 0, + size: None, + }, }, ], }); @@ -110,37 +119,34 @@ impl ScalingRenderer { let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("pixels_scaling_renderer_pipeline"), layout: Some(&pipeline_layout), - vertex_stage: wgpu::ProgrammableStageDescriptor { + vertex: wgpu::VertexState { module: &vs_module, entry_point: "main", + buffers: &[], }, - fragment_stage: Some(wgpu::ProgrammableStageDescriptor { - module: &fs_module, - entry_point: "main", - }), - rasterization_state: Some(wgpu::RasterizationStateDescriptor { + primitive: wgpu::PrimitiveState { + topology: wgpu::PrimitiveTopology::TriangleList, + strip_index_format: None, front_face: wgpu::FrontFace::Ccw, cull_mode: wgpu::CullMode::None, - clamp_depth: false, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, - }), - primitive_topology: wgpu::PrimitiveTopology::TriangleList, - color_states: &[wgpu::ColorStateDescriptor { - format: render_texture_format, - 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: &[], + polygon_mode: wgpu::PolygonMode::Fill, }, - 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, + }, + fragment: Some(wgpu::FragmentState { + module: &fs_module, + entry_point: "main", + targets: &[wgpu::ColorTargetState { + format: render_texture_format, + color_blend: wgpu::BlendState::REPLACE, + alpha_blend: wgpu::BlendState::REPLACE, + write_mask: wgpu::ColorWrite::ALL, + }], + }), }); Self { @@ -156,6 +162,7 @@ impl ScalingRenderer { pub fn render(&self, encoder: &mut wgpu::CommandEncoder, render_target: &wgpu::TextureView) { // Draw the updated texture to the render target let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("pixels_scaling_renderer_render_pass"), color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: render_target, resolve_target: None,