diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index 15afd82f3d..88917557a8 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -1091,6 +1091,7 @@ impl> Parser { selections: &[spirv::Word], type_arena: &UniqueArena, expressions: &mut Arena, + constants: &Arena, span: crate::Span, ) -> Result, Error> { let selection = match selections.first() { @@ -1107,7 +1108,29 @@ impl> Parser { .ok_or(Error::InvalidAccessType(root_type_id))?; (members.len(), child_member.type_id) } - // crate::TypeInner::Array //TODO? + crate::TypeInner::Array { size, .. } => { + let size = match size { + crate::ArraySize::Constant(handle) => match constants[handle] { + crate::Constant { + specialization: Some(_), + .. + } => return Err(Error::UnsupportedType(root_lookup.handle)), + ref unspecialized => unspecialized + .to_array_length() + .ok_or(Error::InvalidArraySize(handle))?, + }, + // A runtime sized array is not a composite type + crate::ArraySize::Dynamic => { + return Err(Error::InvalidAccessType(root_type_id)) + } + }; + + let child_type_id = root_lookup + .base_id + .ok_or(Error::InvalidAccessType(root_type_id))?; + + (size as usize, child_type_id) + } crate::TypeInner::Vector { size, .. } | crate::TypeInner::Matrix { columns: size, .. } => { let child_type_id = root_lookup @@ -1136,6 +1159,7 @@ impl> Parser { &selections[1..], type_arena, expressions, + constants, span, )?; @@ -1735,6 +1759,7 @@ impl> Parser { &selections, ctx.type_arena, ctx.expressions, + ctx.const_arena, span, )?;