wgpu/api/render_bundle.rs
1use std::{sync::Arc, thread};
2
3use crate::*;
4
5/// Pre-prepared reusable bundle of GPU operations.
6///
7/// It only supports a handful of render commands, but it makes them reusable. Executing a
8/// [`RenderBundle`] is often more efficient than issuing the underlying commands manually.
9///
10/// It can be created by use of a [`RenderBundleEncoder`], and executed onto a [`CommandEncoder`]
11/// using [`RenderPass::execute_bundles`].
12///
13/// Corresponds to [WebGPU `GPURenderBundle`](https://gpuweb.github.io/gpuweb/#render-bundle).
14#[derive(Debug)]
15pub struct RenderBundle {
16 pub(crate) context: Arc<C>,
17 pub(crate) data: Box<Data>,
18}
19#[cfg(send_sync)]
20static_assertions::assert_impl_all!(RenderBundle: Send, Sync);
21
22super::impl_partialeq_eq_hash!(RenderBundle);
23
24impl Drop for RenderBundle {
25 fn drop(&mut self) {
26 if !thread::panicking() {
27 self.context.render_bundle_drop(self.data.as_ref());
28 }
29 }
30}
31
32/// Describes a [`RenderBundle`].
33///
34/// For use with [`RenderBundleEncoder::finish`].
35///
36/// Corresponds to [WebGPU `GPURenderBundleDescriptor`](
37/// https://gpuweb.github.io/gpuweb/#dictdef-gpurenderbundledescriptor).
38pub type RenderBundleDescriptor<'a> = wgt::RenderBundleDescriptor<Label<'a>>;
39static_assertions::assert_impl_all!(RenderBundleDescriptor<'_>: Send, Sync);