aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/identityhub.rs
diff options
context:
space:
mode:
authorIstvan Miklos <istvan.miklos@h-lab.eu>2019-11-15 15:09:04 +0100
committerIstvan Miklos <istvan.miklos@h-lab.eu>2019-12-17 11:00:08 +0100
commitebfcd0f27f654bcf14fef7dcb2fca3ad2c88f4bf (patch)
tree7901145807112fcaca7d1a7545dfb1b19e92f38b /components/script/dom/identityhub.rs
parent6ccad53937c2dcc8d1d24d9d924e236927211cf8 (diff)
downloadservo-ebfcd0f27f654bcf14fef7dcb2fca3ad2c88f4bf.tar.gz
servo-ebfcd0f27f654bcf14fef7dcb2fca3ad2c88f4bf.zip
Initial implementation of GPUBuffer for WebGPU
Added WebIDL bindings for GPUBuffer, GPUBufferDescriptor, GPUBufferUsage Implemented the `createBuffer` and `createBufferMapped` functions of GPUDevice
Diffstat (limited to 'components/script/dom/identityhub.rs')
-rw-r--r--components/script/dom/identityhub.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/components/script/dom/identityhub.rs b/components/script/dom/identityhub.rs
index b2f310330e9..64e4cad3867 100644
--- a/components/script/dom/identityhub.rs
+++ b/components/script/dom/identityhub.rs
@@ -5,7 +5,7 @@
use smallvec::SmallVec;
use webgpu::wgpu::{
hub::IdentityManager,
- id::{AdapterId, DeviceId},
+ id::{AdapterId, BufferId, DeviceId},
Backend,
};
@@ -13,6 +13,7 @@ use webgpu::wgpu::{
pub struct IdentityHub {
adapters: IdentityManager,
devices: IdentityManager,
+ buffers: IdentityManager,
backend: Backend,
}
@@ -21,6 +22,7 @@ impl IdentityHub {
IdentityHub {
adapters: IdentityManager::default(),
devices: IdentityManager::default(),
+ buffers: IdentityManager::default(),
backend,
}
}
@@ -32,6 +34,10 @@ impl IdentityHub {
fn create_device_id(&mut self) -> DeviceId {
self.devices.alloc(self.backend)
}
+
+ pub fn create_buffer_id(&mut self) -> BufferId {
+ self.buffers.alloc(self.backend)
+ }
}
#[derive(Debug)]
@@ -99,4 +105,18 @@ impl Identities {
}
ids
}
+
+ pub fn create_buffer_id(&mut self, backend: Backend) -> BufferId {
+ match backend {
+ #[cfg(any(target_os = "linux", target_os = "windows"))]
+ Backend::Vulkan => self.vk_hub.create_buffer_id(),
+ #[cfg(target_os = "windows")]
+ Backend::Dx12 => self.dx12_hub.create_buffer_id(),
+ #[cfg(target_os = "windows")]
+ Backend::Dx11 => self.dx11_hub.create_buffer_id(),
+ #[cfg(any(target_os = "ios", target_os = "macos"))]
+ Backend::Metal => self.metal_hub.create_buffer_id(),
+ _ => self.dummy_hub.create_buffer_id(),
+ }
+ }
}