mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
upgrade to wgpu 0.5.0
This commit is contained in:
parent
89d72ae044
commit
7b48960d42
6 changed files with 22 additions and 19 deletions
|
@ -25,7 +25,7 @@ impl OrthographicCamera {
|
||||||
self.near,
|
self.near,
|
||||||
self.far,
|
self.far,
|
||||||
);
|
);
|
||||||
opengl_to_wgpu_matrix() * projection
|
projection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ pub struct PerspectiveCamera {
|
||||||
impl PerspectiveCamera {
|
impl PerspectiveCamera {
|
||||||
pub fn get_view_matrix(&self) -> Mat4 {
|
pub fn get_view_matrix(&self) -> Mat4 {
|
||||||
let projection = Mat4::perspective_rh_gl(self.fov, self.aspect_ratio, self.near, self.far);
|
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,
|
|
||||||
])
|
|
||||||
}
|
|
|
@ -11,7 +11,7 @@ pub struct SamplerDescriptor {
|
||||||
pub mipmap_filter: FilterMode,
|
pub mipmap_filter: FilterMode,
|
||||||
pub lod_min_clamp: f32,
|
pub lod_min_clamp: f32,
|
||||||
pub lod_max_clamp: f32,
|
pub lod_max_clamp: f32,
|
||||||
pub compare_function: Option<CompareFunction>,
|
pub compare_function: CompareFunction,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Texture> for SamplerDescriptor {
|
impl From<&Texture> for SamplerDescriptor {
|
||||||
|
@ -25,7 +25,7 @@ impl From<&Texture> for SamplerDescriptor {
|
||||||
mipmap_filter: FilterMode::Nearest,
|
mipmap_filter: FilterMode::Nearest,
|
||||||
lod_min_clamp: -100.0,
|
lod_min_clamp: -100.0,
|
||||||
lod_max_clamp: 100.0,
|
lod_max_clamp: 100.0,
|
||||||
compare_function: Some(CompareFunction::Always),
|
compare_function: CompareFunction::Always,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ bevy_winit = { path = "../bevy_winit", version = "0.1.0", optional = true }
|
||||||
legion = { path = "../bevy_legion" }
|
legion = { path = "../bevy_legion" }
|
||||||
|
|
||||||
# render
|
# 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"
|
futures = "0.3"
|
||||||
log = { version = "0.4", features = ["release_max_level_info"] }
|
log = { version = "0.4", features = ["release_max_level_info"] }
|
|
@ -47,6 +47,7 @@ impl WgpuRenderer {
|
||||||
let adapter = wgpu::Adapter::request(
|
let adapter = wgpu::Adapter::request(
|
||||||
&wgpu::RequestAdapterOptions {
|
&wgpu::RequestAdapterOptions {
|
||||||
power_preference: wgpu::PowerPreference::Default,
|
power_preference: wgpu::PowerPreference::Default,
|
||||||
|
compatible_surface: None,
|
||||||
},
|
},
|
||||||
wgpu::BackendBit::PRIMARY,
|
wgpu::BackendBit::PRIMARY,
|
||||||
)
|
)
|
||||||
|
@ -223,7 +224,7 @@ impl WgpuRenderer {
|
||||||
self.encoder = Some(
|
self.encoder = Some(
|
||||||
self.device
|
self.device
|
||||||
.borrow()
|
.borrow()
|
||||||
.create_command_encoder(&wgpu::CommandEncoderDescriptor { todo: 0 }),
|
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut render_graph = resources.get_mut::<RenderGraph>().unwrap();
|
let mut render_graph = resources.get_mut::<RenderGraph>().unwrap();
|
||||||
|
@ -359,7 +360,7 @@ impl Renderer for WgpuRenderer {
|
||||||
self.encoder = Some(
|
self.encoder = Some(
|
||||||
self.device
|
self.device
|
||||||
.borrow()
|
.borrow()
|
||||||
.create_command_encoder(&wgpu::CommandEncoderDescriptor { todo: 0 }),
|
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }),
|
||||||
);
|
);
|
||||||
|
|
||||||
self.update_resource_providers(world, resources);
|
self.update_resource_providers(world, resources);
|
||||||
|
@ -570,6 +571,7 @@ impl Renderer for WgpuRenderer {
|
||||||
let wgpu_bind_group_layout =
|
let wgpu_bind_group_layout =
|
||||||
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||||
bindings: bind_group_layout_binding.as_slice(),
|
bindings: bind_group_layout_binding.as_slice(),
|
||||||
|
label: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
self.wgpu_resources
|
self.wgpu_resources
|
||||||
|
|
|
@ -118,6 +118,7 @@ impl WgpuResources {
|
||||||
.get(&bind_group_descriptor.id)
|
.get(&bind_group_descriptor.id)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let wgpu_bind_group_descriptor = wgpu::BindGroupDescriptor {
|
let wgpu_bind_group_descriptor = wgpu::BindGroupDescriptor {
|
||||||
|
label: None,
|
||||||
layout: bind_group_layout,
|
layout: bind_group_layout,
|
||||||
bindings: bindings.as_slice(),
|
bindings: bindings.as_slice(),
|
||||||
};
|
};
|
||||||
|
@ -148,6 +149,7 @@ impl WgpuResources {
|
||||||
buffer_info: BufferInfo,
|
buffer_info: BufferInfo,
|
||||||
) -> RenderResource {
|
) -> RenderResource {
|
||||||
let buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
let buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
|
label: None,
|
||||||
size: buffer_info.size as u64,
|
size: buffer_info.size as u64,
|
||||||
usage: buffer_info.buffer_usage.wgpu_into(),
|
usage: buffer_info.buffer_usage.wgpu_into(),
|
||||||
});
|
});
|
||||||
|
@ -199,8 +201,11 @@ impl WgpuResources {
|
||||||
let device = device_rc.borrow();
|
let device = device_rc.borrow();
|
||||||
|
|
||||||
let mut mapped = device.create_buffer_mapped(
|
let mut mapped = device.create_buffer_mapped(
|
||||||
buffer_info.size as usize,
|
&wgpu::BufferDescriptor {
|
||||||
buffer_info.buffer_usage.wgpu_into(),
|
size: buffer_info.size as u64,
|
||||||
|
usage: buffer_info.buffer_usage.wgpu_into(),
|
||||||
|
label: None,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
setup_data(&mut mapped.data, renderer);
|
setup_data(&mut mapped.data, renderer);
|
||||||
mapped.finish()
|
mapped.finish()
|
||||||
|
|
|
@ -216,9 +216,10 @@ impl WgpuFrom<Extent3d> for wgpu::Extent3d {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WgpuFrom<TextureDescriptor> for wgpu::TextureDescriptor {
|
impl WgpuFrom<TextureDescriptor> for wgpu::TextureDescriptor<'_> {
|
||||||
fn from(texture_descriptor: TextureDescriptor) -> Self {
|
fn from(texture_descriptor: TextureDescriptor) -> Self {
|
||||||
wgpu::TextureDescriptor {
|
wgpu::TextureDescriptor {
|
||||||
|
label: None,
|
||||||
size: texture_descriptor.size.wgpu_into(),
|
size: texture_descriptor.size.wgpu_into(),
|
||||||
array_layer_count: texture_descriptor.array_layer_count,
|
array_layer_count: texture_descriptor.array_layer_count,
|
||||||
mip_level_count: texture_descriptor.mip_level_count,
|
mip_level_count: texture_descriptor.mip_level_count,
|
||||||
|
@ -494,7 +495,7 @@ impl WgpuFrom<IndexFormat> for wgpu::IndexFormat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WgpuFrom<SamplerDescriptor> for wgpu::SamplerDescriptor<'_> {
|
impl WgpuFrom<SamplerDescriptor> for wgpu::SamplerDescriptor {
|
||||||
fn from(sampler_descriptor: SamplerDescriptor) -> Self {
|
fn from(sampler_descriptor: SamplerDescriptor) -> Self {
|
||||||
wgpu::SamplerDescriptor {
|
wgpu::SamplerDescriptor {
|
||||||
address_mode_u: sampler_descriptor.address_mode_u.wgpu_into(),
|
address_mode_u: sampler_descriptor.address_mode_u.wgpu_into(),
|
||||||
|
@ -505,7 +506,7 @@ impl WgpuFrom<SamplerDescriptor> for wgpu::SamplerDescriptor<'_> {
|
||||||
mipmap_filter: sampler_descriptor.mipmap_filter.wgpu_into(),
|
mipmap_filter: sampler_descriptor.mipmap_filter.wgpu_into(),
|
||||||
lod_min_clamp: sampler_descriptor.lod_min_clamp,
|
lod_min_clamp: sampler_descriptor.lod_min_clamp,
|
||||||
lod_max_clamp: sampler_descriptor.lod_max_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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue