Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SingleInstanceBufferDefinition #988

Merged
merged 2 commits into from
Jul 8, 2018
Merged

Add SingleInstanceBufferDefinition #988

merged 2 commits into from
Jul 8, 2018

Conversation

andrewhickman
Copy link
Contributor

@andrewhickman andrewhickman commented Jul 4, 2018

This is something I needed when translating some code which used gfx::InstanceBuffer. The code is pretty much copied from the other VertexDefinition implementations, I am not really familiar with the specific safety concerns involved.

Unfortunately it appears to not be possible to implement VertexDefinition in downstream crates due to coherence rules.

#[inline]
fn decode(&self, source: B) -> (Vec<Box<BufferAccess + Send + Sync>>, usize, usize) {
let len = source.len();
(vec![Box::new(source) as Box<_>], len, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be (vec![Box::new(source) as Box<_>], 1, len).

// FIXME: safety
assert_eq!(source.len(), 1);
let len = source[0].size() / mem::size_of::<V>();
(vec![Box::new(source.remove(0))], len, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be (vec![Box::new(source.remove(0))], 1, len)

@tomaka
Copy link
Member

tomaka commented Jul 8, 2018

Thanks for the PR!
Could you also please rename the newly-created instance.rs to instance_buffer.rs for example? The word instance is a bit too vague in the context of vertices and attributes.

@tomaka tomaka merged commit 67ace6b into vulkano-rs:master Jul 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants