Skip to content

Commit

Permalink
Implement vertex traits on GraphicsPipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka committed Feb 1, 2017
1 parent 6e58f26 commit 4c0a093
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions vulkano/src/pipeline/graphics_pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::sync::Arc;
use std::u32;
use smallvec::SmallVec;

use buffer::BufferInner;
use device::Device;
use descriptor::PipelineLayoutRef;
use descriptor::descriptor_set::UnsafeDescriptorSetLayout;
Expand Down Expand Up @@ -58,6 +59,7 @@ use pipeline::shader::TessEvaluationShaderEntryPoint;
use pipeline::shader::GeometryShaderEntryPoint;
use pipeline::shader::FragmentShaderEntryPoint;
use pipeline::vertex::Definition as VertexDefinition;
use pipeline::vertex::Source as VertexSource;
use pipeline::vertex::IncompatibleVertexDefinitionError;
use pipeline::viewport::ViewportsState;

Expand Down Expand Up @@ -1099,6 +1101,29 @@ unsafe impl<'a> VulkanObject for GraphicsPipelineSys<'a> {
}
}

unsafe impl<Mv, L, Rp, I> VertexDefinition<I> for GraphicsPipeline<Mv, L, Rp>
where Mv: VertexDefinition<I>
{
type BuffersIter = <Mv as VertexDefinition<I>>::BuffersIter;
type AttribsIter = <Mv as VertexDefinition<I>>::AttribsIter;

#[inline]
fn definition(&self, interface: &I) -> Result<(Self::BuffersIter, Self::AttribsIter),
IncompatibleVertexDefinitionError>
{
self.vertex_definition.definition(interface)
}
}

unsafe impl<Mv, L, Rp, S> VertexSource<S> for GraphicsPipeline<Mv, L, Rp>
where Mv: VertexSource<S>
{
#[inline]
fn decode<'l>(&self, s: &'l S) -> (Vec<BufferInner<'l>>, usize, usize) {
self.vertex_definition.decode(s)
}
}

/// Error that can happen when creating a graphics pipeline.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum GraphicsPipelineCreationError {
Expand Down
2 changes: 1 addition & 1 deletion vulkano/src/pipeline/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub struct AttributeInfo {
}

/// Trait for types that describe the definition of the vertex input used by a graphics pipeline.
pub unsafe trait Definition<I>: 'static + Send + Sync {
pub unsafe trait Definition<I> {
/// Iterator that returns the offset, the stride (in bytes) and input rate of each buffer.
type BuffersIter: ExactSizeIterator<Item = (u32, usize, InputRate)>;
/// Iterator that returns the attribute location, buffer id, and infos.
Expand Down

0 comments on commit 4c0a093

Please # to comment.