aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock15
-rw-r--r--Cargo.toml4
-rw-r--r--components/constellation/constellation.rs34
-rw-r--r--components/script/dom/dedicatedworkerglobalscope.rs8
-rw-r--r--components/script/dom/globalscope.rs8
-rw-r--r--components/script/dom/gpu.rs5
-rw-r--r--components/script/dom/gpuadapter.rs18
-rw-r--r--components/script/dom/gpubindgroup.rs5
-rw-r--r--components/script/dom/gpubindgrouplayout.rs5
-rw-r--r--components/script/dom/gpubuffer.rs5
-rw-r--r--components/script/dom/gpucanvascontext.rs11
-rw-r--r--components/script/dom/gpucommandencoder.rs15
-rw-r--r--components/script/dom/gpucomputepipeline.rs10
-rw-r--r--components/script/dom/gpudevice.rs10
-rw-r--r--components/script/dom/gpupipelinelayout.rs5
-rw-r--r--components/script/dom/gpuqueue.rs1
-rw-r--r--components/script/dom/gpurenderbundleencoder.rs7
-rw-r--r--components/script/dom/gpurenderpipeline.rs10
-rw-r--r--components/script/dom/gpusampler.rs5
-rw-r--r--components/script/dom/gpushadermodule.rs5
-rw-r--r--components/script/dom/gputexture.rs10
-rw-r--r--components/script/dom/identityhub.rs173
-rw-r--r--components/script/dom/serviceworkerglobalscope.rs4
-rw-r--r--components/script/dom/window.rs4
-rw-r--r--components/script/dom/workerglobalscope.rs4
-rw-r--r--components/script/dom/workletglobalscope.rs4
-rw-r--r--components/script/script_thread.rs6
-rw-r--r--components/shared/script/script_msg.rs3
-rw-r--r--components/webgpu/Cargo.toml1
-rw-r--r--components/webgpu/ipc_messages/recv.rs5
-rw-r--r--components/webgpu/render_commands.rs2
-rw-r--r--components/webgpu/wgpu_thread.rs153
-rw-r--r--tests/wpt/webgpu/meta/webgpu/cts.https.html.ini12
33 files changed, 206 insertions, 361 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8d67e68cccd..9d26213ea98 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2358,9 +2358,9 @@ dependencies = [
[[package]]
name = "glow"
-version = "0.14.0"
+version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f865cbd94bd355b89611211e49508da98a1fce0ad755c1e8448fb96711b24528"
+checksum = "2f4a888dbe8181a7535853469c21c67ca9a1cea9460b16808fc018ea9e55d248"
dependencies = [
"js-sys",
"slotmap",
@@ -4426,7 +4426,7 @@ checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03"
[[package]]
name = "naga"
version = "22.0.0"
-source = "git+https://github.com/gfx-rs/wgpu?rev=0e352f5b3448236b6cbebcd146d0606b00cb3806#0e352f5b3448236b6cbebcd146d0606b00cb3806"
+source = "git+https://github.com/gfx-rs/wgpu?rev=9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20#9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20"
dependencies = [
"arrayvec",
"bit-set",
@@ -7876,7 +7876,6 @@ dependencies = [
"malloc_size_of",
"serde",
"servo_config",
- "smallvec",
"webrender",
"webrender_api",
"webrender_traits",
@@ -8006,7 +8005,7 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]]
name = "wgpu-core"
version = "22.0.0"
-source = "git+https://github.com/gfx-rs/wgpu?rev=0e352f5b3448236b6cbebcd146d0606b00cb3806#0e352f5b3448236b6cbebcd146d0606b00cb3806"
+source = "git+https://github.com/gfx-rs/wgpu?rev=9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20#9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20"
dependencies = [
"arrayvec",
"bit-vec",
@@ -8031,7 +8030,7 @@ dependencies = [
[[package]]
name = "wgpu-hal"
version = "22.0.0"
-source = "git+https://github.com/gfx-rs/wgpu?rev=0e352f5b3448236b6cbebcd146d0606b00cb3806#0e352f5b3448236b6cbebcd146d0606b00cb3806"
+source = "git+https://github.com/gfx-rs/wgpu?rev=9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20#9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20"
dependencies = [
"android_system_properties",
"arrayvec",
@@ -8041,7 +8040,7 @@ dependencies = [
"block",
"cfg_aliases 0.1.1",
"core-graphics-types",
- "glow 0.14.0",
+ "glow 0.14.1",
"glutin_wgl_sys",
"gpu-alloc",
"gpu-allocator",
@@ -8073,7 +8072,7 @@ dependencies = [
[[package]]
name = "wgpu-types"
version = "22.0.0"
-source = "git+https://github.com/gfx-rs/wgpu?rev=0e352f5b3448236b6cbebcd146d0606b00cb3806#0e352f5b3448236b6cbebcd146d0606b00cb3806"
+source = "git+https://github.com/gfx-rs/wgpu?rev=9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20#9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20"
dependencies = [
"bitflags 2.6.0",
"js-sys",
diff --git a/Cargo.toml b/Cargo.toml
index bbac1d79f7b..0c2e48dfac4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -143,8 +143,8 @@ webpki-roots = "0.25"
webrender = { git = "https://github.com/servo/webrender", branch = "0.65", features = ["capture"] }
webrender_api = { git = "https://github.com/servo/webrender", branch = "0.65" }
webrender_traits = { path = "components/shared/webrender" }
-wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "0e352f5b3448236b6cbebcd146d0606b00cb3806" }
-wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "0e352f5b3448236b6cbebcd146d0606b00cb3806" }
+wgpu-core = { git = "https://github.com/gfx-rs/wgpu", rev = "9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20" }
+wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20" }
windows-sys = "0.59"
xi-unicode = "0.3.0"
xml5ever = "0.20"
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index 918e3738195..eb5876fb802 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -2087,22 +2087,24 @@ where
Entry::Occupied(o) => Some(o.get().clone()),
};
match request {
- FromScriptMsg::RequestAdapter(response_sender, options, ids) => match webgpu_chan {
- None => {
- if let Err(e) = response_sender.send(WebGPUResponse::None) {
- warn!("Failed to send request adapter message: {}", e)
- }
- },
- Some(webgpu_chan) => {
- let adapter_request = WebGPURequest::RequestAdapter {
- sender: response_sender,
- options,
- ids,
- };
- if webgpu_chan.0.send(adapter_request).is_err() {
- warn!("Failed to send request adapter message on WebGPU channel");
- }
- },
+ FromScriptMsg::RequestAdapter(response_sender, options, adapter_id) => {
+ match webgpu_chan {
+ None => {
+ if let Err(e) = response_sender.send(WebGPUResponse::None) {
+ warn!("Failed to send request adapter message: {}", e)
+ }
+ },
+ Some(webgpu_chan) => {
+ let adapter_request = WebGPURequest::RequestAdapter {
+ sender: response_sender,
+ options,
+ adapter_id,
+ };
+ if webgpu_chan.0.send(adapter_request).is_err() {
+ warn!("Failed to send request adapter message on WebGPU channel");
+ }
+ },
+ }
},
FromScriptMsg::GetWebGPUChan(response_sender) => {
if response_sender.send(webgpu_chan).is_err() {
diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs
index a7e62b0f570..c200e02abf5 100644
--- a/components/script/dom/dedicatedworkerglobalscope.rs
+++ b/components/script/dom/dedicatedworkerglobalscope.rs
@@ -47,7 +47,7 @@ use crate::dom::errorevent::ErrorEvent;
use crate::dom::event::{Event, EventBubbles, EventCancelable, EventStatus};
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
-use crate::dom::identityhub::Identities;
+use crate::dom::identityhub::IdentityHub;
use crate::dom::messageevent::MessageEvent;
use crate::dom::worker::{TrustedWorkerAddress, Worker};
use crate::dom::workerglobalscope::WorkerGlobalScope;
@@ -253,7 +253,7 @@ impl DedicatedWorkerGlobalScope {
closing: Arc<AtomicBool>,
image_cache: Arc<dyn ImageCache>,
browsing_context: Option<BrowsingContextId>,
- gpu_id_hub: Arc<Identities>,
+ gpu_id_hub: Arc<IdentityHub>,
control_receiver: Receiver<DedicatedWorkerControlMsg>,
) -> DedicatedWorkerGlobalScope {
DedicatedWorkerGlobalScope {
@@ -291,7 +291,7 @@ impl DedicatedWorkerGlobalScope {
closing: Arc<AtomicBool>,
image_cache: Arc<dyn ImageCache>,
browsing_context: Option<BrowsingContextId>,
- gpu_id_hub: Arc<Identities>,
+ gpu_id_hub: Arc<IdentityHub>,
control_receiver: Receiver<DedicatedWorkerControlMsg>,
) -> DomRoot<DedicatedWorkerGlobalScope> {
let cx = runtime.cx();
@@ -330,7 +330,7 @@ impl DedicatedWorkerGlobalScope {
closing: Arc<AtomicBool>,
image_cache: Arc<dyn ImageCache>,
browsing_context: Option<BrowsingContextId>,
- gpu_id_hub: Arc<Identities>,
+ gpu_id_hub: Arc<IdentityHub>,
control_receiver: Receiver<DedicatedWorkerControlMsg>,
context_sender: Sender<ContextForRequestInterrupt>,
can_gc: CanGc,
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index cd5de7063ce..52afc63ba47 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -102,7 +102,7 @@ use crate::dom::gamepad::{contains_user_gesture, Gamepad};
use crate::dom::gamepadevent::GamepadEventType;
use crate::dom::gpudevice::GPUDevice;
use crate::dom::htmlscriptelement::{ScriptId, SourceCode};
-use crate::dom::identityhub::Identities;
+use crate::dom::identityhub::IdentityHub;
use crate::dom::imagebitmap::ImageBitmap;
use crate::dom::messageevent::MessageEvent;
use crate::dom::messageport::MessagePort;
@@ -325,7 +325,7 @@ pub struct GlobalScope {
/// Identity Manager for WebGPU resources
#[ignore_malloc_size_of = "defined in wgpu"]
#[no_trace]
- gpu_id_hub: Arc<Identities>,
+ gpu_id_hub: Arc<IdentityHub>,
/// WebGPU devices
gpu_devices: DomRefCell<HashMapTracedValues<WebGPUDevice, WeakRef<GPUDevice>>>,
@@ -768,7 +768,7 @@ impl GlobalScope {
microtask_queue: Rc<MicrotaskQueue>,
is_headless: bool,
user_agent: Cow<'static, str>,
- gpu_id_hub: Arc<Identities>,
+ gpu_id_hub: Arc<IdentityHub>,
inherited_secure_context: Option<bool>,
) -> Self {
Self {
@@ -3154,7 +3154,7 @@ impl GlobalScope {
None
}
- pub fn wgpu_id_hub(&self) -> Arc<Identities> {
+ pub fn wgpu_id_hub(&self) -> Arc<IdentityHub> {
self.gpu_id_hub.clone()
}
diff --git a/components/script/dom/gpu.rs b/components/script/dom/gpu.rs
index c485cbdcc7b..27b2c8908e9 100644
--- a/components/script/dom/gpu.rs
+++ b/components/script/dom/gpu.rs
@@ -111,7 +111,7 @@ impl GPUMethods for GPU {
Some(GPUPowerPreference::High_performance) => PowerPreference::HighPerformance,
None => PowerPreference::default(),
};
- let ids = global.wgpu_id_hub().create_adapter_ids();
+ let ids = global.wgpu_id_hub().create_adapter_id();
let script_to_constellation_chan = global.script_to_constellation_chan();
if script_to_constellation_chan
@@ -147,8 +147,7 @@ impl AsyncWGPUListener for GPU {
adapter.channel,
DOMString::from(format!(
"{} ({:?})",
- adapter.adapter_info.name,
- adapter.adapter_id.0.backend()
+ adapter.adapter_info.name, adapter.adapter_id.0
)),
Heap::default(),
adapter.features,
diff --git a/components/script/dom/gpuadapter.rs b/components/script/dom/gpuadapter.rs
index 14743dad91f..ff43baab82c 100644
--- a/components/script/dom/gpuadapter.rs
+++ b/components/script/dom/gpuadapter.rs
@@ -140,14 +140,8 @@ impl GPUAdapterMethods for GPUAdapter {
label: Some(descriptor.parent.label.to_string()),
memory_hints: MemoryHints::MemoryUsage,
};
- let device_id = self
- .global()
- .wgpu_id_hub()
- .create_device_id(self.adapter.0.backend());
- let queue_id = self
- .global()
- .wgpu_id_hub()
- .create_queue_id(self.adapter.0.backend());
+ let device_id = self.global().wgpu_id_hub().create_device_id();
+ let queue_id = self.global().wgpu_id_hub().create_queue_id();
let pipeline_id = self.global().pipeline_id();
if self
.channel
@@ -222,11 +216,9 @@ impl AsyncWGPUListener for GPUAdapter {
RequestDeviceError::UnsupportedFeature(f).to_string(),
))
},
- WebGPUResponse::Device((
- _,
- _,
- Err(RequestDeviceError::LimitsExceeded(_) | RequestDeviceError::InvalidAdapter),
- )) => promise.reject_error(Error::Operation),
+ WebGPUResponse::Device((_, _, Err(RequestDeviceError::LimitsExceeded(_)))) => {
+ promise.reject_error(Error::Operation)
+ },
WebGPUResponse::Device((device_id, queue_id, Err(e))) => {
let device = GPUDevice::new(
&self.global(),
diff --git a/components/script/dom/gpubindgroup.rs b/components/script/dom/gpubindgroup.rs
index 9c7e248853a..964959e40c0 100644
--- a/components/script/dom/gpubindgroup.rs
+++ b/components/script/dom/gpubindgroup.rs
@@ -90,10 +90,7 @@ impl GPUBindGroup {
entries: Cow::Owned(entries),
};
- let bind_group_id = device
- .global()
- .wgpu_id_hub()
- .create_bind_group_id(device.id().0.backend());
+ let bind_group_id = device.global().wgpu_id_hub().create_bind_group_id();
device
.channel()
.0
diff --git a/components/script/dom/gpubindgrouplayout.rs b/components/script/dom/gpubindgrouplayout.rs
index 18a351079fb..4c2d2413a7a 100644
--- a/components/script/dom/gpubindgrouplayout.rs
+++ b/components/script/dom/gpubindgrouplayout.rs
@@ -89,10 +89,7 @@ impl GPUBindGroupLayout {
},
};
- let bind_group_layout_id = device
- .global()
- .wgpu_id_hub()
- .create_bind_group_layout_id(device.id().0.backend());
+ let bind_group_layout_id = device.global().wgpu_id_hub().create_bind_group_layout_id();
device
.channel()
.0
diff --git a/components/script/dom/gpubuffer.rs b/components/script/dom/gpubuffer.rs
index d90a37b559d..efcb08558b6 100644
--- a/components/script/dom/gpubuffer.rs
+++ b/components/script/dom/gpubuffer.rs
@@ -142,10 +142,7 @@ impl GPUBuffer {
usage: wgt::BufferUsages::from_bits_retain(descriptor.usage),
mapped_at_creation: descriptor.mappedAtCreation,
};
- let id = device
- .global()
- .wgpu_id_hub()
- .create_buffer_id(device.id().0.backend());
+ let id = device.global().wgpu_id_hub().create_buffer_id();
device
.channel()
diff --git a/components/script/dom/gpucanvascontext.rs b/components/script/dom/gpucanvascontext.rs
index fe16b824504..097b89880d9 100644
--- a/components/script/dom/gpucanvascontext.rs
+++ b/components/script/dom/gpucanvascontext.rs
@@ -145,10 +145,7 @@ impl GPUCanvasContext {
pub fn send_swap_chain_present(&self) {
let texture_id = self.texture_id().unwrap().0;
- let encoder_id = self
- .global()
- .wgpu_id_hub()
- .create_command_encoder_id(texture_id.backend());
+ let encoder_id = self.global().wgpu_id_hub().create_command_encoder_id();
if let Err(e) = self.channel.0.send(WebGPURequest::SwapChainPresent {
context_id: self.context_id,
texture_id,
@@ -258,11 +255,7 @@ impl GPUCanvasContextMethods for GPUCanvasContext {
let mut buffer_ids = ArrayVec::<id::BufferId, PRESENTATION_BUFFER_COUNT>::new();
for _ in 0..PRESENTATION_BUFFER_COUNT {
- buffer_ids.push(
- self.global()
- .wgpu_id_hub()
- .create_buffer_id(configuration.device.id().0.backend()),
- );
+ buffer_ids.push(self.global().wgpu_id_hub().create_buffer_id());
}
self.channel
diff --git a/components/script/dom/gpucommandencoder.rs b/components/script/dom/gpucommandencoder.rs
index 16754b721df..8b62cbb8030 100644
--- a/components/script/dom/gpucommandencoder.rs
+++ b/components/script/dom/gpucommandencoder.rs
@@ -85,10 +85,7 @@ impl GPUCommandEncoder {
device: &GPUDevice,
descriptor: &GPUCommandEncoderDescriptor,
) -> DomRoot<GPUCommandEncoder> {
- let command_encoder_id = device
- .global()
- .wgpu_id_hub()
- .create_command_encoder_id(device.id().0.backend());
+ let command_encoder_id = device.global().wgpu_id_hub().create_command_encoder_id();
device
.channel()
.0
@@ -129,10 +126,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
&self,
descriptor: &GPUComputePassDescriptor,
) -> DomRoot<GPUComputePassEncoder> {
- let compute_pass_id = self
- .global()
- .wgpu_id_hub()
- .create_compute_pass_id(self.device.id().0.backend());
+ let compute_pass_id = self.global().wgpu_id_hub().create_compute_pass_id();
if let Err(e) = self.channel.0.send(WebGPURequest::BeginComputePass {
command_encoder_id: self.id().0,
@@ -197,10 +191,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
}))
})
.collect::<Fallible<Vec<_>>>()?;
- let render_pass_id = self
- .global()
- .wgpu_id_hub()
- .create_render_pass_id(self.device.id().0.backend());
+ let render_pass_id = self.global().wgpu_id_hub().create_render_pass_id();
if let Err(e) = self.channel.0.send(WebGPURequest::BeginRenderPass {
command_encoder_id: self.id().0,
diff --git a/components/script/dom/gpucomputepipeline.rs b/components/script/dom/gpucomputepipeline.rs
index 6c69c07900a..6f64e59ab5d 100644
--- a/components/script/dom/gpucomputepipeline.rs
+++ b/components/script/dom/gpucomputepipeline.rs
@@ -74,10 +74,7 @@ impl GPUComputePipeline {
descriptor: &GPUComputePipelineDescriptor,
async_sender: Option<IpcSender<WebGPUResponse>>,
) -> WebGPUComputePipeline {
- let compute_pipeline_id = device
- .global()
- .wgpu_id_hub()
- .create_compute_pipeline_id(device.id().0.backend());
+ let compute_pipeline_id = device.global().wgpu_id_hub().create_compute_pipeline_id();
let (layout, implicit_ids, _) = device.get_pipeline_layout_data(&descriptor.parent.layout);
@@ -117,10 +114,7 @@ impl GPUComputePipelineMethods for GPUComputePipeline {
/// <https://gpuweb.github.io/gpuweb/#dom-gpupipelinebase-getbindgrouplayout>
fn GetBindGroupLayout(&self, index: u32) -> Fallible<DomRoot<GPUBindGroupLayout>> {
- let id = self
- .global()
- .wgpu_id_hub()
- .create_bind_group_layout_id(self.compute_pipeline.0.backend());
+ let id = self.global().wgpu_id_hub().create_bind_group_layout_id();
if let Err(e) = self
.channel
diff --git a/components/script/dom/gpudevice.rs b/components/script/dom/gpudevice.rs
index ddf71100d61..c075894f374 100644
--- a/components/script/dom/gpudevice.rs
+++ b/components/script/dom/gpudevice.rs
@@ -216,18 +216,12 @@ impl GPUDevice {
if let GPUPipelineLayoutOrGPUAutoLayoutMode::GPUPipelineLayout(ref layout) = layout {
(Some(layout.id().0), None, layout.bind_group_layouts())
} else {
- let layout_id = self
- .global()
- .wgpu_id_hub()
- .create_pipeline_layout_id(self.device.0.backend());
+ let layout_id = self.global().wgpu_id_hub().create_pipeline_layout_id();
let max_bind_grps = self.limits.MaxBindGroups();
let mut bgls = Vec::with_capacity(max_bind_grps as usize);
let mut bgl_ids = Vec::with_capacity(max_bind_grps as usize);
for _ in 0..max_bind_grps {
- let bgl = self
- .global()
- .wgpu_id_hub()
- .create_bind_group_layout_id(self.device.0.backend());
+ let bgl = self.global().wgpu_id_hub().create_bind_group_layout_id();
bgls.push(webgpu::WebGPUBindGroupLayout(bgl));
bgl_ids.push(bgl);
}
diff --git a/components/script/dom/gpupipelinelayout.rs b/components/script/dom/gpupipelinelayout.rs
index e851458e637..c97cee67b5b 100644
--- a/components/script/dom/gpupipelinelayout.rs
+++ b/components/script/dom/gpupipelinelayout.rs
@@ -92,10 +92,7 @@ impl GPUPipelineLayout {
push_constant_ranges: Cow::Owned(vec![]),
};
- let pipeline_layout_id = device
- .global()
- .wgpu_id_hub()
- .create_pipeline_layout_id(device.id().0.backend());
+ let pipeline_layout_id = device.global().wgpu_id_hub().create_pipeline_layout_id();
device
.channel()
.0
diff --git a/components/script/dom/gpuqueue.rs b/components/script/dom/gpuqueue.rs
index a82e68dcf8f..8accfdbdce7 100644
--- a/components/script/dom/gpuqueue.rs
+++ b/components/script/dom/gpuqueue.rs
@@ -197,7 +197,6 @@ impl GPUQueueMethods for GPUQueue {
.send(WebGPURequest::QueueOnSubmittedWorkDone {
sender,
queue_id: self.queue.0,
- device_id: self.device.borrow().as_ref().unwrap().id().0,
})
{
warn!("QueueOnSubmittedWorkDone failed with {e}")
diff --git a/components/script/dom/gpurenderbundleencoder.rs b/components/script/dom/gpurenderbundleencoder.rs
index bc05a678f17..9a494a1d628 100644
--- a/components/script/dom/gpurenderbundleencoder.rs
+++ b/components/script/dom/gpurenderbundleencoder.rs
@@ -143,7 +143,7 @@ impl GPURenderBundleEncoderMethods for GPURenderBundleEncoder {
wgpu_bundle::wgpu_render_bundle_set_bind_group(
encoder,
index,
- bind_group.id().0,
+ Some(bind_group.id().0),
dynamic_offsets.as_ptr(),
dynamic_offsets.len(),
)
@@ -255,10 +255,7 @@ impl GPURenderBundleEncoderMethods for GPURenderBundleEncoder {
label: (&descriptor.parent).into(),
};
let encoder = self.render_bundle_encoder.borrow_mut().take().unwrap();
- let render_bundle_id = self
- .global()
- .wgpu_id_hub()
- .create_render_bundle_id(self.device.id().0.backend());
+ let render_bundle_id = self.global().wgpu_id_hub().create_render_bundle_id();
self.channel
.0
diff --git a/components/script/dom/gpurenderpipeline.rs b/components/script/dom/gpurenderpipeline.rs
index c0e9506835b..dde7cc8ff38 100644
--- a/components/script/dom/gpurenderpipeline.rs
+++ b/components/script/dom/gpurenderpipeline.rs
@@ -74,10 +74,7 @@ impl GPURenderPipeline {
descriptor: RenderPipelineDescriptor<'static>,
async_sender: Option<IpcSender<WebGPUResponse>>,
) -> Fallible<WebGPURenderPipeline> {
- let render_pipeline_id = device
- .global()
- .wgpu_id_hub()
- .create_render_pipeline_id(device.id().0.backend());
+ let render_pipeline_id = device.global().wgpu_id_hub().create_render_pipeline_id();
device
.channel()
@@ -108,10 +105,7 @@ impl GPURenderPipelineMethods for GPURenderPipeline {
/// <https://gpuweb.github.io/gpuweb/#dom-gpupipelinebase-getbindgrouplayout>
fn GetBindGroupLayout(&self, index: u32) -> Fallible<DomRoot<GPUBindGroupLayout>> {
- let id = self
- .global()
- .wgpu_id_hub()
- .create_bind_group_layout_id(self.render_pipeline.0.backend());
+ let id = self.global().wgpu_id_hub().create_bind_group_layout_id();
if let Err(e) = self
.channel
diff --git a/components/script/dom/gpusampler.rs b/components/script/dom/gpusampler.rs
index baf987aa467..e79ea6af591 100644
--- a/components/script/dom/gpusampler.rs
+++ b/components/script/dom/gpusampler.rs
@@ -76,10 +76,7 @@ impl GPUSampler {
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler>
pub fn create(device: &GPUDevice, descriptor: &GPUSamplerDescriptor) -> DomRoot<GPUSampler> {
- let sampler_id = device
- .global()
- .wgpu_id_hub()
- .create_sampler_id(device.id().0.backend());
+ let sampler_id = device.global().wgpu_id_hub().create_sampler_id();
let compare_enable = descriptor.compare.is_some();
let desc = SamplerDescriptor {
label: (&descriptor.parent).into(),
diff --git a/components/script/dom/gpushadermodule.rs b/components/script/dom/gpushadermodule.rs
index f245765b36a..a8b62fd96ea 100644
--- a/components/script/dom/gpushadermodule.rs
+++ b/components/script/dom/gpushadermodule.rs
@@ -82,10 +82,7 @@ impl GPUShaderModule {
descriptor: RootedTraceableBox<GPUShaderModuleDescriptor>,
comp: InRealm,
) -> DomRoot<GPUShaderModule> {
- let program_id = device
- .global()
- .wgpu_id_hub()
- .create_shader_module_id(device.id().0.backend());
+ let program_id = device.global().wgpu_id_hub().create_shader_module_id();
let promise = Promise::new_in_current_realm(comp);
let shader_module = GPUShaderModule::new(
&device.global(),
diff --git a/components/script/dom/gputexture.rs b/components/script/dom/gputexture.rs
index df2e5ca83c8..fc0fb0e8f53 100644
--- a/components/script/dom/gputexture.rs
+++ b/components/script/dom/gputexture.rs
@@ -149,10 +149,7 @@ impl GPUTexture {
.collect::<Fallible<_>>()?,
};
- let texture_id = device
- .global()
- .wgpu_id_hub()
- .create_texture_id(device.id().0.backend());
+ let texture_id = device.global().wgpu_id_hub().create_texture_id();
device
.channel()
@@ -228,10 +225,7 @@ impl GPUTextureMethods for GPUTexture {
None
};
- let texture_view_id = self
- .global()
- .wgpu_id_hub()
- .create_texture_view_id(self.device.id().0.backend());
+ let texture_view_id = self.global().wgpu_id_hub().create_texture_view_id();
self.channel
.0
diff --git a/components/script/dom/identityhub.rs b/components/script/dom/identityhub.rs
index 63aca9935c9..cb129dc5ca2 100644
--- a/components/script/dom/identityhub.rs
+++ b/components/script/dom/identityhub.rs
@@ -2,7 +2,6 @@
* 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/. */
-use smallvec::SmallVec;
use webgpu::identity::{ComputePass, ComputePassId, RenderPass, RenderPassId};
use webgpu::wgc::id::markers::{
Adapter, BindGroup, BindGroupLayout, Buffer, CommandEncoder, ComputePipeline, Device,
@@ -15,7 +14,6 @@ use webgpu::wgc::id::{
ShaderModuleId, TextureId, TextureViewId,
};
use webgpu::wgc::identity::IdentityManager;
-use webgpu::wgt::Backend;
#[derive(Debug)]
pub struct IdentityHub {
@@ -39,7 +37,7 @@ pub struct IdentityHub {
}
impl IdentityHub {
- fn new() -> Self {
+ pub fn new() -> Self {
IdentityHub {
adapters: IdentityManager::new(),
devices: IdentityManager::new(),
@@ -62,205 +60,140 @@ impl IdentityHub {
}
}
-#[derive(Debug)]
-pub struct Identities {
- #[cfg(any(target_os = "linux", target_os = "windows"))]
- vk_hub: IdentityHub,
- #[cfg(target_os = "windows")]
- dx12_hub: IdentityHub,
- #[cfg(any(target_os = "ios", target_os = "macos"))]
- metal_hub: IdentityHub,
- #[cfg(any(target_os = "linux", target_os = "windows"))]
- gl_hub: IdentityHub,
- dummy_hub: IdentityHub,
-}
-
-impl Identities {
- pub fn new() -> Self {
- Identities {
- #[cfg(any(target_os = "linux", target_os = "windows"))]
- vk_hub: IdentityHub::new(),
- #[cfg(target_os = "windows")]
- dx12_hub: IdentityHub::new(),
- #[cfg(any(target_os = "ios", target_os = "macos"))]
- metal_hub: IdentityHub::new(),
- #[cfg(any(target_os = "linux", target_os = "windows"))]
- gl_hub: IdentityHub::new(),
- dummy_hub: IdentityHub::new(),
- }
- }
-
- fn select(&self, backend: Backend) -> &IdentityHub {
- match backend {
- #[cfg(any(target_os = "linux", target_os = "windows"))]
- Backend::Vulkan => &self.vk_hub,
- #[cfg(target_os = "windows")]
- Backend::Dx12 => &self.dx12_hub,
- #[cfg(any(target_os = "ios", target_os = "macos"))]
- Backend::Metal => &self.metal_hub,
- #[cfg(any(target_os = "linux", target_os = "windows"))]
- Backend::Gl => &self.gl_hub,
- _ => &self.dummy_hub,
- }
- }
-
- fn hubs(&self) -> Vec<(&IdentityHub, Backend)> {
- vec![
- #[cfg(any(target_os = "linux", target_os = "windows"))]
- (&self.vk_hub, Backend::Vulkan),
- #[cfg(target_os = "windows")]
- (&self.dx12_hub, Backend::Dx12),
- #[cfg(any(target_os = "ios", target_os = "macos"))]
- (&self.metal_hub, Backend::Metal),
- #[cfg(any(target_os = "linux", target_os = "windows"))]
- (&self.gl_hub, Backend::Gl),
- (&self.dummy_hub, Backend::Empty),
- ]
- }
-
- pub fn create_device_id(&self, backend: Backend) -> DeviceId {
- self.select(backend).devices.process(backend)
+impl IdentityHub {
+ pub fn create_device_id(&self) -> DeviceId {
+ self.devices.process()
}
pub fn free_device_id(&self, id: DeviceId) {
- self.select(id.backend()).devices.free(id);
+ self.devices.free(id);
}
- pub fn create_queue_id(&self, backend: Backend) -> QueueId {
- self.select(backend).queues.process(backend)
+ pub fn create_queue_id(&self) -> QueueId {
+ self.queues.process()
}
pub fn free_queue_id(&self, id: QueueId) {
- self.select(id.backend()).queues.free(id);
+ self.queues.free(id);
}
- 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));
- }
- ids
+ pub fn create_adapter_id(&self) -> AdapterId {
+ self.adapters.process()
}
pub fn free_adapter_id(&self, id: AdapterId) {
- self.select(id.backend()).adapters.free(id);
+ self.adapters.free(id);
}
- pub fn create_buffer_id(&self, backend: Backend) -> BufferId {
- self.select(backend).buffers.process(backend)
+ pub fn create_buffer_id(&self) -> BufferId {
+ self.buffers.process()
}
pub fn free_buffer_id(&self, id: BufferId) {
- self.select(id.backend()).buffers.free(id);
+ self.buffers.free(id);
}
- pub fn create_bind_group_id(&self, backend: Backend) -> BindGroupId {
- self.select(backend).bind_groups.process(backend)
+ pub fn create_bind_group_id(&self) -> BindGroupId {
+ self.bind_groups.process()
}
pub fn free_bind_group_id(&self, id: BindGroupId) {
- self.select(id.backend()).bind_groups.free(id);
+ self.bind_groups.free(id);
}
- pub fn create_bind_group_layout_id(&self, backend: Backend) -> BindGroupLayoutId {
- self.select(backend).bind_group_layouts.process(backend)
+ pub fn create_bind_group_layout_id(&self) -> BindGroupLayoutId {
+ self.bind_group_layouts.process()
}
pub fn free_bind_group_layout_id(&self, id: BindGroupLayoutId) {
- self.select(id.backend()).bind_group_layouts.free(id);
+ self.bind_group_layouts.free(id);
}
- pub fn create_compute_pipeline_id(&self, backend: Backend) -> ComputePipelineId {
- self.select(backend).compute_pipelines.process(backend)
+ pub fn create_compute_pipeline_id(&self) -> ComputePipelineId {
+ self.compute_pipelines.process()
}
pub fn free_compute_pipeline_id(&self, id: ComputePipelineId) {
- self.select(id.backend()).compute_pipelines.free(id);
+ self.compute_pipelines.free(id);
}
- pub fn create_pipeline_layout_id(&self, backend: Backend) -> PipelineLayoutId {
- self.select(backend).pipeline_layouts.process(backend)
+ pub fn create_pipeline_layout_id(&self) -> PipelineLayoutId {
+ self.pipeline_layouts.process()
}
pub fn free_pipeline_layout_id(&self, id: PipelineLayoutId) {
- self.select(id.backend()).pipeline_layouts.free(id);
+ self.pipeline_layouts.free(id);
}
- pub fn create_shader_module_id(&self, backend: Backend) -> ShaderModuleId {
- self.select(backend).shader_modules.process(backend)
+ pub fn create_shader_module_id(&self) -> ShaderModuleId {
+ self.shader_modules.process()
}
pub fn free_shader_module_id(&self, id: ShaderModuleId) {
- self.select(id.backend()).shader_modules.free(id);
+ self.shader_modules.free(id);
}
- pub fn create_command_encoder_id(&self, backend: Backend) -> CommandEncoderId {
- self.select(backend).command_encoders.process(backend)
+ pub fn create_command_encoder_id(&self) -> CommandEncoderId {
+ self.command_encoders.process()
}
pub fn free_command_buffer_id(&self, id: CommandEncoderId) {
- self.select(id.backend()).command_encoders.free(id);
+ self.command_encoders.free(id);
}
- pub fn create_sampler_id(&self, backend: Backend) -> SamplerId {
- self.select(backend).samplers.process(backend)
+ pub fn create_sampler_id(&self) -> SamplerId {
+ self.samplers.process()
}
pub fn free_sampler_id(&self, id: SamplerId) {
- self.select(id.backend()).samplers.free(id);
+ self.samplers.free(id);
}
- pub fn create_render_pipeline_id(&self, backend: Backend) -> RenderPipelineId {
- self.select(backend).render_pipelines.process(backend)
+ pub fn create_render_pipeline_id(&self) -> RenderPipelineId {
+ self.render_pipelines.process()
}
pub fn free_render_pipeline_id(&self, id: RenderPipelineId) {
- self.select(id.backend()).render_pipelines.free(id);
+ self.render_pipelines.free(id);
}
- pub fn create_texture_id(&self, backend: Backend) -> TextureId {
- self.select(backend).textures.process(backend)
+ pub fn create_texture_id(&self) -> TextureId {
+ self.textures.process()
}
pub fn free_texture_id(&self, id: TextureId) {
- self.select(id.backend()).textures.free(id);
+ self.textures.free(id);
}
- pub fn create_texture_view_id(&self, backend: Backend) -> TextureViewId {
- self.select(backend).texture_views.process(backend)
+ pub fn create_texture_view_id(&self) -> TextureViewId {
+ self.texture_views.process()
}
pub fn free_texture_view_id(&self, id: TextureViewId) {
- self.select(id.backend()).texture_views.free(id);
+ self.texture_views.free(id);
}
- pub fn create_render_bundle_id(&self, backend: Backend) -> RenderBundleId {
- self.select(backend).render_bundles.process(backend)
+ pub fn create_render_bundle_id(&self) -> RenderBundleId {
+ self.render_bundles.process()
}
pub fn free_render_bundle_id(&self, id: RenderBundleId) {
- self.select(id.backend()).render_bundles.free(id);
+ self.render_bundles.free(id);
}
- pub fn create_compute_pass_id(&self, backend: Backend) -> ComputePassId {
- self.select(backend).compute_passes.process(backend)
+ pub fn create_compute_pass_id(&self) -> ComputePassId {
+ self.compute_passes.process()
}
pub fn free_compute_pass_id(&self, id: ComputePassId) {
- self.select(id.backend()).compute_passes.free(id);
+ self.compute_passes.free(id);
}
- pub fn create_render_pass_id(&self, backend: Backend) -> RenderPassId {
- self.select(backend).render_passes.process(backend)
+ pub fn create_render_pass_id(&self) -> RenderPassId {
+ self.render_passes.process()
}
pub fn free_render_pass_id(&self, id: RenderPassId) {
- self.select(id.backend()).render_passes.free(id);
- }
-}
-
-impl Default for Identities {
- fn default() -> Self {
- Self::new()
+ self.render_passes.free(id);
}
}
diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs
index 45c667a1e6f..fb4c351444a 100644
--- a/components/script/dom/serviceworkerglobalscope.rs
+++ b/components/script/dom/serviceworkerglobalscope.rs
@@ -39,7 +39,7 @@ use crate::dom::eventtarget::EventTarget;
use crate::dom::extendableevent::ExtendableEvent;
use crate::dom::extendablemessageevent::ExtendableMessageEvent;
use crate::dom::globalscope::GlobalScope;
-use crate::dom::identityhub::Identities;
+use crate::dom::identityhub::IdentityHub;
use crate::dom::worker::TrustedWorkerAddress;
use crate::dom::workerglobalscope::WorkerGlobalScope;
use crate::fetch::load_whole_resource;
@@ -241,7 +241,7 @@ impl ServiceWorkerGlobalScope {
runtime,
from_devtools_receiver,
closing,
- Arc::new(Identities::new()),
+ Arc::new(IdentityHub::new()),
),
task_queue: TaskQueue::new(receiver, own_sender.clone()),
own_sender,
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 2c71a2c9fc6..80267002f15 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -123,7 +123,7 @@ use crate::dom::hashchangeevent::HashChangeEvent;
use crate::dom::history::History;
use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection};
use crate::dom::htmliframeelement::HTMLIFrameElement;
-use crate::dom::identityhub::Identities;
+use crate::dom::identityhub::IdentityHub;
use crate::dom::location::Location;
use crate::dom::mediaquerylist::{MediaQueryList, MediaQueryListMatchState};
use crate::dom::mediaquerylistevent::MediaQueryListEvent;
@@ -2558,7 +2558,7 @@ impl Window {
replace_surrogates: bool,
user_agent: Cow<'static, str>,
player_context: WindowGLContext,
- gpu_id_hub: Arc<Identities>,
+ gpu_id_hub: Arc<IdentityHub>,
inherited_secure_context: Option<bool>,
) -> DomRoot<Self> {
let error_reporter = CSSErrorReporter {
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index f45ac219284..c31fc9d2ab0 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -45,7 +45,7 @@ use crate::dom::bindings::trace::RootedTraceableBox;
use crate::dom::crypto::Crypto;
use crate::dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
use crate::dom::globalscope::GlobalScope;
-use crate::dom::identityhub::Identities;
+use crate::dom::identityhub::IdentityHub;
use crate::dom::performance::Performance;
use crate::dom::promise::Promise;
use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
@@ -140,7 +140,7 @@ impl WorkerGlobalScope {
runtime: Runtime,
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
closing: Arc<AtomicBool>,
- gpu_id_hub: Arc<Identities>,
+ gpu_id_hub: Arc<IdentityHub>,
) -> Self {
// Install a pipeline-namespace in the current thread.
PipelineNamespace::auto_install();
diff --git a/components/script/dom/workletglobalscope.rs b/components/script/dom/workletglobalscope.rs
index 0c781a1e2d0..cca5ecb3f1b 100644
--- a/components/script/dom/workletglobalscope.rs
+++ b/components/script/dom/workletglobalscope.rs
@@ -22,7 +22,7 @@ use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::root::DomRoot;
use crate::dom::globalscope::GlobalScope;
-use crate::dom::identityhub::Identities;
+use crate::dom::identityhub::IdentityHub;
use crate::dom::paintworkletglobalscope::{PaintWorkletGlobalScope, PaintWorkletTask};
use crate::dom::testworkletglobalscope::{TestWorkletGlobalScope, TestWorkletTask};
use crate::dom::worklet::WorkletExecutor;
@@ -164,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<Identities>,
+ pub gpu_id_hub: Arc<IdentityHub>,
/// Is considered secure
pub inherited_secure_context: Option<bool>,
}
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index d6228c02f85..6ed36d6b8b5 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -127,7 +127,7 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlanchorelement::HTMLAnchorElement;
use crate::dom::htmliframeelement::HTMLIFrameElement;
-use crate::dom::identityhub::Identities;
+use crate::dom::identityhub::IdentityHub;
use crate::dom::mutationobserver::MutationObserver;
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
use crate::dom::performanceentry::PerformanceEntry;
@@ -718,7 +718,7 @@ pub struct ScriptThread {
/// Identity manager for WebGPU resources
#[no_trace]
- gpu_id_hub: Arc<Identities>,
+ gpu_id_hub: Arc<IdentityHub>,
/// Receiver to receive commands from optional WebGPU server.
#[no_trace]
@@ -1417,7 +1417,7 @@ impl ScriptThread {
node_ids: Default::default(),
is_user_interacting: Cell::new(false),
- gpu_id_hub: Arc::new(Identities::new()),
+ gpu_id_hub: Arc::new(IdentityHub::new()),
webgpu_port: RefCell::new(None),
inherited_secure_context: state.inherited_secure_context,
layout_factory,
diff --git a/components/shared/script/script_msg.rs b/components/shared/script/script_msg.rs
index 6355f13754a..ee8e8da1386 100644
--- a/components/shared/script/script_msg.rs
+++ b/components/shared/script/script_msg.rs
@@ -22,7 +22,6 @@ use net_traits::storage_thread::StorageType;
use net_traits::CoreResourceMsg;
use serde::{Deserialize, Serialize};
use servo_url::{ImmutableOrigin, ServoUrl};
-use smallvec::SmallVec;
use style_traits::CSSPixel;
use webgpu::{wgc, WebGPU, WebGPUResponse};
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
@@ -259,7 +258,7 @@ pub enum ScriptMsg {
RequestAdapter(
IpcSender<WebGPUResponse>,
wgc::instance::RequestAdapterOptions,
- SmallVec<[wgc::id::AdapterId; 4]>,
+ wgc::id::AdapterId,
),
/// Get WebGPU channel
GetWebGPUChan(IpcSender<Option<WebGPU>>),
diff --git a/components/webgpu/Cargo.toml b/components/webgpu/Cargo.toml
index 2e72d7b5105..f3a20f19ad3 100644
--- a/components/webgpu/Cargo.toml
+++ b/components/webgpu/Cargo.toml
@@ -20,7 +20,6 @@ log = { workspace = true }
malloc_size_of = { workspace = true }
serde = { workspace = true, features = ["serde_derive"] }
servo_config = { path = "../config" }
-smallvec = { workspace = true, features = ["serde"] }
webrender = { workspace = true }
webrender_api = { workspace = true }
webrender_traits = { workspace = true }
diff --git a/components/webgpu/ipc_messages/recv.rs b/components/webgpu/ipc_messages/recv.rs
index 383da4bd294..528a1e97581 100644
--- a/components/webgpu/ipc_messages/recv.rs
+++ b/components/webgpu/ipc_messages/recv.rs
@@ -9,7 +9,6 @@ use arrayvec::ArrayVec;
use base::id::PipelineId;
use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
use serde::{Deserialize, Serialize};
-use smallvec::SmallVec;
use webrender_api::units::DeviceIntSize;
use webrender_api::{ImageFormat, ImageKey};
use wgc::binding_model::{
@@ -26,6 +25,7 @@ use wgc::resource::{
BufferDescriptor, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
};
use wgpu_core::command::{RenderPassColorAttachment, RenderPassDepthStencilAttachment};
+use wgpu_core::id::AdapterId;
use wgpu_core::Label;
pub use {wgpu_core as wgc, wgpu_types as wgt};
@@ -186,7 +186,7 @@ pub enum WebGPURequest {
RequestAdapter {
sender: IpcSender<WebGPUResponse>,
options: RequestAdapterOptions,
- ids: SmallVec<[id::AdapterId; 4]>,
+ adapter_id: AdapterId,
},
RequestDevice {
sender: IpcSender<WebGPUResponse>,
@@ -287,7 +287,6 @@ pub enum WebGPURequest {
QueueOnSubmittedWorkDone {
sender: IpcSender<WebGPUResponse>,
queue_id: id::QueueId,
- device_id: id::DeviceId,
},
PushErrorScope {
device_id: id::DeviceId,
diff --git a/components/webgpu/render_commands.rs b/components/webgpu/render_commands.rs
index 7aae2e4a660..3cd374e4118 100644
--- a/components/webgpu/render_commands.rs
+++ b/components/webgpu/render_commands.rs
@@ -85,7 +85,7 @@ pub fn apply_render_command(
index,
bind_group_id,
offsets,
- } => global.render_pass_set_bind_group(pass, index, bind_group_id, &offsets),
+ } => global.render_pass_set_bind_group(pass, index, Some(bind_group_id), &offsets),
RenderCommand::SetViewport {
x,
y,
diff --git a/components/webgpu/wgpu_thread.rs b/components/webgpu/wgpu_thread.rs
index e2ae4bb3e63..ac8385f25cb 100644
--- a/components/webgpu/wgpu_thread.rs
+++ b/components/webgpu/wgpu_thread.rs
@@ -101,10 +101,7 @@ pub(crate) struct WGPU {
sender: IpcSender<WebGPURequest>,
pub(crate) script_sender: IpcSender<WebGPUMsg>,
pub(crate) global: Arc<wgc::global::Global>,
- adapters: Vec<WebGPUAdapter>,
devices: Arc<Mutex<HashMap<DeviceId, DeviceScope>>>,
- // Track invalid adapters https://gpuweb.github.io/gpuweb/#invalid
- _invalid_adapters: Vec<WebGPUAdapter>,
// TODO: Remove this (https://github.com/gfx-rs/wgpu/issues/867)
/// This stores first error on command encoder,
/// because wgpu does not invalidate command encoder object
@@ -155,9 +152,7 @@ impl WGPU {
sender,
script_sender,
global,
- adapters: Vec::new(),
devices: Arc::new(Mutex::new(HashMap::new())),
- _invalid_adapters: Vec::new(),
error_command_encoders: HashMap::new(),
webrender_api: Arc::new(Mutex::new(webrender_api_sender.create_api())),
webrender_document,
@@ -636,22 +631,20 @@ impl WGPU {
WebGPURequest::RequestAdapter {
sender,
options,
- ids,
+ adapter_id,
} => {
let global = &self.global;
let response = self
.global
- .request_adapter(&options, wgc::instance::AdapterInputs::IdSet(&ids))
+ .request_adapter(&options, wgt::Backends::all(), Some(adapter_id))
.map(|adapter_id| {
- let adapter = WebGPUAdapter(adapter_id);
- self.adapters.push(adapter);
// TODO: can we do this lazily
- let info = global.adapter_get_info(adapter_id).unwrap();
- let limits = global.adapter_limits(adapter_id).unwrap();
- let features = global.adapter_features(adapter_id).unwrap();
+ let adapter_info = global.adapter_get_info(adapter_id);
+ let limits = global.adapter_limits(adapter_id);
+ let features = global.adapter_features(adapter_id);
Adapter {
- adapter_info: info,
- adapter_id: adapter,
+ adapter_info,
+ adapter_id: WebGPUAdapter(adapter_id),
features,
limits,
channel: WebGPU(self.sender.clone()),
@@ -680,71 +673,63 @@ impl WGPU {
memory_hints: MemoryHints::MemoryUsage,
};
let global = &self.global;
- let (device_id, queue_id, error) = global.adapter_request_device(
- adapter_id.0,
- &desc,
- None,
- Some(device_id),
- Some(queue_id),
- );
let device = WebGPUDevice(device_id);
let queue = WebGPUQueue(queue_id);
- if let Some(e) = error {
- if let Err(e) =
- sender.send(WebGPUResponse::Device((device, queue, Err(e))))
- {
- warn!(
- "Failed to send response to WebGPURequest::RequestDevice ({})",
- e
- )
- }
- continue;
- }
- {
- self.devices
- .lock()
- .unwrap()
- .insert(device_id, DeviceScope::new(device_id, pipeline_id));
- }
- let script_sender = self.script_sender.clone();
- let devices = Arc::clone(&self.devices);
- let callback =
- DeviceLostClosure::from_rust(Box::from(move |reason, msg| {
- let reason = match reason {
- wgt::DeviceLostReason::Unknown => {
- crate::DeviceLostReason::Unknown
- },
- wgt::DeviceLostReason::Destroyed => {
- crate::DeviceLostReason::Destroyed
- },
- wgt::DeviceLostReason::Dropped => return, // we handle this in WebGPUMsg::FreeDevice
- wgt::DeviceLostReason::ReplacedCallback => {
- panic!("DeviceLost callback should only be set once")
- },
- wgt::DeviceLostReason::DeviceInvalid => {
- crate::DeviceLostReason::Unknown
- },
- };
- // make device lost by removing error scopes stack
- let _ = devices
- .lock()
- .unwrap()
- .get_mut(&device_id)
- .expect("Device should not be dropped by this point")
- .error_scope_stack
- .take();
- if let Err(e) = script_sender.send(WebGPUMsg::DeviceLost {
- device: WebGPUDevice(device_id),
- pipeline_id,
- reason,
- msg,
- }) {
- warn!("Failed to send WebGPUMsg::DeviceLost: {e}");
+ let result = global
+ .adapter_request_device(
+ adapter_id.0,
+ &desc,
+ None,
+ Some(device_id),
+ Some(queue_id),
+ )
+ .map(|_| {
+ {
+ self.devices.lock().unwrap().insert(
+ device_id,
+ DeviceScope::new(device_id, pipeline_id),
+ );
}
- }));
- global.device_set_device_lost_closure(device_id, callback);
- if let Err(e) =
- sender.send(WebGPUResponse::Device((device, queue, Ok(descriptor))))
+ let script_sender = self.script_sender.clone();
+ let devices = Arc::clone(&self.devices);
+ let callback =
+ DeviceLostClosure::from_rust(Box::from(move |reason, msg| {
+ let reason = match reason {
+ wgt::DeviceLostReason::Unknown => {
+ crate::DeviceLostReason::Unknown
+ },
+ wgt::DeviceLostReason::Destroyed => {
+ crate::DeviceLostReason::Destroyed
+ },
+ // we handle this in WebGPUMsg::FreeDevice
+ wgt::DeviceLostReason::Dropped => return,
+ wgt::DeviceLostReason::ReplacedCallback => {
+ panic!(
+ "DeviceLost callback should only be set once"
+ )
+ },
+ };
+ // make device lost by removing error scopes stack
+ let _ = devices
+ .lock()
+ .unwrap()
+ .get_mut(&device_id)
+ .expect("Device should not be dropped by this point")
+ .error_scope_stack
+ .take();
+ if let Err(e) = script_sender.send(WebGPUMsg::DeviceLost {
+ device,
+ pipeline_id,
+ reason,
+ msg,
+ }) {
+ warn!("Failed to send WebGPUMsg::DeviceLost: {e}");
+ }
+ }));
+ global.device_set_device_lost_closure(device_id, callback);
+ descriptor
+ });
+ if let Err(e) = sender.send(WebGPUResponse::Device((device, queue, result)))
{
warn!(
"Failed to send response to WebGPURequest::RequestDevice ({})",
@@ -810,7 +795,12 @@ impl WGPU {
if let Pass::Open { pass, valid } = pass {
*valid &= self
.global
- .compute_pass_set_bind_group(pass, index, bind_group_id, &offsets)
+ .compute_pass_set_bind_group(
+ pass,
+ index,
+ Some(bind_group_id),
+ &offsets,
+ )
.is_ok();
} else {
self.maybe_dispatch_error(
@@ -1058,11 +1048,7 @@ impl WGPU {
drop(_guard);
self.maybe_dispatch_wgpu_error(device_id, result.err());
},
- WebGPURequest::QueueOnSubmittedWorkDone {
- sender,
- queue_id,
- device_id,
- } => {
+ WebGPURequest::QueueOnSubmittedWorkDone { sender, queue_id } => {
let global = &self.global;
let token = self.poller.token();
let callback = SubmittedWorkDoneClosure::from_rust(Box::from(move || {
@@ -1071,9 +1057,8 @@ impl WGPU {
warn!("Could not send SubmittedWorkDone Response ({})", e);
}
}));
- let result = global.queue_on_submitted_work_done(queue_id, callback);
+ global.queue_on_submitted_work_done(queue_id, callback);
self.poller.wake();
- self.maybe_dispatch_wgpu_error(device_id, result.err());
},
WebGPURequest::DropTexture(id) => {
let global = &self.global;
diff --git a/tests/wpt/webgpu/meta/webgpu/cts.https.html.ini b/tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
index e396a12cfde..836e8f205cc 100644
--- a/tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
+++ b/tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
@@ -2590,6 +2590,8 @@
[:boundary="command-buffer";readOp="storage-read";readContext="compute-pass-encoder";writeOp="t2b-copy";writeContext="command-encoder"]
[:boundary="command-buffer";readOp="storage-read";readContext="render-bundle-encoder";writeOp="b2b-copy";writeContext="command-encoder"]
+ expected:
+ if os == "linux" and not debug: [PASS, FAIL]
[:boundary="command-buffer";readOp="storage-read";readContext="render-bundle-encoder";writeOp="t2b-copy";writeContext="command-encoder"]
expected:
@@ -3082,6 +3084,8 @@
if os == "linux" and not debug: [PASS, FAIL]
[:boundary="command-buffer";readOp="constant-uniform";readContext="render-bundle-encoder";writeOp="t2b-copy";writeContext="command-encoder"]
+ expected:
+ if os == "linux" and not debug: [PASS, FAIL]
[:boundary="command-buffer";readOp="constant-uniform";readContext="render-pass-encoder";writeOp="b2b-copy";writeContext="command-encoder"]
expected:
@@ -3152,6 +3156,8 @@
if os == "linux" and not debug: [PASS, FAIL]
[:boundary="command-buffer";readOp="storage-read";readContext="render-pass-encoder";writeOp="t2b-copy";writeContext="command-encoder"]
+ expected:
+ if os == "linux" and not debug: [PASS, FAIL]
[:boundary="dispatch";readOp="input-indirect-dispatch";readContext="compute-pass-encoder";writeOp="storage";writeContext="compute-pass-encoder"]
@@ -46887,9 +46893,6 @@
[cts.https.html?q=webgpu:api,validation,queue,submit:command_buffer,duplicate_buffers:*]
- [:]
- expected:
- if os == "linux" and not debug: FAIL
[cts.https.html?q=webgpu:api,validation,queue,submit:command_buffer,invalid_submit_invalidates:*]
@@ -46899,9 +46902,6 @@
[cts.https.html?q=webgpu:api,validation,queue,submit:command_buffer,submit_invalidates:*]
- [:]
- expected:
- if os == "linux" and not debug: FAIL
[cts.https.html?q=webgpu:api,validation,queue,writeBuffer:buffer,device_mismatch:*]