mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +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
|
@ -117,8 +117,6 @@ use crate::dom::bindings::reflector::{DomGlobal, reflect_dom_object_with_proto};
|
|||
use crate::dom::bindings::root::{Dom, DomRoot, LayoutDom, MutNullableDom, ToLayout};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::bindings::trace::{HashMapTracedValues, NoTrace};
|
||||
#[cfg(feature = "webgpu")]
|
||||
use crate::dom::bindings::weakref::WeakRef;
|
||||
use crate::dom::bindings::xmlname::matches_name_production;
|
||||
use crate::dom::canvasrenderingcontext2d::CanvasRenderingContext2D;
|
||||
use crate::dom::cdatasection::CDATASection;
|
||||
|
@ -280,9 +278,6 @@ pub(crate) enum DeclarativeRefresh {
|
|||
},
|
||||
CreatedAfterLoad,
|
||||
}
|
||||
#[cfg(feature = "webgpu")]
|
||||
pub(crate) type WebGPUContextsMap =
|
||||
Rc<RefCell<HashMapTracedValues<WebGPUContextId, WeakRef<GPUCanvasContext>>>>;
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#document>
|
||||
#[dom_struct]
|
||||
|
@ -485,10 +480,9 @@ pub(crate) struct Document {
|
|||
DomRefCell<HashMapTracedValues<WebGLContextId, Dom<WebGLRenderingContext>>>,
|
||||
/// Whether or not animated images need to have their contents updated.
|
||||
has_pending_animated_image_update: Cell<bool>,
|
||||
/// List of all WebGPU contexts.
|
||||
/// List of all WebGPU contexts that need flushing.
|
||||
#[cfg(feature = "webgpu")]
|
||||
#[ignore_malloc_size_of = "Rc are hard"]
|
||||
webgpu_contexts: WebGPUContextsMap,
|
||||
dirty_webgpu_contexts: DomRefCell<HashMapTracedValues<WebGPUContextId, Dom<GPUCanvasContext>>>,
|
||||
/// <https://w3c.github.io/slection-api/#dfn-selection>
|
||||
selection: MutNullableDom<Selection>,
|
||||
/// A timeline for animations which is used for synchronizing animations.
|
||||
|
@ -2648,8 +2642,11 @@ impl Document {
|
|||
}
|
||||
|
||||
#[cfg(feature = "webgpu")]
|
||||
pub(crate) fn webgpu_contexts(&self) -> WebGPUContextsMap {
|
||||
self.webgpu_contexts.clone()
|
||||
pub(crate) fn add_dirty_webgpu_context(&self, context: &GPUCanvasContext) {
|
||||
self.dirty_webgpu_contexts
|
||||
.borrow_mut()
|
||||
.entry(context.context_id())
|
||||
.or_insert_with(|| Dom::from_ref(context));
|
||||
}
|
||||
|
||||
/// Whether or not this [`Document`] needs a rendering update, due to changed
|
||||
|
@ -2706,12 +2703,11 @@ impl Document {
|
|||
|
||||
#[cfg(feature = "webgpu")]
|
||||
image_keys.extend(
|
||||
self.webgpu_contexts
|
||||
self.dirty_webgpu_contexts
|
||||
.borrow_mut()
|
||||
.iter()
|
||||
.filter_map(|(_, context)| context.root())
|
||||
.filter(|context| context.update_rendering(canvas_epoch))
|
||||
.map(|context| context.image_key()),
|
||||
.drain()
|
||||
.filter(|(_, context)| context.update_rendering(canvas_epoch))
|
||||
.map(|(_, context)| context.image_key()),
|
||||
);
|
||||
|
||||
image_keys.extend(
|
||||
|
@ -3426,7 +3422,7 @@ impl Document {
|
|||
dirty_webgl_contexts: DomRefCell::new(HashMapTracedValues::new()),
|
||||
has_pending_animated_image_update: Cell::new(false),
|
||||
#[cfg(feature = "webgpu")]
|
||||
webgpu_contexts: Rc::new(RefCell::new(HashMapTracedValues::new())),
|
||||
dirty_webgpu_contexts: DomRefCell::new(HashMapTracedValues::new()),
|
||||
selection: MutNullableDom::new(None),
|
||||
animation_timeline: if pref!(layout_animations_test_enabled) {
|
||||
DomRefCell::new(AnimationTimeline::new_for_testing())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue