Skip to content

Commit

Permalink
Remove exposed C symbols from bundle/renderpass/computepass recording
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Mar 17, 2024
1 parent e68e628 commit a23b0ca
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 104 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Bottom level categories:
- Fix registry leaks with de-duplicated resources. By @nical in [#5244](https://github.com/gfx-rs/wgpu/pull/5244)
- Fix behavior of integer `clamp` when `min` argument > `max` argument. By @cwfitzgerald in [#5300](https://github.com/gfx-rs/wgpu/pull/5300).
- Fix linking when targeting android. By @ashdnazg in [#5326](https://github.com/gfx-rs/wgpu/pull/5326).
- Remove exposed C symbols (`extern "C"` + [no_mangle]) from Bundle/RenderPass/ComputePass recording, potentially causing linking issues and unnecessary symbol exports in applications using wgpu. For a wgpu C interface refer to [`wgpu-native`](https://github.com/gfx-rs/wgpu-native/). By @wumpf in [#????](https://github.com/gfx-rs/wgpu/pull/????).

#### Naga
- In spv-in, remove unnecessary "gl_PerVertex" name check so unused builtins will always be skipped. By @Imberflur in [#5227](https://github.com/gfx-rs/wgpu/pull/5227).
Expand Down
36 changes: 12 additions & 24 deletions wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1537,8 +1537,7 @@ pub mod bundle_ffi {
///
/// This function is unsafe as there is no guarantee that the given pointer is
/// valid for `offset_length` elements.
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_set_bind_group(
pub unsafe fn wgpu_render_bundle_set_bind_group(
bundle: &mut RenderBundleEncoder,
index: u32,
bind_group_id: id::BindGroupId,
Expand Down Expand Up @@ -1566,8 +1565,7 @@ pub mod bundle_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_set_pipeline(
pub fn wgpu_render_bundle_set_pipeline(
bundle: &mut RenderBundleEncoder,
pipeline_id: id::RenderPipelineId,
) {
Expand All @@ -1581,8 +1579,7 @@ pub mod bundle_ffi {
.push(RenderCommand::SetPipeline(pipeline_id));
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_set_vertex_buffer(
pub fn wgpu_render_bundle_set_vertex_buffer(
bundle: &mut RenderBundleEncoder,
slot: u32,
buffer_id: id::BufferId,
Expand All @@ -1597,8 +1594,7 @@ pub mod bundle_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_set_index_buffer(
pub fn wgpu_render_bundle_set_index_buffer(
encoder: &mut RenderBundleEncoder,
buffer: id::BufferId,
index_format: IndexFormat,
Expand All @@ -1612,8 +1608,7 @@ pub mod bundle_ffi {
///
/// This function is unsafe as there is no guarantee that the given pointer is
/// valid for `data` elements.
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_set_push_constants(
pub unsafe fn wgpu_render_bundle_set_push_constants(
pass: &mut RenderBundleEncoder,
stages: wgt::ShaderStages,
offset: u32,
Expand Down Expand Up @@ -1649,8 +1644,7 @@ pub mod bundle_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_draw(
pub fn wgpu_render_bundle_draw(
bundle: &mut RenderBundleEncoder,
vertex_count: u32,
instance_count: u32,
Expand All @@ -1665,8 +1659,7 @@ pub mod bundle_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_draw_indexed(
pub fn wgpu_render_bundle_draw_indexed(
bundle: &mut RenderBundleEncoder,
index_count: u32,
instance_count: u32,
Expand All @@ -1683,8 +1676,7 @@ pub mod bundle_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_draw_indirect(
pub fn wgpu_render_bundle_draw_indirect(
bundle: &mut RenderBundleEncoder,
buffer_id: id::BufferId,
offset: BufferAddress,
Expand All @@ -1697,8 +1689,7 @@ pub mod bundle_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_draw_indexed_indirect(
pub fn wgpu_render_bundle_draw_indexed_indirect(
bundle: &mut RenderBundleEncoder,
buffer_id: id::BufferId,
offset: BufferAddress,
Expand All @@ -1715,25 +1706,22 @@ pub mod bundle_ffi {
///
/// This function is unsafe as there is no guarantee that the given `label`
/// is a valid null-terminated string.
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_push_debug_group(
pub unsafe fn wgpu_render_bundle_push_debug_group(
_bundle: &mut RenderBundleEncoder,
_label: RawString,
) {
//TODO
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_pop_debug_group(_bundle: &mut RenderBundleEncoder) {
pub fn wgpu_render_bundle_pop_debug_group(_bundle: &mut RenderBundleEncoder) {
//TODO
}

/// # Safety
///
/// This function is unsafe as there is no guarantee that the given `label`
/// is a valid null-terminated string.
#[no_mangle]
pub unsafe extern "C" fn wgpu_render_bundle_insert_debug_marker(
pub unsafe fn wgpu_render_bundle_insert_debug_marker(
_bundle: &mut RenderBundleEncoder,
_label: RawString,
) {
Expand Down
33 changes: 11 additions & 22 deletions wgpu-core/src/command/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,7 @@ pub mod compute_ffi {
///
/// This function is unsafe as there is no guarantee that the given pointer is
/// valid for `offset_length` elements.
#[no_mangle]
pub unsafe extern "C" fn wgpu_compute_pass_set_bind_group(
pub unsafe fn wgpu_compute_pass_set_bind_group(
pass: &mut ComputePass,
index: u32,
bind_group_id: id::BindGroupId,
Expand Down Expand Up @@ -921,8 +920,7 @@ pub mod compute_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_set_pipeline(
pub fn wgpu_compute_pass_set_pipeline(
pass: &mut ComputePass,
pipeline_id: id::ComputePipelineId,
) {
Expand All @@ -939,8 +937,7 @@ pub mod compute_ffi {
///
/// This function is unsafe as there is no guarantee that the given pointer is
/// valid for `size_bytes` bytes.
#[no_mangle]
pub unsafe extern "C" fn wgpu_compute_pass_set_push_constant(
pub unsafe fn wgpu_compute_pass_set_push_constant(
pass: &mut ComputePass,
offset: u32,
size_bytes: u32,
Expand Down Expand Up @@ -974,8 +971,7 @@ pub mod compute_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_dispatch_workgroups(
pub fn wgpu_compute_pass_dispatch_workgroups(
pass: &mut ComputePass,
groups_x: u32,
groups_y: u32,
Expand All @@ -986,8 +982,7 @@ pub mod compute_ffi {
.push(ComputeCommand::Dispatch([groups_x, groups_y, groups_z]));
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_dispatch_workgroups_indirect(
pub fn wgpu_compute_pass_dispatch_workgroups_indirect(
pass: &mut ComputePass,
buffer_id: id::BufferId,
offset: BufferAddress,
Expand All @@ -1001,8 +996,7 @@ pub mod compute_ffi {
///
/// This function is unsafe as there is no guarantee that the given `label`
/// is a valid null-terminated string.
#[no_mangle]
pub unsafe extern "C" fn wgpu_compute_pass_push_debug_group(
pub unsafe fn wgpu_compute_pass_push_debug_group(
pass: &mut ComputePass,
label: RawString,
color: u32,
Expand All @@ -1016,17 +1010,15 @@ pub mod compute_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_pop_debug_group(pass: &mut ComputePass) {
pub fn wgpu_compute_pass_pop_debug_group(pass: &mut ComputePass) {
pass.base.commands.push(ComputeCommand::PopDebugGroup);
}

/// # Safety
///
/// This function is unsafe as there is no guarantee that the given `label`
/// is a valid null-terminated string.
#[no_mangle]
pub unsafe extern "C" fn wgpu_compute_pass_insert_debug_marker(
pub unsafe fn wgpu_compute_pass_insert_debug_marker(
pass: &mut ComputePass,
label: RawString,
color: u32,
Expand All @@ -1040,8 +1032,7 @@ pub mod compute_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_write_timestamp(
pub fn wgpu_compute_pass_write_timestamp(
pass: &mut ComputePass,
query_set_id: id::QuerySetId,
query_index: u32,
Expand All @@ -1052,8 +1043,7 @@ pub mod compute_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_begin_pipeline_statistics_query(
pub fn wgpu_compute_pass_begin_pipeline_statistics_query(
pass: &mut ComputePass,
query_set_id: id::QuerySetId,
query_index: u32,
Expand All @@ -1066,8 +1056,7 @@ pub mod compute_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_compute_pass_end_pipeline_statistics_query(pass: &mut ComputePass) {
pub fn wgpu_compute_pass_end_pipeline_statistics_query(pass: &mut ComputePass) {
pass.base
.commands
.push(ComputeCommand::EndPipelineStatisticsQuery);
Expand Down
Loading

0 comments on commit a23b0ca

Please sign in to comment.