Bug 1614702 - WebGPU textures, texture views, and samplers r=jgilbert,webidl,smaug

this change adds an ability to create WebGPU textures, views, and samplers

Differential Revision: https://phabricator.services.mozilla.com/D63595

[ghsync] From https://hg.mozilla.org/mozilla-central/rev/7d59549f2fda3aed3927ab49b940d9024e161798
This commit is contained in:
Dzmitry Malyshau
2020-02-26 13:49:56 +00:00
committed by Dzmitry Malyshau
parent 429ca1d446
commit 7f3036449b
3 changed files with 131 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ derive_eq = true
[enum]
prefix_with_name = true
derive_helper_methods = true
add_sentinel = true
[macro_expansion]
bitflags = true

View File

@@ -32,6 +32,9 @@ struct IdentityHub {
shader_modules: IdentityManager,
compute_pipelines: IdentityManager,
render_pipelines: IdentityManager,
textures: IdentityManager,
texture_views: IdentityManager,
samplers: IdentityManager,
}
#[derive(Debug, Default)]
@@ -179,6 +182,79 @@ pub extern "C" fn wgpu_client_kill_buffer_id(client: &Client, id: id::BufferId)
.free(id)
}
#[no_mangle]
pub extern "C" fn wgpu_client_make_texture_id(client: &Client, device_id: id::DeviceId) -> id::TextureId {
let backend = device_id.backend();
client
.identities
.lock()
.select(backend)
.textures
.alloc(backend)
}
#[no_mangle]
pub extern "C" fn wgpu_client_kill_texture_id(
client: &Client,
id: id::TextureId,
) {
client
.identities
.lock()
.select(id.backend())
.textures
.free(id)
}
#[no_mangle]
pub extern "C" fn wgpu_client_make_texture_view_id(client: &Client, device_id: id::DeviceId) -> id::TextureViewId {
let backend = device_id.backend();
client
.identities
.lock()
.select(backend)
.texture_views
.alloc(backend)
}
#[no_mangle]
pub extern "C" fn wgpu_client_kill_texture_view_id(
client: &Client,
id: id::TextureViewId,
) {
client
.identities
.lock()
.select(id.backend())
.texture_views
.free(id)
}
#[no_mangle]
pub extern "C" fn wgpu_client_make_sampler_id(client: &Client, device_id: id::DeviceId) -> id::SamplerId {
let backend = device_id.backend();
client
.identities
.lock()
.select(backend)
.samplers
.alloc(backend)
}
#[no_mangle]
pub extern "C" fn wgpu_client_kill_sampler_id(
client: &Client,
id: id::SamplerId,
) {
client
.identities
.lock()
.select(id.backend())
.samplers
.free(id)
}
#[no_mangle]
pub extern "C" fn wgpu_client_make_encoder_id(
client: &Client,

View File

@@ -334,3 +334,57 @@ pub extern "C" fn wgpu_server_render_pipeline_destroy(
) {
gfx_select!(self_id => global.render_pipeline_destroy(self_id));
}
#[no_mangle]
pub extern "C" fn wgpu_server_device_create_texture(
global: &Global,
self_id: id::DeviceId,
desc: &core::resource::TextureDescriptor,
new_id: id::TextureId,
) {
gfx_select!(self_id => global.device_create_texture(self_id, desc, new_id));
}
#[no_mangle]
pub extern "C" fn wgpu_server_texture_create_view(
global: &Global,
self_id: id::TextureId,
desc: Option<&core::resource::TextureViewDescriptor>,
new_id: id::TextureViewId,
) {
gfx_select!(self_id => global.texture_create_view(self_id, desc, new_id));
}
#[no_mangle]
pub extern "C" fn wgpu_server_texture_destroy(
global: &Global,
self_id: id::TextureId,
) {
gfx_select!(self_id => global.texture_destroy(self_id));
}
#[no_mangle]
pub extern "C" fn wgpu_server_texture_view_destroy(
global: &Global,
self_id: id::TextureViewId,
) {
gfx_select!(self_id => global.texture_view_destroy(self_id));
}
#[no_mangle]
pub extern "C" fn wgpu_server_device_create_sampler(
global: &Global,
self_id: id::DeviceId,
desc: &core::resource::SamplerDescriptor,
new_id: id::SamplerId,
) {
gfx_select!(self_id => global.device_create_sampler(self_id, desc, new_id));
}
#[no_mangle]
pub extern "C" fn wgpu_server_sampler_destroy(
global: &Global,
self_id: id::SamplerId,
) {
gfx_select!(self_id => global.sampler_destroy(self_id));
}