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
[Merged by Bors] - Add multi draw indirect draw calls #6392
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,6 +283,166 @@ impl<'a> TrackedRenderPass<'a> { | |
.draw_indexed_indirect(indirect_buffer, indirect_offset); | ||
} | ||
|
||
/// Dispatches multiple draw calls from the active vertex buffer(s) based on the contents of the `indirect_buffer`. | ||
/// `count` draw calls are issued. | ||
/// | ||
/// The active vertex buffers can be set with [`TrackedRenderPass::set_vertex_buffer`]. | ||
/// | ||
/// `indirect_buffer` should contain `count` tightly packed elements of the following structure: | ||
/// | ||
/// ```rust | ||
/// #[repr(C)] | ||
/// struct DrawIndirect { | ||
/// vertex_count: u32, // The number of vertices to draw. | ||
/// instance_count: u32, // The number of instances to draw. | ||
/// first_vertex: u32, // The Index of the first vertex to draw. | ||
/// first_instance: u32, // The instance ID of the first instance to draw. | ||
/// // has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled. | ||
/// } | ||
/// ``` | ||
pub fn multi_draw_indirect( | ||
&mut self, | ||
indirect_buffer: &'a Buffer, | ||
indirect_offset: u64, | ||
count: u32, | ||
) { | ||
trace!( | ||
"multi draw indirect: {:?} {}, {}x", | ||
indirect_buffer, | ||
indirect_offset, | ||
count | ||
); | ||
self.pass | ||
.multi_draw_indirect(indirect_buffer, indirect_offset, count); | ||
} | ||
|
||
/// Disptaches multiple draw calls from the active vertex buffer(s) based on the contents of the `indirect_buffer`. | ||
/// The count buffer is read to determine how many draws to issue. | ||
/// | ||
/// The indirect buffer must be long enough to account for `max_count` draws, however only `count` will | ||
/// draws will be read. If `count` is greater than `max_count`, `max_count` will be used. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does |
||
/// | ||
/// The active vertex buffers can be set with [`TrackedRenderPass::set_vertex_buffer`]. | ||
/// | ||
/// `indirect_buffer` should contain `count` tightly packed elements of the following structure: | ||
/// | ||
/// ```rust | ||
/// #[repr(C)] | ||
/// struct DrawIndirect { | ||
/// vertex_count: u32, // The number of vertices to draw. | ||
/// instance_count: u32, // The number of instances to draw. | ||
/// first_vertex: u32, // The Index of the first vertex to draw. | ||
/// first_instance: u32, // The instance ID of the first instance to draw. | ||
/// // has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled. | ||
/// } | ||
/// ``` | ||
pub fn multi_draw_indirect_count( | ||
&mut self, | ||
indirect_buffer: &'a Buffer, | ||
indirect_offset: u64, | ||
count_buffer: &'a Buffer, | ||
count_offset: u64, | ||
max_count: u32, | ||
) { | ||
trace!( | ||
"multi draw indirect count: {:?} {}, ({:?} {})x, max {}x", | ||
indirect_buffer, | ||
indirect_offset, | ||
count_buffer, | ||
count_offset, | ||
max_count | ||
); | ||
self.pass.multi_draw_indirect_count( | ||
indirect_buffer, | ||
indirect_offset, | ||
count_buffer, | ||
count_offset, | ||
max_count, | ||
); | ||
} | ||
|
||
/// Dispatches multiple draw calls from the active index buffer and the active vertex buffers, | ||
/// based on the contents of the `indirect_buffer`. `count` draw calls are issued. | ||
/// | ||
/// The active index buffer can be set with [`TrackedRenderPass::set_index_buffer`], while the active | ||
/// vertex buffers can be set with [`TrackedRenderPass::set_vertex_buffer`]. | ||
/// | ||
/// `indirect_buffer` should contain `count` tightly packed elements of the following structure: | ||
/// | ||
/// ```rust | ||
/// #[repr(C)] | ||
/// struct DrawIndexedIndirect { | ||
/// vertex_count: u32, // The number of vertices to draw. | ||
/// instance_count: u32, // The number of instances to draw. | ||
/// first_index: u32, // The base index within the index buffer. | ||
/// vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer. | ||
/// first_instance: u32, // The instance ID of the first instance to draw. | ||
/// // has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled. | ||
/// } | ||
/// ``` | ||
pub fn multi_draw_indexed_indirect( | ||
&mut self, | ||
indirect_buffer: &'a Buffer, | ||
indirect_offset: u64, | ||
count: u32, | ||
) { | ||
trace!( | ||
"multi draw indexed indirect: {:?} {}, {}x", | ||
indirect_buffer, | ||
indirect_offset, | ||
count | ||
); | ||
self.pass | ||
.multi_draw_indexed_indirect(indirect_buffer, indirect_offset, count); | ||
} | ||
|
||
/// Dispatches multiple draw calls from the active index buffer and the active vertex buffers, | ||
/// based on the contents of the `indirect_buffer`. The count buffer is read to determine how many draws to issue. | ||
/// | ||
/// The indirect buffer must be long enough to account for `max_count` draws, however only `count` will | ||
/// draws will be read. If `count` is greater than `max_count`, `max_count` will be used. | ||
/// | ||
/// The active index buffer can be set with [`TrackedRenderPass::set_index_buffer`], while the active | ||
/// vertex buffers can be set with [`TrackedRenderPass::set_vertex_buffer`]. | ||
/// | ||
/// `indirect_buffer` should contain `count` tightly packed elements of the following structure: | ||
/// | ||
/// ```rust | ||
/// #[repr(C)] | ||
/// struct DrawIndexedIndirect { | ||
/// vertex_count: u32, // The number of vertices to draw. | ||
/// instance_count: u32, // The number of instances to draw. | ||
/// first_index: u32, // The base index within the index buffer. | ||
/// vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer. | ||
/// first_instance: u32, // The instance ID of the first instance to draw. | ||
/// // has to be 0, unless [`Features::INDIRECT_FIRST_INSTANCE`] is enabled. | ||
/// } | ||
/// ``` | ||
pub fn multi_draw_indexed_indirect_count( | ||
&mut self, | ||
indirect_buffer: &'a Buffer, | ||
indirect_offset: u64, | ||
count_buffer: &'a Buffer, | ||
count_offset: u64, | ||
max_count: u32, | ||
) { | ||
trace!( | ||
"multi draw indexed indirect count: {:?} {}, ({:?} {})x, max {}x", | ||
indirect_buffer, | ||
indirect_offset, | ||
count_buffer, | ||
count_offset, | ||
max_count | ||
); | ||
self.pass.multi_draw_indexed_indirect_count( | ||
indirect_buffer, | ||
indirect_offset, | ||
count_buffer, | ||
count_offset, | ||
max_count, | ||
); | ||
} | ||
|
||
/// Sets the stencil reference. | ||
/// | ||
/// Subsequent stencil tests will test against this value. | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dispatches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch