OSDN Git Service

nir: move GL specific passes to src/compiler/glsl
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 30 Apr 2018 10:39:43 +0000 (20:39 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 1 May 2018 02:39:33 +0000 (12:39 +1000)
With this we should have no passes in src/compiler/nir with any
dependencies on headers from core GL Mesa.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
12 files changed:
src/compiler/Makefile.sources
src/compiler/glsl/gl_nir.h [new file with mode: 0644]
src/compiler/glsl/gl_nir_lower_atomics.c [moved from src/compiler/nir/nir_lower_atomics.c with 96% similarity]
src/compiler/glsl/gl_nir_lower_samplers.c [moved from src/compiler/nir/nir_lower_samplers.c with 95% similarity]
src/compiler/glsl/gl_nir_lower_samplers_as_deref.c [moved from src/compiler/nir/nir_lower_samplers_as_deref.c with 97% similarity]
src/compiler/glsl/meson.build
src/compiler/nir/meson.build
src/compiler/nir/nir.h
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c
src/mesa/drivers/dri/i965/brw_link.cpp
src/mesa/main/glspirv.h
src/mesa/state_tracker/st_glsl_to_nir.cpp

index aca9dab..b98ea67 100644 (file)
@@ -25,6 +25,10 @@ LIBGLSL_FILES = \
        glsl/builtin_types.cpp \
        glsl/builtin_variables.cpp \
        glsl/generate_ir.cpp \
+       glsl/gl_nir_lower_atomics.c \
+       glsl/gl_nir_lower_samplers.c \
+       glsl/gl_nir_lower_samplers_as_deref.c \
+       glsl/gl_nir.h \
        glsl/glsl_parser_extras.cpp \
        glsl/glsl_parser_extras.h \
        glsl/glsl_symbol_table.cpp \
@@ -211,7 +215,6 @@ NIR_FILES = \
        nir/nir_lower_64bit_packing.c \
        nir/nir_lower_alpha_test.c \
        nir/nir_lower_alu_to_scalar.c \
-       nir/nir_lower_atomics.c \
        nir/nir_lower_atomics_to_ssbo.c \
        nir/nir_lower_bitmap.c \
        nir/nir_lower_clamp_color_outputs.c \
@@ -237,8 +240,6 @@ NIR_FILES = \
        nir/nir_lower_phis_to_scalar.c \
        nir/nir_lower_regs_to_ssa.c \
        nir/nir_lower_returns.c \
-       nir/nir_lower_samplers.c \
-       nir/nir_lower_samplers_as_deref.c \
        nir/nir_lower_subgroups.c \
        nir/nir_lower_system_values.c \
        nir/nir_lower_tex.c \
diff --git a/src/compiler/glsl/gl_nir.h b/src/compiler/glsl/gl_nir.h
new file mode 100644 (file)
index 0000000..59d5f65
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright © 2018 Timothy Arceri
+ *
+ * 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 GL_NIR_H
+#define GL_NIR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct nir_shader;
+struct gl_shader_program;
+
+bool gl_nir_lower_atomics(nir_shader *shader,
+                          const struct gl_shader_program *shader_program,
+                          bool use_binding_as_idx);
+
+bool gl_nir_lower_samplers(nir_shader *shader,
+                           const struct gl_shader_program *shader_program);
+bool gl_nir_lower_samplers_as_deref(nir_shader *shader,
+                                    const struct gl_shader_program *shader_program);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GL_NIR_H */
similarity index 96%
rename from src/compiler/nir/nir_lower_atomics.c
rename to src/compiler/glsl/gl_nir_lower_atomics.c
index 383e323..e203b39 100644 (file)
  *
  */
 
-#include "compiler/glsl/ir_uniform.h"
-#include "nir.h"
+#include "compiler/nir/nir.h"
+#include "gl_nir.h"
+#include "ir_uniform.h"
+
 #include "main/config.h"
 #include "main/mtypes.h"
 #include <assert.h>
@@ -177,9 +179,9 @@ lower_instr(nir_intrinsic_instr *instr,
 }
 
 bool
-nir_lower_atomics(nir_shader *shader,
-                  const struct gl_shader_program *shader_program,
-                  bool use_binding_as_idx)
+gl_nir_lower_atomics(nir_shader *shader,
+                     const struct gl_shader_program *shader_program,
+                     bool use_binding_as_idx)
 {
    bool progress = false;
 
similarity index 95%
rename from src/compiler/nir/nir_lower_samplers.c
rename to src/compiler/glsl/gl_nir_lower_samplers.c
index 7690665..a53fabb 100644 (file)
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "nir.h"
-#include "nir_builder.h"
-#include "compiler/glsl/ir_uniform.h"
+#include "compiler/nir/nir.h"
+#include "compiler/nir/nir_builder.h"
+#include "gl_nir.h"
+#include "ir_uniform.h"
 
 #include "main/compiler.h"
 #include "main/mtypes.h"
@@ -148,8 +149,8 @@ lower_impl(nir_function_impl *impl, const struct gl_shader_program *shader_progr
 }
 
 bool
-nir_lower_samplers(nir_shader *shader,
-                   const struct gl_shader_program *shader_program)
+gl_nir_lower_samplers(nir_shader *shader,
+                      const struct gl_shader_program *shader_program)
 {
    bool progress = false;
 
  * the opaque uniform mapping.
  */
 
-#include "nir.h"
-#include "nir_builder.h"
-#include "compiler/glsl/ir_uniform.h"
+#include "compiler/nir/nir.h"
+#include "compiler/nir/nir_builder.h"
+#include "gl_nir.h"
+#include "ir_uniform.h"
 
 #include "main/compiler.h"
 #include "main/mtypes.h"
@@ -226,8 +227,8 @@ lower_impl(nir_function_impl *impl, struct lower_samplers_as_deref_state *state)
 }
 
 bool
-nir_lower_samplers_as_deref(nir_shader *shader,
-                            const struct gl_shader_program *shader_program)
+gl_nir_lower_samplers_as_deref(nir_shader *shader,
+                               const struct gl_shader_program *shader_program)
 {
    bool progress = false;
    struct lower_samplers_as_deref_state state;
index 26ab4f1..055a847 100644 (file)
@@ -66,6 +66,10 @@ files_libglsl = files(
   'builtin_types.cpp',
   'builtin_variables.cpp',
   'generate_ir.cpp',
+  'gl_nir_lower_atomics.c',
+  'gl_nir_lower_samplers.c',
+  'gl_nir_lower_samplers_as_deref.c',
+  'gl_nir.h',
   'glsl_parser_extras.cpp',
   'glsl_parser_extras.h',
   'glsl_symbol_table.cpp',
index b28a565..84715a5 100644 (file)
@@ -106,7 +106,6 @@ files_libnir = files(
   'nir_lower_64bit_packing.c',
   'nir_lower_alu_to_scalar.c',
   'nir_lower_alpha_test.c',
-  'nir_lower_atomics.c',
   'nir_lower_atomics_to_ssbo.c',
   'nir_lower_bitmap.c',
   'nir_lower_clamp_color_outputs.c',
@@ -132,8 +131,6 @@ files_libnir = files(
   'nir_lower_phis_to_scalar.c',
   'nir_lower_regs_to_ssa.c',
   'nir_lower_returns.c',
-  'nir_lower_samplers.c',
-  'nir_lower_samplers_as_deref.c',
   'nir_lower_subgroups.c',
   'nir_lower_system_values.c',
   'nir_lower_tex.c',
index f3326e6..f8e71d5 100644 (file)
@@ -55,9 +55,6 @@
 extern "C" {
 #endif
 
-struct gl_program;
-struct gl_shader_program;
-
 #define NIR_FALSE 0u
 #define NIR_TRUE (~0u)
 
@@ -2596,11 +2593,6 @@ void nir_lower_io_arrays_to_elements_no_indirects(nir_shader *shader,
 void nir_lower_io_to_scalar(nir_shader *shader, nir_variable_mode mask);
 void nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask);
 
-bool nir_lower_samplers(nir_shader *shader,
-                        const struct gl_shader_program *shader_program);
-bool nir_lower_samplers_as_deref(nir_shader *shader,
-                                 const struct gl_shader_program *shader_program);
-
 typedef struct nir_lower_subgroups_options {
    uint8_t subgroup_size;
    uint8_t ballot_bit_size;
@@ -2755,9 +2747,6 @@ typedef struct nir_lower_bitmap_options {
 
 void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *options);
 
-bool nir_lower_atomics(nir_shader *shader,
-                       const struct gl_shader_program *shader_program,
-                       bool use_binding_as_idx);
 bool nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned ssbo_offset);
 bool nir_lower_to_source_mods(nir_shader *shader);
 
index ff1d9d1..5631216 100644 (file)
@@ -162,7 +162,7 @@ load_glsl(unsigned num_files, char* const* files, gl_shader_stage stage)
 
        NIR_PASS_V(nir, nir_lower_system_values);
        NIR_PASS_V(nir, nir_lower_io, nir_var_all, ir3_glsl_type_size, 0);
-       NIR_PASS_V(nir, nir_lower_samplers, prog);
+       NIR_PASS_V(nir, gl_nir_lower_samplers, prog);
 
        return nir;
 }
index 7841626..39fa94c 100644 (file)
@@ -24,6 +24,7 @@
 #include "brw_context.h"
 #include "compiler/brw_nir.h"
 #include "brw_program.h"
+#include "compiler/glsl/gl_nir.h"
 #include "compiler/glsl/ir.h"
 #include "compiler/glsl/ir_optimization.h"
 #include "compiler/glsl/program.h"
@@ -299,8 +300,8 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
       struct gl_program *prog = shader->Program;
       brw_shader_gather_info(prog->nir, prog);
 
-      NIR_PASS_V(prog->nir, nir_lower_samplers, shProg);
-      NIR_PASS_V(prog->nir, nir_lower_atomics, shProg, false);
+      NIR_PASS_V(prog->nir, gl_nir_lower_samplers, shProg);
+      NIR_PASS_V(prog->nir, gl_nir_lower_atomics, shProg, false);
       NIR_PASS_V(prog->nir, nir_lower_atomics_to_ssbo,
                  prog->nir->info.num_abos);
 
index cbcd3c0..8025c17 100644 (file)
@@ -30,6 +30,7 @@
 extern "C" {
 #endif
 
+struct gl_shader_program;
 struct gl_context;
 struct gl_shader;
 
index bcf6a7c..8d80c8c 100644 (file)
@@ -43,6 +43,7 @@
 #include "compiler/nir/nir.h"
 #include "compiler/glsl_types.h"
 #include "compiler/glsl/glsl_to_nir.h"
+#include "compiler/glsl/gl_nir.h"
 #include "compiler/glsl/ir.h"
 #include "compiler/glsl/string_to_uint_map.h"
 
@@ -467,7 +468,7 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
    st_set_prog_affected_state_flags(prog);
 
    NIR_PASS_V(nir, st_nir_lower_builtin);
-   NIR_PASS_V(nir, nir_lower_atomics, shader_program, true);
+   NIR_PASS_V(nir, gl_nir_lower_atomics, shader_program, true);
 
    if (st->ctx->_Shader->Flags & GLSL_DUMP) {
       _mesa_log("\n");
@@ -813,9 +814,9 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
    }
 
    if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
-      NIR_PASS_V(nir, nir_lower_samplers_as_deref, shader_program);
+      NIR_PASS_V(nir, gl_nir_lower_samplers_as_deref, shader_program);
    else
-      NIR_PASS_V(nir, nir_lower_samplers, shader_program);
+      NIR_PASS_V(nir, gl_nir_lower_samplers, shader_program);
 }
 
 } /* extern "C" */