From 7b48960d424940569f99528610b5c2483ab98f24 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Tue, 7 Apr 2020 19:36:57 -0700 Subject: [PATCH] upgrade to wgpu 0.5.0 --- bevy_render/src/camera.rs | 12 +++--------- bevy_render/src/texture/sampler_descriptor.rs | 4 ++-- bevy_wgpu/Cargo.toml | 3 ++- bevy_wgpu/src/wgpu_renderer.rs | 6 ++++-- bevy_wgpu/src/wgpu_resources.rs | 9 +++++++-- bevy_wgpu/src/wgpu_type_converter.rs | 7 ++++--- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/bevy_render/src/camera.rs b/bevy_render/src/camera.rs index 2e4241a27e..942549a401 100644 --- a/bevy_render/src/camera.rs +++ b/bevy_render/src/camera.rs @@ -25,7 +25,7 @@ impl OrthographicCamera { self.near, self.far, ); - opengl_to_wgpu_matrix() * projection + projection } } @@ -52,7 +52,7 @@ pub struct PerspectiveCamera { impl PerspectiveCamera { pub fn get_view_matrix(&self) -> Mat4 { let projection = Mat4::perspective_rh_gl(self.fov, self.aspect_ratio, self.near, self.far); - opengl_to_wgpu_matrix() * projection + projection } } @@ -115,10 +115,4 @@ impl Camera { } } } -} - -pub fn opengl_to_wgpu_matrix() -> Mat4 { - Mat4::from_cols_array(&[ - 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 1.0, - ]) -} +} \ No newline at end of file diff --git a/bevy_render/src/texture/sampler_descriptor.rs b/bevy_render/src/texture/sampler_descriptor.rs index 71a44c9588..9108744963 100644 --- a/bevy_render/src/texture/sampler_descriptor.rs +++ b/bevy_render/src/texture/sampler_descriptor.rs @@ -11,7 +11,7 @@ pub struct SamplerDescriptor { pub mipmap_filter: FilterMode, pub lod_min_clamp: f32, pub lod_max_clamp: f32, - pub compare_function: Option, + pub compare_function: CompareFunction, } impl From<&Texture> for SamplerDescriptor { @@ -25,7 +25,7 @@ impl From<&Texture> for SamplerDescriptor { mipmap_filter: FilterMode::Nearest, lod_min_clamp: -100.0, lod_max_clamp: 100.0, - compare_function: Some(CompareFunction::Always), + compare_function: CompareFunction::Always, } } } diff --git a/bevy_wgpu/Cargo.toml b/bevy_wgpu/Cargo.toml index a9104d5b56..3b5e43b7f2 100644 --- a/bevy_wgpu/Cargo.toml +++ b/bevy_wgpu/Cargo.toml @@ -18,7 +18,8 @@ bevy_winit = { path = "../bevy_winit", version = "0.1.0", optional = true } legion = { path = "../bevy_legion" } # render -wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "d08f83762426c2c42eda74c7ca9c43d8d950fc0a" } +# wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "d08f83762426c2c42eda74c7ca9c43d8d950fc0a" } +wgpu = { version = "0.5.0" } futures = "0.3" log = { version = "0.4", features = ["release_max_level_info"] } \ No newline at end of file diff --git a/bevy_wgpu/src/wgpu_renderer.rs b/bevy_wgpu/src/wgpu_renderer.rs index cf76bf9d9b..b8fe5c054f 100644 --- a/bevy_wgpu/src/wgpu_renderer.rs +++ b/bevy_wgpu/src/wgpu_renderer.rs @@ -47,6 +47,7 @@ impl WgpuRenderer { let adapter = wgpu::Adapter::request( &wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::Default, + compatible_surface: None, }, wgpu::BackendBit::PRIMARY, ) @@ -223,7 +224,7 @@ impl WgpuRenderer { self.encoder = Some( self.device .borrow() - .create_command_encoder(&wgpu::CommandEncoderDescriptor { todo: 0 }), + .create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }), ); let mut render_graph = resources.get_mut::().unwrap(); @@ -359,7 +360,7 @@ impl Renderer for WgpuRenderer { self.encoder = Some( self.device .borrow() - .create_command_encoder(&wgpu::CommandEncoderDescriptor { todo: 0 }), + .create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }), ); self.update_resource_providers(world, resources); @@ -570,6 +571,7 @@ impl Renderer for WgpuRenderer { let wgpu_bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { bindings: bind_group_layout_binding.as_slice(), + label: None, }); self.wgpu_resources diff --git a/bevy_wgpu/src/wgpu_resources.rs b/bevy_wgpu/src/wgpu_resources.rs index a8579fe193..733bb8970b 100644 --- a/bevy_wgpu/src/wgpu_resources.rs +++ b/bevy_wgpu/src/wgpu_resources.rs @@ -118,6 +118,7 @@ impl WgpuResources { .get(&bind_group_descriptor.id) .unwrap(); let wgpu_bind_group_descriptor = wgpu::BindGroupDescriptor { + label: None, layout: bind_group_layout, bindings: bindings.as_slice(), }; @@ -148,6 +149,7 @@ impl WgpuResources { buffer_info: BufferInfo, ) -> RenderResource { let buffer = device.create_buffer(&wgpu::BufferDescriptor { + label: None, size: buffer_info.size as u64, usage: buffer_info.buffer_usage.wgpu_into(), }); @@ -199,8 +201,11 @@ impl WgpuResources { let device = device_rc.borrow(); let mut mapped = device.create_buffer_mapped( - buffer_info.size as usize, - buffer_info.buffer_usage.wgpu_into(), + &wgpu::BufferDescriptor { + size: buffer_info.size as u64, + usage: buffer_info.buffer_usage.wgpu_into(), + label: None, + } ); setup_data(&mut mapped.data, renderer); mapped.finish() diff --git a/bevy_wgpu/src/wgpu_type_converter.rs b/bevy_wgpu/src/wgpu_type_converter.rs index c7cd759833..e032573770 100644 --- a/bevy_wgpu/src/wgpu_type_converter.rs +++ b/bevy_wgpu/src/wgpu_type_converter.rs @@ -216,9 +216,10 @@ impl WgpuFrom for wgpu::Extent3d { } } -impl WgpuFrom for wgpu::TextureDescriptor { +impl WgpuFrom for wgpu::TextureDescriptor<'_> { fn from(texture_descriptor: TextureDescriptor) -> Self { wgpu::TextureDescriptor { + label: None, size: texture_descriptor.size.wgpu_into(), array_layer_count: texture_descriptor.array_layer_count, mip_level_count: texture_descriptor.mip_level_count, @@ -494,7 +495,7 @@ impl WgpuFrom for wgpu::IndexFormat { } } -impl WgpuFrom for wgpu::SamplerDescriptor<'_> { +impl WgpuFrom for wgpu::SamplerDescriptor { fn from(sampler_descriptor: SamplerDescriptor) -> Self { wgpu::SamplerDescriptor { address_mode_u: sampler_descriptor.address_mode_u.wgpu_into(), @@ -505,7 +506,7 @@ impl WgpuFrom for wgpu::SamplerDescriptor<'_> { mipmap_filter: sampler_descriptor.mipmap_filter.wgpu_into(), lod_min_clamp: sampler_descriptor.lod_min_clamp, lod_max_clamp: sampler_descriptor.lod_max_clamp, - compare: sampler_descriptor.compare_function.map(|c| c.wgpu_into()), + compare: sampler_descriptor.compare_function.wgpu_into(), } } }