From 340f45200ce3a4881632cff9a81796d9f3fcb572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Fri, 24 Jul 2020 17:23:16 +0200 Subject: [PATCH] [rs] Fix missing cows in some places --- wgpu/examples/mipmap/main.rs | 4 ++-- wgpu/examples/msaa-line/main.rs | 22 +++++++++++----------- wgpu/examples/shadow/main.rs | 4 ++-- wgpu/examples/texture-arrays/main.rs | 6 +++--- wgpu/examples/water/main.rs | 14 +++++++------- wgpu/src/backend/web.rs | 6 +++--- wgpu/src/lib.rs | 12 ++++++------ wgpu/src/util/belt.rs | 4 ++-- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/wgpu/examples/mipmap/main.rs b/wgpu/examples/mipmap/main.rs index 23aafe2600..ea44116c79 100644 --- a/wgpu/examples/mipmap/main.rs +++ b/wgpu/examples/mipmap/main.rs @@ -141,7 +141,7 @@ impl Example { }); let sampler = device.create_sampler(&wgpu::SamplerDescriptor { - label: Some("mip"), + label: Some(Borrowed("mip")), address_mode_u: wgpu::AddressMode::ClampToEdge, address_mode_v: wgpu::AddressMode::ClampToEdge, address_mode_w: wgpu::AddressMode::ClampToEdge, @@ -154,7 +154,7 @@ impl Example { let views = (0..mip_count) .map(|mip| { texture.create_view(&wgpu::TextureViewDescriptor { - label: Some("mip"), + label: Some(Borrowed("mip")), format: TEXTURE_FORMAT, dimension: wgpu::TextureViewDimension::D2, aspect: wgpu::TextureAspect::All, diff --git a/wgpu/examples/msaa-line/main.rs b/wgpu/examples/msaa-line/main.rs index 56f44e9dba..3256082624 100644 --- a/wgpu/examples/msaa-line/main.rs +++ b/wgpu/examples/msaa-line/main.rs @@ -10,7 +10,7 @@ #[path = "../framework.rs"] mod framework; -use std::{borrow::Cow, iter}; +use std::{borrow::Cow::Borrowed, iter}; use bytemuck::{Pod, Zeroable}; @@ -53,11 +53,11 @@ impl Example { layout: &pipeline_layout, vertex_stage: wgpu::ProgrammableStageDescriptor { module: vs_module, - entry_point: Cow::Borrowed("main"), + entry_point: Borrowed("main"), }, fragment_stage: Some(wgpu::ProgrammableStageDescriptor { module: fs_module, - entry_point: Cow::Borrowed("main"), + entry_point: Borrowed("main"), }), rasterization_state: Some(wgpu::RasterizationStateDescriptor { front_face: wgpu::FrontFace::Ccw, @@ -65,7 +65,7 @@ impl Example { ..Default::default() }), primitive_topology: wgpu::PrimitiveTopology::LineList, - color_states: Cow::Borrowed(&[wgpu::ColorStateDescriptor { + color_states: Borrowed(&[wgpu::ColorStateDescriptor { format: sc_desc.format, color_blend: wgpu::BlendDescriptor::REPLACE, alpha_blend: wgpu::BlendDescriptor::REPLACE, @@ -74,10 +74,10 @@ impl Example { depth_stencil_state: None, vertex_state: wgpu::VertexStateDescriptor { index_format: wgpu::IndexFormat::Uint16, - vertex_buffers: Cow::Borrowed(&[wgpu::VertexBufferDescriptor { + vertex_buffers: Borrowed(&[wgpu::VertexBufferDescriptor { stride: std::mem::size_of::() as wgpu::BufferAddress, step_mode: wgpu::InputStepMode::Vertex, - attributes: Cow::Borrowed(&wgpu::vertex_attr_array![0 => Float2, 1 => Float4]), + attributes: Borrowed(&wgpu::vertex_attr_array![0 => Float2, 1 => Float4]), }]), }, sample_count, @@ -87,7 +87,7 @@ impl Example { let mut encoder = device.create_render_bundle_encoder(&wgpu::RenderBundleEncoderDescriptor { label: None, - color_formats: Cow::Borrowed(&[sc_desc.format]), + color_formats: Borrowed(&[sc_desc.format]), depth_stencil_format: None, sample_count, }); @@ -95,7 +95,7 @@ impl Example { encoder.set_vertex_buffer(0, vertex_buffer.slice(..)); encoder.draw(0..vertex_count, 0..1); encoder.finish(&wgpu::RenderBundleDescriptor { - label: Some("main"), + label: Some(Borrowed("main")), }) } @@ -138,8 +138,8 @@ impl framework::Example for Example { let fs_module = device.create_shader_module(wgpu::include_spirv!("shader.frag.spv")); let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { - bind_group_layouts: Cow::Borrowed(&[]), - push_constant_ranges: Cow::Borrowed(&[]), + bind_group_layouts: Borrowed(&[]), + push_constant_ranges: Borrowed(&[]), }); let multisampled_framebuffer = @@ -274,7 +274,7 @@ impl framework::Example for Example { encoder .begin_render_pass(&wgpu::RenderPassDescriptor { - color_attachments: Cow::Borrowed(&[rpass_color_attachment]), + color_attachments: Borrowed(&[rpass_color_attachment]), depth_stencil_attachment: None, }) .execute_bundles(iter::once(&self.bundle)); diff --git a/wgpu/examples/shadow/main.rs b/wgpu/examples/shadow/main.rs index 2971db74fb..6c3c470d4d 100644 --- a/wgpu/examples/shadow/main.rs +++ b/wgpu/examples/shadow/main.rs @@ -350,7 +350,7 @@ impl framework::Example for Example { // Create other resources let shadow_sampler = device.create_sampler(&wgpu::SamplerDescriptor { - label: Some("shadow"), + label: Some(Borrowed("shadow")), address_mode_u: wgpu::AddressMode::ClampToEdge, address_mode_v: wgpu::AddressMode::ClampToEdge, address_mode_w: wgpu::AddressMode::ClampToEdge, @@ -375,7 +375,7 @@ impl framework::Example for Example { let mut shadow_target_views = (0..2) .map(|i| { Some(shadow_texture.create_view(&wgpu::TextureViewDescriptor { - label: Some("shadow"), + label: Some(Borrowed("shadow")), format: Self::SHADOW_FORMAT, dimension: wgpu::TextureViewDimension::D2, aspect: wgpu::TextureAspect::All, diff --git a/wgpu/examples/texture-arrays/main.rs b/wgpu/examples/texture-arrays/main.rs index f481248525..d06a91a983 100644 --- a/wgpu/examples/texture-arrays/main.rs +++ b/wgpu/examples/texture-arrays/main.rs @@ -150,11 +150,11 @@ impl framework::Example for Example { label: None, }; let red_texture = device.create_texture(&wgpu::TextureDescriptor { - label: Some("red"), + label: Some(Borrowed("red")), ..texture_descriptor }); let green_texture = device.create_texture(&wgpu::TextureDescriptor { - label: Some("green"), + label: Some(Borrowed("green")), ..texture_descriptor }); @@ -321,7 +321,7 @@ impl framework::Example for Example { _spawner: &impl futures::task::LocalSpawn, ) { let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { - label: Some("primary"), + label: Some(Borrowed("primary")), }); let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { diff --git a/wgpu/examples/water/main.rs b/wgpu/examples/water/main.rs index cdb2170115..dbd750dc1b 100644 --- a/wgpu/examples/water/main.rs +++ b/wgpu/examples/water/main.rs @@ -195,7 +195,7 @@ impl Example { }; let reflection_texture = device.create_texture(&wgpu::TextureDescriptor { - label: Some("Reflection Render Texture"), + label: Some(Borrowed("Reflection Render Texture")), size: texture_extent, mip_level_count: 1, sample_count: 1, @@ -207,7 +207,7 @@ impl Example { }); let draw_depth_buffer = device.create_texture(&wgpu::TextureDescriptor { - label: Some("Depth Buffer"), + label: Some(Borrowed("Depth Buffer")), size: texture_extent, mip_level_count: 1, sample_count: 1, @@ -219,7 +219,7 @@ impl Example { }); let sampler = device.create_sampler(&wgpu::SamplerDescriptor { - label: Some("Texture Sampler"), + label: Some(Borrowed("Texture Sampler")), address_mode_u: wgpu::AddressMode::ClampToEdge, address_mode_v: wgpu::AddressMode::ClampToEdge, address_mode_w: wgpu::AddressMode::ClampToEdge, @@ -424,21 +424,21 @@ impl framework::Example for Example { }); let water_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("Water Uniforms"), + label: Some(Borrowed("Water Uniforms")), size: mem::size_of::() as _, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, mapped_at_creation: false, }); let terrain_normal_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("Normal Terrain Uniforms"), + label: Some(Borrowed("Normal Terrain Uniforms")), size: mem::size_of::() as _, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, mapped_at_creation: false, }); let terrain_flipped_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor { - label: Some("Flipped Terrain Uniforms"), + label: Some(Borrowed("Flipped Terrain Uniforms")), size: mem::size_of::() as _, usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST, mapped_at_creation: false, @@ -710,7 +710,7 @@ impl framework::Example for Example { // The encoder provides a way to turn our instructions here, into // a command buffer the GPU can understand. let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { - label: Some("Main Command Encoder"), + label: Some(Borrowed("Main Command Encoder")), }); // First pass: render the reflection. diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index f492d0c6f3..ed53b9ff9d 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1052,7 +1052,7 @@ impl crate::Context for Context { ) -> Self::BufferId { let mut mapped_desc = web_sys::GpuBufferDescriptor::new(desc.size as f64, desc.usage.bits()); - if let Some(label) = desc.label { + if let Some(ref label) = desc.label { mapped_desc.label(label); } Sendable(device.0.create_buffer(&mapped_desc)) @@ -1068,7 +1068,7 @@ impl crate::Context for Context { &map_extent_3d(desc.size), desc.usage.bits(), ); - if let Some(label) = desc.label { + if let Some(ref label) = desc.label { mapped_desc.label(label); } mapped_desc.dimension(map_texture_dimension(desc.dimension)); @@ -1104,7 +1104,7 @@ impl crate::Context for Context { desc: &CommandEncoderDescriptor, ) -> Self::CommandEncoderId { let mut mapped_desc = web_sys::GpuCommandEncoderDescriptor::new(); - if let Some(label) = desc.label { + if let Some(ref label) = desc.label { mapped_desc.label(label); } device diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index ceb96e5a2e..ebc78a7a47 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -890,23 +890,23 @@ pub type RequestAdapterOptions<'a> = RequestAdapterOptionsBase<&'a Surface>; pub use wgt::BufferDescriptor as BufferDescriptorBase; /// Describes a [`Buffer`]. -pub type BufferDescriptor<'a> = BufferDescriptorBase>; +pub type BufferDescriptor<'a> = BufferDescriptorBase>>; pub use wgt::CommandEncoderDescriptor as CommandEncoderDescriptorBase; /// Describes a [`CommandEncoder`]. -pub type CommandEncoderDescriptor<'a> = CommandEncoderDescriptorBase>; +pub type CommandEncoderDescriptor<'a> = CommandEncoderDescriptorBase>>; pub use wgt::RenderBundleDescriptor as RenderBundleDescriptorBase; /// Describes a [`RenderBundle`]. -pub type RenderBundleDescriptor<'a> = RenderBundleDescriptorBase>; +pub type RenderBundleDescriptor<'a> = RenderBundleDescriptorBase>>; pub use wgt::TextureDescriptor as TextureDescriptorBase; /// Describes a [`Texture`]. -pub type TextureDescriptor<'a> = TextureDescriptorBase>; +pub type TextureDescriptor<'a> = TextureDescriptorBase>>; pub use wgt::TextureViewDescriptor as TextureViewDescriptorBase; /// Describes a [`TextureView`]. -pub type TextureViewDescriptor<'a> = TextureViewDescriptorBase>; +pub type TextureViewDescriptor<'a> = TextureViewDescriptorBase>>; pub use wgt::PipelineLayoutDescriptor as PipelineLayoutDescriptorBase; /// Describes a [`PipelineLayout`]. @@ -914,7 +914,7 @@ pub type PipelineLayoutDescriptor<'a> = PipelineLayoutDescriptorBase<'a, &'a Bin pub use wgt::SamplerDescriptor as SamplerDescriptorBase; /// Describes a [`Sampler`]. -pub type SamplerDescriptor<'a> = SamplerDescriptorBase>; +pub type SamplerDescriptor<'a> = SamplerDescriptorBase>>; pub use wgt::BindGroupEntry as BindGroupEntryBase; /// Bindable resource and the slot to bind it to. diff --git a/wgpu/src/util/belt.rs b/wgpu/src/util/belt.rs index 6d780785cd..52017715d6 100644 --- a/wgpu/src/util/belt.rs +++ b/wgpu/src/util/belt.rs @@ -3,7 +3,7 @@ use crate::{ CommandEncoder, CommandEncoderDescriptor, Device, MapMode, }; use futures::{future::join_all, FutureExt}; -use std::{future::Future, mem, sync::mpsc}; +use std::{borrow::Cow::Borrowed, future::Future, mem, sync::mpsc}; struct Chunk { buffer: Buffer, @@ -77,7 +77,7 @@ impl StagingBelt { wgc::span!(_guard, INFO, "Creating chunk of size {}", size); Chunk { buffer: device.create_buffer(&BufferDescriptor { - label: Some("staging"), + label: Some(Borrowed("staging")), size, usage: BufferUsage::MAP_WRITE | BufferUsage::COPY_SRC, mapped_at_creation: true,