mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-26 01:11:22 +01:00
Merge #350
350: Implement Extensions Interface r=kvark a=cwfitzgerald This implements https://github.com/gfx-rs/wgpu/pull/703 in wgpu-rs. Notable changes include the removal of the anisotropic field from the examples, in favor of the now mandatory `..Default::default()` syntax. Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
This commit is contained in:
commit
092d5bb6fd
13 files changed
+41
-17
No files matched your search
@@ -223,6 +223,7 @@ impl crate::Context for Context {
|
||||
fn instance_request_adapter(
|
||||
&self,
|
||||
options: &crate::RequestAdapterOptions<'_>,
|
||||
unsafe_extensions: wgt::UnsafeExtensions,
|
||||
backends: wgt::BackendBit,
|
||||
) -> Self::RequestAdapterFuture {
|
||||
let id = self.pick_adapter(
|
||||
@@ -230,6 +231,7 @@ impl crate::Context for Context {
|
||||
power_preference: options.power_preference,
|
||||
compatible_surface: options.compatible_surface.map(|surface| surface.id),
|
||||
},
|
||||
unsafe_extensions,
|
||||
wgc::instance::AdapterInputs::Mask(backends, |_| PhantomData),
|
||||
);
|
||||
ready(id)
|
||||
|
||||
@@ -660,6 +660,7 @@ impl crate::Context for Context {
|
||||
fn instance_request_adapter(
|
||||
&self,
|
||||
options: &crate::RequestAdapterOptions<'_>,
|
||||
_unsafe_extensions: wgt::UnsafeExtensions,
|
||||
_backends: wgt::BackendBit,
|
||||
) -> Self::RequestAdapterFuture {
|
||||
//TODO: support this check, return `None` if the flag is not set.
|
||||
@@ -689,6 +690,11 @@ impl crate::Context for Context {
|
||||
if trace_dir.is_some() {
|
||||
//Error: Tracing isn't supported on the Web target
|
||||
}
|
||||
assert!(
|
||||
!desc.extensions.intersects(crate::Extensions::ALL_NATIVE),
|
||||
"The web backend doesn't support any native extensions. Enabled native extensions: {:?}",
|
||||
desc.extensions & crate::Extensions::ALL_NATIVE
|
||||
);
|
||||
let mut mapped_desc = web_sys::GpuDeviceDescriptor::new();
|
||||
// TODO: label, extensions
|
||||
let mut mapped_limits = web_sys::GpuLimits::new();
|
||||
|
||||
+14
-7
@@ -27,8 +27,8 @@ pub use wgt::{
|
||||
RasterizationStateDescriptor, ShaderLocation, ShaderStage, StencilOperation,
|
||||
StencilStateFaceDescriptor, StoreOp, SwapChainDescriptor, SwapChainStatus, TextureAspect,
|
||||
TextureComponentType, TextureDataLayout, TextureDimension, TextureFormat, TextureUsage,
|
||||
TextureViewDimension, VertexAttributeDescriptor, VertexFormat, BIND_BUFFER_ALIGNMENT,
|
||||
COPY_BYTES_PER_ROW_ALIGNMENT,
|
||||
TextureViewDimension, UnsafeExtensions, VertexAttributeDescriptor, VertexFormat,
|
||||
BIND_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT,
|
||||
};
|
||||
|
||||
use backend::Context as C;
|
||||
@@ -123,6 +123,7 @@ trait Context: Sized {
|
||||
fn instance_request_adapter(
|
||||
&self,
|
||||
options: &RequestAdapterOptions<'_>,
|
||||
unsafe_extensions: wgt::UnsafeExtensions,
|
||||
backends: wgt::BackendBit,
|
||||
) -> Self::RequestAdapterFuture;
|
||||
fn adapter_request_device(
|
||||
@@ -923,12 +924,17 @@ impl Instance {
|
||||
|
||||
/// Retrieves all available [`Adapter`]s that match the given backends.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn enumerate_adapters(&self, backends: wgt::BackendBit) -> impl Iterator<Item = Adapter> {
|
||||
pub fn enumerate_adapters(
|
||||
&self,
|
||||
unsafe_extensions: wgt::UnsafeExtensions,
|
||||
backends: wgt::BackendBit,
|
||||
) -> impl Iterator<Item = Adapter> {
|
||||
let context = Arc::clone(&self.context);
|
||||
self.context
|
||||
.enumerate_adapters(wgc::instance::AdapterInputs::Mask(backends, |_| {
|
||||
PhantomData
|
||||
}))
|
||||
.enumerate_adapters(
|
||||
unsafe_extensions,
|
||||
wgc::instance::AdapterInputs::Mask(backends, |_| PhantomData),
|
||||
)
|
||||
.into_iter()
|
||||
.map(move |id| crate::Adapter {
|
||||
id,
|
||||
@@ -982,11 +988,12 @@ impl Instance {
|
||||
pub fn request_adapter(
|
||||
&self,
|
||||
options: &RequestAdapterOptions<'_>,
|
||||
unsafe_extensions: wgt::UnsafeExtensions,
|
||||
backends: BackendBit,
|
||||
) -> impl Future<Output = Option<Adapter>> + Send {
|
||||
let context = Arc::clone(&self.context);
|
||||
self.context
|
||||
.instance_request_adapter(options, backends)
|
||||
.instance_request_adapter(options, unsafe_extensions, backends)
|
||||
.map(|option| option.map(|id| Adapter { context, id }))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user