The Mesa GLSL compiler allows recursion in GLSL 1.20 shaders. According to the GLSL 1.20 specification this is not allowed.
6.1.1 Function Calling Conventions
Recursion is not allowed, not even statically. Static recursion is present if the static function call graph of the program contains cycles.
12 #version 120
14 int A()
16 return A();
19 void main()
21 gl_Position = gl_Vertex;
We do need to fix this. Many GLSL compilers crash in the presence of recursion (ours probably does too at link-time). I'm not too worried about not generating a compile-time error for this. Because of that, I'm lowering the priority.
Thanks for the test case, though.
This should have been fixed on the 7.11 branch by:
Author: Ian Romanick <firstname.lastname@example.org>
Date: Mon Jul 11 10:46:01 2011 -0700
glsl: Reject shaders that contain static recursion
The GLSL 1.20 and later specs say:
"Recursion is not allowed, not even statically. Static recursion is
present if the static function call graph of the program contains
Recursion is detected and rejected both a compile-time and at
link-time. The complie-time check happens to detect some cases that
may be removed by various optimization passes. The spec doesn't seem
to allow this, but other vendors (e.g., NVIDIA) appear to only check
at link-time after all optimizations.
Reviewed-by: Paul Berry <email@example.com>
Reviewed-by: Eric Anholt <firstname.lastname@example.org>
Reviewed-by: Kenneth Graunke <email@example.com>
(cherry picked from commit 02c5ae1b3fef75d5c0a715313a69e6b95ebd5b95)
This also squashes in the following commit to make sure that bisects
in scons builds work:
glsl: Add ir_function_detect_recursion.cpp to SConscript.
(cherry picked from commit 76bccaff0c54aed10ffbc7c7dc744f1708921409)
on Mar 28, 2017 at 15:57:27.
(provided by the Example extension).