Skip to content

Conversation

@floybix
Copy link

@floybix floybix commented Nov 19, 2016

Fixes #36

Here's a one-character fix (after hours of pain and suffering!)... making insert-assignments recurse into blocks. Or was there a reason that was commented out?

I'm not sure if this is fully general, to recurse only into blocks, or if it should walk everything (by mapping over :body). Still hazy about how this all works.

Another approach which could also fix my case would be to lift all the assignments to the top level, instead of a local block. I think the downside there is potential inefficiency in case conditional calculations are not used.

I also added a basic test, just covers this one case so far.

@emnh
Copy link

emnh commented May 1, 2017

I need this fix as well.

@floybix
Copy link
Author

floybix commented May 1, 2017

Heads up. I ran in to problems of computational scalability after submitting this pull request. Once I reached some number of inputs or operations it was taking about a minute for gamma's compile to run. I must admit that I didn't test whether that was due to my change or not; I realised that my use case was highly structured so I could easily generate the GLSL myself without using Gamma.

@emnh
Copy link

emnh commented May 7, 2017

Thanks for the heads up! I ran into the same problem: taking a minute for gamma's compile to run. In addition, it doesn't succeed in compiling. Without nested assignments it is 10 times faster and doesn't give a compile error (but the shader doesn't work, anyway it's a work in progress). I am getting a lot of these errors with nested assignments and sufficient complexity of the shader:

3889: declaration error on:  {:tag :declaration, :variable {:tag :variable, :id 11887, :type nil}}

For example the following function makes gamma blow up combinatorially:

(defn swizzle-by-index
  [vector4 index]
  (g/if
    (g/== index 0)
    (g/swizzle vector4 :x)
    (g/if
      (g/== index 1)
      (g/swizzle vector4 :y)
      (g/if
        (g/== index 2)
        (g/swizzle vector4 :z)
        (g/swizzle vector4 :w)))))

I am still interested in writing my shader using gamma, and have started looking into how the gamma compiler works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad GLSL from shared term in conditional

2 participants