My veins are full of turkey

by baggers

Yo! Back after Christmas, and it's time to dive into projects. The last couple of days have been pretty productive and I have a couple of changes worth yaking about.

So as this is all code related I need to add a bit of context:

If you ignore macro expansion, my compiler (varjo) is single pass. This is pretty weird but has served me thus far. As I have have conveyed in other post, I'm hitting walls using this approach now and really want to be able to use varjo is a multipass fashion. This would rely on some pretty huge changes which frankly would take long enough to be pretty demoralizing, I really just want to implement static analysis of cepl spaces in gpu code... I needed some kind of middle ground.

The middle ground in this case is to provide an AST in the compilation result so that users of varjo (cepl in this case). While it is often quipped that lisp is it's own AST, it takes quite a bit of work to get metadata (like types) out of that ast :). So varjo provides a tree of objects which contain not only the types of each form but also:

  • the environment at the start and end of compiling the form
  • the data from the flow analyzer

With these changes cepl (without extra help from varjo) was able to look at the following code...

(defshader test ((vert :vec4) &uniform (world-space space-g) (screen-space space-g))
    (in screen-space
      (labels ((func () (p! (v! 0 0 0 0)))
           (func2 () (func)))
    (let ((p (p! vert)))
      (in world-space
        (+ p (func2)) ;; <<<<
        (v! 1 2 3 4))))))

... and work out that (in the line marked <<<<) both p and the value returned from func2 were positions that were created in screen-space. Because the marked line is executed in world-space cepl knows it has to upload matrices to convert from screen-space to world-space, but not from world-space to screen-space.

Cepl will then rewrite the lisp code to replace spaces with the correct matrices & positions with vectors. We will then have statically checked transforms in gpu code!

Currently I have cepl detecting the places it needs certain matrices but the next thing I need to do is get it to rewrite the code. This should'nt be too hard, but I want to be sure it is writing optimal code so I will take my time with it.

That's all for now, I'm off to a cabin for a few days so I may not have much for next week. We shall see :)

Ciao

Last Edited on Sun Dec 27 2015 18:15:10 GMT-0500 (EST)