mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
chore: Update wgpu (#33506)
* Update wgpu Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * use all backends at runtime Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * clean up some adapter stuff Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * flakes Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
28d28d0a0a
commit
24ad2a0526
33 changed files with 206 additions and 361 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -2358,9 +2358,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glow"
|
name = "glow"
|
||||||
version = "0.14.0"
|
version = "0.14.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f865cbd94bd355b89611211e49508da98a1fce0ad755c1e8448fb96711b24528"
|
checksum = "2f4a888dbe8181a7535853469c21c67ca9a1cea9460b16808fc018ea9e55d248"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
|
@ -4426,7 +4426,7 @@ checksum = "defc4c55412d89136f966bbb339008b474350e5e6e78d2714439c386b3137a03"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "naga"
|
name = "naga"
|
||||||
version = "22.0.0"
|
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 = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"bit-set",
|
"bit-set",
|
||||||
|
@ -7876,7 +7876,6 @@ dependencies = [
|
||||||
"malloc_size_of",
|
"malloc_size_of",
|
||||||
"serde",
|
"serde",
|
||||||
"servo_config",
|
"servo_config",
|
||||||
"smallvec",
|
|
||||||
"webrender",
|
"webrender",
|
||||||
"webrender_api",
|
"webrender_api",
|
||||||
"webrender_traits",
|
"webrender_traits",
|
||||||
|
@ -8006,7 +8005,7 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-core"
|
name = "wgpu-core"
|
||||||
version = "22.0.0"
|
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 = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"bit-vec",
|
"bit-vec",
|
||||||
|
@ -8031,7 +8030,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-hal"
|
name = "wgpu-hal"
|
||||||
version = "22.0.0"
|
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 = [
|
dependencies = [
|
||||||
"android_system_properties",
|
"android_system_properties",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
|
@ -8041,7 +8040,7 @@ dependencies = [
|
||||||
"block",
|
"block",
|
||||||
"cfg_aliases 0.1.1",
|
"cfg_aliases 0.1.1",
|
||||||
"core-graphics-types",
|
"core-graphics-types",
|
||||||
"glow 0.14.0",
|
"glow 0.14.1",
|
||||||
"glutin_wgl_sys",
|
"glutin_wgl_sys",
|
||||||
"gpu-alloc",
|
"gpu-alloc",
|
||||||
"gpu-allocator",
|
"gpu-allocator",
|
||||||
|
@ -8073,7 +8072,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-types"
|
name = "wgpu-types"
|
||||||
version = "22.0.0"
|
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 = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
|
|
@ -143,8 +143,8 @@ webpki-roots = "0.25"
|
||||||
webrender = { git = "https://github.com/servo/webrender", branch = "0.65", features = ["capture"] }
|
webrender = { git = "https://github.com/servo/webrender", branch = "0.65", features = ["capture"] }
|
||||||
webrender_api = { git = "https://github.com/servo/webrender", branch = "0.65" }
|
webrender_api = { git = "https://github.com/servo/webrender", branch = "0.65" }
|
||||||
webrender_traits = { path = "components/shared/webrender" }
|
webrender_traits = { path = "components/shared/webrender" }
|
||||||
wgpu-core = { 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 = "0e352f5b3448236b6cbebcd146d0606b00cb3806" }
|
wgpu-types = { git = "https://github.com/gfx-rs/wgpu", rev = "9f85f8aeea6c43c1a412bafc8fbcfb43aad0dd20" }
|
||||||
windows-sys = "0.59"
|
windows-sys = "0.59"
|
||||||
xi-unicode = "0.3.0"
|
xi-unicode = "0.3.0"
|
||||||
xml5ever = "0.20"
|
xml5ever = "0.20"
|
||||||
|
|
|
@ -2087,22 +2087,24 @@ where
|
||||||
Entry::Occupied(o) => Some(o.get().clone()),
|
Entry::Occupied(o) => Some(o.get().clone()),
|
||||||
};
|
};
|
||||||
match request {
|
match request {
|
||||||
FromScriptMsg::RequestAdapter(response_sender, options, ids) => match webgpu_chan {
|
FromScriptMsg::RequestAdapter(response_sender, options, adapter_id) => {
|
||||||
None => {
|
match webgpu_chan {
|
||||||
if let Err(e) = response_sender.send(WebGPUResponse::None) {
|
None => {
|
||||||
warn!("Failed to send request adapter message: {}", e)
|
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 {
|
Some(webgpu_chan) => {
|
||||||
sender: response_sender,
|
let adapter_request = WebGPURequest::RequestAdapter {
|
||||||
options,
|
sender: response_sender,
|
||||||
ids,
|
options,
|
||||||
};
|
adapter_id,
|
||||||
if webgpu_chan.0.send(adapter_request).is_err() {
|
};
|
||||||
warn!("Failed to send request adapter message on WebGPU channel");
|
if webgpu_chan.0.send(adapter_request).is_err() {
|
||||||
}
|
warn!("Failed to send request adapter message on WebGPU channel");
|
||||||
},
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
FromScriptMsg::GetWebGPUChan(response_sender) => {
|
FromScriptMsg::GetWebGPUChan(response_sender) => {
|
||||||
if response_sender.send(webgpu_chan).is_err() {
|
if response_sender.send(webgpu_chan).is_err() {
|
||||||
|
|
|
@ -47,7 +47,7 @@ use crate::dom::errorevent::ErrorEvent;
|
||||||
use crate::dom::event::{Event, EventBubbles, EventCancelable, EventStatus};
|
use crate::dom::event::{Event, EventBubbles, EventCancelable, EventStatus};
|
||||||
use crate::dom::eventtarget::EventTarget;
|
use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::identityhub::Identities;
|
use crate::dom::identityhub::IdentityHub;
|
||||||
use crate::dom::messageevent::MessageEvent;
|
use crate::dom::messageevent::MessageEvent;
|
||||||
use crate::dom::worker::{TrustedWorkerAddress, Worker};
|
use crate::dom::worker::{TrustedWorkerAddress, Worker};
|
||||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||||
|
@ -253,7 +253,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
closing: Arc<AtomicBool>,
|
closing: Arc<AtomicBool>,
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
browsing_context: Option<BrowsingContextId>,
|
browsing_context: Option<BrowsingContextId>,
|
||||||
gpu_id_hub: Arc<Identities>,
|
gpu_id_hub: Arc<IdentityHub>,
|
||||||
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
||||||
) -> DedicatedWorkerGlobalScope {
|
) -> DedicatedWorkerGlobalScope {
|
||||||
DedicatedWorkerGlobalScope {
|
DedicatedWorkerGlobalScope {
|
||||||
|
@ -291,7 +291,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
closing: Arc<AtomicBool>,
|
closing: Arc<AtomicBool>,
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
browsing_context: Option<BrowsingContextId>,
|
browsing_context: Option<BrowsingContextId>,
|
||||||
gpu_id_hub: Arc<Identities>,
|
gpu_id_hub: Arc<IdentityHub>,
|
||||||
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
||||||
) -> DomRoot<DedicatedWorkerGlobalScope> {
|
) -> DomRoot<DedicatedWorkerGlobalScope> {
|
||||||
let cx = runtime.cx();
|
let cx = runtime.cx();
|
||||||
|
@ -330,7 +330,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
closing: Arc<AtomicBool>,
|
closing: Arc<AtomicBool>,
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
browsing_context: Option<BrowsingContextId>,
|
browsing_context: Option<BrowsingContextId>,
|
||||||
gpu_id_hub: Arc<Identities>,
|
gpu_id_hub: Arc<IdentityHub>,
|
||||||
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
control_receiver: Receiver<DedicatedWorkerControlMsg>,
|
||||||
context_sender: Sender<ContextForRequestInterrupt>,
|
context_sender: Sender<ContextForRequestInterrupt>,
|
||||||
can_gc: CanGc,
|
can_gc: CanGc,
|
||||||
|
|
|
@ -102,7 +102,7 @@ use crate::dom::gamepad::{contains_user_gesture, Gamepad};
|
||||||
use crate::dom::gamepadevent::GamepadEventType;
|
use crate::dom::gamepadevent::GamepadEventType;
|
||||||
use crate::dom::gpudevice::GPUDevice;
|
use crate::dom::gpudevice::GPUDevice;
|
||||||
use crate::dom::htmlscriptelement::{ScriptId, SourceCode};
|
use crate::dom::htmlscriptelement::{ScriptId, SourceCode};
|
||||||
use crate::dom::identityhub::Identities;
|
use crate::dom::identityhub::IdentityHub;
|
||||||
use crate::dom::imagebitmap::ImageBitmap;
|
use crate::dom::imagebitmap::ImageBitmap;
|
||||||
use crate::dom::messageevent::MessageEvent;
|
use crate::dom::messageevent::MessageEvent;
|
||||||
use crate::dom::messageport::MessagePort;
|
use crate::dom::messageport::MessagePort;
|
||||||
|
@ -325,7 +325,7 @@ pub struct GlobalScope {
|
||||||
/// Identity Manager for WebGPU resources
|
/// Identity Manager for WebGPU resources
|
||||||
#[ignore_malloc_size_of = "defined in wgpu"]
|
#[ignore_malloc_size_of = "defined in wgpu"]
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
gpu_id_hub: Arc<Identities>,
|
gpu_id_hub: Arc<IdentityHub>,
|
||||||
|
|
||||||
/// WebGPU devices
|
/// WebGPU devices
|
||||||
gpu_devices: DomRefCell<HashMapTracedValues<WebGPUDevice, WeakRef<GPUDevice>>>,
|
gpu_devices: DomRefCell<HashMapTracedValues<WebGPUDevice, WeakRef<GPUDevice>>>,
|
||||||
|
@ -768,7 +768,7 @@ impl GlobalScope {
|
||||||
microtask_queue: Rc<MicrotaskQueue>,
|
microtask_queue: Rc<MicrotaskQueue>,
|
||||||
is_headless: bool,
|
is_headless: bool,
|
||||||
user_agent: Cow<'static, str>,
|
user_agent: Cow<'static, str>,
|
||||||
gpu_id_hub: Arc<Identities>,
|
gpu_id_hub: Arc<IdentityHub>,
|
||||||
inherited_secure_context: Option<bool>,
|
inherited_secure_context: Option<bool>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -3154,7 +3154,7 @@ impl GlobalScope {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn wgpu_id_hub(&self) -> Arc<Identities> {
|
pub fn wgpu_id_hub(&self) -> Arc<IdentityHub> {
|
||||||
self.gpu_id_hub.clone()
|
self.gpu_id_hub.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl GPUMethods for GPU {
|
||||||
Some(GPUPowerPreference::High_performance) => PowerPreference::HighPerformance,
|
Some(GPUPowerPreference::High_performance) => PowerPreference::HighPerformance,
|
||||||
None => PowerPreference::default(),
|
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();
|
let script_to_constellation_chan = global.script_to_constellation_chan();
|
||||||
if script_to_constellation_chan
|
if script_to_constellation_chan
|
||||||
|
@ -147,8 +147,7 @@ impl AsyncWGPUListener for GPU {
|
||||||
adapter.channel,
|
adapter.channel,
|
||||||
DOMString::from(format!(
|
DOMString::from(format!(
|
||||||
"{} ({:?})",
|
"{} ({:?})",
|
||||||
adapter.adapter_info.name,
|
adapter.adapter_info.name, adapter.adapter_id.0
|
||||||
adapter.adapter_id.0.backend()
|
|
||||||
)),
|
)),
|
||||||
Heap::default(),
|
Heap::default(),
|
||||||
adapter.features,
|
adapter.features,
|
||||||
|
|
|
@ -140,14 +140,8 @@ impl GPUAdapterMethods for GPUAdapter {
|
||||||
label: Some(descriptor.parent.label.to_string()),
|
label: Some(descriptor.parent.label.to_string()),
|
||||||
memory_hints: MemoryHints::MemoryUsage,
|
memory_hints: MemoryHints::MemoryUsage,
|
||||||
};
|
};
|
||||||
let device_id = self
|
let device_id = self.global().wgpu_id_hub().create_device_id();
|
||||||
.global()
|
let queue_id = self.global().wgpu_id_hub().create_queue_id();
|
||||||
.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 pipeline_id = self.global().pipeline_id();
|
let pipeline_id = self.global().pipeline_id();
|
||||||
if self
|
if self
|
||||||
.channel
|
.channel
|
||||||
|
@ -222,11 +216,9 @@ impl AsyncWGPUListener for GPUAdapter {
|
||||||
RequestDeviceError::UnsupportedFeature(f).to_string(),
|
RequestDeviceError::UnsupportedFeature(f).to_string(),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
WebGPUResponse::Device((
|
WebGPUResponse::Device((_, _, Err(RequestDeviceError::LimitsExceeded(_)))) => {
|
||||||
_,
|
promise.reject_error(Error::Operation)
|
||||||
_,
|
},
|
||||||
Err(RequestDeviceError::LimitsExceeded(_) | RequestDeviceError::InvalidAdapter),
|
|
||||||
)) => promise.reject_error(Error::Operation),
|
|
||||||
WebGPUResponse::Device((device_id, queue_id, Err(e))) => {
|
WebGPUResponse::Device((device_id, queue_id, Err(e))) => {
|
||||||
let device = GPUDevice::new(
|
let device = GPUDevice::new(
|
||||||
&self.global(),
|
&self.global(),
|
||||||
|
|
|
@ -90,10 +90,7 @@ impl GPUBindGroup {
|
||||||
entries: Cow::Owned(entries),
|
entries: Cow::Owned(entries),
|
||||||
};
|
};
|
||||||
|
|
||||||
let bind_group_id = device
|
let bind_group_id = device.global().wgpu_id_hub().create_bind_group_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_bind_group_id(device.id().0.backend());
|
|
||||||
device
|
device
|
||||||
.channel()
|
.channel()
|
||||||
.0
|
.0
|
||||||
|
|
|
@ -89,10 +89,7 @@ impl GPUBindGroupLayout {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let bind_group_layout_id = device
|
let bind_group_layout_id = device.global().wgpu_id_hub().create_bind_group_layout_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_bind_group_layout_id(device.id().0.backend());
|
|
||||||
device
|
device
|
||||||
.channel()
|
.channel()
|
||||||
.0
|
.0
|
||||||
|
|
|
@ -142,10 +142,7 @@ impl GPUBuffer {
|
||||||
usage: wgt::BufferUsages::from_bits_retain(descriptor.usage),
|
usage: wgt::BufferUsages::from_bits_retain(descriptor.usage),
|
||||||
mapped_at_creation: descriptor.mappedAtCreation,
|
mapped_at_creation: descriptor.mappedAtCreation,
|
||||||
};
|
};
|
||||||
let id = device
|
let id = device.global().wgpu_id_hub().create_buffer_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_buffer_id(device.id().0.backend());
|
|
||||||
|
|
||||||
device
|
device
|
||||||
.channel()
|
.channel()
|
||||||
|
|
|
@ -145,10 +145,7 @@ impl GPUCanvasContext {
|
||||||
|
|
||||||
pub fn send_swap_chain_present(&self) {
|
pub fn send_swap_chain_present(&self) {
|
||||||
let texture_id = self.texture_id().unwrap().0;
|
let texture_id = self.texture_id().unwrap().0;
|
||||||
let encoder_id = self
|
let encoder_id = self.global().wgpu_id_hub().create_command_encoder_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_command_encoder_id(texture_id.backend());
|
|
||||||
if let Err(e) = self.channel.0.send(WebGPURequest::SwapChainPresent {
|
if let Err(e) = self.channel.0.send(WebGPURequest::SwapChainPresent {
|
||||||
context_id: self.context_id,
|
context_id: self.context_id,
|
||||||
texture_id,
|
texture_id,
|
||||||
|
@ -258,11 +255,7 @@ impl GPUCanvasContextMethods for GPUCanvasContext {
|
||||||
|
|
||||||
let mut buffer_ids = ArrayVec::<id::BufferId, PRESENTATION_BUFFER_COUNT>::new();
|
let mut buffer_ids = ArrayVec::<id::BufferId, PRESENTATION_BUFFER_COUNT>::new();
|
||||||
for _ in 0..PRESENTATION_BUFFER_COUNT {
|
for _ in 0..PRESENTATION_BUFFER_COUNT {
|
||||||
buffer_ids.push(
|
buffer_ids.push(self.global().wgpu_id_hub().create_buffer_id());
|
||||||
self.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_buffer_id(configuration.device.id().0.backend()),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.channel
|
self.channel
|
||||||
|
|
|
@ -85,10 +85,7 @@ impl GPUCommandEncoder {
|
||||||
device: &GPUDevice,
|
device: &GPUDevice,
|
||||||
descriptor: &GPUCommandEncoderDescriptor,
|
descriptor: &GPUCommandEncoderDescriptor,
|
||||||
) -> DomRoot<GPUCommandEncoder> {
|
) -> DomRoot<GPUCommandEncoder> {
|
||||||
let command_encoder_id = device
|
let command_encoder_id = device.global().wgpu_id_hub().create_command_encoder_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_command_encoder_id(device.id().0.backend());
|
|
||||||
device
|
device
|
||||||
.channel()
|
.channel()
|
||||||
.0
|
.0
|
||||||
|
@ -129,10 +126,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
&self,
|
&self,
|
||||||
descriptor: &GPUComputePassDescriptor,
|
descriptor: &GPUComputePassDescriptor,
|
||||||
) -> DomRoot<GPUComputePassEncoder> {
|
) -> DomRoot<GPUComputePassEncoder> {
|
||||||
let compute_pass_id = self
|
let compute_pass_id = self.global().wgpu_id_hub().create_compute_pass_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_compute_pass_id(self.device.id().0.backend());
|
|
||||||
|
|
||||||
if let Err(e) = self.channel.0.send(WebGPURequest::BeginComputePass {
|
if let Err(e) = self.channel.0.send(WebGPURequest::BeginComputePass {
|
||||||
command_encoder_id: self.id().0,
|
command_encoder_id: self.id().0,
|
||||||
|
@ -197,10 +191,7 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
.collect::<Fallible<Vec<_>>>()?;
|
.collect::<Fallible<Vec<_>>>()?;
|
||||||
let render_pass_id = self
|
let render_pass_id = self.global().wgpu_id_hub().create_render_pass_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_render_pass_id(self.device.id().0.backend());
|
|
||||||
|
|
||||||
if let Err(e) = self.channel.0.send(WebGPURequest::BeginRenderPass {
|
if let Err(e) = self.channel.0.send(WebGPURequest::BeginRenderPass {
|
||||||
command_encoder_id: self.id().0,
|
command_encoder_id: self.id().0,
|
||||||
|
|
|
@ -74,10 +74,7 @@ impl GPUComputePipeline {
|
||||||
descriptor: &GPUComputePipelineDescriptor,
|
descriptor: &GPUComputePipelineDescriptor,
|
||||||
async_sender: Option<IpcSender<WebGPUResponse>>,
|
async_sender: Option<IpcSender<WebGPUResponse>>,
|
||||||
) -> WebGPUComputePipeline {
|
) -> WebGPUComputePipeline {
|
||||||
let compute_pipeline_id = device
|
let compute_pipeline_id = device.global().wgpu_id_hub().create_compute_pipeline_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_compute_pipeline_id(device.id().0.backend());
|
|
||||||
|
|
||||||
let (layout, implicit_ids, _) = device.get_pipeline_layout_data(&descriptor.parent.layout);
|
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>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpupipelinebase-getbindgrouplayout>
|
||||||
fn GetBindGroupLayout(&self, index: u32) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
fn GetBindGroupLayout(&self, index: u32) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
||||||
let id = self
|
let id = self.global().wgpu_id_hub().create_bind_group_layout_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_bind_group_layout_id(self.compute_pipeline.0.backend());
|
|
||||||
|
|
||||||
if let Err(e) = self
|
if let Err(e) = self
|
||||||
.channel
|
.channel
|
||||||
|
|
|
@ -216,18 +216,12 @@ impl GPUDevice {
|
||||||
if let GPUPipelineLayoutOrGPUAutoLayoutMode::GPUPipelineLayout(ref layout) = layout {
|
if let GPUPipelineLayoutOrGPUAutoLayoutMode::GPUPipelineLayout(ref layout) = layout {
|
||||||
(Some(layout.id().0), None, layout.bind_group_layouts())
|
(Some(layout.id().0), None, layout.bind_group_layouts())
|
||||||
} else {
|
} else {
|
||||||
let layout_id = self
|
let layout_id = self.global().wgpu_id_hub().create_pipeline_layout_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_pipeline_layout_id(self.device.0.backend());
|
|
||||||
let max_bind_grps = self.limits.MaxBindGroups();
|
let max_bind_grps = self.limits.MaxBindGroups();
|
||||||
let mut bgls = Vec::with_capacity(max_bind_grps as usize);
|
let mut bgls = Vec::with_capacity(max_bind_grps as usize);
|
||||||
let mut bgl_ids = 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 {
|
for _ in 0..max_bind_grps {
|
||||||
let bgl = self
|
let bgl = self.global().wgpu_id_hub().create_bind_group_layout_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_bind_group_layout_id(self.device.0.backend());
|
|
||||||
bgls.push(webgpu::WebGPUBindGroupLayout(bgl));
|
bgls.push(webgpu::WebGPUBindGroupLayout(bgl));
|
||||||
bgl_ids.push(bgl);
|
bgl_ids.push(bgl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,10 +92,7 @@ impl GPUPipelineLayout {
|
||||||
push_constant_ranges: Cow::Owned(vec![]),
|
push_constant_ranges: Cow::Owned(vec![]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pipeline_layout_id = device
|
let pipeline_layout_id = device.global().wgpu_id_hub().create_pipeline_layout_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_pipeline_layout_id(device.id().0.backend());
|
|
||||||
device
|
device
|
||||||
.channel()
|
.channel()
|
||||||
.0
|
.0
|
||||||
|
|
|
@ -197,7 +197,6 @@ impl GPUQueueMethods for GPUQueue {
|
||||||
.send(WebGPURequest::QueueOnSubmittedWorkDone {
|
.send(WebGPURequest::QueueOnSubmittedWorkDone {
|
||||||
sender,
|
sender,
|
||||||
queue_id: self.queue.0,
|
queue_id: self.queue.0,
|
||||||
device_id: self.device.borrow().as_ref().unwrap().id().0,
|
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
warn!("QueueOnSubmittedWorkDone failed with {e}")
|
warn!("QueueOnSubmittedWorkDone failed with {e}")
|
||||||
|
|
|
@ -143,7 +143,7 @@ impl GPURenderBundleEncoderMethods for GPURenderBundleEncoder {
|
||||||
wgpu_bundle::wgpu_render_bundle_set_bind_group(
|
wgpu_bundle::wgpu_render_bundle_set_bind_group(
|
||||||
encoder,
|
encoder,
|
||||||
index,
|
index,
|
||||||
bind_group.id().0,
|
Some(bind_group.id().0),
|
||||||
dynamic_offsets.as_ptr(),
|
dynamic_offsets.as_ptr(),
|
||||||
dynamic_offsets.len(),
|
dynamic_offsets.len(),
|
||||||
)
|
)
|
||||||
|
@ -255,10 +255,7 @@ impl GPURenderBundleEncoderMethods for GPURenderBundleEncoder {
|
||||||
label: (&descriptor.parent).into(),
|
label: (&descriptor.parent).into(),
|
||||||
};
|
};
|
||||||
let encoder = self.render_bundle_encoder.borrow_mut().take().unwrap();
|
let encoder = self.render_bundle_encoder.borrow_mut().take().unwrap();
|
||||||
let render_bundle_id = self
|
let render_bundle_id = self.global().wgpu_id_hub().create_render_bundle_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_render_bundle_id(self.device.id().0.backend());
|
|
||||||
|
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
|
|
|
@ -74,10 +74,7 @@ impl GPURenderPipeline {
|
||||||
descriptor: RenderPipelineDescriptor<'static>,
|
descriptor: RenderPipelineDescriptor<'static>,
|
||||||
async_sender: Option<IpcSender<WebGPUResponse>>,
|
async_sender: Option<IpcSender<WebGPUResponse>>,
|
||||||
) -> Fallible<WebGPURenderPipeline> {
|
) -> Fallible<WebGPURenderPipeline> {
|
||||||
let render_pipeline_id = device
|
let render_pipeline_id = device.global().wgpu_id_hub().create_render_pipeline_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_render_pipeline_id(device.id().0.backend());
|
|
||||||
|
|
||||||
device
|
device
|
||||||
.channel()
|
.channel()
|
||||||
|
@ -108,10 +105,7 @@ impl GPURenderPipelineMethods for GPURenderPipeline {
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpupipelinebase-getbindgrouplayout>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpupipelinebase-getbindgrouplayout>
|
||||||
fn GetBindGroupLayout(&self, index: u32) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
fn GetBindGroupLayout(&self, index: u32) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
||||||
let id = self
|
let id = self.global().wgpu_id_hub().create_bind_group_layout_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_bind_group_layout_id(self.render_pipeline.0.backend());
|
|
||||||
|
|
||||||
if let Err(e) = self
|
if let Err(e) = self
|
||||||
.channel
|
.channel
|
||||||
|
|
|
@ -76,10 +76,7 @@ impl GPUSampler {
|
||||||
|
|
||||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler>
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler>
|
||||||
pub fn create(device: &GPUDevice, descriptor: &GPUSamplerDescriptor) -> DomRoot<GPUSampler> {
|
pub fn create(device: &GPUDevice, descriptor: &GPUSamplerDescriptor) -> DomRoot<GPUSampler> {
|
||||||
let sampler_id = device
|
let sampler_id = device.global().wgpu_id_hub().create_sampler_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_sampler_id(device.id().0.backend());
|
|
||||||
let compare_enable = descriptor.compare.is_some();
|
let compare_enable = descriptor.compare.is_some();
|
||||||
let desc = SamplerDescriptor {
|
let desc = SamplerDescriptor {
|
||||||
label: (&descriptor.parent).into(),
|
label: (&descriptor.parent).into(),
|
||||||
|
|
|
@ -82,10 +82,7 @@ impl GPUShaderModule {
|
||||||
descriptor: RootedTraceableBox<GPUShaderModuleDescriptor>,
|
descriptor: RootedTraceableBox<GPUShaderModuleDescriptor>,
|
||||||
comp: InRealm,
|
comp: InRealm,
|
||||||
) -> DomRoot<GPUShaderModule> {
|
) -> DomRoot<GPUShaderModule> {
|
||||||
let program_id = device
|
let program_id = device.global().wgpu_id_hub().create_shader_module_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_shader_module_id(device.id().0.backend());
|
|
||||||
let promise = Promise::new_in_current_realm(comp);
|
let promise = Promise::new_in_current_realm(comp);
|
||||||
let shader_module = GPUShaderModule::new(
|
let shader_module = GPUShaderModule::new(
|
||||||
&device.global(),
|
&device.global(),
|
||||||
|
|
|
@ -149,10 +149,7 @@ impl GPUTexture {
|
||||||
.collect::<Fallible<_>>()?,
|
.collect::<Fallible<_>>()?,
|
||||||
};
|
};
|
||||||
|
|
||||||
let texture_id = device
|
let texture_id = device.global().wgpu_id_hub().create_texture_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_texture_id(device.id().0.backend());
|
|
||||||
|
|
||||||
device
|
device
|
||||||
.channel()
|
.channel()
|
||||||
|
@ -228,10 +225,7 @@ impl GPUTextureMethods for GPUTexture {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let texture_view_id = self
|
let texture_view_id = self.global().wgpu_id_hub().create_texture_view_id();
|
||||||
.global()
|
|
||||||
.wgpu_id_hub()
|
|
||||||
.create_texture_view_id(self.device.id().0.backend());
|
|
||||||
|
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
|
|
|
@ -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 smallvec::SmallVec;
|
|
||||||
use webgpu::identity::{ComputePass, ComputePassId, RenderPass, RenderPassId};
|
use webgpu::identity::{ComputePass, ComputePassId, RenderPass, RenderPassId};
|
||||||
use webgpu::wgc::id::markers::{
|
use webgpu::wgc::id::markers::{
|
||||||
Adapter, BindGroup, BindGroupLayout, Buffer, CommandEncoder, ComputePipeline, Device,
|
Adapter, BindGroup, BindGroupLayout, Buffer, CommandEncoder, ComputePipeline, Device,
|
||||||
|
@ -15,7 +14,6 @@ use webgpu::wgc::id::{
|
||||||
ShaderModuleId, TextureId, TextureViewId,
|
ShaderModuleId, TextureId, TextureViewId,
|
||||||
};
|
};
|
||||||
use webgpu::wgc::identity::IdentityManager;
|
use webgpu::wgc::identity::IdentityManager;
|
||||||
use webgpu::wgt::Backend;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct IdentityHub {
|
pub struct IdentityHub {
|
||||||
|
@ -39,7 +37,7 @@ pub struct IdentityHub {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IdentityHub {
|
impl IdentityHub {
|
||||||
fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
IdentityHub {
|
IdentityHub {
|
||||||
adapters: IdentityManager::new(),
|
adapters: IdentityManager::new(),
|
||||||
devices: IdentityManager::new(),
|
devices: IdentityManager::new(),
|
||||||
|
@ -62,205 +60,140 @@ impl IdentityHub {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
impl IdentityHub {
|
||||||
pub struct Identities {
|
pub fn create_device_id(&self) -> DeviceId {
|
||||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
self.devices.process()
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_device_id(&self, id: DeviceId) {
|
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 {
|
pub fn create_queue_id(&self) -> QueueId {
|
||||||
self.select(backend).queues.process(backend)
|
self.queues.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_queue_id(&self, id: QueueId) {
|
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]> {
|
pub fn create_adapter_id(&self) -> AdapterId {
|
||||||
let mut ids = SmallVec::new();
|
self.adapters.process()
|
||||||
for hubs in self.hubs() {
|
|
||||||
ids.push(hubs.0.adapters.process(hubs.1));
|
|
||||||
}
|
|
||||||
ids
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_adapter_id(&self, id: AdapterId) {
|
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 {
|
pub fn create_buffer_id(&self) -> BufferId {
|
||||||
self.select(backend).buffers.process(backend)
|
self.buffers.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_buffer_id(&self, id: BufferId) {
|
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 {
|
pub fn create_bind_group_id(&self) -> BindGroupId {
|
||||||
self.select(backend).bind_groups.process(backend)
|
self.bind_groups.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_bind_group_id(&self, id: BindGroupId) {
|
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 {
|
pub fn create_bind_group_layout_id(&self) -> BindGroupLayoutId {
|
||||||
self.select(backend).bind_group_layouts.process(backend)
|
self.bind_group_layouts.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_bind_group_layout_id(&self, id: BindGroupLayoutId) {
|
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 {
|
pub fn create_compute_pipeline_id(&self) -> ComputePipelineId {
|
||||||
self.select(backend).compute_pipelines.process(backend)
|
self.compute_pipelines.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_compute_pipeline_id(&self, id: ComputePipelineId) {
|
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 {
|
pub fn create_pipeline_layout_id(&self) -> PipelineLayoutId {
|
||||||
self.select(backend).pipeline_layouts.process(backend)
|
self.pipeline_layouts.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_pipeline_layout_id(&self, id: PipelineLayoutId) {
|
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 {
|
pub fn create_shader_module_id(&self) -> ShaderModuleId {
|
||||||
self.select(backend).shader_modules.process(backend)
|
self.shader_modules.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_shader_module_id(&self, id: ShaderModuleId) {
|
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 {
|
pub fn create_command_encoder_id(&self) -> CommandEncoderId {
|
||||||
self.select(backend).command_encoders.process(backend)
|
self.command_encoders.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_command_buffer_id(&self, id: CommandEncoderId) {
|
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 {
|
pub fn create_sampler_id(&self) -> SamplerId {
|
||||||
self.select(backend).samplers.process(backend)
|
self.samplers.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_sampler_id(&self, id: SamplerId) {
|
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 {
|
pub fn create_render_pipeline_id(&self) -> RenderPipelineId {
|
||||||
self.select(backend).render_pipelines.process(backend)
|
self.render_pipelines.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_render_pipeline_id(&self, id: RenderPipelineId) {
|
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 {
|
pub fn create_texture_id(&self) -> TextureId {
|
||||||
self.select(backend).textures.process(backend)
|
self.textures.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_texture_id(&self, id: TextureId) {
|
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 {
|
pub fn create_texture_view_id(&self) -> TextureViewId {
|
||||||
self.select(backend).texture_views.process(backend)
|
self.texture_views.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_texture_view_id(&self, id: TextureViewId) {
|
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 {
|
pub fn create_render_bundle_id(&self) -> RenderBundleId {
|
||||||
self.select(backend).render_bundles.process(backend)
|
self.render_bundles.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_render_bundle_id(&self, id: RenderBundleId) {
|
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 {
|
pub fn create_compute_pass_id(&self) -> ComputePassId {
|
||||||
self.select(backend).compute_passes.process(backend)
|
self.compute_passes.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_compute_pass_id(&self, id: ComputePassId) {
|
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 {
|
pub fn create_render_pass_id(&self) -> RenderPassId {
|
||||||
self.select(backend).render_passes.process(backend)
|
self.render_passes.process()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn free_render_pass_id(&self, id: RenderPassId) {
|
pub fn free_render_pass_id(&self, id: RenderPassId) {
|
||||||
self.select(id.backend()).render_passes.free(id);
|
self.render_passes.free(id);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Identities {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ use crate::dom::eventtarget::EventTarget;
|
||||||
use crate::dom::extendableevent::ExtendableEvent;
|
use crate::dom::extendableevent::ExtendableEvent;
|
||||||
use crate::dom::extendablemessageevent::ExtendableMessageEvent;
|
use crate::dom::extendablemessageevent::ExtendableMessageEvent;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::identityhub::Identities;
|
use crate::dom::identityhub::IdentityHub;
|
||||||
use crate::dom::worker::TrustedWorkerAddress;
|
use crate::dom::worker::TrustedWorkerAddress;
|
||||||
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
use crate::dom::workerglobalscope::WorkerGlobalScope;
|
||||||
use crate::fetch::load_whole_resource;
|
use crate::fetch::load_whole_resource;
|
||||||
|
@ -241,7 +241,7 @@ impl ServiceWorkerGlobalScope {
|
||||||
runtime,
|
runtime,
|
||||||
from_devtools_receiver,
|
from_devtools_receiver,
|
||||||
closing,
|
closing,
|
||||||
Arc::new(Identities::new()),
|
Arc::new(IdentityHub::new()),
|
||||||
),
|
),
|
||||||
task_queue: TaskQueue::new(receiver, own_sender.clone()),
|
task_queue: TaskQueue::new(receiver, own_sender.clone()),
|
||||||
own_sender,
|
own_sender,
|
||||||
|
|
|
@ -123,7 +123,7 @@ use crate::dom::hashchangeevent::HashChangeEvent;
|
||||||
use crate::dom::history::History;
|
use crate::dom::history::History;
|
||||||
use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection};
|
use crate::dom::htmlcollection::{CollectionFilter, HTMLCollection};
|
||||||
use crate::dom::htmliframeelement::HTMLIFrameElement;
|
use crate::dom::htmliframeelement::HTMLIFrameElement;
|
||||||
use crate::dom::identityhub::Identities;
|
use crate::dom::identityhub::IdentityHub;
|
||||||
use crate::dom::location::Location;
|
use crate::dom::location::Location;
|
||||||
use crate::dom::mediaquerylist::{MediaQueryList, MediaQueryListMatchState};
|
use crate::dom::mediaquerylist::{MediaQueryList, MediaQueryListMatchState};
|
||||||
use crate::dom::mediaquerylistevent::MediaQueryListEvent;
|
use crate::dom::mediaquerylistevent::MediaQueryListEvent;
|
||||||
|
@ -2558,7 +2558,7 @@ impl Window {
|
||||||
replace_surrogates: bool,
|
replace_surrogates: bool,
|
||||||
user_agent: Cow<'static, str>,
|
user_agent: Cow<'static, str>,
|
||||||
player_context: WindowGLContext,
|
player_context: WindowGLContext,
|
||||||
gpu_id_hub: Arc<Identities>,
|
gpu_id_hub: Arc<IdentityHub>,
|
||||||
inherited_secure_context: Option<bool>,
|
inherited_secure_context: Option<bool>,
|
||||||
) -> DomRoot<Self> {
|
) -> DomRoot<Self> {
|
||||||
let error_reporter = CSSErrorReporter {
|
let error_reporter = CSSErrorReporter {
|
||||||
|
|
|
@ -45,7 +45,7 @@ use crate::dom::bindings::trace::RootedTraceableBox;
|
||||||
use crate::dom::crypto::Crypto;
|
use crate::dom::crypto::Crypto;
|
||||||
use crate::dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
|
use crate::dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::identityhub::Identities;
|
use crate::dom::identityhub::IdentityHub;
|
||||||
use crate::dom::performance::Performance;
|
use crate::dom::performance::Performance;
|
||||||
use crate::dom::promise::Promise;
|
use crate::dom::promise::Promise;
|
||||||
use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
use crate::dom::serviceworkerglobalscope::ServiceWorkerGlobalScope;
|
||||||
|
@ -140,7 +140,7 @@ impl WorkerGlobalScope {
|
||||||
runtime: Runtime,
|
runtime: Runtime,
|
||||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
|
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
|
||||||
closing: Arc<AtomicBool>,
|
closing: Arc<AtomicBool>,
|
||||||
gpu_id_hub: Arc<Identities>,
|
gpu_id_hub: Arc<IdentityHub>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Install a pipeline-namespace in the current thread.
|
// Install a pipeline-namespace in the current thread.
|
||||||
PipelineNamespace::auto_install();
|
PipelineNamespace::auto_install();
|
||||||
|
|
|
@ -22,7 +22,7 @@ use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
|
||||||
use crate::dom::bindings::inheritance::Castable;
|
use crate::dom::bindings::inheritance::Castable;
|
||||||
use crate::dom::bindings::root::DomRoot;
|
use crate::dom::bindings::root::DomRoot;
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::identityhub::Identities;
|
use crate::dom::identityhub::IdentityHub;
|
||||||
use crate::dom::paintworkletglobalscope::{PaintWorkletGlobalScope, PaintWorkletTask};
|
use crate::dom::paintworkletglobalscope::{PaintWorkletGlobalScope, PaintWorkletTask};
|
||||||
use crate::dom::testworkletglobalscope::{TestWorkletGlobalScope, TestWorkletTask};
|
use crate::dom::testworkletglobalscope::{TestWorkletGlobalScope, TestWorkletTask};
|
||||||
use crate::dom::worklet::WorkletExecutor;
|
use crate::dom::worklet::WorkletExecutor;
|
||||||
|
@ -164,7 +164,7 @@ pub struct WorkletGlobalScopeInit {
|
||||||
/// An optional string allowing the user agent to be set for testing
|
/// An optional string allowing the user agent to be set for testing
|
||||||
pub user_agent: Cow<'static, str>,
|
pub user_agent: Cow<'static, str>,
|
||||||
/// Identity manager for WebGPU resources
|
/// Identity manager for WebGPU resources
|
||||||
pub gpu_id_hub: Arc<Identities>,
|
pub gpu_id_hub: Arc<IdentityHub>,
|
||||||
/// Is considered secure
|
/// Is considered secure
|
||||||
pub inherited_secure_context: Option<bool>,
|
pub inherited_secure_context: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
use crate::dom::globalscope::GlobalScope;
|
use crate::dom::globalscope::GlobalScope;
|
||||||
use crate::dom::htmlanchorelement::HTMLAnchorElement;
|
use crate::dom::htmlanchorelement::HTMLAnchorElement;
|
||||||
use crate::dom::htmliframeelement::HTMLIFrameElement;
|
use crate::dom::htmliframeelement::HTMLIFrameElement;
|
||||||
use crate::dom::identityhub::Identities;
|
use crate::dom::identityhub::IdentityHub;
|
||||||
use crate::dom::mutationobserver::MutationObserver;
|
use crate::dom::mutationobserver::MutationObserver;
|
||||||
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
|
use crate::dom::node::{window_from_node, Node, ShadowIncluding};
|
||||||
use crate::dom::performanceentry::PerformanceEntry;
|
use crate::dom::performanceentry::PerformanceEntry;
|
||||||
|
@ -718,7 +718,7 @@ pub struct ScriptThread {
|
||||||
|
|
||||||
/// Identity manager for WebGPU resources
|
/// Identity manager for WebGPU resources
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
gpu_id_hub: Arc<Identities>,
|
gpu_id_hub: Arc<IdentityHub>,
|
||||||
|
|
||||||
/// Receiver to receive commands from optional WebGPU server.
|
/// Receiver to receive commands from optional WebGPU server.
|
||||||
#[no_trace]
|
#[no_trace]
|
||||||
|
@ -1417,7 +1417,7 @@ impl ScriptThread {
|
||||||
|
|
||||||
node_ids: Default::default(),
|
node_ids: Default::default(),
|
||||||
is_user_interacting: Cell::new(false),
|
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),
|
webgpu_port: RefCell::new(None),
|
||||||
inherited_secure_context: state.inherited_secure_context,
|
inherited_secure_context: state.inherited_secure_context,
|
||||||
layout_factory,
|
layout_factory,
|
||||||
|
|
|
@ -22,7 +22,6 @@ use net_traits::storage_thread::StorageType;
|
||||||
use net_traits::CoreResourceMsg;
|
use net_traits::CoreResourceMsg;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||||
use smallvec::SmallVec;
|
|
||||||
use style_traits::CSSPixel;
|
use style_traits::CSSPixel;
|
||||||
use webgpu::{wgc, WebGPU, WebGPUResponse};
|
use webgpu::{wgc, WebGPU, WebGPUResponse};
|
||||||
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
use webrender_api::units::{DeviceIntPoint, DeviceIntSize};
|
||||||
|
@ -259,7 +258,7 @@ pub enum ScriptMsg {
|
||||||
RequestAdapter(
|
RequestAdapter(
|
||||||
IpcSender<WebGPUResponse>,
|
IpcSender<WebGPUResponse>,
|
||||||
wgc::instance::RequestAdapterOptions,
|
wgc::instance::RequestAdapterOptions,
|
||||||
SmallVec<[wgc::id::AdapterId; 4]>,
|
wgc::id::AdapterId,
|
||||||
),
|
),
|
||||||
/// Get WebGPU channel
|
/// Get WebGPU channel
|
||||||
GetWebGPUChan(IpcSender<Option<WebGPU>>),
|
GetWebGPUChan(IpcSender<Option<WebGPU>>),
|
||||||
|
|
|
@ -20,7 +20,6 @@ log = { workspace = true }
|
||||||
malloc_size_of = { workspace = true }
|
malloc_size_of = { workspace = true }
|
||||||
serde = { workspace = true, features = ["serde_derive"] }
|
serde = { workspace = true, features = ["serde_derive"] }
|
||||||
servo_config = { path = "../config" }
|
servo_config = { path = "../config" }
|
||||||
smallvec = { workspace = true, features = ["serde"] }
|
|
||||||
webrender = { workspace = true }
|
webrender = { workspace = true }
|
||||||
webrender_api = { workspace = true }
|
webrender_api = { workspace = true }
|
||||||
webrender_traits = { workspace = true }
|
webrender_traits = { workspace = true }
|
||||||
|
|
|
@ -9,7 +9,6 @@ use arrayvec::ArrayVec;
|
||||||
use base::id::PipelineId;
|
use base::id::PipelineId;
|
||||||
use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
|
use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use smallvec::SmallVec;
|
|
||||||
use webrender_api::units::DeviceIntSize;
|
use webrender_api::units::DeviceIntSize;
|
||||||
use webrender_api::{ImageFormat, ImageKey};
|
use webrender_api::{ImageFormat, ImageKey};
|
||||||
use wgc::binding_model::{
|
use wgc::binding_model::{
|
||||||
|
@ -26,6 +25,7 @@ use wgc::resource::{
|
||||||
BufferDescriptor, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
|
BufferDescriptor, SamplerDescriptor, TextureDescriptor, TextureViewDescriptor,
|
||||||
};
|
};
|
||||||
use wgpu_core::command::{RenderPassColorAttachment, RenderPassDepthStencilAttachment};
|
use wgpu_core::command::{RenderPassColorAttachment, RenderPassDepthStencilAttachment};
|
||||||
|
use wgpu_core::id::AdapterId;
|
||||||
use wgpu_core::Label;
|
use wgpu_core::Label;
|
||||||
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
pub use {wgpu_core as wgc, wgpu_types as wgt};
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ pub enum WebGPURequest {
|
||||||
RequestAdapter {
|
RequestAdapter {
|
||||||
sender: IpcSender<WebGPUResponse>,
|
sender: IpcSender<WebGPUResponse>,
|
||||||
options: RequestAdapterOptions,
|
options: RequestAdapterOptions,
|
||||||
ids: SmallVec<[id::AdapterId; 4]>,
|
adapter_id: AdapterId,
|
||||||
},
|
},
|
||||||
RequestDevice {
|
RequestDevice {
|
||||||
sender: IpcSender<WebGPUResponse>,
|
sender: IpcSender<WebGPUResponse>,
|
||||||
|
@ -287,7 +287,6 @@ pub enum WebGPURequest {
|
||||||
QueueOnSubmittedWorkDone {
|
QueueOnSubmittedWorkDone {
|
||||||
sender: IpcSender<WebGPUResponse>,
|
sender: IpcSender<WebGPUResponse>,
|
||||||
queue_id: id::QueueId,
|
queue_id: id::QueueId,
|
||||||
device_id: id::DeviceId,
|
|
||||||
},
|
},
|
||||||
PushErrorScope {
|
PushErrorScope {
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
|
|
|
@ -85,7 +85,7 @@ pub fn apply_render_command(
|
||||||
index,
|
index,
|
||||||
bind_group_id,
|
bind_group_id,
|
||||||
offsets,
|
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 {
|
RenderCommand::SetViewport {
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
|
|
|
@ -101,10 +101,7 @@ 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>,
|
||||||
adapters: Vec<WebGPUAdapter>,
|
|
||||||
devices: Arc<Mutex<HashMap<DeviceId, DeviceScope>>>,
|
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)
|
// 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
|
||||||
|
@ -155,9 +152,7 @@ impl WGPU {
|
||||||
sender,
|
sender,
|
||||||
script_sender,
|
script_sender,
|
||||||
global,
|
global,
|
||||||
adapters: Vec::new(),
|
|
||||||
devices: Arc::new(Mutex::new(HashMap::new())),
|
devices: Arc::new(Mutex::new(HashMap::new())),
|
||||||
_invalid_adapters: Vec::new(),
|
|
||||||
error_command_encoders: HashMap::new(),
|
error_command_encoders: HashMap::new(),
|
||||||
webrender_api: Arc::new(Mutex::new(webrender_api_sender.create_api())),
|
webrender_api: Arc::new(Mutex::new(webrender_api_sender.create_api())),
|
||||||
webrender_document,
|
webrender_document,
|
||||||
|
@ -636,22 +631,20 @@ impl WGPU {
|
||||||
WebGPURequest::RequestAdapter {
|
WebGPURequest::RequestAdapter {
|
||||||
sender,
|
sender,
|
||||||
options,
|
options,
|
||||||
ids,
|
adapter_id,
|
||||||
} => {
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let response = self
|
let response = self
|
||||||
.global
|
.global
|
||||||
.request_adapter(&options, wgc::instance::AdapterInputs::IdSet(&ids))
|
.request_adapter(&options, wgt::Backends::all(), Some(adapter_id))
|
||||||
.map(|adapter_id| {
|
.map(|adapter_id| {
|
||||||
let adapter = WebGPUAdapter(adapter_id);
|
|
||||||
self.adapters.push(adapter);
|
|
||||||
// TODO: can we do this lazily
|
// TODO: can we do this lazily
|
||||||
let info = global.adapter_get_info(adapter_id).unwrap();
|
let adapter_info = global.adapter_get_info(adapter_id);
|
||||||
let limits = global.adapter_limits(adapter_id).unwrap();
|
let limits = global.adapter_limits(adapter_id);
|
||||||
let features = global.adapter_features(adapter_id).unwrap();
|
let features = global.adapter_features(adapter_id);
|
||||||
Adapter {
|
Adapter {
|
||||||
adapter_info: info,
|
adapter_info,
|
||||||
adapter_id: adapter,
|
adapter_id: WebGPUAdapter(adapter_id),
|
||||||
features,
|
features,
|
||||||
limits,
|
limits,
|
||||||
channel: WebGPU(self.sender.clone()),
|
channel: WebGPU(self.sender.clone()),
|
||||||
|
@ -680,71 +673,63 @@ impl WGPU {
|
||||||
memory_hints: MemoryHints::MemoryUsage,
|
memory_hints: MemoryHints::MemoryUsage,
|
||||||
};
|
};
|
||||||
let global = &self.global;
|
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 device = WebGPUDevice(device_id);
|
||||||
let queue = WebGPUQueue(queue_id);
|
let queue = WebGPUQueue(queue_id);
|
||||||
if let Some(e) = error {
|
let result = global
|
||||||
if let Err(e) =
|
.adapter_request_device(
|
||||||
sender.send(WebGPUResponse::Device((device, queue, Err(e))))
|
adapter_id.0,
|
||||||
{
|
&desc,
|
||||||
warn!(
|
None,
|
||||||
"Failed to send response to WebGPURequest::RequestDevice ({})",
|
Some(device_id),
|
||||||
e
|
Some(queue_id),
|
||||||
)
|
)
|
||||||
}
|
.map(|_| {
|
||||||
continue;
|
{
|
||||||
}
|
self.devices.lock().unwrap().insert(
|
||||||
{
|
device_id,
|
||||||
self.devices
|
DeviceScope::new(device_id, pipeline_id),
|
||||||
.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 script_sender = self.script_sender.clone();
|
||||||
global.device_set_device_lost_closure(device_id, callback);
|
let devices = Arc::clone(&self.devices);
|
||||||
if let Err(e) =
|
let callback =
|
||||||
sender.send(WebGPUResponse::Device((device, queue, Ok(descriptor))))
|
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!(
|
warn!(
|
||||||
"Failed to send response to WebGPURequest::RequestDevice ({})",
|
"Failed to send response to WebGPURequest::RequestDevice ({})",
|
||||||
|
@ -810,7 +795,12 @@ impl WGPU {
|
||||||
if let Pass::Open { pass, valid } = pass {
|
if let Pass::Open { pass, valid } = pass {
|
||||||
*valid &= self
|
*valid &= self
|
||||||
.global
|
.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();
|
.is_ok();
|
||||||
} else {
|
} else {
|
||||||
self.maybe_dispatch_error(
|
self.maybe_dispatch_error(
|
||||||
|
@ -1058,11 +1048,7 @@ impl WGPU {
|
||||||
drop(_guard);
|
drop(_guard);
|
||||||
self.maybe_dispatch_wgpu_error(device_id, result.err());
|
self.maybe_dispatch_wgpu_error(device_id, result.err());
|
||||||
},
|
},
|
||||||
WebGPURequest::QueueOnSubmittedWorkDone {
|
WebGPURequest::QueueOnSubmittedWorkDone { sender, queue_id } => {
|
||||||
sender,
|
|
||||||
queue_id,
|
|
||||||
device_id,
|
|
||||||
} => {
|
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let token = self.poller.token();
|
let token = self.poller.token();
|
||||||
let callback = SubmittedWorkDoneClosure::from_rust(Box::from(move || {
|
let callback = SubmittedWorkDoneClosure::from_rust(Box::from(move || {
|
||||||
|
@ -1071,9 +1057,8 @@ impl WGPU {
|
||||||
warn!("Could not send SubmittedWorkDone Response ({})", e);
|
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.poller.wake();
|
||||||
self.maybe_dispatch_wgpu_error(device_id, result.err());
|
|
||||||
},
|
},
|
||||||
WebGPURequest::DropTexture(id) => {
|
WebGPURequest::DropTexture(id) => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
|
|
12
tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
vendored
12
tests/wpt/webgpu/meta/webgpu/cts.https.html.ini
vendored
|
@ -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="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"]
|
[: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"]
|
[:boundary="command-buffer";readOp="storage-read";readContext="render-bundle-encoder";writeOp="t2b-copy";writeContext="command-encoder"]
|
||||||
expected:
|
expected:
|
||||||
|
@ -3082,6 +3084,8 @@
|
||||||
if os == "linux" and not debug: [PASS, FAIL]
|
if os == "linux" and not debug: [PASS, FAIL]
|
||||||
|
|
||||||
[:boundary="command-buffer";readOp="constant-uniform";readContext="render-bundle-encoder";writeOp="t2b-copy";writeContext="command-encoder"]
|
[: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"]
|
[:boundary="command-buffer";readOp="constant-uniform";readContext="render-pass-encoder";writeOp="b2b-copy";writeContext="command-encoder"]
|
||||||
expected:
|
expected:
|
||||||
|
@ -3152,6 +3156,8 @@
|
||||||
if os == "linux" and not debug: [PASS, FAIL]
|
if os == "linux" and not debug: [PASS, FAIL]
|
||||||
|
|
||||||
[:boundary="command-buffer";readOp="storage-read";readContext="render-pass-encoder";writeOp="t2b-copy";writeContext="command-encoder"]
|
[: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"]
|
[: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:*]
|
[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:*]
|
[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:*]
|
[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:*]
|
[cts.https.html?q=webgpu:api,validation,queue,writeBuffer:buffer,device_mismatch:*]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue