Mesa (master): pan/mdg: Explain helper invocations dataflow theory

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 12 22:54:14 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Mon May 11 20:05:24 2020 -0400

pan/mdg: Explain helper invocations dataflow theory

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5014>

---

 src/panfrost/midgard/midgard_helper_invocations.c | 63 +++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/src/panfrost/midgard/midgard_helper_invocations.c b/src/panfrost/midgard/midgard_helper_invocations.c
new file mode 100644
index 00000000000..32bcbd4d823
--- /dev/null
+++ b/src/panfrost/midgard/midgard_helper_invocations.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2019 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors (Collabora):
+ *    Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
+ */
+
+#include "compiler.h"
+
+/* Midgard texture/derivative operations have a pair of bits controlling the
+ * behaviour of helper invocations:
+ *
+ *  - Should a helper invocation terminate after executing this instruction?
+ *  - Should a helper invocation actually execute this instruction?
+ *
+ * The terminate bit should be set on the last instruction requiring helper
+ * invocations. Without control flow, that's literally the last instruction;
+ * with control flow, there may be multiple such instructions (with ifs) or no
+ * such instruction (with loops).
+ *
+ * The execute bit should be set if the value of this instruction is required
+ * by a future instruction requiring helper invocations. Consider:
+ *
+ *      0 = texture ...
+ *      1 = fmul 0, #10
+ *      2 = dfdx 1
+ *      store 2
+ *
+ * Since the derivative calculation 2 requires helper invocations, the value 1
+ * must be calculated by helper invocations, and since it depends on 0, 0 must
+ * be calculated by helpers. Hence the texture op has the execute bit set, and
+ * the derivative op has the terminate bit set.
+ *
+ * Calculating the terminate bit occurs by forward dataflow analysis to
+ * determine which blocks require helper invocations. A block requires
+ * invocations in if any of its instructions use helper invocations, or if it
+ * depends on a block that requires invocation. With that analysis, the
+ * terminate bit is set on the last instruction using invocations within any
+ * block that does *not* require invocations out.
+ *
+ * Likewise, calculating the execute bit requires backward dataflow analysis
+ * with union as the join operation and the generating set being the union of
+ * sources of instructions writing executed values.
+ */



More information about the mesa-commit mailing list