mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
webgpu: Update wgpu to 22.0 (#32827)
* Update wgpu to c0e7c1ef94
This is few commits ahead of wgpu 22.0
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Make it compile
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Move usage checking to device timeline as per spec
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Add logging (trace) of WEBGPU messages
This is very useful when debugging
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* update wgpu again
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* set good
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* skip `webgpu:api,operation,memory_sync,texture,same_subresource` for flakyness
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* rm r.json
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:
parent
450aebc839
commit
ad74bfc4ea
9 changed files with 80 additions and 314 deletions
|
@ -7,6 +7,7 @@ use std::rc::Rc;
|
|||
|
||||
use dom_struct::dom_struct;
|
||||
use js::jsapi::{Heap, JSObject};
|
||||
use webgpu::wgt::MemoryHints;
|
||||
use webgpu::{wgt, WebGPU, WebGPUAdapter, WebGPURequest, WebGPUResponse};
|
||||
|
||||
use super::gpusupportedfeatures::GPUSupportedFeatures;
|
||||
|
@ -124,6 +125,7 @@ impl GPUAdapterMethods for GPUAdapter {
|
|||
required_features: features,
|
||||
required_limits: wgt::Limits::default(),
|
||||
label: None,
|
||||
memory_hints: MemoryHints::MemoryUsage,
|
||||
};
|
||||
if let Some(limits) = &descriptor.requiredLimits {
|
||||
for (limit, value) in (*limits).iter() {
|
||||
|
|
|
@ -256,24 +256,17 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer>
|
||||
fn CreateBuffer(&self, descriptor: &GPUBufferDescriptor) -> Fallible<DomRoot<GPUBuffer>> {
|
||||
let desc =
|
||||
wgt::BufferUsages::from_bits(descriptor.usage).map(|usg| wgpu_res::BufferDescriptor {
|
||||
label: convert_label(&descriptor.parent),
|
||||
size: descriptor.size as wgt::BufferAddress,
|
||||
usage: usg,
|
||||
mapped_at_creation: descriptor.mappedAtCreation,
|
||||
});
|
||||
let desc = wgpu_res::BufferDescriptor {
|
||||
label: convert_label(&descriptor.parent),
|
||||
size: descriptor.size as wgt::BufferAddress,
|
||||
usage: wgt::BufferUsages::from_bits_retain(descriptor.usage),
|
||||
mapped_at_creation: descriptor.mappedAtCreation,
|
||||
};
|
||||
let id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.create_buffer_id(self.device.0.backend());
|
||||
|
||||
if desc.is_none() {
|
||||
self.dispatch_error(webgpu::Error::Validation(String::from(
|
||||
"Invalid GPUBufferUsage",
|
||||
)));
|
||||
}
|
||||
|
||||
self.channel
|
||||
.0
|
||||
.send(WebGPURequest::CreateBuffer {
|
||||
|
@ -581,7 +574,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
entry_point: Some(Cow::Owned(descriptor.compute.entryPoint.to_string())),
|
||||
constants: Cow::Owned(HashMap::new()),
|
||||
zero_initialize_workgroup_memory: true,
|
||||
vertex_pulling_transform: false,
|
||||
},
|
||||
cache: None,
|
||||
};
|
||||
|
@ -772,7 +764,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
)),
|
||||
constants: Cow::Owned(HashMap::new()),
|
||||
zero_initialize_workgroup_memory: true,
|
||||
vertex_pulling_transform: false,
|
||||
},
|
||||
buffers: Cow::Owned(
|
||||
descriptor
|
||||
|
@ -809,7 +800,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
entry_point: Some(Cow::Owned(stage.parent.entryPoint.to_string())),
|
||||
constants: Cow::Owned(HashMap::new()),
|
||||
zero_initialize_workgroup_memory: true,
|
||||
vertex_pulling_transform: false,
|
||||
},
|
||||
targets: Cow::Owned(
|
||||
stage
|
||||
|
|
|
@ -89,7 +89,7 @@ pub enum WebGPURequest {
|
|||
CreateBuffer {
|
||||
device_id: id::DeviceId,
|
||||
buffer_id: id::BufferId,
|
||||
descriptor: Option<BufferDescriptor<'static>>,
|
||||
descriptor: BufferDescriptor<'static>,
|
||||
},
|
||||
CreateCommandEncoder {
|
||||
device_id: id::DeviceId,
|
||||
|
|
|
@ -30,6 +30,7 @@ use wgc::resource::{BufferMapCallback, BufferMapOperation};
|
|||
use wgc::{gfx_select, id};
|
||||
use wgpu_core::command::RenderPassDescriptor;
|
||||
use wgpu_core::resource::BufferAccessResult;
|
||||
use wgpu_types::MemoryHints;
|
||||
use wgt::InstanceDescriptor;
|
||||
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
||||
|
||||
|
@ -172,6 +173,7 @@ impl WGPU {
|
|||
pub(crate) fn run(&mut self) {
|
||||
loop {
|
||||
if let Ok(msg) = self.receiver.recv() {
|
||||
log::trace!("recv: {msg:?}");
|
||||
match msg {
|
||||
WebGPURequest::BufferMapAsync {
|
||||
sender,
|
||||
|
@ -196,7 +198,7 @@ impl WGPU {
|
|||
// SAFETY: guarantee to be safe from wgpu
|
||||
let data = unsafe {
|
||||
slice::from_raw_parts(
|
||||
slice_pointer,
|
||||
slice_pointer.as_ptr(),
|
||||
range_size as usize,
|
||||
)
|
||||
};
|
||||
|
@ -355,12 +357,10 @@ impl WGPU {
|
|||
descriptor,
|
||||
} => {
|
||||
let global = &self.global;
|
||||
if let Some(desc) = descriptor {
|
||||
let (_, error) = gfx_select!(buffer_id =>
|
||||
global.device_create_buffer(device_id, &desc, Some(buffer_id)));
|
||||
let (_, error) = gfx_select!(buffer_id =>
|
||||
global.device_create_buffer(device_id, &descriptor, Some(buffer_id)));
|
||||
|
||||
self.maybe_dispatch_wgpu_error(device_id, error);
|
||||
}
|
||||
self.maybe_dispatch_wgpu_error(device_id, error);
|
||||
},
|
||||
WebGPURequest::CreateCommandEncoder {
|
||||
device_id,
|
||||
|
@ -384,13 +384,13 @@ impl WGPU {
|
|||
let bgls = implicit_ids
|
||||
.as_ref()
|
||||
.map_or(Vec::with_capacity(0), |(_, bgls)| {
|
||||
bgls.iter().map(|x| Some(x.to_owned())).collect()
|
||||
bgls.iter().map(|x| x.to_owned()).collect()
|
||||
});
|
||||
let implicit =
|
||||
implicit_ids
|
||||
.as_ref()
|
||||
.map(|(layout, _)| ImplicitPipelineIds {
|
||||
root_id: Some(*layout),
|
||||
root_id: *layout,
|
||||
group_ids: bgls.as_slice(),
|
||||
});
|
||||
let (_, error) = gfx_select!(compute_pipeline_id => global.device_create_compute_pipeline(
|
||||
|
@ -432,13 +432,13 @@ impl WGPU {
|
|||
let bgls = implicit_ids
|
||||
.as_ref()
|
||||
.map_or(Vec::with_capacity(0), |(_, bgls)| {
|
||||
bgls.iter().map(|x| Some(x.to_owned())).collect()
|
||||
bgls.iter().map(|x| x.to_owned()).collect()
|
||||
});
|
||||
let implicit =
|
||||
implicit_ids
|
||||
.as_ref()
|
||||
.map(|(layout, _)| ImplicitPipelineIds {
|
||||
root_id: Some(*layout),
|
||||
root_id: *layout,
|
||||
group_ids: bgls.as_slice(),
|
||||
});
|
||||
if let Some(desc) = descriptor {
|
||||
|
@ -712,6 +712,7 @@ impl WGPU {
|
|||
label: descriptor.label.as_ref().map(crate::Cow::from),
|
||||
required_features: descriptor.required_features,
|
||||
required_limits: descriptor.required_limits.clone(),
|
||||
memory_hints: MemoryHints::MemoryUsage,
|
||||
};
|
||||
let global = &self.global;
|
||||
let (device_id, queue_id, error) = gfx_select!(device_id => global.adapter_request_device(
|
||||
|
@ -1123,7 +1124,10 @@ impl WGPU {
|
|||
global.buffer_get_mapped_range(buffer_id, 0, Some(buffer_size as u64)))
|
||||
.unwrap();
|
||||
let data = unsafe {
|
||||
slice::from_raw_parts(slice_pointer, range_size as usize)
|
||||
slice::from_raw_parts(
|
||||
slice_pointer.as_ptr(),
|
||||
range_size as usize,
|
||||
)
|
||||
}
|
||||
.to_vec();
|
||||
if let Some(present_data) =
|
||||
|
@ -1183,7 +1187,10 @@ impl WGPU {
|
|||
))
|
||||
.unwrap();
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(slice_pointer, range_size as usize)
|
||||
slice::from_raw_parts_mut(
|
||||
slice_pointer.as_ptr(),
|
||||
range_size as usize,
|
||||
)
|
||||
}
|
||||
.copy_from_slice(&array_buffer);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue