Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad GLSL from shared term in conditional #36

Open
floybix opened this issue Nov 17, 2016 · 0 comments · May be fixed by #37
Open

Bad GLSL from shared term in conditional #36

floybix opened this issue Nov 17, 2016 · 0 comments · May be fixed by #37

Comments

@floybix
Copy link

floybix commented Nov 17, 2016

Hi, I found this failure case. If a term appears multiple times within one branch of an if, the shared term gets emitted without an assignment to a variable.

(require '[gamma.api :as g])
(require '[gamma.program :as p])

(def ans2
  (let [g-elem (g/* 5 5)
        sh {(g/gl-position) (g/vec4 (g/if (g/== 0 0)
                                          (g/+ g-elem g-elem)
                                          0.0))}]
    (:glsl (p/shader sh {:float :highp}))))

(println ans2)
precision highp float;

void main(void){
float v387;
float v394;
if((0.0 == 0.0)){
  (5.0 * 5.0);                       <----- note missing assignment
  (v387 = (v394 + v394));}
  else {
    (v387 = 0.0);}
(gl_Position = vec4(v387));
}

I tried to track it down in the code but got lost in the compiler.

@floybix floybix linked a pull request Nov 19, 2016 that will close this issue
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 a pull request may close this issue.

1 participant