intel/fs,vec4: Stuff the constant data from NIR in the end of the program
authorJason Ekstrand <jason@jlekstrand.net>
Sat, 8 Aug 2020 03:26:07 +0000 (22:26 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 2 Sep 2020 19:48:44 +0000 (19:48 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6244>

src/intel/compiler/brw_compiler.h
src/intel/compiler/brw_fs.cpp
src/intel/compiler/brw_fs.h
src/intel/compiler/brw_fs_generator.cpp
src/intel/compiler/brw_shader.cpp
src/intel/compiler/brw_vec4.cpp
src/intel/compiler/brw_vec4_generator.cpp
src/intel/compiler/brw_vec4_gs_visitor.cpp
src/intel/compiler/brw_vec4_tcs.cpp

index 8df2ee59207b7a98a26625e80ef92baffbd6e063..679a78723fe9e5577a2642d405373823e306b207 100644 (file)
@@ -685,6 +685,9 @@ struct brw_stage_prog_data {
 
    unsigned program_size;
 
+   unsigned const_data_size;
+   unsigned const_data_offset;
+
    /** Does this program pull from any UBO or other constant buffers? */
    bool has_ubo_pull;
 
index 388fd8dec286d03e267eada3a3a4dccdddb580ac..460a36587a1ba3d167cd8b50853a23cdf6acc9ac 100644 (file)
@@ -8784,6 +8784,8 @@ brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
       stats = stats ? stats + 1 : NULL;
    }
 
+   g.add_const_data(shader->constant_data, shader->constant_data_size);
+
    delete v8;
    delete v16;
    delete v32;
@@ -9167,6 +9169,8 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data,
                       v->performance_analysis.require(), stats);
    }
 
+   g.add_const_data(src_shader->constant_data, src_shader->constant_data_size);
+
    ret = g.get_assembly();
 
    delete v8;
index c24438a737e57707a157e860379a34ee012b318e..0843f6e73fc5b2b79785c501e7bccc26b2763e89 100644 (file)
@@ -478,6 +478,7 @@ public:
                      struct shader_stats shader_stats,
                      const brw::performance &perf,
                      struct brw_compile_stats *stats);
+   void add_const_data(void *data, unsigned size);
    const unsigned *get_assembly();
 
 private:
index df357440d495cad69e3cb4c52094635cf6089c81..74c6cd3047411a7f9a113622e1acb0063e16f954 100644 (file)
@@ -2595,6 +2595,16 @@ fs_generator::generate_code(const cfg_t *cfg, int dispatch_width,
    return start_offset;
 }
 
+void
+fs_generator::add_const_data(void *data, unsigned size)
+{
+   assert(prog_data->const_data_size == 0);
+   if (size > 0) {
+      prog_data->const_data_size = size;
+      prog_data->const_data_offset = brw_append_data(p, data, size, 32);
+   }
+}
+
 const unsigned *
 fs_generator::get_assembly()
 {
index e78f2cbe50a67f94d842483ca9eb39fafeea8d9a..3219a01e60a82a3fc611a5a3eb25c3ee905ae35f 100644 (file)
@@ -1374,6 +1374,8 @@ brw_compile_tes(const struct brw_compiler *compiler,
       g.generate_code(v.cfg, 8, v.shader_stats,
                       v.performance_analysis.require(), stats);
 
+      g.add_const_data(nir->constant_data, nir->constant_data_size);
+
       assembly = g.get_assembly();
    } else {
       brw::vec4_tes_visitor v(compiler, log_data, key, prog_data,
index 864ece7e636fb8221b2111b59a5777e306d87e80..fe7db43066dc6d190a56478448919fc9b2cf6e9e 100644 (file)
@@ -3001,6 +3001,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void *log_data,
       }
       g.generate_code(v.cfg, 8, v.shader_stats,
                       v.performance_analysis.require(), stats);
+      g.add_const_data(shader->constant_data, shader->constant_data_size);
       assembly = g.get_assembly();
    }
 
index 43fcdf70ff06576db7bdc170fc84712baf507c58..e9142c2c65c0270ae46dbbec9bd794fe8dbfd6bb 100644 (file)
@@ -2281,5 +2281,12 @@ brw_vec4_generate_assembly(const struct brw_compiler *compiler,
 
    generate_code(p, compiler, log_data, nir, prog_data, cfg, perf, stats);
 
+   assert(prog_data->base.const_data_size == 0);
+   if (nir->constant_data_size > 0) {
+      prog_data->base.const_data_size = nir->constant_data_size;
+      prog_data->base.const_data_offset =
+         brw_append_data(p, nir->constant_data, nir->constant_data_size, 32);
+   }
+
    return brw_get_program(p, &prog_data->base.program_size);
 }
index 58f6f1212ac0758a85480948bc212469c57b5857..b286bfd96454d5e6df3d44fb63b4d6df08f7ff86 100644 (file)
@@ -867,6 +867,7 @@ brw_compile_gs(const struct brw_compiler *compiler, void *log_data,
          }
          g.generate_code(v.cfg, 8, v.shader_stats,
                          v.performance_analysis.require(), stats);
+         g.add_const_data(shader->constant_data, shader->constant_data_size);
          return g.get_assembly();
       }
    }
index e9a6880cfbe46f21cb4c5a4cb080b75a5b3d698d..29c0d9e63d7c9c56498ecd407e7e25587f2d654c 100644 (file)
@@ -483,6 +483,8 @@ brw_compile_tcs(const struct brw_compiler *compiler,
       g.generate_code(v.cfg, 8, v.shader_stats,
                       v.performance_analysis.require(), stats);
 
+      g.add_const_data(nir->constant_data, nir->constant_data_size);
+
       assembly = g.get_assembly();
    } else {
       vec4_tcs_visitor v(compiler, log_data, key, prog_data,