mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
refactor: add CanGc as argument to Promise::resolve (#35616)
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
This commit is contained in:
parent
adb831eefe
commit
0383ba9a5b
57 changed files with 330 additions and 294 deletions
|
@ -168,15 +168,15 @@ impl AsyncWGPUListener for GPU {
|
|||
adapter.adapter_id,
|
||||
can_gc,
|
||||
);
|
||||
promise.resolve_native(&adapter);
|
||||
promise.resolve_native(&adapter, can_gc);
|
||||
},
|
||||
WebGPUResponse::Adapter(Err(e)) => {
|
||||
warn!("Could not get GPUAdapter ({:?})", e);
|
||||
promise.resolve_native(&None::<GPUAdapter>);
|
||||
promise.resolve_native(&None::<GPUAdapter>, can_gc);
|
||||
},
|
||||
WebGPUResponse::None => {
|
||||
warn!("Couldn't get a response, because WebGPU is disabled");
|
||||
promise.resolve_native(&None::<GPUAdapter>);
|
||||
promise.resolve_native(&None::<GPUAdapter>, can_gc);
|
||||
},
|
||||
_ => unreachable!("GPU received wrong WebGPUResponse"),
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ impl GPUAdapterMethods<crate::DomTypeHolder> for GPUAdapter {
|
|||
if !unmask_hints.is_empty() {
|
||||
todo!("unmaskHints on RequestAdapterInfo");
|
||||
}
|
||||
promise.resolve_native(&*self.info);
|
||||
promise.resolve_native(&*self.info, can_gc);
|
||||
// Step 5
|
||||
promise
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ impl AsyncWGPUListener for GPUAdapter {
|
|||
can_gc,
|
||||
);
|
||||
self.global().add_gpu_device(&device);
|
||||
promise.resolve_native(&device);
|
||||
promise.resolve_native(&device, can_gc);
|
||||
},
|
||||
WebGPUResponse::Device((_, _, Err(RequestDeviceError::UnsupportedFeature(f)))) => {
|
||||
promise.reject_error(Error::Type(
|
||||
|
@ -246,7 +246,7 @@ impl AsyncWGPUListener for GPUAdapter {
|
|||
can_gc,
|
||||
);
|
||||
device.lose(GPUDeviceLostReason::Unknown, e.to_string(), can_gc);
|
||||
promise.resolve_native(&device);
|
||||
promise.resolve_native(&device, can_gc);
|
||||
},
|
||||
WebGPUResponse::None => unreachable!("Failed to get a response for RequestDevice"),
|
||||
_ => unreachable!("GPUAdapter received wrong WebGPUResponse"),
|
||||
|
|
|
@ -380,7 +380,7 @@ impl GPUBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
fn map_success(&self, p: &Rc<Promise>, wgpu_mapping: Mapping) {
|
||||
fn map_success(&self, p: &Rc<Promise>, wgpu_mapping: Mapping, can_gc: CanGc) {
|
||||
let mut pending_map = self.pending_map.borrow_mut();
|
||||
|
||||
// Step 1
|
||||
|
@ -413,7 +413,7 @@ impl GPUBuffer {
|
|||
self.mapping.borrow_mut().replace(mapping);
|
||||
// Step 7
|
||||
pending_map.take();
|
||||
p.resolve_native(&());
|
||||
p.resolve_native(&(), can_gc);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -421,9 +421,11 @@ impl GPUBuffer {
|
|||
|
||||
impl AsyncWGPUListener for GPUBuffer {
|
||||
#[allow(unsafe_code)]
|
||||
fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>, _can_gc: CanGc) {
|
||||
fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>, can_gc: CanGc) {
|
||||
match response {
|
||||
WebGPUResponse::BufferMapAsync(Ok(mapping)) => self.map_success(promise, mapping),
|
||||
WebGPUResponse::BufferMapAsync(Ok(mapping)) => {
|
||||
self.map_success(promise, mapping, can_gc)
|
||||
},
|
||||
WebGPUResponse::BufferMapAsync(Err(_)) => self.map_failure(promise),
|
||||
_ => unreachable!("Wrong response received on AsyncWGPUListener for GPUBuffer"),
|
||||
}
|
||||
|
|
|
@ -373,7 +373,7 @@ impl GPUDevice {
|
|||
let lost_promise = &(*self.lost_promise.borrow());
|
||||
let global = &self.global();
|
||||
let lost = GPUDeviceLostInfo::new(global, msg.into(), reason, can_gc);
|
||||
lost_promise.resolve_native(&*lost);
|
||||
lost_promise.resolve_native(&*lost, can_gc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -585,21 +585,26 @@ impl AsyncWGPUListener for GPUDevice {
|
|||
fn handle_response(&self, response: WebGPUResponse, promise: &Rc<Promise>, can_gc: CanGc) {
|
||||
match response {
|
||||
WebGPUResponse::PoppedErrorScope(result) => match result {
|
||||
Ok(None) | Err(PopError::Lost) => promise.resolve_native(&None::<Option<GPUError>>),
|
||||
Ok(None) | Err(PopError::Lost) => {
|
||||
promise.resolve_native(&None::<Option<GPUError>>, can_gc)
|
||||
},
|
||||
Err(PopError::Empty) => promise.reject_error(Error::Operation),
|
||||
Ok(Some(error)) => {
|
||||
let error = GPUError::from_error(&self.global(), error, can_gc);
|
||||
promise.resolve_native(&error);
|
||||
promise.resolve_native(&error, can_gc);
|
||||
},
|
||||
},
|
||||
WebGPUResponse::ComputePipeline(result) => match result {
|
||||
Ok(pipeline) => promise.resolve_native(&GPUComputePipeline::new(
|
||||
&self.global(),
|
||||
WebGPUComputePipeline(pipeline.id),
|
||||
pipeline.label.into(),
|
||||
self,
|
||||
Ok(pipeline) => promise.resolve_native(
|
||||
&GPUComputePipeline::new(
|
||||
&self.global(),
|
||||
WebGPUComputePipeline(pipeline.id),
|
||||
pipeline.label.into(),
|
||||
self,
|
||||
can_gc,
|
||||
),
|
||||
can_gc,
|
||||
)),
|
||||
),
|
||||
Err(webgpu::Error::Validation(msg)) => {
|
||||
promise.reject_native(&GPUPipelineError::new(
|
||||
&self.global(),
|
||||
|
@ -617,13 +622,16 @@ impl AsyncWGPUListener for GPUDevice {
|
|||
)),
|
||||
},
|
||||
WebGPUResponse::RenderPipeline(result) => match result {
|
||||
Ok(pipeline) => promise.resolve_native(&GPURenderPipeline::new(
|
||||
&self.global(),
|
||||
WebGPURenderPipeline(pipeline.id),
|
||||
pipeline.label.into(),
|
||||
self,
|
||||
Ok(pipeline) => promise.resolve_native(
|
||||
&GPURenderPipeline::new(
|
||||
&self.global(),
|
||||
WebGPURenderPipeline(pipeline.id),
|
||||
pipeline.label.into(),
|
||||
self,
|
||||
can_gc,
|
||||
),
|
||||
can_gc,
|
||||
)),
|
||||
),
|
||||
Err(webgpu::Error::Validation(msg)) => {
|
||||
promise.reject_native(&GPUPipelineError::new(
|
||||
&self.global(),
|
||||
|
|
|
@ -220,11 +220,11 @@ impl AsyncWGPUListener for GPUQueue {
|
|||
&self,
|
||||
response: webgpu::WebGPUResponse,
|
||||
promise: &Rc<Promise>,
|
||||
_can_gc: CanGc,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
match response {
|
||||
WebGPUResponse::SubmittedWorkDone => {
|
||||
promise.resolve_native(&());
|
||||
promise.resolve_native(&(), can_gc);
|
||||
},
|
||||
_ => {
|
||||
warn!("GPUQueue received wrong WebGPUResponse");
|
||||
|
|
|
@ -134,7 +134,7 @@ impl AsyncWGPUListener for GPUShaderModule {
|
|||
match response {
|
||||
WebGPUResponse::CompilationInfo(info) => {
|
||||
let info = GPUCompilationInfo::from(&self.global(), info, can_gc);
|
||||
promise.resolve_native(&info);
|
||||
promise.resolve_native(&info, can_gc);
|
||||
},
|
||||
_ => unreachable!("Wrong response received on AsyncWGPUListener for GPUShaderModule"),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue