Skip to content

Commit 9ce34a2

Browse files
committed
Switch to wgpu master
1 parent 9b548c7 commit 9ce34a2

File tree

6 files changed

+70
-81
lines changed

6 files changed

+70
-81
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ readme = "README.md"
1616
repository = "https://github.com/bevyengine/bevy"
1717

1818
[workspace]
19+
resolver = "2"
1920
exclude = ["benches"]
2021
members = ["crates/*", "examples/ios", "tools/ci"]
2122

crates/bevy_openxr/Cargo.toml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,10 @@ bevy_xr = { path = "../bevy_xr", version = "0.5.0" }
2525
openxr = { git = "https://github.com/Ralith/openxrs" }
2626
serde = "1"
2727
ash = "0.32.1"
28-
# wgpu = { path = "../../../wgpu/wgpu" }
29-
wgpu = "0.9"
28+
wgpu = { git = "https://github.com/gfx-rs/wgpu" }
29+
wgpu-hal = { git = "https://github.com/gfx-rs/wgpu", features = ["vulkan"] } # vulkan flag used for macos dev. todo remove
3030
thiserror = "1.0"
3131
parking_lot = "0.11"
3232

3333
[target.'cfg(target_os = "android")'.dependencies]
3434
ndk-glue = "0.3.0"
35-
36-
# [target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
37-
# wgpu-hal = { path = "../../../wgpu/wgpu-hal", features = ["vulkan"] }
38-
39-
# [target.'cfg(windows)'.dependencies]
40-
# wgpu-hal = { path = "../../../wgpu/wgpu-hal", features = ["dx11"] }
41-
42-
#dev
43-
# [target.'cfg(target_os = "macos")'.dependencies]
44-
# wgpu-hal = { path = "../../../wgpu/wgpu-hal", features = ["vulkan"] }

