: GLSL source for vertex shader 1: : #version 330 core in vec3 vertex; void main() { gl_Position.xyz = vec3(vertex.xy * 0.5, vertex.z); } : GLSL IR for shader 1: ( (declare (location=17 shader_out ) (array float 0) gl_ClipDistance) (declare (location=12 shader_out ) float gl_PointSize) (declare (location=0 shader_out ) vec4 gl_Position) (declare (shader_in ) vec3 vertex) ( function main (signature void (parameters ) ( (declare (temporary ) vec3 vec_ctor) (assign (xy) (var_ref vec_ctor) (expression vec2 * (swiz xy (var_ref vertex) )(constant float (0.500000)) ) ) (assign (z) (var_ref vec_ctor) (swiz z (var_ref vertex) )) (assign (xyz) (var_ref gl_Position) (var_ref vec_ctor) ) )) ) ) : : GLSL source for geometry shader 2: : #version 330 core layout(triangles) in; layout(points, max_vertices = 1) out; void main() { vec2 nnn = gl_in[1].gl_Position.xy - gl_in[0].gl_Position.xy; float dist = length(nnn); dist = (dist == 0.0) ? 1.0 : 0.0; vec2 d = nnn / dist; if (dot(gl_in[1].gl_Position.xy, d) <= gl_in[0].gl_Position.z) { } else { gl_Position = vec4(gl_in[0].gl_Position.xy, 0.0, 1.0); EmitVertex (); } } : GLSL IR for shader 2: ( (declare (location=21 shader_out flat) int gl_PrimitiveID) (declare (location=21 shader_in flat) int gl_PrimitiveIDIn) (declare (location=22 shader_out flat) int gl_Layer) (declare (location=17 shader_out ) (array float 0) gl_ClipDistance) (declare (location=12 shader_out ) float gl_PointSize) (declare (location=0 shader_out ) vec4 gl_Position) (declare (shader_in ) (array gl_PerVertex 3) gl_in) ( function main (signature void (parameters ) ( (declare (temporary ) vec2 assignment_tmp) (assign (xy) (var_ref assignment_tmp) (expression vec2 + (swiz xy (record_ref (array_ref (var_ref gl_in) (constant int (1)) ) gl_Position) )(expression vec2 neg (swiz xy (record_ref (array_ref (var_ref gl_in) (constant int (0)) ) gl_Position) )) ) ) (declare (temporary ) float length_retval) (assign (x) (var_ref length_retval) (expression float sqrt (expression float dot (var_ref assignment_tmp) (var_ref assignment_tmp) ) ) ) (declare (temporary ) float conditional_tmp) (if (expression bool == (var_ref length_retval) (constant float (0.000000)) ) ( (assign (x) (var_ref conditional_tmp) (constant float (1.000000)) ) ) ( (assign (x) (var_ref conditional_tmp) (constant float (0.000000)) ) )) (declare (temporary ) float dot_retval) (assign (x) (var_ref dot_retval) (expression float dot (swiz xy (record_ref (array_ref (var_ref gl_in) (constant int (1)) ) gl_Position) )(expression vec2 / (var_ref assignment_tmp) (var_ref conditional_tmp) ) ) ) (if (expression bool < (swiz z (record_ref (array_ref (var_ref gl_in) (constant int (0)) ) gl_Position) )(var_ref dot_retval) ) ( (declare (temporary ) vec4 vec_ctor) (assign (zw) (var_ref vec_ctor) (constant vec2 (0.000000 1.000000)) ) (assign (xy) (var_ref vec_ctor) (swiz xy (record_ref (array_ref (var_ref gl_in) (constant int (0)) ) gl_Position) )) (assign (xyzw) (var_ref gl_Position) (var_ref vec_ctor) ) (emit-vertex (constant int (0)) ) ) ()) )) ) ) : : GLSL source for fragment shader 3: : #version 330 core out vec4 Color; void main() { Color = vec4(0,0,0,1); } : GLSL IR for shader 3: ( (declare (location=21 shader_in flat) int gl_PrimitiveID) (declare (location=25 shader_in ) vec2 gl_PointCoord) (declare (location=24 shader_in ) bool gl_FrontFacing) (declare (location=0 shader_in ) vec4 gl_FragCoord) (declare (location=17 shader_in ) (array float 0) gl_ClipDistance) (declare (shader_out ) vec4 Color) ( function main (signature void (parameters ) ( (assign (xyzw) (var_ref Color) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) ) )) ) ) : GLSL IR for linked vertex program 4: ( (declare (location=0 shader_out ) vec4 gl_Position) (declare (location=16 shader_in ) vec3 vertex) ( function main (signature void (parameters ) ( (declare (temporary ) vec3 vec_ctor) (assign (xy) (var_ref vec_ctor) (expression vec2 * (swiz xy (var_ref vertex) )(constant float (0.500000)) ) ) (assign (z) (var_ref vec_ctor) (swiz z (var_ref vertex) )) (assign (xyz) (var_ref gl_Position) (var_ref vec_ctor) ) )) ) ) GLSL IR for linked geometry program 4: ( (declare (location=0 shader_in ) (array vec4 3) gl_Position) (declare (location=0 shader_out ) vec4 gl_Position) ( function main (signature void (parameters ) ( (declare (temporary ) vec2 assignment_tmp) (assign (xy) (var_ref assignment_tmp) (expression vec2 + (swiz xy (array_ref (var_ref gl_Position) (constant int (1)) ) )(expression vec2 neg (swiz xy (array_ref (var_ref gl_Position) (constant int (0)) ) )) ) ) (declare (temporary ) float length_retval) (assign (x) (var_ref length_retval) (expression float sqrt (expression float dot (var_ref assignment_tmp) (var_ref assignment_tmp) ) ) ) (declare (temporary ) float conditional_tmp) (if (expression bool == (var_ref length_retval) (constant float (0.000000)) ) ( (assign (x) (var_ref conditional_tmp) (constant float (1.000000)) ) ) ( (assign (x) (var_ref conditional_tmp) (constant float (0.000000)) ) )) (declare (temporary ) float dot_retval) (assign (x) (var_ref dot_retval) (expression float dot (swiz xy (array_ref (var_ref gl_Position) (constant int (1)) ) )(expression vec2 * (var_ref assignment_tmp) (expression float rcp (var_ref conditional_tmp) ) ) ) ) (if (expression bool < (swiz z (array_ref (var_ref gl_Position) (constant int (0)) ) )(var_ref dot_retval) ) ( (declare (temporary ) vec4 vec_ctor) (assign (zw) (var_ref vec_ctor) (constant vec2 (0.000000 1.000000)) ) (assign (xy) (var_ref vec_ctor) (swiz xy (array_ref (var_ref gl_Position) (constant int (0)) ) )) (assign (xyzw) (var_ref gl_Position@2) (var_ref vec_ctor) ) (emit-vertex (constant int (0)) ) ) ()) )) ) ) GLSL IR for native geometry shader 4: ( (declare (location=0 shader_in ) (array vec4 3) gl_Position) (declare (location=0 shader_out ) vec4 gl_Position) ( function main (signature void (parameters ) ( (declare (temporary ) vec2 assignment_tmp) (assign (xy) (var_ref assignment_tmp) (expression vec2 + (swiz xy (array_ref (var_ref gl_Position) (constant int (1)) ) )(expression vec2 neg (swiz xy (array_ref (var_ref gl_Position) (constant int (0)) ) )) ) ) (declare (temporary ) float length_retval) (assign (x) (var_ref length_retval) (expression float sqrt (expression float dot (var_ref assignment_tmp) (var_ref assignment_tmp) ) ) ) (declare (temporary ) float conditional_tmp) (if (expression bool == (var_ref length_retval) (constant float (0.000000)) ) ( (assign (x) (var_ref conditional_tmp) (constant float (1.000000)) ) ) ( (assign (x) (var_ref conditional_tmp) (constant float (0.000000)) ) )) (declare (temporary ) float dot_retval) (assign (x) (var_ref dot_retval) (expression float dot (swiz xy (array_ref (var_ref gl_Position) (constant int (1)) ) )(expression vec2 * (var_ref assignment_tmp) (expression float rcp (var_ref conditional_tmp) ) ) ) ) (if (expression bool < (swiz z (array_ref (var_ref gl_Position) (constant int (0)) ) )(var_ref dot_retval) ) ( (declare (temporary ) vec4 vec_ctor) (assign (zw) (var_ref vec_ctor) (constant vec2 (0.000000 1.000000)) ) (assign (xy) (var_ref vec_ctor) (swiz xy (array_ref (var_ref gl_Position) (constant int (0)) ) )) (assign (xyzw) (var_ref gl_Position@3) (var_ref vec_ctor) ) (emit-vertex (constant int (0)) ) ) ()) )) ) ) GLSL IR for linked fragment program 4: ( (declare (location=4 shader_out ) vec4 Color) ( function main (signature void (parameters ) ( (assign (xyzw) (var_ref Color) (constant vec4 (0.000000 0.000000 0.000000 1.000000)) ) )) ) ) GLSL vertex shader 0 source for linked program 4: #version 330 core in vec3 vertex; void main() { gl_Position.xyz = vec3(vertex.xy * 0.5, vertex.z); } GLSL geometry shader 1 source for linked program 4: #version 330 core layout(triangles) in; layout(points, max_vertices = 1) out; void main() { vec2 nnn = gl_in[1].gl_Position.xy - gl_in[0].gl_Position.xy; float dist = length(nnn); dist = (dist == 0.0) ? 1.0 : 0.0; vec2 d = nnn / dist; if (dot(gl_in[1].gl_Position.xy, d) <= gl_in[0].gl_Position.z) { } else { gl_Position = vec4(gl_in[0].gl_Position.xy, 0.0, 1.0); EmitVertex (); } } GLSL fragment shader 2 source for linked program 4: #version 330 core out vec4 Color; void main() { Color = vec4(0,0,0,1); } NIR (SSA form) for geometry shader: shader: MESA_SHADER_GEOMETRY name: GLSL4 inputs: 0 outputs: 0 uniforms: 0 shared: 0 decl_var shader_in INTERP_MODE_NONE vec4[3] gl_Position (VARYING_SLOT_POS, 0, 0) decl_var shader_out INTERP_MODE_NONE vec4 gl_Position@0 (VARYING_SLOT_POS, 0, 0) decl_function main returning void impl main { block block_0: /* preds: */ vec1 32 ssa_0 = load_const (0x00000000 /* 0.000000 */) vec2 32 ssa_1 = load_const (0x00000000 /* 0.000000 */, 0x3f800000 /* 1.000000 */) vec1 32 ssa_2 = load_const (0x00000001 /* 0.000000 */) vec4 32 ssa_3 = intrinsic load_per_vertex_input (ssa_2, ssa_0) () (1, 0) /* base=1 */ /* component=0 */ vec4 32 ssa_4 = intrinsic load_per_vertex_input (ssa_0, ssa_0) () (1, 0) /* base=1 */ /* component=0 */ vec2 32 ssa_5 = fadd ssa_3.xy, -ssa_4.xy vec4 32 ssa_6 = fdot_replicated2 ssa_5, ssa_5 vec1 32 ssa_7 = fsqrt ssa_6.x vec1 32 ssa_8 = feq ssa_7, ssa_0 vec1 32 ssa_9 = b2f ssa_8 vec1 32 ssa_10 = frcp ssa_9 vec2 32 ssa_11 = fmul ssa_5, ssa_10.xx vec4 32 ssa_12 = fdot_replicated2 ssa_3.xy, ssa_11 vec1 32 ssa_13 = flt ssa_4.z, ssa_12.x /* succs: block_1 block_2 */ if ssa_13 { block block_1: /* preds: block_0 */ vec4 32 ssa_14 = vec4 ssa_4.x, ssa_4.y, ssa_1.x, ssa_1.y intrinsic store_output (ssa_14, ssa_0) () (0, 15, 0) /* base=0 */ /* wrmask=xyzw */ /* component=0 */ /* gl_Position */ intrinsic emit_vertex_with_counter (ssa_0) () (0) /* stream-id=0 */ /* succs: block_3 */ } else { block block_2: /* preds: block_0 */ /* succs: block_3 */ } block block_3: /* preds: block_1 block_2 */ vec1 32 ssa_15 = phi block_1: ssa_2, block_2: ssa_0 intrinsic set_vertex_count (ssa_15) () () /* succs: block_0 */ block block_0: } NIR (final form) for geometry shader: shader: MESA_SHADER_GEOMETRY name: GLSL4 inputs: 0 outputs: 0 uniforms: 0 shared: 0 decl_var shader_in INTERP_MODE_NONE vec4[3] gl_Position (VARYING_SLOT_POS, 0, 0) decl_var shader_out INTERP_MODE_NONE vec4 gl_Position@0 (VARYING_SLOT_POS, 0, 0) decl_function main returning void impl main { decl_reg vec1 32 r0 decl_reg vec4 32 r1 block block_0: /* preds: */ vec1 32 ssa_0 = load_const (0x00000000 /* 0.000000 */) vec2 32 ssa_1 = load_const (0x00000000 /* 0.000000 */, 0x3f800000 /* 1.000000 */) vec1 32 ssa_2 = load_const (0x00000001 /* 0.000000 */) vec4 32 ssa_3 = intrinsic load_per_vertex_input (ssa_2, ssa_0) () (1, 0) /* base=1 */ /* component=0 */ vec4 32 ssa_4 = intrinsic load_per_vertex_input (ssa_0, ssa_0) () (1, 0) /* base=1 */ /* component=0 */ vec2 32 ssa_5 = fadd ssa_3.xy, -ssa_4.xy vec4 32 ssa_6 = fdot_replicated2 ssa_5, ssa_5 vec1 32 ssa_7 = fsqrt ssa_6.x vec1 32 ssa_8 = feq ssa_7, ssa_0 vec1 32 ssa_9 = b2f ssa_8 vec1 32 ssa_10 = frcp ssa_9 vec2 32 ssa_11 = fmul ssa_5, ssa_10.xx vec4 32 ssa_12 = fdot_replicated2 ssa_3.xy, ssa_11 vec1 32 ssa_13 = flt ssa_4.z, ssa_12.x /* succs: block_1 block_2 */ if ssa_13 { block block_1: /* preds: block_0 */ r1.xy = imov ssa_4.xy r1.zw = imov ssa_1.xy intrinsic store_output (r1, ssa_0) () (0, 15, 0) /* base=0 */ /* wrmask=xyzw */ /* component=0 */ /* gl_Position */ intrinsic emit_vertex_with_counter (ssa_0) () (0) /* stream-id=0 */ r0 = imov ssa_2 /* succs: block_3 */ } else { block block_2: /* preds: block_0 */ r0 = imov ssa_0 /* succs: block_3 */ } block block_3: /* preds: block_1 block_2 */ intrinsic set_vertex_count (r0) () () /* succs: block_0 */ block block_0: } GS Input VUE map (2 slots, non-SSO) [0] VARYING_SLOT_PSIZ [1] VARYING_SLOT_POS GS Output VUE map (2 slots, non-SSO) [0] VARYING_SLOT_PSIZ [1] VARYING_SLOT_POS Native code for unnamed geometry shader GLSL4: GS vec4 shader: 89 instructions. 1 loops. 1742 cycles. 3:3 spills:fills. Compacted 1424 to 1296 bytes (9%) START B0 (168 cycles) mov(1) g0.2<1>UD 0x00000000UD { align1 WE_all 1N compacted }; mov(8) g7<1>.xUD 0x00000000UD { align16 1Q }; mov(8) g10<1>.xUD 0x00000000UD { align16 1Q }; mov(8) g13<1>.xD 0D { align16 1Q }; mov(8) g14<1>.xyF [0F, 1F, 0F, 0F]VF { align16 1Q }; mov(8) m1<1>UD g0<4>UD { align16 WE_all 1Q compacted }; add(8) g18<1>.xyF g3.4<0>.xyyyF -g2.4<0>.xyyyF { align16 1Q }; dp2(8) g21<1>F g18<4>.xyyyF g18<4>.xyyyF { align16 1Q compacted }; math sqrt(8) g22<1>F g21<4,4,1>F null<8,8,1>F { align1 1Q }; cmp.z.f0(8) g23<1>.xF g22<4>.xF 0F { align16 1Q }; mov(8) g26<1>F -g23<4>.xD { align16 1Q }; math inv(8) g27<1>F g26<4,4,1>F null<8,8,1>F { align1 1Q }; mul(8) g28<1>.xyF g18<4>.xyyyF g27<4>.xF { align16 1Q }; dp2(8) g29<1>.xF g3.4<0>.xyyyF g28<4>.xyyyF { align16 1Q }; cmp.l.f0(8) null<1>.xF g2.4<0>.zF g29<4>.xF { align16 1Q }; (+f0.x) if(8) JIP: 58 { align16 1Q }; END B0 ->B1 ->B2 START B1 <-B0 (142 cycles) mov(8) g12<1>.xyD g2.4<0>.xyyyD { align16 NoDDClr 1Q }; mov(8) g34<1>.xD 0x00000000UD { align16 1Q }; mov(8) g35<1>UD 0x00000000UD { align16 WE_all 1Q compacted }; mov(8) g12<1>.zwD g14<4>.xxxyD { align16 NoDDChk 1Q }; mul(8) g34<1>.xD g34<4>.xD 2D { align16 1Q }; mov(8) m21<1>UD g0<4>UD { align16 WE_all 1Q compacted }; mov(1) m22<1>D g34<0,1,0>D { align1 WE_all 1N }; add(1) m22.4<1>D g34.4<0,1,0>D 1D { align1 WE_all 1N }; mov(8) m23<1>D g35<4>D { align16 1Q }; send(8) g0<1>F m21<4>F render OWORD dual block write MsgCtrl = 0x0 Surface = 255 mlen 3 rlen 0 { align16 1Q }; add(8) g7<1>.xUD g7<4>.xUD 0x00000001UD { align16 1Q }; mov(8) g36<1>.xD g7<4>.xUD { align16 1Q }; mul(8) g36<1>.xD g36<4>.xD 2D { align16 1Q }; mov(8) m21<1>UD g0<4>UD { align16 WE_all 1Q compacted }; mov(1) m22<1>D g36<0,1,0>D { align1 WE_all 1N }; add(1) m22.4<1>D g36.4<0,1,0>D 1D { align1 WE_all 1N }; mov(8) m23<1>D g12<4>D { align16 1Q }; send(8) g0<1>F m21<4>F render OWORD dual block write MsgCtrl = 0x0 Surface = 255 mlen 3 rlen 0 { align16 1Q }; add(8) g7<1>.xUD g7<4>.xUD 0x00000001UD { align16 1Q }; mov(8) g39<1>UD 7D { align16 1Q }; mov(8) g38<1>.xD g7<4>.xUD { align16 1Q }; mul(8) g38<1>.xD g38<4>.xD 2D { align16 1Q }; mov(8) m21<1>UD g0<4>UD { align16 WE_all 1Q compacted }; mov(1) m22<1>D g38<0,1,0>D { align1 WE_all 1N }; add(1) m22.4<1>D g38.4<0,1,0>D 1D { align1 WE_all 1N }; mov(8) m23<1>D g39<4>D { align16 1Q }; send(8) g0<1>F m21<4>F render OWORD dual block write MsgCtrl = 0x0 Surface = 255 mlen 3 rlen 0 { align16 1Q }; add(8) g10<1>.xUD g10<4>.xUD 0x00000001UD { align16 1Q }; mov(8) g11<1>.xD 1D { align16 1Q }; else(8) JIP: 4 { align16 1Q }; END B1 ->B3 START B2 <-B0 (2 cycles) mov(8) g11<1>.xD g13<4>.xD { align16 1Q }; END B2 ->B3 START B3 <-B2 <-B1 (20 cycles) endif(8) JIP: 2 { align16 1Q }; cmp.g.f0(8) null<1>UD g11<4>.xUD 0x00000000UD { align16 1Q compacted }; (+f0) if(8) JIP: 67 { align16 1Q }; END B3 ->B4 ->B8 START B4 <-B3 (6 cycles) mov(1) m1<1>UD 0x00000000UD { align1 WE_all 1N }; mov(1) m1.1<1>UD g10<0,1,0>UD { align1 WE_all 1N compacted }; send(8) g8<1>.xUD m1<4>UD urb 0 ff_sync allocate mlen 1 rlen 1 { align16 1Q }; mov(1) m1<1>UD g8<0,1,0>UD { align1 WE_all 1N compacted }; mov(8) g32<1>.xUD 0x00000000UD { align16 1Q }; mov(8) g7<1>.xUD 0x00000000UD { align16 1Q }; END B4 ->B5 START B6 <-B5 <-B7 (18 cycles) cmp.ge.f0(8) null<1>UD g32<4>.xUD g11<4>.xUD { align16 1Q }; END B5 ->B6 ->B8 (+f0) break(8) JIP: 51 UIP: 53 { align16 1Q }; END B6 ->B5 ->B7 START B7 <-B6 (120 cycles) add(8) g33<1>.xUD g7<4>.xUD 2D { align16 1Q }; mov(8) g43<1>.xD g7<4>.xUD { align16 1Q }; add(8) g32<1>.xUD g32<4>.xUD 0x00000001UD { align16 1Q }; mov(8) g41<1>.xD g33<4>.xUD { align16 1Q }; mul(8) g43<1>.xD g43<4>.xD 2D { align16 1Q }; add(8) g7<1>.xUD g7<4>.xUD 0x00000001UD { align16 1Q }; mul(8) g41<1>.xD g41<4>.xD 2D { align16 1Q }; mov(8) g45<1>.xD g7<4>.xUD { align16 1Q }; mov(8) m22<1>UD g0<4>UD { align16 WE_all 1Q compacted }; mov(1) m23<1>D g41<0,1,0>D { align1 WE_all 1N }; add(1) m23.4<1>D g41.4<0,1,0>D 1D { align1 WE_all 1N }; send(8) g40<1>F m22<4>F render OWORD dual block read MsgCtrl = 0x0 Surface = 255 mlen 2 rlen 1 { align16 1Q }; mul(8) g45<1>.xD g45<4>.xD 2D { align16 1Q }; add(8) g7<1>.xUD g7<4>.xUD 0x00000001UD { align16 1Q }; mov(1) m1.2<1>UD g40<0,1,0>UD { align1 WE_all 1N compacted }; mov(8) m22<1>UD g0<4>UD { align16 WE_all 1Q compacted }; mov(1) m23<1>D g43<0,1,0>D { align1 WE_all 1N }; add(1) m23.4<1>D g43.4<0,1,0>D 1D { align1 WE_all 1N }; send(8) g42<1>F m22<4>F render OWORD dual block read MsgCtrl = 0x0 Surface = 255 mlen 2 rlen 1 { align16 1Q }; add(8) g7<1>.xUD g7<4>.xUD 0x00000001UD { align16 1Q }; mov(8) m2<1>F g42<4>F { align16 WE_all 1Q compacted }; mov(8) m22<1>UD g0<4>UD { align16 WE_all 1Q compacted }; mov(1) m23<1>D g45<0,1,0>D { align1 WE_all 1N }; add(1) m23.4<1>D g45.4<0,1,0>D 1D { align1 WE_all 1N }; send(8) g44<1>F m22<4>F render OWORD dual block read MsgCtrl = 0x0 Surface = 255 mlen 2 rlen 1 { align16 1Q }; mov(8) m3<1>F g44<4>F { align16 WE_all 1Q compacted }; send(8) g8<1>UD m1<4>F urb 0 urb_write interleave allocate used complete mlen 3 rlen 1 { align16 1Q }; mov(1) m1<1>UD g8<0,1,0>UD { align1 WE_all 1N compacted }; while(8) JIP: -53 { align16 1Q }; END B7 ->B6 START B8 <-B5 <-B3 (4 cycles) endif(8) JIP: 2 { align16 1Q }; send(8) null<1>F m1<4>F urb 0 urb_write interleave complete mlen 1 rlen 0 { align16 1Q EOT }; END B8