wgpu/api/
render_pass.rs

1use std::ops::Range;
2
3use crate::*;
4pub use wgt::{LoadOp, Operations, StoreOp};
5
6/// In-progress recording of a render pass: a list of render commands in a [`CommandEncoder`].
7///
8/// It can be created with [`CommandEncoder::begin_render_pass()`], whose [`RenderPassDescriptor`]
9/// specifies the attachments (textures) that will be rendered to.
10///
11/// Most of the methods on `RenderPass` serve one of two purposes, identifiable by their names:
12///
13/// * `draw_*()`: Drawing (that is, encoding a render command, which, when executed by the GPU, will
14///   rasterize something and execute shaders).
15/// * `set_*()`: Setting part of the [render state](https://gpuweb.github.io/gpuweb/#renderstate)
16///   for future drawing commands.
17///
18/// A render pass may contain any number of drawing commands, and before/between each command the
19/// render state may be updated however you wish; each drawing command will be executed using the
20/// render state that has been set when the `draw_*()` function is called.
21///
22/// Corresponds to [WebGPU `GPURenderPassEncoder`](
23/// https://gpuweb.github.io/gpuweb/#render-pass-encoder).
24#[derive(Debug)]
25pub struct RenderPass<'encoder> {
26    pub(crate) inner: dispatch::DispatchRenderPass,
27
28    /// This lifetime is used to protect the [`CommandEncoder`] from being used
29    /// while the pass is alive. This needs to be PhantomDrop to prevent the lifetime
30    /// from being shortened.
31    pub(crate) _encoder_guard: PhantomDrop<&'encoder ()>,
32}
33
34#[cfg(send_sync)]
35static_assertions::assert_impl_all!(RenderPass<'_>: Send, Sync);
36
37crate::cmp::impl_eq_ord_hash_proxy!(RenderPass<'_> => .inner);
38
39impl RenderPass<'_> {
40    /// Drops the lifetime relationship to the parent command encoder, making usage of
41    /// the encoder while this pass is recorded a run-time error instead.
42    ///
43    /// Attention: As long as the render pass has not been ended, any mutating operation on the parent
44    /// command encoder will cause a run-time error and invalidate it!
45    /// By default, the lifetime constraint prevents this, but it can be useful
46    /// to handle this at run time, such as when storing the pass and encoder in the same
47    /// data structure.
48    ///
49    /// This operation has no effect on pass recording.
50    /// It's a safe operation, since [`CommandEncoder`] is in a locked state as long as the pass is active
51    /// regardless of the lifetime constraint or its absence.
52    pub fn forget_lifetime(self) -> RenderPass<'static> {
53        RenderPass {
54            inner: self.inner,
55            _encoder_guard: crate::api::PhantomDrop::default(),
56        }
57    }
58
59    /// Sets the active bind group for a given bind group index. The bind group layout
60    /// in the active pipeline when any `draw_*()` method is called must match the layout of
61    /// this bind group.
62    ///
63    /// If the bind group have dynamic offsets, provide them in binding order.
64    /// These offsets have to be aligned to [`Limits::min_uniform_buffer_offset_alignment`]
65    /// or [`Limits::min_storage_buffer_offset_alignment`] appropriately.
66    ///
67    /// Subsequent draw calls’ shader executions will be able to access data in these bind groups.
68    pub fn set_bind_group<'a, BG>(&mut self, index: u32, bind_group: BG, offsets: &[DynamicOffset])
69    where
70        Option<&'a BindGroup>: From<BG>,
71    {
72        let bg: Option<&'a BindGroup> = bind_group.into();
73        let bg = bg.map(|bg| &bg.inner);
74
75        self.inner.set_bind_group(index, bg, offsets);
76    }
77
78    /// Sets the active render pipeline.
79    ///
80    /// Subsequent draw calls will exhibit the behavior defined by `pipeline`.
81    pub fn set_pipeline(&mut self, pipeline: &RenderPipeline) {
82        self.inner.set_pipeline(&pipeline.inner);
83    }
84
85    /// Sets the blend color as used by some of the blending modes.
86    ///
87    /// Subsequent blending tests will test against this value.
88    /// If this method has not been called, the blend constant defaults to [`Color::TRANSPARENT`]
89    /// (all components zero).
90    pub fn set_blend_constant(&mut self, color: Color) {
91        self.inner.set_blend_constant(color);
92    }
93
94    /// Sets the active index buffer.
95    ///
96    /// Subsequent calls to [`draw_indexed`](RenderPass::draw_indexed) on this [`RenderPass`] will
97    /// use `buffer` as the source index buffer.
98    pub fn set_index_buffer(&mut self, buffer_slice: BufferSlice<'_>, index_format: IndexFormat) {
99        self.inner.set_index_buffer(
100            &buffer_slice.buffer.inner,
101            index_format,
102            buffer_slice.offset,
103            buffer_slice.size,
104        );
105    }
106
107    /// Assign a vertex buffer to a slot.
108    ///
109    /// Subsequent calls to [`draw`] and [`draw_indexed`] on this
110    /// [`RenderPass`] will use `buffer` as one of the source vertex buffers.
111    ///
112    /// The `slot` refers to the index of the matching descriptor in
113    /// [`VertexState::buffers`].
114    ///
115    /// [`draw`]: RenderPass::draw
116    /// [`draw_indexed`]: RenderPass::draw_indexed
117    pub fn set_vertex_buffer(&mut self, slot: u32, buffer_slice: BufferSlice<'_>) {
118        self.inner.set_vertex_buffer(
119            slot,
120            &buffer_slice.buffer.inner,
121            buffer_slice.offset,
122            buffer_slice.size,
123        );
124    }
125
126    /// Sets the scissor rectangle used during the rasterization stage.
127    /// After transformation into [viewport coordinates](https://www.w3.org/TR/webgpu/#viewport-coordinates).
128    ///
129    /// Subsequent draw calls will discard any fragments which fall outside the scissor rectangle.
130    /// If this method has not been called, the scissor rectangle defaults to the entire bounds of
131    /// the render targets.
132    ///
133    /// The function of the scissor rectangle resembles [`set_viewport()`](Self::set_viewport),
134    /// but it does not affect the coordinate system, only which fragments are discarded.
135    pub fn set_scissor_rect(&mut self, x: u32, y: u32, width: u32, height: u32) {
136        self.inner.set_scissor_rect(x, y, width, height);
137    }
138
139    /// Sets the viewport used during the rasterization stage to linearly map
140    /// from [normalized device coordinates](https://www.w3.org/TR/webgpu/#ndc) to [viewport coordinates](https://www.w3.org/TR/webgpu/#viewport-coordinates).
141    ///
142    /// Subsequent draw calls will only draw within this region.
143    /// If this method has not been called, the viewport defaults to the entire bounds of the render
144    /// targets.
145    pub fn set_viewport(&mut self, x: f32, y: f32, w: f32, h: f32, min_depth: f32, max_depth: f32) {
146        self.inner.set_viewport(x, y, w, h, min_depth, max_depth);
147    }
148
149    /// Sets the stencil reference.
150    ///
151    /// Subsequent stencil tests will test against this value.
152    /// If this method has not been called, the stencil reference value defaults to `0`.
153    pub fn set_stencil_reference(&mut self, reference: u32) {
154        self.inner.set_stencil_reference(reference);
155    }
156
157    /// Inserts debug marker.
158    pub fn insert_debug_marker(&mut self, label: &str) {
159        self.inner.insert_debug_marker(label);
160    }
161
162    /// Start record commands and group it into debug marker group.
163    pub fn push_debug_group(&mut self, label: &str) {
164        self.inner.push_debug_group(label);
165    }
166
167    /// Stops command recording and creates debug group.
168    pub fn pop_debug_group(&mut self) {
169        self.inner.pop_debug_group();
170    }
171
172    /// Draws primitives from the active vertex buffer(s).
173    ///
174    /// The active vertex buffer(s) can be set with [`RenderPass::set_vertex_buffer`].
175    /// Does not use an Index Buffer. If you need this see [`RenderPass::draw_indexed`]
176    ///
177    /// Panics if vertices Range is outside of the range of the vertices range of any set vertex buffer.
178    ///
179    /// vertices: The range of vertices to draw.
180    /// instances: Range of Instances to draw. Use 0..1 if instance buffers are not used.
181    /// E.g.of how its used internally
182    /// ```rust ignore
183    /// for instance_id in instance_range {
184    ///     for vertex_id in vertex_range {
185    ///         let vertex = vertex[vertex_id];
186    ///         vertex_shader(vertex, vertex_id, instance_id);
187    ///     }
188    /// }
189    /// ```
190    ///
191    /// This drawing command uses the current render state, as set by preceding `set_*()` methods.
192    /// It is not affected by changes to the state that are performed after it is called.
193    pub fn draw(&mut self, vertices: Range<u32>, instances: Range<u32>) {
194        self.inner.draw(vertices, instances);
195    }
196
197    /// Draws indexed primitives using the active index buffer and the active vertex buffers.
198    ///
199    /// The active index buffer can be set with [`RenderPass::set_index_buffer`]
200    /// The active vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
201    ///
202    /// Panics if indices Range is outside of the range of the indices range of any set index buffer.
203    ///
204    /// indices: The range of indices to draw.
205    /// base_vertex: value added to each index value before indexing into the vertex buffers.
206    /// instances: Range of Instances to draw. Use 0..1 if instance buffers are not used.
207    /// E.g.of how its used internally
208    /// ```rust ignore
209    /// for instance_id in instance_range {
210    ///     for index_index in index_range {
211    ///         let vertex_id = index_buffer[index_index];
212    ///         let adjusted_vertex_id = vertex_id + base_vertex;
213    ///         let vertex = vertex[adjusted_vertex_id];
214    ///         vertex_shader(vertex, adjusted_vertex_id, instance_id);
215    ///     }
216    /// }
217    /// ```
218    ///
219    /// This drawing command uses the current render state, as set by preceding `set_*()` methods.
220    /// It is not affected by changes to the state that are performed after it is called.
221    pub fn draw_indexed(&mut self, indices: Range<u32>, base_vertex: i32, instances: Range<u32>) {
222        self.inner.draw_indexed(indices, base_vertex, instances);
223    }
224
225    /// Draws primitives from the active vertex buffer(s) based on the contents of the `indirect_buffer`.
226    ///
227    /// This is like calling [`RenderPass::draw`] but the contents of the call are specified in the `indirect_buffer`.
228    /// The structure expected in `indirect_buffer` must conform to [`DrawIndirectArgs`](crate::util::DrawIndirectArgs).
229    ///
230    /// Indirect drawing has some caveats depending on the features available. We are not currently able to validate
231    /// these and issue an error.
232    /// - If [`Features::INDIRECT_FIRST_INSTANCE`] is not present on the adapter,
233    ///   [`DrawIndirect::first_instance`](crate::util::DrawIndirectArgs::first_instance) will be ignored.
234    /// - If [`DownlevelFlags::VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW`] is not present on the adapter,
235    ///   any use of `@builtin(vertex_index)` or `@builtin(instance_index)` in the vertex shader will have different values.
236    ///
237    /// See details on the individual flags for more information.
238    pub fn draw_indirect(&mut self, indirect_buffer: &Buffer, indirect_offset: BufferAddress) {
239        self.inner
240            .draw_indirect(&indirect_buffer.inner, indirect_offset);
241    }
242
243    /// Draws indexed primitives using the active index buffer and the active vertex buffers,
244    /// based on the contents of the `indirect_buffer`.
245    ///
246    /// This is like calling [`RenderPass::draw_indexed`] but the contents of the call are specified in the `indirect_buffer`.
247    /// The structure expected in `indirect_buffer` must conform to [`DrawIndexedIndirectArgs`](crate::util::DrawIndexedIndirectArgs).
248    ///
249    /// Indirect drawing has some caveats depending on the features available. We are not currently able to validate
250    /// these and issue an error.
251    /// - If [`Features::INDIRECT_FIRST_INSTANCE`] is not present on the adapter,
252    ///   [`DrawIndexedIndirect::first_instance`](crate::util::DrawIndexedIndirectArgs::first_instance) will be ignored.
253    /// - If [`DownlevelFlags::VERTEX_AND_INSTANCE_INDEX_RESPECTS_RESPECTIVE_FIRST_VALUE_IN_INDIRECT_DRAW`] is not present on the adapter,
254    ///   any use of `@builtin(vertex_index)` or `@builtin(instance_index)` in the vertex shader will have different values.
255    ///
256    /// See details on the individual flags for more information.
257    pub fn draw_indexed_indirect(
258        &mut self,
259        indirect_buffer: &Buffer,
260        indirect_offset: BufferAddress,
261    ) {
262        self.inner
263            .draw_indexed_indirect(&indirect_buffer.inner, indirect_offset);
264    }
265
266    /// Execute a [render bundle][RenderBundle], which is a set of pre-recorded commands
267    /// that can be run together.
268    ///
269    /// Commands in the bundle do not inherit this render pass's current render state, and after the
270    /// bundle has executed, the state is **cleared** (reset to defaults, not the previous state).
271    pub fn execute_bundles<'a, I: IntoIterator<Item = &'a RenderBundle>>(
272        &mut self,
273        render_bundles: I,
274    ) {
275        let mut render_bundles = render_bundles.into_iter().map(|rb| &rb.inner);
276
277        self.inner.execute_bundles(&mut render_bundles);
278    }
279}
280
281/// [`Features::MULTI_DRAW_INDIRECT`] must be enabled on the device in order to call these functions.
282impl RenderPass<'_> {
283    /// Dispatches multiple draw calls from the active vertex buffer(s) based on the contents of the `indirect_buffer`.
284    /// `count` draw calls are issued.
285    ///
286    /// The active vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
287    ///
288    /// The structure expected in `indirect_buffer` must conform to [`DrawIndirectArgs`](crate::util::DrawIndirectArgs).
289    /// These draw structures are expected to be tightly packed.
290    ///
291    /// This drawing command uses the current render state, as set by preceding `set_*()` methods.
292    /// It is not affected by changes to the state that are performed after it is called.
293    pub fn multi_draw_indirect(
294        &mut self,
295        indirect_buffer: &Buffer,
296        indirect_offset: BufferAddress,
297        count: u32,
298    ) {
299        self.inner
300            .multi_draw_indirect(&indirect_buffer.inner, indirect_offset, count);
301    }
302
303    /// Dispatches multiple draw calls from the active index buffer and the active vertex buffers,
304    /// based on the contents of the `indirect_buffer`. `count` draw calls are issued.
305    ///
306    /// The active index buffer can be set with [`RenderPass::set_index_buffer`], while the active
307    /// vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
308    ///
309    /// The structure expected in `indirect_buffer` must conform to [`DrawIndexedIndirectArgs`](crate::util::DrawIndexedIndirectArgs).
310    /// These draw structures are expected to be tightly packed.
311    ///
312    /// This drawing command uses the current render state, as set by preceding `set_*()` methods.
313    /// It is not affected by changes to the state that are performed after it is called.
314    pub fn multi_draw_indexed_indirect(
315        &mut self,
316        indirect_buffer: &Buffer,
317        indirect_offset: BufferAddress,
318        count: u32,
319    ) {
320        self.inner
321            .multi_draw_indexed_indirect(&indirect_buffer.inner, indirect_offset, count);
322    }
323}
324
325/// [`Features::MULTI_DRAW_INDIRECT_COUNT`] must be enabled on the device in order to call these functions.
326impl RenderPass<'_> {
327    /// Dispatches multiple draw calls from the active vertex buffer(s) based on the contents of the `indirect_buffer`.
328    /// The count buffer is read to determine how many draws to issue.
329    ///
330    /// The indirect buffer must be long enough to account for `max_count` draws, however only `count`
331    /// draws will be read. If `count` is greater than `max_count`, `max_count` will be used.
332    ///
333    /// The active vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
334    ///
335    /// The structure expected in `indirect_buffer` must conform to [`DrawIndirectArgs`](crate::util::DrawIndirectArgs).
336    /// These draw structures are expected to be tightly packed.
337    ///
338    /// The structure expected in `count_buffer` is the following:
339    ///
340    /// ```rust
341    /// #[repr(C)]
342    /// struct DrawIndirectCount {
343    ///     count: u32, // Number of draw calls to issue.
344    /// }
345    /// ```
346    ///
347    /// This drawing command uses the current render state, as set by preceding `set_*()` methods.
348    /// It is not affected by changes to the state that are performed after it is called.
349    pub fn multi_draw_indirect_count(
350        &mut self,
351        indirect_buffer: &Buffer,
352        indirect_offset: BufferAddress,
353        count_buffer: &Buffer,
354        count_offset: BufferAddress,
355        max_count: u32,
356    ) {
357        self.inner.multi_draw_indirect_count(
358            &indirect_buffer.inner,
359            indirect_offset,
360            &count_buffer.inner,
361            count_offset,
362            max_count,
363        );
364    }
365
366    /// Dispatches multiple draw calls from the active index buffer and the active vertex buffers,
367    /// based on the contents of the `indirect_buffer`. The count buffer is read to determine how many draws to issue.
368    ///
369    /// The indirect buffer must be long enough to account for `max_count` draws, however only `count`
370    /// draws will be read. If `count` is greater than `max_count`, `max_count` will be used.
371    ///
372    /// The active index buffer can be set with [`RenderPass::set_index_buffer`], while the active
373    /// vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
374    ///
375    ///
376    /// The structure expected in `indirect_buffer` must conform to [`DrawIndexedIndirectArgs`](crate::util::DrawIndexedIndirectArgs).
377    ///
378    /// These draw structures are expected to be tightly packed.
379    ///
380    /// The structure expected in `count_buffer` is the following:
381    ///
382    /// ```rust
383    /// #[repr(C)]
384    /// struct DrawIndexedIndirectCount {
385    ///     count: u32, // Number of draw calls to issue.
386    /// }
387    /// ```
388    ///
389    /// This drawing command uses the current render state, as set by preceding `set_*()` methods.
390    /// It is not affected by changes to the state that are performed after it is called.
391    pub fn multi_draw_indexed_indirect_count(
392        &mut self,
393        indirect_buffer: &Buffer,
394        indirect_offset: BufferAddress,
395        count_buffer: &Buffer,
396        count_offset: BufferAddress,
397        max_count: u32,
398    ) {
399        self.inner.multi_draw_indexed_indirect_count(
400            &indirect_buffer.inner,
401            indirect_offset,
402            &count_buffer.inner,
403            count_offset,
404            max_count,
405        );
406    }
407}
408
409/// [`Features::PUSH_CONSTANTS`] must be enabled on the device in order to call these functions.
410impl RenderPass<'_> {
411    /// Set push constant data for subsequent draw calls.
412    ///
413    /// Write the bytes in `data` at offset `offset` within push constant
414    /// storage, all of which are accessible by all the pipeline stages in
415    /// `stages`, and no others.  Both `offset` and the length of `data` must be
416    /// multiples of [`PUSH_CONSTANT_ALIGNMENT`], which is always 4.
417    ///
418    /// For example, if `offset` is `4` and `data` is eight bytes long, this
419    /// call will write `data` to bytes `4..12` of push constant storage.
420    ///
421    /// # Stage matching
422    ///
423    /// Every byte in the affected range of push constant storage must be
424    /// accessible to exactly the same set of pipeline stages, which must match
425    /// `stages`. If there are two bytes of storage that are accessible by
426    /// different sets of pipeline stages - say, one is accessible by fragment
427    /// shaders, and the other is accessible by both fragment shaders and vertex
428    /// shaders - then no single `set_push_constants` call may affect both of
429    /// them; to write both, you must make multiple calls, each with the
430    /// appropriate `stages` value.
431    ///
432    /// Which pipeline stages may access a given byte is determined by the
433    /// pipeline's [`PushConstant`] global variable and (if it is a struct) its
434    /// members' offsets.
435    ///
436    /// For example, suppose you have twelve bytes of push constant storage,
437    /// where bytes `0..8` are accessed by the vertex shader, and bytes `4..12`
438    /// are accessed by the fragment shader. This means there are three byte
439    /// ranges each accessed by a different set of stages:
440    ///
441    /// - Bytes `0..4` are accessed only by the fragment shader.
442    ///
443    /// - Bytes `4..8` are accessed by both the fragment shader and the vertex shader.
444    ///
445    /// - Bytes `8..12` are accessed only by the vertex shader.
446    ///
447    /// To write all twelve bytes requires three `set_push_constants` calls, one
448    /// for each range, each passing the matching `stages` mask.
449    ///
450    /// [`PushConstant`]: https://docs.rs/naga/latest/naga/enum.StorageClass.html#variant.PushConstant
451    pub fn set_push_constants(&mut self, stages: ShaderStages, offset: u32, data: &[u8]) {
452        self.inner.set_push_constants(stages, offset, data);
453    }
454}
455
456/// [`Features::TIMESTAMP_QUERY_INSIDE_PASSES`] must be enabled on the device in order to call these functions.
457impl RenderPass<'_> {
458    /// Issue a timestamp command at this point in the queue. The
459    /// timestamp will be written to the specified query set, at the specified index.
460    ///
461    /// Must be multiplied by [`Queue::get_timestamp_period`] to get
462    /// the value in nanoseconds. Absolute values have no meaning,
463    /// but timestamps can be subtracted to get the time it takes
464    /// for a string of operations to complete.
465    pub fn write_timestamp(&mut self, query_set: &QuerySet, query_index: u32) {
466        self.inner.write_timestamp(&query_set.inner, query_index);
467    }
468}
469
470impl RenderPass<'_> {
471    /// Start a occlusion query on this render pass. It can be ended with
472    /// `end_occlusion_query`. Occlusion queries may not be nested.
473    pub fn begin_occlusion_query(&mut self, query_index: u32) {
474        self.inner.begin_occlusion_query(query_index);
475    }
476
477    /// End the occlusion query on this render pass. It can be started with
478    /// `begin_occlusion_query`. Occlusion queries may not be nested.
479    pub fn end_occlusion_query(&mut self) {
480        self.inner.end_occlusion_query();
481    }
482}
483
484/// [`Features::PIPELINE_STATISTICS_QUERY`] must be enabled on the device in order to call these functions.
485impl RenderPass<'_> {
486    /// Start a pipeline statistics query on this render pass. It can be ended with
487    /// `end_pipeline_statistics_query`. Pipeline statistics queries may not be nested.
488    pub fn begin_pipeline_statistics_query(&mut self, query_set: &QuerySet, query_index: u32) {
489        self.inner
490            .begin_pipeline_statistics_query(&query_set.inner, query_index);
491    }
492
493    /// End the pipeline statistics query on this render pass. It can be started with
494    /// `begin_pipeline_statistics_query`. Pipeline statistics queries may not be nested.
495    pub fn end_pipeline_statistics_query(&mut self) {
496        self.inner.end_pipeline_statistics_query();
497    }
498}
499
500/// Describes the timestamp writes of a render pass.
501///
502/// For use with [`RenderPassDescriptor`].
503/// At least one of `beginning_of_pass_write_index` and `end_of_pass_write_index` must be `Some`.
504///
505/// Corresponds to [WebGPU `GPURenderPassTimestampWrite`](
506/// https://gpuweb.github.io/gpuweb/#dictdef-gpurenderpasstimestampwrites).
507#[derive(Clone, Debug)]
508pub struct RenderPassTimestampWrites<'a> {
509    /// The query set to write to.
510    pub query_set: &'a QuerySet,
511    /// The index of the query set at which a start timestamp of this pass is written, if any.
512    pub beginning_of_pass_write_index: Option<u32>,
513    /// The index of the query set at which an end timestamp of this pass is written, if any.
514    pub end_of_pass_write_index: Option<u32>,
515}
516#[cfg(send_sync)]
517static_assertions::assert_impl_all!(RenderPassTimestampWrites<'_>: Send, Sync);
518
519/// Describes a color attachment to a [`RenderPass`].
520///
521/// For use with [`RenderPassDescriptor`].
522///
523/// Corresponds to [WebGPU `GPURenderPassColorAttachment`](
524/// https://gpuweb.github.io/gpuweb/#color-attachments).
525#[derive(Clone, Debug)]
526pub struct RenderPassColorAttachment<'tex> {
527    /// The view to use as an attachment.
528    pub view: &'tex TextureView,
529    /// The view that will receive the resolved output if multisampling is used.
530    ///
531    /// If set, it is always written to, regardless of how [`Self::ops`] is configured.
532    pub resolve_target: Option<&'tex TextureView>,
533    /// What operations will be performed on this color attachment.
534    pub ops: Operations<Color>,
535}
536#[cfg(send_sync)]
537static_assertions::assert_impl_all!(RenderPassColorAttachment<'_>: Send, Sync);
538
539/// Describes a depth/stencil attachment to a [`RenderPass`].
540///
541/// For use with [`RenderPassDescriptor`].
542///
543/// Corresponds to [WebGPU `GPURenderPassDepthStencilAttachment`](
544/// https://gpuweb.github.io/gpuweb/#depth-stencil-attachments).
545#[derive(Clone, Debug)]
546pub struct RenderPassDepthStencilAttachment<'tex> {
547    /// The view to use as an attachment.
548    pub view: &'tex TextureView,
549    /// What operations will be performed on the depth part of the attachment.
550    pub depth_ops: Option<Operations<f32>>,
551    /// What operations will be performed on the stencil part of the attachment.
552    pub stencil_ops: Option<Operations<u32>>,
553}
554#[cfg(send_sync)]
555static_assertions::assert_impl_all!(RenderPassDepthStencilAttachment<'_>: Send, Sync);
556
557/// Describes the attachments of a render pass.
558///
559/// For use with [`CommandEncoder::begin_render_pass`].
560///
561/// Corresponds to [WebGPU `GPURenderPassDescriptor`](
562/// https://gpuweb.github.io/gpuweb/#dictdef-gpurenderpassdescriptor).
563#[derive(Clone, Debug, Default)]
564pub struct RenderPassDescriptor<'a> {
565    /// Debug label of the render pass. This will show up in graphics debuggers for easy identification.
566    pub label: Label<'a>,
567    /// The color attachments of the render pass.
568    pub color_attachments: &'a [Option<RenderPassColorAttachment<'a>>],
569    /// The depth and stencil attachment of the render pass, if any.
570    pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachment<'a>>,
571    /// Defines which timestamp values will be written for this pass, and where to write them to.
572    ///
573    /// Requires [`Features::TIMESTAMP_QUERY`] to be enabled.
574    pub timestamp_writes: Option<RenderPassTimestampWrites<'a>>,
575    /// Defines where the occlusion query results will be stored for this pass.
576    pub occlusion_query_set: Option<&'a QuerySet>,
577}
578#[cfg(send_sync)]
579static_assertions::assert_impl_all!(RenderPassDescriptor<'_>: Send, Sync);