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

@ -31,12 +31,12 @@ pub use {wgpu_core as wgc, wgpu_types as wgt};
use crate::identity::*;
use crate::render_commands::RenderCommand;
use crate::{Error, ErrorFilter, WebGPUResponseResult, PRESENTATION_BUFFER_COUNT};
use crate::{Error, ErrorFilter, WebGPUResponse, PRESENTATION_BUFFER_COUNT};
#[derive(Debug, Deserialize, Serialize)]
pub enum WebGPURequest {
BufferMapAsync {
sender: IpcSender<Option<WebGPUResponseResult>>,
sender: IpcSender<WebGPUResponse>,
buffer_id: id::BufferId,
device_id: id::DeviceId,
host_map: HostMap,
@ -126,7 +126,7 @@ pub enum WebGPURequest {
program_id: id::ShaderModuleId,
program: String,
label: Option<String>,
sender: IpcSender<Option<WebGPUResponseResult>>,
sender: IpcSender<WebGPUResponse>,
},
CreateSwapChain {
device_id: id::DeviceId,
@ -182,12 +182,12 @@ pub enum WebGPURequest {
device_id: id::DeviceId,
},
RequestAdapter {
sender: IpcSender<Option<WebGPUResponseResult>>,
sender: IpcSender<WebGPUResponse>,
options: RequestAdapterOptions,
ids: SmallVec<[id::AdapterId; 4]>,
},
RequestDevice {
sender: IpcSender<Option<WebGPUResponseResult>>,
sender: IpcSender<WebGPUResponse>,
adapter_id: WebGPUAdapter,
descriptor: wgt::DeviceDescriptor<Option<String>>,
device_id: id::DeviceId,
@ -280,7 +280,7 @@ pub enum WebGPURequest {
data: IpcSharedMemory,
},
QueueOnSubmittedWorkDone {
sender: IpcSender<Option<WebGPUResponseResult>>,
sender: IpcSender<WebGPUResponse>,
queue_id: id::QueueId,
},
PushErrorScope {
@ -293,6 +293,6 @@ pub enum WebGPURequest {
},
PopErrorScope {
device_id: id::DeviceId,
sender: IpcSender<Option<WebGPUResponseResult>>,
sender: IpcSender<WebGPUResponse>,
},
}

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>;