Merge pull request #203 from lachlansneff/ironing-out-uniforms

Replace vector of UniformProperty with a single UniformProperty
This commit is contained in:
Carter Anderson 2020-08-18 13:44:10 -07:00 committed by GitHub
commit 6ffe0696db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 13 deletions

View File

@ -21,7 +21,7 @@ pub struct BindingDescriptor {
pub enum BindType { pub enum BindType {
Uniform { Uniform {
dynamic: bool, dynamic: bool,
properties: Vec<UniformProperty>, property: UniformProperty,
}, },
StorageBuffer { StorageBuffer {
dynamic: bool, dynamic: bool,
@ -45,11 +45,7 @@ pub enum BindType {
impl BindType { impl BindType {
pub fn get_uniform_size(&self) -> Option<u64> { pub fn get_uniform_size(&self) -> Option<u64> {
match self { match self {
BindType::Uniform { properties, .. } => Some( BindType::Uniform { property, .. } => Some(property.get_size()),
properties
.iter()
.fold(0, |total, property| total + property.get_size()),
),
_ => None, _ => None,
} }
} }

View File

@ -77,7 +77,7 @@ impl<Q: HecsQuery> PassNode<Q> {
index: 0, index: 0,
bind_type: BindType::Uniform { bind_type: BindType::Uniform {
dynamic: false, dynamic: false,
properties: vec![UniformProperty::Struct(vec![UniformProperty::Mat4])], property: UniformProperty::Struct(vec![UniformProperty::Mat4]),
}, },
shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT, shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT,
}], }],

View File

@ -273,7 +273,7 @@ mod tests {
name: "a".to_string(), name: "a".to_string(),
bind_type: BindType::Uniform { bind_type: BindType::Uniform {
dynamic: false, dynamic: false,
properties: vec![UniformProperty::Struct(vec![UniformProperty::Mat4])], property: UniformProperty::Struct(vec![UniformProperty::Mat4]),
}, },
shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT, shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT,
}, },
@ -282,7 +282,7 @@ mod tests {
name: "b".to_string(), name: "b".to_string(),
bind_type: BindType::Uniform { bind_type: BindType::Uniform {
dynamic: false, dynamic: false,
properties: vec![UniformProperty::Float], property: UniformProperty::Float,
}, },
shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT, shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT,
}, },

View File

@ -177,7 +177,7 @@ fn reflect_binding(binding: &ReflectDescriptorBinding) -> BindingDescriptor {
&type_description.type_name, &type_description.type_name,
BindType::Uniform { BindType::Uniform {
dynamic: false, dynamic: false,
properties: vec![reflect_uniform(type_description)], property: reflect_uniform(type_description),
}, },
), ),
ReflectDescriptorType::SampledImage => ( ReflectDescriptorType::SampledImage => (
@ -412,9 +412,9 @@ mod tests {
name: "Camera".into(), name: "Camera".into(),
bind_type: BindType::Uniform { bind_type: BindType::Uniform {
dynamic: false, dynamic: false,
properties: vec![UniformProperty::Struct(vec![ property: UniformProperty::Struct(vec![
UniformProperty::Mat4 UniformProperty::Mat4
])], ]),
}, },
shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT, shader_stage: BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT,
}] }]

View File

@ -182,7 +182,7 @@ impl WgpuFrom<&BindType> for wgpu::BindingType {
match bind_type { match bind_type {
BindType::Uniform { BindType::Uniform {
dynamic, dynamic,
properties: _properties, ..
} => wgpu::BindingType::UniformBuffer { } => wgpu::BindingType::UniformBuffer {
dynamic: *dynamic, dynamic: *dynamic,
min_binding_size: bind_type min_binding_size: bind_type