<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Sun, Mar 10, 2013 at 8:35 AM, cage <span dir="ltr"><<a href="mailto:cage@katamail.com" target="_blank">cage@katamail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

(defun lerp-gl-array (a b c count interpolation-factor)<br>
  (dotimes (i count)<br>
    (setf (gl:glaref c i)<br>
      (alexandria:lerp interpolation-factor (gl:glaref a i) (gl:glaref b i)))))<br>
<br>
is this my fault? Any idea how can I improve performance?<br></blockquote><div><br></div><div>Most of the problem is <a href="https://github.com/3b/cl-opengl/issues/27">https://github.com/3b/cl-opengl/issues/27</a> (glaref and (setf glaref) are slow).<br>
<br></div><div>Another problem is that the compiler doesn't know what types the values are, so has to call generic math routines instead of using CPU ops directly.<br><br></div><div>Storing the source arrays as specialized lisp arrays, and declaring types (and/or check-type) would help with both problems, though writing to the gl-array would still be slow until that bug is fixed. You could work around the bug by using cffi:mem-aref directly instead of glaref, or if you are using shaders, you could just do the interpolation on the GPU.<br>
<br></div><div>-b-</div></div></div></div>