From 605620b20c2ecc0bc384eabcd31e5a609182b251 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 28 Nov 2019 17:18:25 -0500 Subject: [PATCH] Buffer creation in wgpu-remote --- wgpu-core/src/command/transfer.rs | 3 --- wgpu-remote/src/lib.rs | 32 ++++++++++++++++++++++++++----- wgpu-remote/src/server.rs | 10 ++++++++++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/wgpu-core/src/command/transfer.rs b/wgpu-core/src/command/transfer.rs index d594e12bc..41220fcd0 100644 --- a/wgpu-core/src/command/transfer.rs +++ b/wgpu-core/src/command/transfer.rs @@ -169,7 +169,6 @@ impl Global { range: pending.selector, }); - let aspects = dst_texture.full_range.aspects; let bytes_per_texel = conv::map_texture_format(dst_texture.format, cmb.features) .surface_desc() .bits as u32 @@ -246,7 +245,6 @@ impl Global { range: None .. None, }); - let aspects = src_texture.full_range.aspects; let bytes_per_texel = conv::map_texture_format(src_texture.format, cmb.features) .surface_desc() .bits as u32 @@ -328,7 +326,6 @@ impl Global { range: pending.selector, })); - let aspects = src_texture.full_range.aspects & dst_texture.full_range.aspects; let region = hal::command::ImageCopy { src_subresource: source.to_sub_layers(aspects), src_offset: conv::map_origin(source.origin), diff --git a/wgpu-remote/src/lib.rs b/wgpu-remote/src/lib.rs index 5469a67fd..38a62f497 100644 --- a/wgpu-remote/src/lib.rs +++ b/wgpu-remote/src/lib.rs @@ -4,7 +4,7 @@ use core::{ hub::IdentityManager, - id::{AdapterId, DeviceId}, + id, Backend, }; @@ -19,6 +19,7 @@ pub mod server; struct IdentityHub { adapters: IdentityManager, devices: IdentityManager, + buffers: IdentityManager, } #[derive(Debug, Default)] @@ -77,7 +78,7 @@ pub extern "C" fn wgpu_client_delete(client: *mut Client) { #[no_mangle] pub extern "C" fn wgpu_client_make_adapter_ids( client: &Client, - ids: *mut AdapterId, + ids: *mut id::AdapterId, id_length: usize, ) -> usize { let mut identities = client.identities.lock(); @@ -101,7 +102,7 @@ pub extern "C" fn wgpu_client_make_adapter_ids( #[no_mangle] pub extern "C" fn wgpu_client_kill_adapter_ids( client: &Client, - ids: *const AdapterId, + ids: *const id::AdapterId, id_length: usize, ) { let mut identity = client.identities.lock(); @@ -112,7 +113,7 @@ pub extern "C" fn wgpu_client_kill_adapter_ids( } #[no_mangle] -pub extern "C" fn wgpu_client_make_device_id(client: &Client, adapter_id: AdapterId) -> DeviceId { +pub extern "C" fn wgpu_client_make_device_id(client: &Client, adapter_id: id::AdapterId) -> id::DeviceId { let backend = adapter_id.backend(); client .identities @@ -123,7 +124,7 @@ pub extern "C" fn wgpu_client_make_device_id(client: &Client, adapter_id: Adapte } #[no_mangle] -pub extern "C" fn wgpu_client_kill_device_id(client: &Client, id: DeviceId) { +pub extern "C" fn wgpu_client_kill_device_id(client: &Client, id: id::DeviceId) { client .identities .lock() @@ -131,3 +132,24 @@ pub extern "C" fn wgpu_client_kill_device_id(client: &Client, id: DeviceId) { .devices .free(id) } + +#[no_mangle] +pub extern "C" fn wgpu_client_make_buffer_id(client: &Client, device_id: id::DeviceId) -> id::BufferId { + let backend = device_id.backend(); + client + .identities + .lock() + .select(backend) + .buffers + .alloc(backend) +} + +#[no_mangle] +pub extern "C" fn wgpu_client_kill_buffer_id(client: &Client, id: id::BufferId) { + client + .identities + .lock() + .select(id.backend()) + .buffers + .free(id) +} diff --git a/wgpu-remote/src/server.rs b/wgpu-remote/src/server.rs index 39eb40ddd..bac28bd96 100644 --- a/wgpu-remote/src/server.rs +++ b/wgpu-remote/src/server.rs @@ -54,3 +54,13 @@ pub extern "C" fn wgpu_server_adapter_request_device( pub extern "C" fn wgpu_server_device_destroy(global: &Global<()>, self_id: id::DeviceId) { gfx_select!(self_id => global.device_destroy(self_id)) } + +#[no_mangle] +pub extern "C" fn wgpu_server_device_create_buffer( + global: &Global<()>, + self_id: id::DeviceId, + desc: &core::resource::BufferDescriptor, + new_id: id::BufferId, +) { + gfx_select!(self_id => global.device_create_buffer(self_id, desc, new_id)); +}