Skip to content

Commit

Permalink
Merge #1077
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bors[bot] and ncharlton02 authored Dec 8, 2020
2 parents 071ccf2 + b71c47a commit 69196d8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
33 changes: 16 additions & 17 deletions wgpu-core/src/command/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
37 changes: 19 additions & 18 deletions wgpu-core/src/command/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 69196d8

Please sign in to comment.