mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Update wgpu to trunk (#34607)
* Update wgpu
8f82992b9f
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* fix warnings
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Update expectations
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* re
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* re
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Allow git source for gfx-rs
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
80c4afa63a
commit
d24234ac72
9 changed files with 96 additions and 581 deletions
|
@ -176,7 +176,8 @@ impl GPUCommandEncoderMethods<crate::DomTypeHolder> for GPUCommandEncoder {
|
|||
.colorAttachments
|
||||
.iter()
|
||||
.map(|color| -> Fallible<_> {
|
||||
let channel = wgpu_com::PassChannel {
|
||||
Ok(Some(wgpu_com::RenderPassColorAttachment {
|
||||
resolve_target: color.resolveTarget.as_ref().map(|t| t.id().0),
|
||||
load_op: convert_load_op(Some(color.loadOp)),
|
||||
store_op: convert_store_op(Some(color.storeOp)),
|
||||
clear_value: color
|
||||
|
@ -185,11 +186,6 @@ impl GPUCommandEncoderMethods<crate::DomTypeHolder> for GPUCommandEncoder {
|
|||
.map(|color| (color).try_convert())
|
||||
.transpose()?
|
||||
.unwrap_or_default(),
|
||||
read_only: false,
|
||||
};
|
||||
Ok(Some(wgpu_com::RenderPassColorAttachment {
|
||||
resolve_target: color.resolveTarget.as_ref().map(|t| t.id().0),
|
||||
channel,
|
||||
view: color.view.id().0,
|
||||
}))
|
||||
})
|
||||
|
|
|
@ -239,9 +239,9 @@ impl TryConvert<wgt::Extent3d> for &GPUExtent3D {
|
|||
}
|
||||
}
|
||||
|
||||
impl Convert<wgt::ImageDataLayout> for &GPUImageDataLayout {
|
||||
fn convert(self) -> wgt::ImageDataLayout {
|
||||
wgt::ImageDataLayout {
|
||||
impl Convert<wgt::TexelCopyBufferLayout> for &GPUImageDataLayout {
|
||||
fn convert(self) -> wgt::TexelCopyBufferLayout {
|
||||
wgt::TexelCopyBufferLayout {
|
||||
offset: self.offset as wgt::BufferAddress,
|
||||
bytes_per_row: self.bytesPerRow,
|
||||
rows_per_image: self.rowsPerImage,
|
||||
|
@ -437,9 +437,9 @@ impl Convert<wgt::StencilOperation> for GPUStencilOperation {
|
|||
}
|
||||
}
|
||||
|
||||
impl Convert<wgpu_com::ImageCopyBuffer> for &GPUImageCopyBuffer {
|
||||
fn convert(self) -> wgpu_com::ImageCopyBuffer {
|
||||
wgpu_com::ImageCopyBuffer {
|
||||
impl Convert<wgpu_com::TexelCopyBufferInfo> for &GPUImageCopyBuffer {
|
||||
fn convert(self) -> wgpu_com::TexelCopyBufferInfo {
|
||||
wgpu_com::TexelCopyBufferInfo {
|
||||
buffer: self.buffer.id().0,
|
||||
layout: self.parent.convert(),
|
||||
}
|
||||
|
@ -474,11 +474,11 @@ impl TryConvert<wgt::Origin3d> for &GPUOrigin3D {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryConvert<wgpu_com::ImageCopyTexture> for &GPUImageCopyTexture {
|
||||
impl TryConvert<wgpu_com::TexelCopyTextureInfo> for &GPUImageCopyTexture {
|
||||
type Error = Error;
|
||||
|
||||
fn try_convert(self) -> Result<wgpu_com::ImageCopyTexture, Self::Error> {
|
||||
Ok(wgpu_com::ImageCopyTexture {
|
||||
fn try_convert(self) -> Result<wgpu_com::TexelCopyTextureInfo, Self::Error> {
|
||||
Ok(wgpu_com::TexelCopyTextureInfo {
|
||||
texture: self.texture.id().0,
|
||||
mip_level: self.mipLevel,
|
||||
origin: self
|
||||
|
|
|
@ -15,7 +15,7 @@ use wgc::binding_model::{
|
|||
BindGroupDescriptor, BindGroupLayoutDescriptor, PipelineLayoutDescriptor,
|
||||
};
|
||||
use wgc::command::{
|
||||
ImageCopyBuffer, ImageCopyTexture, RenderBundleDescriptor, RenderBundleEncoder,
|
||||
RenderBundleDescriptor, RenderBundleEncoder, TexelCopyBufferInfo, TexelCopyTextureInfo,
|
||||
};
|
||||
use wgc::device::HostMap;
|
||||
use wgc::id;
|
||||
|
@ -69,20 +69,20 @@ pub enum WebGPURequest {
|
|||
},
|
||||
CopyBufferToTexture {
|
||||
command_encoder_id: id::CommandEncoderId,
|
||||
source: ImageCopyBuffer,
|
||||
destination: ImageCopyTexture,
|
||||
source: TexelCopyBufferInfo,
|
||||
destination: TexelCopyTextureInfo,
|
||||
copy_size: wgt::Extent3d,
|
||||
},
|
||||
CopyTextureToBuffer {
|
||||
command_encoder_id: id::CommandEncoderId,
|
||||
source: ImageCopyTexture,
|
||||
destination: ImageCopyBuffer,
|
||||
source: TexelCopyTextureInfo,
|
||||
destination: TexelCopyBufferInfo,
|
||||
copy_size: wgt::Extent3d,
|
||||
},
|
||||
CopyTextureToTexture {
|
||||
command_encoder_id: id::CommandEncoderId,
|
||||
source: ImageCopyTexture,
|
||||
destination: ImageCopyTexture,
|
||||
source: TexelCopyTextureInfo,
|
||||
destination: TexelCopyTextureInfo,
|
||||
copy_size: wgt::Extent3d,
|
||||
},
|
||||
CreateBindGroup {
|
||||
|
@ -291,8 +291,8 @@ pub enum WebGPURequest {
|
|||
WriteTexture {
|
||||
device_id: id::DeviceId,
|
||||
queue_id: id::QueueId,
|
||||
texture_cv: ImageCopyTexture,
|
||||
data_layout: wgt::ImageDataLayout,
|
||||
texture_cv: TexelCopyTextureInfo,
|
||||
data_layout: wgt::TexelCopyBufferLayout,
|
||||
size: wgt::Extent3d,
|
||||
data: IpcSharedMemory,
|
||||
},
|
||||
|
|
|
@ -23,7 +23,7 @@ use webrender_traits::{WebrenderExternalImageApi, WebrenderImageSource};
|
|||
use wgpu_core::device::HostMap;
|
||||
use wgpu_core::global::Global;
|
||||
use wgpu_core::id;
|
||||
use wgpu_core::resource::{BufferAccessError, BufferMapCallback, BufferMapOperation};
|
||||
use wgpu_core::resource::{BufferAccessError, BufferMapOperation};
|
||||
|
||||
use crate::{wgt, ContextConfiguration, Error, WebGPUMsg};
|
||||
|
||||
|
@ -471,15 +471,15 @@ impl crate::WGPU {
|
|||
let (encoder_id, error) =
|
||||
global.device_create_command_encoder(device_id, &comm_desc, Some(encoder_id));
|
||||
err(error)?;
|
||||
let buffer_cv = wgt::ImageCopyBuffer {
|
||||
let buffer_cv = wgt::TexelCopyBufferInfo {
|
||||
buffer: buffer_id,
|
||||
layout: wgt::ImageDataLayout {
|
||||
layout: wgt::TexelCopyBufferLayout {
|
||||
offset: 0,
|
||||
bytes_per_row: Some(image_desc.buffer_stride() as u32),
|
||||
rows_per_image: None,
|
||||
},
|
||||
};
|
||||
let texture_cv = wgt::ImageCopyTexture {
|
||||
let texture_cv = wgt::TexelCopyTextureInfo {
|
||||
texture: texture_id,
|
||||
mip_level: 0,
|
||||
origin: wgt::Origin3d::ZERO,
|
||||
|
@ -511,7 +511,7 @@ impl crate::WGPU {
|
|||
let webrender_api = Arc::clone(&self.webrender_api);
|
||||
let webrender_document = self.webrender_document;
|
||||
let token = self.poller.token();
|
||||
BufferMapCallback::from_rust(Box::from(move |result| {
|
||||
Box::new(move |result| {
|
||||
drop(token);
|
||||
update_wr_image(
|
||||
result,
|
||||
|
@ -524,7 +524,7 @@ impl crate::WGPU {
|
|||
image_desc,
|
||||
presentation_id,
|
||||
);
|
||||
}))
|
||||
})
|
||||
};
|
||||
let map_op = BufferMapOperation {
|
||||
host: HostMap::Read,
|
||||
|
|
|
@ -17,13 +17,12 @@ use webrender::{RenderApi, RenderApiSender};
|
|||
use webrender_api::{DocumentId, ExternalImageId};
|
||||
use webrender_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType};
|
||||
use wgc::command::{ComputePass, ComputePassDescriptor, RenderPass};
|
||||
use wgc::device::queue::SubmittedWorkDoneClosure;
|
||||
use wgc::device::{DeviceDescriptor, DeviceLostClosure, ImplicitPipelineIds};
|
||||
use wgc::device::{DeviceDescriptor, ImplicitPipelineIds};
|
||||
use wgc::id;
|
||||
use wgc::id::DeviceId;
|
||||
use wgc::instance::parse_backends_from_comma_list;
|
||||
use wgc::pipeline::ShaderModuleDescriptor;
|
||||
use wgc::resource::{BufferMapCallback, BufferMapOperation};
|
||||
use wgc::resource::BufferMapOperation;
|
||||
use wgpu_core::command::RenderPassDescriptor;
|
||||
use wgpu_core::device::DeviceError;
|
||||
use wgpu_core::pipeline::{CreateComputePipelineError, CreateRenderPipelineError};
|
||||
|
@ -178,34 +177,32 @@ impl WGPU {
|
|||
let glob = Arc::clone(&self.global);
|
||||
let resp_sender = sender.clone();
|
||||
let token = self.poller.token();
|
||||
let callback = BufferMapCallback::from_rust(Box::from(
|
||||
move |result: BufferAccessResult| {
|
||||
drop(token);
|
||||
let response = result.and_then(|_| {
|
||||
let global = &glob;
|
||||
let (slice_pointer, range_size) =
|
||||
global.buffer_get_mapped_range(buffer_id, offset, size)?;
|
||||
// SAFETY: guarantee to be safe from wgpu
|
||||
let data = unsafe {
|
||||
slice::from_raw_parts(
|
||||
slice_pointer.as_ptr(),
|
||||
range_size as usize,
|
||||
)
|
||||
};
|
||||
let callback = Box::from(move |result: BufferAccessResult| {
|
||||
drop(token);
|
||||
let response = result.and_then(|_| {
|
||||
let global = &glob;
|
||||
let (slice_pointer, range_size) =
|
||||
global.buffer_get_mapped_range(buffer_id, offset, size)?;
|
||||
// SAFETY: guarantee to be safe from wgpu
|
||||
let data = unsafe {
|
||||
slice::from_raw_parts(
|
||||
slice_pointer.as_ptr(),
|
||||
range_size as usize,
|
||||
)
|
||||
};
|
||||
|
||||
Ok(Mapping {
|
||||
data: IpcSharedMemory::from_bytes(data),
|
||||
range: offset..offset + range_size,
|
||||
mode: host_map,
|
||||
})
|
||||
});
|
||||
if let Err(e) =
|
||||
resp_sender.send(WebGPUResponse::BufferMapAsync(response))
|
||||
{
|
||||
warn!("Could not send BufferMapAsync Response ({})", e);
|
||||
}
|
||||
},
|
||||
));
|
||||
Ok(Mapping {
|
||||
data: IpcSharedMemory::from_bytes(data),
|
||||
range: offset..offset + range_size,
|
||||
mode: host_map,
|
||||
})
|
||||
});
|
||||
if let Err(e) =
|
||||
resp_sender.send(WebGPUResponse::BufferMapAsync(response))
|
||||
{
|
||||
warn!("Could not send BufferMapAsync Response ({})", e);
|
||||
}
|
||||
});
|
||||
|
||||
let operation = BufferMapOperation {
|
||||
host: host_map,
|
||||
|
@ -711,40 +708,32 @@ impl WGPU {
|
|||
}
|
||||
let script_sender = self.script_sender.clone();
|
||||
let devices = Arc::clone(&self.devices);
|
||||
let callback =
|
||||
DeviceLostClosure::from_rust(Box::from(move |reason, msg| {
|
||||
let reason = match reason {
|
||||
wgt::DeviceLostReason::Unknown => {
|
||||
crate::DeviceLostReason::Unknown
|
||||
},
|
||||
wgt::DeviceLostReason::Destroyed => {
|
||||
crate::DeviceLostReason::Destroyed
|
||||
},
|
||||
// we handle this in WebGPUMsg::FreeDevice
|
||||
wgt::DeviceLostReason::Dropped => return,
|
||||
wgt::DeviceLostReason::ReplacedCallback => {
|
||||
panic!(
|
||||
"DeviceLost callback should only be set once"
|
||||
)
|
||||
},
|
||||
};
|
||||
// make device lost by removing error scopes stack
|
||||
let _ = devices
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_mut(&device_id)
|
||||
.expect("Device should not be dropped by this point")
|
||||
.error_scope_stack
|
||||
.take();
|
||||
if let Err(e) = script_sender.send(WebGPUMsg::DeviceLost {
|
||||
device,
|
||||
pipeline_id,
|
||||
reason,
|
||||
msg,
|
||||
}) {
|
||||
warn!("Failed to send WebGPUMsg::DeviceLost: {e}");
|
||||
}
|
||||
}));
|
||||
let callback = Box::from(move |reason, msg| {
|
||||
let reason = match reason {
|
||||
wgt::DeviceLostReason::Unknown => {
|
||||
crate::DeviceLostReason::Unknown
|
||||
},
|
||||
wgt::DeviceLostReason::Destroyed => {
|
||||
crate::DeviceLostReason::Destroyed
|
||||
},
|
||||
};
|
||||
// make device lost by removing error scopes stack
|
||||
let _ = devices
|
||||
.lock()
|
||||
.unwrap()
|
||||
.get_mut(&device_id)
|
||||
.expect("Device should not be dropped by this point")
|
||||
.error_scope_stack
|
||||
.take();
|
||||
if let Err(e) = script_sender.send(WebGPUMsg::DeviceLost {
|
||||
device,
|
||||
pipeline_id,
|
||||
reason,
|
||||
msg,
|
||||
}) {
|
||||
warn!("Failed to send WebGPUMsg::DeviceLost: {e}");
|
||||
}
|
||||
});
|
||||
global.device_set_device_lost_closure(device_id, callback);
|
||||
descriptor
|
||||
});
|
||||
|
@ -1055,12 +1044,12 @@ impl WGPU {
|
|||
WebGPURequest::QueueOnSubmittedWorkDone { sender, queue_id } => {
|
||||
let global = &self.global;
|
||||
let token = self.poller.token();
|
||||
let callback = SubmittedWorkDoneClosure::from_rust(Box::from(move || {
|
||||
let callback = Box::from(move || {
|
||||
drop(token);
|
||||
if let Err(e) = sender.send(WebGPUResponse::SubmittedWorkDone) {
|
||||
warn!("Could not send SubmittedWorkDone Response ({})", e);
|
||||
}
|
||||
}));
|
||||
});
|
||||
global.queue_on_submitted_work_done(queue_id, callback);
|
||||
self.poller.wake();
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue