From 6f1f971716a691651a00758b9081e78a74036148 Mon Sep 17 00:00:00 2001 From: Rukai Date: Tue, 9 Jun 2020 20:49:03 +1000 Subject: [PATCH 01/17] Upgrade wgpu to latest git commit --- Cargo.toml | 2 +- examples/clipping.rs | 32 +++++++++++++++++++------------- examples/depth.rs | 42 +++++++++++++++++++++--------------------- examples/hello.rs | 32 +++++++++++++++++++------------- src/pipeline.rs | 16 ++++++++-------- src/pipeline/cache.rs | 29 ++++++++++++++++++++++------- 6 files changed, 90 insertions(+), 63 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 375842f..d5ed29b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = "0.5" +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "7b887f12a35c26a21f56f6540b1b771177dabd6a" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index 056ab40..8921dfd 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -12,28 +12,32 @@ fn main() -> Result<(), Box> { .build(&event_loop) .unwrap(); - let surface = wgpu::Surface::create(&window); + let instance = wgpu::Instance::new(); + let surface = unsafe { instance.create_surface(&window) }; // Initialize GPU let (device, queue) = futures::executor::block_on(async { - let adapter = wgpu::Adapter::request( + let adapter = instance.request_adapter( &wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, + wgpu::UnsafeExtensions::disallow(), wgpu::BackendBit::all(), ) .await .expect("Request adapter"); - adapter - .request_device(&wgpu::DeviceDescriptor { - extensions: wgpu::Extensions { - anisotropic_filtering: false, - }, - limits: wgpu::Limits { max_bind_groups: 1 }, - }) - .await + adapter.request_device( + &wgpu::DeviceDescriptor { + extensions: wgpu::Extensions::empty(), + limits: wgpu::Limits::default(), + shader_validation: false, + }, + None + ) + .await + .expect("Request device") }); // Prepare swap chain @@ -94,8 +98,10 @@ fn main() -> Result<(), Box> { ); // Get the next frame - let frame = - swap_chain.get_next_texture().expect("Get next frame"); + let frame = swap_chain + .get_next_frame() + .expect("Get next frame") + .output; // Clear frame { @@ -168,7 +174,7 @@ fn main() -> Result<(), Box> { ) .expect("Draw queued"); - queue.submit(&[encoder.finish()]); + queue.submit(Some(encoder.finish())); } _ => { *control_flow = winit::event_loop::ControlFlow::Wait; diff --git a/examples/depth.rs b/examples/depth.rs index 8368402..f26cac1 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -14,37 +14,34 @@ fn main() -> Result<(), Box> { .build(&event_loop) .unwrap(); - let surface = wgpu::Surface::create(&window); + let instance = wgpu::Instance::new(); + let surface = unsafe { instance.create_surface(&window) }; // Initialize GPU let (device, queue) = futures::executor::block_on(async { - let adapter = wgpu::Adapter::request( + let adapter = instance.request_adapter( &wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, + wgpu::UnsafeExtensions::disallow(), wgpu::BackendBit::all(), ) .await .expect("Request adapter"); - adapter - .request_device(&wgpu::DeviceDescriptor { - extensions: wgpu::Extensions { - anisotropic_filtering: false, - }, - limits: wgpu::Limits { max_bind_groups: 1 }, - }) - .await + adapter.request_device( + &wgpu::DeviceDescriptor { + extensions: wgpu::Extensions::empty(), + limits: wgpu::Limits::default(), + shader_validation: false, + }, + None + ) + .await + .expect("Request device") }); - let window = winit::window::WindowBuilder::new() - .with_resizable(false) - .build(&event_loop) - .unwrap(); - - let surface = wgpu::Surface::create(&window); - // Prepare swap chain and depth buffer let mut size = window.inner_size(); let mut new_size = None; @@ -102,8 +99,10 @@ fn main() -> Result<(), Box> { ); // Get the next frame - let frame = - swap_chain.get_next_texture().expect("Get next frame"); + let frame = swap_chain + .get_next_frame() + .expect("Get next frame") + .output; // Clear frame { @@ -167,8 +166,10 @@ fn main() -> Result<(), Box> { attachment: &depth_view, depth_load_op: wgpu::LoadOp::Clear, depth_store_op: wgpu::StoreOp::Store, + depth_read_only: false, stencil_load_op: wgpu::LoadOp::Clear, stencil_store_op: wgpu::StoreOp::Store, + stencil_read_only: false, clear_depth: -1.0, clear_stencil: 0, }, @@ -177,7 +178,7 @@ fn main() -> Result<(), Box> { ) .expect("Draw queued"); - queue.submit(&[encoder.finish()]); + queue.submit(Some(encoder.finish())); } _ => { *control_flow = winit::event_loop::ControlFlow::Wait; @@ -211,7 +212,6 @@ fn create_frame_views( height, depth: 1, }, - array_layer_count: 1, mip_level_count: 1, sample_count: 1, dimension: wgpu::TextureDimension::D2, diff --git a/examples/hello.rs b/examples/hello.rs index bf408a0..ac67f49 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -12,28 +12,32 @@ fn main() -> Result<(), Box> { .build(&event_loop) .unwrap(); - let surface = wgpu::Surface::create(&window); + let instance = wgpu::Instance::new(); + let surface = unsafe { instance.create_surface(&window) }; // Initialize GPU let (device, queue) = futures::executor::block_on(async { - let adapter = wgpu::Adapter::request( + let adapter = instance.request_adapter( &wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, + wgpu::UnsafeExtensions::disallow(), wgpu::BackendBit::all(), ) .await .expect("Request adapter"); - adapter - .request_device(&wgpu::DeviceDescriptor { - extensions: wgpu::Extensions { - anisotropic_filtering: false, - }, - limits: wgpu::Limits { max_bind_groups: 1 }, - }) - .await + adapter.request_device( + &wgpu::DeviceDescriptor { + extensions: wgpu::Extensions::empty(), + limits: wgpu::Limits::default(), + shader_validation: false, + }, + None + ) + .await + .expect("Request device") }); // Prepare swap chain @@ -94,8 +98,10 @@ fn main() -> Result<(), Box> { ); // Get the next frame - let frame = - swap_chain.get_next_texture().expect("Get next frame"); + let frame = swap_chain + .get_next_frame() + .expect("Get next frame") + .output; // Clear frame { @@ -149,7 +155,7 @@ fn main() -> Result<(), Box> { ) .expect("Draw queued"); - queue.submit(&[encoder.finish()]); + queue.submit(Some(encoder.finish())); } _ => { *control_flow = winit::event_loop::ControlFlow::Wait; diff --git a/src/pipeline.rs b/src/pipeline.rs index a912a05..3b072e5 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -138,6 +138,7 @@ impl Pipeline { size: mem::size_of::() as u64 * instances.len() as u64, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, + mapped_at_creation: false, }); self.supported_instances = instances.len(); @@ -189,9 +190,7 @@ fn build( mag_filter: filter_mode, min_filter: filter_mode, mipmap_filter: filter_mode, - lod_min_clamp: 0.0, - lod_max_clamp: 0.0, - compare: wgpu::CompareFunction::Always, + ..Default::default() }); let cache = Cache::new(device, cache_width, cache_height); @@ -204,11 +203,13 @@ fn build( binding: 0, visibility: wgpu::ShaderStage::VERTEX, ty: wgpu::BindingType::UniformBuffer { dynamic: false }, + ..Default::default() }, wgpu::BindGroupLayoutEntry { binding: 1, visibility: wgpu::ShaderStage::FRAGMENT, ty: wgpu::BindingType::Sampler { comparison: false }, + ..Default::default() }, wgpu::BindGroupLayoutEntry { binding: 2, @@ -218,6 +219,7 @@ fn build( component_type: wgpu::TextureComponentType::Float, multisampled: false, }, + ..Default::default() }, ], }); @@ -235,6 +237,7 @@ fn build( size: mem::size_of::() as u64 * Instance::INITIAL_AMOUNT as u64, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, + mapped_at_creation: false, }); let layout = @@ -386,7 +389,7 @@ fn draw( render_pass.set_pipeline(&pipeline.raw); render_pass.set_bind_group(0, &pipeline.uniforms, &[]); - render_pass.set_vertex_buffer(0, &pipeline.instances, 0, 0); + render_pass.set_vertex_buffer(0, pipeline.instances.slice(..)); if let Some(region) = region { render_pass.set_scissor_rect( @@ -413,10 +416,7 @@ fn create_uniforms( bindings: &[ wgpu::Binding { binding: 0, - resource: wgpu::BindingResource::Buffer { - buffer: transform, - range: 0..64, - }, + resource: wgpu::BindingResource::Buffer(transform.slice(..)), }, wgpu::Binding { binding: 1, diff --git a/src/pipeline/cache.rs b/src/pipeline/cache.rs index f920a8e..ac2ce1b 100644 --- a/src/pipeline/cache.rs +++ b/src/pipeline/cache.rs @@ -12,7 +12,6 @@ impl Cache { height, depth: 1, }, - array_layer_count: 1, dimension: wgpu::TextureDimension::D2, format: wgpu::TextureFormat::R8Unorm, usage: wgpu::TextureUsage::COPY_DST | wgpu::TextureUsage::SAMPLED, @@ -33,19 +32,35 @@ impl Cache { size: [u16; 2], data: &[u8], ) { - let buffer = - device.create_buffer_with_data(data, wgpu::BufferUsage::COPY_SRC); + let width = size[0] as usize; + let height = size[1] as usize; + + // It is a webgpu requirement that: + // BufferCopyView.layout.bytes_per_row % wgpu::COPY_BYTES_PER_ROW_ALIGNMENT == 0 + // So we calculate padded_width by rounding width + // up to the next multiple of wgpu::COPY_BYTES_PER_ROW_ALIGNMENT. + let align = wgpu::COPY_BYTES_PER_ROW_ALIGNMENT as usize; + let padded_width_padding = (align - width % align) % align; + let padded_width = width + padded_width_padding; + + let mut padded_data = vec![0; padded_width * height]; + for row in 0..height { + padded_data[row * padded_width .. row * padded_width + width] + .copy_from_slice(&data[row * width .. (row + 1) * width]) + } + let buffer = device.create_buffer_with_data(&padded_data, wgpu::BufferUsage::COPY_SRC); encoder.copy_buffer_to_texture( wgpu::BufferCopyView { buffer: &buffer, - offset: 0, - bytes_per_row: size[0] as u32, - rows_per_image: size[1] as u32, + layout: wgpu::TextureDataLayout { + offset: 0, + bytes_per_row: padded_width as u32, + rows_per_image: height as u32, + } }, wgpu::TextureCopyView { texture: &self.texture, - array_layer: 0, mip_level: 0, origin: wgpu::Origin3d { x: u32::from(offset[0]), From 3d0e7d17b16877a5c79ea4b3734c1974f8a43a41 Mon Sep 17 00:00:00 2001 From: Rukai Date: Mon, 15 Jun 2020 00:09:57 +1000 Subject: [PATCH 02/17] Update wgpu to the latest commit --- Cargo.toml | 2 +- src/pipeline.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d5ed29b..ee8c6b4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "7b887f12a35c26a21f56f6540b1b771177dabd6a" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "16054f2e418a746277e9d11fd7291c6a93bcaa98" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/src/pipeline.rs b/src/pipeline.rs index 3b072e5..0a73029 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -424,7 +424,7 @@ fn create_uniforms( }, wgpu::Binding { binding: 2, - resource: wgpu::BindingResource::TextureView(cache), + resource: wgpu::BindingResource::TextureView { view: cache, read_only_depth_stencil: false } }, ], }) From 63f4f83645f846dde8592b6b61d1f5474d967b07 Mon Sep 17 00:00:00 2001 From: Rukai Date: Tue, 16 Jun 2020 21:33:15 +1000 Subject: [PATCH 03/17] Update to latest wgpu commit --- Cargo.toml | 2 +- src/pipeline.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ee8c6b4..22a79ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "16054f2e418a746277e9d11fd7291c6a93bcaa98" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "0e2b612c5f33862b328b179e09ae0598cdb21fae" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/src/pipeline.rs b/src/pipeline.rs index 0a73029..3b072e5 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -424,7 +424,7 @@ fn create_uniforms( }, wgpu::Binding { binding: 2, - resource: wgpu::BindingResource::TextureView { view: cache, read_only_depth_stencil: false } + resource: wgpu::BindingResource::TextureView(cache), }, ], }) From f26352c7e9cf7c0c68a2640595cb6c187e7b68fa Mon Sep 17 00:00:00 2001 From: Rukai Date: Wed, 17 Jun 2020 21:29:59 +1000 Subject: [PATCH 04/17] Update to latest wgpu commit --- Cargo.toml | 2 +- src/pipeline.rs | 38 ++++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 22a79ca..4cda56e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "0e2b612c5f33862b328b179e09ae0598cdb21fae" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "0f55a67af2a012cea7681318b3786cf6aebde598" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/src/pipeline.rs b/src/pipeline.rs index 3b072e5..dc1fb56 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -199,28 +199,30 @@ fn build( device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { label: Some("wgpu_glyph::Pipeline uniforms"), bindings: &[ - wgpu::BindGroupLayoutEntry { - binding: 0, - visibility: wgpu::ShaderStage::VERTEX, - ty: wgpu::BindingType::UniformBuffer { dynamic: false }, - ..Default::default() - }, - wgpu::BindGroupLayoutEntry { - binding: 1, - visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::Sampler { comparison: false }, - ..Default::default() - }, - wgpu::BindGroupLayoutEntry { - binding: 2, - visibility: wgpu::ShaderStage::FRAGMENT, - ty: wgpu::BindingType::SampledTexture { + wgpu::BindGroupLayoutEntry::new( + 0, + wgpu::ShaderStage::VERTEX, + wgpu::BindingType::UniformBuffer { + dynamic: false, + min_binding_size: wgpu::NonZeroBufferAddress::new( + mem::size_of::<[f32; 16]>() as u64 + ) + }, + ), + wgpu::BindGroupLayoutEntry::new( + 1, + wgpu::ShaderStage::FRAGMENT, + wgpu::BindingType::Sampler { comparison: false }, + ), + wgpu::BindGroupLayoutEntry::new( + 2, + wgpu::ShaderStage::FRAGMENT, + wgpu::BindingType::SampledTexture { dimension: wgpu::TextureViewDimension::D2, component_type: wgpu::TextureComponentType::Float, multisampled: false, }, - ..Default::default() - }, + ), ], }); From 682e5917c187d856e787205146fdf764f763db45 Mon Sep 17 00:00:00 2001 From: Rukai Date: Thu, 18 Jun 2020 18:44:29 +1000 Subject: [PATCH 05/17] Update to latest wgpu commit --- Cargo.toml | 2 +- src/pipeline.rs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4cda56e..80c545e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "0f55a67af2a012cea7681318b3786cf6aebde598" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "69797d5421478a934530323dc7f1635d869ec1e6" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/src/pipeline.rs b/src/pipeline.rs index dc1fb56..2e641dd 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -247,15 +247,11 @@ fn build( bind_group_layouts: &[&uniform_layout], }); - let vs = include_bytes!("shader/vertex.spv"); - let vs_module = device.create_shader_module( - &wgpu::read_spirv(std::io::Cursor::new(&vs[..])).unwrap(), - ); + let vs_module + = device.create_shader_module(wgpu::include_spirv!("shader/vertex.spv")); - let fs = include_bytes!("shader/fragment.spv"); - let fs_module = device.create_shader_module( - &wgpu::read_spirv(std::io::Cursor::new(&fs[..])).unwrap(), - ); + let fs_module + = device.create_shader_module(wgpu::include_spirv!("shader/fragment.spv")); let raw = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { layout: &layout, From d5ae105d59829e19d55a058fc972bfb50f8435f2 Mon Sep 17 00:00:00 2001 From: Rukai Date: Sat, 20 Jun 2020 16:48:22 +1000 Subject: [PATCH 06/17] Update to latest wgpu --- Cargo.toml | 2 +- examples/clipping.rs | 3 +-- examples/depth.rs | 3 +-- examples/hello.rs | 3 +-- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 80c545e..ace83cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "69797d5421478a934530323dc7f1635d869ec1e6" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "5a7beb6e6ce81dbee43934c35f58c7b2fd50d9a0" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index 8921dfd..92f668b 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -12,7 +12,7 @@ fn main() -> Result<(), Box> { .build(&event_loop) .unwrap(); - let instance = wgpu::Instance::new(); + let instance = wgpu::Instance::new(wgpu::BackendBit::all()); let surface = unsafe { instance.create_surface(&window) }; // Initialize GPU @@ -23,7 +23,6 @@ fn main() -> Result<(), Box> { compatible_surface: Some(&surface), }, wgpu::UnsafeExtensions::disallow(), - wgpu::BackendBit::all(), ) .await .expect("Request adapter"); diff --git a/examples/depth.rs b/examples/depth.rs index f26cac1..d585304 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -14,7 +14,7 @@ fn main() -> Result<(), Box> { .build(&event_loop) .unwrap(); - let instance = wgpu::Instance::new(); + let instance = wgpu::Instance::new(wgpu::BackendBit::all()); let surface = unsafe { instance.create_surface(&window) }; // Initialize GPU @@ -25,7 +25,6 @@ fn main() -> Result<(), Box> { compatible_surface: Some(&surface), }, wgpu::UnsafeExtensions::disallow(), - wgpu::BackendBit::all(), ) .await .expect("Request adapter"); diff --git a/examples/hello.rs b/examples/hello.rs index ac67f49..eb84b10 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -12,7 +12,7 @@ fn main() -> Result<(), Box> { .build(&event_loop) .unwrap(); - let instance = wgpu::Instance::new(); + let instance = wgpu::Instance::new(wgpu::BackendBit::all()); let surface = unsafe { instance.create_surface(&window) }; // Initialize GPU @@ -23,7 +23,6 @@ fn main() -> Result<(), Box> { compatible_surface: Some(&surface), }, wgpu::UnsafeExtensions::disallow(), - wgpu::BackendBit::all(), ) .await .expect("Request adapter"); From fcb6b1a0c8cb90c246bc069d95c2998027b94554 Mon Sep 17 00:00:00 2001 From: Rukai Date: Mon, 22 Jun 2020 20:12:08 +1000 Subject: [PATCH 07/17] Update to latest wgpu commit --- Cargo.toml | 2 +- examples/clipping.rs | 15 ++++++++------- examples/depth.rs | 31 ++++++++++++++++--------------- examples/hello.rs | 15 ++++++++------- src/pipeline.rs | 14 ++++---------- 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ace83cb..1fb7616 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "5a7beb6e6ce81dbee43934c35f58c7b2fd50d9a0" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "54eaa31f7757ae6b5488b56a361ea42b3cb8b840" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index 92f668b..eb0a3c6 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -110,13 +110,14 @@ fn main() -> Result<(), Box> { wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, - load_op: wgpu::LoadOp::Clear, - store_op: wgpu::StoreOp::Store, - clear_color: wgpu::Color { - r: 0.4, - g: 0.4, - b: 0.4, - a: 1.0, + ops: wgpu::Operations { + load: wgpu::LoadOp::Clear(wgpu::Color { + r: 0.4, + g: 0.4, + b: 0.4, + a: 1.0, + }), + store: true, }, }, ], diff --git a/examples/depth.rs b/examples/depth.rs index d585304..bdcdb94 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -111,13 +111,14 @@ fn main() -> Result<(), Box> { wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, - load_op: wgpu::LoadOp::Clear, - store_op: wgpu::StoreOp::Store, - clear_color: wgpu::Color { - r: 0.4, - g: 0.4, - b: 0.4, - a: 1.0, + ops: wgpu::Operations { + load: wgpu::LoadOp::Clear(wgpu::Color { + r: 0.4, + g: 0.4, + b: 0.4, + a: 1.0, + }), + store: true, }, }, ], @@ -163,14 +164,14 @@ fn main() -> Result<(), Box> { &frame.view, wgpu::RenderPassDepthStencilAttachmentDescriptor { attachment: &depth_view, - depth_load_op: wgpu::LoadOp::Clear, - depth_store_op: wgpu::StoreOp::Store, - depth_read_only: false, - stencil_load_op: wgpu::LoadOp::Clear, - stencil_store_op: wgpu::StoreOp::Store, - stencil_read_only: false, - clear_depth: -1.0, - clear_stencil: 0, + depth_ops: Some(wgpu::Operations { + load: wgpu::LoadOp::Clear(-1.0), + store: true, + }), + stencil_ops: Some(wgpu::Operations { + load: wgpu::LoadOp::Clear(0), + store: true, + }), }, size.width, size.height, diff --git a/examples/hello.rs b/examples/hello.rs index eb84b10..92ba17a 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -110,13 +110,14 @@ fn main() -> Result<(), Box> { wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, - load_op: wgpu::LoadOp::Clear, - store_op: wgpu::StoreOp::Store, - clear_color: wgpu::Color { - r: 0.4, - g: 0.4, - b: 0.4, - a: 1.0, + ops: wgpu::Operations { + load: wgpu::LoadOp::Clear(wgpu::Color { + r: 0.4, + g: 0.4, + b: 0.4, + a: 1.0, + }), + store: true, }, }, ], diff --git a/src/pipeline.rs b/src/pipeline.rs index 2e641dd..3d7a8f2 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -204,9 +204,7 @@ fn build( wgpu::ShaderStage::VERTEX, wgpu::BindingType::UniformBuffer { dynamic: false, - min_binding_size: wgpu::NonZeroBufferAddress::new( - mem::size_of::<[f32; 16]>() as u64 - ) + min_binding_size: wgpu::BufferSize::new(mem::size_of::<[f32; 16]>() as u64) }, ), wgpu::BindGroupLayoutEntry::new( @@ -373,13 +371,9 @@ fn draw( color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: target, resolve_target: None, - load_op: wgpu::LoadOp::Load, - store_op: wgpu::StoreOp::Store, - clear_color: wgpu::Color { - r: 0.0, - g: 0.0, - b: 0.0, - a: 0.0, + ops: wgpu::Operations { + load: wgpu::LoadOp::Load, + store: true, }, }], depth_stencil_attachment, From 13eb666ca4e19637922a4d732feb45832076e3a7 Mon Sep 17 00:00:00 2001 From: Rukai Date: Sat, 27 Jun 2020 00:37:46 +1000 Subject: [PATCH 08/17] Update to latest wgpu commit --- Cargo.toml | 2 +- examples/clipping.rs | 4 ++-- examples/depth.rs | 4 ++-- examples/hello.rs | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1fb7616..fe1a907 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "54eaa31f7757ae6b5488b56a361ea42b3cb8b840" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "9d2747f4a440f181265e6c719e636392df102def" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index eb0a3c6..0d02443 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -22,14 +22,14 @@ fn main() -> Result<(), Box> { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, - wgpu::UnsafeExtensions::disallow(), + wgpu::UnsafeFeatures::disallow(), ) .await .expect("Request adapter"); adapter.request_device( &wgpu::DeviceDescriptor { - extensions: wgpu::Extensions::empty(), + features: wgpu::Features::empty(), limits: wgpu::Limits::default(), shader_validation: false, }, diff --git a/examples/depth.rs b/examples/depth.rs index bdcdb94..1eb0674 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -24,14 +24,14 @@ fn main() -> Result<(), Box> { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, - wgpu::UnsafeExtensions::disallow(), + wgpu::UnsafeFeatures::disallow(), ) .await .expect("Request adapter"); adapter.request_device( &wgpu::DeviceDescriptor { - extensions: wgpu::Extensions::empty(), + features: wgpu::Features::empty(), limits: wgpu::Limits::default(), shader_validation: false, }, diff --git a/examples/hello.rs b/examples/hello.rs index 92ba17a..6f8ad94 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -22,14 +22,14 @@ fn main() -> Result<(), Box> { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, - wgpu::UnsafeExtensions::disallow(), + wgpu::UnsafeFeatures::disallow(), ) .await .expect("Request adapter"); adapter.request_device( &wgpu::DeviceDescriptor { - extensions: wgpu::Extensions::empty(), + features: wgpu::Features::empty(), limits: wgpu::Limits::default(), shader_validation: false, }, From 6e507fc5d0fd2dd2a2ab4a4a582e572b43b6bee3 Mon Sep 17 00:00:00 2001 From: Rukai Date: Wed, 8 Jul 2020 22:28:42 +1000 Subject: [PATCH 09/17] Update to latest wgpu commit --- Cargo.toml | 2 +- examples/clipping.rs | 1 - examples/depth.rs | 1 - examples/hello.rs | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fe1a907..01bd0fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "9d2747f4a440f181265e6c719e636392df102def" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "54f5478f400099b2fa0ba9a72f947c4155b2d3aa" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index 0d02443..829eb86 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -22,7 +22,6 @@ fn main() -> Result<(), Box> { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, - wgpu::UnsafeFeatures::disallow(), ) .await .expect("Request adapter"); diff --git a/examples/depth.rs b/examples/depth.rs index 1eb0674..bc17ada 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -24,7 +24,6 @@ fn main() -> Result<(), Box> { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, - wgpu::UnsafeFeatures::disallow(), ) .await .expect("Request adapter"); diff --git a/examples/hello.rs b/examples/hello.rs index 6f8ad94..f550787 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -22,7 +22,6 @@ fn main() -> Result<(), Box> { power_preference: wgpu::PowerPreference::HighPerformance, compatible_surface: Some(&surface), }, - wgpu::UnsafeFeatures::disallow(), ) .await .expect("Request adapter"); From 6bcfe21fa4d7513399abbd581681cec853fd5137 Mon Sep 17 00:00:00 2001 From: Rukai Date: Tue, 14 Jul 2020 18:51:24 +1000 Subject: [PATCH 10/17] Update to latest wgpu commit --- Cargo.toml | 2 +- src/pipeline.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 01bd0fd..38e0dd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "54f5478f400099b2fa0ba9a72f947c4155b2d3aa" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "32de700ef908029cc5f8ac3b0befd7439f5bd7bd" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/src/pipeline.rs b/src/pipeline.rs index 3d7a8f2..4439217 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -198,7 +198,7 @@ fn build( let uniform_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { label: Some("wgpu_glyph::Pipeline uniforms"), - bindings: &[ + entries: &[ wgpu::BindGroupLayoutEntry::new( 0, wgpu::ShaderStage::VERTEX, @@ -242,6 +242,7 @@ fn build( let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { + push_constant_ranges: &[], bind_group_layouts: &[&uniform_layout], }); @@ -405,16 +406,16 @@ fn create_uniforms( device.create_bind_group(&wgpu::BindGroupDescriptor { label: Some("wgpu_glyph::Pipeline uniforms"), layout: layout, - bindings: &[ - wgpu::Binding { + entries: &[ + wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::Buffer(transform.slice(..)), }, - wgpu::Binding { + wgpu::BindGroupEntry { binding: 1, resource: wgpu::BindingResource::Sampler(sampler), }, - wgpu::Binding { + wgpu::BindGroupEntry { binding: 2, resource: wgpu::BindingResource::TextureView(cache), }, From e345953a47c43df66da0c0f1ef80d080c00d7950 Mon Sep 17 00:00:00 2001 From: Rukai Date: Tue, 21 Jul 2020 20:09:37 +1000 Subject: [PATCH 11/17] Update to latest wgpu commit --- Cargo.toml | 2 +- examples/clipping.rs | 2 +- examples/depth.rs | 2 +- examples/hello.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 38e0dd9..0cfb8fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "32de700ef908029cc5f8ac3b0befd7439f5bd7bd" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "d91d046c0a2b75aec94006a1bbeee2955b7d9da6" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index 829eb86..2bce71d 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -97,7 +97,7 @@ fn main() -> Result<(), Box> { // Get the next frame let frame = swap_chain - .get_next_frame() + .get_current_frame() .expect("Get next frame") .output; diff --git a/examples/depth.rs b/examples/depth.rs index bc17ada..eead5b0 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -98,7 +98,7 @@ fn main() -> Result<(), Box> { // Get the next frame let frame = swap_chain - .get_next_frame() + .get_current_frame() .expect("Get next frame") .output; diff --git a/examples/hello.rs b/examples/hello.rs index f550787..6047a4d 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -97,7 +97,7 @@ fn main() -> Result<(), Box> { // Get the next frame let frame = swap_chain - .get_next_frame() + .get_current_frame() .expect("Get next frame") .output; From 7e57959a7232372cc227a425b62baa14b5aaf034 Mon Sep 17 00:00:00 2001 From: Rukai Date: Wed, 22 Jul 2020 20:40:54 +1000 Subject: [PATCH 12/17] Update to latest wgpu commit --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 0cfb8fa..3160528 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "d91d046c0a2b75aec94006a1bbeee2955b7d9da6" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "96f4dda7567b2ddc04f155b98c1183ce57af8f04" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" From 6d22487ae905abcdade6d2bb06f275ead048af2e Mon Sep 17 00:00:00 2001 From: makai Date: Wed, 22 Jul 2020 22:17:26 -0700 Subject: [PATCH 13/17] update for cow change --- Cargo.toml | 2 +- examples/clipping.rs | 5 +++-- examples/depth.rs | 5 +++-- examples/hello.rs | 5 +++-- src/pipeline.rs | 37 +++++++++++++++++++------------------ 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3160528..5592c4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "96f4dda7567b2ddc04f155b98c1183ce57af8f04" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "a85db74cb899c2615bd6d7ef2dd6dffc4431d444" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index 2bce71d..6c74e1f 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow::Borrowed; use std::error::Error; use wgpu_glyph::{ab_glyph, GlyphBrushBuilder, Region, Section, Text}; @@ -105,7 +106,7 @@ fn main() -> Result<(), Box> { { let _ = encoder.begin_render_pass( &wgpu::RenderPassDescriptor { - color_attachments: &[ + color_attachments: Borrowed(&[ wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, @@ -119,7 +120,7 @@ fn main() -> Result<(), Box> { store: true, }, }, - ], + ]), depth_stencil_attachment: None, }, ); diff --git a/examples/depth.rs b/examples/depth.rs index eead5b0..430000c 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow::Borrowed; use std::error::Error; use wgpu_glyph::{ab_glyph, GlyphBrushBuilder, Section, Text}; @@ -106,7 +107,7 @@ fn main() -> Result<(), Box> { { let _ = encoder.begin_render_pass( &wgpu::RenderPassDescriptor { - color_attachments: &[ + color_attachments: Borrowed(&[ wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, @@ -120,7 +121,7 @@ fn main() -> Result<(), Box> { store: true, }, }, - ], + ]), depth_stencil_attachment: None, }, ); diff --git a/examples/hello.rs b/examples/hello.rs index 6047a4d..ea62c4f 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,3 +1,4 @@ +use std::borrow::Cow::Borrowed; use std::error::Error; use wgpu_glyph::{ab_glyph, GlyphBrushBuilder, Section, Text}; @@ -105,7 +106,7 @@ fn main() -> Result<(), Box> { { let _ = encoder.begin_render_pass( &wgpu::RenderPassDescriptor { - color_attachments: &[ + color_attachments: Borrowed(&[ wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, @@ -119,7 +120,7 @@ fn main() -> Result<(), Box> { store: true, }, }, - ], + ]), depth_stencil_attachment: None, }, ); diff --git a/src/pipeline.rs b/src/pipeline.rs index 4439217..93c9705 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -4,6 +4,7 @@ use crate::Region; use cache::Cache; use glyph_brush::ab_glyph::{point, Rect}; +use std::borrow::Cow::Borrowed; use std::marker::PhantomData; use std::mem; use zerocopy::AsBytes; @@ -197,8 +198,8 @@ fn build( let uniform_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: Some("wgpu_glyph::Pipeline uniforms"), - entries: &[ + label: Some(Borrowed("wgpu_glyph::Pipeline uniforms")), + entries: Borrowed(&[ wgpu::BindGroupLayoutEntry::new( 0, wgpu::ShaderStage::VERTEX, @@ -221,7 +222,7 @@ fn build( multisampled: false, }, ), - ], + ]), }); let uniforms = create_uniforms( @@ -242,8 +243,8 @@ fn build( let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - push_constant_ranges: &[], - bind_group_layouts: &[&uniform_layout], + push_constant_ranges: Borrowed(&[]), + bind_group_layouts: Borrowed(&[&uniform_layout]), }); let vs_module @@ -256,11 +257,11 @@ fn build( layout: &layout, vertex_stage: wgpu::ProgrammableStageDescriptor { module: &vs_module, - entry_point: "main", + entry_point: Borrowed("main"), }, fragment_stage: Some(wgpu::ProgrammableStageDescriptor { module: &fs_module, - entry_point: "main", + entry_point: Borrowed("main"), }), rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Cw, @@ -270,7 +271,7 @@ fn build( depth_bias_clamp: 0.0, }), primitive_topology: wgpu::PrimitiveTopology::TriangleStrip, - color_states: &[wgpu::ColorStateDescriptor { + color_states: Borrowed(&[wgpu::ColorStateDescriptor { format: render_format, color_blend: wgpu::BlendDescriptor { src_factor: wgpu::BlendFactor::SrcAlpha, @@ -283,14 +284,14 @@ fn build( operation: wgpu::BlendOperation::Add, }, write_mask: wgpu::ColorWrite::ALL, - }], + }]), depth_stencil_state, vertex_state: wgpu::VertexStateDescriptor { index_format: wgpu::IndexFormat::Uint16, - vertex_buffers: &[wgpu::VertexBufferDescriptor { + vertex_buffers: Borrowed(&[wgpu::VertexBufferDescriptor { stride: mem::size_of::() as u64, step_mode: wgpu::InputStepMode::Instance, - attributes: &[ + attributes: Borrowed(&[ wgpu::VertexAttributeDescriptor { shader_location: 0, format: wgpu::VertexFormat::Float3, @@ -316,8 +317,8 @@ fn build( format: wgpu::VertexFormat::Float4, offset: 4 * (3 + 2 + 2 + 2), }, - ], - }], + ]), + }]), }, sample_count: 1, sample_mask: !0, @@ -369,14 +370,14 @@ fn draw( let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { + color_attachments: Borrowed(&[wgpu::RenderPassColorAttachmentDescriptor { attachment: target, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Load, store: true, }, - }], + }]), depth_stencil_attachment, }); @@ -404,9 +405,9 @@ fn create_uniforms( cache: &wgpu::TextureView, ) -> wgpu::BindGroup { device.create_bind_group(&wgpu::BindGroupDescriptor { - label: Some("wgpu_glyph::Pipeline uniforms"), + label: Some(Borrowed("wgpu_glyph::Pipeline uniforms")), layout: layout, - entries: &[ + entries: Borrowed(&[ wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::Buffer(transform.slice(..)), @@ -419,7 +420,7 @@ fn create_uniforms( binding: 2, resource: wgpu::BindingResource::TextureView(cache), }, - ], + ]), }) } From 742e1e1f33f811a726d31090206255e3b78d1c4b Mon Sep 17 00:00:00 2001 From: Rukai Date: Mon, 3 Aug 2020 22:57:38 +1000 Subject: [PATCH 14/17] Update to latest wgpu commit --- Cargo.toml | 2 +- examples/clipping.rs | 2 +- examples/depth.rs | 4 ++-- examples/hello.rs | 2 +- src/pipeline.rs | 36 +++++++++++++++++++----------------- src/pipeline/cache.rs | 11 +++++++++-- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5592c4e..14a6843 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "a85db74cb899c2615bd6d7ef2dd6dffc4431d444" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "ffa9199402e1436ba525007754e161b08ab12bcc" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index 6c74e1f..5ee0b44 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -92,7 +92,7 @@ fn main() -> Result<(), Box> { // Get a command encoder for the current frame let mut encoder = device.create_command_encoder( &wgpu::CommandEncoderDescriptor { - label: Some("Redraw"), + label: Some(Borrowed("Redraw")), }, ); diff --git a/examples/depth.rs b/examples/depth.rs index 430000c..cba826e 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -93,7 +93,7 @@ fn main() -> Result<(), Box> { // Get a command encoder for the current frame let mut encoder = device.create_command_encoder( &wgpu::CommandEncoderDescriptor { - label: Some("Redraw"), + label: Some(Borrowed("Redraw")), }, ); @@ -206,7 +206,7 @@ fn create_frame_views( ); let depth_texture = device.create_texture(&wgpu::TextureDescriptor { - label: Some("Depth buffer"), + label: Some(Borrowed("Depth buffer")), size: wgpu::Extent3d { width, height, diff --git a/examples/hello.rs b/examples/hello.rs index ea62c4f..c291dfe 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -92,7 +92,7 @@ fn main() -> Result<(), Box> { // Get a command encoder for the current frame let mut encoder = device.create_command_encoder( &wgpu::CommandEncoderDescriptor { - label: Some("Redraw"), + label: Some(Borrowed("Redraw")), }, ); diff --git a/src/pipeline.rs b/src/pipeline.rs index 93c9705..29bc1c4 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -8,6 +8,7 @@ use std::borrow::Cow::Borrowed; use std::marker::PhantomData; use std::mem; use zerocopy::AsBytes; +use wgpu::util::DeviceExt; pub struct Pipeline { transform: wgpu::Buffer, @@ -135,7 +136,7 @@ impl Pipeline { if instances.len() > self.supported_instances { self.instances = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("wgpu_glyph::Pipeline instances"), + label: Some(Borrowed("wgpu_glyph::Pipeline instances")), size: mem::size_of::() as u64 * instances.len() as u64, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, @@ -145,10 +146,11 @@ impl Pipeline { self.supported_instances = instances.len(); } - let instance_buffer = device.create_buffer_with_data( - instances.as_bytes(), - wgpu::BufferUsage::COPY_SRC, - ); + let instance_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + label: None, + contents: instances.as_bytes(), + usage: wgpu::BufferUsage::COPY_SRC, + }); encoder.copy_buffer_to_buffer( &instance_buffer, @@ -179,10 +181,11 @@ fn build( cache_width: u32, cache_height: u32, ) -> Pipeline { - let transform = device.create_buffer_with_data( - IDENTITY_MATRIX.as_bytes(), - wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, - ); + let transform = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + label: None, + contents: IDENTITY_MATRIX.as_bytes(), + usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, + }); let sampler = device.create_sampler(&wgpu::SamplerDescriptor { address_mode_u: wgpu::AddressMode::ClampToEdge, @@ -234,7 +237,7 @@ fn build( ); let instances = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("wgpu_glyph::Pipeline instances"), + label: Some(Borrowed("wgpu_glyph::Pipeline instances")), size: mem::size_of::() as u64 * Instance::INITIAL_AMOUNT as u64, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, @@ -266,9 +269,7 @@ fn build( rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Cw, cull_mode: wgpu::CullMode::None, - depth_bias: 0, - depth_bias_slope_scale: 0.0, - depth_bias_clamp: 0.0, + ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleStrip, color_states: Borrowed(&[wgpu::ColorStateDescriptor { @@ -352,10 +353,11 @@ fn draw( region: Option, ) { if transform != pipeline.current_transform { - let transform_buffer = device.create_buffer_with_data( - transform.as_bytes(), - wgpu::BufferUsage::COPY_SRC, - ); + let transform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + label: None, + contents: transform.as_bytes(), + usage: wgpu::BufferUsage::COPY_SRC, + }); encoder.copy_buffer_to_buffer( &transform_buffer, diff --git a/src/pipeline/cache.rs b/src/pipeline/cache.rs index ac2ce1b..1785655 100644 --- a/src/pipeline/cache.rs +++ b/src/pipeline/cache.rs @@ -1,3 +1,6 @@ +use std::borrow::Cow::Borrowed; +use wgpu::util::DeviceExt; + pub struct Cache { texture: wgpu::Texture, pub(super) view: wgpu::TextureView, @@ -6,7 +9,7 @@ pub struct Cache { impl Cache { pub fn new(device: &wgpu::Device, width: u32, height: u32) -> Cache { let texture = device.create_texture(&wgpu::TextureDescriptor { - label: Some("wgpu_glyph::Cache"), + label: Some(Borrowed("wgpu_glyph::Cache")), size: wgpu::Extent3d { width, height, @@ -48,7 +51,11 @@ impl Cache { padded_data[row * padded_width .. row * padded_width + width] .copy_from_slice(&data[row * width .. (row + 1) * width]) } - let buffer = device.create_buffer_with_data(&padded_data, wgpu::BufferUsage::COPY_SRC); + let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { + label: None, + contents: &padded_data, + usage: wgpu::BufferUsage::COPY_SRC, + }); encoder.copy_buffer_to_texture( wgpu::BufferCopyView { From d14ae7ecd4fdaaf22343007396a743149b351241 Mon Sep 17 00:00:00 2001 From: Rukai Date: Thu, 13 Aug 2020 19:24:35 +1000 Subject: [PATCH 15/17] Update to latest wgpu commit --- Cargo.toml | 2 +- examples/clipping.rs | 7 ++-- examples/depth.rs | 16 ++++----- examples/hello.rs | 7 ++-- src/pipeline.rs | 77 ++++++++++++++++++++++--------------------- src/pipeline/cache.rs | 5 ++- 6 files changed, 55 insertions(+), 59 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 14a6843..5baa1bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "ffa9199402e1436ba525007754e161b08ab12bcc" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "471d2a1a48c795a13d3c65a29ff184d7cfe9e766" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/examples/clipping.rs b/examples/clipping.rs index 5ee0b44..2bce71d 100644 --- a/examples/clipping.rs +++ b/examples/clipping.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow::Borrowed; use std::error::Error; use wgpu_glyph::{ab_glyph, GlyphBrushBuilder, Region, Section, Text}; @@ -92,7 +91,7 @@ fn main() -> Result<(), Box> { // Get a command encoder for the current frame let mut encoder = device.create_command_encoder( &wgpu::CommandEncoderDescriptor { - label: Some(Borrowed("Redraw")), + label: Some("Redraw"), }, ); @@ -106,7 +105,7 @@ fn main() -> Result<(), Box> { { let _ = encoder.begin_render_pass( &wgpu::RenderPassDescriptor { - color_attachments: Borrowed(&[ + color_attachments: &[ wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, @@ -120,7 +119,7 @@ fn main() -> Result<(), Box> { store: true, }, }, - ]), + ], depth_stencil_attachment: None, }, ); diff --git a/examples/depth.rs b/examples/depth.rs index cba826e..b84992f 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow::Borrowed; use std::error::Error; use wgpu_glyph::{ab_glyph, GlyphBrushBuilder, Section, Text}; @@ -58,10 +57,7 @@ fn main() -> Result<(), Box> { format: wgpu::TextureFormat::Depth32Float, depth_write_enabled: true, depth_compare: wgpu::CompareFunction::Greater, - stencil_front: wgpu::StencilStateFaceDescriptor::IGNORE, - stencil_back: wgpu::StencilStateFaceDescriptor::IGNORE, - stencil_read_mask: 0, - stencil_write_mask: 0, + stencil: wgpu::StencilStateDescriptor::default(), }) .build(&device, FORMAT); @@ -93,7 +89,7 @@ fn main() -> Result<(), Box> { // Get a command encoder for the current frame let mut encoder = device.create_command_encoder( &wgpu::CommandEncoderDescriptor { - label: Some(Borrowed("Redraw")), + label: Some("Redraw"), }, ); @@ -107,7 +103,7 @@ fn main() -> Result<(), Box> { { let _ = encoder.begin_render_pass( &wgpu::RenderPassDescriptor { - color_attachments: Borrowed(&[ + color_attachments: &[ wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, @@ -121,7 +117,7 @@ fn main() -> Result<(), Box> { store: true, }, }, - ]), + ], depth_stencil_attachment: None, }, ); @@ -206,7 +202,7 @@ fn create_frame_views( ); let depth_texture = device.create_texture(&wgpu::TextureDescriptor { - label: Some(Borrowed("Depth buffer")), + label: Some("Depth buffer"), size: wgpu::Extent3d { width, height, @@ -219,5 +215,5 @@ fn create_frame_views( usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, }); - (swap_chain, depth_texture.create_default_view()) + (swap_chain, depth_texture.create_view(&wgpu::TextureViewDescriptor::default())) } diff --git a/examples/hello.rs b/examples/hello.rs index c291dfe..6047a4d 100644 --- a/examples/hello.rs +++ b/examples/hello.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow::Borrowed; use std::error::Error; use wgpu_glyph::{ab_glyph, GlyphBrushBuilder, Section, Text}; @@ -92,7 +91,7 @@ fn main() -> Result<(), Box> { // Get a command encoder for the current frame let mut encoder = device.create_command_encoder( &wgpu::CommandEncoderDescriptor { - label: Some(Borrowed("Redraw")), + label: Some("Redraw"), }, ); @@ -106,7 +105,7 @@ fn main() -> Result<(), Box> { { let _ = encoder.begin_render_pass( &wgpu::RenderPassDescriptor { - color_attachments: Borrowed(&[ + color_attachments: &[ wgpu::RenderPassColorAttachmentDescriptor { attachment: &frame.view, resolve_target: None, @@ -120,7 +119,7 @@ fn main() -> Result<(), Box> { store: true, }, }, - ]), + ], depth_stencil_attachment: None, }, ); diff --git a/src/pipeline.rs b/src/pipeline.rs index 29bc1c4..ee5d714 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -4,7 +4,6 @@ use crate::Region; use cache::Cache; use glyph_brush::ab_glyph::{point, Rect}; -use std::borrow::Cow::Borrowed; use std::marker::PhantomData; use std::mem; use zerocopy::AsBytes; @@ -136,7 +135,7 @@ impl Pipeline { if instances.len() > self.supported_instances { self.instances = device.create_buffer(&wgpu::BufferDescriptor { - label: Some(Borrowed("wgpu_glyph::Pipeline instances")), + label: Some("wgpu_glyph::Pipeline instances"), size: mem::size_of::() as u64 * instances.len() as u64, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, @@ -201,31 +200,34 @@ fn build( let uniform_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { - label: Some(Borrowed("wgpu_glyph::Pipeline uniforms")), - entries: Borrowed(&[ - wgpu::BindGroupLayoutEntry::new( - 0, - wgpu::ShaderStage::VERTEX, - wgpu::BindingType::UniformBuffer { + label: Some("wgpu_glyph::Pipeline uniforms"), + entries: &[ + wgpu::BindGroupLayoutEntry { + binding: 0, + visibility: wgpu::ShaderStage::VERTEX, + ty: wgpu::BindingType::UniformBuffer { dynamic: false, min_binding_size: wgpu::BufferSize::new(mem::size_of::<[f32; 16]>() as u64) }, - ), - wgpu::BindGroupLayoutEntry::new( - 1, - wgpu::ShaderStage::FRAGMENT, - wgpu::BindingType::Sampler { comparison: false }, - ), - wgpu::BindGroupLayoutEntry::new( - 2, - wgpu::ShaderStage::FRAGMENT, - wgpu::BindingType::SampledTexture { + count: None + }, + wgpu::BindGroupLayoutEntry { + binding: 1, + visibility: wgpu::ShaderStage::FRAGMENT, + ty: wgpu::BindingType::Sampler { comparison: false }, + count: None + }, + wgpu::BindGroupLayoutEntry { + binding: 2, + visibility: wgpu::ShaderStage::FRAGMENT, + ty: wgpu::BindingType::SampledTexture { dimension: wgpu::TextureViewDimension::D2, component_type: wgpu::TextureComponentType::Float, multisampled: false, }, - ), - ]), + count: None + }, + ], }); let uniforms = create_uniforms( @@ -237,7 +239,7 @@ fn build( ); let instances = device.create_buffer(&wgpu::BufferDescriptor { - label: Some(Borrowed("wgpu_glyph::Pipeline instances")), + label: Some("wgpu_glyph::Pipeline instances"), size: mem::size_of::() as u64 * Instance::INITIAL_AMOUNT as u64, usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST, @@ -246,8 +248,9 @@ fn build( let layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - push_constant_ranges: Borrowed(&[]), - bind_group_layouts: Borrowed(&[&uniform_layout]), + label: None, + push_constant_ranges: &[], + bind_group_layouts: &[&uniform_layout], }); let vs_module @@ -257,14 +260,14 @@ fn build( = device.create_shader_module(wgpu::include_spirv!("shader/fragment.spv")); let raw = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { - layout: &layout, + layout: Some(&layout), vertex_stage: wgpu::ProgrammableStageDescriptor { module: &vs_module, - entry_point: Borrowed("main"), + entry_point: "main", }, fragment_stage: Some(wgpu::ProgrammableStageDescriptor { module: &fs_module, - entry_point: Borrowed("main"), + entry_point: "main", }), rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Cw, @@ -272,7 +275,7 @@ fn build( ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::TriangleStrip, - color_states: Borrowed(&[wgpu::ColorStateDescriptor { + color_states: &[wgpu::ColorStateDescriptor { format: render_format, color_blend: wgpu::BlendDescriptor { src_factor: wgpu::BlendFactor::SrcAlpha, @@ -285,14 +288,14 @@ fn build( operation: wgpu::BlendOperation::Add, }, write_mask: wgpu::ColorWrite::ALL, - }]), + }], depth_stencil_state, vertex_state: wgpu::VertexStateDescriptor { index_format: wgpu::IndexFormat::Uint16, - vertex_buffers: Borrowed(&[wgpu::VertexBufferDescriptor { + vertex_buffers: &[wgpu::VertexBufferDescriptor { stride: mem::size_of::() as u64, step_mode: wgpu::InputStepMode::Instance, - attributes: Borrowed(&[ + attributes: &[ wgpu::VertexAttributeDescriptor { shader_location: 0, format: wgpu::VertexFormat::Float3, @@ -318,8 +321,8 @@ fn build( format: wgpu::VertexFormat::Float4, offset: 4 * (3 + 2 + 2 + 2), }, - ]), - }]), + ], + }], }, sample_count: 1, sample_mask: !0, @@ -372,14 +375,14 @@ fn draw( let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - color_attachments: Borrowed(&[wgpu::RenderPassColorAttachmentDescriptor { + color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: target, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Load, store: true, }, - }]), + }], depth_stencil_attachment, }); @@ -407,9 +410,9 @@ fn create_uniforms( cache: &wgpu::TextureView, ) -> wgpu::BindGroup { device.create_bind_group(&wgpu::BindGroupDescriptor { - label: Some(Borrowed("wgpu_glyph::Pipeline uniforms")), + label: Some("wgpu_glyph::Pipeline uniforms"), layout: layout, - entries: Borrowed(&[ + entries: &[ wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::Buffer(transform.slice(..)), @@ -422,7 +425,7 @@ fn create_uniforms( binding: 2, resource: wgpu::BindingResource::TextureView(cache), }, - ]), + ], }) } diff --git a/src/pipeline/cache.rs b/src/pipeline/cache.rs index 1785655..e3cc57b 100644 --- a/src/pipeline/cache.rs +++ b/src/pipeline/cache.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow::Borrowed; use wgpu::util::DeviceExt; pub struct Cache { @@ -9,7 +8,7 @@ pub struct Cache { impl Cache { pub fn new(device: &wgpu::Device, width: u32, height: u32) -> Cache { let texture = device.create_texture(&wgpu::TextureDescriptor { - label: Some(Borrowed("wgpu_glyph::Cache")), + label: Some("wgpu_glyph::Cache"), size: wgpu::Extent3d { width, height, @@ -22,7 +21,7 @@ impl Cache { sample_count: 1, }); - let view = texture.create_default_view(); + let view = texture.create_view(&wgpu::TextureViewDescriptor::default()); Cache { texture, view } } From 7ef527269c9932eb9a7a4f08da7eda8e912dd910 Mon Sep 17 00:00:00 2001 From: Rukai Date: Tue, 18 Aug 2020 19:22:43 +1000 Subject: [PATCH 16/17] Update to latest wgpu commit --- Cargo.toml | 2 +- src/pipeline.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5baa1bc..1481e26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "471d2a1a48c795a13d3c65a29ff184d7cfe9e766" } +wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "02c1fa563f709bfa7b4781b938781bed57069ad1" } glyph_brush = "0.7" log = "0.4" zerocopy = "0.3" diff --git a/src/pipeline.rs b/src/pipeline.rs index ee5d714..9ba8271 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -260,6 +260,7 @@ fn build( = device.create_shader_module(wgpu::include_spirv!("shader/fragment.spv")); let raw = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { + label: None, layout: Some(&layout), vertex_stage: wgpu::ProgrammableStageDescriptor { module: &vs_module, From 57f3014b79355a40a5f9444dd8234ab3576d7523 Mon Sep 17 00:00:00 2001 From: Rukai Date: Wed, 19 Aug 2020 18:43:45 +1000 Subject: [PATCH 17/17] Update to wgpu 0.6 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1481e26..4120e80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/wgpu_glyph" readme = "README.md" [dependencies] -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "02c1fa563f709bfa7b4781b938781bed57069ad1" } +wgpu = "0.6" glyph_brush = "0.7" log = "0.4" zerocopy = "0.3"