Mesa (master): glsl: Add comments to lower_jumps (from the commit message).

Kenneth Graunke kwg at kemper.freedesktop.org
Wed Dec 1 19:56:37 UTC 2010


Module: Mesa
Branch: master
Commit: d2d7a273c51127677d394d1bb9484a2d85c5dcd2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d2d7a273c51127677d394d1bb9484a2d85c5dcd2

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Mon Nov 29 11:00:10 2010 -0800

glsl: Add comments to lower_jumps (from the commit message).

This is essentially Luca's commit message, but placed at the top of the
file.

---

 src/glsl/lower_jumps.cpp |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/glsl/lower_jumps.cpp b/src/glsl/lower_jumps.cpp
index beacfaf..9cd15ef 100644
--- a/src/glsl/lower_jumps.cpp
+++ b/src/glsl/lower_jumps.cpp
@@ -23,6 +23,37 @@
 
 /**
  * \file lower_jumps.cpp
+ *
+ * This pass lowers jumps (break, continue, and return) to if/else structures.
+ *
+ * It can be asked to:
+ * 1. Pull jumps out of ifs where possible
+ * 2. Remove all "continue"s, replacing them with an "execute flag"
+ * 3. Replace all "break" with a single conditional one at the end of the loop
+ * 4. Replace all "return"s with a single return at the end of the function,
+ *    for the main function and/or other functions
+ *
+ * Applying this pass gives several benefits:
+ * 1. All functions can be inlined.
+ * 2. nv40 and other pre-DX10 chips without "continue" can be supported
+ * 3. nv30 and other pre-DX10 chips with no control flow at all are better
+ *    supported
+ *
+ * Continues are lowered by adding a per-loop "execute flag", initialized to
+ * true, that when cleared inhibits all execution until the end of the loop.
+ *
+ * Breaks are lowered to continues, plus setting a "break flag" that is checked
+ * at the end of the loop, and trigger the unique "break".
+ *
+ * Returns are lowered to breaks/continues, plus adding a "return flag" that
+ * causes loops to break again out of their enclosing loops until all the
+ * loops are exited: then the "execute flag" logic will ignore everything
+ * until the end of the function.
+ *
+ * Note that "continue" and "return" can also be implemented by adding
+ * a dummy loop and using break.
+ * However, this is bad for hardware with limited nesting depth, and
+ * prevents further optimization, and thus is not currently performed.
  */
 
 #include "glsl_types.h"




More information about the mesa-commit mailing list