crates/bevy_openxr/src/interaction/tracking.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ impl XrTrackingSourceBackend for TrackingSource {
229229
.session
230230
.create_reference_space(reference_type, xr::Posef::IDENTITY)
231231
{
232-
let reference_ref = &mut self.context.reference.write();
233-
reference_ref.space_type = reference_type;
234-
reference_ref.space = space;
232+
let reference = &mut self.context.reference.write();
233+
reference.space_type = reference_type;
234+
reference.space = space;
235235

236236
true
237237
} else {

crates/bevy_openxr/src/presentation.rs

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use ash::{
55
use bevy_xr::presentation::XrGraphicsContext;
66
use openxr as xr;
77
use std::{error::Error, ffi::CString, sync::Arc};
8-
// use wgpu_hal as hal;
9-
// #[cfg(windows)]
10-
// use winapi::um::d3d11::ID3D11Device;
8+
use wgpu_hal as hal;
9+
#[cfg(windows)]
10+
use winapi::um::d3d11::ID3D11Device;
1111

1212
#[derive(Clone)]
1313
pub enum GraphicsContextHandles {
@@ -51,25 +51,25 @@ pub fn create_graphics_context(
5151
.engine_version(0)
5252
.api_version(vk_version);
5353

54-
// let mut flags = hal::InstanceFlags::empty();
55-
// if cfg!(debug_assertions) {
56-
// flags |= hal::InstanceFlags::VALIDATION;
57-
// flags |= hal::InstanceFlags::DEBUG;
58-
// }
59-
60-
// let instance_extensions = <hal::api::Vulkan as hal::Api>::Instance::required_extensions(
61-
// &vk_entry, vk_version, flags,
62-
// )
63-
// .map_err(Box::new)?;
64-
// let mut instance_extensions_ptrs = instance_extensions
65-
// .iter()
66-
// .map(|x| x.as_ptr())
67-
// .collect::<Vec<_>>();
68-
let mut instance_extensions_ptrs = vec![];
54+
let mut flags = hal::InstanceFlags::empty();
55+
if cfg!(debug_assertions) {
56+
flags |= hal::InstanceFlags::VALIDATION;
57+
flags |= hal::InstanceFlags::DEBUG;
58+
}
59+
60+
let instance_extensions = <hal::api::Vulkan as hal::Api>::Instance::required_extensions(
61+
&vk_entry, vk_version, flags,
62+
)
63+
.map_err(Box::new)?;
64+
let mut instance_extensions_ptrs = instance_extensions
65+
.iter()
66+
.map(|x| x.as_ptr())
67+
.collect::<Vec<_>>();
68+
// let mut instance_extensions_ptrs = vec![];
6969

7070
let vk_instance = if vulkan_ext2 {
71-
let vk_instance = unsafe {
72-
instance
71+
unsafe {
72+
let vk_instance = instance
7373
.create_vulkan_instance(
7474
system,
7575
std::mem::transmute(vk_entry.static_fn().get_instance_proc_addr),
@@ -79,10 +79,8 @@ pub fn create_graphics_context(
7979
as *const _ as *const _,
8080
)
8181
.map_err(Box::new)?
82-
.map_err(|e| Box::new(vk::Result::from_raw(e)))?
83-
};
82+
.map_err(|e| Box::new(vk::Result::from_raw(e)))?;
8483

85-
unsafe {
8684
ash::Instance::load(
8785
vk_entry.static_fn(),
8886
vk::Instance::from_raw(vk_instance as _),
@@ -109,26 +107,26 @@ pub fn create_graphics_context(
109107
.map_err(Box::new)?
110108
}
111109
};
112-
// let hal_instance = unsafe {
113-
// <hal::api::Vulkan as hal::Api>::Instance::from_raw(
114-
// vk_entry.clone(),
115-
// vk_instance.clone(),
116-
// vk_version,
117-
// instance_extensions,
118-
// flags,
119-
// Box::new(instance.clone()),
120-
// )
121-
// .map_err(Box::new)?
122-
// };
110+
let hal_instance = unsafe {
111+
<hal::api::Vulkan as hal::Api>::Instance::from_raw(
112+
vk_entry.clone(),
113+
vk_instance.clone(),
114+
vk_version,
115+
instance_extensions,
116+
flags,
117+
Box::new(instance.clone()),
118+
)
119+
.map_err(Box::new)?
120+
};
123121

124122
let vk_physical_device = vk::PhysicalDevice::from_raw(
125123
instance
126124
.vulkan_graphics_device(system, vk_instance.handle().as_raw() as _)
127125
.map_err(Box::new)? as _,
128126
);
129-
// let hal_exposed_adapter = hal_instance
130-
// .expose_adapter(vk_physical_device)
131-
// .ok_or_else(|| Box::new(AdapterError))?;
127+
let hal_exposed_adapter = hal_instance
128+
.expose_adapter(vk_physical_device)
129+
.ok_or_else(|| Box::new(AdapterError))?;
132130

133131
let queue_family_index = unsafe {
134132
vk_instance
@@ -146,18 +144,18 @@ pub fn create_graphics_context(
146144
};
147145
let queue_index = 0;
148146

149-
// let device_extensions = hal_exposed_adapter
150-
// .adapter
151-
// .required_device_extensions(device_descriptor.features);
152-
// let mut device_extensions_ptrs = device_extensions
153-
// .iter()
154-
// .map(|x| x.as_ptr())
155-
// .collect::<Vec<_>>();
156-
let mut device_extensions_ptrs = vec![];
147+
let device_extensions = hal_exposed_adapter
148+
.adapter
149+
.required_device_extensions(device_descriptor.features);
150+
let mut device_extensions_ptrs = device_extensions
151+
.iter()
152+
.map(|x| x.as_ptr())
153+
.collect::<Vec<_>>();
154+
// let mut device_extensions_ptrs = vec![];
157155

158-
// let mut physical_features = hal_exposed_adapter
159-
// .adapter
160-
// .physical_device_features(&device_extensions, device_descriptor.features);
156+
let mut physical_features = hal_exposed_adapter
157+
.adapter
158+
.physical_device_features(&device_extensions, device_descriptor.features);
161159

162160
let family_info = vk::DeviceQueueCreateInfo::builder()
163161
.queue_family_index(queue_family_index)
@@ -169,7 +167,7 @@ pub fn create_graphics_context(
169167
let info = vk::DeviceCreateInfo::builder()
170168
.queue_create_infos(&family_infos)
171169
.enabled_extension_names(&device_extensions_ptrs);
172-
// let info = physical_features.add_to_device_create_builder(info).build();
170+
let info = physical_features.add_to_device_create_builder(info).build();
173171

174172
unsafe {
175173
let vk_device = instance
@@ -197,25 +195,25 @@ pub fn create_graphics_context(
197195
let info = vk::DeviceCreateInfo::builder()
198196
.queue_create_infos(&family_infos)
199197
.enabled_extension_names(&device_extensions_ptrs);
200-
// let info = physical_features.add_to_device_create_builder(info).build();
198+
let info = physical_features.add_to_device_create_builder(info).build();
201199

202200
unsafe {
203201
vk_instance
204202
.create_device(vk_physical_device, &info, None)
205203
.map_err(Box::new)?
206204
}
207205
};
208-
// let hal_device = unsafe {
209-
// hal_exposed_adapter
210-
// .adapter
211-
// .device_from_raw(
212-
// vk_device.clone(),
213-
// &device_extensions,
214-
// queue_family_index,
215-
// queue_index,
216-
// )
217-
// .map_err(Box::new)?
218-
// };
206+
let hal_device = unsafe {
207+
hal_exposed_adapter
208+
.adapter
209+
.device_from_raw(
210+
vk_device.clone(),
211+
&device_extensions,
212+
queue_family_index,
213+
queue_index,
214+
)
215+
.map_err(Box::new)?
216+
};
219217

220218
// let wgpu_instance = unsafe { wgpu::Instance::from_hal::<hal::api::Vulkan>(hal_instance) };
221219
// let wgpu_adapter = unsafe { wgpu_instance.adapter_from_hal(hal_exposed_adapter) };

crates/bevy_wgpu/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ bevy_utils = { path = "../bevy_utils", version = "0.5.0" }
3030
bevy_xr = { path = "../bevy_xr", version = "0.5.0" }
3131

3232
# other
33-
# wgpu = { path = "../../../wgpu/wgpu" }
34-
wgpu = "0.9"
33+
wgpu = { git = "https://github.com/gfx-rs/wgpu" }
3534
futures-lite = "1.4.0"
3635
crossbeam-channel = "0.5.0"
3736
crossbeam-utils = "0.8.1"

crates/bevy_xr/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ bevy_app = { path = "../bevy_app", version = "0.5.0" }
1818
bevy_core = { path = "../bevy_core", version = "0.5.0" }
1919
bevy_ecs = { path = "../bevy_ecs", version = "0.5.0" }
2020
bevy_math = { path = "../bevy_math", version = "0.5.0" }
21-
bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = ["bevy"] }
21+
bevy_reflect = { path = "../bevy_reflect", version = "0.5.0", features = [
22+
"bevy",
23+
] }
2224
bevy_utils = { path = "../bevy_utils", version = "0.5.0" }
2325

2426
# other
2527
downcast-rs = "1.2"
2628
serde = "1"
27-
# wgpu = { path = "../../../wgpu/wgpu" }
28-
wgpu = "0.9"
29+
wgpu = { git = "https://github.com/gfx-rs/wgpu" }

0 commit comments

Comments
 (0)