mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
chore: Update wgpu to v25 (#36486)
Updates wgpu to v25 and remove some verbose logging from CTS (that also causes OOM). Testing: WebGPU CTS --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
bd9242acfa
commit
05b5268061
19 changed files with 3833 additions and 2260 deletions
|
@ -6,8 +6,9 @@ use std::rc::Rc;
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{Heap, JSObject};
|
||||
use webgpu_traits::{WebGPU, WebGPUAdapter, WebGPUDeviceResponse, WebGPURequest};
|
||||
use wgpu_core::instance::RequestDeviceError;
|
||||
use webgpu_traits::{
|
||||
RequestDeviceError, WebGPU, WebGPUAdapter, WebGPUDeviceResponse, WebGPURequest,
|
||||
};
|
||||
use wgpu_types::{self, MemoryHints};
|
||||
|
||||
use super::gpusupportedfeatures::GPUSupportedFeatures;
|
||||
|
@ -146,6 +147,7 @@ impl GPUAdapterMethods<crate::DomTypeHolder> for GPUAdapter {
|
|||
required_limits,
|
||||
label: Some(descriptor.parent.label.to_string()),
|
||||
memory_hints: MemoryHints::MemoryUsage,
|
||||
trace: wgpu_types::Trace::Off,
|
||||
};
|
||||
let device_id = self.global().wgpu_id_hub().create_device_id();
|
||||
let queue_id = self.global().wgpu_id_hub().create_queue_id();
|
||||
|
@ -206,6 +208,7 @@ impl GPUAdapterMethods<crate::DomTypeHolder> for GPUAdapter {
|
|||
}
|
||||
|
||||
impl RoutedPromiseListener<WebGPUDeviceResponse> for GPUAdapter {
|
||||
/// <https://www.w3.org/TR/webgpu/#dom-gpuadapter-requestdevice>
|
||||
fn handle_response(
|
||||
&self,
|
||||
response: WebGPUDeviceResponse,
|
||||
|
@ -213,6 +216,7 @@ impl RoutedPromiseListener<WebGPUDeviceResponse> for GPUAdapter {
|
|||
can_gc: CanGc,
|
||||
) {
|
||||
match response {
|
||||
// 3.1 Let device be a new device with the capabilities described by descriptor.
|
||||
(device_id, queue_id, Ok(descriptor)) => {
|
||||
let device = GPUDevice::new(
|
||||
&self.global(),
|
||||
|
@ -229,14 +233,24 @@ impl RoutedPromiseListener<WebGPUDeviceResponse> for GPUAdapter {
|
|||
self.global().add_gpu_device(&device);
|
||||
promise.resolve_native(&device, can_gc);
|
||||
},
|
||||
// 1. If features are not supported reject promise with a TypeError.
|
||||
(_, _, Err(RequestDeviceError::UnsupportedFeature(f))) => promise.reject_error(
|
||||
Error::Type(RequestDeviceError::UnsupportedFeature(f).to_string()),
|
||||
Error::Type(
|
||||
wgpu_core::instance::RequestDeviceError::UnsupportedFeature(f).to_string(),
|
||||
),
|
||||
can_gc,
|
||||
),
|
||||
(_, _, Err(RequestDeviceError::LimitsExceeded(_))) => {
|
||||
// 2. If limits are not supported reject promise with an OperationError.
|
||||
(_, _, Err(RequestDeviceError::LimitsExceeded(l))) => {
|
||||
warn!(
|
||||
"{}",
|
||||
wgpu_core::instance::RequestDeviceError::LimitsExceeded(l)
|
||||
);
|
||||
promise.reject_error(Error::Operation, can_gc)
|
||||
},
|
||||
(device_id, queue_id, Err(e)) => {
|
||||
// 3. user agent otherwise cannot fulfill the request
|
||||
(device_id, queue_id, Err(RequestDeviceError::Other(e))) => {
|
||||
// 1. Let device be a new device.
|
||||
let device = GPUDevice::new(
|
||||
&self.global(),
|
||||
self.channel.clone(),
|
||||
|
@ -249,7 +263,8 @@ impl RoutedPromiseListener<WebGPUDeviceResponse> for GPUAdapter {
|
|||
String::new(),
|
||||
can_gc,
|
||||
);
|
||||
device.lose(GPUDeviceLostReason::Unknown, e.to_string(), can_gc);
|
||||
// 2. Lose the device(device, "unknown").
|
||||
device.lose(GPUDeviceLostReason::Unknown, e, can_gc);
|
||||
promise.resolve_native(&device, can_gc);
|
||||
},
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ pub use wgpu_core::id::{
|
|||
ComputePassEncoderId as ComputePassId, RenderPassEncoderId as RenderPassId,
|
||||
};
|
||||
use wgpu_core::id::{ComputePipelineId, DeviceId, QueueId, RenderPipelineId};
|
||||
use wgpu_core::instance::{RequestAdapterError, RequestDeviceError};
|
||||
use wgpu_core::instance::FailedLimit;
|
||||
use wgpu_core::pipeline::CreateShaderModuleError;
|
||||
use wgpu_types::{AdapterInfo, DeviceDescriptor, Features, Limits, TextureFormat};
|
||||
|
||||
|
@ -31,7 +31,7 @@ pub use crate::render_commands::*;
|
|||
|
||||
pub const PRESENTATION_BUFFER_COUNT: usize = 10;
|
||||
|
||||
pub type WebGPUAdapterResponse = Option<Result<Adapter, RequestAdapterError>>;
|
||||
pub type WebGPUAdapterResponse = Option<Result<Adapter, String>>;
|
||||
pub type WebGPUComputePipelineResponse = Result<Pipeline<ComputePipelineId>, Error>;
|
||||
pub type WebGPUPoppedErrorScopeResponse = Result<Option<Error>, PopError>;
|
||||
pub type WebGPURenderPipelineResponse = Result<Pipeline<RenderPipelineId>, Error>;
|
||||
|
@ -142,3 +142,24 @@ pub type WebGPUDeviceResponse = (
|
|||
WebGPUQueue,
|
||||
Result<DeviceDescriptor<Option<String>>, RequestDeviceError>,
|
||||
);
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum RequestDeviceError {
|
||||
LimitsExceeded(FailedLimit),
|
||||
UnsupportedFeature(Features),
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl From<wgpu_core::instance::RequestDeviceError> for RequestDeviceError {
|
||||
fn from(value: wgpu_core::instance::RequestDeviceError) -> Self {
|
||||
match value {
|
||||
wgpu_core::instance::RequestDeviceError::LimitsExceeded(failed_limit) => {
|
||||
RequestDeviceError::LimitsExceeded(failed_limit)
|
||||
},
|
||||
wgpu_core::instance::RequestDeviceError::UnsupportedFeature(features) => {
|
||||
RequestDeviceError::UnsupportedFeature(features)
|
||||
},
|
||||
e => RequestDeviceError::Other(e.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -664,7 +664,8 @@ impl WGPU {
|
|||
limits,
|
||||
channel: WebGPU(self.sender.clone()),
|
||||
}
|
||||
});
|
||||
})
|
||||
.map_err(|err| err.to_string());
|
||||
|
||||
if let Err(e) = sender.send(Some(response)) {
|
||||
warn!(
|
||||
|
@ -686,6 +687,7 @@ impl WGPU {
|
|||
required_features: descriptor.required_features,
|
||||
required_limits: descriptor.required_limits.clone(),
|
||||
memory_hints: MemoryHints::MemoryUsage,
|
||||
trace: wgpu_types::Trace::Off,
|
||||
};
|
||||
let global = &self.global;
|
||||
let device = WebGPUDevice(device_id);
|
||||
|
@ -694,7 +696,6 @@ impl WGPU {
|
|||
.adapter_request_device(
|
||||
adapter_id.0,
|
||||
&desc,
|
||||
None,
|
||||
Some(device_id),
|
||||
Some(queue_id),
|
||||
)
|
||||
|
@ -733,7 +734,8 @@ impl WGPU {
|
|||
});
|
||||
global.device_set_device_lost_closure(device_id, callback);
|
||||
descriptor
|
||||
});
|
||||
})
|
||||
.map_err(Into::into);
|
||||
if let Err(e) = sender.send((device, queue, result)) {
|
||||
warn!(
|
||||
"Failed to send response to WebGPURequest::RequestDevice ({})",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue