diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 82b007b217..85c8298359 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -25,13 +25,13 @@ vulkan-portability = ["wgc/gfx-backend-vulkan"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "89e585af615c5ed2050a1cab7225f6e92a26b3ba" +rev = "4ebe1f50b057046e4d4f015eb006330d62f5fe91" features = ["raw-window-handle"] [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "89e585af615c5ed2050a1cab7225f6e92a26b3ba" +rev = "4ebe1f50b057046e4d4f015eb006330d62f5fe91" [dependencies] arrayvec = "0.5" diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index c97b69e1c0..f5ef5ee128 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -1,10 +1,10 @@ use crate::{ backend::{error::ContextError, native_gpu_future}, - BindGroupDescriptor, BindGroupLayoutDescriptor, BindingResource, CommandEncoderDescriptor, - ComputePassDescriptor, ComputePipelineDescriptor, Features, Label, Limits, LoadOp, MapMode, - Operations, PipelineLayoutDescriptor, RenderBundleEncoderDescriptor, RenderPipelineDescriptor, - SamplerDescriptor, ShaderModuleDescriptor, ShaderSource, SwapChainStatus, TextureDescriptor, - TextureViewDescriptor, + AdapterInfo, BindGroupDescriptor, BindGroupLayoutDescriptor, BindingResource, + CommandEncoderDescriptor, ComputePassDescriptor, ComputePipelineDescriptor, Features, Label, + Limits, LoadOp, MapMode, Operations, PipelineLayoutDescriptor, RenderBundleEncoderDescriptor, + RenderPipelineDescriptor, SamplerDescriptor, ShaderModuleDescriptor, ShaderSource, + SwapChainStatus, TextureDescriptor, TextureViewDescriptor, }; use arrayvec::ArrayVec; @@ -37,14 +37,6 @@ impl Context { &self.0 } - pub fn adapter_get_info(&self, id: wgc::id::AdapterId) -> wgc::instance::AdapterInfo { - let global = &self.0; - match wgc::gfx_select!(id => global.adapter_get_info(id)) { - Ok(info) => info, - Err(e) => panic!("{}", e), - } - } - pub fn enumerate_adapters(&self, backends: wgt::BackendBit) -> Vec { self.0 .enumerate_adapters(wgc::instance::AdapterInputs::Mask(backends, |_| { @@ -691,6 +683,14 @@ impl crate::Context for Context { } } + fn adapter_get_info(&self, adapter: &wgc::id::AdapterId) -> AdapterInfo { + let global = &self.0; + match wgc::gfx_select!(*adapter => global.adapter_get_info(*adapter)) { + Ok(info) => info, + Err(err) => self.handle_error_fatal(err, "Adapter::get_info"), + } + } + fn device_features(&self, device: &Self::DeviceId) -> Features { let global = &self.0; match wgc::gfx_select!(device.id => global.device_features(device.id)) { diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index dbf18efe59..5b5975aeeb 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -941,6 +941,17 @@ impl crate::Context for Context { wgt::Limits::default() } + fn adapter_get_info(&self, _adapter: &Self::AdapterId) -> wgt::AdapterInfo { + // TODO: web-sys has no way of getting information on adapters + wgt::AdapterInfo { + name: String::new(), + vendor: 0, + device: 0, + device_type: wgt::DeviceType::Other, + backend: wgt::Backend::BrowserWebGpu, + } + } + fn device_features(&self, _device: &Self::DeviceId) -> wgt::Features { // TODO: web-sys has no way of getting extensions on devices wgt::Features::empty() diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 7169fbc53e..7fe3d51434 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -24,26 +24,20 @@ use std::{ use futures::FutureExt as _; use parking_lot::Mutex; -#[cfg(feature = "replay")] -use serde::Deserialize; -#[cfg(feature = "trace")] -use serde::Serialize; -#[cfg(not(target_arch = "wasm32"))] -pub use wgc::instance::{AdapterInfo, DeviceType}; pub use wgt::{ - AddressMode, Backend, BackendBit, BindGroupLayoutEntry, BindingType, BlendDescriptor, - BlendFactor, BlendOperation, BufferAddress, BufferBindingType, BufferSize, BufferUsage, Color, - ColorStateDescriptor, ColorWrite, CommandBufferDescriptor, CompareFunction, CullMode, - DepthStencilStateDescriptor, DynamicOffset, Extent3d, Features, FilterMode, FrontFace, - IndexFormat, InputStepMode, Limits, Origin3d, PolygonMode, PowerPreference, PresentMode, - PrimitiveTopology, PushConstantRange, RasterizationStateDescriptor, SamplerBorderColor, - ShaderFlags, ShaderLocation, ShaderStage, StencilOperation, StencilStateDescriptor, - StencilStateFaceDescriptor, StorageTextureAccess, SwapChainDescriptor, SwapChainStatus, - TextureAspect, TextureDataLayout, TextureDimension, TextureFormat, TextureSampleType, - TextureUsage, TextureViewDimension, VertexAttributeDescriptor, VertexFormat, - BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT, - PUSH_CONSTANT_ALIGNMENT, + AdapterInfo, AddressMode, Backend, BackendBit, BindGroupLayoutEntry, BindingType, + BlendDescriptor, BlendFactor, BlendOperation, BufferAddress, BufferBindingType, BufferSize, + BufferUsage, Color, ColorStateDescriptor, ColorWrite, CommandBufferDescriptor, CompareFunction, + CullMode, DepthStencilStateDescriptor, DeviceType, DynamicOffset, Extent3d, Features, + FilterMode, FrontFace, IndexFormat, InputStepMode, Limits, Origin3d, PolygonMode, + PowerPreference, PresentMode, PrimitiveTopology, PushConstantRange, + RasterizationStateDescriptor, SamplerBorderColor, ShaderFlags, ShaderLocation, ShaderStage, + StencilOperation, StencilStateDescriptor, StencilStateFaceDescriptor, StorageTextureAccess, + SwapChainDescriptor, SwapChainStatus, TextureAspect, TextureDataLayout, TextureDimension, + TextureFormat, TextureSampleType, TextureUsage, TextureViewDimension, + VertexAttributeDescriptor, VertexFormat, BIND_BUFFER_ALIGNMENT, COPY_BUFFER_ALIGNMENT, + COPY_BYTES_PER_ROW_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT, }; use backend::{BufferMappedRange, Context as C}; @@ -198,6 +192,7 @@ trait Context: Debug + Send + Sized + Sync { ) -> Self::RequestDeviceFuture; fn adapter_features(&self, adapter: &Self::AdapterId) -> Features; fn adapter_limits(&self, adapter: &Self::AdapterId) -> Limits; + fn adapter_get_info(&self, adapter: &Self::AdapterId) -> AdapterInfo; fn device_features(&self, device: &Self::DeviceId) -> Features; fn device_limits(&self, device: &Self::DeviceId) -> Limits; @@ -915,8 +910,8 @@ pub enum BindingResource<'a> { /// /// The render target must be cleared at least once before it's content be loaded. #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] -#[cfg_attr(feature = "trace", derive(Serialize))] -#[cfg_attr(feature = "replay", derive(Deserialize))] +#[cfg_attr(feature = "trace", derive(serde::Serialize))] +#[cfg_attr(feature = "replay", derive(serde::Deserialize))] pub enum LoadOp { /// Clear with a specified value. Clear(V), @@ -932,8 +927,8 @@ impl Default for LoadOp { /// Pair of load and store operations for an attachment aspect. #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] -#[cfg_attr(feature = "trace", derive(Serialize))] -#[cfg_attr(feature = "replay", derive(Deserialize))] +#[cfg_attr(feature = "trace", derive(serde::Serialize))] +#[cfg_attr(feature = "replay", derive(serde::Deserialize))] pub struct Operations { /// How data should be read through this attachment. pub load: LoadOp, @@ -1406,9 +1401,8 @@ impl Adapter { } /// Get info about the adapter itself. - #[cfg(not(target_arch = "wasm32"))] pub fn get_info(&self) -> AdapterInfo { - self.context.adapter_get_info(self.id) + Context::adapter_get_info(&*self.context, &self.id) } }