mirror of
https://github.com/servo/servo.git
synced 2025-09-27 23:30:08 +01:00
webgpu: Simplify presentation and handle cleared in script (#38717)
There are many important changes here: - Generalize the presentation buffer into standalone staging buffers that hold their own state. This allow them to be used by getImage. - Move all clear handling to the ScriptThread and send the configuration on each request present/getimage, thus avoiding any recreate/clearing messages. This means that we prepare staging buffers lazily, on the first request. Try run for this change: https://github.com/sagudev/servo/actions/runs/17341982368 Testing: This is covered by existing WebGPU CTS tests. There are some bad expectations updates, but they are also on main (presumably from last update the rendering work) although I think CTS is actually wrong (see https://github.com/gpuweb/cts/issues/4440). Fixes: #36820 Fixes: #37705 Fixes: #33368 (we now keep reference alive in hashmap) --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
8d2723b2c9
commit
1f0f079203
29 changed files with 1023 additions and 935 deletions
|
@ -36,8 +36,8 @@ use wgpu_types::MemoryHints;
|
|||
use wgt::InstanceDescriptor;
|
||||
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
||||
|
||||
use crate::canvas_context::WGPUImageMap;
|
||||
use crate::poll_thread::Poller;
|
||||
use crate::swapchain::WGPUImageMap;
|
||||
|
||||
#[derive(Eq, Hash, PartialEq)]
|
||||
pub(crate) struct DeviceScope {
|
||||
|
@ -509,32 +509,19 @@ impl WGPU {
|
|||
};
|
||||
self.create_context(context_id, image_key, size, buffer_ids);
|
||||
},
|
||||
WebGPURequest::UpdateContext {
|
||||
WebGPURequest::Present {
|
||||
context_id,
|
||||
pending_texture,
|
||||
size,
|
||||
configuration,
|
||||
} => {
|
||||
self.update_context(context_id, size, configuration);
|
||||
},
|
||||
WebGPURequest::SwapChainPresent {
|
||||
context_id,
|
||||
texture_id,
|
||||
encoder_id,
|
||||
canvas_epoch,
|
||||
} => {
|
||||
let result = self.swapchain_present(
|
||||
context_id,
|
||||
encoder_id,
|
||||
texture_id,
|
||||
canvas_epoch,
|
||||
);
|
||||
if let Err(e) = result {
|
||||
log::error!("Error occured in SwapChainPresent: {e:?}");
|
||||
}
|
||||
},
|
||||
WebGPURequest::GetImage { context_id, sender } => {
|
||||
sender.send(self.get_image(context_id)).unwrap()
|
||||
self.present(context_id, pending_texture, size, canvas_epoch);
|
||||
},
|
||||
WebGPURequest::GetImage {
|
||||
context_id,
|
||||
pending_texture,
|
||||
sender,
|
||||
} => self.get_image(context_id, pending_texture, sender),
|
||||
WebGPURequest::ValidateTextureDescriptor {
|
||||
device_id,
|
||||
texture_id,
|
||||
|
@ -1185,25 +1172,22 @@ impl WGPU {
|
|||
let device_scope = devices
|
||||
.get_mut(&device_id)
|
||||
.expect("Device should not be dropped by this point");
|
||||
if let Some(error_scope_stack) = &mut device_scope.error_scope_stack {
|
||||
if let Some(error_scope) = error_scope_stack.pop() {
|
||||
if let Err(e) = sender.send(Ok(
|
||||
// TODO: Do actual selection instead of selecting first error
|
||||
error_scope.errors.first().cloned(),
|
||||
)) {
|
||||
warn!(
|
||||
"Unable to send {:?} to poperrorscope: {e:?}",
|
||||
error_scope.errors
|
||||
);
|
||||
let result =
|
||||
if let Some(error_scope_stack) = &mut device_scope.error_scope_stack {
|
||||
if let Some(error_scope) = error_scope_stack.pop() {
|
||||
Ok(
|
||||
// TODO: Do actual selection instead of selecting first error
|
||||
error_scope.errors.first().cloned(),
|
||||
)
|
||||
} else {
|
||||
Err(PopError::Empty)
|
||||
}
|
||||
} else if let Err(e) = sender.send(Err(PopError::Empty)) {
|
||||
warn!("Unable to send PopError::Empty: {e:?}");
|
||||
}
|
||||
} else {
|
||||
// device lost
|
||||
if let Err(e) = sender.send(Err(PopError::Lost)) {
|
||||
warn!("Unable to send PopError::Lost due {e:?}");
|
||||
}
|
||||
} else {
|
||||
// This means the device has been lost.
|
||||
Err(PopError::Lost)
|
||||
};
|
||||
if let Err(error) = sender.send(result) {
|
||||
warn!("Error while sending PopErrorScope result: {error}");
|
||||
}
|
||||
},
|
||||
WebGPURequest::ComputeGetBindGroupLayout {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue