@@ -117,8 +117,7 @@ impl<'a> TrackedRenderPass<'a> {
117
117
}
118
118
119
119
/// Sets the active [`BindGroup`] for a given bind group index. The bind group layout in the
120
- /// active pipeline when any `draw()` function is called must match the layout
121
- /// of this `bind group`.
120
+ /// active pipeline when any `draw()` function is called must match the layout of this `bind group`.
122
121
pub fn set_bind_group (
123
122
& mut self ,
124
123
index : usize ,
@@ -149,40 +148,41 @@ impl<'a> TrackedRenderPass<'a> {
149
148
/// Assign a vertex buffer to a slot.
150
149
///
151
150
/// Subsequent calls to [`TrackedRenderPass::draw`] and [`TrackedRenderPass::draw_indexed`]
152
- /// will use the ` buffer` as one of the source vertex buffers .
151
+ /// will use the buffer referenced by `buffer_slice` as one of the source vertex buffer(s) .
153
152
///
154
- /// The `slot ` refers to the index of the matching descriptor in
153
+ /// The `slot_index ` refers to the index of the matching descriptor in
155
154
/// [`VertexState::buffers`](crate::render_resource::VertexState::buffers).
156
- pub fn set_vertex_buffer ( & mut self , index : usize , buffer_slice : BufferSlice < ' a > ) {
155
+ pub fn set_vertex_buffer ( & mut self , slot_index : usize , buffer_slice : BufferSlice < ' a > ) {
157
156
let offset = buffer_slice. offset ( ) ;
158
157
if self
159
158
. state
160
- . is_vertex_buffer_set ( index , buffer_slice. id ( ) , offset)
159
+ . is_vertex_buffer_set ( slot_index , buffer_slice. id ( ) , offset)
161
160
{
162
161
debug ! (
163
162
"set vertex buffer {} (already set): {:?} ({})" ,
164
- index ,
163
+ slot_index ,
165
164
buffer_slice. id( ) ,
166
165
offset
167
166
) ;
168
167
return ;
169
168
} else {
170
169
debug ! (
171
170
"set vertex buffer {}: {:?} ({})" ,
172
- index ,
171
+ slot_index ,
173
172
buffer_slice. id( ) ,
174
173
offset
175
174
) ;
176
175
}
177
- self . pass . set_vertex_buffer ( index as u32 , * buffer_slice) ;
176
+ self . pass
177
+ . set_vertex_buffer ( slot_index as u32 , * buffer_slice) ;
178
178
self . state
179
- . set_vertex_buffer ( index , buffer_slice. id ( ) , offset) ;
179
+ . set_vertex_buffer ( slot_index , buffer_slice. id ( ) , offset) ;
180
180
}
181
181
182
182
/// Sets the active index buffer.
183
183
///
184
- /// Subsequent calls to [`TrackedRenderPass::draw_indexed`] will use the ` buffer` as
185
- /// the source index buffer.
184
+ /// Subsequent calls to [`TrackedRenderPass::draw_indexed`] will use the buffer referenced by
185
+ /// `buffer_slice` as the source index buffer.
186
186
pub fn set_index_buffer (
187
187
& mut self ,
188
188
buffer_slice : BufferSlice < ' a > ,
@@ -209,7 +209,7 @@ impl<'a> TrackedRenderPass<'a> {
209
209
210
210
/// Draws primitives from the active vertex buffer(s).
211
211
///
212
- /// The active vertex buffers can be set with [`TrackedRenderPass::set_vertex_buffer`].
212
+ /// The active vertex buffer(s) can be set with [`TrackedRenderPass::set_vertex_buffer`].
213
213
pub fn draw ( & mut self , vertices : Range < u32 > , instances : Range < u32 > ) {
214
214
debug ! ( "draw: {:?} {:?}" , vertices, instances) ;
215
215
self . pass . draw ( vertices, instances) ;
@@ -218,7 +218,7 @@ impl<'a> TrackedRenderPass<'a> {
218
218
/// Draws indexed primitives using the active index buffer and the active vertex buffer(s).
219
219
///
220
220
/// The active index buffer can be set with [`TrackedRenderPass::set_index_buffer`], while the
221
- /// active vertex buffers can be set with [`TrackedRenderPass::set_vertex_buffer`].
221
+ /// active vertex buffer(s) can be set with [`TrackedRenderPass::set_vertex_buffer`].
222
222
pub fn draw_indexed ( & mut self , indices : Range < u32 > , base_vertex : i32 , instances : Range < u32 > ) {
223
223
debug ! (
224
224
"draw indexed: {:?} {} {:?}" ,
@@ -234,6 +234,7 @@ impl<'a> TrackedRenderPass<'a> {
234
234
}
235
235
236
236
/// Sets the scissor region.
237
+ ///
237
238
/// Subsequent draw calls will discard any fragments that fall outside this region.
238
239
pub fn set_scissor_rect ( & mut self , x : u32 , y : u32 , width : u32 , height : u32 ) {
239
240
debug ! ( "set_scissor_rect: {} {} {} {}" , x, y, width, height) ;
@@ -253,6 +254,9 @@ impl<'a> TrackedRenderPass<'a> {
253
254
self . pass . set_push_constants ( stages, offset, data)
254
255
}
255
256
257
+ /// Set the rendering viewport.
258
+ ///
259
+ /// Subsequent draw calls will be projected into that viewport.
256
260
pub fn set_viewport (
257
261
& mut self ,
258
262
x : f32 ,
@@ -270,16 +274,51 @@ impl<'a> TrackedRenderPass<'a> {
270
274
. set_viewport ( x, y, width, height, min_depth, max_depth)
271
275
}
272
276
277
+ /// Insert a single debug marker.
278
+ ///
279
+ /// This is a GPU debugging feature. This has no effect on the rendering itself.
273
280
pub fn insert_debug_marker ( & mut self , label : & str ) {
274
281
debug ! ( "insert debug marker: {}" , label) ;
275
282
self . pass . insert_debug_marker ( label)
276
283
}
277
284
285
+ /// Start a new debug group.
286
+ ///
287
+ /// Push a new debug group over the internal stack. Subsequent render commands and debug
288
+ /// markers are grouped into this new group, until [`pop_debug_group`] is called.
289
+ ///
290
+ /// ```
291
+ /// # fn example(mut pass: bevy_render::render_phase::TrackedRenderPass<'static>) {
292
+ /// pass.push_debug_group("Render the car");
293
+ /// // [setup pipeline etc...]
294
+ /// pass.draw(0..64, 0..1);
295
+ /// pass.pop_debug_group();
296
+ /// # }
297
+ /// ```
298
+ ///
299
+ /// Note that [`push_debug_group`] and [`pop_debug_group`] must always be called in pairs.
300
+ ///
301
+ /// This is a GPU debugging feature. This has no effect on the rendering itself.
302
+ ///
303
+ /// [`push_debug_group`]: TrackedRenderPass::push_debug_group
304
+ /// [`pop_debug_group`]: TrackedRenderPass::pop_debug_group
278
305
pub fn push_debug_group ( & mut self , label : & str ) {
279
306
debug ! ( "push_debug_group marker: {}" , label) ;
280
307
self . pass . push_debug_group ( label)
281
308
}
282
309
310
+ /// End the current debug group.
311
+ ///
312
+ /// Subsequent render commands and debug markers are not grouped anymore in
313
+ /// this group, but in the previous one (if any) or the default top-level one
314
+ /// if the debug group was the last one on the stack.
315
+ ///
316
+ /// Note that [`push_debug_group`] and [`pop_debug_group`] must always be called in pairs.
317
+ ///
318
+ /// This is a GPU debugging feature. This has no effect on the rendering itself.
319
+ ///
320
+ /// [`push_debug_group`]: TrackedRenderPass::push_debug_group
321
+ /// [`pop_debug_group`]: TrackedRenderPass::pop_debug_group
283
322
pub fn pop_debug_group ( & mut self ) {
284
323
debug ! ( "pop_debug_group" ) ;
285
324
self . pass . pop_debug_group ( )
0 commit comments