Minimal change to support instanced rendering (#1262)

This commit is contained in:
Alec Deason 2021-01-18 16:52:06 -08:00 committed by GitHub
parent a0475e9ad5
commit 71c6a19ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -22,3 +22,4 @@ pub struct ShaderLayout {
}
pub const GL_VERTEX_INDEX: &str = "gl_VertexIndex";
pub const GL_INSTANCE_INDEX: &str = "gl_InstanceIndex";

View File

@ -3,7 +3,7 @@ use crate::{
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, InputStepMode,
UniformProperty, VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat,
},
shader::{ShaderLayout, GL_VERTEX_INDEX},
shader::{ShaderLayout, GL_INSTANCE_INDEX, GL_VERTEX_INDEX},
texture::{TextureComponentType, TextureViewDimension},
};
use bevy_core::AsBytes;
@ -31,7 +31,9 @@ impl ShaderLayout {
// obtain attribute descriptors from reflection
let mut vertex_attribute_descriptors = Vec::new();
for input_variable in module.enumerate_input_variables(None).unwrap() {
if input_variable.name == GL_VERTEX_INDEX {
if input_variable.name == GL_VERTEX_INDEX
|| input_variable.name == GL_INSTANCE_INDEX
{
continue;
}
// reflect vertex attribute descriptor and record it