Less nesting in webgpu response (#32799)

* Remove Option wrap of WebGPUResponse

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

* Replace WebGPUResponseResult with WebGPUResponse

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Samson 2024-07-17 22:37:52 +02:00 committed by GitHub
parent 1223335547
commit 34eed29037
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 196 additions and 214 deletions

View file

@ -54,25 +54,32 @@ impl ShaderCompilationInfo {
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Adapter {
pub adapter_info: wgt::AdapterInfo,
pub adapter_id: WebGPUAdapter,
pub features: wgt::Features,
pub limits: wgt::Limits,
pub channel: WebGPU,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Device {
pub device_id: WebGPUDevice,
pub queue_id: WebGPUQueue,
pub descriptor: wgt::DeviceDescriptor<Option<String>>,
}
#[derive(Debug, Deserialize, Serialize)]
#[allow(clippy::large_enum_variant)]
pub enum WebGPUResponse {
RequestAdapter {
adapter_info: wgt::AdapterInfo,
adapter_id: WebGPUAdapter,
features: wgt::Features,
limits: wgt::Limits,
channel: WebGPU,
},
RequestDevice {
device_id: WebGPUDevice,
queue_id: WebGPUQueue,
descriptor: wgt::DeviceDescriptor<Option<String>>,
},
BufferMapAsync(IpcSharedMemory),
/// WebGPU is disabled
None,
// TODO: use wgpu errors
Adapter(Result<Adapter, String>),
Device(Result<Device, String>),
BufferMapAsync(Result<IpcSharedMemory, String>),
SubmittedWorkDone,
PoppedErrorScope(Result<Option<Error>, PopError>),
CompilationInfo(Option<ShaderCompilationInfo>),
}
pub type WebGPUResponseResult = Result<WebGPUResponse, String>;