<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class="">On 19 Dec 2015, at 00:12, David Turnbull <<a href="mailto:dturnbull@gmail.com" class="">dturnbull@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Fri, Dec 18, 2015 at 2:31 PM, Janosch Hildebrand via swift-users <span dir="ltr" class=""><<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>></span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class="">You will also want to have this code in the same module that is using this type.</div><div class="">If you're using these types from another module you're limited to unspecialized generics which are (unsurprisingly) very slow.</div></div></blockquote><div class=""><br class=""></div><div class="">This is becoming clear. Hopefully these patterns can be optimized across modules eventually. </div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Agreed. I think we'll eventually want some way to "inline" dependencies with the package manager to treat them as one target for optimization purposes. The standard library is fancier even and can essentially specializes and inlines most of it's code into yours when you use it but I don't know if we'll get those abilities for our own modules at some point.</div><div class=""><br class=""></div><div class="">For now you can use @transparent (or @_transparent for Swift 2.2) to force-inline functions across module boundaries but that's it as far as I know.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">It's easy enough to write a pre-processor that expands the generics into four specializations. But it doesn't solve everything so not a priority.</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class="">And since you probably need to drop generics anyway it might make sense to simply wrap the respective GLKit types on OS X and iOS for the GLFloat variants as they are already highly optimized. I have some wrappers for the GLKMatrix and GLKVector types lying around in my own OpenGL wrapper (incidentally also named SwiftGL ;-)) which might save you some typing if you're interested...</div></div></blockquote><div class=""><br class=""></div><div class="">I'm trailblazing cross-platform OpenGL in Swift. Given there's only one other platform, the key question is, "Does it work on Linux?"<br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">If you only care about having a simple cross-platform library, doing a simple implementation by yourself is fine. Also Swift (well, LLVM) is also pretty good at auto-vectorization so you get decent results for custom vector/matrix types.</div><div class=""><br class=""></div><div class="">However OpenGL-related code is usually pretty performance sensitive and the math parts doubly so, so I'd recommend wrapping some appropriate libraries instead of writing your own...</div><div class=""><br class=""></div><div class="">Now if you find a nice cross-platform C library you could wrap that, C++ (for example <a href="http://glm.g-truc.net/0.9.7/api/index.html" class="">http://glm.g-truc.net/0.9.7/api/index.html</a>) also works but then you'd also have to write a C wrapper first :-(</div><div class=""><br class=""></div><div class="">Now on the Apple side, the Accelerate, GLKit and simd modules contain vector and matrix types/functions but these are OS X and iOS only...</div><div class="">Using a single cross platform library is obviously simpler but using these on the Apple platforms would remove the need for a separate dependency there and they are likely well optimized for the target architectures.</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Is your SwiftGL online somewhere? A cursory search didn't yield anything. </div></div></div></div></div></blockquote><div class=""><br class=""></div>No. I mostly just wrapped the OpenGL symbols I needed and experimented with some other additions but as a whole it wasn't really in a state to be published. I don't know if it'd be much use to you but if you're interested l I can give you the code in whatever form is most convenient for you :-)</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><span class="" style="font-size: 13px;">-david (</span><a href="https://github.com/AE9RB/SwiftGL" target="_blank" class="" style="font-size: 13px;">https://github.com/AE9RB/SwiftGL</a><span class="" style="font-size: 13px;">)</span></div></div></div></div></div></blockquote><br class=""></div><div class=""><div class="">- Janosch</div></div></body></html>