Skip to content

Commit

Permalink
Move set_index_buffer FFI functions back into wgpu. (#2661)
Browse files Browse the repository at this point in the history
It's very odd to have almost all the render pass and compute pass ffi
functions in `wgpu` except for the `set_index_buffer` functions, which
live in Firefox. I'd like to remove these from Firefox and put them
back next to their companions.

These functions were originally removed from wgpu in #1077, because
wgpu-native has its own incompatible version of IndexFormat (see that
PR for details). However, with wgpu-native#85, that code was removed,
so having these functions in `wgpu` should be no longer be a problem
for wgpu-native.
  • Loading branch information
jimblandy authored May 15, 2022
1 parent 75b881e commit 202d81a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ pub mod bundle_ffi {
use super::{RenderBundleEncoder, RenderCommand};
use crate::{id, RawString};
use std::{convert::TryInto, slice};
use wgt::{BufferAddress, BufferSize, DynamicOffset};
use wgt::{BufferAddress, BufferSize, DynamicOffset, IndexFormat};

/// # Safety
///
Expand Down Expand Up @@ -1283,6 +1283,17 @@ pub mod bundle_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_render_bundle_set_index_buffer(
encoder: &mut RenderBundleEncoder,
buffer: id::BufferId,
index_format: IndexFormat,
offset: BufferAddress,
size: Option<BufferSize>,
) {
encoder.set_index_buffer(buffer, index_format, offset, size);
}

/// # Safety
///
/// This function is unsafe as there is no guarantee that the given pointer is
Expand Down
13 changes: 12 additions & 1 deletion wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ pub mod render_ffi {
};
use crate::{id, RawString};
use std::{convert::TryInto, ffi, num::NonZeroU32, slice};
use wgt::{BufferAddress, BufferSize, Color, DynamicOffset};
use wgt::{BufferAddress, BufferSize, Color, DynamicOffset, IndexFormat};

/// # Safety
///
Expand Down Expand Up @@ -2071,6 +2071,17 @@ pub mod render_ffi {
});
}

#[no_mangle]
pub extern "C" fn wgpu_render_pass_set_index_buffer(
pass: &mut RenderPass,
buffer: id::BufferId,
index_format: IndexFormat,
offset: BufferAddress,
size: Option<BufferSize>,
) {
pass.set_index_buffer(buffer, index_format, offset, size);
}

#[no_mangle]
pub extern "C" fn wgpu_render_pass_set_blend_constant(pass: &mut RenderPass, color: &Color) {
pass.base
Expand Down

0 comments on commit 202d81a

Please sign in to comment.