Skip to content

Instantly share code, notes, and snippets.

@JayFoxRox
Created September 25, 2015 13:00
Show Gist options
  • Save JayFoxRox/dcc0d83219a2af26a51d to your computer and use it in GitHub Desktop.
Save JayFoxRox/dcc0d83219a2af26a51d to your computer and use it in GitHub Desktop.
MESA GLSL Notes (<3)
GLSL IR for linked vertex program 172:
(
(declare (location=0 shader_out ) vec4 gl_Position)
(declare (uniform ) vec4 ua)
(declare (uniform ) vec4 ub)
( function main
(signature void
(parameters
)
(
(declare (temporary ) vec4 vec_ctor)
(declare (temporary ) float cse)
(assign (x) (var_ref cse) (expression float + (swiz x (var_ref ua) )(swiz x (var_ref ub) )) )
(declare (temporary ) bool cse@192)
(assign (x) (var_ref cse@192) (expression bool > (swiz x (var_ref ua) )(constant float (0.000000)) ) )
(assign (x) (var_ref vec_ctor) (expression float csel (var_ref cse@192) (var_ref cse) (expression float csel (var_ref cse@192) (var_ref cse) (var_ref cse) ) ) )
(declare (temporary ) float cse@193)
(assign (x) (var_ref cse@193) (expression float + (swiz y (var_ref ua) )(swiz y (var_ref ub) )) )
(declare (temporary ) bool cse@194)
(assign (x) (var_ref cse@194) (expression bool > (swiz y (var_ref ua) )(constant float (0.000000)) ) )
(assign (y) (var_ref vec_ctor) (expression float csel (var_ref cse@194) (var_ref cse@193) (expression float csel (var_ref cse@194) (var_ref cse@193) (var_ref cse@193) ) ) )
(declare (temporary ) float cse@195)
(assign (x) (var_ref cse@195) (expression float + (swiz z (var_ref ua) )(swiz z (var_ref ub) )) )
(declare (temporary ) bool cse@196)
(assign (x) (var_ref cse@196) (expression bool > (swiz z (var_ref ua) )(constant float (0.000000)) ) )
(assign (z) (var_ref vec_ctor) (expression float csel (var_ref cse@196) (var_ref cse@195) (expression float csel (var_ref cse@196) (var_ref cse@195) (var_ref cse@195) ) ) )
(declare (temporary ) float cse@197)
(assign (x) (var_ref cse@197) (expression float + (swiz w (var_ref ua) )(swiz w (var_ref ub) )) )
(declare (temporary ) bool cse@198)
(assign (x) (var_ref cse@198) (expression bool > (swiz w (var_ref ua) )(constant float (0.000000)) ) )
(assign (w) (var_ref vec_ctor) (expression float csel (var_ref cse@198) (var_ref cse@197) (expression float csel (var_ref cse@198) (var_ref cse@197) (var_ref cse@197) ) ) )
(declare (temporary ) vec4 vec_ctor@199)
(assign (yzw) (var_ref vec_ctor@199) (constant vec3 (0.000000 0.000000 0.000000)) )
(assign (x) (var_ref vec_ctor@199) (swiz x (var_ref vec_ctor) ))
(assign (xyzw) (var_ref gl_Position) (var_ref vec_ctor@199) )
))
)
)
GLSL vertex shader 0 source for linked program 172:
// Ran with MESA_GLSL=dump, "Mesa 11.0.0-devel (git-1bba29e) is supported"
#version 130
uniform vec4 ua;
uniform vec4 ub;
float add(float a, float b) {
float c = mix(a + b, a + b, a > 0.0);
return mix(c, a + b, a > 0.0); // *Cough* a + b *cough*
}
vec4 add4(vec4 va, vec4 vb) {
return vec4(add(va.x,vb.x),
add(va.y,vb.y),
add(va.z,vb.z),
add(va.w,vb.w));
}
void main()
{
gl_Position = vec4(add4(ua,ub).x,0.0,0.0,0.0);
}
GLSL IR for linked vertex program 176:
(
(declare (location=0 shader_out ) vec4 gl_Position)
(declare (uniform ) vec4 ua)
(declare (uniform ) vec4 ub)
( function main
(signature void
(parameters
)
(
(declare (temporary ) vec4 vec_ctor)
(assign (yzw) (var_ref vec_ctor) (constant vec3 (0.000000 0.000000 0.000000)) )
(assign (x) (var_ref vec_ctor) (swiz x (expression vec4 + (var_ref ua) (var_ref ub) ) ))
(assign (xyzw) (var_ref gl_Position) (var_ref vec_ctor) )
))
)
)
GLSL vertex shader 0 source for linked program 176:
// Ran with MESA_GLSL=dump, "Mesa 11.0.0-devel (git-1bba29e) is supported"
#version 130
uniform vec4 ua;
uniform vec4 ub;
float add(float a, float b) {
return a + b;
}
vec4 add4(vec4 va, vec4 vb) {
return vec4(add(va.x,vb.x),
add(va.y,vb.y),
add(va.z,vb.z),
add(va.w,vb.w));
}
void main()
{
gl_Position = vec4(add4(ua,ub).x,0.0,0.0,0.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment