mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
Merge #506
506: Bug 1614702 - WebGPU textures, texture views, and samplers r=gecko a=kvark This is a commit cherry-picked from #504 Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
This commit is contained in:
commit
3d896d4ce1
@ -40,6 +40,7 @@ derive_eq = true
|
|||||||
[enum]
|
[enum]
|
||||||
prefix_with_name = true
|
prefix_with_name = true
|
||||||
derive_helper_methods = true
|
derive_helper_methods = true
|
||||||
|
add_sentinel = true
|
||||||
|
|
||||||
[macro_expansion]
|
[macro_expansion]
|
||||||
bitflags = true
|
bitflags = true
|
||||||
|
@ -32,6 +32,9 @@ struct IdentityHub {
|
|||||||
shader_modules: IdentityManager,
|
shader_modules: IdentityManager,
|
||||||
compute_pipelines: IdentityManager,
|
compute_pipelines: IdentityManager,
|
||||||
render_pipelines: IdentityManager,
|
render_pipelines: IdentityManager,
|
||||||
|
textures: IdentityManager,
|
||||||
|
texture_views: IdentityManager,
|
||||||
|
samplers: IdentityManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
@ -179,6 +182,79 @@ pub extern "C" fn wgpu_client_kill_buffer_id(client: &Client, id: id::BufferId)
|
|||||||
.free(id)
|
.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]
|
#[no_mangle]
|
||||||
pub extern "C" fn wgpu_client_make_encoder_id(
|
pub extern "C" fn wgpu_client_make_encoder_id(
|
||||||
client: &Client,
|
client: &Client,
|
||||||
|
@ -334,3 +334,57 @@ pub extern "C" fn wgpu_server_render_pipeline_destroy(
|
|||||||
) {
|
) {
|
||||||
gfx_select!(self_id => global.render_pipeline_destroy(self_id));
|
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));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user