@@ -368,20 +368,44 @@ enum class MSLFormatPacking : uint16_t
368368};
369369
370370// / Describes the details of an MSLFormat necessary for easily generating vertex loading code
371- struct MSLFormatInfo
371+ union MSLFormatInfo
372372{
373- uint16_t log2_align : 2 ; // /< log2(minimum msl alignment)
374- uint16_t num_elems : 3 ;
375- MSLFormatPacking packing : 3 ;
376- uint16_t is_float : 1 ;
377- uint16_t is_signed : 1 ;
378- uint16_t is_normalized : 1 ;
379- uint16_t is_packed : 1 ; // /< Is packed in MSL
380- uint16_t vk_packed : 1 ; // /< Is packed in Vulkan but not MSL
381- uint16_t is_bgr : 1 ;
382- uint16_t is_srgb : 1 ;
383- uint16_t _pad : 1 ;
384-
373+ struct
374+ {
375+ uint16_t log2_align : 2 ; // /< log2(minimum msl alignment)
376+ uint16_t num_elems : 3 ;
377+ MSLFormatPacking packing : 3 ;
378+ uint16_t is_float : 1 ;
379+ uint16_t is_signed : 1 ;
380+ uint16_t is_normalized : 1 ;
381+ uint16_t is_packed : 1 ; // /< Is packed in MSL
382+ uint16_t vk_packed : 1 ; // /< Is packed in Vulkan but not MSL
383+ uint16_t is_bgr : 1 ;
384+ uint16_t is_srgb : 1 ;
385+ uint16_t _pad : 1 ;
386+ };
387+ uint16_t bits;
388+
389+ constexpr MSLFormatInfo (uint16_t log2_align, uint16_t num_elems, MSLFormatPacking packing, bool is_float,
390+ bool is_signed, bool is_normalized, bool is_packed, bool vk_packed, bool is_bgr,
391+ bool is_srgb)
392+ : log2_align (log2_align)
393+ , num_elems (num_elems)
394+ , packing (packing)
395+ , is_float (is_float)
396+ , is_signed (is_signed)
397+ , is_normalized (is_normalized)
398+ , is_packed (is_packed)
399+ , vk_packed (vk_packed)
400+ , is_bgr (is_bgr)
401+ , is_srgb (is_srgb)
402+ , _pad (0 )
403+ {
404+ }
405+ constexpr MSLFormatInfo ()
406+ : bits (0 )
407+ {
408+ }
385409 constexpr uint32_t align () const
386410 {
387411 return 1 << log2_align;
@@ -400,8 +424,8 @@ struct MSLFormatInfo
400424 }
401425 uint16_t raw_value () const
402426 {
403- static_assert (sizeof (MSLFormatInfo) == sizeof (uint16_t ), " Size check" );
404- return * reinterpret_cast < const uint16_t *>( this ) ;
427+ static_assert (sizeof (MSLFormatInfo) == sizeof (bits ), " Size check" );
428+ return bits ;
405429 }
406430 bool operator ==(const MSLFormatInfo &other) const
407431 {
0 commit comments