<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 3, 2017, at 3:33 PM, Kelvin Ma <<a href="mailto:kelvin13ma@gmail.com" class="">kelvin13ma@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class="Apple-interchange-newline"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Fri, Nov 3, 2017 at 2:05 PM, Steve Canon via swift-evolution<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div class=""><span class=""></span></div><div class="">If/when 16b floats were added to the standard lib, you would just write:<div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>let vertexData: [Float16] = [ 1, 0, 0.5, 1 ]</div><div class=""><br class=""></div><div class="">I should note that something like vertex coordinates is usually better modeled with a more specific type than [Float], like SCNVector4 or simd.float4 or your own type, which also solves this problem:</div><div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>import SceneKit</div><div class=""> <span class="Apple-converted-space"> </span>let vertexData = SCNVector4(1, 0, 0.5, 1)</div><div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>import simd</div><div class=""> <span class="Apple-converted-space"> </span>let vertexData = float4(1, 0, 0.5, 1)</div><div class=""><br class=""></div><div class="">(NB both of these frameworks are Apple-specific).</div><div class=""><br class=""></div><div class="">- Steve<br class=""><br class=""><div id="m_1466030459997147934AppleMailSignature" class="">Sent from my iPhone<span class="Apple-converted-space"> </span><br class=""></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">If @_fixed_layout was supported this would be sensible, but most graphics frameworks expect a plain buffer of floats and the packing order is implicit. We can’t model vertex vectors with Swift structs because we can’t safely pointer-cast them to an array of floats.</div></div></div></blockquote><br class=""></div><div>SCNVector4 is a C struct and hence has fixed layout. simd.float4 fixes its ordering by having a single field that is an LLVM ext-vector type. Both can be safely converted to a buffer of floats.</div><div><br class=""></div><div>– Steve</div></body></html>