Mesa (master): nir/scheduler: Move nir_scheduler to its own header

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 24 10:58:16 UTC 2020


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

Author: Neil Roberts <nroberts at igalia.com>
Date:   Fri Jul 17 09:08:47 2020 +0200

nir/scheduler: Move nir_scheduler to its own header

nir_schedule already has a struct for options which makes it more than
just a function declaration. Later patches intend to add more structs to
complement these options. In order to make the code easier to manage,
this moves the nir_scheduler-related parts out of nir.h to their own
header.

Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5953>

---

 src/broadcom/compiler/vir.c     |  1 +
 src/compiler/Makefile.sources   |  1 +
 src/compiler/nir/meson.build    |  1 +
 src/compiler/nir/nir.h          | 15 ------------
 src/compiler/nir/nir_schedule.c |  2 +-
 src/compiler/nir/nir_schedule.h | 52 +++++++++++++++++++++++++++++++++++++++++
 6 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 44ee75697df..6f586490d92 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -24,6 +24,7 @@
 #include "broadcom/common/v3d_device_info.h"
 #include "v3d_compiler.h"
 #include "util/u_prim.h"
+#include "compiler/nir/nir_schedule.h"
 
 int
 vir_get_nsrc(struct qinst *inst)
diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 44ece537d93..6e18c620e3e 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -339,6 +339,7 @@ NIR_FILES = \
 	nir/nir_remove_dead_variables.c \
 	nir/nir_repair_ssa.c \
 	nir/nir_schedule.c \
+	nir/nir_schedule.h \
 	nir/nir_search.c \
 	nir/nir_search.h \
 	nir/nir_search_helpers.h \
diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
index 5d34376ceac..faa141c7f95 100644
--- a/src/compiler/nir/meson.build
+++ b/src/compiler/nir/meson.build
@@ -220,6 +220,7 @@ files_libnir = files(
   'nir_remove_dead_variables.c',
   'nir_repair_ssa.c',
   'nir_schedule.c',
+  'nir_schedule.h',
   'nir_search.c',
   'nir_search.h',
   'nir_search_helpers.h',
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 9fa4c443c62..7bbf347a3b5 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -4590,21 +4590,6 @@ bool nir_opt_load_store_vectorize(nir_shader *shader, nir_variable_mode modes,
                                   nir_should_vectorize_mem_func callback,
                                   nir_variable_mode robust_modes);
 
-typedef struct nir_schedule_options {
-   /* On some hardware with some stages the inputs and outputs to the shader
-    * share the same memory. In that case scheduler needs to ensure that all
-    * output writes are scheduled after all of the input writes to avoid
-    * overwriting them. This is a bitmask of stages that need that.
-    */
-   unsigned stages_with_shared_io_memory;
-   /* The approximate amount of register pressure at which point the scheduler
-    * will try to reduce register usage.
-    */
-   int threshold;
-} nir_schedule_options;
-
-void nir_schedule(nir_shader *shader, const nir_schedule_options *options);
-
 void nir_strip(nir_shader *shader);
 
 void nir_sweep(nir_shader *shader);
diff --git a/src/compiler/nir/nir_schedule.c b/src/compiler/nir/nir_schedule.c
index 9fa02547dc1..386a515d783 100644
--- a/src/compiler/nir/nir_schedule.c
+++ b/src/compiler/nir/nir_schedule.c
@@ -21,7 +21,7 @@
  * IN THE SOFTWARE.
  */
 
-#include "nir.h"
+#include "nir_schedule.h"
 #include "util/dag.h"
 #include "util/u_dynarray.h"
 
diff --git a/src/compiler/nir/nir_schedule.h b/src/compiler/nir/nir_schedule.h
new file mode 100644
index 00000000000..030077a87c8
--- /dev/null
+++ b/src/compiler/nir/nir_schedule.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2014 Connor Abbott
+ *
+ * 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.
+ */
+
+#ifndef NIR_SCHEDULE_H
+#define NIR_SCHEDULE_H
+
+#include "nir.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct nir_schedule_options {
+   /* On some hardware with some stages the inputs and outputs to the shader
+    * share the same memory. In that case the scheduler needs to ensure that
+    * all output writes are scheduled after all of the input writes to avoid
+    * overwriting them. This is a bitmask of stages that need that.
+    */
+   unsigned stages_with_shared_io_memory;
+   /* The approximate amount of register pressure at which point the scheduler
+    * will try to reduce register usage.
+    */
+   int threshold;
+} nir_schedule_options;
+
+void nir_schedule(nir_shader *shader, const nir_schedule_options *options);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* NIR_SCHEDULE_H */



More information about the mesa-commit mailing list