summaryrefslogtreecommitdiffstats
path: root/gfx/wgpu_bindings/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /gfx/wgpu_bindings/src
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/wgpu_bindings/src')
-rw-r--r--gfx/wgpu_bindings/src/client.rs175
-rw-r--r--gfx/wgpu_bindings/src/server.rs41
2 files changed, 196 insertions, 20 deletions
diff --git a/gfx/wgpu_bindings/src/client.rs b/gfx/wgpu_bindings/src/client.rs
index c49dbea7a5..ae1a5ef5ea 100644
--- a/gfx/wgpu_bindings/src/client.rs
+++ b/gfx/wgpu_bindings/src/client.rs
@@ -525,6 +525,20 @@ pub extern "C" fn wgpu_client_make_buffer_id(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_buffer_id(
+ client: &Client,
+ id: id::BufferId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .buffers
+ .free(id)
+}
+
+#[no_mangle]
pub extern "C" fn wgpu_client_create_texture(
client: &Client,
device_id: id::DeviceId,
@@ -555,6 +569,21 @@ pub extern "C" fn wgpu_client_create_texture(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_texture_id(
+ client: &Client,
+ id: id::TextureId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .textures
+ .free(id)
+}
+
+
+#[no_mangle]
pub extern "C" fn wgpu_client_create_texture_view(
client: &Client,
device_id: id::DeviceId,
@@ -590,6 +619,20 @@ pub extern "C" fn wgpu_client_create_texture_view(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_texture_view_id(
+ client: &Client,
+ id: id::TextureViewId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .texture_views
+ .free(id)
+}
+
+#[no_mangle]
pub extern "C" fn wgpu_client_create_sampler(
client: &Client,
device_id: id::DeviceId,
@@ -624,6 +667,20 @@ pub extern "C" fn wgpu_client_create_sampler(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_sampler_id(
+ client: &Client,
+ id: id::SamplerId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .samplers
+ .free(id)
+}
+
+#[no_mangle]
pub extern "C" fn wgpu_client_make_encoder_id(
client: &Client,
device_id: id::DeviceId,
@@ -639,6 +696,21 @@ pub extern "C" fn wgpu_client_make_encoder_id(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_command_encoder_id(
+ client: &Client,
+ id: id::CommandEncoderId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .command_buffers
+ .free(id.transmute())
+}
+
+
+#[no_mangle]
pub extern "C" fn wgpu_client_create_command_encoder(
client: &Client,
device_id: id::DeviceId,
@@ -700,6 +772,7 @@ pub extern "C" fn wgpu_device_create_render_bundle_encoder(
}
}
+
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_encoder_destroy(
pass: *mut wgc::command::RenderBundleEncoder,
@@ -755,6 +828,20 @@ pub unsafe extern "C" fn wgpu_client_create_render_bundle_error(
id
}
+#[no_mangle]
+pub extern "C" fn wgpu_client_free_render_bundle_id(
+ client: &Client,
+ id: id::RenderBundleId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .render_bundles
+ .free(id)
+}
+
#[repr(C)]
pub struct ComputePassDescriptor<'a> {
pub label: Option<&'a nsACString>,
@@ -986,6 +1073,20 @@ pub unsafe extern "C" fn wgpu_client_create_bind_group_layout(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_bind_group_layout_id(
+ client: &Client,
+ id: id::BindGroupLayoutId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .bind_group_layouts
+ .free(id)
+}
+
+#[no_mangle]
pub unsafe extern "C" fn wgpu_client_render_pipeline_get_bind_group_layout(
client: &Client,
pipeline_id: id::RenderPipelineId,
@@ -1059,6 +1160,20 @@ pub unsafe extern "C" fn wgpu_client_create_pipeline_layout(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_pipeline_layout_id(
+ client: &Client,
+ id: id::PipelineLayoutId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .pipeline_layouts
+ .free(id)
+}
+
+#[no_mangle]
pub unsafe extern "C" fn wgpu_client_create_bind_group(
client: &Client,
device_id: id::DeviceId,
@@ -1106,6 +1221,20 @@ pub unsafe extern "C" fn wgpu_client_create_bind_group(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_bind_group_id(
+ client: &Client,
+ id: id::BindGroupId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .bind_groups
+ .free(id)
+}
+
+#[no_mangle]
pub extern "C" fn wgpu_client_make_shader_module_id(
client: &Client,
device_id: id::DeviceId,
@@ -1120,6 +1249,20 @@ pub extern "C" fn wgpu_client_make_shader_module_id(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_shader_module_id(
+ client: &Client,
+ id: id::ShaderModuleId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .shader_modules
+ .free(id)
+}
+
+#[no_mangle]
pub unsafe extern "C" fn wgpu_client_create_compute_pipeline(
client: &Client,
device_id: id::DeviceId,
@@ -1161,6 +1304,20 @@ pub unsafe extern "C" fn wgpu_client_create_compute_pipeline(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_compute_pipeline_id(
+ client: &Client,
+ id: id::ComputePipelineId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .compute_pipelines
+ .free(id)
+}
+
+#[no_mangle]
pub unsafe extern "C" fn wgpu_client_create_render_pipeline(
client: &Client,
device_id: id::DeviceId,
@@ -1204,6 +1361,20 @@ pub unsafe extern "C" fn wgpu_client_create_render_pipeline(
}
#[no_mangle]
+pub extern "C" fn wgpu_client_free_render_pipeline_id(
+ client: &Client,
+ id: id::RenderPipelineId,
+) {
+ let backend = id.backend();
+ client
+ .identities
+ .lock()
+ .select(backend)
+ .render_pipelines
+ .free(id)
+}
+
+#[no_mangle]
pub unsafe extern "C" fn wgpu_command_encoder_copy_buffer_to_buffer(
src: id::BufferId,
src_offset: wgt::BufferAddress,
@@ -1346,10 +1517,6 @@ pub extern "C" fn wgpu_client_use_external_texture_in_swapChain(
return false;
}
- if !static_prefs::pref!("dom.webgpu.swap-chain.external-texture-dx12") {
- return false;
- }
-
let supported = match format {
wgt::TextureFormat::Bgra8Unorm => true,
_ => false,
diff --git a/gfx/wgpu_bindings/src/server.rs b/gfx/wgpu_bindings/src/server.rs
index 8417fe84fb..1cedf35ea5 100644
--- a/gfx/wgpu_bindings/src/server.rs
+++ b/gfx/wgpu_bindings/src/server.rs
@@ -337,29 +337,38 @@ impl ShaderModuleCompilationMessage {
fn set_error(&mut self, error: &CreateShaderModuleError, source: &str) {
// The WebGPU spec says that if the message doesn't point to a particular position in
// the source, the line number, position, offset and lengths should be zero.
- self.line_number = 0;
- self.line_pos = 0;
- self.utf16_offset = 0;
- self.utf16_length = 0;
+ let line_number;
+ let line_pos;
+ let utf16_offset;
+ let utf16_length;
if let Some(location) = error.location(source) {
- self.line_number = location.line_number as u64;
- self.line_pos = location.line_position as u64;
-
+ let len_utf16 = |s: &str| s.chars().map(|c| c.len_utf16() as u64).sum();
let start = location.offset as usize;
let end = start + location.length as usize;
- self.utf16_offset = source[0..start].chars().map(|c| c.len_utf16() as u64).sum();
- self.utf16_length = source[start..end]
- .chars()
- .map(|c| c.len_utf16() as u64)
- .sum();
+ utf16_offset = len_utf16(&source[0..start]);
+ utf16_length = len_utf16(&source[start..end]);
+
+ line_number = location.line_number as u64;
+ // Naga reports a `line_pos` using UTF-8 bytes, so we cannot use it.
+ let line_start = source[0..start].rfind('\n').map(|pos| pos + 1).unwrap_or(0);
+ line_pos = len_utf16(&source[line_start..start]) + 1;
+ } else {
+ line_number = 0;
+ line_pos = 0;
+ utf16_offset = 0;
+ utf16_length = 0;
}
- let error_string = error.to_string();
+ let message = nsString::from(&error.to_string());
- if !error_string.is_empty() {
- self.message = nsString::from(&error_string[..]);
- }
+ *self = Self {
+ line_number,
+ line_pos,
+ utf16_offset,
+ utf16_length,
+ message,
+ };
}
}