use std::{sync::Arc, thread};
use crate::*;
#[derive(Debug)]
pub struct BindGroup {
pub(crate) context: Arc<C>,
pub(crate) data: Box<Data>,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(BindGroup: Send, Sync);
super::impl_partialeq_eq_hash!(BindGroup);
impl Drop for BindGroup {
fn drop(&mut self) {
if !thread::panicking() {
self.context.bind_group_drop(self.data.as_ref());
}
}
}
#[non_exhaustive]
#[derive(Clone, Debug)]
pub enum BindingResource<'a> {
Buffer(BufferBinding<'a>),
BufferArray(&'a [BufferBinding<'a>]),
Sampler(&'a Sampler),
SamplerArray(&'a [&'a Sampler]),
TextureView(&'a TextureView),
TextureViewArray(&'a [&'a TextureView]),
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(BindingResource<'_>: Send, Sync);
#[derive(Clone, Debug)]
pub struct BufferBinding<'a> {
pub buffer: &'a Buffer,
pub offset: BufferAddress,
pub size: Option<BufferSize>,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(BufferBinding<'_>: Send, Sync);
#[derive(Clone, Debug)]
pub struct BindGroupEntry<'a> {
pub binding: u32,
pub resource: BindingResource<'a>,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(BindGroupEntry<'_>: Send, Sync);
#[derive(Clone, Debug)]
pub struct BindGroupDescriptor<'a> {
pub label: Label<'a>,
pub layout: &'a BindGroupLayout,
pub entries: &'a [BindGroupEntry<'a>],
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(BindGroupDescriptor<'_>: Send, Sync);