Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Commit 2003e6b

Browse files
bors[bot]kvark
andauthored
Merge #232
232: Update to latest wgpu, duplicate RequestAdapterOptions r=kvark a=kvark Co-authored-by: Dzmitry Malyshau <[email protected]>
2 parents 02f7ac9 + b93e942 commit 2003e6b

File tree

7 files changed

+37
-11
lines changed

7 files changed

+37
-11
lines changed

Cargo.toml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ vulkan = ["wgn/vulkan-portability"]
2727
package = "wgpu-native"
2828
version = "0.4"
2929
git = "https://github.com/gfx-rs/wgpu"
30-
rev = "306554600ab7479ec3e54d0c076c71f02474237a"
30+
rev = "05ba7a50b4645f6ac6c65edbae295a31c0d7ebef"
3131

3232
[dependencies.wgc]
3333
package = "wgpu-core"
3434
version = "0.1"
3535
git = "https://github.com/gfx-rs/wgpu"
36-
rev = "306554600ab7479ec3e54d0c076c71f02474237a"
36+
rev = "05ba7a50b4645f6ac6c65edbae295a31c0d7ebef"
3737

3838
[dependencies.wgt]
3939
package = "wgpu-types"
4040
version = "0.1"
4141
git = "https://github.com/gfx-rs/wgpu"
42-
rev = "306554600ab7479ec3e54d0c076c71f02474237a"
42+
rev = "05ba7a50b4645f6ac6c65edbae295a31c0d7ebef"
4343

4444
[dependencies]
4545
arrayvec = "0.5"
@@ -58,12 +58,21 @@ rand = "0.7.2"
5858
zerocopy = "0.3"
5959
futures = "0.3"
6060

61+
[[example]]
62+
name="hello-compute"
63+
path="examples/hello-compute/main.rs"
64+
test = true
65+
6166
#[patch."https://github.com/gfx-rs/wgpu"]
6267
#wgc = { version = "0.1.0", package = "wgpu-core", path = "../wgpu/wgpu-core" }
6368
#wgt = { version = "0.1.0", package = "wgpu-types", path = "../wgpu/wgpu-types" }
6469
#wgn = { version = "0.4.0", package = "wgpu-native", path = "../wgpu/wgpu-native" }
6570

66-
[[example]]
67-
name="hello-compute"
68-
path="examples/hello-compute/main.rs"
69-
test = true
71+
#[patch.crates-io]
72+
#gfx-hal = { version = "0.5.0", path = "../gfx/src/hal" }
73+
#gfx-backend-empty = { version = "0.5.0", path = "../gfx/src/backend/empty" }
74+
#gfx-backend-vulkan = { version = "0.5.0", path = "../gfx/src/backend/vulkan" }
75+
#gfx-backend-dx12 = { version = "0.5.0", path = "../gfx/src/backend/dx12" }
76+
#gfx-backend-dx11 = { version = "0.5.0", path = "../gfx/src/backend/dx11" }
77+
#gfx-descriptor = { version = "0.1.0", path = "../gfx-extras/gfx-descriptor" }
78+
#gfx-memory = { version = "0.1.0", path = "../gfx-extras/gfx-memory" }

examples/capture/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ async fn run() {
88
let adapter = wgpu::Adapter::request(
99
&wgpu::RequestAdapterOptions {
1010
power_preference: wgpu::PowerPreference::Default,
11+
compatible_surface: None,
1112
},
1213
wgpu::BackendBit::PRIMARY,
1314
)

examples/describe/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ async fn run() {
88
let adapter = wgpu::Adapter::request(
99
&wgpu::RequestAdapterOptions {
1010
power_preference: wgpu::PowerPreference::Default,
11+
compatible_surface: None,
1112
},
1213
wgpu::BackendBit::PRIMARY,
1314
)

examples/framework.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ async fn run_async<E: Example>(title: &str) {
102102
let adapter = wgpu::Adapter::request(
103103
&wgpu::RequestAdapterOptions {
104104
power_preference: wgpu::PowerPreference::Default,
105+
compatible_surface: Some(&surface),
105106
},
106107
wgpu::BackendBit::PRIMARY,
107108
)

examples/hello-compute/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async fn execute_gpu(numbers: Vec<u32>) -> Vec<u32> {
2424
let adapter = wgpu::Adapter::request(
2525
&wgpu::RequestAdapterOptions {
2626
power_preference: wgpu::PowerPreference::Default,
27+
compatible_surface: None,
2728
},
2829
wgpu::BackendBit::PRIMARY,
2930
)

examples/hello-triangle/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
1111
let adapter = wgpu::Adapter::request(
1212
&wgpu::RequestAdapterOptions {
1313
power_preference: wgpu::PowerPreference::Default,
14+
compatible_surface: Some(&surface),
1415
},
1516
wgpu::BackendBit::PRIMARY,
1617
)

src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ pub use wgt::{
4949
PresentMode,
5050
PrimitiveTopology,
5151
RasterizationStateDescriptor,
52-
RequestAdapterOptions,
5352
SamplerDescriptor,
5453
ShaderLocation,
5554
ShaderStage,
@@ -79,7 +78,7 @@ pub use wgc::instance::{
7978
#[derive(Default, Debug)]
8079
struct Temp {
8180
//bind_group_descriptors: Vec<wgn::BindGroupDescriptor>,
82-
//vertex_buffers: Vec<wgn::VertexBufferDescriptor>,
81+
//vertex_buffers: Vec<wgn::VertexBufferDescriptor>,
8382
}
8483

8584
/// A handle to a physical graphics and/or compute device.
@@ -91,6 +90,15 @@ pub struct Adapter {
9190
id: wgc::id::AdapterId,
9291
}
9392

93+
/// Options for requesting adapter.
94+
#[derive(Clone, Debug)]
95+
pub struct RequestAdapterOptions<'a> {
96+
/// Power preference for the adapter.
97+
pub power_preference: PowerPreference,
98+
/// Surface that is required to be presentable with the requested adapter.
99+
pub compatible_surface: Option<&'a Surface>,
100+
}
101+
94102
/// An open connection to a graphics and/or compute device.
95103
///
96104
/// The `Device` is the responsible for the creation of most rendering and compute resources, as
@@ -613,7 +621,7 @@ impl Adapter {
613621
/// Some options are "soft", so treated as non-mandatory. Others are "hard".
614622
///
615623
/// If no adapters are found that suffice all the "hard" options, `None` is returned.
616-
pub async fn request(options: &RequestAdapterOptions, backends: BackendBit) -> Option<Self> {
624+
pub async fn request(options: &RequestAdapterOptions<'_>, backends: BackendBit) -> Option<Self> {
617625
unsafe extern "C" fn adapter_callback(
618626
id: wgc::id::AdapterId,
619627
user_data: *mut std::ffi::c_void,
@@ -624,7 +632,11 @@ impl Adapter {
624632
let mut id = wgc::id::AdapterId::ERROR;
625633
unsafe {
626634
wgn::wgpu_request_adapter_async(
627-
Some(options),
635+
Some(&wgc::instance::RequestAdapterOptions {
636+
power_preference: options.power_preference,
637+
compatible_surface: options.compatible_surface
638+
.map_or(wgc::id::SurfaceId::ERROR, |surface| surface.id),
639+
}),
628640
backends,
629641
adapter_callback,
630642
&mut id as *mut _ as *mut std::ffi::c_void,

0 commit comments

Comments
 (0)