Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RenderPass draw, draw_indexed, set_viewport and set_scissor_rect documentation #3860

Merged
merged 16 commits into from
Jun 17, 2023
Merged
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3106,7 +3106,8 @@ impl<'a> RenderPass<'a> {

/// Sets the scissor region.
///
/// Subsequent draw calls will discard any fragments that fall outside this region.
/// Subsequent draw calls will discard any fragments that fall outside this region
/// as framebuffer space.
genusistimelord marked this conversation as resolved.
Show resolved Hide resolved
pub fn set_scissor_rect(&mut self, x: u32, y: u32, width: u32, height: u32) {
DynContext::render_pass_set_scissor_rect(
&*self.parent.context,
Expand All @@ -3119,7 +3120,7 @@ impl<'a> RenderPass<'a> {
);
}

/// Sets the viewport region.
/// Sets the viewport region of framebuffer space.
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
///
/// Subsequent draw calls will draw any fragments in this region.
pub fn set_viewport(&mut self, x: f32, y: f32, w: f32, h: f32, min_depth: f32, max_depth: f32) {
Expand Down Expand Up @@ -3150,7 +3151,16 @@ impl<'a> RenderPass<'a> {

/// Draws primitives from the active vertex buffer(s).
///
/// The active vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
/// The active vertex buffer(s) can be set with [`RenderPass::set_vertex_buffer`].
/// Does not use an Index Buffer. If you need this see [`RenderPass::draw_indexed`]
///
/// Panics if vertices Range is not within 0..BufferLen / BufferStride.
genusistimelord marked this conversation as resolved.
Show resolved Hide resolved
///
/// vertices: The range of vertices being used from the Vertex Buffer.
/// instances: Change the vertex data used for any instance-rate vertex attributes
/// from a set instance buffer. The instance index is passed to the vertex
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
/// shader through the instance_index builtin. Use 0..1 if instance
/// buffers are not used.
pub fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>) {
DynContext::render_pass_draw(
&*self.parent.context,
Expand Down Expand Up @@ -3192,8 +3202,18 @@ impl<'a> RenderPass<'a> {

/// Draws indexed primitives using the active index buffer and the active vertex buffers.
///
/// The active index buffer can be set with [`RenderPass::set_index_buffer`], while the active
/// vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
/// The active index buffer can be set with [`RenderPass::set_index_buffer`]
/// The active vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
///
/// Panics if indices Range is not within 0..BufferLen / BufferStride.
genusistimelord marked this conversation as resolved.
Show resolved Hide resolved
///
/// indices: The indices range within the index buffer.
/// base_vertex: Addition upon the next set of Index's. example: 0,1,2,0,2,3 on next instance
genusistimelord marked this conversation as resolved.
Show resolved Hide resolved
/// becomes 4,5,6,4,6,7 if base_vertex is set to 4 on the next index offset.
/// instances: Change the vertex data used for any instance-rate vertex attributes
/// from a set instance buffer. The instance index is passed to the vertex
/// shader through the instance_index builtin. use 0..1 if instance
/// buffers are not used.
Wumpf marked this conversation as resolved.
Show resolved Hide resolved
pub fn draw_indexed(&mut self, indices: Range<u32>, base_vertex: i32, instances: Range<u32>) {
DynContext::render_pass_draw_indexed(
&*self.parent.context,
Expand Down Expand Up @@ -3787,6 +3807,15 @@ impl<'a> RenderBundleEncoder<'a> {
/// Draws primitives from the active vertex buffer(s).
///
/// The active vertex buffers can be set with [`RenderBundleEncoder::set_vertex_buffer`].
/// Does not use an Index Buffer. If you need this see [`RenderBundleEncoder::draw_indexed`]
///
/// Panics if vertices Range is not within 0..BufferLen / BufferStride.
///
/// vertices: The range of vertices being used from the Vertex Buffer.
/// instances: Change the vertex data used for any instance-rate vertex attributes
/// from a set instance buffer. The instance index is passed to the vertex
/// shader through the instance_index builtin. Use 0..1 if instance
/// buffers are not used.
pub fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>) {
DynContext::render_bundle_encoder_draw(
&*self.parent.context,
Expand All @@ -3799,8 +3828,18 @@ impl<'a> RenderBundleEncoder<'a> {

/// Draws indexed primitives using the active index buffer and the active vertex buffers.
///
/// The active index buffer can be set with [`RenderBundleEncoder::set_index_buffer`], while the active
/// vertex buffers can be set with [`RenderBundleEncoder::set_vertex_buffer`].
/// The active index buffer can be set with [`RenderBundleEncoder::set_index_buffer`].
/// The active vertex buffers can be set with [`RenderBundleEncoder::set_vertex_buffer`].
///
/// Panics if indices Range is not within 0..BufferLen / BufferStride.
///
/// indices: The indices range within the index buffer.
/// base_vertex: Addition upon the next set of Index's. example: 0,1,2,0,2,3 on next instance
/// becomes 4,5,6,4,6,7 if base_vertex is set to 4 on the next index offset.
/// instances: Change the vertex data used for any instance-rate vertex attributes
/// from a set instance buffer. The instance index is passed to the vertex
/// shader through the instance_index builtin. use 0..1 if instance
/// buffers are not used.
pub fn draw_indexed(&mut self, indices: Range<u32>, base_vertex: i32, instances: Range<u32>) {
DynContext::render_bundle_encoder_draw_indexed(
&*self.parent.context,
Expand Down