Truly independent web browser
Compositor+LibWebView: Stop sharing GPU images a presentation can't use
Andreas Klingf3f410e4ca1e
diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cppindex 09e64f30c7f..d76c0350dee 100644--- a/Libraries/LibWebView/Application.cpp+++ b/Libraries/LibWebView/Application.cpp@@ -1901,9 +1901,9 @@ ErrorOr<void> Application::launch_compositor_process()compositor_reported_gpu_device_identity(move(identity));};+ m_reported_compositor_gpu_presentation_unavailable = false;Optional<u64> gpu_presentation_adapter_luid;#ifdef USE_DIRECTX- m_reported_compositor_gpu_presentation_unavailable = false;gpu_presentation_adapter_luid = Gfx::default_dxgi_adapter_luid();#endifauto presentation_or_error = m_compositor_client->try_create_presentation_connection(!platform_reports_scroll_momentum(), platform_scrolls_elastically(), gpu_presentation_adapter_luid);diff --git a/Services/Compositor/CompositorState.cpp b/Services/Compositor/CompositorState.cppindex 6acec986ed0..24b958801c7 100644--- a/Services/Compositor/CompositorState.cpp+++ b/Services/Compositor/CompositorState.cpp@@ -1482,6 +1482,9 @@ BackingStoreManager::GpuSharing CompositorState::gpu_sharing_for_context([[maybeauto* presentation = presentation_for_context(context_id);if (!presentation || !m_skia_backend_context || m_presentations.get(presentation)->gpu_presentation_adapter_luid != m_skia_backend_context->direct3d_context().adapter_luid())return BackingStoreManager::GpuSharing::Disallowed;+#else+ if (auto* presentation = presentation_for_context(context_id); presentation && m_presentations.get(presentation)->cannot_present_gpu_images)+ return BackingStoreManager::GpuSharing::Disallowed;#endifreturn BackingStoreManager::GpuSharing::Allowed;}@@ -1565,10 +1568,11 @@ void CompositorState::set_client_gpu_presentation_capability(CompositorStateClieOptional<u64> new_adapter_luid;if (supported)new_adapter_luid = adapter_luid;- auto& presentation_adapter_luid = m_presentations.get(&presentation)->gpu_presentation_adapter_luid;- if (presentation_adapter_luid == new_adapter_luid)+ auto& capabilities = *m_presentations.get(&presentation);+ if (capabilities.gpu_presentation_adapter_luid == new_adapter_luid && capabilities.cannot_present_gpu_images == !supported)return;- presentation_adapter_luid = new_adapter_luid;+ capabilities.gpu_presentation_adapter_luid = new_adapter_luid;+ capabilities.cannot_present_gpu_images = !supported;// Reallocate the backing stores of the presentation's contexts so they match the new capability.for (auto& context_entry : m_contexts) {diff --git a/Services/Compositor/CompositorState.h b/Services/Compositor/CompositorState.hindex 838cdf5ca86..cb66f47f81e 100644--- a/Services/Compositor/CompositorState.h+++ b/Services/Compositor/CompositorState.h@@ -94,6 +94,8 @@ public:bool scrollbar_track_press_jumps { false };// LUID of the GPU adapter the presentation can present shared GPU textures on, if any.Optional<u64> gpu_presentation_adapter_luid;+ // Whether the presentation found it cannot present the shared GPU images it was given.+ bool cannot_present_gpu_images { false };};// Each root context presents to the presentation it is bound to. Unbound contexts keep rendering, but publish nothing.