mirror of
https://github.com/servo/servo.git
synced 2025-08-13 01:15:34 +01:00
webgpu: leverage routed_promise in calls returning promises (#35859)
Using the RoutedPromiseListener let us define a different response type for each promise. This removes unreachable branches that used to exist when they all shared the same WebGPUResponse. Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
parent
4814cbdb1f
commit
1c9f486f88
15 changed files with 221 additions and 263 deletions
|
@ -12,7 +12,6 @@ use wgc::id;
|
|||
use wgc::pipeline::CreateShaderModuleError;
|
||||
use wgpu_core::device::HostMap;
|
||||
use wgpu_core::instance::{RequestAdapterError, RequestDeviceError};
|
||||
use wgpu_core::resource::BufferAccessError;
|
||||
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
||||
|
||||
use crate::identity::*;
|
||||
|
@ -82,23 +81,14 @@ pub struct Mapping {
|
|||
pub range: Range<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
pub enum WebGPUResponse {
|
||||
/// WebGPU is disabled
|
||||
None,
|
||||
Adapter(Result<Adapter, RequestAdapterError>),
|
||||
Device(
|
||||
(
|
||||
WebGPUDevice,
|
||||
WebGPUQueue,
|
||||
Result<wgt::DeviceDescriptor<Option<String>>, RequestDeviceError>,
|
||||
),
|
||||
),
|
||||
BufferMapAsync(Result<Mapping, BufferAccessError>),
|
||||
SubmittedWorkDone,
|
||||
PoppedErrorScope(Result<Option<Error>, PopError>),
|
||||
CompilationInfo(Option<ShaderCompilationInfo>),
|
||||
RenderPipeline(Result<Pipeline<id::RenderPipelineId>, Error>),
|
||||
ComputePipeline(Result<Pipeline<id::ComputePipelineId>, Error>),
|
||||
}
|
||||
pub type WebGPUDeviceResponse = (
|
||||
WebGPUDevice,
|
||||
WebGPUQueue,
|
||||
Result<wgt::DeviceDescriptor<Option<String>>, RequestDeviceError>,
|
||||
);
|
||||
|
||||
pub type WebGPUAdapterResponse = Option<Result<Adapter, RequestAdapterError>>;
|
||||
|
||||
pub type WebGPUPoppedErrorScopeResponse = Result<Option<Error>, PopError>;
|
||||
pub type WebGPURenderPipelineResponse = Result<Pipeline<id::RenderPipelineId>, Error>;
|
||||
pub type WebGPUComputePipelineResponse = Result<Pipeline<id::ComputePipelineId>, Error>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue