Skip to content

Commit

Permalink
Merge pull request #203 from lachlansneff/ironing-out-uniforms
Browse files Browse the repository at this point in the history
Replace vector of UniformProperty with a single UniformProperty
  • Loading branch information
cart authored Aug 18, 2020
2 parents 6228e8a + 9883cd1 commit 6ffe069
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
8 changes: 2 additions & 6 deletions crates/bevy_render/src/pipeline/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct BindingDescriptor {
pub enum BindType {
Uniform {
dynamic: bool,
properties: Vec<UniformProperty>,
property: UniformProperty,
},
StorageBuffer {
dynamic: bool,
Expand All @@ -45,11 +45,7 @@ pub enum BindType {
impl BindType {
pub fn get_uniform_size(&self) -> Option<u64> {
match self {
BindType::Uniform { properties, .. } => Some(
properties
.iter()
.fold(0, |total, property| total + property.get_size()),
),
BindType::Uniform { property, .. } => Some(property.get_size()),
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/render_graph/nodes/pass_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<Q: HecsQuery> PassNode<Q> {
index: 0,
bind_type: BindType::Uniform {
dynamic: false,
properties: vec![UniformProperty::Struct(vec![UniformProperty::Mat4])],
property: UniformProperty::Struct(vec![UniformProperty::Mat4]),
},
shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT,
}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod tests {
name: "a".to_string(),
bind_type: BindType::Uniform {
dynamic: false,
properties: vec![UniformProperty::Struct(vec![UniformProperty::Mat4])],
property: UniformProperty::Struct(vec![UniformProperty::Mat4]),
},
shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT,
},
Expand All @@ -282,7 +282,7 @@ mod tests {
name: "b".to_string(),
bind_type: BindType::Uniform {
dynamic: false,
properties: vec![UniformProperty::Float],
property: UniformProperty::Float,
},
shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT,
},
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_render/src/shader/shader_reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn reflect_binding(binding: &ReflectDescriptorBinding) -> BindingDescriptor {
&type_description.type_name,
BindType::Uniform {
dynamic: false,
properties: vec![reflect_uniform(type_description)],
property: reflect_uniform(type_description),
},
),
ReflectDescriptorType::SampledImage => (
Expand Down Expand Up @@ -412,9 +412,9 @@ mod tests {
name: "Camera".into(),
bind_type: BindType::Uniform {
dynamic: false,
properties: vec![UniformProperty::Struct(vec![
property: UniformProperty::Struct(vec![
UniformProperty::Mat4
])],
]),
},
shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT,
}]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_wgpu/src/wgpu_type_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl WgpuFrom<&BindType> for wgpu::BindingType {
match bind_type {
BindType::Uniform {
dynamic,
properties: _properties,
..
} => wgpu::BindingType::UniformBuffer {
dynamic: *dynamic,
min_binding_size: bind_type
Expand Down

0 comments on commit 6ffe069

Please sign in to comment.