1077: Remove extern "C" from set_index_buffer r=kvark a=DevOrc

**Connections**
Fixes an issue that is blocking gfx-rs/wgpu-native#61

**Description**
Moves the ffi definition of wgpu_render_bundle_set_index_buffer / wgpu_render_pass_set_index_buffer to wgpu-native. This is needed because wgpu-native has its own version of IndexFormat that is different than the wgpu_types version. 

**Testing**
My projects with wgpu-native work


Co-authored-by: Noah Charlton <ncharlton002@gmail.com>
This commit is contained in:
bors[bot] 2020-12-08 15:45:00 +00:00 committed by GitHub
commit 69196d85a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 35 deletions

View File

@ -436,6 +436,22 @@ impl RenderBundleEncoder {
life_guard: LifeGuard::new(desc.label.borrow_or_default()),
})
}
pub fn set_index_buffer(
&mut self,
buffer_id: id::BufferId,
index_format: wgt::IndexFormat,
offset: wgt::BufferAddress,
size: Option<wgt::BufferSize>,
) {
span!(_guard, DEBUG, "RenderBundle::set_index_buffer");
self.base.commands.push(RenderCommand::SetIndexBuffer {
buffer_id,
index_format,
offset,
size,
});
}
}
/// Error type returned from `RenderBundleEncoder::new` if the sample count is invalid.
@ -1076,23 +1092,6 @@ pub mod bundle_ffi {
.push(RenderCommand::SetPipeline(pipeline_id));
}
#[no_mangle]
pub extern "C" fn wgpu_render_bundle_set_index_buffer(
bundle: &mut RenderBundleEncoder,
buffer_id: id::BufferId,
index_format: wgt::IndexFormat,
offset: BufferAddress,
size: Option<BufferSize>,
) {
span!(_guard, DEBUG, "RenderBundle::set_index_buffer");
bundle.base.commands.push(RenderCommand::SetIndexBuffer {
buffer_id,
index_format,
offset,
size,
});
}
#[no_mangle]
pub extern "C" fn wgpu_render_bundle_set_vertex_buffer(
bundle: &mut RenderBundleEncoder,

View File

@ -29,7 +29,9 @@ use crate::{
use arrayvec::ArrayVec;
use hal::command::CommandBuffer as _;
use thiserror::Error;
use wgt::{BufferAddress, BufferUsage, Color, IndexFormat, InputStepMode, TextureUsage};
use wgt::{
BufferAddress, BufferSize, BufferUsage, Color, IndexFormat, InputStepMode, TextureUsage,
};
#[cfg(any(feature = "serial-pass", feature = "replay"))]
use serde::Deserialize;
@ -172,6 +174,22 @@ impl RenderPass {
target_depth_stencil: self.depth_stencil_target,
}
}
pub fn set_index_buffer(
&mut self,
buffer_id: id::BufferId,
index_format: IndexFormat,
offset: BufferAddress,
size: Option<BufferSize>,
) {
span!(_guard, DEBUG, "RenderPass::set_index_buffer");
self.base.commands.push(RenderCommand::SetIndexBuffer {
buffer_id,
index_format,
offset,
size,
});
}
}
impl fmt::Debug for RenderPass {
@ -1756,23 +1774,6 @@ pub mod render_ffi {
.push(RenderCommand::SetPipeline(pipeline_id));
}
#[no_mangle]
pub extern "C" fn wgpu_render_pass_set_index_buffer(
pass: &mut RenderPass,
buffer_id: id::BufferId,
index_format: wgt::IndexFormat,
offset: BufferAddress,
size: Option<BufferSize>,
) {
span!(_guard, DEBUG, "RenderPass::set_index_buffer");
pass.base.commands.push(RenderCommand::SetIndexBuffer {
buffer_id,
index_format,
offset,
size,
});
}
#[no_mangle]
pub extern "C" fn wgpu_render_pass_set_vertex_buffer(
pass: &mut RenderPass,