@@ -2274,6 +2274,7 @@ impl<W: Write> Writer<W> {
22742274 // to signed.
22752275 self . put_bitcasted_expression (
22762276 context. resolve_type ( expr_handle) ,
2277+ expr_handle,
22772278 context,
22782279 & |writer, context, is_scoped| {
22792280 writer. put_binop (
@@ -2285,6 +2286,7 @@ impl<W: Write> Writer<W> {
22852286 & |writer, expr, context, _is_scoped| {
22862287 writer. put_bitcasted_expression (
22872288 & to_unsigned ( context. resolve_type ( expr) ) ?,
2289+ expr,
22882290 context,
22892291 & |writer, context, is_scoped| {
22902292 writer. put_expression ( expr, context, is_scoped)
@@ -3026,6 +3028,7 @@ impl<W: Write> Writer<W> {
30263028 fn put_bitcasted_expression < F > (
30273029 & mut self ,
30283030 cast_to : & crate :: TypeInner ,
3031+ inner_expr : Handle < crate :: Expression > ,
30293032 context : & ExpressionContext ,
30303033 put_expression : & F ,
30313034 ) -> BackendResult
@@ -3041,9 +3044,18 @@ impl<W: Write> Writer<W> {
30413044 _ => return Err ( Error :: UnsupportedBitCast ( cast_to. clone ( ) ) ) ,
30423045 } ;
30433046 write ! ( self . out, ">(" ) ?;
3044- put_expression ( self , context, true ) ?;
3045- write ! ( self . out, ")" ) ?;
30463047
3048+ // if it's packed, we must unpack it (e.g., float3(val)) before the bitcast.
3049+ if let Some ( scalar) = context. get_packed_vec_kind ( inner_expr) {
3050+ put_numeric_type ( & mut self . out , scalar, & [ crate :: VectorSize :: Tri ] ) ?;
3051+ write ! ( self . out, "(" ) ?;
3052+ put_expression ( self , context, true ) ?;
3053+ write ! ( self . out, ")" ) ?;
3054+ } else {
3055+ put_expression ( self , context, true ) ?;
3056+ }
3057+
3058+ write ! ( self . out, ")" ) ?;
30473059 Ok ( ( ) )
30483060 }
30493061
0 commit comments