use std::{num::NonZeroU32, sync::Arc, thread};
use crate::*;
#[derive(Debug)]
pub struct RenderPipeline {
pub(crate) context: Arc<C>,
pub(crate) data: Box<Data>,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(RenderPipeline: Send, Sync);
super::impl_partialeq_eq_hash!(RenderPipeline);
impl Drop for RenderPipeline {
fn drop(&mut self) {
if !thread::panicking() {
self.context.render_pipeline_drop(self.data.as_ref());
}
}
}
impl RenderPipeline {
pub fn get_bind_group_layout(&self, index: u32) -> BindGroupLayout {
let context = Arc::clone(&self.context);
let data = self
.context
.render_pipeline_get_bind_group_layout(self.data.as_ref(), index);
BindGroupLayout { context, data }
}
}
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct VertexBufferLayout<'a> {
pub array_stride: BufferAddress,
pub step_mode: VertexStepMode,
pub attributes: &'a [VertexAttribute],
}
static_assertions::assert_impl_all!(VertexBufferLayout<'_>: Send, Sync);
#[derive(Clone, Debug)]
pub struct VertexState<'a> {
pub module: &'a ShaderModule,
pub entry_point: Option<&'a str>,
pub compilation_options: PipelineCompilationOptions<'a>,
pub buffers: &'a [VertexBufferLayout<'a>],
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(VertexState<'_>: Send, Sync);
#[derive(Clone, Debug)]
pub struct FragmentState<'a> {
pub module: &'a ShaderModule,
pub entry_point: Option<&'a str>,
pub compilation_options: PipelineCompilationOptions<'a>,
pub targets: &'a [Option<ColorTargetState>],
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(FragmentState<'_>: Send, Sync);
#[derive(Clone, Debug)]
pub struct RenderPipelineDescriptor<'a> {
pub label: Label<'a>,
pub layout: Option<&'a PipelineLayout>,
pub vertex: VertexState<'a>,
pub primitive: PrimitiveState,
pub depth_stencil: Option<DepthStencilState>,
pub multisample: MultisampleState,
pub fragment: Option<FragmentState<'a>>,
pub multiview: Option<NonZeroU32>,
pub cache: Option<&'a PipelineCache>,
}
#[cfg(send_sync)]
static_assertions::assert_impl_all!(RenderPipelineDescriptor<'_>: Send, Sync);