mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Fix failed request for adapter when not available (#31002)
Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
dd0149d953
commit
fddc4a430f
6 changed files with 97 additions and 90 deletions
|
@ -237,35 +237,35 @@ impl GPUAdapterMethods for GPUAdapter {
|
|||
}
|
||||
|
||||
impl AsyncWGPUListener for GPUAdapter {
|
||||
fn handle_response(&self, response: WebGPUResponseResult, promise: &Rc<Promise>) {
|
||||
fn handle_response(&self, response: Option<WebGPUResponseResult>, promise: &Rc<Promise>) {
|
||||
match response {
|
||||
Ok(WebGPUResponse::RequestDevice {
|
||||
device_id,
|
||||
queue_id,
|
||||
descriptor,
|
||||
}) => {
|
||||
let device = GPUDevice::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
&self,
|
||||
Heap::default(),
|
||||
descriptor.features,
|
||||
descriptor.limits,
|
||||
Some(response) => match response {
|
||||
Ok(WebGPUResponse::RequestDevice {
|
||||
device_id,
|
||||
queue_id,
|
||||
descriptor.label.unwrap_or_default(),
|
||||
);
|
||||
self.global().add_gpu_device(&device);
|
||||
promise.resolve_native(&device);
|
||||
},
|
||||
Err(e) => {
|
||||
warn!("Could not get GPUDevice({:?})", e);
|
||||
promise.reject_error(Error::Operation);
|
||||
},
|
||||
_ => {
|
||||
warn!("GPUAdapter received wrong WebGPUResponse");
|
||||
promise.reject_error(Error::Operation);
|
||||
descriptor,
|
||||
}) => {
|
||||
let device = GPUDevice::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
&self,
|
||||
Heap::default(),
|
||||
descriptor.features,
|
||||
descriptor.limits,
|
||||
device_id,
|
||||
queue_id,
|
||||
descriptor.label.unwrap_or_default(),
|
||||
);
|
||||
self.global().add_gpu_device(&device);
|
||||
promise.resolve_native(&device);
|
||||
},
|
||||
Err(e) => {
|
||||
warn!("Could not get GPUDevice({:?})", e);
|
||||
promise.reject_error(Error::Operation);
|
||||
},
|
||||
Ok(_) => unreachable!("GPUAdapter received wrong WebGPUResponse"),
|
||||
},
|
||||
None => unreachable!("Failed to get a response for RequestDevice"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue