<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 3, 2017 at 2:05 PM, Steve Canon via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><span></span></div><div>If/when 16b floats were added to the standard lib, you would just write:<div><br></div><div> let vertexData: [Float16] = [ 1, 0, 0.5, 1 ]</div><div><br></div><div>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><br></div><div> import SceneKit</div><div> let vertexData = SCNVector4(1, 0, 0.5, 1)</div><div><br></div><div> import simd</div><div> let vertexData = float4(1, 0, 0.5, 1)</div><div><br></div><div>(NB both of these frameworks are Apple-specific).</div><div><br></div><div>- Steve<br><br><div id="m_1466030459997147934AppleMailSignature">Sent from my iPhone <br></div></div></div></div></blockquote><div><br></div><div>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.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><div><div id="m_1466030459997147934AppleMailSignature"></div><div><div class="h5"><div><br>On Nov 3, 2017, at 14:58, Tony Allevato via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">You can write this for the first thing that you want:<div><br></div><div> let vertexData: [Float] = [1.0, 0.0, 0.5, 1.0]</div><div><br></div><div>I don't know enough about 16-bit floats to comment on those.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 3, 2017 at 11:26 AM nick ralabate via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think it would be helpful for graphics programmers to specify vertex data inline without surrounding every value with Float(4.0).<div><br></div><div>Something like this:</div><div><br></div><div>let vertexData = [ 1.0f, 0.0f, 0.5f, 1.0f ]</div><div><br></div><div>Also, it would be great if Swift had a type for half-floats to match the iPhone GPU:</div><div><br></div><div>let vertexData = [ 1.0h, 0.0h, 0.5h, 1.0h]</div><div><br></div><div><br></div><div>Thanks!</div></div>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</blockquote></div>
</div></blockquote><blockquote type="cite"><div><span>______________________________<wbr>_________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a></span><br></div></blockquote></div></div></div></div></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div></div>