use super::{definition::VertexDefinition, VertexBufferDescription};
use crate::{
pipeline::graphics::vertex_input::{Vertex, VertexInputState},
shader::EntryPoint,
ValidationError,
};
#[deprecated(
since = "0.33.0",
note = "use `VertexBufferDescription` directly instead as returned by `Vertex::per_vertex` or `Vertex::per_instance`"
)]
#[derive(Clone, Debug, Default)]
pub struct BuffersDefinition(Vec<VertexBufferDescription>);
#[allow(deprecated)]
impl BuffersDefinition {
#[inline]
pub fn new() -> Self {
BuffersDefinition(Vec::new())
}
pub fn vertex<V: Vertex>(mut self) -> Self {
self.0.push(V::per_vertex());
self
}
pub fn instance<V: Vertex>(mut self) -> Self {
self.0.push(V::per_instance());
self
}
pub fn instance_with_divisor<V: Vertex>(mut self, divisor: u32) -> Self {
self.0.push(V::per_instance_with_divisor(divisor));
self
}
}
#[allow(deprecated)]
unsafe impl VertexDefinition for BuffersDefinition {
#[inline]
fn definition(
&self,
entry_point: &EntryPoint,
) -> Result<VertexInputState, Box<ValidationError>> {
self.0.definition(entry_point)
}
}