use super::VertexBufferDescription;
use crate::{
pipeline::graphics::vertex_input::{Vertex, VertexDefinition, VertexInputState},
shader::ShaderInterface,
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,
interface: &ShaderInterface,
) -> Result<VertexInputState, Box<ValidationError>> {
self.0.definition(interface)
}
}