@@ -1931,6 +1931,34 @@ impl<W: Write> Writer<W> {
19311931 Ok ( ( ) )
19321932 }
19331933
1934+ fn put_unpacked_access_chain (
1935+ & mut self ,
1936+ expr_handle : Handle < crate :: Expression > ,
1937+ policy : index:: BoundsCheckPolicy ,
1938+ context : & ExpressionContext ,
1939+ ) -> Result < ( ) , Error > {
1940+ let packed_kind = context. get_packed_vec_kind ( expr_handle) ;
1941+ let ty = context. resolve_type ( expr_handle) ;
1942+
1943+ // handle packed_type3 like packed_int3, we should unpack by using metal::type3()
1944+ if let (
1945+ Some ( _) ,
1946+ & crate :: TypeInner :: Vector {
1947+ size : crate :: VectorSize :: Tri ,
1948+ scalar,
1949+ } ,
1950+ ) = ( packed_kind, ty)
1951+ {
1952+ put_numeric_type ( & mut self . out , scalar, & [ crate :: VectorSize :: Tri ] ) ?;
1953+ write ! ( self . out, "(" ) ?;
1954+ self . put_access_chain ( expr_handle, policy, context) ?;
1955+ write ! ( self . out, ")" ) ?;
1956+ } else {
1957+ self . put_access_chain ( expr_handle, policy, context) ?;
1958+ }
1959+ Ok ( ( ) )
1960+ }
1961+
19341962 /// Emit code for the expression `expr_handle`.
19351963 ///
19361964 /// The `is_scoped` argument is true if the surrounding operators have the
@@ -1993,7 +2021,7 @@ impl<W: Write> Writer<W> {
19932021 ) ?
19942022 {
19952023 write ! ( self . out, " ? " ) ?;
1996- self . put_access_chain ( expr_handle, policy, context) ?;
2024+ self . put_unpacked_access_chain ( expr_handle, policy, context) ?;
19972025 write ! ( self . out, " : " ) ?;
19982026
19992027 if context. resolve_type ( base) . pointer_space ( ) . is_some ( ) {
@@ -2035,7 +2063,7 @@ impl<W: Write> Writer<W> {
20352063 write ! ( self . out, ")" ) ?;
20362064 }
20372065 } else {
2038- self . put_access_chain ( expr_handle, policy, context) ?;
2066+ self . put_unpacked_access_chain ( expr_handle, policy, context) ?;
20392067 }
20402068 }
20412069 crate :: Expression :: Swizzle {
0 commit comments