// Copyright (c) 2016 The vulkano developers // Licensed under the Apache License, Version 2.0 // or the MIT // license , // at your option. All files in the project carrying such // notice may not be copied, modified, or distributed except // according to those terms. use super::VertexBufferDescription; use crate::{ pipeline::graphics::vertex_input::{ IncompatibleVertexDefinitionError, Vertex, VertexDefinition, VertexInputState, }, shader::ShaderInterface, }; /// A vertex definition for any number of vertex and instance buffers. #[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); #[allow(deprecated)] impl BuffersDefinition { /// Constructs a new definition. #[inline] pub fn new() -> Self { BuffersDefinition(Vec::new()) } /// Adds a new vertex buffer containing elements of type `V` to the definition. pub fn vertex(mut self) -> Self { self.0.push(V::per_vertex()); self } /// Adds a new instance buffer containing elements of type `V` to the definition. pub fn instance(mut self) -> Self { self.0.push(V::per_instance()); self } /// Adds a new instance buffer containing elements of type `V` to the definition, with the /// specified input rate divisor. /// /// This requires the [`vertex_attribute_instance_rate_divisor`] feature has been enabled on /// the device, unless `divisor` is 1. /// /// `divisor` can be 0 if the [`vertex_attribute_instance_rate_zero_divisor`] feature is also /// enabled. This means that every vertex will use the same vertex and instance data. /// /// [`vertex_attribute_instance_rate_divisor`]: crate::device::Features::vertex_attribute_instance_rate_divisor /// [`vertex_attribute_instance_rate_zero_divisor`]: crate::device::Features::vertex_attribute_instance_rate_zero_divisor pub fn instance_with_divisor(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 { self.0.definition(interface) } }