mirror of
https://github.com/servo/servo.git
synced 2025-09-23 13:20:11 +01:00
Moves to FxHashMap for Allocator, BHM, Canvas, Media, Servo, WebGL and WebGPU (#39202)
This moves more of HashMap/FnvHashMap to FxHashmap. Again we only changed instances that do not look security related and have small keys. Additionally, allocator used the fnv feature which did not seem to be used. Testing: Unit Tests and WPT should cover this and functionality change is highly unlikely. Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
parent
228b240635
commit
d2c78db981
19 changed files with 53 additions and 46 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -738,6 +738,7 @@ dependencies = [
|
||||||
"mach2",
|
"mach2",
|
||||||
"nix 0.30.1",
|
"nix 0.30.1",
|
||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1171,6 +1172,7 @@ dependencies = [
|
||||||
"pixels",
|
"pixels",
|
||||||
"pollster",
|
"pollster",
|
||||||
"range",
|
"range",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"servo-tracing",
|
"servo-tracing",
|
||||||
"servo_arc",
|
"servo_arc",
|
||||||
"servo_config",
|
"servo_config",
|
||||||
|
@ -5044,6 +5046,7 @@ dependencies = [
|
||||||
"profile",
|
"profile",
|
||||||
"profile_traits",
|
"profile_traits",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"rustls",
|
"rustls",
|
||||||
"script",
|
"script",
|
||||||
"script_traits",
|
"script_traits",
|
||||||
|
@ -5248,9 +5251,9 @@ version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"compositing_traits",
|
"compositing_traits",
|
||||||
"euclid",
|
"euclid",
|
||||||
"fnv",
|
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
"log",
|
"log",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"serde",
|
"serde",
|
||||||
"servo-media",
|
"servo-media",
|
||||||
"servo_config",
|
"servo_config",
|
||||||
|
@ -7863,8 +7866,8 @@ name = "servo_allocator"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"fnv",
|
|
||||||
"libc",
|
"libc",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"tikv-jemalloc-sys",
|
"tikv-jemalloc-sys",
|
||||||
"tikv-jemallocator",
|
"tikv-jemallocator",
|
||||||
"windows-sys 0.61.0",
|
"windows-sys 0.61.0",
|
||||||
|
@ -9834,13 +9837,13 @@ dependencies = [
|
||||||
"compositing_traits",
|
"compositing_traits",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
"euclid",
|
"euclid",
|
||||||
"fnv",
|
|
||||||
"glow",
|
"glow",
|
||||||
"half",
|
"half",
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"log",
|
"log",
|
||||||
"pixels",
|
"pixels",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"surfman",
|
"surfman",
|
||||||
"webrender",
|
"webrender",
|
||||||
"webrender_api",
|
"webrender_api",
|
||||||
|
@ -9859,6 +9862,7 @@ dependencies = [
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
"log",
|
"log",
|
||||||
"pixels",
|
"pixels",
|
||||||
|
"rustc-hash 2.1.1",
|
||||||
"serde",
|
"serde",
|
||||||
"servo_config",
|
"servo_config",
|
||||||
"webgpu_traits",
|
"webgpu_traits",
|
||||||
|
|
|
@ -11,12 +11,12 @@ rust-version.workspace = true
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
allocation-tracking = ["backtrace", "fnv"]
|
allocation-tracking = ["backtrace", "dep:rustc-hash"]
|
||||||
use-system-allocator = ["libc"]
|
use-system-allocator = ["libc"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
backtrace = { workspace = true, optional = true }
|
backtrace = { workspace = true, optional = true }
|
||||||
fnv = { workspace = true, optional = true }
|
rustc-hash = { workspace = true, optional = true }
|
||||||
|
|
||||||
[target.'cfg(not(any(windows, target_env = "ohos")))'.dependencies]
|
[target.'cfg(not(any(windows, target_env = "ohos")))'.dependencies]
|
||||||
libc = { workspace = true, optional = true }
|
libc = { workspace = true, optional = true }
|
||||||
|
|
|
@ -12,7 +12,7 @@ use std::collections::hash_map::Entry;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use fnv::{FnvBuildHasher, FnvHashMap};
|
use rustc_hash::{FxBuildHasher, FxHashMap};
|
||||||
|
|
||||||
/// The maximum number of allocations that we'll keep track of. Once the limit
|
/// The maximum number of allocations that we'll keep track of. Once the limit
|
||||||
/// is reached, we'll evict the first allocation that is smaller than the new addition.
|
/// is reached, we'll evict the first allocation that is smaller than the new addition.
|
||||||
|
@ -54,8 +54,8 @@ impl AllocSite {
|
||||||
unsafe impl Send for AllocSite {}
|
unsafe impl Send for AllocSite {}
|
||||||
|
|
||||||
/// A map of pointers to allocation callsite metadata.
|
/// A map of pointers to allocation callsite metadata.
|
||||||
static ALLOCATION_SITES: Mutex<FnvHashMap<usize, AllocSite>> =
|
static ALLOCATION_SITES: Mutex<FxHashMap<usize, AllocSite>> =
|
||||||
const { Mutex::new(FnvHashMap::with_hasher(FnvBuildHasher::new())) };
|
const { Mutex::new(FxHashMap::default()) };
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct AccountingAlloc<A = System> {
|
pub struct AccountingAlloc<A = System> {
|
||||||
|
|
|
@ -17,6 +17,7 @@ doctest = false
|
||||||
background_hang_monitor_api = { workspace = true }
|
background_hang_monitor_api = { workspace = true }
|
||||||
backtrace = { workspace = true }
|
backtrace = { workspace = true }
|
||||||
base = { workspace = true }
|
base = { workspace = true }
|
||||||
|
rustc-hash = { workspace = true }
|
||||||
crossbeam-channel = { workspace = true }
|
crossbeam-channel = { workspace = true }
|
||||||
ipc-channel = { workspace = true }
|
ipc-channel = { workspace = true }
|
||||||
libc = { workspace = true }
|
libc = { workspace = true }
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::{HashMap, VecDeque};
|
use std::collections::VecDeque;
|
||||||
use std::thread::{self, Builder, JoinHandle};
|
use std::thread::{self, Builder, JoinHandle};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ use background_hang_monitor_api::{
|
||||||
use crossbeam_channel::{Receiver, Sender, after, never, select, unbounded};
|
use crossbeam_channel::{Receiver, Sender, after, never, select, unbounded};
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::sampler::{NativeStack, Sampler};
|
use crate::sampler::{NativeStack, Sampler};
|
||||||
|
|
||||||
|
@ -208,8 +209,8 @@ struct MonitoredComponent {
|
||||||
struct Sample(MonitoredComponentId, Instant, NativeStack);
|
struct Sample(MonitoredComponentId, Instant, NativeStack);
|
||||||
|
|
||||||
struct BackgroundHangMonitorWorker {
|
struct BackgroundHangMonitorWorker {
|
||||||
component_names: HashMap<MonitoredComponentId, String>,
|
component_names: FxHashMap<MonitoredComponentId, String>,
|
||||||
monitored_components: HashMap<MonitoredComponentId, MonitoredComponent>,
|
monitored_components: FxHashMap<MonitoredComponentId, MonitoredComponent>,
|
||||||
constellation_chan: IpcSender<HangMonitorAlert>,
|
constellation_chan: IpcSender<HangMonitorAlert>,
|
||||||
port: Receiver<(MonitoredComponentId, MonitoredComponentMsg)>,
|
port: Receiver<(MonitoredComponentId, MonitoredComponentMsg)>,
|
||||||
control_port: Receiver<BackgroundHangMonitorControlMsg>,
|
control_port: Receiver<BackgroundHangMonitorControlMsg>,
|
||||||
|
|
|
@ -28,6 +28,7 @@ euclid = { workspace = true }
|
||||||
fonts = { path = "../fonts" }
|
fonts = { path = "../fonts" }
|
||||||
ipc-channel = { workspace = true }
|
ipc-channel = { workspace = true }
|
||||||
kurbo = { workspace = true }
|
kurbo = { workspace = true }
|
||||||
|
rustc-hash = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
net_traits = { workspace = true }
|
net_traits = { workspace = true }
|
||||||
peniko = { workspace = true, optional = true }
|
peniko = { workspace = true, optional = true }
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::borrow::ToOwned;
|
use std::borrow::ToOwned;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::{f32, thread};
|
use std::{f32, thread};
|
||||||
|
|
||||||
use base::Epoch;
|
use base::Epoch;
|
||||||
|
@ -16,12 +15,13 @@ use ipc_channel::ipc::{self, IpcSender};
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use pixels::Snapshot;
|
use pixels::Snapshot;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use webrender_api::ImageKey;
|
use webrender_api::ImageKey;
|
||||||
|
|
||||||
use crate::canvas_data::*;
|
use crate::canvas_data::*;
|
||||||
|
|
||||||
pub struct CanvasPaintThread {
|
pub struct CanvasPaintThread {
|
||||||
canvases: HashMap<CanvasId, Canvas>,
|
canvases: FxHashMap<CanvasId, Canvas>,
|
||||||
next_canvas_id: CanvasId,
|
next_canvas_id: CanvasId,
|
||||||
compositor_api: CrossProcessCompositorApi,
|
compositor_api: CrossProcessCompositorApi,
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ pub struct CanvasPaintThread {
|
||||||
impl CanvasPaintThread {
|
impl CanvasPaintThread {
|
||||||
fn new(compositor_api: CrossProcessCompositorApi) -> CanvasPaintThread {
|
fn new(compositor_api: CrossProcessCompositorApi) -> CanvasPaintThread {
|
||||||
CanvasPaintThread {
|
CanvasPaintThread {
|
||||||
canvases: HashMap::new(),
|
canvases: FxHashMap::default(),
|
||||||
next_canvas_id: CanvasId(0),
|
next_canvas_id: CanvasId(0),
|
||||||
compositor_api: compositor_api.clone(),
|
compositor_api: compositor_api.clone(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ path = "lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
compositing_traits = { workspace = true }
|
compositing_traits = { workspace = true }
|
||||||
euclid = { workspace = true }
|
euclid = { workspace = true }
|
||||||
fnv = { workspace = true }
|
rustc-hash = { workspace = true }
|
||||||
ipc-channel = { workspace = true }
|
ipc-channel = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
|
|
@ -6,9 +6,9 @@ use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use compositing_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType};
|
use compositing_traits::{WebrenderExternalImageRegistry, WebrenderImageHandlerType};
|
||||||
use fnv::FnvHashMap;
|
|
||||||
use ipc_channel::ipc::{IpcSender, channel};
|
use ipc_channel::ipc::{IpcSender, channel};
|
||||||
use log::{trace, warn};
|
use log::{trace, warn};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use webrender_api::ExternalImageId;
|
use webrender_api::ExternalImageId;
|
||||||
|
|
||||||
/// GL player threading API entry point that lives in the
|
/// GL player threading API entry point that lives in the
|
||||||
|
@ -19,7 +19,7 @@ use crate::{GLPlayerMsg, GLPlayerMsgForward};
|
||||||
/// a set of video players with GL render.
|
/// a set of video players with GL render.
|
||||||
pub struct GLPlayerThread {
|
pub struct GLPlayerThread {
|
||||||
/// Map of live players.
|
/// Map of live players.
|
||||||
players: FnvHashMap<u64, IpcSender<GLPlayerMsgForward>>,
|
players: FxHashMap<u64, IpcSender<GLPlayerMsgForward>>,
|
||||||
/// List of registered webrender external images.
|
/// List of registered webrender external images.
|
||||||
/// We use it to get an unique ID for new players.
|
/// We use it to get an unique ID for new players.
|
||||||
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
||||||
|
|
|
@ -67,6 +67,7 @@ vello_cpu = ["constellation/vello_cpu"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
background_hang_monitor = { path = "../background_hang_monitor" }
|
background_hang_monitor = { path = "../background_hang_monitor" }
|
||||||
base = { workspace = true }
|
base = { workspace = true }
|
||||||
|
rustc-hash = { workspace = true }
|
||||||
bincode = { workspace = true }
|
bincode = { workspace = true }
|
||||||
bluetooth = { path = "../bluetooth", optional = true }
|
bluetooth = { path = "../bluetooth", optional = true }
|
||||||
bluetooth_traits = { workspace = true, optional = true }
|
bluetooth_traits = { workspace = true, optional = true }
|
||||||
|
|
|
@ -2,11 +2,10 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use base::id::WebViewId;
|
use base::id::WebViewId;
|
||||||
use constellation_traits::EmbedderToConstellationMessage;
|
use constellation_traits::EmbedderToConstellationMessage;
|
||||||
use embedder_traits::{JSValue, JavaScriptEvaluationError, JavaScriptEvaluationId};
|
use embedder_traits::{JSValue, JavaScriptEvaluationError, JavaScriptEvaluationId};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use crate::ConstellationProxy;
|
use crate::ConstellationProxy;
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@ struct PendingEvaluation {
|
||||||
pub(crate) struct JavaScriptEvaluator {
|
pub(crate) struct JavaScriptEvaluator {
|
||||||
current_id: JavaScriptEvaluationId,
|
current_id: JavaScriptEvaluationId,
|
||||||
constellation_proxy: ConstellationProxy,
|
constellation_proxy: ConstellationProxy,
|
||||||
pending_evaluations: HashMap<JavaScriptEvaluationId, PendingEvaluation>,
|
pending_evaluations: FxHashMap<JavaScriptEvaluationId, PendingEvaluation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JavaScriptEvaluator {
|
impl JavaScriptEvaluator {
|
||||||
|
|
|
@ -27,7 +27,6 @@ mod webview_delegate;
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::rc::{Rc, Weak};
|
use std::rc::{Rc, Weak};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
@ -96,6 +95,7 @@ use net_traits::{exit_fetch_thread, start_fetch_thread};
|
||||||
use profile::{mem as profile_mem, time as profile_time};
|
use profile::{mem as profile_mem, time as profile_time};
|
||||||
use profile_traits::mem::MemoryReportResult;
|
use profile_traits::mem::MemoryReportResult;
|
||||||
use profile_traits::{mem, time};
|
use profile_traits::{mem, time};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use script::{JSEngineSetup, ServiceWorkerManager};
|
use script::{JSEngineSetup, ServiceWorkerManager};
|
||||||
use servo_config::opts::Opts;
|
use servo_config::opts::Opts;
|
||||||
pub use servo_config::prefs::PrefValue;
|
pub use servo_config::prefs::PrefValue;
|
||||||
|
@ -209,7 +209,7 @@ pub struct Servo {
|
||||||
/// as `Weak` references so that the embedding application can control their lifetime.
|
/// as `Weak` references so that the embedding application can control their lifetime.
|
||||||
/// When accessed, `Servo` will be reponsible for cleaning up the invalid `Weak`
|
/// When accessed, `Servo` will be reponsible for cleaning up the invalid `Weak`
|
||||||
/// references.
|
/// references.
|
||||||
webviews: RefCell<HashMap<WebViewId, Weak<RefCell<WebViewInner>>>>,
|
webviews: RefCell<FxHashMap<WebViewId, Weak<RefCell<WebViewInner>>>>,
|
||||||
servo_errors: ServoErrorChannel,
|
servo_errors: ServoErrorChannel,
|
||||||
/// For single-process Servo instances, this field controls the initialization
|
/// For single-process Servo instances, this field controls the initialization
|
||||||
/// and deinitialization of the JS Engine. Multiprocess Servo instances have their
|
/// and deinitialization of the JS Engine. Multiprocess Servo instances have their
|
||||||
|
|
|
@ -19,11 +19,11 @@ webxr = ["dep:webxr", "dep:webxr-api"]
|
||||||
base = { workspace = true }
|
base = { workspace = true }
|
||||||
bitflags = { workspace = true }
|
bitflags = { workspace = true }
|
||||||
byteorder = { workspace = true }
|
byteorder = { workspace = true }
|
||||||
|
rustc-hash = { workspace = true }
|
||||||
canvas_traits = { workspace = true }
|
canvas_traits = { workspace = true }
|
||||||
compositing_traits = { workspace = true }
|
compositing_traits = { workspace = true }
|
||||||
crossbeam-channel = { workspace = true }
|
crossbeam-channel = { workspace = true }
|
||||||
euclid = { workspace = true }
|
euclid = { workspace = true }
|
||||||
fnv = { workspace = true }
|
|
||||||
glow = { workspace = true }
|
glow = { workspace = true }
|
||||||
half = "2"
|
half = "2"
|
||||||
ipc-channel = { workspace = true }
|
ipc-channel = { workspace = true }
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::default::Default;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
@ -13,8 +12,8 @@ use compositing_traits::{
|
||||||
WebrenderExternalImageRegistry,
|
WebrenderExternalImageRegistry,
|
||||||
};
|
};
|
||||||
use euclid::default::Size2D;
|
use euclid::default::Size2D;
|
||||||
use fnv::FnvHashMap;
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use surfman::chains::{SwapChainAPI, SwapChains, SwapChainsAPI};
|
use surfman::chains::{SwapChainAPI, SwapChains, SwapChainsAPI};
|
||||||
use surfman::{Device, SurfaceTexture};
|
use surfman::{Device, SurfaceTexture};
|
||||||
use webrender::RenderApiSender;
|
use webrender::RenderApiSender;
|
||||||
|
@ -87,7 +86,7 @@ impl WebGLComm {
|
||||||
struct WebGLExternalImages {
|
struct WebGLExternalImages {
|
||||||
rendering_context: Rc<dyn RenderingContext>,
|
rendering_context: Rc<dyn RenderingContext>,
|
||||||
swap_chains: SwapChains<WebGLContextId, Device>,
|
swap_chains: SwapChains<WebGLContextId, Device>,
|
||||||
locked_front_buffers: FnvHashMap<WebGLContextId, SurfaceTexture>,
|
locked_front_buffers: FxHashMap<WebGLContextId, SurfaceTexture>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebGLExternalImages {
|
impl WebGLExternalImages {
|
||||||
|
@ -98,7 +97,7 @@ impl WebGLExternalImages {
|
||||||
Self {
|
Self {
|
||||||
rendering_context,
|
rendering_context,
|
||||||
swap_chains,
|
swap_chains,
|
||||||
locked_front_buffers: FnvHashMap::default(),
|
locked_front_buffers: FxHashMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ use compositing_traits::{
|
||||||
WebrenderImageHandlerType,
|
WebrenderImageHandlerType,
|
||||||
};
|
};
|
||||||
use euclid::default::Size2D;
|
use euclid::default::Size2D;
|
||||||
use fnv::FnvHashMap;
|
|
||||||
use glow::{
|
use glow::{
|
||||||
self as gl, ActiveTransformFeedback, Context as Gl, HasContext, NativeTransformFeedback,
|
self as gl, ActiveTransformFeedback, Context as Gl, HasContext, NativeTransformFeedback,
|
||||||
NativeUniformLocation, NativeVertexArray, PixelUnpackData, ShaderPrecisionFormat,
|
NativeUniformLocation, NativeVertexArray, PixelUnpackData, ShaderPrecisionFormat,
|
||||||
|
@ -40,6 +39,7 @@ use ipc_channel::ipc::IpcSharedMemory;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::{debug, error, trace, warn};
|
use log::{debug, error, trace, warn};
|
||||||
use pixels::{self, PixelFormat, SnapshotAlphaMode, unmultiply_inplace};
|
use pixels::{self, PixelFormat, SnapshotAlphaMode, unmultiply_inplace};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use surfman::chains::{PreserveBuffer, SwapChains, SwapChainsAPI};
|
use surfman::chains::{PreserveBuffer, SwapChains, SwapChainsAPI};
|
||||||
use surfman::{
|
use surfman::{
|
||||||
self, Adapter, Connection, Context, ContextAttributeFlags, ContextAttributes, Device,
|
self, Adapter, Connection, Context, ContextAttributeFlags, ContextAttributes, Device,
|
||||||
|
@ -210,9 +210,9 @@ pub(crate) struct WebGLThread {
|
||||||
compositor_api: CrossProcessCompositorApi,
|
compositor_api: CrossProcessCompositorApi,
|
||||||
webrender_api: RenderApi,
|
webrender_api: RenderApi,
|
||||||
/// Map of live WebGLContexts.
|
/// Map of live WebGLContexts.
|
||||||
contexts: FnvHashMap<WebGLContextId, GLContextData>,
|
contexts: FxHashMap<WebGLContextId, GLContextData>,
|
||||||
/// Cached information for WebGLContexts.
|
/// Cached information for WebGLContexts.
|
||||||
cached_context_info: FnvHashMap<WebGLContextId, WebGLContextInfo>,
|
cached_context_info: FxHashMap<WebGLContextId, WebGLContextInfo>,
|
||||||
/// Current bound context.
|
/// Current bound context.
|
||||||
bound_context_id: Option<WebGLContextId>,
|
bound_context_id: Option<WebGLContextId>,
|
||||||
/// List of registered webrender external images.
|
/// List of registered webrender external images.
|
||||||
|
@ -863,7 +863,7 @@ impl WebGLThread {
|
||||||
pub(crate) fn make_current_if_needed<'a>(
|
pub(crate) fn make_current_if_needed<'a>(
|
||||||
device: &Device,
|
device: &Device,
|
||||||
context_id: WebGLContextId,
|
context_id: WebGLContextId,
|
||||||
contexts: &'a FnvHashMap<WebGLContextId, GLContextData>,
|
contexts: &'a FxHashMap<WebGLContextId, GLContextData>,
|
||||||
bound_id: &mut Option<WebGLContextId>,
|
bound_id: &mut Option<WebGLContextId>,
|
||||||
) -> Option<&'a GLContextData> {
|
) -> Option<&'a GLContextData> {
|
||||||
let data = contexts.get(&context_id);
|
let data = contexts.get(&context_id);
|
||||||
|
@ -882,7 +882,7 @@ impl WebGLThread {
|
||||||
pub(crate) fn make_current_if_needed_mut<'a>(
|
pub(crate) fn make_current_if_needed_mut<'a>(
|
||||||
device: &Device,
|
device: &Device,
|
||||||
context_id: WebGLContextId,
|
context_id: WebGLContextId,
|
||||||
contexts: &'a mut FnvHashMap<WebGLContextId, GLContextData>,
|
contexts: &'a mut FxHashMap<WebGLContextId, GLContextData>,
|
||||||
bound_id: &mut Option<WebGLContextId>,
|
bound_id: &mut Option<WebGLContextId>,
|
||||||
) -> Option<&'a mut GLContextData> {
|
) -> Option<&'a mut GLContextData> {
|
||||||
let data = contexts.get_mut(&context_id);
|
let data = contexts.get_mut(&context_id);
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::num::NonZeroU32;
|
||||||
use canvas_traits::webgl::{
|
use canvas_traits::webgl::{
|
||||||
WebGLContextId, WebGLMsg, WebGLSender, WebXRCommand, WebXRLayerManagerId, webgl_channel,
|
WebGLContextId, WebGLMsg, WebGLSender, WebXRCommand, WebXRLayerManagerId, webgl_channel,
|
||||||
};
|
};
|
||||||
use fnv::FnvHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use surfman::{Context, Device};
|
use surfman::{Context, Device};
|
||||||
use webxr::SurfmanGL as WebXRSurfman;
|
use webxr::SurfmanGL as WebXRSurfman;
|
||||||
use webxr_api::{
|
use webxr_api::{
|
||||||
|
@ -310,7 +310,7 @@ impl Drop for WebXRBridgeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct WebXRBridgeContexts<'a> {
|
pub(crate) struct WebXRBridgeContexts<'a> {
|
||||||
pub(crate) contexts: &'a mut FnvHashMap<WebGLContextId, GLContextData>,
|
pub(crate) contexts: &'a mut FxHashMap<WebGLContextId, GLContextData>,
|
||||||
pub(crate) bound_context_id: &'a mut Option<WebGLContextId>,
|
pub(crate) bound_context_id: &'a mut Option<WebGLContextId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ path = "lib.rs"
|
||||||
arrayvec = { workspace = true, features = ["serde"] }
|
arrayvec = { workspace = true, features = ["serde"] }
|
||||||
base = { workspace = true }
|
base = { workspace = true }
|
||||||
compositing_traits = { workspace = true }
|
compositing_traits = { workspace = true }
|
||||||
|
rustc-hash = { workspace = true }
|
||||||
euclid = { workspace = true }
|
euclid = { workspace = true }
|
||||||
ipc-channel = { workspace = true }
|
ipc-channel = { workspace = true }
|
||||||
log = { workspace = true }
|
log = { workspace = true }
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
@ -17,6 +16,7 @@ use euclid::default::Size2D;
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use pixels::{IpcSnapshot, Snapshot, SnapshotAlphaMode, SnapshotPixelFormat};
|
use pixels::{IpcSnapshot, Snapshot, SnapshotAlphaMode, SnapshotPixelFormat};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use webgpu_traits::{
|
use webgpu_traits::{
|
||||||
ContextConfiguration, Error, PRESENTATION_BUFFER_COUNT, WebGPUContextId, WebGPUMsg,
|
ContextConfiguration, Error, PRESENTATION_BUFFER_COUNT, WebGPUContextId, WebGPUMsg,
|
||||||
|
@ -35,7 +35,7 @@ use crate::wgt;
|
||||||
|
|
||||||
const DEFAULT_IMAGE_FORMAT: ImageFormat = ImageFormat::RGBA8;
|
const DEFAULT_IMAGE_FORMAT: ImageFormat = ImageFormat::RGBA8;
|
||||||
|
|
||||||
pub type WGPUImageMap = Arc<Mutex<HashMap<WebGPUContextId, ContextData>>>;
|
pub type WGPUImageMap = Arc<Mutex<FxHashMap<WebGPUContextId, ContextData>>>;
|
||||||
|
|
||||||
/// Presentation id encodes current configuration and current image
|
/// Presentation id encodes current configuration and current image
|
||||||
/// so that async presentation does not update context with older data
|
/// so that async presentation does not update context with older data
|
||||||
|
@ -80,7 +80,7 @@ impl Drop for GPUPresentationBuffer {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WGPUExternalImages {
|
pub struct WGPUExternalImages {
|
||||||
pub images: WGPUImageMap,
|
pub images: WGPUImageMap,
|
||||||
pub locked_ids: HashMap<WebGPUContextId, Vec<u8>>,
|
pub locked_ids: FxHashMap<WebGPUContextId, Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebrenderExternalImageApi for WGPUExternalImages {
|
impl WebrenderExternalImageApi for WGPUExternalImages {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
//! Data and main loop of WebGPU thread.
|
//! Data and main loop of WebGPU thread.
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
@ -15,6 +14,7 @@ use compositing_traits::{
|
||||||
};
|
};
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender, IpcSharedMemory};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender, IpcSharedMemory};
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use servo_config::pref;
|
use servo_config::pref;
|
||||||
use webgpu_traits::{
|
use webgpu_traits::{
|
||||||
Adapter, ComputePassId, DeviceLostReason, Error, ErrorScope, Mapping, Pipeline, PopError,
|
Adapter, ComputePassId, DeviceLostReason, Error, ErrorScope, Mapping, Pipeline, PopError,
|
||||||
|
@ -98,21 +98,21 @@ pub(crate) struct WGPU {
|
||||||
sender: IpcSender<WebGPURequest>,
|
sender: IpcSender<WebGPURequest>,
|
||||||
pub(crate) script_sender: IpcSender<WebGPUMsg>,
|
pub(crate) script_sender: IpcSender<WebGPUMsg>,
|
||||||
pub(crate) global: Arc<wgc::global::Global>,
|
pub(crate) global: Arc<wgc::global::Global>,
|
||||||
devices: Arc<Mutex<HashMap<DeviceId, DeviceScope>>>,
|
devices: Arc<Mutex<FxHashMap<DeviceId, DeviceScope>>>,
|
||||||
// TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867)
|
// TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867)
|
||||||
/// This stores first error on command encoder,
|
/// This stores first error on command encoder,
|
||||||
/// because wgpu does not invalidate command encoder object
|
/// because wgpu does not invalidate command encoder object
|
||||||
/// (this is also reused for invalidation of command buffers)
|
/// (this is also reused for invalidation of command buffers)
|
||||||
error_command_encoders: HashMap<id::CommandEncoderId, String>,
|
error_command_encoders: FxHashMap<id::CommandEncoderId, String>,
|
||||||
pub(crate) compositor_api: CrossProcessCompositorApi,
|
pub(crate) compositor_api: CrossProcessCompositorApi,
|
||||||
pub(crate) external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
pub(crate) external_images: Arc<Mutex<WebrenderExternalImageRegistry>>,
|
||||||
pub(crate) wgpu_image_map: WGPUImageMap,
|
pub(crate) wgpu_image_map: WGPUImageMap,
|
||||||
/// Provides access to poller thread
|
/// Provides access to poller thread
|
||||||
pub(crate) poller: Poller,
|
pub(crate) poller: Poller,
|
||||||
/// Store compute passes
|
/// Store compute passes
|
||||||
compute_passes: HashMap<ComputePassId, Pass<ComputePass>>,
|
compute_passes: FxHashMap<ComputePassId, Pass<ComputePass>>,
|
||||||
/// Store render passes
|
/// Store render passes
|
||||||
render_passes: HashMap<RenderPassId, Pass<RenderPass>>,
|
render_passes: FxHashMap<RenderPassId, Pass<RenderPass>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WGPU {
|
impl WGPU {
|
||||||
|
@ -147,13 +147,13 @@ impl WGPU {
|
||||||
sender,
|
sender,
|
||||||
script_sender,
|
script_sender,
|
||||||
global,
|
global,
|
||||||
devices: Arc::new(Mutex::new(HashMap::new())),
|
devices: Arc::new(Mutex::new(FxHashMap::default())),
|
||||||
error_command_encoders: HashMap::new(),
|
error_command_encoders: FxHashMap::default(),
|
||||||
compositor_api,
|
compositor_api,
|
||||||
external_images,
|
external_images,
|
||||||
wgpu_image_map,
|
wgpu_image_map,
|
||||||
compute_passes: HashMap::new(),
|
compute_passes: FxHashMap::default(),
|
||||||
render_passes: HashMap::new(),
|
render_passes: FxHashMap::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue