232: Update to latest wgpu, duplicate RequestAdapterOptions r=kvark a=kvark



Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot]
2020-04-02 04:30:05 +00:00
committed by GitHub
7 changed files with 37 additions and 11 deletions

View File

@@ -27,19 +27,19 @@ vulkan = ["wgn/vulkan-portability"]
package = "wgpu-native"
version = "0.4"
git = "https://github.com/gfx-rs/wgpu"
rev = "306554600ab7479ec3e54d0c076c71f02474237a"
rev = "05ba7a50b4645f6ac6c65edbae295a31c0d7ebef"
[dependencies.wgc]
package = "wgpu-core"
version = "0.1"
git = "https://github.com/gfx-rs/wgpu"
rev = "306554600ab7479ec3e54d0c076c71f02474237a"
rev = "05ba7a50b4645f6ac6c65edbae295a31c0d7ebef"
[dependencies.wgt]
package = "wgpu-types"
version = "0.1"
git = "https://github.com/gfx-rs/wgpu"
rev = "306554600ab7479ec3e54d0c076c71f02474237a"
rev = "05ba7a50b4645f6ac6c65edbae295a31c0d7ebef"
[dependencies]
arrayvec = "0.5"
@@ -58,12 +58,21 @@ rand = "0.7.2"
zerocopy = "0.3"
futures = "0.3"
[[example]]
name="hello-compute"
path="examples/hello-compute/main.rs"
test = true
#[patch."https://github.com/gfx-rs/wgpu"]
#wgc = { version = "0.1.0", package = "wgpu-core", path = "../wgpu/wgpu-core" }
#wgt = { version = "0.1.0", package = "wgpu-types", path = "../wgpu/wgpu-types" }
#wgn = { version = "0.4.0", package = "wgpu-native", path = "../wgpu/wgpu-native" }
[[example]]
name="hello-compute"
path="examples/hello-compute/main.rs"
test = true
#[patch.crates-io]
#gfx-hal = { version = "0.5.0", path = "../gfx/src/hal" }
#gfx-backend-empty = { version = "0.5.0", path = "../gfx/src/backend/empty" }
#gfx-backend-vulkan = { version = "0.5.0", path = "../gfx/src/backend/vulkan" }
#gfx-backend-dx12 = { version = "0.5.0", path = "../gfx/src/backend/dx12" }
#gfx-backend-dx11 = { version = "0.5.0", path = "../gfx/src/backend/dx11" }
#gfx-descriptor = { version = "0.1.0", path = "../gfx-extras/gfx-descriptor" }
#gfx-memory = { version = "0.1.0", path = "../gfx-extras/gfx-memory" }

View File

@@ -8,6 +8,7 @@ async fn run() {
let adapter = wgpu::Adapter::request(
&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::Default,
compatible_surface: None,
},
wgpu::BackendBit::PRIMARY,
)

View File

@@ -8,6 +8,7 @@ async fn run() {
let adapter = wgpu::Adapter::request(
&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::Default,
compatible_surface: None,
},
wgpu::BackendBit::PRIMARY,
)

View File

@@ -102,6 +102,7 @@ async fn run_async<E: Example>(title: &str) {
let adapter = wgpu::Adapter::request(
&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::Default,
compatible_surface: Some(&surface),
},
wgpu::BackendBit::PRIMARY,
)

View File

@@ -24,6 +24,7 @@ async fn execute_gpu(numbers: Vec<u32>) -> Vec<u32> {
let adapter = wgpu::Adapter::request(
&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::Default,
compatible_surface: None,
},
wgpu::BackendBit::PRIMARY,
)

View File

@@ -11,6 +11,7 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
let adapter = wgpu::Adapter::request(
&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::Default,
compatible_surface: Some(&surface),
},
wgpu::BackendBit::PRIMARY,
)

View File

@@ -49,7 +49,6 @@ pub use wgt::{
PresentMode,
PrimitiveTopology,
RasterizationStateDescriptor,
RequestAdapterOptions,
SamplerDescriptor,
ShaderLocation,
ShaderStage,
@@ -79,7 +78,7 @@ pub use wgc::instance::{
#[derive(Default, Debug)]
struct Temp {
//bind_group_descriptors: Vec<wgn::BindGroupDescriptor>,
//vertex_buffers: Vec<wgn::VertexBufferDescriptor>,
//vertex_buffers: Vec<wgn::VertexBufferDescriptor>,
}
/// A handle to a physical graphics and/or compute device.
@@ -91,6 +90,15 @@ pub struct Adapter {
id: wgc::id::AdapterId,
}
/// Options for requesting adapter.
#[derive(Clone, Debug)]
pub struct RequestAdapterOptions<'a> {
/// Power preference for the adapter.
pub power_preference: PowerPreference,
/// Surface that is required to be presentable with the requested adapter.
pub compatible_surface: Option<&'a Surface>,
}
/// An open connection to a graphics and/or compute device.
///
/// The `Device` is the responsible for the creation of most rendering and compute resources, as
@@ -613,7 +621,7 @@ impl Adapter {
/// Some options are "soft", so treated as non-mandatory. Others are "hard".
///
/// If no adapters are found that suffice all the "hard" options, `None` is returned.
pub async fn request(options: &RequestAdapterOptions, backends: BackendBit) -> Option<Self> {
pub async fn request(options: &RequestAdapterOptions<'_>, backends: BackendBit) -> Option<Self> {
unsafe extern "C" fn adapter_callback(
id: wgc::id::AdapterId,
user_data: *mut std::ffi::c_void,
@@ -624,7 +632,11 @@ impl Adapter {
let mut id = wgc::id::AdapterId::ERROR;
unsafe {
wgn::wgpu_request_adapter_async(
Some(options),
Some(&wgc::instance::RequestAdapterOptions {
power_preference: options.power_preference,
compatible_surface: options.compatible_surface
.map_or(wgc::id::SurfaceId::ERROR, |surface| surface.id),
}),
backends,
adapter_callback,
&mut id as *mut _ as *mut std::ffi::c_void,