mirror of
https://github.com/servo/servo.git
synced 2025-07-21 22:33:41 +01:00
webgpu: Remove mutex around Identities (#32682)
This commit is contained in:
parent
959ffad99a
commit
650af7db92
15 changed files with 69 additions and 100 deletions
|
@ -21,7 +21,6 @@ use net_traits::request::{
|
|||
CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder, RequestMode,
|
||||
};
|
||||
use net_traits::IpcSend;
|
||||
use parking_lot::Mutex;
|
||||
use script_traits::{WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
|
||||
use servo_rand::random;
|
||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||
|
@ -254,7 +253,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
closing: Arc<AtomicBool>,
|
||||
image_cache: Arc<dyn ImageCache>,
|
||||
browsing_context: Option<BrowsingContextId>,
|
||||
gpu_id_hub: Arc<Mutex<Identities>>,
|
||||
gpu_id_hub: Arc<Identities>,
|
||||
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
||||
) -> DedicatedWorkerGlobalScope {
|
||||
DedicatedWorkerGlobalScope {
|
||||
|
@ -292,7 +291,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
closing: Arc<AtomicBool>,
|
||||
image_cache: Arc<dyn ImageCache>,
|
||||
browsing_context: Option<BrowsingContextId>,
|
||||
gpu_id_hub: Arc<Mutex<Identities>>,
|
||||
gpu_id_hub: Arc<Identities>,
|
||||
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
||||
) -> DomRoot<DedicatedWorkerGlobalScope> {
|
||||
let cx = runtime.cx();
|
||||
|
@ -331,7 +330,7 @@ impl DedicatedWorkerGlobalScope {
|
|||
closing: Arc<AtomicBool>,
|
||||
image_cache: Arc<dyn ImageCache>,
|
||||
browsing_context: Option<BrowsingContextId>,
|
||||
gpu_id_hub: Arc<Mutex<Identities>>,
|
||||
gpu_id_hub: Arc<Identities>,
|
||||
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
||||
context_sender: Sender<ContextForRequestInterrupt>,
|
||||
) -> JoinHandle<()> {
|
||||
|
|
|
@ -46,7 +46,6 @@ use net_traits::image_cache::ImageCache;
|
|||
use net_traits::request::Referrer;
|
||||
use net_traits::response::HttpsState;
|
||||
use net_traits::{CoreResourceMsg, CoreResourceThread, IpcSend, ResourceThreads};
|
||||
use parking_lot::Mutex;
|
||||
use profile_traits::{ipc as profile_ipc, mem as profile_mem, time as profile_time};
|
||||
use script_traits::serializable::{BlobData, BlobImpl, FileBlob};
|
||||
use script_traits::transferable::MessagePortImpl;
|
||||
|
@ -319,7 +318,7 @@ pub struct GlobalScope {
|
|||
/// Identity Manager for WebGPU resources
|
||||
#[ignore_malloc_size_of = "defined in wgpu"]
|
||||
#[no_trace]
|
||||
gpu_id_hub: Arc<Mutex<Identities>>,
|
||||
gpu_id_hub: Arc<Identities>,
|
||||
|
||||
/// WebGPU devices
|
||||
gpu_devices: DomRefCell<HashMapTracedValues<WebGPUDevice, WeakRef<GPUDevice>>>,
|
||||
|
@ -762,7 +761,7 @@ impl GlobalScope {
|
|||
microtask_queue: Rc<MicrotaskQueue>,
|
||||
is_headless: bool,
|
||||
user_agent: Cow<'static, str>,
|
||||
gpu_id_hub: Arc<Mutex<Identities>>,
|
||||
gpu_id_hub: Arc<Identities>,
|
||||
inherited_secure_context: Option<bool>,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
@ -3084,7 +3083,7 @@ impl GlobalScope {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn wgpu_id_hub(&self) -> Arc<Mutex<Identities>> {
|
||||
pub fn wgpu_id_hub(&self) -> Arc<Identities> {
|
||||
self.gpu_id_hub.clone()
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ impl GPUMethods for GPU {
|
|||
Some(GPUPowerPreference::High_performance) => PowerPreference::HighPerformance,
|
||||
None => PowerPreference::default(),
|
||||
};
|
||||
let ids = global.wgpu_id_hub().lock().create_adapter_ids();
|
||||
let ids = global.wgpu_id_hub().create_adapter_ids();
|
||||
|
||||
let script_to_constellation_chan = global.script_to_constellation_chan();
|
||||
if script_to_constellation_chan
|
||||
|
|
|
@ -211,7 +211,6 @@ impl GPUAdapterMethods for GPUAdapter {
|
|||
let id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_device_id(self.adapter.0.backend());
|
||||
let pipeline_id = self.global().pipeline_id();
|
||||
if self
|
||||
|
|
|
@ -151,7 +151,6 @@ impl GPUCanvasContext {
|
|||
let encoder_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_command_encoder_id(texture_id.backend());
|
||||
if let Err(e) = self.channel.0.send(WebGPURequest::SwapChainPresent {
|
||||
external_id: self.context_id.0,
|
||||
|
@ -265,7 +264,6 @@ impl GPUCanvasContextMethods for GPUCanvasContext {
|
|||
buffer_ids.push(
|
||||
self.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_buffer_id(descriptor.device.id().0.backend()),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,6 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
let compute_pass_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_compute_pass_id(self.device.id().0.backend());
|
||||
|
||||
if let Err(e) = self.channel.0.send(WebGPURequest::BeginComputePass {
|
||||
|
|
|
@ -198,7 +198,6 @@ impl GPUDevice {
|
|||
let layout_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_pipeline_layout_id(self.device.0.backend());
|
||||
let max_bind_grps = self.limits.MaxBindGroups();
|
||||
let mut bgls = Vec::with_capacity(max_bind_grps as usize);
|
||||
|
@ -207,7 +206,6 @@ impl GPUDevice {
|
|||
let bgl = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_bind_group_layout_id(self.device.0.backend());
|
||||
bgls.push(webgpu::WebGPUBindGroupLayout(bgl));
|
||||
bgl_ids.push(bgl);
|
||||
|
@ -268,7 +266,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_buffer_id(self.device.0.backend());
|
||||
|
||||
if desc.is_none() {
|
||||
|
@ -411,7 +408,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let bind_group_layout_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_bind_group_layout_id(self.device.0.backend());
|
||||
self.channel
|
||||
.0
|
||||
|
@ -452,7 +448,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let pipeline_layout_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_pipeline_layout_id(self.device.0.backend());
|
||||
self.channel
|
||||
.0
|
||||
|
@ -512,7 +507,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let bind_group_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_bind_group_id(self.device.0.backend());
|
||||
self.channel
|
||||
.0
|
||||
|
@ -544,7 +538,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let program_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_shader_module_id(self.device.0.backend());
|
||||
let promise = Promise::new_in_current_realm(comp);
|
||||
let shader_module = GPUShaderModule::new(
|
||||
|
@ -576,7 +569,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let compute_pipeline_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_compute_pipeline_id(self.device.0.backend());
|
||||
|
||||
let (layout, implicit_ids, bgls) = self.get_pipeline_layout_data(&descriptor.parent.layout);
|
||||
|
@ -634,7 +626,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let command_encoder_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_command_encoder_id(self.device.0.backend());
|
||||
self.channel
|
||||
.0
|
||||
|
@ -683,7 +674,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let texture_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_texture_id(self.device.0.backend());
|
||||
|
||||
if desc.is_none() {
|
||||
|
@ -720,7 +710,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let sampler_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_sampler_id(self.device.0.backend());
|
||||
let compare_enable = descriptor.compare.is_some();
|
||||
let desc = wgpu_res::SamplerDescriptor {
|
||||
|
@ -895,7 +884,6 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let render_pipeline_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_render_pipeline_id(self.device.0.backend());
|
||||
|
||||
self.channel
|
||||
|
|
|
@ -204,7 +204,6 @@ impl GPURenderBundleEncoderMethods for GPURenderBundleEncoder {
|
|||
let render_bundle_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_render_bundle_id(self.device.id().0.backend());
|
||||
|
||||
self.channel
|
||||
|
|
|
@ -173,7 +173,6 @@ impl GPUTextureMethods for GPUTexture {
|
|||
let texture_view_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
.lock()
|
||||
.create_texture_view_id(self.device.id().0.backend());
|
||||
|
||||
self.channel
|
||||
|
|
|
@ -85,43 +85,43 @@ impl Identities {
|
|||
}
|
||||
}
|
||||
|
||||
fn select(&mut self, backend: Backend) -> &mut IdentityHub {
|
||||
fn select(&self, backend: Backend) -> &IdentityHub {
|
||||
match backend {
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
Backend::Vulkan => &mut self.vk_hub,
|
||||
Backend::Vulkan => &self.vk_hub,
|
||||
#[cfg(target_os = "windows")]
|
||||
Backend::Dx12 => &mut self.dx12_hub,
|
||||
Backend::Dx12 => &self.dx12_hub,
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
Backend::Metal => &mut self.metal_hub,
|
||||
Backend::Metal => &self.metal_hub,
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
Backend::Gl => &mut self.gl_hub,
|
||||
_ => &mut self.dummy_hub,
|
||||
Backend::Gl => &self.gl_hub,
|
||||
_ => &self.dummy_hub,
|
||||
}
|
||||
}
|
||||
|
||||
fn hubs(&mut self) -> Vec<(&mut IdentityHub, Backend)> {
|
||||
fn hubs(&self) -> Vec<(&IdentityHub, Backend)> {
|
||||
vec![
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
(&mut self.vk_hub, Backend::Vulkan),
|
||||
(&self.vk_hub, Backend::Vulkan),
|
||||
#[cfg(target_os = "windows")]
|
||||
(&mut self.dx12_hub, Backend::Dx12),
|
||||
(&self.dx12_hub, Backend::Dx12),
|
||||
#[cfg(any(target_os = "ios", target_os = "macos"))]
|
||||
(&mut self.metal_hub, Backend::Metal),
|
||||
(&self.metal_hub, Backend::Metal),
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
(&mut self.gl_hub, Backend::Gl),
|
||||
(&mut self.dummy_hub, Backend::Empty),
|
||||
(&self.gl_hub, Backend::Gl),
|
||||
(&self.dummy_hub, Backend::Empty),
|
||||
]
|
||||
}
|
||||
|
||||
pub fn create_device_id(&mut self, backend: Backend) -> DeviceId {
|
||||
pub fn create_device_id(&self, backend: Backend) -> DeviceId {
|
||||
self.select(backend).devices.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_device_id(&mut self, id: DeviceId) {
|
||||
pub fn kill_device_id(&self, id: DeviceId) {
|
||||
self.select(id.backend()).devices.free(id);
|
||||
}
|
||||
|
||||
pub fn create_adapter_ids(&mut self) -> SmallVec<[AdapterId; 4]> {
|
||||
pub fn create_adapter_ids(&self) -> SmallVec<[AdapterId; 4]> {
|
||||
let mut ids = SmallVec::new();
|
||||
for hubs in self.hubs() {
|
||||
ids.push(hubs.0.adapters.process(hubs.1));
|
||||
|
@ -129,111 +129,111 @@ impl Identities {
|
|||
ids
|
||||
}
|
||||
|
||||
pub fn kill_adapter_id(&mut self, id: AdapterId) {
|
||||
pub fn kill_adapter_id(&self, id: AdapterId) {
|
||||
self.select(id.backend()).adapters.free(id);
|
||||
}
|
||||
|
||||
pub fn create_buffer_id(&mut self, backend: Backend) -> BufferId {
|
||||
pub fn create_buffer_id(&self, backend: Backend) -> BufferId {
|
||||
self.select(backend).buffers.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_buffer_id(&mut self, id: BufferId) {
|
||||
pub fn kill_buffer_id(&self, id: BufferId) {
|
||||
self.select(id.backend()).buffers.free(id);
|
||||
}
|
||||
|
||||
pub fn create_bind_group_id(&mut self, backend: Backend) -> BindGroupId {
|
||||
pub fn create_bind_group_id(&self, backend: Backend) -> BindGroupId {
|
||||
self.select(backend).bind_groups.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_bind_group_id(&mut self, id: BindGroupId) {
|
||||
pub fn kill_bind_group_id(&self, id: BindGroupId) {
|
||||
self.select(id.backend()).bind_groups.free(id);
|
||||
}
|
||||
|
||||
pub fn create_bind_group_layout_id(&mut self, backend: Backend) -> BindGroupLayoutId {
|
||||
pub fn create_bind_group_layout_id(&self, backend: Backend) -> BindGroupLayoutId {
|
||||
self.select(backend).bind_group_layouts.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_bind_group_layout_id(&mut self, id: BindGroupLayoutId) {
|
||||
pub fn kill_bind_group_layout_id(&self, id: BindGroupLayoutId) {
|
||||
self.select(id.backend()).bind_group_layouts.free(id);
|
||||
}
|
||||
|
||||
pub fn create_compute_pipeline_id(&mut self, backend: Backend) -> ComputePipelineId {
|
||||
pub fn create_compute_pipeline_id(&self, backend: Backend) -> ComputePipelineId {
|
||||
self.select(backend).compute_pipelines.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_compute_pipeline_id(&mut self, id: ComputePipelineId) {
|
||||
pub fn kill_compute_pipeline_id(&self, id: ComputePipelineId) {
|
||||
self.select(id.backend()).compute_pipelines.free(id);
|
||||
}
|
||||
|
||||
pub fn create_pipeline_layout_id(&mut self, backend: Backend) -> PipelineLayoutId {
|
||||
pub fn create_pipeline_layout_id(&self, backend: Backend) -> PipelineLayoutId {
|
||||
self.select(backend).pipeline_layouts.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_pipeline_layout_id(&mut self, id: PipelineLayoutId) {
|
||||
pub fn kill_pipeline_layout_id(&self, id: PipelineLayoutId) {
|
||||
self.select(id.backend()).pipeline_layouts.free(id);
|
||||
}
|
||||
|
||||
pub fn create_shader_module_id(&mut self, backend: Backend) -> ShaderModuleId {
|
||||
pub fn create_shader_module_id(&self, backend: Backend) -> ShaderModuleId {
|
||||
self.select(backend).shader_modules.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_shader_module_id(&mut self, id: ShaderModuleId) {
|
||||
pub fn kill_shader_module_id(&self, id: ShaderModuleId) {
|
||||
self.select(id.backend()).shader_modules.free(id);
|
||||
}
|
||||
|
||||
pub fn create_command_encoder_id(&mut self, backend: Backend) -> CommandEncoderId {
|
||||
pub fn create_command_encoder_id(&self, backend: Backend) -> CommandEncoderId {
|
||||
self.select(backend).command_encoders.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_command_buffer_id(&mut self, id: CommandEncoderId) {
|
||||
pub fn kill_command_buffer_id(&self, id: CommandEncoderId) {
|
||||
self.select(id.backend()).command_encoders.free(id);
|
||||
}
|
||||
|
||||
pub fn create_sampler_id(&mut self, backend: Backend) -> SamplerId {
|
||||
pub fn create_sampler_id(&self, backend: Backend) -> SamplerId {
|
||||
self.select(backend).samplers.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_sampler_id(&mut self, id: SamplerId) {
|
||||
pub fn kill_sampler_id(&self, id: SamplerId) {
|
||||
self.select(id.backend()).samplers.free(id);
|
||||
}
|
||||
|
||||
pub fn create_render_pipeline_id(&mut self, backend: Backend) -> RenderPipelineId {
|
||||
pub fn create_render_pipeline_id(&self, backend: Backend) -> RenderPipelineId {
|
||||
self.select(backend).render_pipelines.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_render_pipeline_id(&mut self, id: RenderPipelineId) {
|
||||
pub fn kill_render_pipeline_id(&self, id: RenderPipelineId) {
|
||||
self.select(id.backend()).render_pipelines.free(id);
|
||||
}
|
||||
|
||||
pub fn create_texture_id(&mut self, backend: Backend) -> TextureId {
|
||||
pub fn create_texture_id(&self, backend: Backend) -> TextureId {
|
||||
self.select(backend).textures.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_texture_id(&mut self, id: TextureId) {
|
||||
pub fn kill_texture_id(&self, id: TextureId) {
|
||||
self.select(id.backend()).textures.free(id);
|
||||
}
|
||||
|
||||
pub fn create_texture_view_id(&mut self, backend: Backend) -> TextureViewId {
|
||||
pub fn create_texture_view_id(&self, backend: Backend) -> TextureViewId {
|
||||
self.select(backend).texture_views.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_texture_view_id(&mut self, id: TextureViewId) {
|
||||
pub fn kill_texture_view_id(&self, id: TextureViewId) {
|
||||
self.select(id.backend()).texture_views.free(id);
|
||||
}
|
||||
|
||||
pub fn create_render_bundle_id(&mut self, backend: Backend) -> RenderBundleId {
|
||||
pub fn create_render_bundle_id(&self, backend: Backend) -> RenderBundleId {
|
||||
self.select(backend).render_bundles.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_render_bundle_id(&mut self, id: RenderBundleId) {
|
||||
pub fn kill_render_bundle_id(&self, id: RenderBundleId) {
|
||||
self.select(id.backend()).render_bundles.free(id);
|
||||
}
|
||||
|
||||
pub fn create_compute_pass_id(&mut self, backend: Backend) -> ComputePassId {
|
||||
pub fn create_compute_pass_id(&self, backend: Backend) -> ComputePassId {
|
||||
self.select(backend).compute_passes.process(backend)
|
||||
}
|
||||
|
||||
pub fn kill_compute_pass_id(&mut self, id: ComputePassId) {
|
||||
pub fn kill_compute_pass_id(&self, id: ComputePassId) {
|
||||
self.select(id.backend()).compute_passes.free(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ use js::jsapi::{JSContext, JS_AddInterruptCallback};
|
|||
use js::jsval::UndefinedValue;
|
||||
use net_traits::request::{CredentialsMode, Destination, ParserMetadata, Referrer, RequestBuilder};
|
||||
use net_traits::{CustomResponseMediator, IpcSend};
|
||||
use parking_lot::Mutex;
|
||||
use script_traits::{ScopeThings, ServiceWorkerMsg, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
|
||||
use servo_config::pref;
|
||||
use servo_rand::random;
|
||||
|
@ -242,7 +241,7 @@ impl ServiceWorkerGlobalScope {
|
|||
runtime,
|
||||
from_devtools_receiver,
|
||||
closing,
|
||||
Arc::new(Mutex::new(Identities::new())),
|
||||
Arc::new(Identities::new()),
|
||||
),
|
||||
task_queue: TaskQueue::new(receiver, own_sender.clone()),
|
||||
own_sender,
|
||||
|
|
|
@ -44,7 +44,6 @@ use net_traits::image_cache::{
|
|||
use net_traits::storage_thread::StorageType;
|
||||
use net_traits::ResourceThreads;
|
||||
use num_traits::ToPrimitive;
|
||||
use parking_lot::Mutex as ParkMutex;
|
||||
use profile_traits::ipc as ProfiledIpc;
|
||||
use profile_traits::mem::ProfilerChan as MemProfilerChan;
|
||||
use profile_traits::time::ProfilerChan as TimeProfilerChan;
|
||||
|
@ -2557,7 +2556,7 @@ impl Window {
|
|||
replace_surrogates: bool,
|
||||
user_agent: Cow<'static, str>,
|
||||
player_context: WindowGLContext,
|
||||
gpu_id_hub: Arc<ParkMutex<Identities>>,
|
||||
gpu_id_hub: Arc<Identities>,
|
||||
inherited_secure_context: Option<bool>,
|
||||
) -> DomRoot<Self> {
|
||||
let error_reporter = CSSErrorReporter {
|
||||
|
|
|
@ -19,7 +19,6 @@ use net_traits::request::{
|
|||
CredentialsMode, Destination, ParserMetadata, RequestBuilder as NetRequestInit,
|
||||
};
|
||||
use net_traits::IpcSend;
|
||||
use parking_lot::Mutex;
|
||||
use script_traits::WorkerGlobalScopeInit;
|
||||
use servo_url::{MutableOrigin, ServoUrl};
|
||||
use time::precise_time_ns;
|
||||
|
@ -138,7 +137,7 @@ impl WorkerGlobalScope {
|
|||
runtime: Runtime,
|
||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
|
||||
closing: Arc<AtomicBool>,
|
||||
gpu_id_hub: Arc<Mutex<Identities>>,
|
||||
gpu_id_hub: Arc<Identities>,
|
||||
) -> Self {
|
||||
// Install a pipeline-namespace in the current thread.
|
||||
PipelineNamespace::auto_install();
|
||||
|
|
|
@ -14,7 +14,6 @@ use js::jsval::UndefinedValue;
|
|||
use js::rust::Runtime;
|
||||
use net_traits::image_cache::ImageCache;
|
||||
use net_traits::ResourceThreads;
|
||||
use parking_lot::Mutex;
|
||||
use profile_traits::{mem, time};
|
||||
use script_traits::{Painter, ScriptMsg, ScriptToConstellationChan, TimerSchedulerMsg};
|
||||
use servo_atoms::Atom;
|
||||
|
@ -165,7 +164,7 @@ pub struct WorkletGlobalScopeInit {
|
|||
/// An optional string allowing the user agent to be set for testing
|
||||
pub user_agent: Cow<'static, str>,
|
||||
/// Identity manager for WebGPU resources
|
||||
pub gpu_id_hub: Arc<Mutex<Identities>>,
|
||||
pub gpu_id_hub: Arc<Identities>,
|
||||
/// Is considered secure
|
||||
pub inherited_secure_context: Option<bool>,
|
||||
}
|
||||
|
|
|
@ -69,7 +69,6 @@ use net_traits::{
|
|||
FetchMetadata, FetchResponseListener, FetchResponseMsg, Metadata, NetworkError, ReferrerPolicy,
|
||||
ResourceFetchTiming, ResourceThreads, ResourceTimingType,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use percent_encoding::percent_decode;
|
||||
use profile_traits::mem::{self as profile_mem, OpaqueSender, ReportsChan};
|
||||
use profile_traits::time::{self as profile_time, profile, ProfilerCategory};
|
||||
|
@ -721,7 +720,7 @@ pub struct ScriptThread {
|
|||
|
||||
/// Identity manager for WebGPU resources
|
||||
#[no_trace]
|
||||
gpu_id_hub: Arc<Mutex<Identities>>,
|
||||
gpu_id_hub: Arc<Identities>,
|
||||
|
||||
/// Receiver to receive commands from optional WebGPU server.
|
||||
#[no_trace]
|
||||
|
@ -1419,7 +1418,7 @@ impl ScriptThread {
|
|||
|
||||
node_ids: Default::default(),
|
||||
is_user_interacting: Cell::new(false),
|
||||
gpu_id_hub: Arc::new(Mutex::new(Identities::new())),
|
||||
gpu_id_hub: Arc::new(Identities::new()),
|
||||
webgpu_port: RefCell::new(None),
|
||||
inherited_secure_context: state.inherited_secure_context,
|
||||
layout_factory,
|
||||
|
@ -1582,7 +1581,7 @@ impl ScriptThread {
|
|||
CompositorEvent::MouseMoveEvent(point, node_address, pressed_mouse_buttons) => {
|
||||
self.process_mouse_move_event(
|
||||
&document,
|
||||
&window,
|
||||
window,
|
||||
point,
|
||||
node_address,
|
||||
pressed_mouse_buttons,
|
||||
|
@ -2422,35 +2421,29 @@ impl ScriptThread {
|
|||
|
||||
fn handle_msg_from_webgpu_server(&self, msg: WebGPUMsg) {
|
||||
match msg {
|
||||
WebGPUMsg::FreeAdapter(id) => self.gpu_id_hub.lock().kill_adapter_id(id),
|
||||
WebGPUMsg::FreeAdapter(id) => self.gpu_id_hub.kill_adapter_id(id),
|
||||
WebGPUMsg::FreeDevice {
|
||||
device_id,
|
||||
pipeline_id,
|
||||
} => {
|
||||
self.gpu_id_hub.lock().kill_device_id(device_id);
|
||||
self.gpu_id_hub.kill_device_id(device_id);
|
||||
let global = self.documents.borrow().find_global(pipeline_id).unwrap();
|
||||
global.remove_gpu_device(WebGPUDevice(device_id));
|
||||
},
|
||||
WebGPUMsg::FreeBuffer(id) => self.gpu_id_hub.lock().kill_buffer_id(id),
|
||||
WebGPUMsg::FreePipelineLayout(id) => self.gpu_id_hub.lock().kill_pipeline_layout_id(id),
|
||||
WebGPUMsg::FreeComputePipeline(id) => {
|
||||
self.gpu_id_hub.lock().kill_compute_pipeline_id(id)
|
||||
},
|
||||
WebGPUMsg::FreeBindGroup(id) => self.gpu_id_hub.lock().kill_bind_group_id(id),
|
||||
WebGPUMsg::FreeBindGroupLayout(id) => {
|
||||
self.gpu_id_hub.lock().kill_bind_group_layout_id(id)
|
||||
},
|
||||
WebGPUMsg::FreeBuffer(id) => self.gpu_id_hub.kill_buffer_id(id),
|
||||
WebGPUMsg::FreePipelineLayout(id) => self.gpu_id_hub.kill_pipeline_layout_id(id),
|
||||
WebGPUMsg::FreeComputePipeline(id) => self.gpu_id_hub.kill_compute_pipeline_id(id),
|
||||
WebGPUMsg::FreeBindGroup(id) => self.gpu_id_hub.kill_bind_group_id(id),
|
||||
WebGPUMsg::FreeBindGroupLayout(id) => self.gpu_id_hub.kill_bind_group_layout_id(id),
|
||||
WebGPUMsg::FreeCommandBuffer(id) => self
|
||||
.gpu_id_hub
|
||||
.lock()
|
||||
.kill_command_buffer_id(id.into_command_encoder_id()),
|
||||
WebGPUMsg::FreeSampler(id) => self.gpu_id_hub.lock().kill_sampler_id(id),
|
||||
WebGPUMsg::FreeShaderModule(id) => self.gpu_id_hub.lock().kill_shader_module_id(id),
|
||||
WebGPUMsg::FreeRenderBundle(id) => self.gpu_id_hub.lock().kill_render_bundle_id(id),
|
||||
WebGPUMsg::FreeRenderPipeline(id) => self.gpu_id_hub.lock().kill_render_pipeline_id(id),
|
||||
WebGPUMsg::FreeTexture(id) => self.gpu_id_hub.lock().kill_texture_id(id),
|
||||
WebGPUMsg::FreeTextureView(id) => self.gpu_id_hub.lock().kill_texture_view_id(id),
|
||||
WebGPUMsg::FreeComputePass(id) => self.gpu_id_hub.lock().kill_compute_pass_id(id),
|
||||
WebGPUMsg::FreeSampler(id) => self.gpu_id_hub.kill_sampler_id(id),
|
||||
WebGPUMsg::FreeShaderModule(id) => self.gpu_id_hub.kill_shader_module_id(id),
|
||||
WebGPUMsg::FreeRenderBundle(id) => self.gpu_id_hub.kill_render_bundle_id(id),
|
||||
WebGPUMsg::FreeRenderPipeline(id) => self.gpu_id_hub.kill_render_pipeline_id(id),
|
||||
WebGPUMsg::FreeTexture(id) => self.gpu_id_hub.kill_texture_id(id),
|
||||
WebGPUMsg::FreeTextureView(id) => self.gpu_id_hub.kill_texture_view_id(id),
|
||||
WebGPUMsg::Exit => *self.webgpu_port.borrow_mut() = None,
|
||||
WebGPUMsg::DeviceLost {
|
||||
pipeline_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue